Merge pull request #423 from jedk1/master

Various Changes & Fixes
This commit is contained in:
OmniCypher 2016-02-25 15:24:21 -08:00
commit 3cddb44b57
11 changed files with 416 additions and 291 deletions

View file

@ -75,11 +75,11 @@ public class BendingPlayer {
this.chiBlocked = false; this.chiBlocked = false;
cooldowns = new ConcurrentHashMap<String, Long>(); cooldowns = new ConcurrentHashMap<String, Long>();
toggledElements = new ConcurrentHashMap<Element, Boolean>(); toggledElements = new ConcurrentHashMap<Element, Boolean>();
toggledElements.put(Element.AIR, true); for (Element e : Element.getAllElements()) {
toggledElements.put(Element.EARTH, true); if (!e.equals(Element.AVATAR)) {
toggledElements.put(Element.FIRE, true); toggledElements.put(e, true);
toggledElements.put(Element.WATER, true); }
toggledElements.put(Element.CHI, true); }
PLAYERS.put(uuid, this); PLAYERS.put(uuid, this);
PKListener.login(this); PKListener.login(this);
@ -483,7 +483,7 @@ public class BendingPlayer {
public boolean isElementToggled(Element element) { public boolean isElementToggled(Element element) {
if (element != null && toggledElements.containsKey(element)) { if (element != null && toggledElements.containsKey(element)) {
return toggledElements.containsKey(element); return toggledElements.get(element);
} }
return true; return true;
} }

View file

@ -1,23 +1,55 @@
package com.projectkorra.projectkorra; package com.projectkorra.projectkorra;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.plugin.Plugin;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap; import java.util.HashMap;
import java.util.List;
public class Element { public class Element {
public enum ElementType {
BENDING("bending", "bender", "bend"),
BLOCKING("blocking", "blocker", "block"),
NO_SUFFIX("", "", "");
private String bending;
private String bender;
private String bend;
ElementType(String bending, String bender, String bend) {
this.bending = bending;
this.bender = bender;
this.bend = bend;
}
public String getBending() {
return bending;
}
public String getBender() {
return bender;
}
public String getBend() {
return bend;
}
}
private static final HashMap<String, Element> ALL_ELEMENTS = new HashMap<>(); // Must be initialized first private static final HashMap<String, Element> ALL_ELEMENTS = new HashMap<>(); // Must be initialized first
public static final Element AIR = new Element("Air"); public static final Element AIR = new Element("Air");
public static final Element WATER = new Element("Water"); public static final Element WATER = new Element("Water");
public static final Element EARTH = new Element("Earth"); public static final Element EARTH = new Element("Earth");
public static final Element FIRE = new Element("Fire"); public static final Element FIRE = new Element("Fire");
public static final Element CHI = new Element("Chi"); public static final Element CHI = new Element("Chi", ElementType.BLOCKING);
public static final Element AVATAR = new Element("Avatar"); public static final Element AVATAR = new Element("Avatar", null);
public static final SubElement FLIGHT = new SubElement("Flight", AIR); public static final SubElement FLIGHT = new SubElement("Flight", AIR, ElementType.NO_SUFFIX);
public static final SubElement SPIRITUAL = new SubElement("Spiritual", AIR); public static final SubElement SPIRITUAL = new SubElement("Spiritual", AIR, ElementType.NO_SUFFIX);
public static final SubElement BLOOD = new SubElement("Blood", WATER); public static final SubElement BLOOD = new SubElement("Blood", WATER);
public static final SubElement HEALING = new SubElement("Healing", WATER); public static final SubElement HEALING = new SubElement("Healing", WATER, ElementType.NO_SUFFIX);
public static final SubElement ICE = new SubElement("Ice", WATER); public static final SubElement ICE = new SubElement("Ice", WATER);
public static final SubElement PLANT = new SubElement("Plant", WATER); public static final SubElement PLANT = new SubElement("Plant", WATER);
public static final SubElement LAVA = new SubElement("Lava", EARTH); public static final SubElement LAVA = new SubElement("Lava", EARTH);
@ -31,20 +63,65 @@ public class Element {
private static final SubElement[] SUB_ELEMENTS = {FLIGHT, SPIRITUAL, BLOOD, HEALING, ICE, PLANT, LAVA, METAL, SAND, LIGHTNING, COMBUSTION}; private static final SubElement[] SUB_ELEMENTS = {FLIGHT, SPIRITUAL, BLOOD, HEALING, ICE, PLANT, LAVA, METAL, SAND, LIGHTNING, COMBUSTION};
private String name; private String name;
private ElementType type;
private Plugin plugin;
protected Element(String name) { /**
* To be used when creating a new Element.
* Do not use for comparing Elements.
* @param name Name of the new Element.
*/
public Element(String name) {
this(name, ElementType.BENDING, ProjectKorra.plugin);
}
/**
* To be used when creating a new Element.
* Do not use for comparing Elements.
* @param name Name of the new Element.
* @param type ElementType specifies if its a regular element or chi style element.
*/
public Element(String name, ElementType type) {
this(name, type, ProjectKorra.plugin);
}
/**
* To be used when creating a new Element.
* Do not use for comparing Elements.
* @param name Name of the new Element.
* @param type ElementType specifies if its a regular element or chi style element.
* @param plugin The plugin that is adding the element.
*/
public Element(String name, ElementType type, Plugin plugin) {
this.name = name; this.name = name;
this.type = type;
this.plugin = plugin;
ALL_ELEMENTS.put(name.toLowerCase(), this); ALL_ELEMENTS.put(name.toLowerCase(), this);
} }
public ChatColor getColor() { public ChatColor getColor() {
return ChatColor.valueOf(ProjectKorra.plugin.getConfig().getString("Properties.Chat.Colors." + name)); String color = getPlugin().getConfig().getString("Properties.Chat.Colors." + name);
return color != null ? ChatColor.valueOf(color) : ChatColor.WHITE;
}
public ChatColor getSubColor() {
String color = getPlugin().getConfig().getString("Properties.Chat.Colors." + name + "Sub");
return color != null ? ChatColor.valueOf(color) : ChatColor.WHITE;
} }
public String getName() { public String getName() {
return name; return name;
} }
public Plugin getPlugin() {
return plugin;
}
public ElementType getType() {
if (type == null) return ElementType.NO_SUFFIX;
return type;
}
@Override @Override
public String toString() { public String toString() {
return getColor() + getName(); return getColor() + getName();
@ -57,6 +134,17 @@ public class Element {
return ALL_ELEMENTS.get(name.toLowerCase()); return ALL_ELEMENTS.get(name.toLowerCase());
} }
public static Element[] getAllElements() {
List<Element> ae = new ArrayList<Element>();
ae.addAll(Arrays.asList(getMainElements()));
for (Element e : ALL_ELEMENTS.values()) {
if (!ae.contains(e) && !(e instanceof SubElement)) {
ae.add(e);
}
}
return ae.toArray(new Element[ae.size()]);
}
public static Element[] getElements() { public static Element[] getElements() {
return ELEMENTS; return ELEMENTS;
} }
@ -65,22 +153,111 @@ public class Element {
return MAIN_ELEMENTS; return MAIN_ELEMENTS;
} }
public static Element[] getAddonElements() {
List<Element> ae = new ArrayList<Element>();
for (Element e : getAllElements()) {
if (!Arrays.asList(getMainElements()).contains(e)) {
ae.add(e);
}
}
ae.remove(Element.AVATAR);
return ae.toArray(new Element[ae.size()]);
}
public static SubElement[] getAllSubElements() {
List<SubElement> se = new ArrayList<SubElement>();
se.addAll(Arrays.asList(getSubElements()));
for (Element e : ALL_ELEMENTS.values()) {
if (!se.contains(e) && e instanceof SubElement) {
se.add((SubElement) e);
}
}
return se.toArray(new SubElement[se.size()]);
}
public static SubElement[] getSubElements() { public static SubElement[] getSubElements() {
return SUB_ELEMENTS; return SUB_ELEMENTS;
} }
public static SubElement[] getSubElements(Element element) {
List<SubElement> se = new ArrayList<SubElement>();
for (SubElement sub : getAllSubElements()) {
if (sub.getParentElement().equals(element)) {
se.add(sub);
}
}
return se.toArray(new SubElement[se.size()]);
}
public static SubElement[] getAddonSubElements() {
List<SubElement> ae = new ArrayList<SubElement>();
for (SubElement e : getAllSubElements()) {
if (!Arrays.asList(getSubElements()).contains(e)) {
ae.add(e);
}
}
return ae.toArray(new SubElement[ae.size()]);
}
public static Element fromString(String element) {
if (getElement(element) != null) {
return getElement(element);
}
for (String s : ALL_ELEMENTS.keySet()) {
if (element.length() <= 1 && getElement(s) instanceof SubElement) {
continue;
}
if (s.length() >= element.length()) {
if (s.substring(0, element.length()).equalsIgnoreCase(element)) {
return getElement(s);
}
}
}
return null;
}
public static class SubElement extends Element { public static class SubElement extends Element {
private Element parentElement; private Element parentElement;
private SubElement(String name, Element parentElement) { /**
super(name); * To be used when creating a new SubElement.
* Do not use for comparing SubElements.
* @param name Name of the new SubElement.
* @param parentElement ParentElement of the SubElement.
*/
public SubElement(String name, Element parentElement) {
this(name, parentElement, ElementType.BENDING, ProjectKorra.plugin);
}
/**
* To be used when creating a new SubElement.
* Do not use for comparing SubElements.
* @param name Name of the new SubElement.
* @param parentElement ParentElement of the SubElement.
* @param type ElementType specifies if its a regular element or chi style element.
*/
public SubElement(String name, Element parentElement, ElementType type) {
this(name, parentElement, type, ProjectKorra.plugin);
}
/**
* To be used when creating a new SubElement.
* Do not use for comparing SubElements.
* @param name Name of the new SubElement.
* @param parentElement ParentElement of the SubElement.
* @param type ElementType specifies if its a regular element or chi style element.
* @param plugin The plugin that is adding the element.
*/
public SubElement(String name, Element parentElement, ElementType type, Plugin plugin) {
super(name, type, plugin);
this.parentElement = parentElement; this.parentElement = parentElement;
} }
@Override @Override
public ChatColor getColor() { public ChatColor getColor() {
return ChatColor.valueOf(ProjectKorra.plugin.getConfig().getString("Properties.Chat.Colors." + parentElement.name + "Sub")); String color = getPlugin().getConfig().getString("Properties.Chat.Colors." + parentElement.name + "Sub");
return color != null ? ChatColor.valueOf(color) : ChatColor.WHITE;
} }
public Element getParentElement() { public Element getParentElement() {

View file

@ -302,21 +302,32 @@ 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>();
if (element != null) { // Player has an element. if (element != null) {
if (element.contains("a")) { boolean hasAddon = element.contains(";");
elements.add(Element.AIR); String[] split = element.split(";");
} if (split[0] != null) { // Player has an element.
if (element.contains("w")) { if (split[0].contains("a")) {
elements.add(Element.WATER); elements.add(Element.AIR);
} }
if (element.contains("e")) { if (split[0].contains("w")) {
elements.add(Element.EARTH); elements.add(Element.WATER);
} }
if (element.contains("f")) { if (split[0].contains("e")) {
elements.add(Element.FIRE); elements.add(Element.EARTH);
} }
if (element.contains("c")) { if (split[0].contains("f")) {
elements.add(Element.CHI); 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));
}
}
}
} }
} }
@ -1489,6 +1500,16 @@ public class GeneralMethods {
if (bPlayer.hasElement(Element.CHI)) { if (bPlayer.hasElement(Element.CHI)) {
elements.append("c"); elements.append("c");
} }
boolean hasAddon = false;
for (Element element : bPlayer.getElements()) {
if (Arrays.asList(Element.getAddonElements()).contains(element)) {
if (!hasAddon) {
hasAddon = true;
elements.append(";");
}
elements.append(element.getName() + ",");
}
}
DBConnection.sql.modifyQuery("UPDATE pk_players SET element = '" + elements + "' WHERE uuid = '" + uuid + "'"); DBConnection.sql.modifyQuery("UPDATE pk_players SET element = '" + elements + "' WHERE uuid = '" + uuid + "'");
} }

View file

@ -21,6 +21,9 @@ public class QuickStrike extends ChiAbility {
this.damage = getConfig().getInt("Abilities.Chi.QuickStrike.Damage"); this.damage = getConfig().getInt("Abilities.Chi.QuickStrike.Damage");
this.blockChance = getConfig().getInt("Abilities.Chi.QuickStrike.ChiBlockChance"); this.blockChance = getConfig().getInt("Abilities.Chi.QuickStrike.ChiBlockChance");
target = GeneralMethods.getTargetedEntity(player, 2); target = GeneralMethods.getTargetedEntity(player, 2);
if (target == null) {
return;
}
start(); start();
} }
@ -28,6 +31,7 @@ public class QuickStrike extends ChiAbility {
@Override @Override
public void progress() { public void progress() {
if (target == null) { if (target == null) {
remove();
return; return;
} }

View file

@ -30,7 +30,7 @@ public class AddCommand extends PKCommand {
if (!hasPermission(sender) || !isPlayer(sender)) { if (!hasPermission(sender) || !isPlayer(sender)) {
return; return;
} }
add(sender, (Player) sender, args.get(0).toLowerCase()); add(sender, (Player) sender, Element.fromString(args.get(0).toLowerCase()));
} else if (args.size() == 2) { //bending add element combo } else if (args.size() == 2) { //bending add element combo
if (!hasPermission(sender, "others")) { if (!hasPermission(sender, "others")) {
return; return;
@ -40,7 +40,7 @@ public class AddCommand extends PKCommand {
sender.sendMessage(ChatColor.RED + "That player is not online."); sender.sendMessage(ChatColor.RED + "That player is not online.");
return; return;
} }
add(sender, player, args.get(0).toLowerCase()); add(sender, player, Element.fromString(args.get(0).toLowerCase()));
} }
} }
@ -51,7 +51,7 @@ public class AddCommand extends PKCommand {
* @param target The player to add the element to * @param target The player to add the element to
* @param element The element to add * @param element The element to add
*/ */
private void add(CommandSender sender, Player target, String element) { private void add(CommandSender sender, Player target, Element element) {
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(target); BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(target);
if (bPlayer == null) { if (bPlayer == null) {
GeneralMethods.createBendingPlayer(target.getUniqueId(), target.getName()); GeneralMethods.createBendingPlayer(target.getUniqueId(), target.getName());
@ -61,33 +61,32 @@ public class AddCommand extends PKCommand {
sender.sendMessage(ChatColor.RED + "That player's bending was permanently removed."); sender.sendMessage(ChatColor.RED + "That player's bending was permanently removed.");
return; return;
} }
if (Arrays.asList(Commands.elementaliases).contains(element.toLowerCase())) { if (Arrays.asList(Element.getAllElements()).contains(element)) {
element = getElement(element.toLowerCase()); if (bPlayer.hasElement(element)) {
Element type = Element.getElement(element); if (!(sender instanceof Player) || !((Player) sender).equals(target)) {
bPlayer.addElement(type); sender.sendMessage(ChatColor.DARK_AQUA + target.getName() + ChatColor.RED + " already has that element!");
ChatColor color = type.getColor(); } else {
sender.sendMessage(ChatColor.RED + "You already have that element!");
if (element.charAt(0) == 'w' || element.charAt(0) == 'f') {
target.sendMessage(color + "You are also a " + Character.toString(element.charAt(0)).toUpperCase() + element.substring(1) + "bender.");
} else if (element.charAt(0) == 'e' || element.charAt(0) == 'a') {
target.sendMessage(color + "You are also an " + Character.toString(element.charAt(0)).toUpperCase() + element.substring(1) + "bender.");
} else if (element.charAt(0) == 'c' || element.equalsIgnoreCase("chi")) {
target.sendMessage(color + "You are now a Chiblocker.");
}
if (!(sender instanceof Player) || !((Player) sender).equals(target)) {
if (element.charAt(0) == 'w' || element.charAt(0) == 'f') {
sender.sendMessage(ChatColor.DARK_AQUA + target.getName() + color + " is also a " + Character.toString(element.charAt(0)).toUpperCase() + element.substring(1) + "bender.");
} else if (element.charAt(0) == 'e' || element.charAt(0) == 'a') {
sender.sendMessage(ChatColor.DARK_AQUA + target.getName() + color + " is also an " + Character.toString(element.charAt(0)).toUpperCase() + element.substring(1) + "bender.");
} else if (element.charAt(0) == 'c' || element.equalsIgnoreCase("chi")) {
sender.sendMessage(ChatColor.DARK_AQUA + target.getName() + color + " is also a " + Character.toString(element.charAt(0)).toUpperCase() + element.substring(1) + "blocker.");
} }
return;
}
bPlayer.addElement(element);
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().getBender() + ".");
} else {
target.sendMessage(color + "You are also a" + (isVowel(element.getName().charAt(0)) ? "n " : " ") + element.getName() + element.getType().getBender() + ".");
} }
GeneralMethods.saveElements(bPlayer); GeneralMethods.saveElements(bPlayer);
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, target, type, Result.ADD)); Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, target, element, Result.ADD));
return; return;
} else { } else {
sender.sendMessage(ChatColor.RED + "You must specify a valid element."); sender.sendMessage(ChatColor.RED + "You must specify a valid element.");
} }
} }
public static boolean isVowel(char c) {
return "AEIOUaeiou".indexOf(c) != -1;
}
} }

