Updated AddCommand

This commit is contained in:
jayoevans 2019-10-26 16:57:25 +10:00
parent dcdd3326a5
commit 470a03e571
7 changed files with 144 additions and 224 deletions

View file

@ -75,7 +75,6 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import com.projectkorra.projectkorra.Element.SubElement;
import com.projectkorra.projectkorra.ability.Ability; import com.projectkorra.projectkorra.ability.Ability;
import com.projectkorra.projectkorra.ability.AddonAbility; import com.projectkorra.projectkorra.ability.AddonAbility;
import com.projectkorra.projectkorra.ability.AirAbility; import com.projectkorra.projectkorra.ability.AirAbility;
@ -496,7 +495,7 @@ public class PKListener implements Listener {
final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
PassiveManager.registerPassives(player); PassiveManager.registerPassives(player);
if (ConfigManager.getConfig(ChatPropertiesConfig.class).Enabled) { if (ConfigManager.getConfig(ChatPropertiesConfig.class).Enabled) {
final Element element = event.getElement(); final com.projectkorra.projectkorra.element.Element element = event.getElement();
String prefix = ""; String prefix = "";
if (bPlayer == null) { if (bPlayer == null) {
@ -506,7 +505,9 @@ public class PKListener implements Listener {
if (bPlayer.getElements().size() > 1) { if (bPlayer.getElements().size() > 1) {
prefix = Element.AVATAR.getPrefix(); prefix = Element.AVATAR.getPrefix();
} else if (element != null) { } else if (element != null) {
prefix = element.getPrefix(); // TODO Pull prefix from config
// prefix = element.getPrefix();
prefix = element.getColoredName();
} else { } else {
prefix = ChatColor.WHITE + ChatColor.translateAlternateColorCodes('&', ConfigManager.getConfig(ChatPropertiesConfig.class).NonbenderPrefix) + " "; 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); new AirBurst(ConfigManager.getConfig(AirBurstConfig.class), player, true);
} }
} }
CoreAbility gd = CoreAbility.getAbility(GracefulDescent.class); CoreAbility gd = CoreAbility.getAbility(GracefulDescent.class);
CoreAbility ds = CoreAbility.getAbility(DensityShift.class); CoreAbility ds = CoreAbility.getAbility(DensityShift.class);
CoreAbility hs = CoreAbility.getAbility(HydroSink.class); CoreAbility hs = CoreAbility.getAbility(HydroSink.class);
@ -967,7 +968,7 @@ public class PKListener implements Listener {
} }
CoreAbility hc = CoreAbility.getAbility(HeatControl.class); 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)) { 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)); event.setCancelled(!HeatControl.canBurn(player));
} }

View file

@ -1,31 +1,34 @@
package com.projectkorra.projectkorra.command; package com.projectkorra.projectkorra.command;
import java.util.ArrayList; import com.projectkorra.projectkorra.GeneralMethods;
import java.util.Arrays; import com.projectkorra.projectkorra.configuration.ConfigManager;
import java.util.LinkedList; import com.projectkorra.projectkorra.configuration.configs.commands.AddCommandConfig;
import java.util.List; 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.Bukkit;
import org.bukkit.ChatColor; 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 com.projectkorra.projectkorra.BendingPlayer; import java.util.ArrayList;
import com.projectkorra.projectkorra.Element; import java.util.LinkedList;
import com.projectkorra.projectkorra.Element.SubElement; 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.event.PlayerChangeElementEvent;
import com.projectkorra.projectkorra.event.PlayerChangeElementEvent.Result;
import com.projectkorra.projectkorra.event.PlayerChangeSubElementEvent;
/** /**
* Executor for /bending add. Extends {@link PKCommand}. * Executor for /bending add. Extends {@link PKCommand}.
*/ */
public class AddCommand extends PKCommand<AddCommandConfig> { public class AddCommand extends PKCommand<AddCommandConfig> {
private final BendingPlayerManager bendingPlayerManager;
private final ElementManager elementManager;
private final String playerNotFound; private final String playerNotFound;
private final String invalidElement; private final String invalidElement;
private final String addedOther; private final String addedOther;
@ -44,6 +47,9 @@ public class AddCommand extends PKCommand<AddCommandConfig> {
public AddCommand(final AddCommandConfig config) { public AddCommand(final AddCommandConfig config) {
super(config, "add", "/bending add <Element/SubElement> [Player]", config.Description, new String[] { "add", "a" }); 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.playerNotFound = config.PlayerNotFound;
this.invalidElement = config.InvalidElement; this.invalidElement = config.InvalidElement;
this.addedOther = config.SuccessfullyAdded_Other; 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. * Adds the ability to bend an element to a player.
* *
* @param sender The CommandSender who issued the add command * @param sender The CommandSender who issued the add command
* @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 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 bendingPlayer = this.bendingPlayerManager.getBendingPlayer(target);
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(target);
if (bPlayer == null) { if (bendingPlayer.isBendingRemoved()) {
GeneralMethods.createBendingPlayer(target.getUniqueId(), target.getName());
bPlayer = BendingPlayer.getBendingPlayer(target);
} else if (bPlayer.isPermaRemoved()) { // ignore permaremoved users.
GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + ConfigManager.getConfig(CommandPropertiesConfig.class).BendingPermanentlyRemoved_Other); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + ConfigManager.getConfig(CommandPropertiesConfig.class).BendingPermanentlyRemoved_Other);
return; return;
} }
if (element.toLowerCase().equals("all")) { if (elementName.toLowerCase().equals("all")) {
final StringBuilder elements = new StringBuilder(""); final StringBuilder elements = new StringBuilder();
List<Element> added = new LinkedList<>(); 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) { for (Element element : this.elementManager.getElements()) {
elements.append(ChatColor.YELLOW + ", "); if (bendingPlayer.hasElement(element) || element.equals(this.elementManager.getAvatar())) {
} continue;
elements.append(e.getColor() + e.getName());
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, target, e, Result.ADD));
} }
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) { if (added.size() > 0) {
GeneralMethods.saveElements(bPlayer, added); if (!(sender instanceof Player) || !(sender).equals(target)) {
if (!(sender instanceof Player) || !((Player) sender).equals(target)) {
GeneralMethods.sendBrandingMessage(sender, ChatColor.YELLOW + this.addedOtherAll.replace("{target}", ChatColor.DARK_AQUA + target.getName() + ChatColor.YELLOW) + elements); 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); GeneralMethods.sendBrandingMessage(target, ChatColor.YELLOW + this.addedAll + elements);
} else { } else {
GeneralMethods.sendBrandingMessage(target, ChatColor.YELLOW + this.addedAll + elements); GeneralMethods.sendBrandingMessage(target, ChatColor.YELLOW + this.addedAll + elements);
} }
} else { } 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)); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.alreadyHasAllElementsOther.replace("{target}", ChatColor.DARK_AQUA + target.getName() + ChatColor.RED));
} else { } else {
GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.alreadyHasAllElements); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.alreadyHasAllElements);
} }
} }
return;
} else { } else {
// get the [sub]element. // get the [sub]element.
Element e = Element.fromString(element); Element e = this.elementManager.getElement(elementName);
if (e == null) { if (e == null) {
return; return;
} }
List<Element> adding = new LinkedList<>(); List<Element> adding = new LinkedList<>();
adding.add(e); adding.add(e);
if (e == Element.AVATAR) { if (e.equals(this.elementManager.getAvatar())) {
adding.clear(); adding.clear();
adding.add(Element.AIR); adding.add(this.elementManager.getAir());
adding.add(Element.EARTH); adding.add(this.elementManager.getEarth());
adding.add(Element.FIRE); adding.add(this.elementManager.getFire());
adding.add(Element.WATER); adding.add(this.elementManager.getWater());
} }
List<Element> added = new LinkedList<>(); List<Element> added = new LinkedList<>();
for (Element elem : adding) { 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. if (bendingPlayer.hasElement(elem)) {
bPlayer.addElement(elem); continue;
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);
} }
this.elementManager.addElement(target, elem);
added.add(elem);
Bukkit.getPluginManager().callEvent(new PlayerChangeElementEvent(sender, target, elem, Result.ADD));
} }
if (added.isEmpty()) { 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) { 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)); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.alreadyHasSubElementOther.replace("{target}", ChatColor.DARK_AQUA + target.getName() + ChatColor.RED));
} else { } else {
@ -203,21 +188,15 @@ public class AddCommand extends PKCommand<AddCommandConfig> {
GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.alreadyHasElement); GeneralMethods.sendBrandingMessage(sender, ChatColor.RED + this.alreadyHasElement);
} }
} }
return; return;
} }
if (added.size() == 1) {
GeneralMethods.saveElement(bPlayer, added.get(0));
} else {
GeneralMethods.saveElements(bPlayer, added);
}
for (Element elem : added) { for (Element elem : added) {
ChatColor color = elem.getColor(); ChatColor color = elem.getColor();
boolean vowel = GeneralMethods.isVowel(ChatColor.stripColor(elem.getName()).charAt(0)); 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) { if (vowel) {
GeneralMethods.sendBrandingMessage(sender, color + this.addedOtherVowel.replace("{target}", ChatColor.DARK_AQUA + target.getName() + color).replace("{element}", elem.getName() + elem.getType().getBender())); GeneralMethods.sendBrandingMessage(sender, color + this.addedOtherVowel.replace("{target}", ChatColor.DARK_AQUA + target.getName() + color).replace("{element}", elem.getName() + elem.getType().getBender()));
} else { } else {
@ -241,29 +220,8 @@ public class AddCommand extends PKCommand<AddCommandConfig> {
} }
final List<String> l = new ArrayList<>(); final List<String> l = new ArrayList<>();
if (args.size() == 0) { if (args.size() == 0) {
for (Element element : this.elementManager.getElements()) {
l.add("Air"); l.add(element.getName());
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());
} }
} else { } else {
for (final Player p : Bukkit.getOnlinePlayers()) { for (final Player p : Bukkit.getOnlinePlayers()) {

View file

@ -8,12 +8,14 @@ public class Element {
private final String elementName; private final String elementName;
private final String displayName; private final String displayName;
private final ChatColor color; 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.elementId = elementId;
this.elementName = elementName; this.elementName = elementName;
this.displayName = displayName; this.displayName = displayName;
this.color = color; this.color = color;
this.type = type;
} }
public int getId() { public int getId() {
@ -35,4 +37,8 @@ public class Element {
public String getColoredName() { public String getColoredName() {
return this.color + this.displayName; return this.color + this.displayName;
} }
public ElementManager.ElementType getType() {
return this.type;
}
} }

View file

@ -11,6 +11,7 @@ import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
@ -48,33 +49,33 @@ public class ElementManager extends DatabaseModule<ElementRepository> {
getRepository().createTables(); getRepository().createTables();
// Waterbending // Waterbending
this.water = addElement(WATER, "Water", ChatColor.AQUA); this.water = addElement(WATER, "Water", ChatColor.AQUA, ElementType.BENDING);
this.blood = addSubElement(BLOOD, "Blood", ChatColor.DARK_AQUA, this.water); this.blood = addSubElement(BLOOD, "Blood", ChatColor.DARK_AQUA, ElementType.BENDING, this.water);
this.healing = addSubElement(HEALING, "Healing", ChatColor.DARK_AQUA, this.water); this.healing = addSubElement(HEALING, "Healing", ChatColor.DARK_AQUA, ElementType.NO_SUFFIX, this.water);
this.ice = addSubElement(ICE, "Ice", ChatColor.DARK_AQUA, this.water); this.ice = addSubElement(ICE, "Ice", ChatColor.DARK_AQUA, ElementType.BENDING, this.water);
this.plant = addSubElement(PLANT, "Plant", ChatColor.DARK_AQUA, this.water); this.plant = addSubElement(PLANT, "Plant", ChatColor.DARK_AQUA, ElementType.BENDING, this.water);
// Earthbending // Earthbending
this.earth = addElement(EARTH, "Earth", ChatColor.AQUA); this.earth = addElement(EARTH, "Earth", ChatColor.AQUA, ElementType.BENDING);
this.lava = addSubElement(LAVA, "Lava", ChatColor.DARK_GREEN, this.earth); this.lava = addSubElement(LAVA, "Lava", ChatColor.DARK_GREEN, ElementType.BENDING, this.earth);
this.metal = addSubElement(METAL, "Metal", ChatColor.DARK_GREEN, this.earth); this.metal = addSubElement(METAL, "Metal", ChatColor.DARK_GREEN, ElementType.BENDING, this.earth);
this.sand = addSubElement(SAND, "Sand", ChatColor.DARK_GREEN, this.earth); this.sand = addSubElement(SAND, "Sand", ChatColor.DARK_GREEN, ElementType.BENDING, this.earth);
// Firebending // Firebending
this.fire = addElement(FIRE, "Fire", ChatColor.RED); this.fire = addElement(FIRE, "Fire", ChatColor.RED, ElementType.BENDING);
this.combustion = addSubElement(COMBUSTION, "Combustion", ChatColor.DARK_RED, this.fire); this.combustion = addSubElement(COMBUSTION, "Combustion", ChatColor.DARK_RED, ElementType.BENDING, this.fire);
this.lightning = addSubElement(LIGHTNING, "Lightning", ChatColor.DARK_RED, this.fire); this.lightning = addSubElement(LIGHTNING, "Lightning", ChatColor.DARK_RED, ElementType.BENDING, this.fire);
// Airbending // Airbending
this.air = addElement(AIR, "Air", ChatColor.GRAY); this.air = addElement(AIR, "Air", ChatColor.GRAY, ElementType.BENDING);
this.flight = addSubElement(FLIGHT, "Flight", ChatColor.DARK_GRAY, this.air); this.flight = addSubElement(FLIGHT, "Flight", ChatColor.DARK_GRAY, ElementType.NO_SUFFIX, this.air);
this.spiritual = addSubElement(SPIRITUAL, "Spiritual", ChatColor.DARK_GRAY, this.air); this.spiritual = addSubElement(SPIRITUAL, "Spiritual", ChatColor.DARK_GRAY, ElementType.NO_SUFFIX, this.air);
// Chiblocking // Chiblocking
this.chi = addElement(CHI, "Chi", ChatColor.GOLD); this.chi = addElement(CHI, "Chi", ChatColor.GOLD, ElementType.BLOCKING);
// Avatar // Avatar
this.avatar = addElement(AVATAR, "Avatar", ChatColor.DARK_PURPLE); this.avatar = addElement(AVATAR, "Avatar", ChatColor.DARK_PURPLE, null);
} catch (SQLException e) { } catch (SQLException e) {
e.printStackTrace(); 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); 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.elements.put(elementId, element);
this.names.put(elementName, element); this.names.put(elementName, element);
@ -177,10 +182,10 @@ public class ElementManager extends DatabaseModule<ElementRepository> {
return element; 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); 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.elements.put(elementId, element);
this.names.put(elementName, element); this.names.put(elementName, element);
@ -268,4 +273,34 @@ public class ElementManager extends DatabaseModule<ElementRepository> {
public Element getAvatar() { public Element getAvatar() {
return this.avatar; 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;
}
}
} }

View file

@ -6,8 +6,8 @@ public class SubElement extends Element {
private final Element parent; private final Element parent;
public SubElement(int elementId, String elementName, String displayName, ChatColor color, Element parent) { public SubElement(int elementId, String elementName, String displayName, ChatColor color, ElementManager.ElementType type, Element parent) {
super(elementId, elementName, displayName, color); super(elementId, elementName, displayName, color, type);
this.parent = parent; this.parent = parent;
} }

View file

@ -1,12 +1,11 @@
package com.projectkorra.projectkorra.event; package com.projectkorra.projectkorra.event;
import com.projectkorra.projectkorra.element.Element;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.Event; import org.bukkit.event.Event;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import com.projectkorra.projectkorra.Element;
/** /**
* Called when a player's bending element is modified * Called when a player's bending element is modified
*/ */

View file

@ -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() {}
}
}