mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-12-22 16:05:01 +00:00
Fixed NPE & Other New Bugs (#663)
• Fixed NPEs in CoreAbility.setPlater • Turned off blocking for WaterManipulation • Fixed /b display showing some moves twice
This commit is contained in:
parent
b7a3458c33
commit
6b656cc711
3 changed files with 41 additions and 9 deletions
|
@ -615,7 +615,30 @@ public abstract class CoreAbility implements Ability {
|
|||
* @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());
|
||||
Map<UUID, Map<Integer, CoreAbility>> classMap = INSTANCES_BY_PLAYER.get(getClass());
|
||||
if (classMap != null) {
|
||||
Map<Integer, CoreAbility> playerMap = classMap.get(player.getUniqueId());
|
||||
if (playerMap != null) {
|
||||
playerMap.remove(this.id);
|
||||
if (playerMap.size() == 0) {
|
||||
classMap.remove(player.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
if (classMap.size() == 0) {
|
||||
INSTANCES_BY_PLAYER.remove(getClass());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
if (!INSTANCES_BY_PLAYER.containsKey(this.getClass())) {
|
||||
INSTANCES_BY_PLAYER.put(this.getClass(), new ConcurrentHashMap<UUID, Map<Integer, CoreAbility>>());
|
||||
}
|
||||
|
||||
if (!INSTANCES_BY_PLAYER.get(this.getClass()).containsKey(player.getUniqueId())) {
|
||||
INSTANCES_BY_PLAYER.get(this.getClass()).put(player.getUniqueId(), new ConcurrentHashMap<Integer, CoreAbility>());
|
||||
}
|
||||
|
||||
INSTANCES_BY_PLAYER.get(this.getClass()).get(player.getUniqueId()).put(this.getId(), this);
|
||||
|
||||
this.player = player;
|
||||
|
|
|
@ -15,6 +15,7 @@ import org.bukkit.entity.Player;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -121,16 +122,19 @@ public class DisplayCommand extends PKCommand {
|
|||
sender.sendMessage(ChatColor.YELLOW + noAbilitiesAvailable.replace("{element}", Element.AVATAR.getColor() + "Avatar" + ChatColor.YELLOW));
|
||||
return;
|
||||
}
|
||||
HashSet<String> abilitiesSent = new HashSet<String>(); //Some abilities have the same name. This prevents this from showing anything.
|
||||
for (CoreAbility ability : abilities) {
|
||||
if (ability.isHiddenAbility()) {
|
||||
if (ability.isHiddenAbility() || abilitiesSent.contains(ability.getName())) {
|
||||
continue;
|
||||
}
|
||||
if (sender instanceof Player) {
|
||||
if (GeneralMethods.canView((Player) sender, ability.getName())) {
|
||||
sender.sendMessage(ability.getElement().getColor() + ability.getName());
|
||||
abilitiesSent.add(ability.getName());
|
||||
}
|
||||
} else {
|
||||
sender.sendMessage(ability.getElement().getColor() + ability.getName());
|
||||
abilitiesSent.add(ability.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -151,12 +155,14 @@ public class DisplayCommand extends PKCommand {
|
|||
sender.sendMessage(ChatColor.YELLOW + noAbilitiesAvailable.replace("{element}", element.getColor() + element.getName() + ChatColor.YELLOW));
|
||||
}
|
||||
|
||||
HashSet<String> abilitiesSent = new HashSet<String>(); //Some abilities have the same name. This prevents this from showing anything.
|
||||
for (CoreAbility ability : abilities) {
|
||||
if (ability instanceof SubAbility || ability.isHiddenAbility()) {
|
||||
if (ability instanceof SubAbility || ability.isHiddenAbility() || abilitiesSent.contains(ability.getName())) {
|
||||
continue;
|
||||
}
|
||||
if (!(sender instanceof Player) || GeneralMethods.canView((Player) sender, ability.getName())) {
|
||||
sender.sendMessage(ability.getElement().getColor() + ability.getName());
|
||||
abilitiesSent.add(ability.getName());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -185,11 +191,14 @@ public class DisplayCommand extends PKCommand {
|
|||
sender.sendMessage(ChatColor.YELLOW + noAbilitiesAvailable.replace("{element}", element.getColor() + element.getName() + ChatColor.YELLOW));
|
||||
return;
|
||||
}
|
||||
|
||||
HashSet<String> abilitiesSent = new HashSet<String>();
|
||||
for (CoreAbility ability : abilities) {
|
||||
if (ability.isHiddenAbility()) {
|
||||
if (ability.isHiddenAbility() || abilitiesSent.contains(ability.getName())) {
|
||||
continue;
|
||||
} else if (!(sender instanceof Player) || GeneralMethods.canView((Player) sender, ability.getName())) {
|
||||
sender.sendMessage(element.getColor() + ability.getName());
|
||||
abilitiesSent.add(ability.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -165,7 +165,7 @@ public class WaterManipulation extends WaterAbility {
|
|||
Block block = BlockSource.getWaterSourceBlock(player, selectRange, ClickType.SHIFT_DOWN, true, true,
|
||||
bPlayer.canPlantbend());
|
||||
cancelPrevious();
|
||||
block(player);
|
||||
//block(player);
|
||||
|
||||
if (block != null) {
|
||||
sourceBlock = block;
|
||||
|
@ -384,7 +384,7 @@ public class WaterManipulation extends WaterAbility {
|
|||
}
|
||||
|
||||
/**Blocks other water manips*/
|
||||
private static void block(Player player) {
|
||||
public static void block(Player player) {
|
||||
for (WaterManipulation manip : getAbilities(WaterManipulation.class)) {
|
||||
if (!manip.location.getWorld().equals(player.getWorld())) {
|
||||
continue;
|
||||
|
@ -462,7 +462,6 @@ public class WaterManipulation extends WaterAbility {
|
|||
return location;
|
||||
}
|
||||
|
||||
@SuppressWarnings("deprecation")
|
||||
public static void moveWater(Player player) {
|
||||
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
|
||||
if (bPlayer == null) {
|
||||
|
@ -493,15 +492,16 @@ public class WaterManipulation extends WaterAbility {
|
|||
|
||||
if (isTransparent(player, block) && isTransparent(player, eyeLoc.getBlock())) {
|
||||
if (getTargetLocation(player, range).distanceSquared(block.getLocation()) > 1) {
|
||||
block.setType(Material.WATER);
|
||||
block.setData((byte) 0);
|
||||
TempBlock tb = new TempBlock(block, Material.WATER, (byte)0);
|
||||
|
||||
WaterManipulation waterManip = new WaterManipulation(player);
|
||||
waterManip.moveWater();
|
||||
if (!waterManip.progressing) {
|
||||
block.setType(Material.AIR);
|
||||
tb.revertBlock();
|
||||
} else {
|
||||
WaterReturn.emptyWaterBottle(player);
|
||||
tb.revertBlock();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue