mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-08-17 08:57:40 +00:00
Fix NPE with Custom Elements
This commit is contained in:
parent
042866ec62
commit
78a341e636
|
@ -302,29 +302,31 @@ public class GeneralMethods {
|
|||
String permaremoved = rs2.getString("permaremoved");
|
||||
boolean p = false;
|
||||
final ArrayList<Element> elements = new ArrayList<Element>();
|
||||
boolean hasAddon = element.contains(";");
|
||||
String[] split = element.split(";");
|
||||
if (split[0] != null) { // Player has an element.
|
||||
if (split[0].contains("a")) {
|
||||
elements.add(Element.AIR);
|
||||
}
|
||||
if (split[0].contains("w")) {
|
||||
elements.add(Element.WATER);
|
||||
}
|
||||
if (split[0].contains("e")) {
|
||||
elements.add(Element.EARTH);
|
||||
}
|
||||
if (split[0].contains("f")) {
|
||||
elements.add(Element.FIRE);
|
||||
}
|
||||
if (split[0].contains("c")) {
|
||||
elements.add(Element.CHI);
|
||||
}
|
||||
}
|
||||
if (hasAddon) {
|
||||
for (String addon : split[split.length - 1].split(",")) {
|
||||
if (Element.getElement(addon) != null) {
|
||||
elements.add(Element.getElement(addon));
|
||||
if (element != null) {
|
||||
boolean hasAddon = element.contains(";");
|
||||
String[] split = element.split(";");
|
||||
if (split[0] != null) { // Player has an element.
|
||||
if (split[0].contains("a")) {
|
||||
elements.add(Element.AIR);
|
||||
}
|
||||
if (split[0].contains("w")) {
|
||||
elements.add(Element.WATER);
|
||||
}
|
||||
if (split[0].contains("e")) {
|
||||
elements.add(Element.EARTH);
|
||||
}
|
||||
if (split[0].contains("f")) {
|
||||
elements.add(Element.FIRE);
|
||||
}
|
||||
if (split[0].contains("c")) {
|
||||
elements.add(Element.CHI);
|
||||
}
|
||||
if (hasAddon) {
|
||||
for (String addon : split[split.length - 1].split(",")) {
|
||||
if (Element.getElement(addon) != null) {
|
||||
elements.add(Element.getElement(addon));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -74,9 +74,9 @@ public class AddCommand extends PKCommand {
|
|||
ChatColor color = element.getColor();
|
||||
|
||||
if (!(sender instanceof Player) || !((Player) sender).equals(target)) {
|
||||
sender.sendMessage(ChatColor.DARK_AQUA + target.getName() + color + " is also a" + (isVowel(element.getName().charAt(0)) ? "n " : " ") + element.getName() + (element.getType() != null ? element.getType().getBender() : ""));
|
||||
sender.sendMessage(ChatColor.DARK_AQUA + target.getName() + color + " is also a" + (isVowel(element.getName().charAt(0)) ? "n " : " ") + element.getName() + (element.getType() != null ? element.getType().getBender() : "") + ".");
|
||||
} else {
|
||||
target.sendMessage(color + "You are also a" + (isVowel(element.getName().charAt(0)) ? "n " : " ") + element.getName() + (element.getType() != null ? element.getType().getBender() : ""));
|
||||
target.sendMessage(color + "You are also a" + (isVowel(element.getName().charAt(0)) ? "n " : " ") + element.getName() + (element.getType() != null ? element.getType().getBender() : "") + ".");
|
||||
}
|
||||
GeneralMethods.saveElements(bPlayer);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, target, element, Result.ADD));
|
||||
|
|
|
@ -97,17 +97,9 @@ public class ChooseCommand extends PKCommand {
|
|||
bPlayer.setElement(element);
|
||||
ChatColor color = element != null ? element.getColor() : null;
|
||||
if (!(sender instanceof Player) || !((Player) sender).equals(target)) {
|
||||
if (element != Element.CHI) {
|
||||
sender.sendMessage(ChatColor.DARK_AQUA + target.getName() + color + " is now a" + (isVowel(element.getName().charAt(0)) ? "n " : " ") + element.getName() + "bender.");
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.DARK_AQUA + target.getName() + color + " is now a Chiblocker.");
|
||||
}
|
||||
sender.sendMessage(ChatColor.DARK_AQUA + target.getName() + color + " is now a" + (isVowel(element.getName().charAt(0)) ? "n " : " ") + element.getName() + (element.getType() != null ? element.getType().getBender() : "") + ".");
|
||||
} else {
|
||||
if (element != Element.CHI) {
|
||||
target.sendMessage(color + "You are now a" + (isVowel(element.getName().charAt(0)) ? "n " : " ") + element.getName() + "bender.");
|
||||
} else {
|
||||
target.sendMessage(color + "You are now a Chiblocker.");
|
||||
}
|
||||
target.sendMessage(color + "You are now a" + (isVowel(element.getName().charAt(0)) ? "n " : " ") + element.getName() + (element.getType() != null ? element.getType().getBender() : "") + ".");
|
||||
}
|
||||
|
||||
|
||||
|
|
Loading…
Reference in a new issue