View file

@ -2,6 +2,7 @@ package com.projectkorra.projectkorra.command;
import com.projectkorra.projectkorra.BendingPlayer; import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.Element; import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.Element.SubElement;
import com.projectkorra.projectkorra.ability.CoreAbility; import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.object.Preset; import com.projectkorra.projectkorra.object.Preset;
@ -77,6 +78,12 @@ public class BendingTabComplete implements TabCompleter {
list.add("WaterCombos"); list.add("WaterCombos");
list.add("ChiCombos"); list.add("ChiCombos");
list.add("Avatar"); list.add("Avatar");
for (Element e : Element.getAddonElements()) {
list.add(e.getName());
}
for (SubElement se : Element.getAddonSubElements()) {
list.add(se.getName());
}
return getPossibleCompletionsForGivenArgs(args, list); return getPossibleCompletionsForGivenArgs(args, list);
} else if (args[0].equalsIgnoreCase("add") || args[0].equalsIgnoreCase("a") || args[0].equalsIgnoreCase("choose") || args[0].equalsIgnoreCase("ch")) { } else if (args[0].equalsIgnoreCase("add") || args[0].equalsIgnoreCase("a") || args[0].equalsIgnoreCase("choose") || args[0].equalsIgnoreCase("ch")) {
if (args.length > 3 || !sender.hasPermission("bending.command.add")) if (args.length > 3 || !sender.hasPermission("bending.command.add"))
@ -89,6 +96,9 @@ public class BendingTabComplete implements TabCompleter {
l.add("Fire"); l.add("Fire");
l.add("Water"); l.add("Water");
l.add("Chi"); l.add("Chi");
for (Element e : Element.getAddonElements()) {
l.add(e.getName());
}
} }
else else
{ {
@ -183,6 +193,9 @@ public class BendingTabComplete implements TabCompleter {
l.add("Fire"); l.add("Fire");
l.add("Water"); l.add("Water");
l.add("Chi"); l.add("Chi");
for (Element e : Element.getAddonElements()) {
l.add(e.getName());
}
} }
return getPossibleCompletionsForGivenArgs(args, l); return getPossibleCompletionsForGivenArgs(args, l);
} else if (args[0].equalsIgnoreCase("who") || args[0].equalsIgnoreCase("w")) { } else if (args[0].equalsIgnoreCase("who") || args[0].equalsIgnoreCase("w")) {

View file

@ -48,11 +48,12 @@ public class ChooseCommand extends PKCommand {
return; return;
} }
String element = args.get(0).toLowerCase(); String element = args.get(0).toLowerCase();
if (Arrays.asList(Commands.elementaliases).contains(element)) { Element target = Element.getElement(element);
if (Arrays.asList(Element.getAllElements()).contains(target)) {
if (!hasPermission(sender, element)) { if (!hasPermission(sender, element)) {
return; return;
} }
add(sender, (Player) sender, element); add(sender, (Player) sender, target);
return; return;
} else { } else {
sender.sendMessage(ChatColor.RED + "That is not a valid element."); sender.sendMessage(ChatColor.RED + "That is not a valid element.");
@ -69,8 +70,9 @@ public class ChooseCommand extends PKCommand {
return; return;
} }
String element = args.get(0).toLowerCase(); String element = args.get(0).toLowerCase();
if (Arrays.asList(Commands.elementaliases).contains(element)) { Element targetElement = Element.getElement(element);
add(sender, target, element); if (Arrays.asList(Element.getAllElements()).contains(target)) {
add(sender, target, targetElement);
return; return;
} else { } else {
sender.sendMessage(ChatColor.RED + "That is not a valid element."); sender.sendMessage(ChatColor.RED + "That is not a valid element.");
@ -83,11 +85,9 @@ public class ChooseCommand extends PKCommand {
* *
* @param sender The CommandSender who issued the command * @param sender The CommandSender who issued the command
* @param target The Player to add the element to * @param target The Player to add the element to
* @param elementName The element to add to the Player * @param element The element to add to the Player
*/ */
private void add(CommandSender sender, Player target, String elementName) { private void add(CommandSender sender, Player target, Element element) {
elementName = getElement(elementName);
Element element = Element.getElement(elementName);
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(target); BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(target);
if (bPlayer == null) { if (bPlayer == null) {
@ -96,25 +96,20 @@ 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 (elementName.charAt(0) == 'w' || elementName.charAt(0) == 'f') {
target.sendMessage(color + "You are now a " + Character.toString(elementName.charAt(0)).toUpperCase() + elementName.substring(1) + "bender.");
} else if (elementName.charAt(0) == 'e' || elementName.charAt(0) == 'a') {
target.sendMessage(color + "You are now an " + Character.toString(elementName.charAt(0)).toUpperCase() + elementName.substring(1) + "bender.");
} else if (elementName.equalsIgnoreCase("chi")) {
target.sendMessage(color + "You are now a Chiblocker.");
}
if (!(sender instanceof Player) || !((Player) sender).equals(target)) { if (!(sender instanceof Player) || !((Player) sender).equals(target)) {
if (elementName.charAt(0) == 'w' || elementName.charAt(0) == 'f') { sender.sendMessage(ChatColor.DARK_AQUA + target.getName() + color + " is now a" + (isVowel(element.getName().charAt(0)) ? "n " : " ") + element.getName() + element.getType().getBender() + ".");
sender.sendMessage(ChatColor.DARK_AQUA + target.getName() + color + " is now a " + Character.toString(elementName.charAt(0)).toUpperCase() + elementName.substring(1) + "bender."); } else {
} else if (elementName.charAt(0) == 'e' || elementName.charAt(0) == 'a') { target.sendMessage(color + "You are now a" + (isVowel(element.getName().charAt(0)) ? "n " : " ") + element.getName() + element.getType().getBender() + ".");
sender.sendMessage(ChatColor.DARK_AQUA + target.getName() + color + " is now an " + Character.toString(elementName.charAt(0)).toUpperCase() + elementName.substring(1) + "bender.");
} else if (elementName.equalsIgnoreCase("chi")) {
target.sendMessage(color + "You are now a Chiblocker.");
}
} }
GeneralMethods.removeUnusableAbilities(target.getName()); GeneralMethods.removeUnusableAbilities(target.getName());
GeneralMethods.saveElements(bPlayer); GeneralMethods.saveElements(bPlayer);
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, target, element, Result.CHOOSE)); Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, target, element, Result.CHOOSE));
} }
public static boolean isVowel(char c) {
return "AEIOUaeiou".indexOf(c) != -1;
}
} }

