diff --git a/src/com/projectkorra/projectkorra/Element.java b/src/com/projectkorra/projectkorra/Element.java index e4cad0cb..1caf2568 100644 --- a/src/com/projectkorra/projectkorra/Element.java +++ b/src/com/projectkorra/projectkorra/Element.java @@ -271,6 +271,9 @@ public class Element { } public static Element fromString(String element) { + if (element == null || element.equals("")) { + return null; + } if (getElement(element) != null) { return getElement(element); } diff --git a/src/com/projectkorra/projectkorra/GeneralMethods.java b/src/com/projectkorra/projectkorra/GeneralMethods.java index 85278e43..4d442aed 100644 --- a/src/com/projectkorra/projectkorra/GeneralMethods.java +++ b/src/com/projectkorra/projectkorra/GeneralMethods.java @@ -1159,7 +1159,7 @@ public class GeneralMethods { } public static boolean isAdjacentToThreeOrMoreSources(Block block) { - if (block.equals(null) || (TempBlock.isTempBlock(block) && WaterAbility.isBendableWaterTempBlock(block))) { + if (block == null || (TempBlock.isTempBlock(block) && WaterAbility.isBendableWaterTempBlock(block))) { return false; } int sources = 0; diff --git a/src/com/projectkorra/projectkorra/ability/CoreAbility.java b/src/com/projectkorra/projectkorra/ability/CoreAbility.java index 637fd36a..1fe901a1 100644 --- a/src/com/projectkorra/projectkorra/ability/CoreAbility.java +++ b/src/com/projectkorra/projectkorra/ability/CoreAbility.java @@ -543,6 +543,7 @@ public abstract class CoreAbility implements Ability { try { addon.load(); ABILITIES_BY_NAME.put(name.toLowerCase(), coreAbil); + ABILITIES_BY_CLASS.put(coreAbil.getClass(), coreAbil); if (coreAbil instanceof ComboAbility) { ComboAbility combo = (ComboAbility) coreAbil; @@ -582,6 +583,7 @@ public abstract class CoreAbility implements Ability { e.printStackTrace(); addon.stop(); ABILITIES_BY_NAME.remove(name.toLowerCase()); + ABILITIES_BY_CLASS.remove(coreAbil.getClass()); } } } diff --git a/src/com/projectkorra/projectkorra/command/DisplayCommand.java b/src/com/projectkorra/projectkorra/command/DisplayCommand.java index d7007d3d..6ddca63e 100644 --- a/src/com/projectkorra/projectkorra/command/DisplayCommand.java +++ b/src/com/projectkorra/projectkorra/command/DisplayCommand.java @@ -100,7 +100,27 @@ public class DisplayCommand extends PKCommand { } return; //passives - } else if (element != null && elementName.contains("passive")) { + } else if (elementName.contains("passive")) { + if (element == null) { + for (Element e : Element.getAllElements()) { + ChatColor color = e != null ? e.getColor() : null; + Set passives = PassiveManager.getPassivesForElement(e); + + for (String passiveAbil : passives) { + ChatColor passiveColor = color; + if (!sender.hasPermission("bending.ability." + passiveAbil)) { + continue; + } + + CoreAbility coreAbil = CoreAbility.getAbility(passiveAbil); + if (coreAbil != null) { + passiveColor = coreAbil.getElement().getColor(); + } + sender.sendMessage(passiveColor + passiveAbil); + } + } + return; + } ChatColor color = element != null ? element.getColor() : null; Set passives = PassiveManager.getPassivesForElement(element); diff --git a/src/com/projectkorra/projectkorra/command/ToggleCommand.java b/src/com/projectkorra/projectkorra/command/ToggleCommand.java index 8100b6bc..b657066e 100644 --- a/src/com/projectkorra/projectkorra/command/ToggleCommand.java +++ b/src/com/projectkorra/projectkorra/command/ToggleCommand.java @@ -2,6 +2,7 @@ package com.projectkorra.projectkorra.command; import com.projectkorra.projectkorra.BendingPlayer; import com.projectkorra.projectkorra.Element; +import com.projectkorra.projectkorra.Element.SubElement; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.configuration.ConfigManager; @@ -92,7 +93,7 @@ public class ToggleCommand extends PKCommand { if (!(sender instanceof Player)) sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + toggleOffAll); } - } else if (sender instanceof Player && args.size() == 1 && Element.fromString(args.get(0)) != null) { + } else if (sender instanceof Player && args.size() == 1 && Element.fromString(args.get(0)) != null && !(Element.fromString(args.get(0)) instanceof SubElement)) { if (!BendingPlayer.getBendingPlayer(sender.getName()).hasElement(Element.fromString(args.get(0)))) { sender.sendMessage(ConfigManager.getBrandingPrefix() + ChatColor.RED + wrongElement); return; @@ -107,8 +108,11 @@ public class ToggleCommand extends PKCommand { } else { sender.sendMessage(ConfigManager.getBrandingPrefix() + color + toggledOffSingleElement.replace("{element}", e.getName() + (e.getType() != null ? e.getType().getBending() : ""))); } + } else { + help(sender, false); } - } else if (sender instanceof Player && args.size() == 2 && Element.fromString(args.get(0)) != null) { + + } else if (sender instanceof Player && args.size() == 2 && Element.fromString(args.get(0)) != null && !(Element.fromString(args.get(0)) instanceof SubElement)) { Player target = Bukkit.getPlayer(args.get(1)); if (!hasAdminPermission(sender)) return; diff --git a/src/com/projectkorra/projectkorra/command/WhoCommand.java b/src/com/projectkorra/projectkorra/command/WhoCommand.java index db10bcfe..8549bce2 100644 --- a/src/com/projectkorra/projectkorra/command/WhoCommand.java +++ b/src/com/projectkorra/projectkorra/command/WhoCommand.java @@ -4,6 +4,7 @@ import java.io.BufferedReader; import java.io.IOException; import java.io.InputStreamReader; import java.net.MalformedURLException; +import java.net.SocketException; import java.net.URL; import java.net.URLConnection; import java.nio.charset.Charset; @@ -53,8 +54,9 @@ public class WhoCommand extends PKCommand { new BukkitRunnable() { public void run() { + Map updatedstaff = new HashMap(); try { - staff.clear(); + // Create a URL for the desired page URLConnection url = new URL("http://www.projectkorra.com/staff.txt").openConnection(); url.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11"); @@ -65,10 +67,15 @@ public class WhoCommand extends PKCommand { while ((unparsed = in.readLine()) != null) { String[] staffEntry = unparsed.split("/"); if (staffEntry.length >= 2) { - staff.put(staffEntry[0], ChatColor.translateAlternateColorCodes('&', staffEntry[1])); + updatedstaff.put(staffEntry[0], ChatColor.translateAlternateColorCodes('&', staffEntry[1])); } } in.close(); + staff.clear(); + staff.putAll(updatedstaff); + } + catch (SocketException e) { + ProjectKorra.log.info("Could not update staff list."); } catch (MalformedURLException e) { e.printStackTrace(); @@ -77,7 +84,7 @@ public class WhoCommand extends PKCommand { e.printStackTrace(); } } - }.runTaskTimerAsynchronously(ProjectKorra.plugin, 0, 20 * 60); + }.runTaskTimerAsynchronously(ProjectKorra.plugin, 0, 20 * 60 * 60); } @Override diff --git a/src/com/projectkorra/projectkorra/object/HorizontalVelocityTracker.java b/src/com/projectkorra/projectkorra/object/HorizontalVelocityTracker.java index c29bef05..3f5cb80f 100644 --- a/src/com/projectkorra/projectkorra/object/HorizontalVelocityTracker.java +++ b/src/com/projectkorra/projectkorra/object/HorizontalVelocityTracker.java @@ -103,7 +103,7 @@ public class HorizontalVelocityTracker { public static void updateAll() { for (Entity e : instances.keySet()) - if (e != null) { + if (e != null && !e.isDead() && instances.get(e) != null) { instances.get(e).update(); } else { instances.remove(e);