Remove Attribute system (#725)

* AirJump, Attribute continuation

* Remove AirJump

* Revert "Remove AirJump"

This reverts commit e6cf056bb746d70643931f523f163aea1738b482.

* Revert "AirJump, Attribute continuation"

This reverts commit b8198d7eaff34b089fb0ec1003e4b766503cb0ae.

* Remove Attribute to redesign
This commit is contained in:
Simplicitee 2017-02-10 22:53:47 -05:00 committed by Christopher Martin
parent 477d02c673
commit b2fcfc493a
11 changed files with 76 additions and 283 deletions

View file

@ -29,7 +29,6 @@ import com.projectkorra.projectkorra.util.MetricsLite;
import com.projectkorra.projectkorra.util.RevertChecker; import com.projectkorra.projectkorra.util.RevertChecker;
import com.projectkorra.projectkorra.util.TempBlock; import com.projectkorra.projectkorra.util.TempBlock;
import com.projectkorra.projectkorra.util.Updater; import com.projectkorra.projectkorra.util.Updater;
import com.projectkorra.projectkorra.util.attributes.AttributeModifiers;
import com.projectkorra.projectkorra.util.logging.PKLogHandler; import com.projectkorra.projectkorra.util.logging.PKLogHandler;
import com.projectkorra.projectkorra.waterbending.util.WaterbendingManager; import com.projectkorra.projectkorra.waterbending.util.WaterbendingManager;
@ -70,7 +69,6 @@ public class ProjectKorra extends JavaPlugin {
CoreAbility.registerAbilities(); CoreAbility.registerAbilities();
collisionInitializer.initializeDefaultCollisions(); // must be called after abilities have been registered collisionInitializer.initializeDefaultCollisions(); // must be called after abilities have been registered
collisionManager.startCollisionDetection(); collisionManager.startCollisionDetection();
new AttributeModifiers();
Preset.loadExternalPresets(); Preset.loadExternalPresets();

View file

@ -40,7 +40,6 @@ import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.event.AbilityEndEvent; import com.projectkorra.projectkorra.event.AbilityEndEvent;
import com.projectkorra.projectkorra.event.AbilityProgressEvent; import com.projectkorra.projectkorra.event.AbilityProgressEvent;
import com.projectkorra.projectkorra.event.AbilityStartEvent; import com.projectkorra.projectkorra.event.AbilityStartEvent;
import com.projectkorra.projectkorra.util.Attribute.Attributable;
import sun.reflect.ReflectionFactory; import sun.reflect.ReflectionFactory;
@ -492,11 +491,6 @@ public abstract class CoreAbility implements Ability {
AddonAbility addon = (AddonAbility) ability; AddonAbility addon = (AddonAbility) ability;
addon.load(); addon.load();
} }
if (ability instanceof Attributable) {
Attributable att = (Attributable) ability;
att.registerAttributes();
}
} }
catch (Exception e) { catch (Exception e) {
} }
@ -571,12 +565,6 @@ public abstract class CoreAbility implements Ability {
PassiveManager.getPassivesByElement().get(((SubElement) coreAbil.getElement()).getParentElement()).add(name); PassiveManager.getPassivesByElement().get(((SubElement) coreAbil.getElement()).getParentElement()).add(name);
} }
} }
if (coreAbil instanceof Attributable) {
Attributable att = (Attributable) coreAbil;
att.registerAttributes();
}
} }
catch (Exception | Error e) { catch (Exception | Error e) {
plugin.getLogger().warning("The ability " + coreAbil.getName() + " was not able to load, if this message shows again please remove it!"); plugin.getLogger().warning("The ability " + coreAbil.getName() + " was not able to load, if this message shows again please remove it!");

View file

@ -29,12 +29,10 @@ import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.ability.util.Collision; import com.projectkorra.projectkorra.ability.util.Collision;
import com.projectkorra.projectkorra.command.Commands; import com.projectkorra.projectkorra.command.Commands;
import com.projectkorra.projectkorra.object.HorizontalVelocityTracker; import com.projectkorra.projectkorra.object.HorizontalVelocityTracker;
import com.projectkorra.projectkorra.util.Attribute;
import com.projectkorra.projectkorra.util.Attribute.Attributable;
import com.projectkorra.projectkorra.util.DamageHandler; import com.projectkorra.projectkorra.util.DamageHandler;
import com.projectkorra.projectkorra.util.Flight; import com.projectkorra.projectkorra.util.Flight;
public class AirBlast extends AirAbility implements Attributable{ public class AirBlast extends AirAbility {
private static final int MAX_TICKS = 10000; private static final int MAX_TICKS = 10000;
private static final Map<Player, Location> ORIGINS = new ConcurrentHashMap<>(); private static final Map<Player, Location> ORIGINS = new ConcurrentHashMap<>();
@ -46,9 +44,15 @@ public class AirBlast extends AirAbility implements Attributable{
private boolean isFromOtherOrigin; private boolean isFromOtherOrigin;
private boolean showParticles; private boolean showParticles;
private int ticks; private int ticks;
int particles; private int particles;
long cooldown; private long cooldown;
double speedFactor, range, pushFactor, pushFactorForOthers, damage, speed, radius; private double speedFactor;
private double range;
private double pushFactor;
private double pushFactorForOthers;
private double damage;
private double speed;
private double radius;
private Location location; private Location location;
private Location origin; private Location origin;
private Vector direction; private Vector direction;
@ -56,14 +60,6 @@ public class AirBlast extends AirAbility implements Attributable{
private Random random; private Random random;
private ArrayList<Block> affectedLevers; private ArrayList<Block> affectedLevers;
private ArrayList<Entity> affectedEntities; private ArrayList<Entity> affectedEntities;
private static Attribute<Integer> particlesA;
private static Attribute<Long> cooldownA;
private static Attribute<Double> rangeA;
private static Attribute<Double> pushFactorA;
private static Attribute<Double> pushFactorForOthersA;
private static Attribute<Double> damageA;
private static Attribute<Double> speedA;
private static Attribute<Double> radiusA;
public AirBlast(Player player) { public AirBlast(Player player) {
super(player); super(player);
@ -115,18 +111,23 @@ public class AirBlast extends AirAbility implements Attributable{
this.canPressButtons = false; this.canPressButtons = false;
this.canFlickLevers = false; this.canFlickLevers = false;
if (bPlayer.isAvatarState()) {
this.pushFactor = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirBlast.Push.Entities");
this.pushFactorForOthers = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirBlast.Push.Self");
}
start(); start();
} }
private void setFields() { private void setFields() {
this.particles = particlesA.getModified(bPlayer); this.particles = getConfig().getInt("Abilities.Air.AirBlast.Particles");
this.cooldown = cooldownA.getModified(bPlayer); this.cooldown = getConfig().getLong("Abilities.Air.AirBlast.Cooldown");
this.range = rangeA.getModified(bPlayer); this.range = getConfig().getDouble("Abilities.Air.AirBlast.Range");
this.damage = damageA.getModified(bPlayer); this.speed = getConfig().getDouble("Abilities.Air.AirBlast.Speed");
this.speed = speedA.getModified(bPlayer); this.range = getConfig().getDouble("Abilities.Air.AirBlast.Range");
this.radius = radiusA.getModified(bPlayer); this.radius = getConfig().getDouble("Abilities.Air.AirBlast.Radius");
this.pushFactor = pushFactorA.getModified(bPlayer); this.pushFactor = getConfig().getDouble("Abilities.Air.AirBlast.Push.Entities");
this.pushFactorForOthers = pushFactorForOthersA.getModified(bPlayer); this.pushFactorForOthers = getConfig().getDouble("Abilities.Air.AirBlast.Push.Self");
this.canFlickLevers = getConfig().getBoolean("Abilities.Air.AirBlast.CanFlickLevers"); this.canFlickLevers = getConfig().getBoolean("Abilities.Air.AirBlast.CanFlickLevers");
this.canOpenDoors = getConfig().getBoolean("Abilities.Air.AirBlast.CanOpenDoors"); this.canOpenDoors = getConfig().getBoolean("Abilities.Air.AirBlast.CanOpenDoors");
this.canPressButtons = getConfig().getBoolean("Abilities.Air.AirBlast.CanPressButtons"); this.canPressButtons = getConfig().getBoolean("Abilities.Air.AirBlast.CanPressButtons");
@ -638,16 +639,4 @@ public class AirBlast extends AirAbility implements Attributable{
return getConfig().getInt("Abilities.Air.AirBlast.SelectRange"); return getConfig().getInt("Abilities.Air.AirBlast.SelectRange");
} }
@Override
public void registerAttributes() {
particlesA = new Attribute<Integer>(this, "particles", getConfig().getInt("Abilities.Air.AirBlast.Particles"));
cooldownA = new Attribute<Long>(this, "cooldown", getConfig().getLong("Abilities.Air.AirBlast.Cooldown"));
rangeA = new Attribute<Double>(this, "range", getConfig().getDouble("Abilities.Air.AirBlast.Range"));
pushFactorA = new Attribute<Double>(this, "pushFactor", getConfig().getDouble("Abilities.Air.AirBlast.Push.Self"));
pushFactorForOthersA = new Attribute<Double>(this, "pushFactorForOthers", getConfig().getDouble("Abilities.Air.AirBlast.Push.Entities"));
damageA = new Attribute<Double>(this, "damage", getConfig().getDouble("Abilities.Air.AirBlast.Damage"));
speedA = new Attribute<Double>(this, "speed", getConfig().getDouble("Abilities.Air.AirBlast.Speed"));
radiusA = new Attribute<Double>(this, "radius", getConfig().getDouble("Abilities.Air.AirBlast.Radius"));
}
} }

View file

@ -14,26 +14,22 @@ import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.Element; import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ability.AirAbility; import com.projectkorra.projectkorra.ability.AirAbility;
import com.projectkorra.projectkorra.util.Attribute;
import com.projectkorra.projectkorra.util.Attribute.Attributable;
import com.projectkorra.projectkorra.waterbending.WaterManipulation; import com.projectkorra.projectkorra.waterbending.WaterManipulation;
public class AirBubble extends AirAbility implements Attributable{ public class AirBubble extends AirAbility {
private boolean waterBubble; private boolean waterBubble;
private double radius; private double radius;
private double airRadius; private double airRadius;
private double waterRadius; private double waterRadius;
private Map<Block, BlockState> waterOrigins; private Map<Block, BlockState> waterOrigins;
private static Attribute<Double> airRadiusA;
private static Attribute<Double> waterRadiusA;
public AirBubble(Player player) { public AirBubble(Player player) {
super(player); super(player);
this.radius = 0; this.radius = 0;
this.airRadius = airRadiusA.getModified(bPlayer); this.airRadius = getConfig().getDouble("Abilities.Air.AirBubble.Radius");
this.waterRadius = waterRadiusA.getModified(bPlayer); this.waterRadius = getConfig().getDouble("Abilities.Water.WaterBubble.Radius");
this.waterOrigins = new ConcurrentHashMap<>(); this.waterOrigins = new ConcurrentHashMap<>();
start(); start();
} }
@ -210,10 +206,4 @@ public class AirBubble extends AirAbility implements Attributable{
return waterOrigins; return waterOrigins;
} }
@Override
public void registerAttributes() {
airRadiusA = new Attribute<Double>(this, "airRadius", getConfig().getDouble("Abilities.Air.AirBubble.Radius"));
waterRadiusA = new Attribute<Double>(this, "waterRadius", getConfig().getDouble("Abilities.Water.WaterBubble.Radius"));
}
} }

View file

@ -11,10 +11,8 @@ import org.bukkit.util.Vector;
import com.projectkorra.projectkorra.ProjectKorra; import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.ability.AirAbility; import com.projectkorra.projectkorra.ability.AirAbility;
import com.projectkorra.projectkorra.util.Attribute;
import com.projectkorra.projectkorra.util.Attribute.Attributable;
public class AirBurst extends AirAbility implements Attributable{ public class AirBurst extends AirAbility {
private boolean isCharged; private boolean isCharged;
private boolean isFallBurst; private boolean isFallBurst;
@ -29,12 +27,6 @@ public class AirBurst extends AirAbility implements Attributable{
private double particlePercentage; private double particlePercentage;
private ArrayList<AirBlast> blasts; private ArrayList<AirBlast> blasts;
private ArrayList<Entity> affectedEntities; private ArrayList<Entity> affectedEntities;
private static Attribute<Long> chargeTimeA;
private static Attribute<Double> fallThresholdA;
private static Attribute<Double> pushFactorA;
private static Attribute<Double> damageA;
private static Attribute<Double> blastAngleThetaA;
private static Attribute<Double> blastAnglePhiA;
public AirBurst(Player player, boolean isFallBurst) { public AirBurst(Player player, boolean isFallBurst) {
super(player); super(player);
@ -51,17 +43,21 @@ public class AirBurst extends AirAbility implements Attributable{
this.isFallBurst = isFallBurst; this.isFallBurst = isFallBurst;
this.isCharged = false; this.isCharged = false;
this.playerFallDistance = player.getFallDistance(); this.playerFallDistance = player.getFallDistance();
this.chargeTime = chargeTimeA.getModified(bPlayer); this.chargeTime = getConfig().getLong("Abilities.Air.AirBurst.ChargeTime");
this.fallThreshold = fallThresholdA.getModified(bPlayer); this.fallThreshold = getConfig().getDouble("Abilities.Air.AirBurst.FallThreshold");
this.pushFactor = pushFactorA.getModified(bPlayer); this.pushFactor = getConfig().getDouble("Abilities.Air.AirBurst.PushFactor");
this.damage = damageA.getModified(bPlayer); this.damage = getConfig().getDouble("Abilities.Air.AirBurst.Damage");
this.blastAnglePhi = blastAnglePhiA.getModified(bPlayer); this.blastAnglePhi = getConfig().getDouble("Abilities.Air.AirBurst.AnglePhi");
this.blastAngleTheta = blastAngleThetaA.getModified(bPlayer); this.blastAngleTheta = getConfig().getDouble("Abilities.Air.AirBurst.AngleTheta");
this.sneakParticles = getConfig().getInt("Abilities.Air.AirBurst.SneakParticles"); this.sneakParticles = getConfig().getInt("Abilities.Air.AirBurst.SneakParticles");
this.particlePercentage = getConfig().getDouble("Abilities.Air.AirBurst.ParticlePercentage"); this.particlePercentage = getConfig().getDouble("Abilities.Air.AirBurst.ParticlePercentage");
this.blasts = new ArrayList<>(); this.blasts = new ArrayList<>();
this.affectedEntities = new ArrayList<>(); this.affectedEntities = new ArrayList<>();
if (bPlayer.isAvatarState()) {
this.chargeTime = getConfig().getLong("Abilities.Avatar.AvatarState.Air.AirBurst.ChargeTime");
this.damage = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirBurst.Damage");
}
start(); start();
} }
@ -319,14 +315,4 @@ public class AirBurst extends AirAbility implements Attributable{
public ArrayList<Entity> getAffectedEntities() { public ArrayList<Entity> getAffectedEntities() {
return affectedEntities; return affectedEntities;
} }
@Override
public void registerAttributes() {
chargeTimeA = new Attribute<Long>(this, "chargeTime", getConfig().getLong("Abilities.Air.AirBurst.ChargeTime"));
fallThresholdA = new Attribute<Double>(this, "fallThreshold", getConfig().getDouble("Abilities.Air.AirBurst.FallThreshold"));
pushFactorA = new Attribute<Double>(this, "pushFactor", getConfig().getDouble("Abilities.Air.AirBurst.PushFactor"));
damageA = new Attribute<Double>(this, "damage", getConfig().getDouble("Abilities.Air.AirBurst.Damage"));
blastAngleThetaA = new Attribute<Double>(this, "blastAngleTheta", getConfig().getDouble("Abilities.Air.AirBlast.AngleTheta"));
blastAnglePhiA = new Attribute<Double>(this, "blastAnglePhi", getConfig().getDouble("Abilities.Air.AirBlast.AnglePhi"));
}
} }

View file

@ -1,5 +1,6 @@
package com.projectkorra.projectkorra.airbending; package com.projectkorra.projectkorra.airbending;
import java.util.ArrayList;
import java.util.Random; import java.util.Random;
import org.bukkit.Location; import org.bukkit.Location;
@ -12,28 +13,22 @@ import org.bukkit.util.Vector;
import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ability.AirAbility; import com.projectkorra.projectkorra.ability.AirAbility;
import com.projectkorra.projectkorra.ability.WaterAbility; import com.projectkorra.projectkorra.ability.WaterAbility;
import com.projectkorra.projectkorra.util.Attribute;
import com.projectkorra.projectkorra.util.Attribute.Attributable;
import com.projectkorra.projectkorra.util.Flight; import com.projectkorra.projectkorra.util.Flight;
public class AirScooter extends AirAbility implements Attributable{ public class AirScooter extends AirAbility {
private double speed; private double speed;
private double interval; private double interval;
private double radius; private double radius;
private long cooldown; private long cooldown;
private double maxHeightFromGround; private double maxHeightFromGround;
private static Attribute<Double> speedA;
private static Attribute<Double> intervalA;
private static Attribute<Double> radiusA;
private static Attribute<Long> cooldownA;
private static Attribute<Double> heightA;
private Block floorblock; private Block floorblock;
private Random random; private Random random;
private double phi = 0; private ArrayList<Double> angles;
private boolean canFly; private boolean canFly;
private boolean hadFly; private boolean hadFly;
private double phi = 0;
public AirScooter(Player player) { public AirScooter(Player player) {
super(player); super(player);
@ -47,12 +42,13 @@ public class AirScooter extends AirAbility implements Attributable{
else if (bPlayer.isOnCooldown(this)) else if (bPlayer.isOnCooldown(this))
return; return;
this.speed = speedA.getModified(bPlayer); this.speed = getConfig().getDouble("Abilities.Air.AirScooter.Speed");
this.interval = intervalA.getModified(bPlayer); this.interval = getConfig().getDouble("Abilities.Air.AirScooter.Interval");
this.radius = radiusA.getModified(bPlayer); this.radius = getConfig().getDouble("Abilities.Air.AirScooter.Radius");
this.cooldown = cooldownA.getModified(bPlayer); this.cooldown = getConfig().getLong("Abilities.Air.AirScooter.Cooldown");
this.maxHeightFromGround = heightA.getModified(bPlayer); this.maxHeightFromGround = getConfig().getDouble("Abilities.Air.AirScooter.MaxHeightFromGround");
this.random = new Random(); this.random = new Random();
this.angles = new ArrayList<>();
canFly = player.getAllowFlight(); canFly = player.getAllowFlight();
hadFly = player.isFlying(); hadFly = player.isFlying();
@ -63,6 +59,10 @@ public class AirScooter extends AirAbility implements Attributable{
player.setSprinting(false); player.setSprinting(false);
player.setSneaking(false); player.setSneaking(false);
for (int i = 0; i < 5; i++) {
angles.add((double) (60 * i));
}
start(); start();
} }
@ -109,7 +109,7 @@ public class AirScooter extends AirAbility implements Attributable{
} }
Vector velocity = player.getEyeLocation().getDirection().clone().normalize(); Vector velocity = player.getEyeLocation().getDirection().clone().normalize();
velocity = velocity.multiply(speed); velocity = velocity.clone().normalize().multiply(speed);
/* /*
* checks the players speed and ends the move if they are going too slow * checks the players speed and ends the move if they are going too slow
*/ */
@ -125,10 +125,11 @@ public class AirScooter extends AirAbility implements Attributable{
* lowers the player based on their distance from the ground. * lowers the player based on their distance from the ground.
*/ */
double distance = player.getLocation().getY() - (double) floorblock.getY(); double distance = player.getLocation().getY() - (double) floorblock.getY();
if (distance > 2.355) { double dx = Math.abs(distance - 2.4);
velocity.setY(-0.15); if (distance > 2.75) {
} else if (distance < 1.9) { velocity.setY(-.40 * dx * dx);
velocity.setY(0.15); } else if (distance < 2) {
velocity.setY(.40 * dx * dx);
} else { } else {
velocity.setY(0); velocity.setY(0);
} }
@ -141,14 +142,17 @@ public class AirScooter extends AirAbility implements Attributable{
velocity.add(new Vector(0, 0.6, 0)); velocity.add(new Vector(0, 0.6, 0));
} }
if (WaterAbility.isWater(player.getLocation().getBlock())) { Location loc = player.getLocation();
remove(); if (!WaterAbility.isWater(player.getLocation().add(0, 2, 0).getBlock())) {
loc.setY((double) floorblock.getY() + 1.5);
} else {
return; return;
} }
player.setSprinting(false); player.setSprinting(false);
player.removePotionEffect(PotionEffectType.SPEED); player.removePotionEffect(PotionEffectType.SPEED);
player.setVelocity(velocity); player.setVelocity(velocity);
if (random.nextInt(4) == 0) { if (random.nextInt(4) == 0) {
playAirbendingSound(player.getLocation()); playAirbendingSound(player.getLocation());
} }
@ -165,9 +169,13 @@ public class AirScooter extends AirAbility implements Attributable{
bPlayer.addCooldown(this); bPlayer.addCooldown(this);
} }
/*
* The particles used for AirScooter phi = how many rings of particles the
* sphere has. theta = how dense the rings are. r = Radius of the sphere
*/
private void spinScooter() { private void spinScooter() {
Location origin = player.getLocation().clone(); Location origin = player.getLocation();
Location origin2 = player.getLocation().clone(); Location origin2 = player.getLocation();
phi += Math.PI / 10 * 4; phi += Math.PI / 10 * 4;
for (double theta = 0; theta <= 2 * Math.PI; theta += Math.PI / 10) { for (double theta = 0; theta <= 2 * Math.PI; theta += Math.PI / 10) {
double r = 0.6; double r = 0.6;
@ -186,7 +194,7 @@ public class AirScooter extends AirAbility implements Attributable{
origin2.subtract(x, y, z); origin2.subtract(x, y, z);
playAirbendingParticles(origin2, 1, 0F, 0F, 0F); playAirbendingParticles(origin2, 1, 0F, 0F, 0F);
origin2.add(x, y, z); origin2.add(x, y, z);
} }
} }
@Override @Override
@ -262,13 +270,4 @@ public class AirScooter extends AirAbility implements Attributable{
public void setCooldown(long cooldown) { public void setCooldown(long cooldown) {
this.cooldown = cooldown; this.cooldown = cooldown;
} }
@Override
public void registerAttributes() {
speedA = new Attribute<Double>(this, "speed", getConfig().getDouble("Abilities.Air.AirScooter.Speed"));
intervalA = new Attribute<Double>(this, "interval", getConfig().getDouble("Abilities.Air.AirScooter.Interval"));
radiusA = new Attribute<Double>(this, "radius", getConfig().getDouble("Abilities.Air.AirScooter.Radius"));
heightA = new Attribute<Double>(this, "height", getConfig().getDouble("Abilities.Air.AirScooter.MaxHeightFromGround"));
cooldownA = new Attribute<Long>(this, "cooldown", getConfig().getLong("Abilities.Air.AirScooter.Cooldown"));
}
} }

View file

@ -556,8 +556,8 @@ public class ConfigManager {
config.addDefault("Abilities.Avatar.AvatarState.Air.AirBlast.Push.Entities", 4.5); config.addDefault("Abilities.Avatar.AvatarState.Air.AirBlast.Push.Entities", 4.5);
config.addDefault("Abilities.Avatar.AvatarState.Air.AirBlast.Push.Self", 4.0); config.addDefault("Abilities.Avatar.AvatarState.Air.AirBlast.Push.Self", 4.0);
config.addDefault("Abilities.Avatar.AvatarState.Air.AirSpout.Height", 26); config.addDefault("Abilities.Avatar.AvatarState.AirSpout.Height", 26);
config.addDefault("Abilities.Avatar.AvatarState.Air.AirSuction.Push", 3.5); config.addDefault("Abilities.Avatar.AvatarState.AirSuction.Push", 3.5);
config.addDefault("Abilities.Avatar.AvatarState.Air.AirSwipe.Cooldown", 1000); config.addDefault("Abilities.Avatar.AvatarState.Air.AirSwipe.Cooldown", 1000);
config.addDefault("Abilities.Avatar.AvatarState.Air.AirSwipe.Damage", 4.5); config.addDefault("Abilities.Avatar.AvatarState.Air.AirSwipe.Damage", 4.5);
config.addDefault("Abilities.Avatar.AvatarState.Air.AirSwipe.Push", 1.0); config.addDefault("Abilities.Avatar.AvatarState.Air.AirSwipe.Push", 1.0);

View file

@ -1,90 +0,0 @@
package com.projectkorra.projectkorra.util;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.ability.CoreAbility;
public class Attribute<TYPE> {
private static Map<CoreAbility, Map<String, Attribute<? extends Object>>> attributes = new HashMap<>();
public List<AttributeModifier<TYPE>> modifiers;
public CoreAbility ability;
public String name;
public TYPE value;
public Attribute(CoreAbility ability, String name, TYPE value) {
this(ability, name, value, new ArrayList<AttributeModifier<TYPE>>());
}
public Attribute(CoreAbility ability, String name, TYPE value, List<AttributeModifier<TYPE>> modifiers) {
this.ability = ability;
this.name = name;
this.value = value;
if (!attributes.containsKey(ability)) {
attributes.put(ability, new HashMap<String, Attribute<? extends Object>>());
}
attributes.get(ability).put(name.toLowerCase(), this);
this.modifiers = new ArrayList<AttributeModifier<TYPE>>(modifiers);
}
public List<AttributeModifier<TYPE>> getModifiers() {
return modifiers;
}
public void addModifier(AttributeModifier<TYPE> modifier) {
modifiers.add(modifier);
}
public CoreAbility getAbility() {
return ability;
}
public String getName() {
return name;
}
public TYPE getDefault() {
return value;
}
public TYPE getModified(BendingPlayer bPlayer) {
TYPE modified = value;
for (AttributeModifier<TYPE> modifier : modifiers) {
if (!modifier.canModify(bPlayer)) {
continue;
}
value = modifier.newValue(value);
}
return modified;
}
public static Attribute<? extends Object> get(CoreAbility ability, String name) {
Map<String, Attribute<? extends Object>> map = attributes.containsKey(ability) ? attributes.get(ability) : new HashMap<String, Attribute<? extends Object>>();
if (map.isEmpty()) {
return null;
}
if (map.containsKey(name.toLowerCase())) {
return map.get(name.toLowerCase());
}
return null;
}
public interface AttributeModifier<TYPE> {
public boolean canModify(BendingPlayer bPlayer);
public TYPE newValue(TYPE value);
}
public interface Attributable {
/**
* Registers the {@link Attribute} objects the ability has
*/
public void registerAttributes();
}
}

View file

@ -30,11 +30,11 @@ public enum ClickType {
*/ */
RIGHT_CLICK_BLOCK, RIGHT_CLICK_BLOCK,
/** /**
* The shift key being released. * The shift key being pressed.
*/ */
SHIFT_DOWN, SHIFT_DOWN,
/** /**
* The shift key being pressed. * The shift key being released.
*/ */
SHIFT_UP; SHIFT_UP;
} }

View file

@ -1,49 +0,0 @@
package com.projectkorra.projectkorra.util.attributes;
import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.airbending.AirBlast;
import com.projectkorra.projectkorra.airbending.AirBurst;
import com.projectkorra.projectkorra.configuration.ConfigManager;
import com.projectkorra.projectkorra.util.Attribute;
public class AttributeModifiers {
public AttributeModifiers() {
load();
}
@SuppressWarnings("unchecked")
public void load() {
Attribute<Double> airBlastPushSelf = (Attribute<Double>) Attribute.get(CoreAbility.getAbility(AirBlast.class), "pushFactor");
airBlastPushSelf.addModifier(new AvatarStateModifier<Double>() {
@Override
public Double newValue(Double value) {
return ConfigManager.getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirBlast.Push.Self");
}
});
Attribute<Double> airBlastPushOthers = (Attribute<Double>) Attribute.get(CoreAbility.getAbility(AirBlast.class), "pushFactorForOthers");
airBlastPushOthers.addModifier(new AvatarStateModifier<Double>() {
@Override
public Double newValue(Double value) {
return ConfigManager.getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirBlast.Push.Entities");
}
});
Attribute<Double> airBurstDamage = (Attribute<Double>) Attribute.get(CoreAbility.getAbility(AirBurst.class), "damage");
airBurstDamage.addModifier(new AvatarStateModifier<Double>() {
@Override
public Double newValue(Double value) {
return ConfigManager.getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirBurst.Damage");
}
});
Attribute<Long> airBurstChargetime = (Attribute<Long>) Attribute.get(CoreAbility.getAbility(AirBurst.class), "chargeTime");
airBurstChargetime.addModifier(new AvatarStateModifier<Long>() {
@Override
public Long newValue(Long value) {
return ConfigManager.getConfig().getLong("Abilities.Avatar.AvatarState.Air.AirBurst.ChargeTime");
}
});
}
}

View file

@ -1,18 +0,0 @@
package com.projectkorra.projectkorra.util.attributes;
import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.util.Attribute.AttributeModifier;
public class AvatarStateModifier<TYPE> implements AttributeModifier<TYPE>{
@Override
public boolean canModify(BendingPlayer bPlayer) {
return bPlayer.isAvatarState();
}
@Override
public TYPE newValue(TYPE value) {
return value;
}
}