Few fixes here, here and maybe there (#724)

• Fixed CoreAbility.getAbilities() not returning addon abilities
• Fixed errors spammed from /b w when the server can't fetch the staff
list
• Fixed /b d passives - now displays all possible passives
• Fixed /b t <sub> causing an internal error
• Fixed a lot of NPEs
This commit is contained in:
StrangeOne101 2017-02-07 12:09:02 +13:00 committed by Christopher Martin
parent e8df4895b9
commit 477d02c673
7 changed files with 44 additions and 8 deletions

View file

@ -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);
}

View file

@ -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;

View file

@ -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());
}
}
}

View file

@ -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<String> 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<String> passives = PassiveManager.getPassivesForElement(element);

View file

@ -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;

View file

@ -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<String, String> updatedstaff = new HashMap<String, String>();
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

View file

@ -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);