View file

@ -1,14 +1,5 @@
package com.projectkorra.projectkorra.command; package com.projectkorra.projectkorra.command;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.HashMap;
import java.util.List;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.projectkorra.projectkorra.BendingPlayer; import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.Element; import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.Element.SubElement; import com.projectkorra.projectkorra.Element.SubElement;
@ -17,6 +8,14 @@ import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.ability.SubAbility; import com.projectkorra.projectkorra.ability.SubAbility;
import com.projectkorra.projectkorra.ability.util.ComboManager; import com.projectkorra.projectkorra.ability.util.ComboManager;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
/** /**
* Executor for /bending display. Extends {@link PKCommand}. * Executor for /bending display. Extends {@link PKCommand}.
*/ */
@ -34,16 +33,15 @@ public class DisplayCommand extends PKCommand {
//bending display [Element] //bending display [Element]
if (args.size() == 1) { if (args.size() == 1) {
String elementName = args.get(0).toLowerCase(); String elementName = args.get(0).toLowerCase().replace("bending", "");
Element element = Element.fromString(elementName.replace("combos", "").replace("combo", ""));
//combos //combos
if (Arrays.asList(Commands.comboaliases).contains(elementName)) { if (element != null && elementName.contains("combo")) {
elementName = this.getElement(elementName);
Element element = Element.getElement(elementName);
ChatColor color = element != null ? element.getColor() : null; ChatColor color = element != null ? element.getColor() : null;
ArrayList<String> combos = ComboManager.getCombosForElement(element); ArrayList<String> combos = ComboManager.getCombosForElement(element);
if (combos.isEmpty()) { if (combos.isEmpty()) {
sender.sendMessage(color + "There are no " + elementName + " combos avaliable."); sender.sendMessage(color + "There are no " + element.getName() + " combos available.");
return; return;
} }
for (String comboMove : combos) { for (String comboMove : combos) {
@ -51,7 +49,7 @@ public class DisplayCommand extends PKCommand {
if (!sender.hasPermission("bending.ability." + comboMove)) { if (!sender.hasPermission("bending.ability." + comboMove)) {
continue; continue;
} }
CoreAbility coreAbil = CoreAbility.getAbility(comboMove); CoreAbility coreAbil = CoreAbility.getAbility(comboMove);
if (coreAbil != null) { if (coreAbil != null) {
comboColor = coreAbil.getElement().getColor(); comboColor = coreAbil.getElement().getColor();
@ -60,42 +58,32 @@ public class DisplayCommand extends PKCommand {
} }
return; return;
} }
else if (element != null) {
//normal elements if (!element.equals(Element.AVATAR)) {
else if (Arrays.asList(Commands.elementaliases).contains(elementName)) { if (!(element instanceof SubElement)) {
elementName = getElement(elementName); displayElement(sender, element);
displayElement(sender, elementName); } else {
} displaySubElement(sender, element);
}
//subelements } else {
else if (Arrays.asList(Commands.subelementaliases).contains(elementName)) { displayAvatar(sender);
displaySubElement(sender, elementName); }
}
//avatar
else if (Arrays.asList(Commands.avataraliases).contains(elementName)) {
displayAvatar(sender);
} }
else { else {
ChatColor w = ChatColor.WHITE; StringBuilder elements = new StringBuilder(ChatColor.RED + "Not a valid argument.");
sender.sendMessage(ChatColor.RED + "Not a valid argument." + ChatColor.WHITE + "\nElements: " elements.append(ChatColor.WHITE + "\nElements: ");
+ Element.AIR.getColor() + "Air" + ChatColor.WHITE + " | " for (Element e : Element.getAllElements()) {
+ Element.WATER.getColor() + "Water" + ChatColor.WHITE + " | " if (!(e instanceof SubElement)) {
+ Element.EARTH.getColor() + "Earth" + ChatColor.WHITE + " | " elements.append(e.getColor() + e.getName() + ChatColor.WHITE + " | ");
+ Element.FIRE.getColor() + "Fire" + ChatColor.WHITE + " | " }
+ Element.CHI.getColor() + "Chi"); }
sender.sendMessage(w + "SubElements: " sender.sendMessage(elements.toString());
+ w + "\n-" + Element.AIR.getColor() + " Flight" StringBuilder subelements = new StringBuilder(ChatColor.WHITE + "SubElements: ");
+ w + "\n-" + Element.EARTH.getColor() + " Lavabending" for (SubElement e : Element.getAllSubElements()) {
+ w + "\n-" + Element.EARTH.getColor() + " Metalbending" subelements.append(ChatColor.WHITE + "\n- " + e.getColor() + e.getName());
+ w + "\n-" + Element.EARTH.getColor() + " Sandbending" }
+ w + "\n-" + Element.FIRE.getColor() + " Combustion" sender.sendMessage(subelements.toString());
+ w + "\n-" + Element.FIRE.getColor() + " Lightning"
+ w + "\n-" + Element.WATER.getColor() + " Bloodbending"
+ w + "\n-" + Element.WATER.getColor() + " Healing"
+ w + "\n-" + Element.WATER.getColor() + " Icebending"
+ w + "\n-" + Element.WATER.getColor() + " Plantbending");
} }
} }
if (args.size() == 0) { if (args.size() == 0) {
@ -107,7 +95,7 @@ public class DisplayCommand extends PKCommand {
displayBinds(sender); displayBinds(sender);
} }
} }
private void displayAvatar(CommandSender sender) { private void displayAvatar(CommandSender sender) {
List<CoreAbility> abilities = CoreAbility.getAbilitiesByElement(Element.AVATAR); List<CoreAbility> abilities = CoreAbility.getAbilitiesByElement(Element.AVATAR);
if (abilities.isEmpty()) { if (abilities.isEmpty()) {
@ -134,17 +122,16 @@ public class DisplayCommand extends PKCommand {
* @param sender The CommandSender to show the moves to * @param sender The CommandSender to show the moves to
* @param element The element to show the moves for * @param element The element to show the moves for
*/ */
private void displayElement(CommandSender sender, String element) { private void displayElement(CommandSender sender, Element element) {
element = this.getElement(element); List<CoreAbility> abilities = CoreAbility.getAbilitiesByElement(element);
List<CoreAbility> abilities = CoreAbility.getAbilitiesByElement(Element.getElement(element));
if (abilities.isEmpty()) { if (abilities.isEmpty()) {
sender.sendMessage(ChatColor.RED + "You must select a valid element."); sender.sendMessage(ChatColor.RED + "You must select a valid element.");
return; return;
} else if (abilities.isEmpty()) { } else if (abilities.isEmpty()) {
sender.sendMessage(ChatColor.YELLOW + "There are no " + element + " abilities enabled on the server."); sender.sendMessage(ChatColor.YELLOW + "There are no " + element + " abilities enabled on the server.");
} }
for (CoreAbility ability : abilities) { for (CoreAbility ability : abilities) {
if (ability instanceof SubAbility || ability.isHiddenAbility()) { if (ability instanceof SubAbility || ability.isHiddenAbility()) {
continue; continue;
@ -153,46 +140,16 @@ public class DisplayCommand extends PKCommand {
sender.sendMessage(ability.getElement().getColor() + ability.getName()); sender.sendMessage(ability.getElement().getColor() + ability.getName());
} }
} }
if (element.equalsIgnoreCase("earth")) { if (element.equals(Element.CHI)) {
if (sender.hasPermission("bending.earth.lavabending")) {
sender.sendMessage(ChatColor.DARK_GREEN + "Lavabending abilities: " + ChatColor.GREEN + "/bending display Lavabending");
}
if (sender.hasPermission("bending.earth.metalbending")) {
sender.sendMessage(ChatColor.DARK_GREEN + "Metalbending abilities: " + ChatColor.GREEN + "/bending display Metalbending");
}
if (sender.hasPermission("bending.earth.sandbending")) {
sender.sendMessage(ChatColor.DARK_GREEN + "Sandbending abilities: " + ChatColor.GREEN + "/bending display Sandbending");
}
} else if (element.equalsIgnoreCase("air")) {
sender.sendMessage(ChatColor.DARK_GRAY + "Combos: " + ChatColor.GRAY + "/bending display AirCombos");
if (sender.hasPermission("bending.air.flight")) {
sender.sendMessage(ChatColor.DARK_GRAY + "Flight abilities: " + ChatColor.GRAY + "/bending display Flight");
}
} else if (element.equalsIgnoreCase("fire")) {
sender.sendMessage(ChatColor.DARK_RED + "Combos: " + ChatColor.RED + "/bending display FireCombos");
if (sender.hasPermission("bending.fire.lightningbending")) {
sender.sendMessage(ChatColor.DARK_RED + "Lightning abilities: " + ChatColor.RED + "/bending display Lightning");
}
if (sender.hasPermission("bending.fire.combustionbending")) {
sender.sendMessage(ChatColor.DARK_RED + "Combustion abilities: " + ChatColor.RED + "/bending display Combustion");
}
} else if (element.equalsIgnoreCase("water")) {
sender.sendMessage(ChatColor.DARK_AQUA + "Combos: " + ChatColor.AQUA + "/bending display WaterCombos");
if (sender.hasPermission("bending.water.bloodbending")) {
sender.sendMessage(ChatColor.DARK_AQUA + "Bloodbending abilities: " + ChatColor.AQUA + "/bending display Bloodbending");
}
if (sender.hasPermission("bending.water.healing")) {
sender.sendMessage(ChatColor.DARK_AQUA + "Healing abilities: " + ChatColor.AQUA + "/bending display Healing");
}
if (sender.hasPermission("bending.water.icebending")) {
sender.sendMessage(ChatColor.DARK_AQUA + "Icebending abilities: " + ChatColor.AQUA + "/bending display Icebending");
}
if (sender.hasPermission("bending.water.plantbending")) {
sender.sendMessage(ChatColor.DARK_AQUA + "Plantbending abilities: " + ChatColor.AQUA + "/bending display Plantbending");
}
} else if (element.equalsIgnoreCase("chi")) {
sender.sendMessage(ChatColor.GOLD + "Combos: " + ChatColor.YELLOW + "/bending display ChiCombos"); sender.sendMessage(ChatColor.GOLD + "Combos: " + ChatColor.YELLOW + "/bending display ChiCombos");
} else {
sender.sendMessage(element.getSubColor() + "Combos: " + element.getColor() + "/bending display " + element.getName() + "Combos");
for (SubElement sub : Element.getSubElements(element)) {
if (sender.hasPermission("bending." + element.getName().toLowerCase() + "." + sub.getName().toLowerCase())) {
sender.sendMessage(sub.getColor() + sub.getName() + " abilities: " + element.getColor() + "/bending display " + sub.getName());
}
}
} }
} }
@ -202,26 +159,18 @@ public class DisplayCommand extends PKCommand {
* @param sender The CommandSender to show the moves to * @param sender The CommandSender to show the moves to
* @param element The subelement to show the moves for * @param element The subelement to show the moves for
*/ */
private void displaySubElement(CommandSender sender, String element) { private void displaySubElement(CommandSender sender, Element element) {
element = this.getElement(element); List<CoreAbility> abilities = CoreAbility.getAbilitiesByElement(element);
Element mainElement = Element.getElement(element);
List<CoreAbility> abilities = CoreAbility.getAbilitiesByElement(mainElement); if (abilities.isEmpty() && element != null) {
sender.sendMessage(ChatColor.YELLOW + "There are no " + element.getColor() + element + ChatColor.YELLOW + " abilities installed!");
if (mainElement instanceof SubElement) {
mainElement = ((SubElement) mainElement).getParentElement();
}
ChatColor color = mainElement != null ? mainElement.getColor() : null;
if (abilities.isEmpty() && mainElement != null) {
sender.sendMessage(ChatColor.YELLOW + "There are no " + color + element + ChatColor.YELLOW + " abilities installed!");
return; return;
} }
for (CoreAbility ability : abilities) { for (CoreAbility ability : abilities) {
if (ability.isHiddenAbility()) { if (ability.isHiddenAbility()) {
continue; continue;
} else if (!(sender instanceof Player) || GeneralMethods.canView((Player) sender, ability.getName())) { } else if (!(sender instanceof Player) || GeneralMethods.canView((Player) sender, ability.getName())) {
sender.sendMessage(color + ability.getName()); sender.sendMessage(element.getColor() + ability.getName());
} }
} }
} }

View file

@ -11,7 +11,6 @@ import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.List; import java.util.List;
/** /**
@ -31,24 +30,25 @@ public class RemoveCommand extends PKCommand {
Player player = Bukkit.getPlayer(args.get(0)); Player player = Bukkit.getPlayer(args.get(0));
if (player == null) { if (player == null) {
Element e = Element.getElement(getElement(args.get(0))); Element e = Element.fromString(args.get(0));
BendingPlayer senderBPlayer = BendingPlayer.getBendingPlayer(sender.getName()); BendingPlayer senderBPlayer = BendingPlayer.getBendingPlayer(sender.getName());
if (senderBPlayer != null && e != null && sender instanceof Player) { if (senderBPlayer != null && sender instanceof Player) {
if (senderBPlayer.hasElement(e)) { if (e != null) {
senderBPlayer.getElements().remove(e); if (senderBPlayer.hasElement(e)) {
GeneralMethods.saveElements(senderBPlayer); senderBPlayer.getElements().remove(e);
GeneralMethods.removeUnusableAbilities(sender.getName()); GeneralMethods.saveElements(senderBPlayer);
GeneralMethods.removeUnusableAbilities(sender.getName());
if (e == Element.CHI) {
sender.sendMessage(Element.CHI.getColor() + "You have removed your chiblocking."); sender.sendMessage(e.getColor() + "You have removed your " + e.getName() + e.getType().getBending() + ".");
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, (Player) sender, e, Result.REMOVE));
return;
} else {
sender.sendMessage(ChatColor.RED + "You do not have that element!");
return; return;
} }
sender.sendMessage(e.getColor() + "You have removed your " + e.toString().toLowerCase() + "bending.");
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, (Player) sender, e, Result.REMOVE));
return;
} else { } else {
sender.sendMessage(ChatColor.RED + "You do not have that element!"); sender.sendMessage(ChatColor.RED + "That is not a valid element!");
return; return;
} }
} }
@ -62,7 +62,7 @@ public class RemoveCommand extends PKCommand {
bPlayer = BendingPlayer.getBendingPlayer(player); bPlayer = BendingPlayer.getBendingPlayer(player);
} }
if (args.size() == 2) { if (args.size() == 2) {
Element e = Element.getElement(getElement(args.get(1))); Element e = Element.fromString(args.get(1));
if (e != null) { if (e != null) {
if (!bPlayer.hasElement(e)) { if (!bPlayer.hasElement(e)) {
sender.sendMessage(ChatColor.DARK_RED + "Targeted player does not have that element"); sender.sendMessage(ChatColor.DARK_RED + "Targeted player does not have that element");
@ -71,13 +71,8 @@ public class RemoveCommand extends PKCommand {
bPlayer.getElements().remove(e); bPlayer.getElements().remove(e);
GeneralMethods.saveElements(bPlayer); GeneralMethods.saveElements(bPlayer);
GeneralMethods.removeUnusableAbilities(player.getName()); GeneralMethods.removeUnusableAbilities(player.getName());
if (e == Element.CHI) { sender.sendMessage(e.getColor() + "You have removed the " + e.getName() + e.getType().getBending() + " of " + ChatColor.DARK_AQUA + player.getName());
sender.sendMessage(Element.CHI.getColor() + "You have removed the chiblocking of " + ChatColor.DARK_AQUA + player.getName()); sender.sendMessage(e.getColor() + "Your " + e.getName() + e.getType().getBending() + " has been removed by " + ChatColor.DARK_AQUA + player.getName());
player.sendMessage(Element.CHI.getColor() + "Your chiblocking has been removed by " + ChatColor.DARK_AQUA + sender.getName());
} else {
sender.sendMessage(e.getColor() + "You have removed the " + getElement(args.get(1)).toLowerCase() + "bending of " + ChatColor.DARK_AQUA + player.getName());
player.sendMessage(e.getColor() + "Your " + getElement(args.get(1)).toLowerCase() + "bending has been removed by " + ChatColor.DARK_AQUA + sender.getName());
}
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, player, e, Result.REMOVE)); Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, player, e, Result.REMOVE));
return; return;
} }
@ -105,13 +100,4 @@ public class RemoveCommand extends PKCommand {
sender.sendMessage(ChatColor.RED + "You don't have permission to use this command."); sender.sendMessage(ChatColor.RED + "You don't have permission to use this command.");
return false; return false;
} }
public String getElement(String string) {
if (Arrays.asList(Commands.airaliases).contains(string)) return "air";
if (Arrays.asList(Commands.chialiases).contains(string)) return "chi";
if (Arrays.asList(Commands.earthaliases).contains(string)) return "earth";
if (Arrays.asList(Commands.firealiases).contains(string)) return "fire";
if (Arrays.asList(Commands.wateraliases).contains(string)) return "water";
return null;
}
} }

View file

@ -9,7 +9,6 @@ import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import java.util.Arrays;
import java.util.List; import java.util.List;
/** /**
@ -45,55 +44,56 @@ public class ToggleCommand extends PKCommand {
sender.sendMessage(ChatColor.GREEN + "You have turned your Bending back on."); sender.sendMessage(ChatColor.GREEN + "You have turned your Bending back on.");
bPlayer.toggleBending(); bPlayer.toggleBending();
} }
} else if (args.size() == 1 && args.get(0).equalsIgnoreCase("all") && hasPermission(sender, "all")) { //bending toggle all } else if (args.size() == 1 ) {
if (Commands.isToggledForAll) { // Bending is toggled off for all players. if (args.size() == 1 && args.get(0).equalsIgnoreCase("all") && hasPermission(sender, "all")) { //bending toggle all
Commands.isToggledForAll = false; if (Commands.isToggledForAll) { // Bending is toggled off for all players.
for (Player player : Bukkit.getOnlinePlayers()) { Commands.isToggledForAll = false;
player.sendMessage(ChatColor.GREEN + "Bending has been toggled back on for all players."); for (Player player : Bukkit.getOnlinePlayers()) {
} player.sendMessage(ChatColor.GREEN + "Bending has been toggled back on for all players.");
if (!(sender instanceof Player)) }
sender.sendMessage(ChatColor.GREEN + "Bending has been toggled back on for all players."); if (!(sender instanceof Player))
} else { sender.sendMessage(ChatColor.GREEN + "Bending has been toggled back on for all players.");
Commands.isToggledForAll = true;
for (Player player : Bukkit.getOnlinePlayers()) {
player.sendMessage(ChatColor.RED + "Bending has been toggled off for all players.");
}
if (!(sender instanceof Player))
sender.sendMessage(ChatColor.RED + "Bending has been toggled off for all players.");
}
} else if (sender instanceof Player && args.size() == 1
&& Element.getElement(getElement(args.get(0))) != null
&& BendingPlayer.getBendingPlayer(sender.getName()).hasElement(Element.getElement(getElement(args.get(0))))) {
Element e = Element.getElement(getElement(args.get(0)));
ChatColor color = e != null ? e.getColor() : null;
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(sender.getName());
bPlayer.toggleElement(e);
if (bPlayer.isElementToggled(e) == false) {
if (e == Element.CHI) {
sender.sendMessage(color + "You have toggled off your chiblocking");
} else { } else {
sender.sendMessage(color + "You have toggled off your " + getElement(args.get(0)).toLowerCase() + "bending"); Commands.isToggledForAll = true;
for (Player player : Bukkit.getOnlinePlayers()) {
player.sendMessage(ChatColor.RED + "Bending has been toggled off for all players.");
}
if (!(sender instanceof Player))
sender.sendMessage(ChatColor.RED + "Bending has been toggled off for all players.");
} }
} else { } else if (sender instanceof Player && args.size() == 1
if (e == Element.CHI) { && Element.fromString(args.get(0)) != null) {
sender.sendMessage(color + "You have toggled on your chiblocking"); if (!BendingPlayer.getBendingPlayer(sender.getName()).hasElement(Element.fromString(args.get(0)))) {
sender.sendMessage(ChatColor.RED + "You do not have that element.");
return;
}
Element e = Element.fromString(args.get(0));
ChatColor color = e != null ? e.getColor() : null;
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(sender.getName());
bPlayer.toggleElement(e);
if (bPlayer.isElementToggled(e)) {
sender.sendMessage(color + "You have toggled on your " + e.getName() + (e.getType() != null ? e.getType().getBending() : "") + ".");
} else { } else {
sender.sendMessage(color + "You have toggled on your " + getElement(args.get(0)).toLowerCase() + "bending"); sender.sendMessage(color + "You have toggled off your " + e.getName() + (e.getType() != null ? e.getType().getBending() : "") + ".");
} }
} }
} else if (sender instanceof Player && args.size() == 2 } else if (sender instanceof Player && args.size() == 2
&& Element.getElement(getElement(args.get(0))) != null && Element.fromString(args.get(0)) != null) {
&& BendingPlayer.getBendingPlayer(sender.getName()).hasElement(Element.getElement(getElement(args.get(0))))) {
Player target = Bukkit.getPlayer(args.get(1)); Player target = Bukkit.getPlayer(args.get(1));
if (!hasAdminPermission(sender)) return; if (!hasAdminPermission(sender)) return;
if (target == null) { if (target == null) {
sender.sendMessage(ChatColor.RED + "Target is not found."); sender.sendMessage(ChatColor.RED + "Target is not found.");
return;
} }
Element e = Element.getElement(getElement(args.get(0))); if (!BendingPlayer.getBendingPlayer(target.getName()).hasElement(Element.fromString(args.get(0)))) {
sender.sendMessage(ChatColor.DARK_AQUA + target.getName() + ChatColor.RED + " doesn't have that element.");
return;
}
Element e = Element.fromString(args.get(0));
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(target.getName()); BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(target.getName());
ChatColor color = e != null ? e.getColor() : null; ChatColor color = e != null ? e.getColor() : null;
if (bPlayer.isElementToggled(e) == true) { if (bPlayer.isElementToggled(e) == true) {
if (e == Element.CHI) { if (e == Element.CHI) {
sender.sendMessage(color + "You have toggled off " + ChatColor.DARK_AQUA + target.getName() + "'s chiblocking"); sender.sendMessage(color + "You have toggled off " + ChatColor.DARK_AQUA + target.getName() + "'s chiblocking");
@ -117,15 +117,6 @@ public class ToggleCommand extends PKCommand {
} }
} }
public String getElement(String string) {
if (Arrays.asList(Commands.airaliases).contains(string)) return "air";
if (Arrays.asList(Commands.chialiases).contains(string)) return "chi";
if (Arrays.asList(Commands.earthaliases).contains(string)) return "earth";
if (Arrays.asList(Commands.firealiases).contains(string)) return "fire";
if (Arrays.asList(Commands.wateraliases).contains(string)) return "water";
return null;
}
public boolean hasAdminPermission(CommandSender sender) { public boolean hasAdminPermission(CommandSender sender) {
if (!sender.hasPermission("bending.admin.toggle")) { if (!sender.hasPermission("bending.admin.toggle")) {
sender.sendMessage(ChatColor.RED + "You don't have permission to do that."); sender.sendMessage(ChatColor.RED + "You don't have permission to do that.");

View file

@ -2,6 +2,8 @@ package com.projectkorra.projectkorra.command;
import com.projectkorra.projectkorra.BendingPlayer; import com.projectkorra.projectkorra.BendingPlayer;
import com.projectkorra.projectkorra.Element; import com.projectkorra.projectkorra.Element;
import com.projectkorra.projectkorra.Element.ElementType;
import com.projectkorra.projectkorra.Element.SubElement;
import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ProjectKorra; import com.projectkorra.projectkorra.ProjectKorra;
import com.projectkorra.projectkorra.ability.CoreAbility; import com.projectkorra.projectkorra.ability.CoreAbility;
@ -84,35 +86,11 @@ public class WhoCommand extends PKCommand {
GeneralMethods.createBendingPlayer(player.getUniqueId(), player.getName()); GeneralMethods.createBendingPlayer(player.getUniqueId(), player.getName());
bp = BendingPlayer.getBendingPlayer(player.getName()); bp = BendingPlayer.getBendingPlayer(player.getName());
} }
if (bp.hasElement(Element.AIR)) { for (Element element : bp.getElements()) {
result = ChatColor.WHITE + playerName + " - " + ((!bp.isElementToggled(Element.AIR) || !bp.isToggled()) ? ChatColor.translateAlternateColorCodes('&', "&7&mA") : Element.AIR.getColor() + "A");
}
if (bp.hasElement(Element.EARTH)) {
if (result == "") { if (result == "") {
result = ChatColor.WHITE + playerName + " - " + ((!bp.isElementToggled(Element.EARTH) || !bp.isToggled()) ? ChatColor.translateAlternateColorCodes('&', "&a&mE") : Element.EARTH.getColor() + "E"); result = ChatColor.WHITE + playerName + " - " + (((!bp.isElementToggled(element) || !bp.isToggled()) ? element.getColor() + "" + ChatColor.STRIKETHROUGH : element.getColor()) + element.getName().substring(0, 1));
} else { } else {
result = result + ChatColor.WHITE + " | " + ((!bp.isElementToggled(Element.EARTH) || !bp.isToggled()) ? ChatColor.translateAlternateColorCodes('&', "&a&mE") : Element.EARTH.getColor() + "E"); result = result + ChatColor.WHITE + " | " + (((!bp.isElementToggled(element) || !bp.isToggled()) ? element.getColor() + "" + ChatColor.STRIKETHROUGH : element.getColor()) + element.getName().substring(0, 1));
}
}
if (bp.hasElement(Element.FIRE)) {
if (result == "") {
result = ChatColor.WHITE + playerName + " - " + ((!bp.isElementToggled(Element.FIRE) || !bp.isToggled()) ? ChatColor.translateAlternateColorCodes('&', "&c&mF") : Element.FIRE.getColor() + "F");
} else {
result = result + ChatColor.WHITE + " | " + ((!bp.isElementToggled(Element.FIRE) || !bp.isToggled()) ? ChatColor.translateAlternateColorCodes('&', "&c&mF") : Element.FIRE.getColor() + "F");
}
}
if (bp.hasElement(Element.WATER)) {
if (result == "") {
result = ChatColor.WHITE + playerName + " - " + ((!bp.isElementToggled(Element.WATER) || !bp.isToggled()) ? ChatColor.translateAlternateColorCodes('&', "&b&mW") : Element.WATER.getColor() + "W");
} else {
result = result + ChatColor.WHITE + " | " + ((!bp.isElementToggled(Element.WATER) || !bp.isToggled()) ? ChatColor.translateAlternateColorCodes('&', "&b&mW") : Element.WATER.getColor() + "W");
}
}
if (bp.hasElement(Element.CHI)) {
if (result == "") {
result = ChatColor.WHITE + playerName + " - " + ((!bp.isElementToggled(Element.CHI) || !bp.isToggled()) ? ChatColor.translateAlternateColorCodes('&', "&6&mC") : Element.CHI.getColor() + "C");
} else {
result = result + ChatColor.WHITE + " | " + ((!bp.isElementToggled(Element.CHI) || !bp.isToggled()) ? ChatColor.translateAlternateColorCodes('&', "&6&mC") : Element.CHI.getColor() + "C");
} }
} }
if (staff.containsKey(player.getUniqueId().toString())) { if (staff.containsKey(player.getUniqueId().toString())) {
@ -268,6 +246,18 @@ public class WhoCommand extends PKCommand {
sender.sendMessage(Element.CHI.getColor() + "" + ChatColor.STRIKETHROUGH + "- Chiblocker"); sender.sendMessage(Element.CHI.getColor() + "" + ChatColor.STRIKETHROUGH + "- Chiblocker");
} }
} }
for (Element element : Element.getAddonElements()) {
if (bPlayer.hasElement(element)) {
sender.sendMessage(element.getColor() + "" + (bPlayer.isElementToggled(element) ? "" : ChatColor.STRIKETHROUGH) + "- " + element.getName() + (element.getType() != null ? element.getType().getBender() : ""));
if (player_ != null) {
for (SubElement subelement : Element.getSubElements(element)) {
if (player_.hasPermission("bending." + element.getName().toLowerCase() + "." + subelement.getName().toLowerCase())) {
sender.sendMessage(subelement.getColor() + " Can " + (!subelement.getType().equals(ElementType.NO_SUFFIX) ? "" : "use ") + subelement.getName() + subelement.getType().getBend());
}
}
}
}
}
UUID uuid = player.getUniqueId(); UUID uuid = player.getUniqueId();
if (bPlayer != null) { if (bPlayer != null) {