Minor fixes (#662)

• Fixed Bottlebending breaking (needs testing)
• Fixed CoreAbility not returning all abilities with
CoreAbility.getAbilities()
• Added new ability.setPlayer(...) method that is used for moves that
change who created the ability (used for redirection)
This commit is contained in:
StrangeOne101 2016-12-20 17:53:20 +13:00 committed by Christopher Martin
parent 5ad7f1f3b5
commit b7a3458c33
3 changed files with 17 additions and 4 deletions

View file

@ -286,7 +286,7 @@ public abstract class CoreAbility implements Ability {
* {@link #registerAbilities()}
*/
public static ArrayList<CoreAbility> getAbilities() {
return new ArrayList<CoreAbility>(ABILITIES_BY_NAME.values());
return new ArrayList<CoreAbility>(ABILITIES_BY_CLASS.values());
}
/**
@ -607,6 +607,19 @@ public abstract class CoreAbility implements Ability {
public Player getPlayer() {
return player;
}
/**
* Changes the player that owns this ability instance. Used for redirection
* and other abilities that change the player object.
*
* @param player The player who now controls the ability
*/
public void setPlayer(Player player) {
INSTANCES_BY_PLAYER.get(this.getClass()).get(this.player.getUniqueId()).remove(this.getId());
INSTANCES_BY_PLAYER.get(this.getClass()).get(player.getUniqueId()).put(this.getId(), this);
this.player = player;
}
/**
* Used by the CollisionManager to check if two instances can collide with
@ -731,4 +744,4 @@ public abstract class CoreAbility implements Ability {
return DEFAULT_COLLISION_RADIUS;
}
}
}

View file

@ -210,7 +210,7 @@ public class IceSpikeBlast extends IceAbility {
private void redirect(Location destination, Player player) {
this.destination = destination;
this.player = player;
this.setPlayer(player);
}
@Override

View file

@ -317,7 +317,7 @@ public class WaterManipulation extends WaterAbility {
targetDirection = GeneralMethods.getDirection(location, targetlocation).normalize();
}
targetDestination = targetlocation;
this.player = player;
this.setPlayer(player);
}
}