mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-08-17 08:57:40 +00:00
Add support for custom elements
This commit is contained in:
parent
f599b5ca1e
commit
042866ec62
|
@ -75,11 +75,11 @@ public class BendingPlayer {
|
|||
this.chiBlocked = false;
|
||||
cooldowns = new ConcurrentHashMap<String, Long>();
|
||||
toggledElements = new ConcurrentHashMap<Element, Boolean>();
|
||||
toggledElements.put(Element.AIR, true);
|
||||
toggledElements.put(Element.EARTH, true);
|
||||
toggledElements.put(Element.FIRE, true);
|
||||
toggledElements.put(Element.WATER, true);
|
||||
toggledElements.put(Element.CHI, true);
|
||||
for (Element e : Element.getAllElements()) {
|
||||
if (!e.equals(Element.AVATAR)) {
|
||||
toggledElements.put(e, true);
|
||||
}
|
||||
}
|
||||
|
||||
PLAYERS.put(uuid, this);
|
||||
PKListener.login(this);
|
||||
|
@ -483,7 +483,7 @@ public class BendingPlayer {
|
|||
|
||||
public boolean isElementToggled(Element element) {
|
||||
if (element != null && toggledElements.containsKey(element)) {
|
||||
return toggledElements.containsKey(element);
|
||||
return toggledElements.get(element);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
@ -1,23 +1,54 @@
|
|||
package com.projectkorra.projectkorra;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
|
||||
public class Element {
|
||||
|
||||
public enum ElementType {
|
||||
BENDING("bending", "bender", "bend"),
|
||||
BLOCKING("blocking", "blocker", "block");
|
||||
|
||||
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
|
||||
|
||||
public static final Element AIR = new Element("Air");
|
||||
public static final Element WATER = new Element("Water");
|
||||
public static final Element EARTH = new Element("Earth");
|
||||
public static final Element FIRE = new Element("Fire");
|
||||
public static final Element CHI = new Element("Chi");
|
||||
public static final Element AVATAR = new Element("Avatar");
|
||||
public static final Element CHI = new Element("Chi", ElementType.BLOCKING);
|
||||
public static final Element AVATAR = new Element("Avatar", null);
|
||||
public static final SubElement FLIGHT = new SubElement("Flight", AIR);
|
||||
public static final SubElement SPIRITUAL = new SubElement("Spiritual", AIR);
|
||||
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, null);
|
||||
public static final SubElement ICE = new SubElement("Ice", WATER);
|
||||
public static final SubElement PLANT = new SubElement("Plant", WATER);
|
||||
public static final SubElement LAVA = new SubElement("Lava", EARTH);
|
||||
|
@ -31,6 +62,8 @@ public class Element {
|
|||
private static final SubElement[] SUB_ELEMENTS = {FLIGHT, SPIRITUAL, BLOOD, HEALING, ICE, PLANT, LAVA, METAL, SAND, LIGHTNING, COMBUSTION};
|
||||
|
||||
private String name;
|
||||
private ElementType type;
|
||||
private Plugin plugin;
|
||||
|
||||
/**
|
||||
* To be used when creating a new Element.
|
||||
|
@ -38,18 +71,55 @@ public class Element {
|
|||
* @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.type = type;
|
||||
this.plugin = plugin;
|
||||
ALL_ELEMENTS.put(name.toLowerCase(), this);
|
||||
}
|
||||
|
||||
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() {
|
||||
return name;
|
||||
}
|
||||
|
||||
public Plugin getPlugin() {
|
||||
return plugin;
|
||||
}
|
||||
|
||||
public ElementType getType() {
|
||||
return type;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toString() {
|
||||
return getColor() + getName();
|
||||
|
@ -62,6 +132,17 @@ public class Element {
|
|||
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() {
|
||||
return ELEMENTS;
|
||||
}
|
||||
|
@ -70,10 +151,69 @@ public class Element {
|
|||
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() {
|
||||
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 {
|
||||
|
||||
private Element parentElement;
|
||||
|
@ -82,15 +222,40 @@ public class Element {
|
|||
* 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) {
|
||||
super(name);
|
||||
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;
|
||||
}
|
||||
|
||||
@Override
|
||||
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() {
|
||||
|
|
|
@ -302,23 +302,32 @@ public class GeneralMethods {
|
|||
String permaremoved = rs2.getString("permaremoved");
|
||||
boolean p = false;
|
||||
final ArrayList<Element> elements = new ArrayList<Element>();
|
||||
if (element != null) { // Player has an element.
|
||||
if (element.contains("a")) {
|
||||
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 (element.contains("w")) {
|
||||
if (split[0].contains("w")) {
|
||||
elements.add(Element.WATER);
|
||||
}
|
||||
if (element.contains("e")) {
|
||||
if (split[0].contains("e")) {
|
||||
elements.add(Element.EARTH);
|
||||
}
|
||||
if (element.contains("f")) {
|
||||
if (split[0].contains("f")) {
|
||||
elements.add(Element.FIRE);
|
||||
}
|
||||
if (element.contains("c")) {
|
||||
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));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
final HashMap<Integer, String> abilities = new HashMap<Integer, String>();
|
||||
for (int i = 1; i <= 9; i++) {
|
||||
|
@ -1489,6 +1498,16 @@ public class GeneralMethods {
|
|||
if (bPlayer.hasElement(Element.CHI)) {
|
||||
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 + "'");
|
||||
}
|
||||
|
|
|
@ -30,7 +30,7 @@ public class AddCommand extends PKCommand {
|
|||
if (!hasPermission(sender) || !isPlayer(sender)) {
|
||||
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
|
||||
if (!hasPermission(sender, "others")) {
|
||||
return;
|
||||
|
@ -40,7 +40,7 @@ public class AddCommand extends PKCommand {
|
|||
sender.sendMessage(ChatColor.RED + "That player is not online.");
|
||||
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 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);
|
||||
if (bPlayer == null) {
|
||||
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.");
|
||||
return;
|
||||
}
|
||||
if (Arrays.asList(Commands.elementaliases).contains(element.toLowerCase())) {
|
||||
element = getElement(element.toLowerCase());
|
||||
Element type = Element.getElement(element);
|
||||
bPlayer.addElement(type);
|
||||
ChatColor color = type.getColor();
|
||||
|
||||
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.");
|
||||
if (Arrays.asList(Element.getAllElements()).contains(element)) {
|
||||
if (bPlayer.hasElement(element)) {
|
||||
if (!(sender instanceof Player) || !((Player) sender).equals(target)) {
|
||||
sender.sendMessage(ChatColor.DARK_AQUA + target.getName() + ChatColor.RED + " already has that element!");
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "You already have that element!");
|
||||
}
|
||||
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() != 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() : ""));
|
||||
}
|
||||
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;
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "You must specify a valid element.");
|
||||
}
|
||||
}
|
||||
|
||||
public static boolean isVowel(char c) {
|
||||
return "AEIOUaeiou".indexOf(c) != -1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -48,11 +48,12 @@ public class ChooseCommand extends PKCommand {
|
|||
return;
|
||||
}
|
||||
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)) {
|
||||
return;
|
||||
}
|
||||
add(sender, (Player) sender, element);
|
||||
add(sender, (Player) sender, target);
|
||||
return;
|
||||
} else {
|
||||
sender.sendMessage(ChatColor.RED + "That is not a valid element.");
|
||||
|
@ -69,8 +70,9 @@ public class ChooseCommand extends PKCommand {
|
|||
return;
|
||||
}
|
||||
String element = args.get(0).toLowerCase();
|
||||
if (Arrays.asList(Commands.elementaliases).contains(element)) {
|
||||
add(sender, target, element);
|
||||
Element targetElement = Element.getElement(element);
|
||||
if (Arrays.asList(Element.getAllElements()).contains(target)) {
|
||||
add(sender, target, targetElement);
|
||||
return;
|
||||
} else {
|
||||
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 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) {
|
||||
elementName = getElement(elementName);
|
||||
Element element = Element.getElement(elementName);
|
||||
private void add(CommandSender sender, Player target, Element element) {
|
||||
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(target);
|
||||
|
||||
if (bPlayer == null) {
|
||||
|
@ -96,25 +96,28 @@ public class ChooseCommand extends PKCommand {
|
|||
|
||||
bPlayer.setElement(element);
|
||||
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 (elementName.charAt(0) == 'w' || elementName.charAt(0) == 'f') {
|
||||
sender.sendMessage(ChatColor.DARK_AQUA + target.getName() + color + " is now a " + Character.toString(elementName.charAt(0)).toUpperCase() + elementName.substring(1) + "bender.");
|
||||
} else if (elementName.charAt(0) == 'e' || elementName.charAt(0) == 'a') {
|
||||
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")) {
|
||||
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.");
|
||||
}
|
||||
} 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.");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
GeneralMethods.removeUnusableAbilities(target.getName());
|
||||
GeneralMethods.saveElements(bPlayer);
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, target, element, Result.CHOOSE));
|
||||
}
|
||||
|
||||
public static boolean isVowel(char c) {
|
||||
return "AEIOUaeiou".indexOf(c) != -1;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,14 +1,5 @@
|
|||
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.Element;
|
||||
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.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}.
|
||||
*/
|
||||
|
@ -34,16 +33,15 @@ public class DisplayCommand extends PKCommand {
|
|||
|
||||
//bending display [Element]
|
||||
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
|
||||
if (Arrays.asList(Commands.comboaliases).contains(elementName)) {
|
||||
elementName = this.getElement(elementName);
|
||||
Element element = Element.getElement(elementName);
|
||||
if (element != null && elementName.contains("combo")) {
|
||||
ChatColor color = element != null ? element.getColor() : null;
|
||||
ArrayList<String> combos = ComboManager.getCombosForElement(element);
|
||||
|
||||
|
||||
if (combos.isEmpty()) {
|
||||
sender.sendMessage(color + "There are no " + elementName + " combos avaliable.");
|
||||
sender.sendMessage(color + "There are no " + element.getName() + " combos available.");
|
||||
return;
|
||||
}
|
||||
for (String comboMove : combos) {
|
||||
|
@ -51,7 +49,7 @@ public class DisplayCommand extends PKCommand {
|
|||
if (!sender.hasPermission("bending.ability." + comboMove)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
|
||||
CoreAbility coreAbil = CoreAbility.getAbility(comboMove);
|
||||
if (coreAbil != null) {
|
||||
comboColor = coreAbil.getElement().getColor();
|
||||
|
@ -60,42 +58,32 @@ public class DisplayCommand extends PKCommand {
|
|||
}
|
||||
return;
|
||||
}
|
||||
|
||||
//normal elements
|
||||
else if (Arrays.asList(Commands.elementaliases).contains(elementName)) {
|
||||
elementName = getElement(elementName);
|
||||
displayElement(sender, elementName);
|
||||
}
|
||||
|
||||
//subelements
|
||||
else if (Arrays.asList(Commands.subelementaliases).contains(elementName)) {
|
||||
displaySubElement(sender, elementName);
|
||||
}
|
||||
|
||||
//avatar
|
||||
else if (Arrays.asList(Commands.avataraliases).contains(elementName)) {
|
||||
displayAvatar(sender);
|
||||
else if (element != null) {
|
||||
if (!element.equals(Element.AVATAR)) {
|
||||
if (!(element instanceof SubElement)) {
|
||||
displayElement(sender, element);
|
||||
} else {
|
||||
displaySubElement(sender, element);
|
||||
}
|
||||
} else {
|
||||
displayAvatar(sender);
|
||||
}
|
||||
}
|
||||
|
||||
else {
|
||||
ChatColor w = ChatColor.WHITE;
|
||||
sender.sendMessage(ChatColor.RED + "Not a valid argument." + ChatColor.WHITE + "\nElements: "
|
||||
+ Element.AIR.getColor() + "Air" + ChatColor.WHITE + " | "
|
||||
+ Element.WATER.getColor() + "Water" + ChatColor.WHITE + " | "
|
||||
+ Element.EARTH.getColor() + "Earth" + ChatColor.WHITE + " | "
|
||||
+ Element.FIRE.getColor() + "Fire" + ChatColor.WHITE + " | "
|
||||
+ Element.CHI.getColor() + "Chi");
|
||||
sender.sendMessage(w + "SubElements: "
|
||||
+ w + "\n-" + Element.AIR.getColor() + " Flight"
|
||||
+ w + "\n-" + Element.EARTH.getColor() + " Lavabending"
|
||||
+ w + "\n-" + Element.EARTH.getColor() + " Metalbending"
|
||||
+ w + "\n-" + Element.EARTH.getColor() + " Sandbending"
|
||||
+ w + "\n-" + Element.FIRE.getColor() + " Combustion"
|
||||
+ 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");
|
||||
StringBuilder elements = new StringBuilder(ChatColor.RED + "Not a valid argument.");
|
||||
elements.append(ChatColor.WHITE + "\nElements: ");
|
||||
for (Element e : Element.getAllElements()) {
|
||||
if (!(e instanceof SubElement)) {
|
||||
elements.append(e.getColor() + e.getName() + ChatColor.WHITE + " | ");
|
||||
}
|
||||
}
|
||||
sender.sendMessage(elements.toString());
|
||||
StringBuilder subelements = new StringBuilder(ChatColor.WHITE + "SubElements: ");
|
||||
for (SubElement e : Element.getAllSubElements()) {
|
||||
subelements.append(ChatColor.WHITE + "\n- " + e.getColor() + e.getName());
|
||||
}
|
||||
sender.sendMessage(subelements.toString());
|
||||
}
|
||||
}
|
||||
if (args.size() == 0) {
|
||||
|
@ -107,7 +95,7 @@ public class DisplayCommand extends PKCommand {
|
|||
displayBinds(sender);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void displayAvatar(CommandSender sender) {
|
||||
List<CoreAbility> abilities = CoreAbility.getAbilitiesByElement(Element.AVATAR);
|
||||
if (abilities.isEmpty()) {
|
||||
|
@ -134,17 +122,16 @@ public class DisplayCommand extends PKCommand {
|
|||
* @param sender The CommandSender to show the moves to
|
||||
* @param element The element to show the moves for
|
||||
*/
|
||||
private void displayElement(CommandSender sender, String element) {
|
||||
element = this.getElement(element);
|
||||
List<CoreAbility> abilities = CoreAbility.getAbilitiesByElement(Element.getElement(element));
|
||||
|
||||
private void displayElement(CommandSender sender, Element element) {
|
||||
List<CoreAbility> abilities = CoreAbility.getAbilitiesByElement(element);
|
||||
|
||||
if (abilities.isEmpty()) {
|
||||
sender.sendMessage(ChatColor.RED + "You must select a valid element.");
|
||||
return;
|
||||
} else if (abilities.isEmpty()) {
|
||||
sender.sendMessage(ChatColor.YELLOW + "There are no " + element + " abilities enabled on the server.");
|
||||
}
|
||||
|
||||
|
||||
for (CoreAbility ability : abilities) {
|
||||
if (ability instanceof SubAbility || ability.isHiddenAbility()) {
|
||||
continue;
|
||||
|
@ -153,46 +140,16 @@ public class DisplayCommand extends PKCommand {
|
|||
sender.sendMessage(ability.getElement().getColor() + ability.getName());
|
||||
}
|
||||
}
|
||||
|
||||
if (element.equalsIgnoreCase("earth")) {
|
||||
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")) {
|
||||
|
||||
if (element.equals(Element.CHI)) {
|
||||
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 element The subelement to show the moves for
|
||||
*/
|
||||
private void displaySubElement(CommandSender sender, String element) {
|
||||
element = this.getElement(element);
|
||||
Element mainElement = Element.getElement(element);
|
||||
List<CoreAbility> abilities = CoreAbility.getAbilitiesByElement(mainElement);
|
||||
|
||||
|
||||
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!");
|
||||
private void displaySubElement(CommandSender sender, Element element) {
|
||||
List<CoreAbility> abilities = CoreAbility.getAbilitiesByElement(element);
|
||||
|
||||
if (abilities.isEmpty() && element != null) {
|
||||
sender.sendMessage(ChatColor.YELLOW + "There are no " + element.getColor() + element + ChatColor.YELLOW + " abilities installed!");
|
||||
return;
|
||||
}
|
||||
for (CoreAbility ability : abilities) {
|
||||
if (ability.isHiddenAbility()) {
|
||||
continue;
|
||||
} else if (!(sender instanceof Player) || GeneralMethods.canView((Player) sender, ability.getName())) {
|
||||
sender.sendMessage(color + ability.getName());
|
||||
sender.sendMessage(element.getColor() + ability.getName());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -31,24 +31,29 @@ public class RemoveCommand extends PKCommand {
|
|||
|
||||
Player player = Bukkit.getPlayer(args.get(0));
|
||||
if (player == null) {
|
||||
Element e = Element.getElement(getElement(args.get(0)));
|
||||
Element e = Element.fromString(args.get(0));
|
||||
BendingPlayer senderBPlayer = BendingPlayer.getBendingPlayer(sender.getName());
|
||||
|
||||
if (senderBPlayer != null && e != null && sender instanceof Player) {
|
||||
if (senderBPlayer.hasElement(e)) {
|
||||
senderBPlayer.getElements().remove(e);
|
||||
GeneralMethods.saveElements(senderBPlayer);
|
||||
GeneralMethods.removeUnusableAbilities(sender.getName());
|
||||
|
||||
if (e == Element.CHI) {
|
||||
sender.sendMessage(Element.CHI.getColor() + "You have removed your chiblocking.");
|
||||
|
||||
if (senderBPlayer != null && sender instanceof Player) {
|
||||
if (e != null) {
|
||||
if (senderBPlayer.hasElement(e)) {
|
||||
senderBPlayer.getElements().remove(e);
|
||||
GeneralMethods.saveElements(senderBPlayer);
|
||||
GeneralMethods.removeUnusableAbilities(sender.getName());
|
||||
|
||||
if (e == Element.CHI) {
|
||||
sender.sendMessage(Element.CHI.getColor() + "You have removed your Chiblocking.");
|
||||
return;
|
||||
}
|
||||
sender.sendMessage(e.getColor() + "You have removed your " + e.getName() + "bending.");
|
||||
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;
|
||||
}
|
||||
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 {
|
||||
sender.sendMessage(ChatColor.RED + "You do not have that element!");
|
||||
sender.sendMessage(ChatColor.RED + "That is not a valid element!");
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
@ -62,7 +67,7 @@ public class RemoveCommand extends PKCommand {
|
|||
bPlayer = BendingPlayer.getBendingPlayer(player);
|
||||
}
|
||||
if (args.size() == 2) {
|
||||
Element e = Element.getElement(getElement(args.get(1)));
|
||||
Element e = Element.fromString(args.get(1));
|
||||
if (e != null) {
|
||||
if (!bPlayer.hasElement(e)) {
|
||||
sender.sendMessage(ChatColor.DARK_RED + "Targeted player does not have that element");
|
||||
|
@ -72,11 +77,11 @@ public class RemoveCommand extends PKCommand {
|
|||
GeneralMethods.saveElements(bPlayer);
|
||||
GeneralMethods.removeUnusableAbilities(player.getName());
|
||||
if (e == Element.CHI) {
|
||||
sender.sendMessage(Element.CHI.getColor() + "You have removed the chiblocking of " + ChatColor.DARK_AQUA + player.getName());
|
||||
player.sendMessage(Element.CHI.getColor() + "Your chiblocking has been removed by " + ChatColor.DARK_AQUA + sender.getName());
|
||||
sender.sendMessage(Element.CHI.getColor() + "You have removed the Chiblocking of " + 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());
|
||||
sender.sendMessage(e.getColor() + "You have removed the " + e.getName() + "bending of " + ChatColor.DARK_AQUA + player.getName());
|
||||
player.sendMessage(e.getColor() + "Your " + e.getName() + "bending has been removed by " + ChatColor.DARK_AQUA + sender.getName());
|
||||
}
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, player, e, Result.REMOVE));
|
||||
return;
|
||||
|
@ -105,7 +110,7 @@ public class RemoveCommand extends PKCommand {
|
|||
sender.sendMessage(ChatColor.RED + "You don't have permission to use this command.");
|
||||
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";
|
||||
|
|
|
@ -9,7 +9,6 @@ import org.bukkit.ChatColor;
|
|||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -45,55 +44,56 @@ public class ToggleCommand extends PKCommand {
|
|||
sender.sendMessage(ChatColor.GREEN + "You have turned your Bending back on.");
|
||||
bPlayer.toggleBending();
|
||||
}
|
||||
} else if (args.size() == 1 && args.get(0).equalsIgnoreCase("all") && hasPermission(sender, "all")) { //bending toggle all
|
||||
if (Commands.isToggledForAll) { // Bending is toggled off for all players.
|
||||
Commands.isToggledForAll = false;
|
||||
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.");
|
||||
} else {
|
||||
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 if (args.size() == 1 ) {
|
||||
if (args.size() == 1 && args.get(0).equalsIgnoreCase("all") && hasPermission(sender, "all")) { //bending toggle all
|
||||
if (Commands.isToggledForAll) { // Bending is toggled off for all players.
|
||||
Commands.isToggledForAll = false;
|
||||
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.");
|
||||
} 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 {
|
||||
if (e == Element.CHI) {
|
||||
sender.sendMessage(color + "You have toggled on your chiblocking");
|
||||
} else if (sender instanceof Player && args.size() == 1
|
||||
&& Element.fromString(args.get(0)) != null) {
|
||||
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 {
|
||||
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
|
||||
&& Element.getElement(getElement(args.get(0))) != null
|
||||
&& BendingPlayer.getBendingPlayer(sender.getName()).hasElement(Element.getElement(getElement(args.get(0))))) {
|
||||
&& Element.fromString(args.get(0)) != null) {
|
||||
Player target = Bukkit.getPlayer(args.get(1));
|
||||
if (!hasAdminPermission(sender)) return;
|
||||
if (target == null) {
|
||||
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());
|
||||
ChatColor color = e != null ? e.getColor() : null;
|
||||
|
||||
|
||||
if (bPlayer.isElementToggled(e) == true) {
|
||||
if (e == Element.CHI) {
|
||||
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) {
|
||||
if (!sender.hasPermission("bending.admin.toggle")) {
|
||||
sender.sendMessage(ChatColor.RED + "You don't have permission to do that.");
|
||||
|
|
|
@ -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.ProjectKorra;
|
||||
import com.projectkorra.projectkorra.ability.CoreAbility;
|
||||
|
@ -84,6 +85,7 @@ public class WhoCommand extends PKCommand {
|
|||
GeneralMethods.createBendingPlayer(player.getUniqueId(), player.getName());
|
||||
bp = BendingPlayer.getBendingPlayer(player.getName());
|
||||
}
|
||||
/*
|
||||
if (bp.hasElement(Element.AIR)) {
|
||||
result = ChatColor.WHITE + playerName + " - " + ((!bp.isElementToggled(Element.AIR) || !bp.isToggled()) ? ChatColor.translateAlternateColorCodes('&', "&7&mA") : Element.AIR.getColor() + "A");
|
||||
}
|
||||
|
@ -115,6 +117,14 @@ public class WhoCommand extends PKCommand {
|
|||
result = result + ChatColor.WHITE + " | " + ((!bp.isElementToggled(Element.CHI) || !bp.isToggled()) ? ChatColor.translateAlternateColorCodes('&', "&6&mC") : Element.CHI.getColor() + "C");
|
||||
}
|
||||
}
|
||||
*/
|
||||
for (Element element : bp.getElements()) {
|
||||
if (result == "") {
|
||||
result = ChatColor.WHITE + playerName + " - " + (((!bp.isElementToggled(element) || !bp.isToggled()) ? element.getColor() + "" + ChatColor.STRIKETHROUGH : element.getColor()) + element.getName().substring(0, 1));
|
||||
} else {
|
||||
result = result + ChatColor.WHITE + " | " + (((!bp.isElementToggled(element) || !bp.isToggled()) ? element.getColor() + "" + ChatColor.STRIKETHROUGH : element.getColor()) + element.getName().substring(0, 1));
|
||||
}
|
||||
}
|
||||
if (staff.containsKey(player.getUniqueId().toString())) {
|
||||
if (result == "") {
|
||||
result = ChatColor.WHITE + playerName + " | " + staff.get(player.getUniqueId().toString());
|
||||
|
@ -268,6 +278,19 @@ public class WhoCommand extends PKCommand {
|
|||
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.getAddonSubElements()) {
|
||||
if (player_.hasPermission("bending." + element.getName().toLowerCase() + "." + subelement.getName().toLowerCase())) {
|
||||
String type = (subelement.getType() != null ? subelement.getType().getBend() : null);
|
||||
sender.sendMessage(subelement.getColor() + " Can " + (type != null ? "" : "use ") + subelement.getName() + (type != null ? type : ""));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
UUID uuid = player.getUniqueId();
|
||||
if (bPlayer != null) {
|
||||
|
|
Loading…
Reference in a new issue