mirror of
https://github.com/TotalFreedomMC/TF-ProjectKorra.git
synced 2024-12-22 16:05:01 +00:00
Updated AddCommand
This commit is contained in:
parent
dcdd3326a5
commit
470a03e571
7 changed files with 144 additions and 224 deletions
|
@ -75,7 +75,6 @@ import org.bukkit.inventory.ItemStack;
|
|||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import com.projectkorra.projectkorra.Element.SubElement;
|
||||
import com.projectkorra.projectkorra.ability.Ability;
|
||||
import com.projectkorra.projectkorra.ability.AddonAbility;
|
||||
import com.projectkorra.projectkorra.ability.AirAbility;
|
||||
|
@ -496,7 +495,7 @@ public class PKListener implements Listener {
|
|||
final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
|
||||
PassiveManager.registerPassives(player);
|
||||
if (ConfigManager.getConfig(ChatPropertiesConfig.class).Enabled) {
|
||||
final Element element = event.getElement();
|
||||
final com.projectkorra.projectkorra.element.Element element = event.getElement();
|
||||
String prefix = "";
|
||||
|
||||
if (bPlayer == null) {
|
||||
|
@ -506,7 +505,9 @@ public class PKListener implements Listener {
|
|||
if (bPlayer.getElements().size() > 1) {
|
||||
prefix = Element.AVATAR.getPrefix();
|
||||
} else if (element != null) {
|
||||
prefix = element.getPrefix();
|
||||
// TODO Pull prefix from config
|
||||
// prefix = element.getPrefix();
|
||||
prefix = element.getColoredName();
|
||||
} else {
|
||||
prefix = ChatColor.WHITE + ChatColor.translateAlternateColorCodes('&', ConfigManager.getConfig(ChatPropertiesConfig.class).NonbenderPrefix) + " ";
|
||||
}
|
||||
|
@ -926,7 +927,7 @@ public class PKListener implements Listener {
|
|||
new AirBurst(ConfigManager.getConfig(AirBurstConfig.class), player, true);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
CoreAbility gd = CoreAbility.getAbility(GracefulDescent.class);
|
||||
CoreAbility ds = CoreAbility.getAbility(DensityShift.class);
|
||||
CoreAbility hs = CoreAbility.getAbility(HydroSink.class);
|
||||
|
@ -967,7 +968,7 @@ public class PKListener implements Listener {
|
|||
}
|
||||
|
||||
CoreAbility hc = CoreAbility.getAbility(HeatControl.class);
|
||||
|
||||
|
||||
if (hc != null && bPlayer.hasElement(Element.FIRE) && bPlayer.canBendPassive(hc) && bPlayer.canUsePassive(hc) && (event.getCause() == DamageCause.FIRE || event.getCause() == DamageCause.FIRE_TICK)) {
|
||||
event.setCancelled(!HeatControl.canBurn(player));
|
||||
}
|
||||
|
|
|
@ -1,31 +1,34 @@
|
|||
package com.projectkorra.projectkorra.command;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.configuration.ConfigManager;
|
||||
import com.projectkorra.projectkorra.configuration.configs.commands.AddCommandConfig;
|
||||
import com.projectkorra.projectkorra.configuration.configs.properties.CommandPropertiesConfig;
|
||||
import com.projectkorra.projectkorra.element.Element;
|
||||
import com.projectkorra.projectkorra.element.ElementManager;
|
||||
import com.projectkorra.projectkorra.element.SubElement;
|
||||
import com.projectkorra.projectkorra.event.PlayerChangeElementEvent;
|
||||
import com.projectkorra.projectkorra.event.PlayerChangeElementEvent.Result;
|
||||
import com.projectkorra.projectkorra.module.ModuleManager;
|
||||
import com.projectkorra.projectkorra.player.BendingPlayer;
|
||||
import com.projectkorra.projectkorra.player.BendingPlayerManager;
|
||||
import org.bukkit.Bukkit;
|
||||
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;
|
||||
import com.projectkorra.projectkorra.GeneralMethods;
|
||||
import com.projectkorra.projectkorra.configuration.ConfigManager;
|
||||
import com.projectkorra.projectkorra.configuration.configs.commands.AddCommandConfig;
|
||||
import com.projectkorra.projectkorra.configuration.configs.properties.CommandPropertiesConfig;
|
||||
import com.projectkorra.projectkorra.event.PlayerChangeElementEvent;
|
||||
import com.projectkorra.projectkorra.event.PlayerChangeElementEvent.Result;
|
||||
import com.projectkorra.projectkorra.event.PlayerChangeSubElementEvent;
|
||||
import java.util.ArrayList;
|
||||
import java.util.LinkedList;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Executor for /bending add. Extends {@link PKCommand}.
|
||||
*/
|
||||
public class AddCommand extends PKCommand<AddCommandConfig> {
|
||||
|
||||
private final BendingPlayerManager bendingPlayerManager;
|
||||
private final ElementManager elementManager;
|
||||
|
||||
private final String playerNotFound;
|
||||
private final String invalidElement;
|
||||
private final String addedOther;
|
||||
|
@ -44,6 +47,9 @@ public class AddCommand extends PKCommand<AddCommandConfig> {
|
|||
public AddCommand(final AddCommandConfig config) {
|
||||
super(config, "add", "/bending add <Element/SubElement> [Player]", config.Description, new String[] { "add", "a" });
|
||||
|
||||
this.bendingPlayerManager = ModuleManager.getModule(BendingPlayerManager.class);
|
||||
this.elementManager = ModuleManager.getModule(ElementManager.class);
|
||||
|
||||
this.playerNotFound = config.PlayerNotFound;
|
||||
this.invalidElement = config.InvalidElement;
|
||||
this.addedOther = config.SuccessfullyAdded_Other;
|
||||
|
@ -85,112 +91,91 @@ public class AddCommand extends PKCommand<AddCommandConfig> {
|
|||
/**
|
||||
* Adds the ability to bend an element to a player.
|
||||
*
|
||||
* @param sender The CommandSender who issued the add command
|
||||
* @param target The player to add the element to
|
||||
* @param element The element to add
|
||||
* @param sender The CommandSender who issued the add command
|
||||
* @param target The player to add the element to
|
||||
* @param elementName The element to add
|
||||
*/
|
||||
private void add(final CommandSender sender, final Player target, final String element) {
|
||||
private void add(final CommandSender sender, final Player target, final String elementName) {
|
||||
|
||||
// if they aren't a BendingPlayer, create them.
|
||||
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(target);
|
||||
if (bPlayer == null) {
|
||||
GeneralMethods.createBendingPlayer(target.getUniqueId(), target.getName());
|
||||
bPlayer = BendingPlayer.getBendingPlayer(target);
|
||||
} else if (bPlayer.isPermaRemoved()) { // ignore permaremoved users.
|
||||
BendingPlayer bendingPlayer = this.bendingPlayerManager.getBendingPlayer(target);
|
||||
|
||||
if (bendingPlayer.isBendingRemoved()) {
|
||||
GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + ConfigManager.getConfig(CommandPropertiesConfig.class).BendingPermanentlyRemoved_Other);
|
||||
return;
|
||||
}
|
||||
|
||||
if (element.toLowerCase().equals("all")) {
|
||||
final StringBuilder elements = new StringBuilder("");
|
||||
if (elementName.toLowerCase().equals("all")) {
|
||||
final StringBuilder elements = new StringBuilder();
|
||||
List<Element> added = new LinkedList<>();
|
||||
for (final Element e : Element.getAllElements()) {
|
||||
if (!bPlayer.hasElement(e) && e != Element.AVATAR) {
|
||||
bPlayer.addElement(e);
|
||||
added.add(e);
|
||||
|
||||
if (elements.length() > 1) {
|
||||
elements.append(ChatColor.YELLOW + ", ");
|
||||
}
|
||||
elements.append(e.getColor() + e.getName());
|
||||
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, target, e, Result.ADD));
|
||||
for (Element element : this.elementManager.getElements()) {
|
||||
if (bendingPlayer.hasElement(element) || element.equals(this.elementManager.getAvatar())) {
|
||||
continue;
|
||||
}
|
||||
|
||||
this.elementManager.addElement(target, element);
|
||||
added.add(element);
|
||||
|
||||
if (elements.length() > 1) {
|
||||
elements.append(ChatColor.YELLOW + ", ");
|
||||
}
|
||||
|
||||
elements.append(element.getColor() + element.getName());
|
||||
|
||||
Bukkit.getPluginManager().callEvent(new PlayerChangeElementEvent(sender, target, element, Result.ADD));
|
||||
}
|
||||
|
||||
if (added.size() > 0) {
|
||||
GeneralMethods.saveElements(bPlayer, added);
|
||||
|
||||
if (!(sender instanceof Player) || !((Player) sender).equals(target)) {
|
||||
if (!(sender instanceof Player) || !(sender).equals(target)) {
|
||||
GeneralMethods.sendBrandingMessage(sender, ChatColor.YELLOW + this.addedOtherAll.replace("{target}", ChatColor.DARK_AQUA + target.getName() + ChatColor.YELLOW) + elements);
|
||||
GeneralMethods.sendBrandingMessage(target, ChatColor.YELLOW + this.addedAll + elements);
|
||||
} else {
|
||||
GeneralMethods.sendBrandingMessage(target, ChatColor.YELLOW + this.addedAll + elements);
|
||||
}
|
||||
} else {
|
||||
if (!(sender instanceof Player) || !((Player) sender).equals(target)) {
|
||||
if (!(sender instanceof Player) || !(sender).equals(target)) {
|
||||
GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.alreadyHasAllElementsOther.replace("{target}", ChatColor.DARK_AQUA + target.getName() + ChatColor.RED));
|
||||
} else {
|
||||
GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.alreadyHasAllElements);
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
} else {
|
||||
|
||||
// get the [sub]element.
|
||||
Element e = Element.fromString(element);
|
||||
|
||||
Element e = this.elementManager.getElement(elementName);
|
||||
|
||||
if (e == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
List<Element> adding = new LinkedList<>();
|
||||
adding.add(e);
|
||||
|
||||
if (e == Element.AVATAR) {
|
||||
if (e.equals(this.elementManager.getAvatar())) {
|
||||
adding.clear();
|
||||
adding.add(Element.AIR);
|
||||
adding.add(Element.EARTH);
|
||||
adding.add(Element.FIRE);
|
||||
adding.add(Element.WATER);
|
||||
adding.add(this.elementManager.getAir());
|
||||
adding.add(this.elementManager.getEarth());
|
||||
adding.add(this.elementManager.getFire());
|
||||
adding.add(this.elementManager.getWater());
|
||||
}
|
||||
|
||||
List<Element> added = new LinkedList<>();
|
||||
|
||||
|
||||
for (Element elem : adding) {
|
||||
// if it's an element:
|
||||
if (Arrays.asList(Element.getAllElements()).contains(elem)) {
|
||||
if (bPlayer.hasElement(elem)) { // if already had, determine who to send the error message to.
|
||||
continue;
|
||||
}
|
||||
|
||||
// add all allowed subelements.
|
||||
bPlayer.addElement(elem);
|
||||
added.add(elem);
|
||||
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, target, e, Result.ADD));
|
||||
return;
|
||||
|
||||
// if it's a sub element:
|
||||
} else if (Arrays.asList(Element.getAllSubElements()).contains(e)) {
|
||||
final SubElement sub = (SubElement) e;
|
||||
|
||||
if (bPlayer.hasSubElement(sub)) { // if already had, determine who to send the error message to.
|
||||
continue;
|
||||
}
|
||||
|
||||
bPlayer.addSubElement(sub);
|
||||
added.add(elem);
|
||||
|
||||
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeSubElementEvent(sender, target, sub, PlayerChangeSubElementEvent.Result.ADD));
|
||||
return;
|
||||
|
||||
} else { // bad element.
|
||||
sender.sendMessage(ChatColor.RED + this.invalidElement);
|
||||
if (bendingPlayer.hasElement(elem)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
this.elementManager.addElement(target, elem);
|
||||
added.add(elem);
|
||||
|
||||
Bukkit.getPluginManager().callEvent(new PlayerChangeElementEvent(sender, target, elem, Result.ADD));
|
||||
}
|
||||
|
||||
|
||||
if (added.isEmpty()) {
|
||||
if (!(sender instanceof Player) || !((Player) sender).equals(target)) {
|
||||
if (!(sender instanceof Player) || !(sender).equals(target)) {
|
||||
if (adding.size() == 1 && adding.get(0) instanceof SubElement) {
|
||||
GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.alreadyHasSubElementOther.replace("{target}", ChatColor.DARK_AQUA + target.getName() + ChatColor.RED));
|
||||
} else {
|
||||
|
@ -203,21 +188,15 @@ public class AddCommand extends PKCommand<AddCommandConfig> {
|
|||
GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.alreadyHasElement);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
if (added.size() == 1) {
|
||||
GeneralMethods.saveElement(bPlayer, added.get(0));
|
||||
} else {
|
||||
GeneralMethods.saveElements(bPlayer, added);
|
||||
}
|
||||
|
||||
|
||||
for (Element elem : added) {
|
||||
ChatColor color = elem.getColor();
|
||||
boolean vowel = GeneralMethods.isVowel(ChatColor.stripColor(elem.getName()).charAt(0));
|
||||
|
||||
if (!(sender instanceof Player) || !((Player) sender).equals(target)) {
|
||||
|
||||
if (!(sender instanceof Player) || !(sender).equals(target)) {
|
||||
if (vowel) {
|
||||
GeneralMethods.sendBrandingMessage(sender, color + this.addedOtherVowel.replace("{target}", ChatColor.DARK_AQUA + target.getName() + color).replace("{element}", elem.getName() + elem.getType().getBender()));
|
||||
} else {
|
||||
|
@ -241,29 +220,8 @@ public class AddCommand extends PKCommand<AddCommandConfig> {
|
|||
}
|
||||
final List<String> l = new ArrayList<>();
|
||||
if (args.size() == 0) {
|
||||
|
||||
l.add("Air");
|
||||
l.add("Earth");
|
||||
l.add("Fire");
|
||||
l.add("Water");
|
||||
l.add("Chi");
|
||||
for (final Element e : Element.getAddonElements()) {
|
||||
l.add(e.getName());
|
||||
}
|
||||
|
||||
l.add("Blood");
|
||||
l.add("Combustion");
|
||||
l.add("Flight");
|
||||
l.add("Healing");
|
||||
l.add("Ice");
|
||||
l.add("Lava");
|
||||
l.add("Lightning");
|
||||
l.add("Metal");
|
||||
l.add("Plant");
|
||||
l.add("Sand");
|
||||
l.add("Spiritual");
|
||||
for (final SubElement e : Element.getAddonSubElements()) {
|
||||
l.add(e.getName());
|
||||
for (Element element : this.elementManager.getElements()) {
|
||||
l.add(element.getName());
|
||||
}
|
||||
} else {
|
||||
for (final Player p : Bukkit.getOnlinePlayers()) {
|
||||
|
|
|
@ -8,12 +8,14 @@ public class Element {
|
|||
private final String elementName;
|
||||
private final String displayName;
|
||||
private final ChatColor color;
|
||||
private final ElementManager.ElementType type;
|
||||
|
||||
public Element(int elementId, String elementName, String displayName, ChatColor color) {
|
||||
public Element(int elementId, String elementName, String displayName, ChatColor color, ElementManager.ElementType type) {
|
||||
this.elementId = elementId;
|
||||
this.elementName = elementName;
|
||||
this.displayName = displayName;
|
||||
this.color = color;
|
||||
this.type = type;
|
||||
}
|
||||
|
||||
public int getId() {
|
||||
|
@ -35,4 +37,8 @@ public class Element {
|
|||
public String getColoredName() {
|
||||
return this.color + this.displayName;
|
||||
}
|
||||
|
||||
public ElementManager.ElementType getType() {
|
||||
return this.type;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -11,6 +11,7 @@ import org.bukkit.entity.Player;
|
|||
import org.bukkit.event.EventHandler;
|
||||
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
@ -48,33 +49,33 @@ public class ElementManager extends DatabaseModule<ElementRepository> {
|
|||
getRepository().createTables();
|
||||
|
||||
// Waterbending
|
||||
this.water = addElement(WATER, "Water", ChatColor.AQUA);
|
||||
this.blood = addSubElement(BLOOD, "Blood", ChatColor.DARK_AQUA, this.water);
|
||||
this.healing = addSubElement(HEALING, "Healing", ChatColor.DARK_AQUA, this.water);
|
||||
this.ice = addSubElement(ICE, "Ice", ChatColor.DARK_AQUA, this.water);
|
||||
this.plant = addSubElement(PLANT, "Plant", ChatColor.DARK_AQUA, this.water);
|
||||
this.water = addElement(WATER, "Water", ChatColor.AQUA, ElementType.BENDING);
|
||||
this.blood = addSubElement(BLOOD, "Blood", ChatColor.DARK_AQUA, ElementType.BENDING, this.water);
|
||||
this.healing = addSubElement(HEALING, "Healing", ChatColor.DARK_AQUA, ElementType.NO_SUFFIX, this.water);
|
||||
this.ice = addSubElement(ICE, "Ice", ChatColor.DARK_AQUA, ElementType.BENDING, this.water);
|
||||
this.plant = addSubElement(PLANT, "Plant", ChatColor.DARK_AQUA, ElementType.BENDING, this.water);
|
||||
|
||||
// Earthbending
|
||||
this.earth = addElement(EARTH, "Earth", ChatColor.AQUA);
|
||||
this.lava = addSubElement(LAVA, "Lava", ChatColor.DARK_GREEN, this.earth);
|
||||
this.metal = addSubElement(METAL, "Metal", ChatColor.DARK_GREEN, this.earth);
|
||||
this.sand = addSubElement(SAND, "Sand", ChatColor.DARK_GREEN, this.earth);
|
||||
this.earth = addElement(EARTH, "Earth", ChatColor.AQUA, ElementType.BENDING);
|
||||
this.lava = addSubElement(LAVA, "Lava", ChatColor.DARK_GREEN, ElementType.BENDING, this.earth);
|
||||
this.metal = addSubElement(METAL, "Metal", ChatColor.DARK_GREEN, ElementType.BENDING, this.earth);
|
||||
this.sand = addSubElement(SAND, "Sand", ChatColor.DARK_GREEN, ElementType.BENDING, this.earth);
|
||||
|
||||
// Firebending
|
||||
this.fire = addElement(FIRE, "Fire", ChatColor.RED);
|
||||
this.combustion = addSubElement(COMBUSTION, "Combustion", ChatColor.DARK_RED, this.fire);
|
||||
this.lightning = addSubElement(LIGHTNING, "Lightning", ChatColor.DARK_RED, this.fire);
|
||||
this.fire = addElement(FIRE, "Fire", ChatColor.RED, ElementType.BENDING);
|
||||
this.combustion = addSubElement(COMBUSTION, "Combustion", ChatColor.DARK_RED, ElementType.BENDING, this.fire);
|
||||
this.lightning = addSubElement(LIGHTNING, "Lightning", ChatColor.DARK_RED, ElementType.BENDING, this.fire);
|
||||
|
||||
// Airbending
|
||||
this.air = addElement(AIR, "Air", ChatColor.GRAY);
|
||||
this.flight = addSubElement(FLIGHT, "Flight", ChatColor.DARK_GRAY, this.air);
|
||||
this.spiritual = addSubElement(SPIRITUAL, "Spiritual", ChatColor.DARK_GRAY, this.air);
|
||||
this.air = addElement(AIR, "Air", ChatColor.GRAY, ElementType.BENDING);
|
||||
this.flight = addSubElement(FLIGHT, "Flight", ChatColor.DARK_GRAY, ElementType.NO_SUFFIX, this.air);
|
||||
this.spiritual = addSubElement(SPIRITUAL, "Spiritual", ChatColor.DARK_GRAY, ElementType.NO_SUFFIX, this.air);
|
||||
|
||||
// Chiblocking
|
||||
this.chi = addElement(CHI, "Chi", ChatColor.GOLD);
|
||||
this.chi = addElement(CHI, "Chi", ChatColor.GOLD, ElementType.BLOCKING);
|
||||
|
||||
// Avatar
|
||||
this.avatar = addElement(AVATAR, "Avatar", ChatColor.DARK_PURPLE);
|
||||
this.avatar = addElement(AVATAR, "Avatar", ChatColor.DARK_PURPLE, null);
|
||||
} catch (SQLException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -166,10 +167,14 @@ public class ElementManager extends DatabaseModule<ElementRepository> {
|
|||
});
|
||||
}
|
||||
|
||||
private Element addElement(String elementName, String displayName, ChatColor color) {
|
||||
public Element getElement(String elementName) {
|
||||
return this.names.get(elementName);
|
||||
}
|
||||
|
||||
private Element addElement(String elementName, String displayName, ChatColor color, ElementType type) {
|
||||
int elementId = registerElement(elementName);
|
||||
|
||||
Element element = new Element(elementId, elementName, displayName, color);
|
||||
Element element = new Element(elementId, elementName, displayName, color, type);
|
||||
|
||||
this.elements.put(elementId, element);
|
||||
this.names.put(elementName, element);
|
||||
|
@ -177,10 +182,10 @@ public class ElementManager extends DatabaseModule<ElementRepository> {
|
|||
return element;
|
||||
}
|
||||
|
||||
private SubElement addSubElement(String elementName, String displayName, ChatColor color, Element parent) {
|
||||
private SubElement addSubElement(String elementName, String displayName, ChatColor color, ElementType type, Element parent) {
|
||||
int elementId = registerElement(elementName);
|
||||
|
||||
SubElement element = new SubElement(elementId, elementName, displayName, color, parent);
|
||||
SubElement element = new SubElement(elementId, elementName, displayName, color, type, parent);
|
||||
|
||||
this.elements.put(elementId, element);
|
||||
this.names.put(elementName, element);
|
||||
|
@ -268,4 +273,34 @@ public class ElementManager extends DatabaseModule<ElementRepository> {
|
|||
public Element getAvatar() {
|
||||
return this.avatar;
|
||||
}
|
||||
|
||||
public List<Element> getElements() {
|
||||
return new ArrayList<>(this.elements.values());
|
||||
}
|
||||
|
||||
public enum ElementType {
|
||||
BENDING("bending", "bender", "bend"), BLOCKING("blocking", "blocker", "block"), NO_SUFFIX("", "", "");
|
||||
|
||||
private String bending;
|
||||
private String bender;
|
||||
private String bend;
|
||||
|
||||
ElementType(final String bending, final String bender, final String bend) {
|
||||
this.bending = bending;
|
||||
this.bender = bender;
|
||||
this.bend = bend;
|
||||
}
|
||||
|
||||
public String getBending() {
|
||||
return this.bending;
|
||||
}
|
||||
|
||||
public String getBender() {
|
||||
return this.bender;
|
||||
}
|
||||
|
||||
public String getBend() {
|
||||
return this.bend;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -6,8 +6,8 @@ public class SubElement extends Element {
|
|||
|
||||
private final Element parent;
|
||||
|
||||
public SubElement(int elementId, String elementName, String displayName, ChatColor color, Element parent) {
|
||||
super(elementId, elementName, displayName, color);
|
||||
public SubElement(int elementId, String elementName, String displayName, ChatColor color, ElementManager.ElementType type, Element parent) {
|
||||
super(elementId, elementName, displayName, color, type);
|
||||
|
||||
this.parent = parent;
|
||||
}
|
||||
|
|
|
@ -1,12 +1,11 @@
|
|||
package com.projectkorra.projectkorra.event;
|
||||
|
||||
import com.projectkorra.projectkorra.element.Element;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.projectkorra.projectkorra.Element;
|
||||
|
||||
/**
|
||||
* Called when a player's bending element is modified
|
||||
*/
|
||||
|
|
|
@ -1,79 +0,0 @@
|
|||
package com.projectkorra.projectkorra.event;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.Event;
|
||||
import org.bukkit.event.HandlerList;
|
||||
|
||||
import com.projectkorra.projectkorra.Element;
|
||||
import com.projectkorra.projectkorra.Element.SubElement;
|
||||
|
||||
public class PlayerChangeSubElementEvent extends Event {
|
||||
|
||||
private static final HandlerList handlers = new HandlerList();
|
||||
private final CommandSender sender;
|
||||
private final Player target;
|
||||
private final SubElement sub;
|
||||
private final Result result;
|
||||
|
||||
/**
|
||||
*
|
||||
* @param sender the {@link CommandSender} who changed the player's bending
|
||||
* @param target the {@link Player} who's bending was changed
|
||||
* @param sub the {@link SubElement} that was changed to
|
||||
* @param result whether the element was chosen, added, removed, or
|
||||
* permaremoved
|
||||
*/
|
||||
public PlayerChangeSubElementEvent(final CommandSender sender, final Player target, final SubElement sub, final Result result) {
|
||||
this.sender = sender;
|
||||
this.target = target;
|
||||
this.sub = sub;
|
||||
this.result = result;
|
||||
}
|
||||
|
||||
@Override
|
||||
public HandlerList getHandlers() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
public static HandlerList getHandlerList() {
|
||||
return handlers;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the {@link CommandSender} who changed the player's bending
|
||||
*/
|
||||
public CommandSender getSender() {
|
||||
return this.sender;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the {@link Player player} who's bending was changed
|
||||
*/
|
||||
public Player getTarget() {
|
||||
return this.target;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return the {@link Element element} that was affected
|
||||
*/
|
||||
public SubElement getSubElement() {
|
||||
return this.sub;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return whether the element was chosen, added, removed, or permaremoved
|
||||
*/
|
||||
public Result getResult() {
|
||||
return this.result;
|
||||
}
|
||||
|
||||
public static enum Result {
|
||||
CHOOSE, REMOVE, ADD, PERMAREMOVE;
|
||||
private Result() {}
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue