From 1afe4a65e1aad106fcfb6eb129f7c6ebf2f2da0e Mon Sep 17 00:00:00 2001 From: Benford Date: Wed, 6 Apr 2016 19:08:12 -0400 Subject: [PATCH] Fix Fixes - Removed unnecessary check in remove - Changed hasElement subelement portion --- .../projectkorra/projectkorra/BendingPlayer.java | 10 +--------- .../projectkorra/command/RemoveCommand.java | 14 +++----------- 2 files changed, 4 insertions(+), 20 deletions(-) diff --git a/src/com/projectkorra/projectkorra/BendingPlayer.java b/src/com/projectkorra/projectkorra/BendingPlayer.java index cc92dbf9..6f172f3c 100644 --- a/src/com/projectkorra/projectkorra/BendingPlayer.java +++ b/src/com/projectkorra/projectkorra/BendingPlayer.java @@ -496,16 +496,8 @@ public class BendingPlayer { } else if (!(element instanceof SubElement)) { return this.elements.contains(element); } else { - Element parentElement = ((SubElement) element).getParentElement(); - String prefix = "bending." + parentElement.getName() + "."; - - // Some permissions are bending.water.name and some are bending.water.namebending - if (player.hasPermission(prefix + element.getName()) - || player.hasPermission(prefix + element.getName() + "bending")) { - return true; - } + return hasSubElement((SubElement)element); } - return false; } public boolean hasSubElement(SubElement sub) { diff --git a/src/com/projectkorra/projectkorra/command/RemoveCommand.java b/src/com/projectkorra/projectkorra/command/RemoveCommand.java index 802a0479..3b8bc4c1 100644 --- a/src/com/projectkorra/projectkorra/command/RemoveCommand.java +++ b/src/com/projectkorra/projectkorra/command/RemoveCommand.java @@ -2,11 +2,12 @@ package com.projectkorra.projectkorra.command; import com.projectkorra.projectkorra.BendingPlayer; import com.projectkorra.projectkorra.Element; -import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.Element.SubElement; +import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.configuration.ConfigManager; import com.projectkorra.projectkorra.event.PlayerChangeElementEvent; import com.projectkorra.projectkorra.event.PlayerChangeElementEvent.Result; +import com.projectkorra.projectkorra.event.PlayerChangeSubElementEvent; import com.projectkorra.rpg.RPGMethods; import org.bukkit.Bukkit; @@ -57,7 +58,7 @@ public class RemoveCommand extends PKCommand { GeneralMethods.saveSubElements(senderBPlayer); GeneralMethods.removeUnusableAbilities(sender.getName()); sender.sendMessage(e.getColor() + this.succesfullyRemovedElementSelf.replace("{element}" , e.getName() + e.getType().getBending()).replace("{sender}", ChatColor.DARK_AQUA + sender.getName() + e.getColor())); - Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, player, e, Result.REMOVE)); + Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeSubElementEvent(sender, player, (SubElement) e, com.projectkorra.projectkorra.event.PlayerChangeSubElementEvent.Result.REMOVE)); } else sender.sendMessage(ChatColor.RED + invalidElement); return; } @@ -73,15 +74,6 @@ public class RemoveCommand extends PKCommand { sender.sendMessage(ChatColor.RED + wrongElementSelf); return; } - } else if (SubElement.fromString(args.get(0)) != null) { - SubElement sub = (SubElement) SubElement.fromString(args.get(0)); - if (senderBPlayer.hasSubElement(sub)) { - senderBPlayer.getSubElements().remove(sub); - GeneralMethods.saveSubElements(senderBPlayer); - GeneralMethods.removeUnusableAbilities(sender.getName()); - sender.sendMessage(sub.getColor() + this.succesfullyRemovedElementSelf.replace("{element}" , sub.getName() + sub.getType().getBending()).replace("{sender}", ChatColor.DARK_AQUA + sender.getName() + sub.getColor())); - Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, player, e, Result.REMOVE)); - } } else { sender.sendMessage(ChatColor.RED + invalidElement); return;