mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-09-11 12:49:32 +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");
|
String permaremoved = rs2.getString("permaremoved");
|
||||||
boolean p = false;
|
boolean p = false;
|
||||||
final ArrayList<Element> elements = new ArrayList<Element>();
|
final ArrayList<Element> elements = new ArrayList<Element>();
|
||||||
boolean hasAddon = element.contains(";");
|
if (element != null) {
|
||||||
String[] split = element.split(";");
|
boolean hasAddon = element.contains(";");
|
||||||
if (split[0] != null) { // Player has an element.
|
String[] split = element.split(";");
|
||||||
if (split[0].contains("a")) {
|
if (split[0] != null) { // Player has an element.
|
||||||
elements.add(Element.AIR);
|
if (split[0].contains("a")) {
|
||||||
}
|
elements.add(Element.AIR);
|
||||||
if (split[0].contains("w")) {
|
}
|
||||||
elements.add(Element.WATER);
|
if (split[0].contains("w")) {
|
||||||
}
|
elements.add(Element.WATER);
|
||||||
if (split[0].contains("e")) {
|
}
|
||||||
elements.add(Element.EARTH);
|
if (split[0].contains("e")) {
|
||||||
}
|
elements.add(Element.EARTH);
|
||||||
if (split[0].contains("f")) {
|
}
|
||||||
elements.add(Element.FIRE);
|
if (split[0].contains("f")) {
|
||||||
}
|
elements.add(Element.FIRE);
|
||||||
if (split[0].contains("c")) {
|
}
|
||||||
elements.add(Element.CHI);
|
if (split[0].contains("c")) {
|
||||||
}
|
elements.add(Element.CHI);
|
||||||
}
|
}
|
||||||
if (hasAddon) {
|
if (hasAddon) {
|
||||||
for (String addon : split[split.length - 1].split(",")) {
|
for (String addon : split[split.length - 1].split(",")) {
|
||||||
if (Element.getElement(addon) != null) {
|
if (Element.getElement(addon) != null) {
|
||||||
elements.add(Element.getElement(addon));
|
elements.add(Element.getElement(addon));
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -74,9 +74,9 @@ public class AddCommand extends PKCommand {
|
||||||
ChatColor color = element.getColor();
|
ChatColor color = element.getColor();
|
||||||
|
|
||||||
if (!(sender instanceof Player) || !((Player) sender).equals(target)) {
|
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 {
|
} 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);
|
GeneralMethods.saveElements(bPlayer);
|
||||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, target, element, Result.ADD));
|
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, target, element, Result.ADD));
|
||||||
|
|
|
@ -97,17 +97,9 @@ public class ChooseCommand extends PKCommand {
|
||||||
bPlayer.setElement(element);
|
bPlayer.setElement(element);
|
||||||
ChatColor color = element != null ? element.getColor() : null;
|
ChatColor color = element != null ? element.getColor() : null;
|
||||||
if (!(sender instanceof Player) || !((Player) sender).equals(target)) {
|
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() + (element.getType() != null ? element.getType().getBender() : "") + ".");
|
||||||
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.");
|
|
||||||
}
|
|
||||||
} else {
|
} else {
|
||||||
if (element != Element.CHI) {
|
target.sendMessage(color + "You are now a" + (isVowel(element.getName().charAt(0)) ? "n " : " ") + element.getName() + (element.getType() != null ? element.getType().getBender() : "") + ".");
|
||||||
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.");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue