This commit is contained in:
Sobki 2017-01-16 16:48:20 +10:00 committed by Christopher Martin
parent 8f205eccbf
commit 9fa1810e71
169 changed files with 2578 additions and 2622 deletions

View file

@ -86,7 +86,7 @@ public class BendingManager implements Runnable {
if (bPlayer == null) { if (bPlayer == null) {
continue; continue;
} }
if (bPlayer.hasElement(Element.WATER) && player.hasPermission("bending.message.nightmessage")) { if (bPlayer.hasElement(Element.WATER) && player.hasPermission("bending.message.nightmessage")) {
player.sendMessage(Element.WATER.getColor() + getMoonsetMessage()); player.sendMessage(Element.WATER.getColor() + getMoonsetMessage());
} }
@ -113,7 +113,8 @@ public class BendingManager implements Runnable {
ChiCombo.handleParalysis(); ChiCombo.handleParalysis();
HorizontalVelocityTracker.updateAll(); HorizontalVelocityTracker.updateAll();
handleCooldowns(); handleCooldowns();
} catch (Exception e) { }
catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -133,5 +134,5 @@ public class BendingManager implements Runnable {
public static String getMoonsetMessage() { public static String getMoonsetMessage() {
return ChatColor.translateAlternateColorCodes('&', ConfigManager.languageConfig.get().getString("Extras.Water.DayMessage")); return ChatColor.translateAlternateColorCodes('&', ConfigManager.languageConfig.get().getString("Extras.Water.DayMessage"));
} }
} }

View file

@ -35,12 +35,14 @@ import com.projectkorra.spirits.SpiritElement;
import com.projectkorra.spirits.SpiritPlayer; import com.projectkorra.spirits.SpiritPlayer;
/** /**
* Class that presents a player and stores all bending information about the player. * Class that presents a player and stores all bending information about the
* player.
*/ */
public class BendingPlayer { public class BendingPlayer {
/** /**
* ConcurrentHashMap that contains all instances of BendingPlayer, with UUID key. * ConcurrentHashMap that contains all instances of BendingPlayer, with UUID
* key.
*/ */
private static final Map<UUID, BendingPlayer> PLAYERS = new ConcurrentHashMap<>(); private static final Map<UUID, BendingPlayer> PLAYERS = new ConcurrentHashMap<>();
@ -58,7 +60,7 @@ public class BendingPlayer {
private ArrayList<SubElement> subelements; private ArrayList<SubElement> subelements;
private HashMap<Integer, String> abilities; private HashMap<Integer, String> abilities;
private Map<String, Long> cooldowns; private Map<String, Long> cooldowns;
private Map<Element, Boolean> toggledElements; private Map<Element, Boolean> toggledElements;
/** /**
* Creates a new {@link BendingPlayer}. * Creates a new {@link BendingPlayer}.
@ -69,8 +71,7 @@ public class BendingPlayer {
* @param abilities The known abilities * @param abilities The known abilities
* @param permaRemoved The permanent removed status * @param permaRemoved The permanent removed status
*/ */
public BendingPlayer(UUID uuid, String playerName, ArrayList<Element> elements, ArrayList<SubElement> subelements, HashMap<Integer, String> abilities, public BendingPlayer(UUID uuid, String playerName, ArrayList<Element> elements, ArrayList<SubElement> subelements, HashMap<Integer, String> abilities, boolean permaRemoved) {
boolean permaRemoved) {
this.uuid = uuid; this.uuid = uuid;
this.name = playerName; this.name = playerName;
this.elements = elements; this.elements = elements;
@ -93,7 +94,7 @@ public class BendingPlayer {
PLAYERS.put(uuid, this); PLAYERS.put(uuid, this);
GeneralMethods.loadBendingPlayer(this); GeneralMethods.loadBendingPlayer(this);
} }
public void addCooldown(Ability ability, long cooldown) { public void addCooldown(Ability ability, long cooldown) {
addCooldown(ability.getName(), cooldown); addCooldown(ability.getName(), cooldown);
} }
@ -103,7 +104,8 @@ public class BendingPlayer {
} }
/** /**
* Adds an ability to the cooldowns map while firing a {@link PlayerCooldownChangeEvent}. * Adds an ability to the cooldowns map while firing a
* {@link PlayerCooldownChangeEvent}.
* *
* @param ability Name of the ability * @param ability Name of the ability
* @param cooldown The cooldown time * @param cooldown The cooldown time
@ -113,13 +115,13 @@ public class BendingPlayer {
Bukkit.getServer().getPluginManager().callEvent(event); Bukkit.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
this.cooldowns.put(ability, cooldown + System.currentTimeMillis()); this.cooldowns.put(ability, cooldown + System.currentTimeMillis());
Player player = event.getPlayer(); Player player = event.getPlayer();
int slot = player.getInventory().getHeldItemSlot() + 1; int slot = player.getInventory().getHeldItemSlot() + 1;
String abilityName = event.getAbility(); String abilityName = event.getAbility();
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (bPlayer.getBoundAbility()!= null && bPlayer.getBoundAbility().equals(CoreAbility.getAbility(abilityName))) { if (bPlayer.getBoundAbility() != null && bPlayer.getBoundAbility().equals(CoreAbility.getAbility(abilityName))) {
GeneralMethods.displayMovePreview(player, CoreAbility.getAbility(bPlayer.getAbilities().get(slot))); GeneralMethods.displayMovePreview(player, CoreAbility.getAbility(bPlayer.getAbilities().get(slot)));
} }
} }
@ -133,7 +135,7 @@ public class BendingPlayer {
public void addElement(Element element) { public void addElement(Element element) {
this.elements.add(element); this.elements.add(element);
} }
/** /**
* Adds a subelement to the {@link BendingPlayer}'s known list. * Adds a subelement to the {@link BendingPlayer}'s known list.
* *
@ -154,8 +156,8 @@ public class BendingPlayer {
* Checks to see if a Player is effected by BloodBending. * Checks to see if a Player is effected by BloodBending.
* *
* @return true If {@link ChiMethods#isChiBlocked(String)} is true <br /> * @return true If {@link ChiMethods#isChiBlocked(String)} is true <br />
* false If player is BloodBender and Bending is toggled on, or if player is in * false If player is BloodBender and Bending is toggled on, or if
* AvatarState * player is in AvatarState
*/ */
public boolean canBeBloodbent() { public boolean canBeBloodbent() {
if (isAvatarState()) { if (isAvatarState()) {
@ -177,10 +179,10 @@ public class BendingPlayer {
if (ability == null) { if (ability == null) {
return false; return false;
} }
List<String> disabledWorlds = getConfig().getStringList("Properties.DisabledWorlds"); List<String> disabledWorlds = getConfig().getStringList("Properties.DisabledWorlds");
Location playerLoc = player.getLocation(); Location playerLoc = player.getLocation();
if (!player.isOnline() || player.isDead()) { if (!player.isOnline() || player.isDead()) {
return false; return false;
} else if (!canBind(ability)) { } else if (!canBind(ability)) {
@ -198,7 +200,7 @@ public class BendingPlayer {
} else if (player.getGameMode() == GameMode.SPECTATOR) { } else if (player.getGameMode() == GameMode.SPECTATOR) {
return false; return false;
} }
if (!ignoreCooldowns && cooldowns.containsKey(name)) { if (!ignoreCooldowns && cooldowns.containsKey(name)) {
if (cooldowns.get(name) + getConfig().getLong("Properties.GlobalCooldown") >= System.currentTimeMillis()) { if (cooldowns.get(name) + getConfig().getLong("Properties.GlobalCooldown") >= System.currentTimeMillis()) {
return false; return false;
@ -214,8 +216,8 @@ public class BendingPlayer {
return false; return false;
} else if (ability instanceof WaterAbility && WaterAbility.isLunarEclipse(player.getWorld())) { } else if (ability instanceof WaterAbility && WaterAbility.isLunarEclipse(player.getWorld())) {
return false; return false;
} }
if (!ignoreBinds && !canBind(ability)) { if (!ignoreBinds && !canBind(ability)) {
return false; return false;
} }
@ -233,14 +235,14 @@ public class BendingPlayer {
public boolean canBendIgnoreCooldowns(CoreAbility ability) { public boolean canBendIgnoreCooldowns(CoreAbility ability) {
return canBend(ability, false, true); return canBend(ability, false, true);
} }
public boolean canBendPassive(Element element) { public boolean canBendPassive(Element element) {
if (Commands.isToggledForAll && ConfigManager.defaultConfig.get().getBoolean("Properties.TogglePassivesWithAllBending")) { if (Commands.isToggledForAll && ConfigManager.defaultConfig.get().getBoolean("Properties.TogglePassivesWithAllBending")) {
return false; return false;
} }
List<String> disabledWorlds = getConfig().getStringList("Properties.DisabledWorlds"); List<String> disabledWorlds = getConfig().getStringList("Properties.DisabledWorlds");
if (element == null || player == null) { if (element == null || player == null) {
return false; return false;
} else if (!player.hasPermission("bending." + element.getName() + ".passive")) { } else if (!player.hasPermission("bending." + element.getName() + ".passive")) {
@ -253,27 +255,27 @@ public class BendingPlayer {
return false; return false;
} else if (GeneralMethods.isRegionProtectedFromBuild(player, player.getLocation())) { } else if (GeneralMethods.isRegionProtectedFromBuild(player, player.getLocation())) {
return false; return false;
} }
return true; return true;
} }
public boolean canCurrentlyBendWithWeapons() { public boolean canCurrentlyBendWithWeapons() {
if (getBoundAbility() != null && player.getInventory().getItemInMainHand() != null) { if (getBoundAbility() != null && player.getInventory().getItemInMainHand() != null) {
boolean hasWeapon = GeneralMethods.isWeapon(player.getInventory().getItemInMainHand().getType()); boolean hasWeapon = GeneralMethods.isWeapon(player.getInventory().getItemInMainHand().getType());
boolean noWeaponElement = GeneralMethods.getElementsWithNoWeaponBending().contains(getBoundAbility().getElement()); boolean noWeaponElement = GeneralMethods.getElementsWithNoWeaponBending().contains(getBoundAbility().getElement());
if (hasWeapon) { if (hasWeapon) {
if(noWeaponElement) { if (noWeaponElement) {
return false; return false;
} else { } else {
return true; return true;
} }
} }
return true; return true;
} }
return false; return false;
} }
/** /**
* Checks to see if {@link BendingPlayer} can be slowed. * Checks to see if {@link BendingPlayer} can be slowed.
@ -289,7 +291,7 @@ public class BendingPlayer {
return false; return false;
} else if (!player.hasPermission("bending.ability." + ability.getName())) { } else if (!player.hasPermission("bending.ability." + ability.getName())) {
return false; return false;
} else if (!hasElement(ability.getElement()) && !(ability instanceof AvatarAbility && !((AvatarAbility)ability).requireAvatar())) { } else if (!hasElement(ability.getElement()) && !(ability instanceof AvatarAbility && !((AvatarAbility) ability).requireAvatar())) {
return false; return false;
} else if (ability.getElement() instanceof SubElement) { } else if (ability.getElement() instanceof SubElement) {
SubElement subElement = (SubElement) ability.getElement(); SubElement subElement = (SubElement) ability.getElement();
@ -322,7 +324,7 @@ public class BendingPlayer {
public boolean canBloodbend() { public boolean canBloodbend() {
return subelements.contains(SubElement.BLOOD); return subelements.contains(SubElement.BLOOD);
} }
public boolean canBloodbendAtAnytime() { public boolean canBloodbendAtAnytime() {
return canBloodbend() && player.hasPermission("bending.water.bloodbending.anytime"); return canBloodbend() && player.hasPermission("bending.water.bloodbending.anytime");
} }
@ -392,7 +394,8 @@ public class BendingPlayer {
* Checks to see if a player can use SpiritualProjection. * Checks to see if a player can use SpiritualProjection.
* *
* @param player The player to check * @param player The player to check
* @return true If player has permission node "bending.air.spiritualprojection" * @return true If player has permission node
* "bending.air.spiritualprojection"
*/ */
public boolean canUseSpiritualProjection() { public boolean canUseSpiritualProjection() {
return subelements.contains(SubElement.SPIRITUAL); return subelements.contains(SubElement.SPIRITUAL);
@ -400,14 +403,17 @@ public class BendingPlayer {
/** /**
* Checks to see if a player can use Water Healing. * Checks to see if a player can use Water Healing.
*
* @return true If player has permission node "bending.water.healing" * @return true If player has permission node "bending.water.healing"
*/ */
public boolean canWaterHeal() { public boolean canWaterHeal() {
return subelements.contains(SubElement.HEALING); return subelements.contains(SubElement.HEALING);
} }
/** /**
* Checks to see if a player can bend a specific sub element. Used when checking addon sub elements. * Checks to see if a player can bend a specific sub element. Used when
* checking addon sub elements.
*
* @param sub SubElement to check for. * @param sub SubElement to check for.
* @return true If the player has permission to bend that subelement. * @return true If the player has permission to bend that subelement.
*/ */
@ -454,7 +460,7 @@ public class BendingPlayer {
} }
return -1; return -1;
} }
/** /**
* Gets the map of cooldowns of the {@link BendingPlayer}. * Gets the map of cooldowns of the {@link BendingPlayer}.
* *
@ -499,7 +505,7 @@ public class BendingPlayer {
public List<SubElement> getSubElements() { public List<SubElement> getSubElements() {
return this.subelements; return this.subelements;
} }
/** /**
* Gets the unique identifier of the {@link BendingPlayer}. * Gets the unique identifier of the {@link BendingPlayer}.
* *
@ -517,7 +523,7 @@ public class BendingPlayer {
public String getUUIDString() { public String getUUIDString() {
return this.uuid.toString(); return this.uuid.toString();
} }
/** /**
* Checks to see if the {@link BendingPlayer} knows a specific element. * Checks to see if the {@link BendingPlayer} knows a specific element.
* *
@ -534,10 +540,10 @@ public class BendingPlayer {
} else if (!(element instanceof SubElement)) { } else if (!(element instanceof SubElement)) {
return this.elements.contains(element); return this.elements.contains(element);
} else { } else {
return hasSubElement((SubElement)element); return hasSubElement((SubElement) element);
} }
} }
public boolean hasSubElement(SubElement sub) { public boolean hasSubElement(SubElement sub) {
if (sub == null) { if (sub == null) {
return false; return false;
@ -545,9 +551,10 @@ public class BendingPlayer {
return this.subelements.contains(sub); return this.subelements.contains(sub);
} }
} }
/** /**
* Returns whether the player has permission to bend the subelement * Returns whether the player has permission to bend the subelement
*
* @param sub The SubElement * @param sub The SubElement
*/ */
public boolean hasSubElementPermission(SubElement sub) { public boolean hasSubElementPermission(SubElement sub) {
@ -632,7 +639,7 @@ public class BendingPlayer {
public boolean isTremorSensing() { public boolean isTremorSensing() {
return this.tremorSense; return this.tremorSense;
} }
/** /**
* Checks if the {@link BendingPlayer} is using illumination. * Checks if the {@link BendingPlayer} is using illumination.
* *
@ -647,7 +654,7 @@ public class BendingPlayer {
removeCooldown(ability.getName()); removeCooldown(ability.getName());
} }
} }
/** /**
* Removes the cooldown of an ability. * Removes the cooldown of an ability.
* *
@ -661,21 +668,21 @@ public class BendingPlayer {
Bukkit.getServer().getPluginManager().callEvent(event); Bukkit.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (!event.isCancelled()) {
this.cooldowns.remove(ability); this.cooldowns.remove(ability);
Player player = event.getPlayer(); Player player = event.getPlayer();
int slot = player.getInventory().getHeldItemSlot() + 1; int slot = player.getInventory().getHeldItemSlot() + 1;
String abilityName = event.getAbility(); String abilityName = event.getAbility();
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (bPlayer.getBoundAbility()!= null && bPlayer.getBoundAbility().equals(CoreAbility.getAbility(abilityName))) { if (bPlayer.getBoundAbility() != null && bPlayer.getBoundAbility().equals(CoreAbility.getAbility(abilityName))) {
GeneralMethods.displayMovePreview(player, CoreAbility.getAbility(bPlayer.getAbilities().get(slot))); GeneralMethods.displayMovePreview(player, CoreAbility.getAbility(bPlayer.getAbilities().get(slot)));
} }
} }
} }
/** /**
* Sets the {@link BendingPlayer}'s abilities. This method also saves the abilities to the * Sets the {@link BendingPlayer}'s abilities. This method also saves the
* database. * abilities to the database.
* *
* @param abilities The abilities to set/save * @param abilities The abilities to set/save
*/ */
@ -687,8 +694,8 @@ public class BendingPlayer {
} }
/** /**
* Sets the {@link BendingPlayer}'s element. If the player had elements before they will be * Sets the {@link BendingPlayer}'s element. If the player had elements
* overwritten. * before they will be overwritten.
* *
* @param e The element to set * @param e The element to set
*/ */
@ -705,7 +712,7 @@ public class BendingPlayer {
public void setPermaRemoved(boolean permaRemoved) { public void setPermaRemoved(boolean permaRemoved) {
this.permaRemoved = permaRemoved; this.permaRemoved = permaRemoved;
} }
/** /**
* Sets the player's {@link ChiAbility Chi stance} * Sets the player's {@link ChiAbility Chi stance}
* *
@ -723,7 +730,7 @@ public class BendingPlayer {
public void slow(long cooldown) { public void slow(long cooldown) {
slowTime = System.currentTimeMillis() + cooldown; slowTime = System.currentTimeMillis() + cooldown;
} }
/** /**
* Toggles the {@link BendingPlayer}'s bending. * Toggles the {@link BendingPlayer}'s bending.
*/ */
@ -738,14 +745,14 @@ public class BendingPlayer {
} }
toggledElements.put(element, !toggledElements.get(element)); toggledElements.put(element, !toggledElements.get(element));
} }
/** /**
* Toggles the {@link BendingPlayer}'s tremor sensing. * Toggles the {@link BendingPlayer}'s tremor sensing.
*/ */
public void toggleTremorSense() { public void toggleTremorSense() {
tremorSense = !tremorSense; tremorSense = !tremorSense;
} }
/** /**
* Toggles the {@link BendingPlayer}'s illumination. * Toggles the {@link BendingPlayer}'s illumination.
*/ */
@ -759,27 +766,29 @@ public class BendingPlayer {
public void unblockChi() { public void unblockChi() {
chiBlocked = false; chiBlocked = false;
} }
public static BendingPlayer getBendingPlayer(OfflinePlayer oPlayer) { public static BendingPlayer getBendingPlayer(OfflinePlayer oPlayer) {
if (oPlayer == null) { if (oPlayer == null) {
return null; return null;
} }
return BendingPlayer.getPlayers().get(oPlayer.getUniqueId()); return BendingPlayer.getPlayers().get(oPlayer.getUniqueId());
} }
public static BendingPlayer getBendingPlayer(Player player) { public static BendingPlayer getBendingPlayer(Player player) {
if (player == null) { if (player == null) {
return null; return null;
} }
return getBendingPlayer(player.getName()); return getBendingPlayer(player.getName());
} }
/** /**
* Attempts to get a {@link BendingPlayer} from specified player name. this method tries to get * Attempts to get a {@link BendingPlayer} from specified player name. this
* a {@link Player} object and gets the uuid and then calls {@link #getBendingPlayer(UUID)} * method tries to get a {@link Player} object and gets the uuid and then
* calls {@link #getBendingPlayer(UUID)}
* *
* @param playerName The name of the Player * @param playerName The name of the Player
* @return The BendingPlayer object if {@link BendingPlayer#PLAYERS} contains the player name * @return The BendingPlayer object if {@link BendingPlayer#PLAYERS}
* contains the player name
* *
* @see #getBendingPlayer(UUID) * @see #getBendingPlayer(UUID)
*/ */
@ -795,7 +804,7 @@ public class BendingPlayer {
private static FileConfiguration getConfig() { private static FileConfiguration getConfig() {
return ConfigManager.getConfig(); return ConfigManager.getConfig();
} }
/** /**
* Gets the map of {@link BendingPlayer}s. * Gets the map of {@link BendingPlayer}s.
* *

View file

@ -11,37 +11,35 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
public class Element { public class Element {
public enum ElementType { public enum ElementType {
BENDING("bending", "bender", "bend"), BENDING("bending", "bender", "bend"), BLOCKING("blocking", "blocker", "block"), NO_SUFFIX("", "", "");
BLOCKING("blocking", "blocker", "block"),
NO_SUFFIX("", "", "");
private String bending; private String bending;
private String bender; private String bender;
private String bend; private String bend;
ElementType(String bending, String bender, String bend) { ElementType(String bending, String bender, String bend) {
this.bending = bending; this.bending = bending;
this.bender = bender; this.bender = bender;
this.bend = bend; this.bend = bend;
} }
public String getBending() { public String getBending() {
return bending; return bending;
} }
public String getBender() { public String getBender() {
return bender; return bender;
} }
public String getBend() { public String getBend() {
return bend; return bend;
} }
} }
private static final HashMap<String, Element> ALL_ELEMENTS = new HashMap<>(); // Must be initialized first private static final HashMap<String, Element> ALL_ELEMENTS = new HashMap<>(); // Must be initialized first
public static final Element AIR = new Element("Air"); public static final Element AIR = new Element("Air");
public static final Element WATER = new Element("Water"); public static final Element WATER = new Element("Water");
public static final Element EARTH = new Element("Earth"); public static final Element EARTH = new Element("Earth");
@ -59,39 +57,44 @@ public class Element {
public static final SubElement SAND = new SubElement("Sand", EARTH); public static final SubElement SAND = new SubElement("Sand", EARTH);
public static final SubElement LIGHTNING = new SubElement("Lightning", FIRE); public static final SubElement LIGHTNING = new SubElement("Lightning", FIRE);
public static final SubElement COMBUSTION = new SubElement("Combustion", FIRE); public static final SubElement COMBUSTION = new SubElement("Combustion", FIRE);
private static final Element[] ELEMENTS = {AIR, WATER, EARTH, FIRE, CHI, FLIGHT, SPIRITUAL, BLOOD, HEALING, ICE, PLANT, LAVA, METAL, SAND, LIGHTNING, COMBUSTION}; private static final Element[] ELEMENTS = { AIR, WATER, EARTH, FIRE, CHI, FLIGHT, SPIRITUAL, BLOOD, HEALING, ICE, PLANT, LAVA, METAL, SAND, LIGHTNING, COMBUSTION };
private static final Element[] MAIN_ELEMENTS = {AIR, WATER, EARTH, FIRE, CHI}; private static final Element[] MAIN_ELEMENTS = { AIR, WATER, EARTH, FIRE, CHI };
private static final SubElement[] SUB_ELEMENTS = {FLIGHT, SPIRITUAL, BLOOD, HEALING, ICE, PLANT, LAVA, METAL, SAND, LIGHTNING, COMBUSTION}; private static final SubElement[] SUB_ELEMENTS = { FLIGHT, SPIRITUAL, BLOOD, HEALING, ICE, PLANT, LAVA, METAL, SAND, LIGHTNING, COMBUSTION };
private String name; private String name;
private ElementType type; private ElementType type;
private Plugin plugin; private Plugin plugin;
/** /**
* To be used when creating a new Element. * To be used when creating a new Element. Do not use for comparing
* Do not use for comparing Elements. * Elements.
*
* @param name Name of the new Element. * @param name Name of the new Element.
*/ */
public Element(String name) { public Element(String name) {
this(name, ElementType.BENDING, ProjectKorra.plugin); this(name, ElementType.BENDING, ProjectKorra.plugin);
} }
/** /**
* To be used when creating a new Element. * To be used when creating a new Element. Do not use for comparing
* Do not use for comparing Elements. * Elements.
*
* @param name Name of the new Element. * @param name Name of the new Element.
* @param type ElementType specifies if its a regular element or chi style element. * @param type ElementType specifies if its a regular element or chi style
* element.
*/ */
public Element(String name, ElementType type) { public Element(String name, ElementType type) {
this(name, type, ProjectKorra.plugin); this(name, type, ProjectKorra.plugin);
} }
/** /**
* To be used when creating a new Element. * To be used when creating a new Element. Do not use for comparing
* Do not use for comparing Elements. * Elements.
*
* @param name Name of the new Element. * @param name Name of the new Element.
* @param type ElementType specifies if its a regular element or chi style element. * @param type ElementType specifies if its a regular element or chi style
* element.
* @param plugin The plugin that is adding the element. * @param plugin The plugin that is adding the element.
*/ */
public Element(String name, ElementType type, Plugin plugin) { public Element(String name, ElementType type, Plugin plugin) {
@ -100,50 +103,54 @@ public class Element {
this.plugin = plugin; this.plugin = plugin;
ALL_ELEMENTS.put(name.toLowerCase(), this); ALL_ELEMENTS.put(name.toLowerCase(), this);
} }
public String getPrefix() { public String getPrefix() {
String name_ = name; String name_ = name;
if (this instanceof SubElement) name_ = ((SubElement)this).parentElement.name; if (this instanceof SubElement)
name_ = ((SubElement) this).parentElement.name;
return getColor() + ChatColor.translateAlternateColorCodes('&', ConfigManager.languageConfig.get().getString("Chat.Prefixes." + name_)) + " "; return getColor() + ChatColor.translateAlternateColorCodes('&', ConfigManager.languageConfig.get().getString("Chat.Prefixes." + name_)) + " ";
} }
public ChatColor getColor() { public ChatColor getColor() {
String color = this.plugin.getName().equalsIgnoreCase("ProjectKorra") ? ConfigManager.languageConfig.get().getString("Chat.Colors." + name) : plugin.getConfig().getString("Chat.Colors." + name); String color = this.plugin.getName().equalsIgnoreCase("ProjectKorra") ? ConfigManager.languageConfig.get().getString("Chat.Colors." + name) : plugin.getConfig().getString("Chat.Colors." + name);
return color != null ? ChatColor.valueOf(color) : ChatColor.WHITE; return color != null ? ChatColor.valueOf(color) : ChatColor.WHITE;
} }
public ChatColor getSubColor() { public ChatColor getSubColor() {
String color = this.plugin.getName().equalsIgnoreCase("ProjectKorra") ? ConfigManager.languageConfig.get().getString("Chat.Colors." + name + "Sub") : plugin.getConfig().getString("Chat.Colors." + name + "Sub"); String color = this.plugin.getName().equalsIgnoreCase("ProjectKorra") ? ConfigManager.languageConfig.get().getString("Chat.Colors." + name + "Sub") : plugin.getConfig().getString("Chat.Colors." + name + "Sub");
return color != null ? ChatColor.valueOf(color) : ChatColor.WHITE; return color != null ? ChatColor.valueOf(color) : ChatColor.WHITE;
} }
public String getName() { public String getName() {
return name; return name;
} }
public Plugin getPlugin() { public Plugin getPlugin() {
return plugin; return plugin;
} }
public ElementType getType() { public ElementType getType() {
if (type == null) return ElementType.NO_SUFFIX; if (type == null)
return ElementType.NO_SUFFIX;
return type; return type;
} }
@Override @Override
public String toString() { public String toString() {
return getColor() + getName(); return getColor() + getName();
} }
public static Element getElement(String name) { public static Element getElement(String name) {
if (name == null) { if (name == null) {
return null; return null;
} }
return ALL_ELEMENTS.get(name.toLowerCase()); return ALL_ELEMENTS.get(name.toLowerCase());
} }
/** /**
* Returns an array of all official and addon elements excluding subelements. * Returns an array of all official and addon elements excluding
* subelements.
*
* @return Array of all official and addon elements. * @return Array of all official and addon elements.
*/ */
public static Element[] getAllElements() { public static Element[] getAllElements() {
@ -156,25 +163,28 @@ public class Element {
} }
return ae.toArray(new Element[ae.size()]); return ae.toArray(new Element[ae.size()]);
} }
/** /**
* Returns an array of all the official elements and subelements. * Returns an array of all the official elements and subelements.
*
* @return Array of all official elements and subelements. * @return Array of all official elements and subelements.
*/ */
public static Element[] getElements() { public static Element[] getElements() {
return ELEMENTS; return ELEMENTS;
} }
/** /**
* Returns an array of all the official elements. * Returns an array of all the official elements.
*
* @return Array of all official elements. * @return Array of all official elements.
*/ */
public static Element[] getMainElements() { public static Element[] getMainElements() {
return MAIN_ELEMENTS; return MAIN_ELEMENTS;
} }
/** /**
* Returns an array of all the addon elements. * Returns an array of all the addon elements.
*
* @return Array of all addon elements. * @return Array of all addon elements.
*/ */
public static Element[] getAddonElements() { public static Element[] getAddonElements() {
@ -187,9 +197,10 @@ public class Element {
ae.remove(Element.AVATAR); ae.remove(Element.AVATAR);
return ae.toArray(new Element[ae.size()]); return ae.toArray(new Element[ae.size()]);
} }
/** /**
* Returns all subelements, official and addon. * Returns all subelements, official and addon.
*
* @return Array of all the subelements. * @return Array of all the subelements.
*/ */
public static SubElement[] getAllSubElements() { public static SubElement[] getAllSubElements() {
@ -202,17 +213,19 @@ public class Element {
} }
return se.toArray(new SubElement[se.size()]); return se.toArray(new SubElement[se.size()]);
} }
/** /**
* Return official subelements. * Return official subelements.
*
* @return Array of official subelements. * @return Array of official subelements.
*/ */
public static SubElement[] getSubElements() { public static SubElement[] getSubElements() {
return SUB_ELEMENTS; return SUB_ELEMENTS;
} }
/** /**
* Return all subelements belonging to a parent element. * Return all subelements belonging to a parent element.
*
* @param element * @param element
* @return Array of all subelements belonging to a parent element. * @return Array of all subelements belonging to a parent element.
*/ */
@ -225,9 +238,10 @@ public class Element {
} }
return se.toArray(new SubElement[se.size()]); return se.toArray(new SubElement[se.size()]);
} }
/** /**
* Returns an array of all the addon subelements. * Returns an array of all the addon subelements.
*
* @return Array of all addon subelements. * @return Array of all addon subelements.
*/ */
public static SubElement[] getAddonSubElements() { public static SubElement[] getAddonSubElements() {
@ -239,9 +253,10 @@ public class Element {
} }
return ae.toArray(new SubElement[ae.size()]); return ae.toArray(new SubElement[ae.size()]);
} }
/** /**
* Returns array of addon subelements belonging to a parent element. * Returns array of addon subelements belonging to a parent element.
*
* @param element * @param element
* @return Array of addon subelements belonging to a parent element. * @return Array of addon subelements belonging to a parent element.
*/ */
@ -254,7 +269,7 @@ public class Element {
} }
return se.toArray(new SubElement[se.size()]); return se.toArray(new SubElement[se.size()]);
} }
public static Element fromString(String element) { public static Element fromString(String element) {
if (getElement(element) != null) { if (getElement(element) != null) {
return getElement(element); return getElement(element);
@ -271,51 +286,56 @@ public class Element {
} }
return null; return null;
} }
public static class SubElement extends Element { public static class SubElement extends Element {
private Element parentElement; private Element parentElement;
/** /**
* To be used when creating a new SubElement. * To be used when creating a new SubElement. Do not use for comparing
* Do not use for comparing SubElements. * SubElements.
*
* @param name Name of the new SubElement. * @param name Name of the new SubElement.
* @param parentElement ParentElement of the SubElement. * @param parentElement ParentElement of the SubElement.
*/ */
public SubElement(String name, Element parentElement) { public SubElement(String name, Element parentElement) {
this(name, parentElement, ElementType.BENDING, ProjectKorra.plugin); this(name, parentElement, ElementType.BENDING, ProjectKorra.plugin);
} }
/** /**
* To be used when creating a new SubElement. * To be used when creating a new SubElement. Do not use for comparing
* Do not use for comparing SubElements. * SubElements.
*
* @param name Name of the new SubElement. * @param name Name of the new SubElement.
* @param parentElement ParentElement of the SubElement. * @param parentElement ParentElement of the SubElement.
* @param type ElementType specifies if its a regular element or chi style element. * @param type ElementType specifies if its a regular element or chi
* style element.
*/ */
public SubElement(String name, Element parentElement, ElementType type) { public SubElement(String name, Element parentElement, ElementType type) {
this(name, parentElement, type, ProjectKorra.plugin); this(name, parentElement, type, ProjectKorra.plugin);
} }
/** /**
* To be used when creating a new SubElement. * To be used when creating a new SubElement. Do not use for comparing
* Do not use for comparing SubElements. * SubElements.
*
* @param name Name of the new SubElement. * @param name Name of the new SubElement.
* @param parentElement ParentElement of the SubElement. * @param parentElement ParentElement of the SubElement.
* @param type ElementType specifies if its a regular element or chi style element. * @param type ElementType specifies if its a regular element or chi
* style element.
* @param plugin The plugin that is adding the element. * @param plugin The plugin that is adding the element.
*/ */
public SubElement(String name, Element parentElement, ElementType type, Plugin plugin) { public SubElement(String name, Element parentElement, ElementType type, Plugin plugin) {
super(name, type, plugin); super(name, type, plugin);
this.parentElement = parentElement; this.parentElement = parentElement;
} }
@Override @Override
public ChatColor getColor() { public ChatColor getColor() {
String color = getPlugin().getName().equalsIgnoreCase("ProjectKorra") ? ConfigManager.languageConfig.get().getString("Chat.Colors." + parentElement.name + "Sub") : getPlugin().getConfig().getString("Chat.Colors." + parentElement.name + "Sub"); String color = getPlugin().getName().equalsIgnoreCase("ProjectKorra") ? ConfigManager.languageConfig.get().getString("Chat.Colors." + parentElement.name + "Sub") : getPlugin().getConfig().getString("Chat.Colors." + parentElement.name + "Sub");
return color != null ? ChatColor.valueOf(color) : ChatColor.WHITE; return color != null ? ChatColor.valueOf(color) : ChatColor.WHITE;
} }
public Element getParentElement() { public Element getParentElement() {
return this.parentElement; return this.parentElement;
} }

View file

@ -133,34 +133,26 @@ import net.sacredlabyrinth.Phaed.PreciousStones.PreciousStones;
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public class GeneralMethods { public class GeneralMethods {
public static final Integer[] NON_OPAQUE = { 0, 6, 8, 9, 10, 11, 27, 28, 30, 31, 32, 37, 38, 39, 40, 50, 51, 55, 59, 66, 68, public static final Integer[] NON_OPAQUE = { 0, 6, 8, 9, 10, 11, 27, 28, 30, 31, 32, 37, 38, 39, 40, 50, 51, 55, 59, 66, 68, 69, 70, 72, 75, 76, 77, 78, 83, 90, 93, 94, 104, 105, 106, 111, 115, 119, 127, 131, 132, 175 };
69, 70, 72, 75, 76, 77, 78, 83, 90, 93, 94, 104, 105, 106, 111, 115, 119, 127, 131, 132, 175 }; public static final Material[] INTERACTABLE_MATERIALS = { Material.ACACIA_DOOR, Material.ACACIA_FENCE_GATE, Material.ANVIL, Material.BEACON, Material.BED_BLOCK, Material.BIRCH_DOOR, Material.BIRCH_FENCE_GATE, Material.BOAT, Material.BREWING_STAND, Material.BURNING_FURNACE, Material.CAKE_BLOCK, Material.CHEST, Material.COMMAND, Material.DARK_OAK_DOOR, Material.DARK_OAK_FENCE_GATE, Material.DISPENSER, Material.DRAGON_EGG, Material.DROPPER, Material.ENCHANTMENT_TABLE, Material.ENDER_CHEST, Material.ENDER_PORTAL_FRAME, Material.FENCE_GATE, Material.FURNACE, Material.HOPPER, Material.HOPPER_MINECART, Material.COMMAND_MINECART, Material.JUKEBOX, Material.JUNGLE_DOOR, Material.JUNGLE_FENCE_GATE, Material.LEVER, Material.MINECART, Material.NOTE_BLOCK, Material.SPRUCE_DOOR, Material.SPRUCE_FENCE_GATE, Material.STONE_BUTTON, Material.TRAPPED_CHEST, Material.TRAP_DOOR, Material.WOOD_BUTTON, Material.WOOD_DOOR, Material.WORKBENCH };
public static final Material[] INTERACTABLE_MATERIALS = { Material.ACACIA_DOOR, Material.ACACIA_FENCE_GATE, Material.ANVIL,
Material.BEACON, Material.BED_BLOCK, Material.BIRCH_DOOR, Material.BIRCH_FENCE_GATE, Material.BOAT,
Material.BREWING_STAND, Material.BURNING_FURNACE, Material.CAKE_BLOCK, Material.CHEST, Material.COMMAND,
Material.DARK_OAK_DOOR, Material.DARK_OAK_FENCE_GATE, Material.DISPENSER, Material.DRAGON_EGG, Material.DROPPER,
Material.ENCHANTMENT_TABLE, Material.ENDER_CHEST, Material.ENDER_PORTAL_FRAME, Material.FENCE_GATE,
Material.FURNACE, Material.HOPPER, Material.HOPPER_MINECART, Material.COMMAND_MINECART,
Material.JUKEBOX, Material.JUNGLE_DOOR, Material.JUNGLE_FENCE_GATE, Material.LEVER, Material.MINECART,
Material.NOTE_BLOCK, Material.SPRUCE_DOOR, Material.SPRUCE_FENCE_GATE, Material.STONE_BUTTON,
Material.TRAPPED_CHEST, Material.TRAP_DOOR, Material.WOOD_BUTTON, Material.WOOD_DOOR, Material.WORKBENCH };
// Represents PlayerName, previously checked blocks, and whether they were true or false // Represents PlayerName, previously checked blocks, and whether they were true or false
private static final Map<String, Map<Block, BlockCacheElement>> BLOCK_CACHE = new ConcurrentHashMap<>(); private static final Map<String, Map<Block, BlockCacheElement>> BLOCK_CACHE = new ConcurrentHashMap<>();
private static final ArrayList<Ability> INVINCIBLE = new ArrayList<>(); private static final ArrayList<Ability> INVINCIBLE = new ArrayList<>();
private static ProjectKorra plugin; private static ProjectKorra plugin;
private static Method getAbsorption; private static Method getAbsorption;
private static Method setAbsorption; private static Method setAbsorption;
public GeneralMethods(ProjectKorra plugin) { public GeneralMethods(ProjectKorra plugin) {
GeneralMethods.plugin = plugin; GeneralMethods.plugin = plugin;
try { try {
getAbsorption = ReflectionHandler.getMethod("EntityPlayer", PackageType.MINECRAFT_SERVER, "getAbsorptionHearts"); getAbsorption = ReflectionHandler.getMethod("EntityPlayer", PackageType.MINECRAFT_SERVER, "getAbsorptionHearts");
setAbsorption = ReflectionHandler.getMethod("EntityPlayer", PackageType.MINECRAFT_SERVER, "setAbsorptionHearts", Float.class); setAbsorption = ReflectionHandler.getMethod("EntityPlayer", PackageType.MINECRAFT_SERVER, "setAbsorptionHearts", Float.class);
} catch (Exception e) { }
catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -204,12 +196,12 @@ public class GeneralMethods {
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player.getName()); BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player.getName());
CoreAbility coreAbil = CoreAbility.getAbility(ability); CoreAbility coreAbil = CoreAbility.getAbility(ability);
if (bPlayer == null) { if (bPlayer == null) {
return; return;
} }
bPlayer.getAbilities().put(slot, ability); bPlayer.getAbilities().put(slot, ability);
if (coreAbil != null) { if (coreAbil != null) {
player.sendMessage(coreAbil.getElement().getColor() + ConfigManager.languageConfig.get().getString("Commands.Bind.SuccessfullyBound").replace("{ability}", ability).replace("{slot}", String.valueOf(slot))); player.sendMessage(coreAbil.getElement().getColor() + ConfigManager.languageConfig.get().getString("Commands.Bind.SuccessfullyBound").replace("{ability}", ability).replace("{slot}", String.valueOf(slot)));
} }
@ -238,9 +230,9 @@ public class GeneralMethods {
} else if (ability.equalsIgnoreCase("AirSwipe")) { } else if (ability.equalsIgnoreCase("AirSwipe")) {
hasBlocked = AirSwipe.removeSwipesAroundPoint(loc, radius) || hasBlocked; hasBlocked = AirSwipe.removeSwipesAroundPoint(loc, radius) || hasBlocked;
} else if (ability.equalsIgnoreCase("AirBlast")) { } else if (ability.equalsIgnoreCase("AirBlast")) {
hasBlocked = AirBlast.removeAirBlastsAroundPoint(loc, radius) || hasBlocked; hasBlocked = AirBlast.removeAirBlastsAroundPoint(loc, radius) || hasBlocked;
} else if (ability.equalsIgnoreCase("AirSuction")) { } else if (ability.equalsIgnoreCase("AirSuction")) {
hasBlocked = AirSuction.removeAirSuctionsAroundPoint(loc, radius) || hasBlocked; hasBlocked = AirSuction.removeAirSuctionsAroundPoint(loc, radius) || hasBlocked;
} else if (ability.equalsIgnoreCase("Combustion")) { } else if (ability.equalsIgnoreCase("Combustion")) {
hasBlocked = Combustion.removeAroundPoint(loc, radius) || hasBlocked; hasBlocked = Combustion.removeAroundPoint(loc, radius) || hasBlocked;
} else if (ability.equalsIgnoreCase("FireShield")) { } else if (ability.equalsIgnoreCase("FireShield")) {
@ -290,12 +282,12 @@ public class GeneralMethods {
* @throws SQLException * @throws SQLException
*/ */
public static void createBendingPlayer(final UUID uuid, final String player) { public static void createBendingPlayer(final UUID uuid, final String player) {
// new BukkitRunnable() { // new BukkitRunnable() {
// @Override // @Override
// public void run() { // public void run() {
// createBendingPlayerAsynchronously(uuid, player); // createBendingPlayerAsynchronously(uuid, player);
// } // }
// }.runTaskAsynchronously(ProjectKorra.plugin); // }.runTaskAsynchronously(ProjectKorra.plugin);
createBendingPlayerAsynchronously(uuid, player); // "async" createBendingPlayerAsynchronously(uuid, player); // "async"
} }
@ -355,14 +347,12 @@ public class GeneralMethods {
if (subelement.equals("-")) { if (subelement.equals("-")) {
Player playero = Bukkit.getPlayer(uuid); Player playero = Bukkit.getPlayer(uuid);
for (SubElement sub : Element.getAllSubElements()) { for (SubElement sub : Element.getAllSubElements()) {
if ((playero != null && playero.hasPermission("bending." + sub.getParentElement().getName().toLowerCase() + "." + sub.getName().toLowerCase() if ((playero != null && playero.hasPermission("bending." + sub.getParentElement().getName().toLowerCase() + "." + sub.getName().toLowerCase() + sub.getType().getBending())) && elements.contains(sub.getParentElement())) {
+ sub.getType().getBending())) && elements.contains(sub.getParentElement())) {
subelements.add(sub); subelements.add(sub);
shouldSave = true && playero != null; shouldSave = true && playero != null;
} }
} }
} } else if (split[0] != null) {
else if (split[0] != null) {
if (split[0].contains("m")) { if (split[0].contains("m")) {
subelements.add(Element.METAL); subelements.add(Element.METAL);
} }
@ -399,7 +389,7 @@ public class GeneralMethods {
if (hasAddon) { if (hasAddon) {
for (String addon : split[split.length - 1].split(",")) { for (String addon : split[split.length - 1].split(",")) {
if (Element.getElement(addon) != null && Element.getElement(addon) instanceof SubElement) { if (Element.getElement(addon) != null && Element.getElement(addon) instanceof SubElement) {
subelements.add((SubElement)Element.getElement(addon)); subelements.add((SubElement) Element.getElement(addon));
} }
} }
} }
@ -434,7 +424,6 @@ public class GeneralMethods {
ex.printStackTrace(); ex.printStackTrace();
} }
} }
/** /**
* Deserializes the configuration file "bendingPlayers.yml" of the old * Deserializes the configuration file "bendingPlayers.yml" of the old
@ -448,7 +437,7 @@ public class GeneralMethods {
if (readFile.exists()) { if (readFile.exists()) {
try (DataInputStream input = new DataInputStream(new FileInputStream(readFile)); BufferedReader reader = new BufferedReader(new InputStreamReader(input)); try (DataInputStream input = new DataInputStream(new FileInputStream(readFile)); BufferedReader reader = new BufferedReader(new InputStreamReader(input));
DataOutputStream output = new DataOutputStream(new FileOutputStream(writeFile)); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(output))) { DataOutputStream output = new DataOutputStream(new FileOutputStream(writeFile)); BufferedWriter writer = new BufferedWriter(new OutputStreamWriter(output))) {
String line; String line;
while ((line = reader.readLine()) != null) { while ((line = reader.readLine()) != null) {
@ -583,19 +572,18 @@ public class GeneralMethods {
block.getWorld().dropItem(block.getLocation(), item); block.getWorld().dropItem(block.getLocation(), item);
} }
} }
public static void displayMovePreview(Player player, CoreAbility ability) { public static void displayMovePreview(Player player, CoreAbility ability) {
String displayedMessage = null; String displayedMessage = null;
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (ConfigManager.defaultConfig.get().getBoolean("Properties.BendingPreview") == true) { if (ConfigManager.defaultConfig.get().getBoolean("Properties.BendingPreview") == true) {
if (ability != null && bPlayer != null) { if (ability != null && bPlayer != null) {
if (bPlayer.isOnCooldown(ability)) { if (bPlayer.isOnCooldown(ability)) {
displayedMessage = ability.getElement().getColor() + "" + ChatColor.STRIKETHROUGH + ability.getName(); displayedMessage = ability.getElement().getColor() + "" + ChatColor.STRIKETHROUGH + ability.getName();
} else { } else {
if (bPlayer.getStance() instanceof AcrobatStance && ability.getName().equals("AcrobatStance") || if (bPlayer.getStance() instanceof AcrobatStance && ability.getName().equals("AcrobatStance") || bPlayer.getStance() instanceof WarriorStance && ability.getName().equals("WarriorStance")) {
bPlayer.getStance() instanceof WarriorStance && ability.getName().equals("WarriorStance")) {
displayedMessage = ability.getElement().getColor() + "" + ChatColor.UNDERLINE + ability.getName(); displayedMessage = ability.getElement().getColor() + "" + ChatColor.UNDERLINE + ability.getName();
} else { } else {
displayedMessage = ability.getElement().getColor() + ability.getName(); displayedMessage = ability.getElement().getColor() + ability.getName();
@ -604,31 +592,33 @@ public class GeneralMethods {
} else { } else {
displayedMessage = ""; displayedMessage = "";
} }
ActionBar.sendActionBar(displayedMessage, player); ActionBar.sendActionBar(displayedMessage, player);
} }
} }
public static float getAbsorbationHealth(Player player) { public static float getAbsorbationHealth(Player player) {
try { try {
Object entityplayer = ActionBar.getHandle.invoke(player); Object entityplayer = ActionBar.getHandle.invoke(player);
Object hearts = getAbsorption.invoke(entityplayer); Object hearts = getAbsorption.invoke(entityplayer);
//player.sendMessage(hearts.toString()); //player.sendMessage(hearts.toString());
return (float) hearts; return (float) hearts;
} catch (Exception e) { }
catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
return 0; return 0;
} }
public static void setAbsorbationHealth(Player player, float hearts) { public static void setAbsorbationHealth(Player player, float hearts) {
try { try {
Object entityplayer = ActionBar.getHandle.invoke(player); Object entityplayer = ActionBar.getHandle.invoke(player);
setAbsorption.invoke(entityplayer, hearts); setAbsorption.invoke(entityplayer, hearts);
//player.sendMessage(hearts.toString()); //player.sendMessage(hearts.toString());
} catch (Exception e) { }
catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -838,37 +828,37 @@ public class GeneralMethods {
List<Entity> entities = new ArrayList<Entity>(); List<Entity> entities = new ArrayList<Entity>();
World world = location.getWorld(); World world = location.getWorld();
// To find chunks we use chunk coordinates (not block coordinates!) // To find chunks we use chunk coordinates (not block coordinates!)
int smallX = (int) (location.getX() - radius) >> 4; int smallX = (int) (location.getX() - radius) >> 4;
int bigX = (int) (location.getX() + radius) >> 4; int bigX = (int) (location.getX() + radius) >> 4;
int smallZ = (int) (location.getZ() - radius) >> 4; int smallZ = (int) (location.getZ() - radius) >> 4;
int bigZ = (int) (location.getZ() + radius) >> 4; int bigZ = (int) (location.getZ() + radius) >> 4;
for (int x = smallX; x <= bigX; x++) { for (int x = smallX; x <= bigX; x++) {
for (int z = smallZ; z <= bigZ; z++) { for (int z = smallZ; z <= bigZ; z++) {
if (world.isChunkLoaded(x, z)) { if (world.isChunkLoaded(x, z)) {
entities.addAll(Arrays.asList(world.getChunkAt(x, z).getEntities())); entities.addAll(Arrays.asList(world.getChunkAt(x, z).getEntities()));
} }
} }
} }
Iterator<Entity> entityIterator = entities.iterator();
while (entityIterator.hasNext()) {
Entity e = entityIterator.next();
if (e.getWorld().equals(location.getWorld()) && e.getLocation().distanceSquared(location) > radius * radius) {
entityIterator.remove();
} else if (e instanceof Player && ((Player) e).getGameMode().equals(GameMode.SPECTATOR)) {
entityIterator.remove();
}
}
Iterator<Entity> entityIterator = entities.iterator();
while (entityIterator.hasNext()) {
Entity e = entityIterator.next();
if (e.getWorld().equals(location.getWorld()) && e.getLocation().distanceSquared(location) > radius * radius) {
entityIterator.remove();
} else if (e instanceof Player && ((Player)e).getGameMode().equals(GameMode.SPECTATOR)) {
entityIterator.remove();
}
}
return entities; return entities;
} }
public static long getGlobalCooldown() { public static long getGlobalCooldown() {
return ConfigManager.defaultConfig.get().getLong("Properties.GlobalCooldown"); return ConfigManager.defaultConfig.get().getLong("Properties.GlobalCooldown");
} }
/** /**
* *
* @param one One location being tested * @param one One location being tested
@ -878,7 +868,7 @@ public class GeneralMethods {
public static double getHorizontalDistance(Location one, Location two) { public static double getHorizontalDistance(Location one, Location two) {
double x = one.getX() - two.getX(); double x = one.getX() - two.getX();
double z = one.getZ() - two.getZ(); double z = one.getZ() - two.getZ();
return Math.sqrt((x*x) + (z*z)); return Math.sqrt((x * x) + (z * z));
} }
@SuppressWarnings("incomplete-switch") @SuppressWarnings("incomplete-switch")
@ -994,28 +984,28 @@ public class GeneralMethods {
float angle = location.getYaw() / 60; float angle = location.getYaw() / 60;
return location.clone().subtract(new Vector(Math.cos(angle), 0, Math.sin(angle)).normalize().multiply(distance)); return location.clone().subtract(new Vector(Math.cos(angle), 0, Math.sin(angle)).normalize().multiply(distance));
} }
public static Plugin getProbending() { public static Plugin getProbending() {
if (hasProbending()) { if (hasProbending()) {
return Bukkit.getServer().getPluginManager().getPlugin("Probending"); return Bukkit.getServer().getPluginManager().getPlugin("Probending");
} }
return null; return null;
} }
public static Plugin getRPG() { public static Plugin getRPG() {
if (hasRPG()) { if (hasRPG()) {
return Bukkit.getServer().getPluginManager().getPlugin("ProjectKorraRPG"); return Bukkit.getServer().getPluginManager().getPlugin("ProjectKorraRPG");
} }
return null; return null;
} }
public static Plugin getSpirits() { public static Plugin getSpirits() {
if (hasSpirits()) { if (hasSpirits()) {
return Bukkit.getServer().getPluginManager().getPlugin("ProjectKorraSpirits"); return Bukkit.getServer().getPluginManager().getPlugin("ProjectKorraSpirits");
} }
return null; return null;
} }
@SuppressWarnings("unused") @SuppressWarnings("unused")
public static Entity getTargetedEntity(Player player, double range, List<Entity> avoid) { public static Entity getTargetedEntity(Player player, double range, List<Entity> avoid) {
double longestr = range + 1; double longestr = range + 1;
@ -1027,11 +1017,7 @@ public class GeneralMethods {
continue; continue;
} }
if (entity.getWorld().equals(origin.getWorld())) { if (entity.getWorld().equals(origin.getWorld())) {
if (entity.getLocation().distanceSquared(origin) < longestr * longestr if (entity.getLocation().distanceSquared(origin) < longestr * longestr && getDistanceFromLine(direction, origin, entity.getLocation()) < 2 && (entity instanceof LivingEntity) && entity.getEntityId() != player.getEntityId() && entity.getLocation().distanceSquared(origin.clone().add(direction)) < entity.getLocation().distanceSquared(origin.clone().add(direction.clone().multiply(-1)))) {
&& getDistanceFromLine(direction, origin, entity.getLocation()) < 2
&& (entity instanceof LivingEntity)
&& entity.getEntityId() != player.getEntityId()
&& entity.getLocation().distanceSquared(origin.clone().add(direction)) < entity.getLocation().distanceSquared(origin.clone().add(direction.clone().multiply(-1)))) {
target = entity; target = entity;
longestr = entity.getLocation().distance(origin); longestr = entity.getLocation().distance(origin);
} }
@ -1049,7 +1035,7 @@ public class GeneralMethods {
} }
return target; return target;
} }
public static Entity getTargetedEntity(Player player, double range) { public static Entity getTargetedEntity(Player player, double range) {
return getTargetedEntity(player, range, new ArrayList<Entity>()); return getTargetedEntity(player, range, new ArrayList<Entity>());
} }
@ -1071,7 +1057,7 @@ public class GeneralMethods {
Block block = player.getTargetBlock(trans, (int) originselectrange + 1); Block block = player.getTargetBlock(trans, (int) originselectrange + 1);
double distance = originselectrange; double distance = originselectrange;
if(block.getWorld().equals(origin.getWorld())) { if (block.getWorld().equals(origin.getWorld())) {
distance = block.getLocation().distance(origin) - 1.5; distance = block.getLocation().distance(origin) - 1.5;
} }
Location location = origin.add(direction.multiply(distance)); Location location = origin.add(direction.multiply(distance));
@ -1136,13 +1122,12 @@ public class GeneralMethods {
} }
} }
return blockHolder; return blockHolder;
} }
public static ArrayList<Element> getElementsWithNoWeaponBending() { public static ArrayList<Element> getElementsWithNoWeaponBending() {
ArrayList<Element> elements = new ArrayList<Element>(); ArrayList<Element> elements = new ArrayList<Element>();
if (!plugin.getConfig().getBoolean("Properties.Air.CanBendWithWeapons")) if (!plugin.getConfig().getBoolean("Properties.Air.CanBendWithWeapons"))
elements.add(Element.AIR); elements.add(Element.AIR);
if (!plugin.getConfig().getBoolean("Properties.Water.CanBendWithWeapons")) if (!plugin.getConfig().getBoolean("Properties.Water.CanBendWithWeapons"))
@ -1153,14 +1138,14 @@ public class GeneralMethods {
elements.add(Element.FIRE); elements.add(Element.FIRE);
if (!plugin.getConfig().getBoolean("Properties.Chi.CanBendWithWeapons")) if (!plugin.getConfig().getBoolean("Properties.Chi.CanBendWithWeapons"))
elements.add(Element.CHI); elements.add(Element.CHI);
return elements; return elements;
} }
public static boolean hasItems() { public static boolean hasItems() {
return Bukkit.getServer().getPluginManager().getPlugin("ProjectKorraItems") != null; return Bukkit.getServer().getPluginManager().getPlugin("ProjectKorraItems") != null;
} }
public static boolean hasProbending() { public static boolean hasProbending() {
return Bukkit.getServer().getPluginManager().getPlugin("Probending") != null; return Bukkit.getServer().getPluginManager().getPlugin("Probending") != null;
} }
@ -1168,7 +1153,7 @@ public class GeneralMethods {
public static boolean hasRPG() { public static boolean hasRPG() {
return Bukkit.getServer().getPluginManager().getPlugin("ProjectKorraRPG") != null; return Bukkit.getServer().getPluginManager().getPlugin("ProjectKorraRPG") != null;
} }
public static boolean hasSpirits() { public static boolean hasSpirits() {
return Bukkit.getServer().getPluginManager().getPlugin("ProjectKorraSpirits") != null; return Bukkit.getServer().getPluginManager().getPlugin("ProjectKorraSpirits") != null;
} }
@ -1195,7 +1180,7 @@ public class GeneralMethods {
public static boolean isImportEnabled() { public static boolean isImportEnabled() {
return ConfigManager.defaultConfig.get().getBoolean("Properties.ImportEnabled"); return ConfigManager.defaultConfig.get().getBoolean("Properties.ImportEnabled");
} }
public static boolean isInteractable(Block block) { public static boolean isInteractable(Block block) {
return Arrays.asList(INTERACTABLE_MATERIALS).contains(block.getType()); return Arrays.asList(INTERACTABLE_MATERIALS).contains(block.getType());
} }
@ -1210,7 +1195,7 @@ public class GeneralMethods {
Location loc; Location loc;
double max = 0; double max = 0;
if(location1.getWorld().equals(location2.getWorld())) if (location1.getWorld().equals(location2.getWorld()))
max = location1.distance(location2); max = location1.distance(location2);
for (double i = 0; i <= max; i++) { for (double i = 0; i <= max; i++) {
@ -1251,11 +1236,11 @@ public class GeneralMethods {
blockMap.put(block, new BlockCacheElement(player, block, ability, value, System.currentTimeMillis())); blockMap.put(block, new BlockCacheElement(player, block, ability, value, System.currentTimeMillis()));
return value; return value;
} }
public static boolean isRegionProtectedFromBuild(Ability ability, Location loc) { public static boolean isRegionProtectedFromBuild(Ability ability, Location loc) {
return isRegionProtectedFromBuild(ability.getPlayer(), ability.getName(), loc); return isRegionProtectedFromBuild(ability.getPlayer(), ability.getName(), loc);
} }
public static boolean isRegionProtectedFromBuild(Player player, Location loc) { public static boolean isRegionProtectedFromBuild(Player player, Location loc) {
return isRegionProtectedFromBuild(player, null, loc); return isRegionProtectedFromBuild(player, null, loc);
} }
@ -1417,7 +1402,7 @@ public class GeneralMethods {
return true; return true;
} }
} }
if (residence != null && respectResidence) { if (residence != null && respectResidence) {
ClaimedResidence res = Residence.getResidenceManager().getByLoc(loc); ClaimedResidence res = Residence.getResidenceManager().getByLoc(loc);
if (res != null) { if (res != null) {
@ -1427,12 +1412,12 @@ public class GeneralMethods {
} }
} }
} }
if (kingdoms != null && respectKingdoms) { if (kingdoms != null && respectKingdoms) {
SimpleLocation location_ = new SimpleLocation(loc); SimpleLocation location_ = new SimpleLocation(loc);
SimpleChunkLocation chunk = location_.toSimpleChunk(); SimpleChunkLocation chunk = location_.toSimpleChunk();
Land land = GameManagement.getLandManager().getOrLoadLand(chunk); Land land = GameManagement.getLandManager().getOrLoadLand(chunk);
if (land.getOwner() != null) { if (land.getOwner() != null) {
KingdomPlayer kp = GameManagement.getPlayerManager().getSession(player); KingdomPlayer kp = GameManagement.getPlayerManager().getSession(player);
@ -1441,25 +1426,21 @@ public class GeneralMethods {
return true; return true;
} else if (kp.getKingdom() == null) { //If the player isn't in a kingdom but it's claimed land } else if (kp.getKingdom() == null) { //If the player isn't in a kingdom but it's claimed land
return true; return true;
} } else {
else
{
Kingdom kingdom = kp.getKingdom(); Kingdom kingdom = kp.getKingdom();
String kingdomName = kingdom.getKingdomName(); String kingdomName = kingdom.getKingdomName();
if (!kingdomName.equals(land.getOwner())) //If the player's kingdom doesn't match if (!kingdomName.equals(land.getOwner())) //If the player's kingdom doesn't match
{ {
return true; return true;
} }
//If it's within the nexus area, test for higher permission //If it's within the nexus area, test for higher permission
if (land.getStructure() != null && land.getStructure().getType() == StructureType.NEXUS) { if (land.getStructure() != null && land.getStructure().getType() == StructureType.NEXUS) {
if (!kp.getRank().isHigherOrEqualTo(kingdom.getPermissionsInfo().getBuildInNexus())) if (!kp.getRank().isHigherOrEqualTo(kingdom.getPermissionsInfo().getBuildInNexus())) {
{
return true; return true;
} }
} }
} }
} }
} }
} }
@ -1471,16 +1452,15 @@ public class GeneralMethods {
return !Arrays.asList(NON_OPAQUE).contains(block.getTypeId()); return !Arrays.asList(NON_OPAQUE).contains(block.getTypeId());
} }
/** Checks if an entity is Undead **/ /** Checks if an entity is Undead **/
public static boolean isUndead(Entity entity) { public static boolean isUndead(Entity entity) {
return entity != null && (entity.getType() == EntityType.ZOMBIE || entity.getType() == EntityType.BLAZE || entity.getType() == EntityType.GIANT || entity.getType() == EntityType.IRON_GOLEM || entity.getType() == EntityType.MAGMA_CUBE || entity.getType() == EntityType.PIG_ZOMBIE || entity.getType() == EntityType.SKELETON || entity.getType() == EntityType.SLIME || entity.getType() == EntityType.SNOWMAN || entity.getType() == EntityType.ZOMBIE); return entity != null && (entity.getType() == EntityType.ZOMBIE || entity.getType() == EntityType.BLAZE || entity.getType() == EntityType.GIANT || entity.getType() == EntityType.IRON_GOLEM || entity.getType() == EntityType.MAGMA_CUBE || entity.getType() == EntityType.PIG_ZOMBIE || entity.getType() == EntityType.SKELETON || entity.getType() == EntityType.SLIME || entity.getType() == EntityType.SNOWMAN || entity.getType() == EntityType.ZOMBIE);
} }
public static boolean isWeapon(Material mat) { public static boolean isWeapon(Material mat) {
return mat != null && (mat == Material.WOOD_AXE || mat == Material.WOOD_PICKAXE || mat == Material.WOOD_SPADE || mat == Material.WOOD_SWORD || mat == Material.STONE_AXE || mat == Material.STONE_PICKAXE || mat == Material.STONE_SPADE || mat == Material.STONE_SWORD || mat == Material.IRON_AXE || mat == Material.IRON_PICKAXE || mat == Material.IRON_SWORD || mat == Material.IRON_SPADE || mat == Material.DIAMOND_AXE || mat == Material.DIAMOND_PICKAXE || mat == Material.DIAMOND_SWORD || mat == Material.DIAMOND_SPADE || mat == Material.GOLD_AXE || mat == Material.GOLD_HOE || mat == Material.GOLD_SWORD || mat == Material.GOLD_PICKAXE || mat == Material.GOLD_SPADE); return mat != null && (mat == Material.WOOD_AXE || mat == Material.WOOD_PICKAXE || mat == Material.WOOD_SPADE || mat == Material.WOOD_SWORD || mat == Material.STONE_AXE || mat == Material.STONE_PICKAXE || mat == Material.STONE_SPADE || mat == Material.STONE_SWORD || mat == Material.IRON_AXE || mat == Material.IRON_PICKAXE || mat == Material.IRON_SWORD || mat == Material.IRON_SPADE || mat == Material.DIAMOND_AXE || mat == Material.DIAMOND_PICKAXE || mat == Material.DIAMOND_SWORD || mat == Material.DIAMOND_SPADE || mat == Material.GOLD_AXE || mat == Material.GOLD_HOE || mat == Material.GOLD_SWORD || mat == Material.GOLD_PICKAXE || mat == Material.GOLD_SPADE);
} }
public static void loadBendingPlayer(BendingPlayer pl) { public static void loadBendingPlayer(BendingPlayer pl) {
Player player = Bukkit.getPlayer(pl.getUUID()); Player player = Bukkit.getPlayer(pl.getUUID());
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
@ -1497,17 +1477,17 @@ public class GeneralMethods {
Preset.loadPresets(player); Preset.loadPresets(player);
Element element = null; Element element = null;
String prefix = ""; String prefix = "";
boolean chatEnabled = ConfigManager.languageConfig.get().getBoolean("Chat.Enable"); boolean chatEnabled = ConfigManager.languageConfig.get().getBoolean("Chat.Enable");
if (bPlayer.getElements().size() > 1) { if (bPlayer.getElements().size() > 1) {
prefix = Element.AVATAR.getPrefix(); prefix = Element.AVATAR.getPrefix();
} else if (bPlayer.getElements().size() == 1){ } else if (bPlayer.getElements().size() == 1) {
element = bPlayer.getElements().get(0); element = bPlayer.getElements().get(0);
prefix = element.getPrefix(); prefix = element.getPrefix();
} else { } else {
prefix = ChatColor.WHITE + ChatColor.translateAlternateColorCodes('&', ConfigManager.languageConfig.get().getString("Chat.Prefixes.Nonbender")) + " "; prefix = ChatColor.WHITE + ChatColor.translateAlternateColorCodes('&', ConfigManager.languageConfig.get().getString("Chat.Prefixes.Nonbender")) + " ";
} }
if (chatEnabled) { if (chatEnabled) {
player.setDisplayName(player.getName()); player.setDisplayName(player.getName());
player.setDisplayName(prefix + ChatColor.RESET + player.getDisplayName()); player.setDisplayName(prefix + ChatColor.RESET + player.getDisplayName());
@ -1552,14 +1532,14 @@ public class GeneralMethods {
CoreAbility.registerAbilities(); CoreAbility.registerAbilities();
new ComboManager(); new ComboManager();
new MultiAbilityManager(); new MultiAbilityManager();
DBConnection.host = ConfigManager.defaultConfig.get().getString("Storage.MySQL.host"); DBConnection.host = ConfigManager.defaultConfig.get().getString("Storage.MySQL.host");
DBConnection.port = ConfigManager.defaultConfig.get().getInt("Storage.MySQL.port"); DBConnection.port = ConfigManager.defaultConfig.get().getInt("Storage.MySQL.port");
DBConnection.pass = ConfigManager.defaultConfig.get().getString("Storage.MySQL.pass"); DBConnection.pass = ConfigManager.defaultConfig.get().getString("Storage.MySQL.pass");
DBConnection.db = ConfigManager.defaultConfig.get().getString("Storage.MySQL.db"); DBConnection.db = ConfigManager.defaultConfig.get().getString("Storage.MySQL.db");
DBConnection.user = ConfigManager.defaultConfig.get().getString("Storage.MySQL.user"); DBConnection.user = ConfigManager.defaultConfig.get().getString("Storage.MySQL.user");
DBConnection.init(); DBConnection.init();
if (!DBConnection.isOpen()) { if (!DBConnection.isOpen()) {
ProjectKorra.log.severe("Unable to enable ProjectKorra due to the database not being open"); ProjectKorra.log.severe("Unable to enable ProjectKorra due to the database not being open");
stopPlugin(); stopPlugin();
@ -1586,7 +1566,7 @@ public class GeneralMethods {
if (bPlayer == null) { if (bPlayer == null) {
return; return;
} }
HashMap<Integer, String> slots = bPlayer.getAbilities(); HashMap<Integer, String> slots = bPlayer.getAbilities();
HashMap<Integer, String> finalAbilities = new HashMap<Integer, String>(); HashMap<Integer, String> finalAbilities = new HashMap<Integer, String>();
for (int i : slots.keySet()) { for (int i : slots.keySet()) {
@ -1658,7 +1638,7 @@ public class GeneralMethods {
writeToDebug(line); writeToDebug(line);
} }
} }
writeToDebug(""); writeToDebug("");
writeToDebug("Supported Plugins"); writeToDebug("Supported Plugins");
writeToDebug("===================="); writeToDebug("====================");
@ -1704,15 +1684,14 @@ public class GeneralMethods {
writeToDebug(""); writeToDebug("");
writeToDebug("Plugins Hooking Into ProjectKorra (Core)"); writeToDebug("Plugins Hooking Into ProjectKorra (Core)");
writeToDebug("===================="); writeToDebug("====================");
String[] pkPlugins = new String[] {"projectkorrarpg", "projectkorraitems", "projectkorraspirits", "probending"}; String[] pkPlugins = new String[] { "projectkorrarpg", "projectkorraitems", "projectkorraspirits", "probending" };
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) { for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
if (plugin.getDescription().getDepend() != null && plugin.getDescription().getDepend().contains("ProjectKorra") if (plugin.getDescription().getDepend() != null && plugin.getDescription().getDepend().contains("ProjectKorra") && !Arrays.asList(pkPlugins).contains(plugin.getName().toLowerCase())) {
&& !Arrays.asList(pkPlugins).contains(plugin.getName().toLowerCase())) {
writeToDebug(plugin.getDescription().getName() + " v" + plugin.getDescription().getVersion()); writeToDebug(plugin.getDescription().getName() + " v" + plugin.getDescription().getVersion());
} }
} }
writeToDebug(""); writeToDebug("");
writeToDebug("Ability Information"); writeToDebug("Ability Information");
writeToDebug("===================="); writeToDebug("====================");
@ -1737,7 +1716,7 @@ public class GeneralMethods {
writeToDebug(ability + " - UNOFFICAL"); writeToDebug(ability + " - UNOFFICAL");
} }
} }
writeToDebug(""); writeToDebug("");
writeToDebug("Collection Sizes"); writeToDebug("Collection Sizes");
writeToDebug("===================="); writeToDebug("====================");
@ -1745,34 +1724,36 @@ public class GeneralMethods {
try { try {
for (final ClassPath.ClassInfo info : ClassPath.from(loader).getTopLevelClasses()) { for (final ClassPath.ClassInfo info : ClassPath.from(loader).getTopLevelClasses()) {
if (info.getName().startsWith("com.projectkorra.")) { if (info.getName().startsWith("com.projectkorra.")) {
final Class<?> clazz = info.load(); final Class<?> clazz = info.load();
for (Field field : clazz.getDeclaredFields()) { for (Field field : clazz.getDeclaredFields()) {
String simpleName = clazz.getSimpleName(); String simpleName = clazz.getSimpleName();
field.setAccessible(true); field.setAccessible(true);
try { try {
Object obj = field.get(null); Object obj = field.get(null);
if (obj instanceof Collection) { if (obj instanceof Collection) {
writeToDebug(simpleName + ": " + field.getName() + " size=" + ((Collection<?>) obj).size()); writeToDebug(simpleName + ": " + field.getName() + " size=" + ((Collection<?>) obj).size());
} else if (obj instanceof Map) { } else if (obj instanceof Map) {
writeToDebug(simpleName + ": " + field.getName() + " size=" + ((Map<?,?>) obj).size()); writeToDebug(simpleName + ": " + field.getName() + " size=" + ((Map<?, ?>) obj).size());
} }
} catch (Exception e) { }
catch (Exception e) {
}
} }
}
} }
} }
} catch (IOException e) { }
catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
writeToDebug(""); writeToDebug("");
writeToDebug("CoreAbility Debugger"); writeToDebug("CoreAbility Debugger");
writeToDebug("===================="); writeToDebug("====================");
for (String line : CoreAbility.getDebugString().split("\\n")) { for (String line : CoreAbility.getDebugString().split("\\n")) {
writeToDebug(line); writeToDebug(line);
} }
} }
public static void saveAbility(BendingPlayer bPlayer, int slot, String ability) { public static void saveAbility(BendingPlayer bPlayer, int slot, String ability) {
@ -1780,7 +1761,7 @@ public class GeneralMethods {
return; return;
} }
String uuid = bPlayer.getUUIDString(); String uuid = bPlayer.getUUIDString();
BindChangeEvent event = new BindChangeEvent(Bukkit.getPlayer(UUID.fromString(uuid)), ability, slot, false); BindChangeEvent event = new BindChangeEvent(Bukkit.getPlayer(UUID.fromString(uuid)), ability, slot, false);
Bukkit.getServer().getPluginManager().callEvent(event); Bukkit.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) { if (event.isCancelled()) {
@ -1830,13 +1811,13 @@ public class GeneralMethods {
DBConnection.sql.modifyQuery("UPDATE pk_players SET element = '" + elements + "' WHERE uuid = '" + uuid + "'"); DBConnection.sql.modifyQuery("UPDATE pk_players SET element = '" + elements + "' WHERE uuid = '" + uuid + "'");
} }
public static void saveSubElements(BendingPlayer bPlayer) { public static void saveSubElements(BendingPlayer bPlayer) {
if (bPlayer == null) { if (bPlayer == null) {
return; return;
} }
String uuid = bPlayer.getUUIDString(); String uuid = bPlayer.getUUIDString();
StringBuilder subs = new StringBuilder(); StringBuilder subs = new StringBuilder();
if (bPlayer.hasSubElement(Element.METAL)) { if (bPlayer.hasSubElement(Element.METAL)) {
subs.append("m"); subs.append("m");
@ -1873,7 +1854,8 @@ public class GeneralMethods {
} }
boolean hasAddon = false; boolean hasAddon = false;
for (Element element : bPlayer.getElements()) { for (Element element : bPlayer.getElements()) {
if (!(element instanceof SubElement)) continue; if (!(element instanceof SubElement))
continue;
if (Arrays.asList(Element.getAddonElements()).contains(element)) { if (Arrays.asList(Element.getAddonElements()).contains(element)) {
if (!hasAddon) { if (!hasAddon) {
hasAddon = true; hasAddon = true;
@ -1882,7 +1864,7 @@ public class GeneralMethods {
subs.append(element.getName() + ","); subs.append(element.getName() + ",");
} }
} }
DBConnection.sql.modifyQuery("UPDATE pk_players SET subelement = '" + subs + "' WHERE uuid = '" + uuid + "'"); DBConnection.sql.modifyQuery("UPDATE pk_players SET subelement = '" + subs + "' WHERE uuid = '" + uuid + "'");
} }
@ -1908,26 +1890,26 @@ public class GeneralMethods {
} }
return; return;
} }
// Attempt to stop velocity from going over the packet cap. // Attempt to stop velocity from going over the packet cap.
if(velocity.getX() > 4){ if (velocity.getX() > 4) {
velocity.setX(4); velocity.setX(4);
} else if(velocity.getX() < -4){ } else if (velocity.getX() < -4) {
velocity.setX(-4); velocity.setX(-4);
} }
if(velocity.getY() > 4){ if (velocity.getY() > 4) {
velocity.setY(4); velocity.setY(4);
} else if(velocity.getY() < -4){ } else if (velocity.getY() < -4) {
velocity.setY(-4); velocity.setY(-4);
} }
if(velocity.getZ() > 4){ if (velocity.getZ() > 4) {
velocity.setZ(4); velocity.setZ(4);
} else if(velocity.getZ() < -4){ } else if (velocity.getZ() < -4) {
velocity.setZ(-4); velocity.setZ(-4);
} }
entity.setVelocity(velocity); entity.setVelocity(velocity);
} }

View file

@ -40,7 +40,7 @@ public class ProjectKorra extends JavaPlugin {
public static CollisionInitializer collisionInitializer; public static CollisionInitializer collisionInitializer;
public static long time_step = 1; public static long time_step = 1;
public Updater updater; public Updater updater;
@Override @Override
public void onEnable() { public void onEnable() {
plugin = this; plugin = this;
@ -56,7 +56,7 @@ public class ProjectKorra extends JavaPlugin {
catch (SecurityException | IOException e) { catch (SecurityException | IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
new ConfigManager(); new ConfigManager();
new GeneralMethods(this); new GeneralMethods(this);
updater = new Updater(this, "http://projectkorra.com/forums/dev-builds.16/index.rss"); updater = new Updater(this, "http://projectkorra.com/forums/dev-builds.16/index.rss");
@ -65,12 +65,12 @@ public class ProjectKorra extends JavaPlugin {
new ComboManager(); new ComboManager();
collisionManager = new CollisionManager(); collisionManager = new CollisionManager();
collisionInitializer = new CollisionInitializer(collisionManager); collisionInitializer = new CollisionInitializer(collisionManager);
CoreAbility.registerAbilities(); CoreAbility.registerAbilities();
collisionInitializer.initializeDefaultCollisions(); // must be called after abilities have been registered collisionInitializer.initializeDefaultCollisions(); // must be called after abilities have been registered
collisionManager.startCollisionDetection(); collisionManager.startCollisionDetection();
Preset.loadExternalPresets(); Preset.loadExternalPresets();
DBConnection.host = getConfig().getString("Storage.MySQL.host"); DBConnection.host = getConfig().getString("Storage.MySQL.host");
DBConnection.port = getConfig().getInt("Storage.MySQL.port"); DBConnection.port = getConfig().getInt("Storage.MySQL.port");
DBConnection.pass = getConfig().getString("Storage.MySQL.pass"); DBConnection.pass = getConfig().getString("Storage.MySQL.pass");
@ -92,10 +92,10 @@ public class ProjectKorra extends JavaPlugin {
//getServer().getScheduler().scheduleSyncRepeatingTask(this, new PassiveHandler(), 0, 1); //getServer().getScheduler().scheduleSyncRepeatingTask(this, new PassiveHandler(), 0, 1);
getServer().getScheduler().runTaskTimerAsynchronously(this, new RevertChecker(this), 0, 200); getServer().getScheduler().runTaskTimerAsynchronously(this, new RevertChecker(this), 0, 200);
TempBlock.startReversion(); TempBlock.startReversion();
for (final Player player : Bukkit.getOnlinePlayers()) { for (final Player player : Bukkit.getOnlinePlayers()) {
PKListener.getJumpStatistics().put(player, player.getStatistic(Statistic.JUMP)); PKListener.getJumpStatistics().put(player, player.getStatistic(Statistic.JUMP));
GeneralMethods.createBendingPlayer(player.getUniqueId(), player.getName()); GeneralMethods.createBendingPlayer(player.getUniqueId(), player.getName());
GeneralMethods.removeUnusableAbilities(player.getName()); GeneralMethods.removeUnusableAbilities(player.getName());
Bukkit.getScheduler().runTaskLater(ProjectKorra.plugin, new Runnable() { Bukkit.getScheduler().runTaskLater(ProjectKorra.plugin, new Runnable() {

View file

@ -17,8 +17,9 @@ import com.projectkorra.projectkorra.waterbending.TorrentWave;
import com.projectkorra.projectkorra.waterbending.passive.WaterPassive; import com.projectkorra.projectkorra.waterbending.passive.WaterPassive;
/** /**
* The Ability interface defines the set of methods that any CoreAbility, AddonAbility, ComboAbility, or * The Ability interface defines the set of methods that any CoreAbility,
* MultiAbility should implement. {@link CoreAbility} provides a default implementation for a few of these * AddonAbility, ComboAbility, or MultiAbility should implement.
* {@link CoreAbility} provides a default implementation for a few of these
* methods, but most will need to be specified by each Ability individually. * methods, but most will need to be specified by each Ability individually.
*/ */
public interface Ability { public interface Ability {
@ -34,45 +35,49 @@ public interface Ability {
public void remove(); public void remove();
/** /**
* Determines if this ability uses the {@link PlayerToggleSneakEvent} as a controlling * Determines if this ability uses the {@link PlayerToggleSneakEvent} as a
* mechanism. Currently {@link WaterPassive} will not work while the player has a sneak ability * controlling mechanism. Currently {@link WaterPassive} will not work while
* bound. * the player has a sneak ability bound.
* *
* @return true if the ability uses sneak as a controlling mechanism * @return true if the ability uses sneak as a controlling mechanism
*/ */
public boolean isSneakAbility(); public boolean isSneakAbility();
/** /**
* Determines if this ability is considered harmless against other players. A harmless ability * Determines if this ability is considered harmless against other players.
* cannot manipulate another player. For example: AirPassive, WaterSpout, AirSpout, and FireJet. * A harmless ability cannot manipulate another player. For example:
* AirPassive, WaterSpout, AirSpout, and FireJet.
* *
* @return true if the ability is harmless and should be allowed in both PvP and non-PvP zones * @return true if the ability is harmless and should be allowed in both PvP
* and non-PvP zones
*/ */
public boolean isHarmlessAbility(); public boolean isHarmlessAbility();
/** /**
* Determines if this ability can ignite blocks. For example: {@link Blaze}, {@link FireBlast}, * Determines if this ability can ignite blocks. For example: {@link Blaze},
* and {@link FireBurst}. * {@link FireBlast}, and {@link FireBurst}.
*/ */
public boolean isIgniteAbility(); public boolean isIgniteAbility();
/** /**
* Determines if this ability can cause explosions. For example: {@link FireBlastCharged} * Determines if this ability can cause explosions. For example:
* {@link FireBlastCharged}
*/ */
public boolean isExplosiveAbility(); public boolean isExplosiveAbility();
/** /**
* A hidden ability is an ability that should not be shown by commands such as <b>/bending * A hidden ability is an ability that should not be shown by commands such
* display</b> and <b>/bending help</b>. For example: Combos, MultiAbility sub abilities, and * as <b>/bending display</b> and <b>/bending help</b>. For example: Combos,
* helper abilities. * MultiAbility sub abilities, and helper abilities.
* *
* @return true if the ability should not be displayed to the players * @return true if the ability should not be displayed to the players
*/ */
public boolean isHiddenAbility(); public boolean isHiddenAbility();
/** /**
* Returns true if the ability is enabled through the config.yml. Usually the Enabled option * Returns true if the ability is enabled through the config.yml. Usually
* follows the format Abilities.ElementName.AbilityName.Enabled. * the Enabled option follows the format
* Abilities.ElementName.AbilityName.Enabled.
*/ */
public boolean isEnabled(); public boolean isEnabled();
@ -82,40 +87,45 @@ public interface Ability {
public long getCooldown(); public long getCooldown();
/** /**
* Returns the player that caused this ability to be initiated. The player can be null in * Returns the player that caused this ability to be initiated. The player
* certain circumstances, for example when calling {@link CoreAbility#getAbility(String)}, or if * can be null in certain circumstances, for example when calling
* an ability decided to set player to null. * {@link CoreAbility#getAbility(String)}, or if an ability decided to set
* player to null.
* *
* @return the player that this ability belongs to * @return the player that this ability belongs to
*/ */
public Player getPlayer(); public Player getPlayer();
/** /**
* The name of the ability is used for commands such as <b>/bending display</b> and <b>/bending * The name of the ability is used for commands such as <b>/bending
* help</b>. The name is also used for determining the tag for cooldowns * display</b> and <b>/bending help</b>. The name is also used for
* {@link BendingPlayer#addCooldown(Ability)}, therefore if two abilities have the same name * determining the tag for cooldowns
* they will also share cooldowns. If two classes share the same name (SurgeWall/SurgeWave) but * {@link BendingPlayer#addCooldown(Ability)}, therefore if two abilities
* need to have independent cooldowns, then {@link BendingPlayer#addCooldown(String, long)} * have the same name they will also share cooldowns. If two classes share
* should be called explicitly. * the same name (SurgeWall/SurgeWave) but need to have independent
* cooldowns, then {@link BendingPlayer#addCooldown(String, long)} should be
* called explicitly.
* *
* @return Returns the name of the ability * @return Returns the name of the ability
*/ */
public String getName(); public String getName();
/** /**
* Return's the instructions of an ability. * Return's the instructions of an ability. ProjectKorra's help command will
* ProjectKorra's help command will then use this method to display the instructions of an ability when the command is run. * then use this method to display the instructions of an ability when the
* command is run.
* *
* @return the instructions for this ability * @return the instructions for this ability
* @see HelpCommand * @see HelpCommand
* @see CoreAbility#getInstructions() * @see CoreAbility#getInstructions()
*/ */
public String getInstructions(); public String getInstructions();
/** /**
* The description of an ability is a few sentences used to describe how the player can fully * The description of an ability is a few sentences used to describe how the
* utilize the ability. In most cases the description will be specified in the config.yml file * player can fully utilize the ability. In most cases the description will
* and will be retrieved by accessing the FileConfiguration via {@link CoreAbility#getConfig}. * be specified in the config.yml file and will be retrieved by accessing
* the FileConfiguration via {@link CoreAbility#getConfig}.
* *
* @return the description for this ability * @return the description for this ability
* @see HelpCommand * @see HelpCommand
@ -124,9 +134,9 @@ public interface Ability {
public String getDescription(); public String getDescription();
/** /**
* Specifies the Element used to represent this type of ability, favoring SubElements over * Specifies the Element used to represent this type of ability, favoring
* Elements. For example, a LightningAbility would return {@link Element#LIGHTNING} instead of * SubElements over Elements. For example, a LightningAbility would return
* {@link Element#FIRE}. * {@link Element#LIGHTNING} instead of {@link Element#FIRE}.
* *
* @return the most accurate Element that this ability belongs to * @return the most accurate Element that this ability belongs to
* @see SubElement#getParentElement * @see SubElement#getParentElement
@ -134,10 +144,12 @@ public interface Ability {
public Element getElement(); public Element getElement();
/** /**
* Specifies the Location of the ability, which may be slightly inaccurate depending on the * Specifies the Location of the ability, which may be slightly inaccurate
* Ability implementation. For example, a {@link TorrentWave} could not be fully specified by a * depending on the Ability implementation. For example, a
* single location, while it is possible for an {@link EarthBlast}. The location is useful for * {@link TorrentWave} could not be fully specified by a single location,
* making sure that the player is currently in the same world as the ability. * while it is possible for an {@link EarthBlast}. The location is useful
* for making sure that the player is currently in the same world as the
* ability.
* *
* @return the location of the Ability * @return the location of the Ability
* @see BendingPlayer#canBend(CoreAbility) * @see BendingPlayer#canBend(CoreAbility)

View file

@ -3,15 +3,16 @@ package com.projectkorra.projectkorra.ability;
public interface AddonAbility { public interface AddonAbility {
/** /**
* Called when the ability is loaded by PK. This is where the developer registers Listeners and * Called when the ability is loaded by PK. This is where the developer
* Permissions. * registers Listeners and Permissions.
*/ */
public void load(); public void load();
/** /**
* Called whenever ProjectKorra stops and the ability is unloaded. This method is useful * Called whenever ProjectKorra stops and the ability is unloaded. This
* for cleaning up leftover objects such as frozen blocks. Any CoreAbility instances do not need to be * method is useful for cleaning up leftover objects such as frozen blocks.
* cleaned up by stop method, as they will be cleaned up by {@link CoreAbility#removeAll()}. * Any CoreAbility instances do not need to be cleaned up by stop method, as
* they will be cleaned up by {@link CoreAbility#removeAll()}.
*/ */
public void stop(); public void stop();
@ -21,7 +22,7 @@ public interface AddonAbility {
public String getAuthor(); public String getAuthor();
/** /**
* @return The version of the ability as a String. * @return The version of the ability as a String.
*/ */
public String getVersion(); public String getVersion();
} }

View file

@ -18,7 +18,7 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
public abstract class AirAbility extends ElementalAbility { public abstract class AirAbility extends ElementalAbility {
public AirAbility(Player player) { public AirAbility(Player player) {
super(player); super(player);
} }
@ -27,17 +27,17 @@ public abstract class AirAbility extends ElementalAbility {
public boolean isIgniteAbility() { public boolean isIgniteAbility() {
return false; return false;
} }
@Override @Override
public boolean isExplosiveAbility() { public boolean isExplosiveAbility() {
return false; return false;
} }
@Override @Override
public Element getElement() { public Element getElement() {
return Element.AIR; return Element.AIR;
} }
@Override @Override
public void handleCollision(Collision collision) { public void handleCollision(Collision collision) {
super.handleCollision(collision); super.handleCollision(collision);
@ -46,10 +46,10 @@ public abstract class AirAbility extends ElementalAbility {
ParticleEffect.BLOCK_CRACK.display(particleData, 1F, 1F, 1F, 0.1F, 10, collision.getLocationFirst(), 50); ParticleEffect.BLOCK_CRACK.display(particleData, 1F, 1F, 1F, 0.1F, 10, collision.getLocationFirst(), 50);
} }
} }
/** /**
* Breaks a breathbendng hold on an entity or one a player is inflicting on an entity. * Breaks a breathbendng hold on an entity or one a player is inflicting on
* an entity.
* *
* @param entity The entity to be acted upon * @param entity The entity to be acted upon
*/ */
@ -66,7 +66,7 @@ public abstract class AirAbility extends ElementalAbility {
} }
} }
} }
/** /**
* Gets the Air Particles from the config. * Gets the Air Particles from the config.
* *
@ -88,7 +88,7 @@ public abstract class AirAbility extends ElementalAbility {
return ParticleEffect.CLOUD; return ParticleEffect.CLOUD;
} }
} }
/** /**
* This method was used for the old collision detection system. Please see * This method was used for the old collision detection system. Please see
* {@link Collision} for the new system. * {@link Collision} for the new system.
@ -116,8 +116,8 @@ public abstract class AirAbility extends ElementalAbility {
} }
/** /**
* Plays an integer amount of air particles in a location with a given xOffset, yOffset, and * Plays an integer amount of air particles in a location with a given
* zOffset. * xOffset, yOffset, and zOffset.
* *
* @param loc The location to use * @param loc The location to use
* @param amount The amount of particles * @param amount The amount of particles

View file

@ -7,16 +7,16 @@ import org.bukkit.Sound;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public abstract class AvatarAbility extends ElementalAbility { public abstract class AvatarAbility extends ElementalAbility {
public AvatarAbility(Player player) { public AvatarAbility(Player player) {
super(player); super(player);
} }
@Override @Override
public boolean isIgniteAbility() { public boolean isIgniteAbility() {
return false; return false;
} }
@Override @Override
public boolean isExplosiveAbility() { public boolean isExplosiveAbility() {
return false; return false;
@ -26,14 +26,16 @@ public abstract class AvatarAbility extends ElementalAbility {
public final Element getElement() { public final Element getElement() {
return Element.AVATAR; return Element.AVATAR;
} }
public static void playAvatarSound(Location loc) { public static void playAvatarSound(Location loc) {
loc.getWorld().playSound(loc, Sound.BLOCK_ANVIL_LAND, 1, 10); loc.getWorld().playSound(loc, Sound.BLOCK_ANVIL_LAND, 1, 10);
} }
/**Determines whether the ability requires the user to be an avatar in order to be able /**
* to use it. Set this to <tt>false</tt> for moves that should be able to be used without * Determines whether the ability requires the user to be an avatar in order
* players needing to have the avatar element*/ * to be able to use it. Set this to <tt>false</tt> for moves that should be
* able to be used without players needing to have the avatar element
*/
public boolean requireAvatar() { public boolean requireAvatar() {
return true; return true;
} }

View file

@ -5,7 +5,7 @@ import com.projectkorra.projectkorra.Element;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public abstract class BloodAbility extends WaterAbility implements SubAbility { public abstract class BloodAbility extends WaterAbility implements SubAbility {
public BloodAbility(Player player) { public BloodAbility(Player player) {
super(player); super(player);
} }
@ -14,10 +14,10 @@ public abstract class BloodAbility extends WaterAbility implements SubAbility {
public Class<? extends Ability> getParentAbility() { public Class<? extends Ability> getParentAbility() {
return WaterAbility.class; return WaterAbility.class;
} }
@Override @Override
public Element getElement() { public Element getElement() {
return Element.BLOOD; return Element.BLOOD;
} }
} }

View file

@ -5,7 +5,7 @@ import com.projectkorra.projectkorra.Element;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public abstract class ChiAbility extends ElementalAbility { public abstract class ChiAbility extends ElementalAbility {
public ChiAbility(Player player) { public ChiAbility(Player player) {
super(player); super(player);
} }
@ -14,15 +14,15 @@ public abstract class ChiAbility extends ElementalAbility {
public boolean isIgniteAbility() { public boolean isIgniteAbility() {
return false; return false;
} }
@Override @Override
public boolean isExplosiveAbility() { public boolean isExplosiveAbility() {
return false; return false;
} }
@Override @Override
public Element getElement() { public Element getElement() {
return Element.CHI; return Element.CHI;
} }
} }

View file

@ -7,13 +7,13 @@ import org.bukkit.entity.Player;
import java.util.ArrayList; import java.util.ArrayList;
public interface ComboAbility { public interface ComboAbility {
/** /**
* Accessor Method to get the instructions for using this combo. * Accessor Method to get the instructions for using this combo.
* *
* @return The steps for the combo. * @return The steps for the combo.
*/ */
public abstract Object createNewComboInstance(Player player); public abstract Object createNewComboInstance(Player player);
/** /**
@ -22,5 +22,5 @@ public interface ComboAbility {
* @return An ArrayList containing the combo's steps. * @return An ArrayList containing the combo's steps.
*/ */
public abstract ArrayList<AbilityInformation> getCombination(); public abstract ArrayList<AbilityInformation> getCombination();
} }

View file

@ -5,7 +5,7 @@ import com.projectkorra.projectkorra.Element;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public abstract class CombustionAbility extends FireAbility implements SubAbility { public abstract class CombustionAbility extends FireAbility implements SubAbility {
public CombustionAbility(Player player) { public CombustionAbility(Player player) {
super(player); super(player);
} }
@ -14,10 +14,10 @@ public abstract class CombustionAbility extends FireAbility implements SubAbilit
public Class<? extends Ability> getParentAbility() { public Class<? extends Ability> getParentAbility() {
return FireAbility.class; return FireAbility.class;
} }
@Override @Override
public Element getElement() { public Element getElement() {
return Element.COMBUSTION; return Element.COMBUSTION;
} }
} }

View file

@ -472,7 +472,7 @@ public abstract class CoreAbility implements Ability {
MultiAbility multiAbil = (MultiAbility) ability; MultiAbility multiAbil = (MultiAbility) ability;
MultiAbilityManager.multiAbilityList.add(new MultiAbilityInfo(name, multiAbil.getMultiAbilities())); MultiAbilityManager.multiAbilityList.add(new MultiAbilityInfo(name, multiAbil.getMultiAbilities()));
} }
if (ability instanceof PassiveAbility) { if (ability instanceof PassiveAbility) {
ability.setHiddenAbility(true); ability.setHiddenAbility(true);
PassiveManager.getPassives().put(name, ability); PassiveManager.getPassives().put(name, ability);
@ -550,7 +550,7 @@ public abstract class CoreAbility implements Ability {
MultiAbility multiAbil = (MultiAbility) coreAbil; MultiAbility multiAbil = (MultiAbility) coreAbil;
MultiAbilityManager.multiAbilityList.add(new MultiAbilityInfo(name, multiAbil.getMultiAbilities())); MultiAbilityManager.multiAbilityList.add(new MultiAbilityInfo(name, multiAbil.getMultiAbilities()));
} }
if (coreAbil instanceof PassiveAbility) { if (coreAbil instanceof PassiveAbility) {
coreAbil.setHiddenAbility(true); coreAbil.setHiddenAbility(true);
PassiveManager.getPassives().put(name, coreAbil); PassiveManager.getPassives().put(name, coreAbil);
@ -604,7 +604,7 @@ public abstract class CoreAbility implements Ability {
public boolean isHiddenAbility() { public boolean isHiddenAbility() {
return hidden; return hidden;
} }
public void setHiddenAbility(boolean hidden) { public void setHiddenAbility(boolean hidden) {
this.hidden = hidden; this.hidden = hidden;
} }
@ -637,15 +637,15 @@ public abstract class CoreAbility implements Ability {
} }
@Override @Override
public String getInstructions() { public String getInstructions() {
String elementName = getElement().getName(); String elementName = getElement().getName();
if (getElement() instanceof SubElement) { if (getElement() instanceof SubElement) {
elementName = ((SubElement) getElement()).getParentElement().getName(); elementName = ((SubElement) getElement()).getParentElement().getName();
} }
return ConfigManager.languageConfig.get().getString("Abilities." + elementName + "." + getName() + ".Instructions"); return ConfigManager.languageConfig.get().contains("Abilities." + elementName + "." + getName() + ".Instructions") ? ConfigManager.languageConfig.get().getString("Abilities." + elementName + "." + getName() + ".Instructions") : "";
} }
@Override @Override
public String getDescription() { public String getDescription() {
String elementName = getElement().getName(); String elementName = getElement().getName();
@ -662,9 +662,9 @@ public abstract class CoreAbility implements Ability {
public Player getPlayer() { public Player getPlayer() {
return player; return player;
} }
/** /**
* Changes the player that owns this ability instance. Used for redirection * Changes the player that owns this ability instance. Used for redirection
* and other abilities that change the player object. * and other abilities that change the player object.
* *
* @param player The player who now controls the ability * @param player The player who now controls the ability
@ -684,18 +684,17 @@ public abstract class CoreAbility implements Ability {
INSTANCES_BY_PLAYER.remove(getClass()); INSTANCES_BY_PLAYER.remove(getClass());
} }
} }
if (!INSTANCES_BY_PLAYER.containsKey(this.getClass())) { if (!INSTANCES_BY_PLAYER.containsKey(this.getClass())) {
INSTANCES_BY_PLAYER.put(this.getClass(), new ConcurrentHashMap<UUID, Map<Integer, CoreAbility>>()); INSTANCES_BY_PLAYER.put(this.getClass(), new ConcurrentHashMap<UUID, Map<Integer, CoreAbility>>());
} }
if (!INSTANCES_BY_PLAYER.get(this.getClass()).containsKey(player.getUniqueId())) { if (!INSTANCES_BY_PLAYER.get(this.getClass()).containsKey(player.getUniqueId())) {
INSTANCES_BY_PLAYER.get(this.getClass()).put(player.getUniqueId(), new ConcurrentHashMap<Integer, CoreAbility>()); INSTANCES_BY_PLAYER.get(this.getClass()).put(player.getUniqueId(), new ConcurrentHashMap<Integer, CoreAbility>());
} }
INSTANCES_BY_PLAYER.get(this.getClass()).get(player.getUniqueId()).put(this.getId(), this); INSTANCES_BY_PLAYER.get(this.getClass()).get(player.getUniqueId()).put(this.getId(), this);
this.player = player; this.player = player;
} }
@ -822,4 +821,4 @@ public abstract class CoreAbility implements Ability {
return DEFAULT_COLLISION_RADIUS; return DEFAULT_COLLISION_RADIUS;
} }
} }

View file

@ -35,7 +35,7 @@ import com.projectkorra.projectkorra.util.ParticleEffect.ParticleData;
import com.projectkorra.projectkorra.util.TempBlock; import com.projectkorra.projectkorra.util.TempBlock;
public abstract class EarthAbility extends ElementalAbility { public abstract class EarthAbility extends ElementalAbility {
private static final HashSet<Block> PREVENT_EARTHBENDING = new HashSet<Block>(); private static final HashSet<Block> PREVENT_EARTHBENDING = new HashSet<Block>();
private static final Map<Block, Information> MOVED_EARTH = new ConcurrentHashMap<Block, Information>(); private static final Map<Block, Information> MOVED_EARTH = new ConcurrentHashMap<Block, Information>();
private static final Map<Integer, Information> TEMP_AIR_LOCATIONS = new ConcurrentHashMap<Integer, Information>(); private static final Map<Integer, Information> TEMP_AIR_LOCATIONS = new ConcurrentHashMap<Integer, Information>();
@ -44,7 +44,7 @@ public abstract class EarthAbility extends ElementalAbility {
public EarthAbility(Player player) { public EarthAbility(Player player) {
super(player); super(player);
} }
public int getEarthbendableBlocksLength(Block block, Vector direction, int maxlength) { public int getEarthbendableBlocksLength(Block block, Vector direction, int maxlength) {
Location location = block.getLocation(); Location location = block.getLocation();
direction = direction.normalize(); direction = direction.normalize();
@ -56,11 +56,11 @@ public abstract class EarthAbility extends ElementalAbility {
} }
return maxlength; return maxlength;
} }
public Block getEarthSourceBlock(double range) { public Block getEarthSourceBlock(double range) {
return getEarthSourceBlock(player, getName(), range); return getEarthSourceBlock(player, getName(), range);
} }
@Override @Override
public Element getElement() { public Element getElement() {
return Element.EARTH; return Element.EARTH;
@ -78,12 +78,12 @@ public abstract class EarthAbility extends ElementalAbility {
public boolean isExplosiveAbility() { public boolean isExplosiveAbility() {
return false; return false;
} }
@Override @Override
public boolean isIgniteAbility() { public boolean isIgniteAbility() {
return false; return false;
} }
@Override @Override
public void handleCollision(Collision collision) { public void handleCollision(Collision collision) {
super.handleCollision(collision); super.handleCollision(collision);
@ -92,7 +92,7 @@ public abstract class EarthAbility extends ElementalAbility {
ParticleEffect.BLOCK_CRACK.display(particleData, 1F, 1F, 1F, 0.1F, 10, collision.getLocationFirst(), 50); ParticleEffect.BLOCK_CRACK.display(particleData, 1F, 1F, 1F, 0.1F, 10, collision.getLocationFirst(), 50);
} }
} }
public static boolean isEarthbendable(Material material) { public static boolean isEarthbendable(Material material) {
return isEarth(material) || isMetal(material) || isSand(material) || isLava(material); return isEarth(material) || isMetal(material) || isSand(material) || isLava(material);
} }
@ -100,7 +100,7 @@ public abstract class EarthAbility extends ElementalAbility {
public boolean isEarthbendable(Block block) { public boolean isEarthbendable(Block block) {
return isEarthbendable(player, getName(), block); return isEarthbendable(player, getName(), block);
} }
public static boolean isEarthbendable(Player player, Block block) { public static boolean isEarthbendable(Player player, Block block) {
return isEarthbendable(player, null, block); return isEarthbendable(player, null, block);
} }
@ -116,7 +116,7 @@ public abstract class EarthAbility extends ElementalAbility {
public boolean isMetalbendable(Material material) { public boolean isMetalbendable(Material material) {
return isMetalbendable(player, material); return isMetalbendable(player, material);
} }
public boolean isSandbendable(Block block) { public boolean isSandbendable(Block block) {
return isSandbendable(block.getType()); return isSandbendable(block.getType());
} }
@ -128,7 +128,7 @@ public abstract class EarthAbility extends ElementalAbility {
public void moveEarth(Block block, Vector direction, int chainlength) { public void moveEarth(Block block, Vector direction, int chainlength) {
moveEarth(block, direction, chainlength, true); moveEarth(block, direction, chainlength, true);
} }
public boolean moveEarth(Block block, Vector direction, int chainlength, boolean throwplayer) { public boolean moveEarth(Block block, Vector direction, int chainlength, boolean throwplayer) {
if (isEarthbendable(block) && !GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation())) { if (isEarthbendable(block) && !GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation())) {
boolean up = false; boolean up = false;
@ -167,15 +167,13 @@ public abstract class EarthAbility extends ElementalAbility {
for (Entity entity : GeneralMethods.getEntitiesAroundPoint(affectedblock.getLocation(), 1.75)) { for (Entity entity : GeneralMethods.getEntitiesAroundPoint(affectedblock.getLocation(), 1.75)) {
if (entity instanceof LivingEntity) { if (entity instanceof LivingEntity) {
LivingEntity lentity = (LivingEntity) entity; LivingEntity lentity = (LivingEntity) entity;
if (lentity.getEyeLocation().getBlockX() == affectedblock.getX() if (lentity.getEyeLocation().getBlockX() == affectedblock.getX() && lentity.getEyeLocation().getBlockZ() == affectedblock.getZ()) {
&& lentity.getEyeLocation().getBlockZ() == affectedblock.getZ()) {
if (!(entity instanceof FallingBlock)) { if (!(entity instanceof FallingBlock)) {
entity.setVelocity(norm.clone().multiply(.75)); entity.setVelocity(norm.clone().multiply(.75));
} }
} }
} else { } else {
if (entity.getLocation().getBlockX() == affectedblock.getX() if (entity.getLocation().getBlockX() == affectedblock.getX() && entity.getLocation().getBlockZ() == affectedblock.getZ()) {
&& entity.getLocation().getBlockZ() == affectedblock.getZ()) {
if (!(entity instanceof FallingBlock)) { if (!(entity instanceof FallingBlock)) {
entity.setVelocity(norm.clone().multiply(.75)); entity.setVelocity(norm.clone().multiply(.75));
} }
@ -201,8 +199,7 @@ public abstract class EarthAbility extends ElementalAbility {
affectedblock = location.clone().add(negnorm.getX() * i, negnorm.getY() * i, negnorm.getZ() * i).getBlock(); affectedblock = location.clone().add(negnorm.getX() * i, negnorm.getY() * i, negnorm.getZ() * i).getBlock();
if (!isEarthbendable(affectedblock)) { if (!isEarthbendable(affectedblock)) {
if (down) { if (down) {
if (isTransparent(affectedblock) && !affectedblock.isLiquid() if (isTransparent(affectedblock) && !affectedblock.isLiquid() && affectedblock.getType() != Material.AIR) {
&& affectedblock.getType() != Material.AIR) {
moveEarthBlock(affectedblock, block); moveEarthBlock(affectedblock, block);
} }
} }
@ -251,7 +248,7 @@ public abstract class EarthAbility extends ElementalAbility {
public void moveEarth(Location location, Vector direction, int chainlength, boolean throwplayer) { public void moveEarth(Location location, Vector direction, int chainlength, boolean throwplayer) {
moveEarth(location.getBlock(), direction, chainlength, throwplayer); moveEarth(location.getBlock(), direction, chainlength, throwplayer);
} }
/** /**
* Creates a temporary air block. * Creates a temporary air block.
* *
@ -260,14 +257,14 @@ public abstract class EarthAbility extends ElementalAbility {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static void addTempAirBlock(Block block) { public static void addTempAirBlock(Block block) {
Information info; Information info;
if (MOVED_EARTH.containsKey(block)) { if (MOVED_EARTH.containsKey(block)) {
info = MOVED_EARTH.get(block); info = MOVED_EARTH.get(block);
MOVED_EARTH.remove(block); MOVED_EARTH.remove(block);
} else { } else {
info = new Information(); info = new Information();
info.setBlock(block); info.setBlock(block);
info.setState(block.getState()); info.setState(block.getState());
info.setData(block.getData()); info.setData(block.getData());
@ -292,11 +289,11 @@ public abstract class EarthAbility extends ElementalAbility {
} }
} }
/** /**
* Finds a valid Earth source for a Player. To use dynamic source selection, use * Finds a valid Earth source for a Player. To use dynamic source selection,
* BlockSource.getEarthSourceBlock() instead of this method. Dynamic source selection saves the * use BlockSource.getEarthSourceBlock() instead of this method. Dynamic
* user's previous source for future use. * source selection saves the user's previous source for future use.
* {@link BlockSource#getEarthSourceBlock(Player, double, com.projectkorra.projectkorra.util.ClickType)} * {@link BlockSource#getEarthSourceBlock(Player, double, com.projectkorra.projectkorra.util.ClickType)}
* *
* @param range the maximum block selection range. * @param range the maximum block selection range.
@ -327,15 +324,15 @@ public abstract class EarthAbility extends ElementalAbility {
} }
return null; return null;
} }
public static Block getLavaSourceBlock(Player player, double range) { public static Block getLavaSourceBlock(Player player, double range) {
return getLavaSourceBlock(player, null, range); return getLavaSourceBlock(player, null, range);
} }
/** /**
* Finds a valid Lava source for a Player. To use dynamic source selection, use * Finds a valid Lava source for a Player. To use dynamic source selection,
* BlockSource.getLavaSourceBlock() instead of this method. Dynamic source selection saves the * use BlockSource.getLavaSourceBlock() instead of this method. Dynamic
* user's previous source for future use. * source selection saves the user's previous source for future use.
* {@link BlockSource#getLavaSourceBlock(Player, double, com.projectkorra.projectkorra.util.ClickType)} * {@link BlockSource#getLavaSourceBlock(Player, double, com.projectkorra.projectkorra.util.ClickType)}
* *
* @param range the maximum block selection range. * @param range the maximum block selection range.
@ -364,22 +361,22 @@ public abstract class EarthAbility extends ElementalAbility {
} }
return null; return null;
} }
public static double getMetalAugment(double value) { public static double getMetalAugment(double value) {
return value * getConfig().getDouble("Properties.Earth.MetalPowerFactor"); return value * getConfig().getDouble("Properties.Earth.MetalPowerFactor");
} }
public static Map<Block, Information> getMovedEarth() { public static Map<Block, Information> getMovedEarth() {
return MOVED_EARTH; return MOVED_EARTH;
} }
/** /**
* Attempts to find the closest earth block near a given location. * Attempts to find the closest earth block near a given location.
* *
* @param loc the initial location to search from. * @param loc the initial location to search from.
* @param radius the maximum radius to search for the earth block. * @param radius the maximum radius to search for the earth block.
* @param maxVertical the maximum block height difference between the starting location and the * @param maxVertical the maximum block height difference between the
* earth bendable block. * starting location and the earth bendable block.
* @return an earth bendable block, or null. * @return an earth bendable block, or null.
*/ */
public static Block getNearbyEarthBlock(Location loc, double radius, int maxVertical) { public static Block getNearbyEarthBlock(Location loc, double radius, int maxVertical) {
@ -402,11 +399,11 @@ public abstract class EarthAbility extends ElementalAbility {
} }
return null; return null;
} }
public static HashSet<Block> getPreventEarthbendingBlocks() { public static HashSet<Block> getPreventEarthbendingBlocks() {
return PREVENT_EARTHBENDING; return PREVENT_EARTHBENDING;
} }
public static ArrayList<Block> getPreventPhysicsBlocks() { public static ArrayList<Block> getPreventPhysicsBlocks() {
return PREVENT_PHYSICS; return PREVENT_PHYSICS;
} }
@ -419,21 +416,20 @@ public abstract class EarthAbility extends ElementalAbility {
public static Block getTargetEarthBlock(Player player, int range) { public static Block getTargetEarthBlock(Player player, int range) {
return player.getTargetBlock(getTransparentMaterialSet(), range); return player.getTargetBlock(getTransparentMaterialSet(), range);
} }
public static Map<Integer, Information> getTempAirLocations() { public static Map<Integer, Information> getTempAirLocations() {
return TEMP_AIR_LOCATIONS; return TEMP_AIR_LOCATIONS;
} }
public static boolean isEarthbendable(Player player, String abilityName, Block block) { public static boolean isEarthbendable(Player player, String abilityName, Block block) {
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (bPlayer == null || !isEarthbendable(block.getType()) || PREVENT_EARTHBENDING.contains(block) if (bPlayer == null || !isEarthbendable(block.getType()) || PREVENT_EARTHBENDING.contains(block) || GeneralMethods.isRegionProtectedFromBuild(player, abilityName, block.getLocation())) {
|| GeneralMethods.isRegionProtectedFromBuild(player, abilityName, block.getLocation())) {
return false; return false;
} else if (isMetal(block) && !bPlayer.canMetalbend()) { } else if (isMetal(block) && !bPlayer.canMetalbend()) {
return false; return false;
} else if (isSand(block) && !bPlayer.canSandbend()) { } else if (isSand(block) && !bPlayer.canSandbend()) {
return false; return false;
} else if (isLava(block) && !bPlayer.canLavabend()) { } else if (isLava(block) && !bPlayer.canLavabend()) {
return false; return false;
} }
return true; return true;
@ -442,7 +438,7 @@ public abstract class EarthAbility extends ElementalAbility {
public static boolean isEarthRevertOn() { public static boolean isEarthRevertOn() {
return getConfig().getBoolean("Properties.Earth.RevertEarthbending"); return getConfig().getBoolean("Properties.Earth.RevertEarthbending");
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static boolean isLavabendable(Player player, Block block) { public static boolean isLavabendable(Player player, Block block) {
byte full = 0x0; byte full = 0x0;
@ -462,7 +458,7 @@ public abstract class EarthAbility extends ElementalAbility {
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
return bPlayer == null ? null : isMetal(material) && bPlayer.canMetalbend(); return bPlayer == null ? null : isMetal(material) && bPlayer.canMetalbend();
} }
public static boolean isSandbendable(Player player, Material material) { public static boolean isSandbendable(Player player, Material material) {
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
return bPlayer == null ? null : isSand(material) && bPlayer.canSandbend(); return bPlayer == null ? null : isSand(material) && bPlayer.canSandbend();
@ -485,7 +481,7 @@ public abstract class EarthAbility extends ElementalAbility {
MOVED_EARTH.put(target, info); MOVED_EARTH.put(target, info);
source.setType(Material.AIR); source.setType(Material.AIR);
if (info.getState().getType() == Material.SAND) { if (info.getState().getType() == Material.SAND) {
if (info.getState().getRawData() == (byte) 0x1) { if (info.getState().getRawData() == (byte) 0x1) {
target.setType(Material.RED_SANDSTONE); target.setType(Material.RED_SANDSTONE);
@ -505,7 +501,7 @@ public abstract class EarthAbility extends ElementalAbility {
loc.getWorld().playEffect(loc, Effect.GHAST_SHOOT, 0, 10); loc.getWorld().playEffect(loc, Effect.GHAST_SHOOT, 0, 10);
} }
} }
public static void playMetalbendingSound(Location loc) { public static void playMetalbendingSound(Location loc) {
if (getConfig().getBoolean("Properties.Earth.PlaySound")) { if (getConfig().getBoolean("Properties.Earth.PlaySound")) {
loc.getWorld().playSound(loc, Sound.ENTITY_IRONGOLEM_HURT, 1, 10); loc.getWorld().playSound(loc, Sound.ENTITY_IRONGOLEM_HURT, 1, 10);
@ -540,11 +536,11 @@ public abstract class EarthAbility extends ElementalAbility {
MOVED_EARTH.remove(block); MOVED_EARTH.remove(block);
} }
} }
public static void revertAirBlock(int i) { public static void revertAirBlock(int i) {
revertAirBlock(i, false); revertAirBlock(i, false);
} }
public static void revertAirBlock(int i, boolean force) { public static void revertAirBlock(int i, boolean force) {
if (!TEMP_AIR_LOCATIONS.containsKey(i)) { if (!TEMP_AIR_LOCATIONS.containsKey(i)) {
return; return;
@ -565,7 +561,7 @@ public abstract class EarthAbility extends ElementalAbility {
TEMP_AIR_LOCATIONS.remove(i); TEMP_AIR_LOCATIONS.remove(i);
} }
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static boolean revertBlock(Block block) { public static boolean revertBlock(Block block) {
byte full = 0x0; byte full = 0x0;
@ -623,11 +619,11 @@ public abstract class EarthAbility extends ElementalAbility {
MOVED_EARTH.remove(block); MOVED_EARTH.remove(block);
} }
return true; return true;
} }
public static void stopBending() { public static void stopBending() {
EarthPassive.removeAll(); EarthPassive.removeAll();
if (isEarthRevertOn()) { if (isEarthRevertOn()) {
removeAllEarthbendedBlocks(); removeAllEarthbendedBlocks();
} }
@ -636,6 +632,7 @@ public abstract class EarthAbility extends ElementalAbility {
public static void removeSandSpouts(Location loc, double radius, Player source) { public static void removeSandSpouts(Location loc, double radius, Player source) {
SandSpout.removeSpouts(loc, radius, source); SandSpout.removeSpouts(loc, radius, source);
} }
public static void removeSandSpouts(Location loc, Player source) { public static void removeSandSpouts(Location loc, Player source) {
removeSandSpouts(loc, 1.5, source); removeSandSpouts(loc, 1.5, source);
} }

View file

@ -17,32 +17,29 @@ import com.projectkorra.rpg.event.EventManager;
/** /**
* ElementalAbility is used to hold methods that should be accessible by every * ElementalAbility is used to hold methods that should be accessible by every
* Air, Water, Earth, Fire, Chi, or AvatarAbility. This class is mainly used to keep * Air, Water, Earth, Fire, Chi, or AvatarAbility. This class is mainly used to
* CoreAbility from becoming too cluttered. * keep CoreAbility from becoming too cluttered.
*/ */
public abstract class ElementalAbility extends CoreAbility { public abstract class ElementalAbility extends CoreAbility {
private static final Integer[] TRANSPARENT_MATERIAL = { 0, 6, 8, 9, 10, 11, 30, 31, 32, 37, 38, 39, 40, 50, 51, 59, 78, 83, 106, 175 }; private static final Integer[] TRANSPARENT_MATERIAL = { 0, 6, 8, 9, 10, 11, 30, 31, 32, 37, 38, 39, 40, 50, 51, 59, 78, 83, 106, 175 };
//private static final Integer[] PLANT_IDS = { 6, 18, 31, 37, 38, 39, 40, 59, 81, 83, 86, 99, 100, 103, 104, 105, 106, 111, 161, 175 }; //private static final Integer[] PLANT_IDS = { 6, 18, 31, 37, 38, 39, 40, 59, 81, 83, 86, 99, 100, 103, 104, 105, 106, 111, 161, 175 };
private static final PotionEffectType[] POSITIVE_EFFECTS = {PotionEffectType.ABSORPTION, PotionEffectType.DAMAGE_RESISTANCE, PotionEffectType.FAST_DIGGING, private static final PotionEffectType[] POSITIVE_EFFECTS = { PotionEffectType.ABSORPTION, PotionEffectType.DAMAGE_RESISTANCE, PotionEffectType.FAST_DIGGING, PotionEffectType.FIRE_RESISTANCE, PotionEffectType.HEAL, PotionEffectType.HEALTH_BOOST, PotionEffectType.INCREASE_DAMAGE, PotionEffectType.JUMP, PotionEffectType.NIGHT_VISION, PotionEffectType.REGENERATION, PotionEffectType.SATURATION, PotionEffectType.SPEED, PotionEffectType.WATER_BREATHING };
PotionEffectType.FIRE_RESISTANCE, PotionEffectType.HEAL, PotionEffectType.HEALTH_BOOST, PotionEffectType.INCREASE_DAMAGE, PotionEffectType.JUMP, private static final PotionEffectType[] NEUTRAL_EFFECTS = { PotionEffectType.INVISIBILITY };
PotionEffectType.NIGHT_VISION, PotionEffectType.REGENERATION, PotionEffectType.SATURATION, PotionEffectType.SPEED, PotionEffectType.WATER_BREATHING}; private static final PotionEffectType[] NEGATIVE_EFFECTS = { PotionEffectType.POISON, PotionEffectType.BLINDNESS, PotionEffectType.CONFUSION, PotionEffectType.HARM, PotionEffectType.HUNGER, PotionEffectType.SLOW, PotionEffectType.SLOW_DIGGING, PotionEffectType.WEAKNESS, PotionEffectType.WITHER };
private static final PotionEffectType[] NEUTRAL_EFFECTS = {PotionEffectType.INVISIBILITY};
private static final PotionEffectType[] NEGATIVE_EFFECTS = {PotionEffectType.POISON, PotionEffectType.BLINDNESS, PotionEffectType.CONFUSION,
PotionEffectType.HARM, PotionEffectType.HUNGER, PotionEffectType.SLOW, PotionEffectType.SLOW_DIGGING, PotionEffectType.WEAKNESS, PotionEffectType.WITHER};
public ElementalAbility(Player player) { public ElementalAbility(Player player) {
super(player); super(player);
} }
public boolean isTransparent(Block block) { public boolean isTransparent(Block block) {
return isTransparent(player, getName(), block); return isTransparent(player, getName(), block);
} }
public static Integer[] getTransparentMaterial() { public static Integer[] getTransparentMaterial() {
return TRANSPARENT_MATERIAL; return TRANSPARENT_MATERIAL;
} }
public static HashSet<Byte> getTransparentMaterialSet() { public static HashSet<Byte> getTransparentMaterialSet() {
HashSet<Byte> set = new HashSet<Byte>(); HashSet<Byte> set = new HashSet<Byte>();
for (int i : TRANSPARENT_MATERIAL) { for (int i : TRANSPARENT_MATERIAL) {
@ -50,7 +47,7 @@ public abstract class ElementalAbility extends CoreAbility {
} }
return set; return set;
} }
public static boolean isDay(World world) { public static boolean isDay(World world) {
long time = world.getTime(); long time = world.getTime();
if (world.getEnvironment() == Environment.NETHER || world.getEnvironment() == Environment.THE_END) { if (world.getEnvironment() == Environment.NETHER || world.getEnvironment() == Environment.THE_END) {
@ -61,15 +58,15 @@ public abstract class ElementalAbility extends CoreAbility {
} }
return false; return false;
} }
public static boolean isEarth(Block block) { public static boolean isEarth(Block block) {
return block != null ? isEarth(block.getType()) : false; return block != null ? isEarth(block.getType()) : false;
} }
public static boolean isEarth(Material material) { public static boolean isEarth(Material material) {
return getConfig().getStringList("Properties.Earth.EarthBlocks").contains(material.toString()); return getConfig().getStringList("Properties.Earth.EarthBlocks").contains(material.toString());
} }
public static boolean isFullMoon(World world) { public static boolean isFullMoon(World world) {
if (GeneralMethods.hasRPG()) { if (GeneralMethods.hasRPG()) {
return EventManager.marker.get(world).equalsIgnoreCase("FullMoon"); return EventManager.marker.get(world).equalsIgnoreCase("FullMoon");
@ -94,57 +91,55 @@ public abstract class ElementalAbility extends CoreAbility {
public static boolean isLava(Block block) { public static boolean isLava(Block block) {
return block != null ? isLava(block.getType()) : false; return block != null ? isLava(block.getType()) : false;
} }
public static boolean isLava(Material material) { public static boolean isLava(Material material) {
return material == Material.LAVA || material == Material.STATIONARY_LAVA; return material == Material.LAVA || material == Material.STATIONARY_LAVA;
} }
public static boolean isSnow(Block block) { public static boolean isSnow(Block block) {
return block != null ? isSnow(block.getType()) : false; return block != null ? isSnow(block.getType()) : false;
} }
public static boolean isSnow(Material material) { public static boolean isSnow(Material material) {
return getConfig().getStringList("Properties.Water.SnowBlocks").contains(material.toString()); return getConfig().getStringList("Properties.Water.SnowBlocks").contains(material.toString());
} }
public static boolean isLunarEclipse(World world) { public static boolean isLunarEclipse(World world) {
if (world == null || !GeneralMethods.hasRPG()) { if (world == null || !GeneralMethods.hasRPG()) {
return false; return false;
} }
return EventManager.marker.get(world).equalsIgnoreCase("LunarEclipse"); return EventManager.marker.get(world).equalsIgnoreCase("LunarEclipse");
} }
public static boolean isSolarEclipse(World world) { public static boolean isSolarEclipse(World world) {
if (world == null || !GeneralMethods.hasRPG() || !EventManager.marker.containsKey(world)) { if (world == null || !GeneralMethods.hasRPG() || !EventManager.marker.containsKey(world)) {
return false; return false;
} }
return EventManager.marker.get(world).equalsIgnoreCase("SolarEclipse"); return EventManager.marker.get(world).equalsIgnoreCase("SolarEclipse");
} }
public static boolean isMeltable(Block block) { public static boolean isMeltable(Block block) {
if (block.getType() == Material.ICE || block.getType() == Material.SNOW) { if (block.getType() == Material.ICE || block.getType() == Material.SNOW) {
return true; return true;
} }
return false; return false;
} }
public static boolean isMetal(Block block) { public static boolean isMetal(Block block) {
return block != null ? isMetal(block.getType()) : false; return block != null ? isMetal(block.getType()) : false;
} }
public static boolean isMetal(Material material) { public static boolean isMetal(Material material) {
return getConfig().getStringList("Properties.Earth.MetalBlocks").contains(material.toString()); return getConfig().getStringList("Properties.Earth.MetalBlocks").contains(material.toString());
} }
public static boolean isMetalBlock(Block block) { public static boolean isMetalBlock(Block block) {
if (block.getType() == Material.GOLD_BLOCK || block.getType() == Material.IRON_BLOCK if (block.getType() == Material.GOLD_BLOCK || block.getType() == Material.IRON_BLOCK || block.getType() == Material.IRON_ORE || block.getType() == Material.GOLD_ORE || block.getType() == Material.QUARTZ_BLOCK || block.getType() == Material.QUARTZ_ORE) {
|| block.getType() == Material.IRON_ORE || block.getType() == Material.GOLD_ORE
|| block.getType() == Material.QUARTZ_BLOCK || block.getType() == Material.QUARTZ_ORE) {
return true; return true;
} }
return false; return false;
} }
public static boolean isNegativeEffect(PotionEffectType effect) { public static boolean isNegativeEffect(PotionEffectType effect) {
for (PotionEffectType effect2 : NEGATIVE_EFFECTS) { for (PotionEffectType effect2 : NEGATIVE_EFFECTS) {
if (effect2.equals(effect)) { if (effect2.equals(effect)) {
@ -153,7 +148,7 @@ public abstract class ElementalAbility extends CoreAbility {
} }
return false; return false;
} }
public static boolean isNeutralEffect(PotionEffectType effect) { public static boolean isNeutralEffect(PotionEffectType effect) {
for (PotionEffectType effect2 : NEUTRAL_EFFECTS) { for (PotionEffectType effect2 : NEUTRAL_EFFECTS) {
if (effect2.equals(effect)) { if (effect2.equals(effect)) {
@ -162,7 +157,7 @@ public abstract class ElementalAbility extends CoreAbility {
} }
return false; return false;
} }
public static boolean isNight(World world) { public static boolean isNight(World world) {
if (world.getEnvironment() == Environment.NETHER || world.getEnvironment() == Environment.THE_END) { if (world.getEnvironment() == Environment.NETHER || world.getEnvironment() == Environment.THE_END) {
return false; return false;
@ -174,11 +169,11 @@ public abstract class ElementalAbility extends CoreAbility {
} }
return false; return false;
} }
public static boolean isPlant(Block block) { public static boolean isPlant(Block block) {
return block != null ? isPlant(block.getType()) : false; return block != null ? isPlant(block.getType()) : false;
} }
public static boolean isPlant(Material material) { public static boolean isPlant(Material material) {
return getConfig().getStringList("Properties.Water.PlantBlocks").contains(material.toString()); return getConfig().getStringList("Properties.Water.PlantBlocks").contains(material.toString());
} }
@ -193,9 +188,9 @@ public abstract class ElementalAbility extends CoreAbility {
} }
public static boolean isSand(Block block) { public static boolean isSand(Block block) {
return block != null ? isSand(block.getType()) : false; return block != null ? isSand(block.getType()) : false;
} }
public static boolean isSand(Material material) { public static boolean isSand(Material material) {
return getConfig().getStringList("Properties.Earth.SandBlocks").contains(material.toString()); return getConfig().getStringList("Properties.Earth.SandBlocks").contains(material.toString());
} }
@ -213,18 +208,13 @@ public abstract class ElementalAbility extends CoreAbility {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static boolean isTransparent(Player player, String abilityName, Block block) { public static boolean isTransparent(Player player, String abilityName, Block block) {
return Arrays.asList(TRANSPARENT_MATERIAL).contains(block.getTypeId()) return Arrays.asList(TRANSPARENT_MATERIAL).contains(block.getTypeId()) && !GeneralMethods.isRegionProtectedFromBuild(player, abilityName, block.getLocation());
&& !GeneralMethods.isRegionProtectedFromBuild(player, abilityName, block.getLocation());
} }
public static boolean isUndead(Entity entity) { public static boolean isUndead(Entity entity) {
if (entity == null) { if (entity == null) {
return false; return false;
} else if (entity.getType() == EntityType.ZOMBIE || entity.getType() == EntityType.BLAZE } else if (entity.getType() == EntityType.ZOMBIE || entity.getType() == EntityType.BLAZE || entity.getType() == EntityType.GIANT || entity.getType() == EntityType.IRON_GOLEM || entity.getType() == EntityType.MAGMA_CUBE || entity.getType() == EntityType.PIG_ZOMBIE || entity.getType() == EntityType.SKELETON || entity.getType() == EntityType.SLIME || entity.getType() == EntityType.SNOWMAN || entity.getType() == EntityType.ZOMBIE) {
|| entity.getType() == EntityType.GIANT || entity.getType() == EntityType.IRON_GOLEM
|| entity.getType() == EntityType.MAGMA_CUBE || entity.getType() == EntityType.PIG_ZOMBIE
|| entity.getType() == EntityType.SKELETON || entity.getType() == EntityType.SLIME
|| entity.getType() == EntityType.SNOWMAN || entity.getType() == EntityType.ZOMBIE) {
return true; return true;
} }
return false; return false;
@ -233,9 +223,9 @@ public abstract class ElementalAbility extends CoreAbility {
public static boolean isWater(Block block) { public static boolean isWater(Block block) {
return block != null ? isWater(block.getType()) : null; return block != null ? isWater(block.getType()) : null;
} }
public static boolean isWater(Material material) { public static boolean isWater(Material material) {
return material == Material.WATER || material == Material.STATIONARY_WATER; return material == Material.WATER || material == Material.STATIONARY_WATER;
} }
} }

View file

@ -28,30 +28,19 @@ import com.projectkorra.projectkorra.util.ParticleEffect.ParticleData;
import com.projectkorra.rpg.RPGMethods; import com.projectkorra.rpg.RPGMethods;
public abstract class FireAbility extends ElementalAbility { public abstract class FireAbility extends ElementalAbility {
private static final Map<Location, Information> TEMP_FIRE = new ConcurrentHashMap<Location, Information>(); private static final Map<Location, Information> TEMP_FIRE = new ConcurrentHashMap<Location, Information>();
private static final Material[] IGNITABLE_MATERIALS = { Material.BEDROCK, Material.BOOKSHELF, Material.BRICK, Material.CLAY, Material.CLAY_BRICK, private static final Material[] IGNITABLE_MATERIALS = { Material.BEDROCK, Material.BOOKSHELF, Material.BRICK, Material.CLAY, Material.CLAY_BRICK, Material.COAL_ORE, Material.COBBLESTONE, Material.DIAMOND_ORE, Material.DIAMOND_BLOCK, Material.DIRT, Material.ENDER_STONE, Material.GLOWING_REDSTONE_ORE, Material.GOLD_BLOCK, Material.GRAVEL, Material.GRASS, Material.HUGE_MUSHROOM_1, Material.HUGE_MUSHROOM_2, Material.LAPIS_BLOCK, Material.LAPIS_ORE, Material.LOG, Material.MOSSY_COBBLESTONE, Material.MYCEL, Material.NETHER_BRICK, Material.NETHERRACK, Material.OBSIDIAN, Material.REDSTONE_ORE, Material.SAND, Material.SANDSTONE, Material.SMOOTH_BRICK, Material.STONE, Material.SOUL_SAND, Material.WOOD, Material.WOOL, Material.LEAVES, Material.LEAVES_2, Material.MELON_BLOCK, Material.PUMPKIN, Material.JACK_O_LANTERN, Material.NOTE_BLOCK, Material.GLOWSTONE, Material.IRON_BLOCK, Material.DISPENSER, Material.SPONGE, Material.IRON_ORE, Material.GOLD_ORE, Material.COAL_BLOCK, Material.WORKBENCH, Material.HAY_BLOCK, Material.REDSTONE_LAMP_OFF, Material.REDSTONE_LAMP_ON, Material.EMERALD_ORE, Material.EMERALD_BLOCK, Material.REDSTONE_BLOCK, Material.QUARTZ_BLOCK, Material.QUARTZ_ORE, Material.STAINED_CLAY, Material.HARD_CLAY };
Material.COAL_ORE, Material.COBBLESTONE, Material.DIAMOND_ORE, Material.DIAMOND_BLOCK, Material.DIRT,
Material.ENDER_STONE, Material.GLOWING_REDSTONE_ORE, Material.GOLD_BLOCK, Material.GRAVEL, Material.GRASS,
Material.HUGE_MUSHROOM_1, Material.HUGE_MUSHROOM_2, Material.LAPIS_BLOCK, Material.LAPIS_ORE, Material.LOG,
Material.MOSSY_COBBLESTONE, Material.MYCEL, Material.NETHER_BRICK, Material.NETHERRACK, Material.OBSIDIAN,
Material.REDSTONE_ORE, Material.SAND, Material.SANDSTONE, Material.SMOOTH_BRICK, Material.STONE, Material.SOUL_SAND,
Material.WOOD, Material.WOOL, Material.LEAVES, Material.LEAVES_2, Material.MELON_BLOCK, Material.PUMPKIN,
Material.JACK_O_LANTERN, Material.NOTE_BLOCK, Material.GLOWSTONE, Material.IRON_BLOCK, Material.DISPENSER,
Material.SPONGE, Material.IRON_ORE, Material.GOLD_ORE, Material.COAL_BLOCK, Material.WORKBENCH,
Material.HAY_BLOCK, Material.REDSTONE_LAMP_OFF, Material.REDSTONE_LAMP_ON, Material.EMERALD_ORE,
Material.EMERALD_BLOCK, Material.REDSTONE_BLOCK, Material.QUARTZ_BLOCK, Material.QUARTZ_ORE,
Material.STAINED_CLAY, Material.HARD_CLAY };
public FireAbility(Player player) { public FireAbility(Player player) {
super(player); super(player);
} }
@Override @Override
public boolean isIgniteAbility() { public boolean isIgniteAbility() {
return true; return true;
} }
@Override @Override
public boolean isExplosiveAbility() { public boolean isExplosiveAbility() {
return true; return true;
@ -61,7 +50,7 @@ public abstract class FireAbility extends ElementalAbility {
public Element getElement() { public Element getElement() {
return Element.FIRE; return Element.FIRE;
} }
@Override @Override
public void handleCollision(Collision collision) { public void handleCollision(Collision collision) {
super.handleCollision(collision); super.handleCollision(collision);
@ -70,22 +59,22 @@ public abstract class FireAbility extends ElementalAbility {
ParticleEffect.BLOCK_CRACK.display(particleData, 1F, 1F, 1F, 0.1F, 10, collision.getLocationFirst(), 50); ParticleEffect.BLOCK_CRACK.display(particleData, 1F, 1F, 1F, 0.1F, 10, collision.getLocationFirst(), 50);
} }
} }
public double getDayFactor(double value) { public double getDayFactor(double value) {
return player != null ? getDayFactor(value, player.getWorld()) : 1; return player != null ? getDayFactor(value, player.getWorld()) : 1;
} }
/** /**
* Returns if fire is allowed to completely replace blocks or if it should place a temp fire * Returns if fire is allowed to completely replace blocks or if it should
* block. * place a temp fire block.
*/ */
public static boolean canFireGrief() { public static boolean canFireGrief() {
return getConfig().getBoolean("Properties.Fire.FireGriefing"); return getConfig().getBoolean("Properties.Fire.FireGriefing");
} }
/** /**
* Creates a fire block meant to replace other blocks but reverts when the fire dissipates or is * Creates a fire block meant to replace other blocks but reverts when the
* destroyed. * fire dissipates or is destroyed.
*/ */
public static void createTempFire(Location loc) { public static void createTempFire(Location loc) {
if (loc.getBlock().getType() == Material.AIR) { if (loc.getBlock().getType() == Material.AIR) {
@ -93,8 +82,7 @@ public abstract class FireAbility extends ElementalAbility {
return; return;
} }
Information info = new Information(); Information info = new Information();
long time = getConfig().getLong("Properties.Fire.RevertTicks") long time = getConfig().getLong("Properties.Fire.RevertTicks") + (long) ((new Random()).nextDouble() * getConfig().getLong("Properties.Fire.RevertTicks"));
+ (long) ((new Random()).nextDouble() * getConfig().getLong("Properties.Fire.RevertTicks"));
if (TEMP_FIRE.containsKey(loc)) { if (TEMP_FIRE.containsKey(loc)) {
info = TEMP_FIRE.get(loc); info = TEMP_FIRE.get(loc);
} else { } else {
@ -110,13 +98,15 @@ public abstract class FireAbility extends ElementalAbility {
public static double getDayFactor() { public static double getDayFactor() {
return getConfig().getDouble("Properties.Fire.DayFactor"); return getConfig().getDouble("Properties.Fire.DayFactor");
} }
/** /**
* Gets the firebending dayfactor from the config multiplied by a specific value if it is day. * Gets the firebending dayfactor from the config multiplied by a specific
* value if it is day.
* *
* @param value The value * @param value The value
* @param world The world to pass into {@link #isDay(World)} * @param world The world to pass into {@link #isDay(World)}
* @return value DayFactor multiplied by specified value when {@link #isDay(World)} is true <br /> * @return value DayFactor multiplied by specified value when
* {@link #isDay(World)} is true <br />
* else <br /> * else <br />
* value The specified value in the parameters * value The specified value in the parameters
*/ */
@ -136,7 +126,7 @@ public abstract class FireAbility extends ElementalAbility {
} }
return value; return value;
} }
public static ChatColor getSubChatColor() { public static ChatColor getSubChatColor() {
return ChatColor.valueOf(ConfigManager.getConfig().getString("Properties.Chat.Colors.FireSub")); return ChatColor.valueOf(ConfigManager.getConfig().getString("Properties.Chat.Colors.FireSub"));
} }
@ -144,11 +134,11 @@ public abstract class FireAbility extends ElementalAbility {
public static boolean isIgnitable(Block block) { public static boolean isIgnitable(Block block) {
return block != null ? isIgnitable(block.getType()) : false; return block != null ? isIgnitable(block.getType()) : false;
} }
public static boolean isIgnitable(Material material) { public static boolean isIgnitable(Material material) {
return Arrays.asList(IGNITABLE_MATERIALS).contains(material); return Arrays.asList(IGNITABLE_MATERIALS).contains(material);
} }
/** /**
* This method was used for the old collision detection system. Please see * This method was used for the old collision detection system. Please see
* {@link Collision} for the new system. * {@link Collision} for the new system.
@ -198,8 +188,7 @@ public abstract class FireAbility extends ElementalAbility {
while (it.hasNext()) { while (it.hasNext()) {
Location loc = it.next(); Location loc = it.next();
Information info = TEMP_FIRE.get(loc); Information info = TEMP_FIRE.get(loc);
if (info.getLocation().getBlock().getType() != Material.FIRE if (info.getLocation().getBlock().getType() != Material.FIRE && info.getLocation().getBlock().getType() != Material.AIR) {
&& info.getLocation().getBlock().getType() != Material.AIR) {
revertTempFire(loc); revertTempFire(loc);
} else if (info.getBlock().getType() == Material.AIR || System.currentTimeMillis() > info.getTime()) { } else if (info.getBlock().getType() == Material.AIR || System.currentTimeMillis() > info.getTime()) {
revertTempFire(loc); revertTempFire(loc);
@ -211,7 +200,7 @@ public abstract class FireAbility extends ElementalAbility {
* Revert the temp fire at the location if any is there. * Revert the temp fire at the location if any is there.
* *
* @param location The Location * @param location The Location
* */ */
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public static void revertTempFire(Location location) { public static void revertTempFire(Location location) {
if (!TEMP_FIRE.containsKey(location)) { if (!TEMP_FIRE.containsKey(location)) {
@ -236,5 +225,5 @@ public abstract class FireAbility extends ElementalAbility {
revertTempFire(loc); revertTempFire(loc);
} }
} }
} }

View file

@ -14,10 +14,10 @@ public abstract class FlightAbility extends AirAbility implements SubAbility {
public Class<? extends Ability> getParentAbility() { public Class<? extends Ability> getParentAbility() {
return AirAbility.class; return AirAbility.class;
} }
@Override @Override
public Element getElement() { public Element getElement() {
return Element.FLIGHT; return Element.FLIGHT;
} }
} }

View file

@ -5,7 +5,7 @@ import com.projectkorra.projectkorra.Element;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public abstract class HealingAbility extends WaterAbility implements SubAbility { public abstract class HealingAbility extends WaterAbility implements SubAbility {
public HealingAbility(Player player) { public HealingAbility(Player player) {
super(player); super(player);
} }
@ -14,10 +14,10 @@ public abstract class HealingAbility extends WaterAbility implements SubAbility
public Class<? extends Ability> getParentAbility() { public Class<? extends Ability> getParentAbility() {
return WaterAbility.class; return WaterAbility.class;
} }
@Override @Override
public Element getElement() { public Element getElement() {
return Element.HEALING; return Element.HEALING;
} }
} }

View file

@ -14,10 +14,10 @@ public abstract class IceAbility extends WaterAbility implements SubAbility {
public Class<? extends Ability> getParentAbility() { public Class<? extends Ability> getParentAbility() {
return WaterAbility.class; return WaterAbility.class;
} }
@Override @Override
public Element getElement() { public Element getElement() {
return Element.ICE; return Element.ICE;
} }
} }

View file

@ -5,7 +5,7 @@ import com.projectkorra.projectkorra.Element;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public abstract class LavaAbility extends EarthAbility implements SubAbility { public abstract class LavaAbility extends EarthAbility implements SubAbility {
public LavaAbility(Player player) { public LavaAbility(Player player) {
super(player); super(player);
} }
@ -14,10 +14,10 @@ public abstract class LavaAbility extends EarthAbility implements SubAbility {
public Class<? extends Ability> getParentAbility() { public Class<? extends Ability> getParentAbility() {
return EarthAbility.class; return EarthAbility.class;
} }
@Override @Override
public Element getElement() { public Element getElement() {
return Element.LAVA; return Element.LAVA;
} }
} }

View file

@ -14,10 +14,10 @@ public abstract class LightningAbility extends FireAbility implements SubAbility
public Class<? extends Ability> getParentAbility() { public Class<? extends Ability> getParentAbility() {
return FireAbility.class; return FireAbility.class;
} }
@Override @Override
public Element getElement() { public Element getElement() {
return Element.LIGHTNING; return Element.LIGHTNING;
} }
} }

View file

@ -9,12 +9,12 @@ public abstract class MetalAbility extends EarthAbility implements SubAbility {
public MetalAbility(Player player) { public MetalAbility(Player player) {
super(player); super(player);
} }
@Override @Override
public Class<? extends Ability> getParentAbility() { public Class<? extends Ability> getParentAbility() {
return EarthAbility.class; return EarthAbility.class;
} }
@Override @Override
public Element getElement() { public Element getElement() {
return Element.METAL; return Element.METAL;

View file

@ -5,13 +5,15 @@ import com.projectkorra.projectkorra.ability.util.MultiAbilityManager.MultiAbili
import java.util.ArrayList; import java.util.ArrayList;
public interface MultiAbility { public interface MultiAbility {
/** /**
* Returns the sub abilities of a MultiAbility. For example: <p>{@code new * Returns the sub abilities of a MultiAbility. For example:
* <p>
* {@code new
* MultiAbilitySub("SubAbility", Element.LIGHTNING);} * MultiAbilitySub("SubAbility", Element.LIGHTNING);}
* *
* @return a list of sub MultiAbilities * @return a list of sub MultiAbilities
*/ */
public abstract ArrayList<MultiAbilityInfoSub> getMultiAbilities(); public abstract ArrayList<MultiAbilityInfoSub> getMultiAbilities();
} }

View file

@ -1,10 +1,11 @@
package com.projectkorra.projectkorra.ability; package com.projectkorra.projectkorra.ability;
public interface PassiveAbility { public interface PassiveAbility {
/** /**
* *
* @return false if the passive does not actually do anything, but so it still registers in /b d [element]passive * @return false if the passive does not actually do anything, but so it
* still registers in /b d [element]passive
*/ */
public boolean isInstantiable(); public boolean isInstantiable();

View file

@ -5,7 +5,7 @@ import com.projectkorra.projectkorra.Element;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public abstract class PlantAbility extends WaterAbility implements SubAbility { public abstract class PlantAbility extends WaterAbility implements SubAbility {
public PlantAbility(Player player) { public PlantAbility(Player player) {
super(player); super(player);
} }
@ -14,10 +14,10 @@ public abstract class PlantAbility extends WaterAbility implements SubAbility {
public Class<? extends Ability> getParentAbility() { public Class<? extends Ability> getParentAbility() {
return WaterAbility.class; return WaterAbility.class;
} }
@Override @Override
public Element getElement() { public Element getElement() {
return Element.PLANT; return Element.PLANT;
} }
} }

View file

@ -5,7 +5,7 @@ import com.projectkorra.projectkorra.Element;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
public abstract class SandAbility extends EarthAbility implements SubAbility { public abstract class SandAbility extends EarthAbility implements SubAbility {
public SandAbility(Player player) { public SandAbility(Player player) {
super(player); super(player);
} }
@ -14,10 +14,10 @@ public abstract class SandAbility extends EarthAbility implements SubAbility {
public Class<? extends Ability> getParentAbility() { public Class<? extends Ability> getParentAbility() {
return EarthAbility.class; return EarthAbility.class;
} }
@Override @Override
public Element getElement() { public Element getElement() {
return Element.SAND; return Element.SAND;
} }
} }

View file

@ -14,10 +14,10 @@ public abstract class SpiritualAbility extends AirAbility implements SubAbility
public Class<? extends Ability> getParentAbility() { public Class<? extends Ability> getParentAbility() {
return AirAbility.class; return AirAbility.class;
} }
@Override @Override
public Element getElement() { public Element getElement() {
return Element.SPIRITUAL; return Element.SPIRITUAL;
} }
} }

View file

@ -3,8 +3,8 @@ package com.projectkorra.projectkorra.ability;
public interface SubAbility { public interface SubAbility {
/** /**
* Specifies the Class of this Ability's parent. For example, a LightningAbility would return * Specifies the Class of this Ability's parent. For example, a
* FireAbility.class. * LightningAbility would return FireAbility.class.
* *
* @return the Class of the parent * @return the Class of the parent
*/ */

View file

@ -30,15 +30,15 @@ public abstract class WaterAbility extends ElementalAbility {
public WaterAbility(Player player) { public WaterAbility(Player player) {
super(player); super(player);
} }
public boolean canAutoSource() { public boolean canAutoSource() {
return getConfig().getBoolean("Abilities." + getElement() + "." + getName() + ".CanAutoSource"); return getConfig().getBoolean("Abilities." + getElement() + "." + getName() + ".CanAutoSource");
} }
public boolean canDynamicSource() { public boolean canDynamicSource() {
return getConfig().getBoolean("Abilities." + getElement() + "." + getName() + ".CanDynamicSource"); return getConfig().getBoolean("Abilities." + getElement() + "." + getName() + ".CanDynamicSource");
} }
@Override @Override
public Element getElement() { public Element getElement() {
return Element.WATER; return Element.WATER;
@ -47,14 +47,14 @@ public abstract class WaterAbility extends ElementalAbility {
public Block getIceSourceBlock(double range) { public Block getIceSourceBlock(double range) {
return getIceSourceBlock(player, range); return getIceSourceBlock(player, range);
} }
public double getNightFactor() { public double getNightFactor() {
if (getLocation() != null) { if (getLocation() != null) {
return getNightFactor(getLocation().getWorld()); return getNightFactor(getLocation().getWorld());
} }
return player != null ? getNightFactor(player.getLocation().getWorld()) : 1; return player != null ? getNightFactor(player.getLocation().getWorld()) : 1;
} }
public double getNightFactor(double value) { public double getNightFactor(double value) {
return player != null ? getNightFactor(value, player.getWorld()) : value; return player != null ? getNightFactor(value, player.getWorld()) : value;
} }
@ -62,21 +62,21 @@ public abstract class WaterAbility extends ElementalAbility {
public Block getPlantSourceBlock(double range) { public Block getPlantSourceBlock(double range) {
return getPlantSourceBlock(range, false); return getPlantSourceBlock(range, false);
} }
public Block getPlantSourceBlock(double range, boolean onlyLeaves) { public Block getPlantSourceBlock(double range, boolean onlyLeaves) {
return getPlantSourceBlock(player, range, onlyLeaves); return getPlantSourceBlock(player, range, onlyLeaves);
} }
@Override @Override
public boolean isExplosiveAbility() { public boolean isExplosiveAbility() {
return false; return false;
} }
@Override @Override
public boolean isIgniteAbility() { public boolean isIgniteAbility() {
return false; return false;
} }
@Override @Override
public void handleCollision(Collision collision) { public void handleCollision(Collision collision) {
super.handleCollision(collision); super.handleCollision(collision);
@ -85,7 +85,7 @@ public abstract class WaterAbility extends ElementalAbility {
ParticleEffect.BLOCK_CRACK.display(particleData, 1F, 1F, 1F, 0.1F, 10, collision.getLocationFirst(), 50); ParticleEffect.BLOCK_CRACK.display(particleData, 1F, 1F, 1F, 0.1F, 10, collision.getLocationFirst(), 50);
} }
} }
public boolean isIcebendable(Block block) { public boolean isIcebendable(Block block) {
return isIcebendable(block.getType()); return isIcebendable(block.getType());
} }
@ -93,35 +93,35 @@ public abstract class WaterAbility extends ElementalAbility {
public boolean isIcebendable(Material material) { public boolean isIcebendable(Material material) {
return isIcebendable(player, material); return isIcebendable(player, material);
} }
public boolean isIcebendable(Player player, Material material) { public boolean isIcebendable(Player player, Material material) {
return isIcebendable(player, material, false); return isIcebendable(player, material, false);
} }
public boolean isPlantbendable (Block block) { public boolean isPlantbendable(Block block) {
return isPlantbendable(block.getType()); return isPlantbendable(block.getType());
} }
public boolean isPlantbendable (Material material) { public boolean isPlantbendable(Material material) {
return isPlantbendable(player, material); return isPlantbendable(player, material);
} }
public boolean isPlantbendable (Player player, Material material) { public boolean isPlantbendable(Player player, Material material) {
return isPlantbendable(player, material, false); return isPlantbendable(player, material, false);
} }
public boolean isWaterbendable(Block block) { public boolean isWaterbendable(Block block) {
return isWaterbendable(player, block); return isWaterbendable(player, block);
} }
public boolean isWaterbendable(Player player, Block block) { public boolean isWaterbendable(Player player, Block block) {
return isWaterbendable(player, null, block); return isWaterbendable(player, null, block);
} }
public static boolean isWaterbendable(Material material) { public static boolean isWaterbendable(Material material) {
return isWater(material) || isIce(material) || isPlant(material) || isSnow(material); return isWater(material) || isIce(material) || isPlant(material) || isSnow(material);
} }
public static Block getIceSourceBlock(Player player, double range) { public static Block getIceSourceBlock(Player player, double range) {
Location location = player.getEyeLocation(); Location location = player.getEyeLocation();
Vector vector = location.getDirection().clone().normalize(); Vector vector = location.getDirection().clone().normalize();
@ -161,7 +161,7 @@ public abstract class WaterAbility extends ElementalAbility {
return value; return value;
} }
} }
public static double getNightFactor(World world) { public static double getNightFactor(World world) {
return getNightFactor(1, world); return getNightFactor(1, world);
} }
@ -169,12 +169,12 @@ public abstract class WaterAbility extends ElementalAbility {
public static Block getPlantSourceBlock(Player player, double range, boolean onlyLeaves) { public static Block getPlantSourceBlock(Player player, double range, boolean onlyLeaves) {
Location location = player.getEyeLocation(); Location location = player.getEyeLocation();
Vector vector = location.getDirection().clone().normalize(); Vector vector = location.getDirection().clone().normalize();
for (double i = 0; i <= range; i++) { for (double i = 0; i <= range; i++) {
Block block = location.clone().add(vector.clone().multiply(i)).getBlock(); Block block = location.clone().add(vector.clone().multiply(i)).getBlock();
if (GeneralMethods.isRegionProtectedFromBuild(player, "PlantDisc", location)) { if (GeneralMethods.isRegionProtectedFromBuild(player, "PlantDisc", location)) {
continue; continue;
} else if (isPlantbendable (player, block.getType(), onlyLeaves)) { } else if (isPlantbendable(player, block.getType(), onlyLeaves)) {
if (TempBlock.isTempBlock(block)) { if (TempBlock.isTempBlock(block)) {
continue; continue;
} }
@ -183,7 +183,7 @@ public abstract class WaterAbility extends ElementalAbility {
} }
return null; return null;
} }
/** /**
* Finds a valid Water source for a Player. To use dynamic source selection, * Finds a valid Water source for a Player. To use dynamic source selection,
* use BlockSource.getWaterSourceBlock() instead of this method. Dynamic * use BlockSource.getWaterSourceBlock() instead of this method. Dynamic
@ -199,7 +199,7 @@ public abstract class WaterAbility extends ElementalAbility {
public static Block getWaterSourceBlock(Player player, double range, boolean plantbending) { public static Block getWaterSourceBlock(Player player, double range, boolean plantbending) {
Location location = player.getEyeLocation(); Location location = player.getEyeLocation();
Vector vector = location.getDirection().clone().normalize(); Vector vector = location.getDirection().clone().normalize();
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
Block testBlock = player.getTargetBlock(getTransparentMaterialSet(), range > 3 ? 3 : (int) range); Block testBlock = player.getTargetBlock(getTransparentMaterialSet(), range > 3 ? 3 : (int) range);
if (bPlayer == null) { if (bPlayer == null) {
@ -207,7 +207,7 @@ public abstract class WaterAbility extends ElementalAbility {
} else if (isWaterbendable(player, null, testBlock) && (!isPlant(testBlock) || plantbending)) { } else if (isWaterbendable(player, null, testBlock) && (!isPlant(testBlock) || plantbending)) {
return testBlock; return testBlock;
} }
for (double i = 0; i <= range; i++) { for (double i = 0; i <= range; i++) {
Block block = location.clone().add(vector.clone().multiply(i)).getBlock(); Block block = location.clone().add(vector.clone().multiply(i)).getBlock();
if ((!isTransparent(player, block) && !isIce(block) && !isPlant(block)) || GeneralMethods.isRegionProtectedFromBuild(player, "WaterManipulation", location)) { if ((!isTransparent(player, block) && !isIce(block) && !isPlant(block)) || GeneralMethods.isRegionProtectedFromBuild(player, "WaterManipulation", location)) {
@ -215,12 +215,13 @@ public abstract class WaterAbility extends ElementalAbility {
} else if (isWaterbendable(player, null, block) && (!isPlant(block) || plantbending)) { } else if (isWaterbendable(player, null, block) && (!isPlant(block) || plantbending)) {
if (TempBlock.isTempBlock(block)) { if (TempBlock.isTempBlock(block)) {
continue; continue;
/*TempBlock tb = TempBlock.get(block); /*
byte full = 0x0; * TempBlock tb = TempBlock.get(block); byte full = 0x0; if
if (tb.getState().getRawData() != full * (tb.getState().getRawData() != full &&
&& (tb.getState().getType() != Material.WATER || tb.getState().getType() != Material.STATIONARY_WATER)) { * (tb.getState().getType() != Material.WATER ||
continue; * tb.getState().getType() != Material.STATIONARY_WATER)) {
}*/ * continue; }
*/
} }
return block; return block;
} }
@ -238,21 +239,21 @@ public abstract class WaterAbility extends ElementalAbility {
} }
return adjacent; return adjacent;
} }
public static boolean isIcebendable(Player player, Material material, boolean onlyIce) { public static boolean isIcebendable(Player player, Material material, boolean onlyIce) {
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
return bPlayer == null ? null : isIce(material) && bPlayer.canIcebend() && (!onlyIce || material == Material.ICE); return bPlayer == null ? null : isIce(material) && bPlayer.canIcebend() && (!onlyIce || material == Material.ICE);
} }
public static boolean isPlantbendable(Player player, Material material, boolean onlyLeaves) { public static boolean isPlantbendable(Player player, Material material, boolean onlyLeaves) {
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if(onlyLeaves) { if (onlyLeaves) {
return bPlayer == null ? null : isPlant(material) && bPlayer.canPlantbend() && isLeaves(material); return bPlayer == null ? null : isPlant(material) && bPlayer.canPlantbend() && isLeaves(material);
} else { } else {
return bPlayer == null ? null : isPlant(material) && bPlayer.canPlantbend(); return bPlayer == null ? null : isPlant(material) && bPlayer.canPlantbend();
} }
} }
public static boolean isLeaves(Block block) { public static boolean isLeaves(Block block) {
return block != null ? isLeaves(block.getType()) : false; return block != null ? isLeaves(block.getType()) : false;
} }
@ -260,7 +261,7 @@ public abstract class WaterAbility extends ElementalAbility {
public static boolean isLeaves(Material material) { public static boolean isLeaves(Material material) {
return material == Material.LEAVES || material == Material.LEAVES_2; return material == Material.LEAVES || material == Material.LEAVES_2;
} }
public static boolean isSnow(Block block) { public static boolean isSnow(Block block) {
return block != null ? isSnow(block.getType()) : false; return block != null ? isSnow(block.getType()) : false;
} }
@ -276,7 +277,7 @@ public abstract class WaterAbility extends ElementalAbility {
if (bPlayer == null || !isWaterbendable(block.getType()) || GeneralMethods.isRegionProtectedFromBuild(player, abilityName, block.getLocation())) { if (bPlayer == null || !isWaterbendable(block.getType()) || GeneralMethods.isRegionProtectedFromBuild(player, abilityName, block.getLocation())) {
return false; return false;
} }
if (TempBlock.isTempBlock(block)) { if (TempBlock.isTempBlock(block)) {
return false; return false;
} else if (isWater(block) && block.getData() == full) { } else if (isWater(block) && block.getData() == full) {
@ -339,7 +340,7 @@ public abstract class WaterAbility extends ElementalAbility {
public static void removeWaterSpouts(Location loc, Player source) { public static void removeWaterSpouts(Location loc, Player source) {
removeWaterSpouts(loc, 1.5, source); removeWaterSpouts(loc, 1.5, source);
} }
public static void stopBending() { public static void stopBending() {
SurgeWall.removeAllCleanup(); SurgeWall.removeAllCleanup();
SurgeWave.removeAllCleanup(); SurgeWave.removeAllCleanup();

View file

@ -33,7 +33,7 @@ public class AbilityLoader<T> implements Listener {
this.plugin = plugin; this.plugin = plugin;
this.directory = directory; this.directory = directory;
this.files = new ArrayList<File>(); this.files = new ArrayList<File>();
if (plugin == null || directory == null) { if (plugin == null || directory == null) {
return; return;
} }
@ -53,40 +53,43 @@ public class AbilityLoader<T> implements Listener {
} }
this.loader = URLClassLoader.newInstance(urls.toArray(new URL[0]), plugin.getClass().getClassLoader()); this.loader = URLClassLoader.newInstance(urls.toArray(new URL[0]), plugin.getClass().getClassLoader());
} }
/** /**
* @param classType * @param classType
* @param parentClass a parent of classType that has a visible default constructor * @param parentClass a parent of classType that has a visible default
* @return A list of all of the T objects that were loaded from the jar files within @param directory * constructor
* @return A list of all of the T objects that were loaded from the jar
* files within @param directory
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public List<T> load(Class<?> classType, Class<?> parentClass) { public List<T> load(Class<?> classType, Class<?> parentClass) {
ArrayList<T> loadables = new ArrayList<>(); ArrayList<T> loadables = new ArrayList<>();
for (File file : files) { for (File file : files) {
JarFile jarFile = null; JarFile jarFile = null;
try { try {
jarFile = new JarFile(file); jarFile = new JarFile(file);
Enumeration<JarEntry> entries = jarFile.entries(); Enumeration<JarEntry> entries = jarFile.entries();
while (entries.hasMoreElements()) { while (entries.hasMoreElements()) {
JarEntry entry = entries.nextElement(); JarEntry entry = entries.nextElement();
if (!entry.getName().endsWith(".class")) { if (!entry.getName().endsWith(".class")) {
continue; continue;
} }
String className = entry.getName().replace('/', '.').substring(0, entry.getName().length() - 6); String className = entry.getName().replace('/', '.').substring(0, entry.getName().length() - 6);
Class<?> clazz = null; Class<?> clazz = null;
try { try {
clazz = Class.forName(className, true, loader); clazz = Class.forName(className, true, loader);
} catch (Exception | Error e) { }
catch (Exception | Error e) {
continue; continue;
} }
if (!classType.isAssignableFrom(clazz) || clazz.isInterface() || Modifier.isAbstract(clazz.getModifiers())) { if (!classType.isAssignableFrom(clazz) || clazz.isInterface() || Modifier.isAbstract(clazz.getModifiers())) {
continue; continue;
} }
ReflectionFactory rf = ReflectionFactory.getReflectionFactory(); ReflectionFactory rf = ReflectionFactory.getReflectionFactory();
Constructor<?> objDef = parentClass.getDeclaredConstructor(); Constructor<?> objDef = parentClass.getDeclaredConstructor();
Constructor<?> intConstr = rf.newConstructorForSerialization(clazz, objDef); Constructor<?> intConstr = rf.newConstructorForSerialization(clazz, objDef);
@ -96,16 +99,19 @@ public class AbilityLoader<T> implements Listener {
AbilityLoadEvent<T> event = new AbilityLoadEvent<T>(plugin, loadable, jarFile); AbilityLoadEvent<T> event = new AbilityLoadEvent<T>(plugin, loadable, jarFile);
plugin.getServer().getPluginManager().callEvent(event); plugin.getServer().getPluginManager().callEvent(event);
} }
} catch (Exception | Error e) { }
catch (Exception | Error e) {
e.printStackTrace(); e.printStackTrace();
plugin.getLogger().log(Level.WARNING, "Unknown cause"); plugin.getLogger().log(Level.WARNING, "Unknown cause");
plugin.getLogger().log(Level.WARNING, "The JAR file " + file.getName() + " failed to load"); plugin.getLogger().log(Level.WARNING, "The JAR file " + file.getName() + " failed to load");
} finally { }
finally {
if (jarFile != null) { if (jarFile != null) {
try { try {
jarFile.close(); jarFile.close();
} catch (IOException e) { }
catch (IOException e) {
e.printStackTrace(); e.printStackTrace();
} }
} }

View file

@ -131,7 +131,7 @@ public class CollisionManager {
if (locationSecond == null) { if (locationSecond == null) {
continue; continue;
} }
if (locationFirst.getWorld() != locationSecond.getWorld()) { if (locationFirst.getWorld() != locationSecond.getWorld()) {
return; return;
} }

View file

@ -207,7 +207,8 @@ public class ComboManager {
Class<?> clazz = (Class<?>) comboAbil.getComboType(); Class<?> clazz = (Class<?>) comboAbil.getComboType();
try { try {
ReflectionHandler.instantiateObject(clazz, player); ReflectionHandler.instantiateObject(clazz, player);
} catch (Exception e) { }
catch (Exception e) {
e.printStackTrace(); e.printStackTrace();
} }
} else { } else {

View file

@ -45,9 +45,9 @@ public class MultiAbilityManager {
public static void bindMultiAbility(Player player, String multiAbility) { public static void bindMultiAbility(Player player, String multiAbility) {
BindChangeEvent event = new BindChangeEvent(player, multiAbility, true); BindChangeEvent event = new BindChangeEvent(player, multiAbility, true);
Bukkit.getServer().getPluginManager().callEvent(event); Bukkit.getServer().getPluginManager().callEvent(event);
if(event.isCancelled()) if (event.isCancelled())
return; return;
if (playerAbilities.containsKey(player)) if (playerAbilities.containsKey(player))
unbindMultiAbility(player); unbindMultiAbility(player);
playerSlot.put(player, player.getInventory().getHeldItemSlot()); playerSlot.put(player, player.getInventory().getHeldItemSlot());
@ -117,8 +117,9 @@ public class MultiAbilityManager {
} }
/** /**
* MultiAbility equivalent of {@link GeneralMethods#getBoundAbility(Player)}. Returns a * MultiAbility equivalent of
* boolean based on whether a player has a specific MultiAbility active. * {@link GeneralMethods#getBoundAbility(Player)}. Returns a boolean based
* on whether a player has a specific MultiAbility active.
* *
* @param player The player to check * @param player The player to check
* @param multiAbility The multiability name * @param multiAbility The multiability name
@ -129,7 +130,7 @@ public class MultiAbilityManager {
if (bPlayer == null) { if (bPlayer == null) {
return false; return false;
} }
if (playerAbilities.containsKey(player)) { if (playerAbilities.containsKey(player)) {
if (!playerBoundAbility.get(player).equals(multiAbility) && bPlayer.getBoundAbility() != null) if (!playerBoundAbility.get(player).equals(multiAbility) && bPlayer.getBoundAbility() != null)
return false; return false;
@ -195,14 +196,14 @@ public class MultiAbilityManager {
* *
* @param player * @param player
*/ */
public static void unbindMultiAbility(Player player) { public static void unbindMultiAbility(Player player) {
if (playerAbilities.containsKey(player)) { if (playerAbilities.containsKey(player)) {
HashMap<Integer, String> prevBinds = playerAbilities.get(player); HashMap<Integer, String> prevBinds = playerAbilities.get(player);
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (bPlayer == null) { if (bPlayer == null) {
return; return;
} }
int lastNonNull = -1; int lastNonNull = -1;
for (int i = 1; i < 10; i++) { for (int i = 1; i < 10; i++) {
if (prevBinds.get(i) != null) if (prevBinds.get(i) != null)

View file

@ -44,20 +44,22 @@ public class PassiveManager {
Class<?> clazz = null; Class<?> clazz = null;
try { try {
clazz = Class.forName(ability.getClass().getName()); clazz = Class.forName(ability.getClass().getName());
} catch (ClassNotFoundException e) { }
catch (ClassNotFoundException e) {
e.printStackTrace(); e.printStackTrace();
} }
Constructor<?> constructor = null; Constructor<?> constructor = null;
try { try {
constructor = clazz.getConstructor(Player.class); constructor = clazz.getConstructor(Player.class);
} catch (NoSuchMethodException | SecurityException e) { }
catch (NoSuchMethodException | SecurityException e) {
e.printStackTrace(); e.printStackTrace();
} }
Object object = null; Object object = null;
try { try {
object = constructor.newInstance(new Object[] { player }); object = constructor.newInstance(new Object[] { player });
} catch (InstantiationException | IllegalAccessException | IllegalArgumentException }
| InvocationTargetException e) { catch (InstantiationException | IllegalAccessException | IllegalArgumentException | InvocationTargetException e) {
e.printStackTrace(); e.printStackTrace();
} }
((CoreAbility) object).start(); ((CoreAbility) object).start();

View file

@ -110,13 +110,12 @@ public class AirBlast extends AirAbility {
this.canOpenDoors = false; this.canOpenDoors = false;
this.canPressButtons = false; this.canPressButtons = false;
this.canFlickLevers = false; this.canFlickLevers = false;
if (bPlayer.isAvatarState()) { if (bPlayer.isAvatarState()) {
this.pushFactor = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirBlast.Push.Entities"); this.pushFactor = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirBlast.Push.Entities");
this.pushFactorForOthers = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirBlast.Push.Self"); this.pushFactorForOthers = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirBlast.Push.Self");
} }
start(); start();
} }
@ -201,7 +200,6 @@ public class AirBlast extends AirAbility {
double max = speed / speedFactor; double max = speed / speedFactor;
double factor = pushFactor; double factor = pushFactor;
Vector push = direction.clone(); Vector push = direction.clone();
if (Math.abs(push.getY()) > max && !isUser) { if (Math.abs(push.getY()) > max && !isUser) {
if (push.getY() < 0) { if (push.getY() < 0) {

View file

@ -50,11 +50,11 @@ public class AirSpout extends AirAbility {
} }
new Flight(player); new Flight(player);
if (bPlayer.isAvatarState()) { if (bPlayer.isAvatarState()) {
this.height = getConfig().getDouble("Abilities.Avatar.AvatarState.AirSpout.Height"); this.height = getConfig().getDouble("Abilities.Avatar.AvatarState.AirSpout.Height");
} }
start(); start();
bPlayer.addCooldown(this); bPlayer.addCooldown(this);
} }

View file

@ -103,7 +103,7 @@ public class AirSwipe extends AirAbility {
this.damage = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirSwipe.Damage"); this.damage = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirSwipe.Damage");
this.pushFactor = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirSwipe.Push"); this.pushFactor = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirSwipe.Push");
} }
start(); start();
} }
@ -137,8 +137,7 @@ public class AirSwipe extends AirAbility {
location = location.clone().add(direction.clone().multiply(speed)); location = location.clone().add(direction.clone().multiply(speed));
elements.put(direction, location); elements.put(direction, location);
if (location.distanceSquared(origin) > range * range if (location.distanceSquared(origin) > range * range || GeneralMethods.isRegionProtectedFromBuild(this, location)) {
|| GeneralMethods.isRegionProtectedFromBuild(this, location)) {
elements.remove(direction); elements.remove(direction);
} else { } else {
Block block = location.getBlock(); Block block = location.getBlock();
@ -225,9 +224,9 @@ public class AirSwipe extends AirAbility {
elements.remove(fDirection); elements.remove(fDirection);
} }
} else if (entity.getEntityId() != player.getEntityId() && !(entity instanceof LivingEntity)) { } else if (entity.getEntityId() != player.getEntityId() && !(entity instanceof LivingEntity)) {
GeneralMethods.setVelocity(entity, fDirection.multiply(pushFactor)); GeneralMethods.setVelocity(entity, fDirection.multiply(pushFactor));
} }
} }
}.runTaskLater(ProjectKorra.plugin, i / MAX_AFFECTABLE_ENTITIES); }.runTaskLater(ProjectKorra.plugin, i / MAX_AFFECTABLE_ENTITIES);
@ -286,9 +285,8 @@ public class AirSwipe extends AirAbility {
double factor = 1; double factor = 1;
if (System.currentTimeMillis() >= getStartTime() + maxChargeTime) { if (System.currentTimeMillis() >= getStartTime() + maxChargeTime) {
factor = maxChargeFactor; factor = maxChargeFactor;
} else { } else {
factor = maxChargeFactor * (double) (System.currentTimeMillis() - getStartTime()) factor = maxChargeFactor * (double) (System.currentTimeMillis() - getStartTime()) / (double) maxChargeTime;
/ (double) maxChargeTime;
} }
charging = false; charging = false;

View file

@ -91,7 +91,7 @@ public class Suffocate extends AirAbility {
chargeTime = getConfig().getLong("Abilities.Avatar.AvatarState.Air.Suffocate.ChargeTime"); chargeTime = getConfig().getLong("Abilities.Avatar.AvatarState.Air.Suffocate.ChargeTime");
damage = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.Suffocate.Damage"); damage = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.Suffocate.Damage");
range = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.Suffocate.Range"); range = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.Suffocate.Range");
} }
if (particleCount < 1) { if (particleCount < 1) {

View file

@ -603,7 +603,7 @@ public class AirCombo extends AirAbility implements ComboAbility {
public ArrayList<BukkitRunnable> getTasks() { public ArrayList<BukkitRunnable> getTasks() {
return tasks; return tasks;
} }
public void setTasks(ArrayList<BukkitRunnable> tasks) { public void setTasks(ArrayList<BukkitRunnable> tasks) {
this.tasks = tasks; this.tasks = tasks;
} }
@ -650,7 +650,7 @@ public class AirCombo extends AirAbility implements ComboAbility {
public boolean isCollidable() { public boolean isCollidable() {
return true; return true;
} }
@Override @Override
public void handleCollision(Collision collision) { public void handleCollision(Collision collision) {
if (collision.isRemovingFirst()) { if (collision.isRemovingFirst()) {
@ -674,7 +674,7 @@ public class AirCombo extends AirAbility implements ComboAbility {
setTasks(newTasks); setTasks(newTasks);
} }
} }
@Override @Override
public List<Location> getLocations() { public List<Location> getLocations() {
ArrayList<Location> locations = new ArrayList<>(); ArrayList<Location> locations = new ArrayList<>();

View file

@ -15,10 +15,10 @@ import com.projectkorra.projectkorra.object.PlayerFlyData;
import com.projectkorra.projectkorra.util.Flight; import com.projectkorra.projectkorra.util.Flight;
public class AirFlight extends FlightAbility { public class AirFlight extends FlightAbility {
private static final Map<String, Integer> HITS = new ConcurrentHashMap<>(); private static final Map<String, Integer> HITS = new ConcurrentHashMap<>();
private static final Map<String, PlayerFlyData> HOVERING = new ConcurrentHashMap<>(); private static final Map<String, PlayerFlyData> HOVERING = new ConcurrentHashMap<>();
private long cooldown; private long cooldown;
private boolean firstProgressIteration; private boolean firstProgressIteration;
private int maxHitsBeforeRemoval; private int maxHitsBeforeRemoval;
@ -29,10 +29,10 @@ public class AirFlight extends FlightAbility {
public AirFlight(Player player) { public AirFlight(Player player) {
super(player); super(player);
if (CoreAbility.getAbility(player, AirFlight.class) != null) if (CoreAbility.getAbility(player, AirFlight.class) != null)
return; return;
this.cooldown = getConfig().getInt("Abilities.Air.Flight.Cooldown"); this.cooldown = getConfig().getInt("Abilities.Air.Flight.Cooldown");
this.maxHitsBeforeRemoval = getConfig().getInt("Abilities.Air.Flight.MaxHits"); this.maxHitsBeforeRemoval = getConfig().getInt("Abilities.Air.Flight.MaxHits");
this.speed = getConfig().getDouble("Abilities.Air.Flight.Speed"); this.speed = getConfig().getDouble("Abilities.Air.Flight.Speed");
@ -78,7 +78,7 @@ public class AirFlight extends FlightAbility {
public static void setHovering(Player player, boolean bool) { public static void setHovering(Player player, boolean bool) {
AirFlight flight = CoreAbility.getAbility(player, AirFlight.class); AirFlight flight = CoreAbility.getAbility(player, AirFlight.class);
flight.hoverY = player.getLocation().getBlockY(); flight.hoverY = player.getLocation().getBlockY();
String playername = player.getName(); String playername = player.getName();
if (bool) { if (bool) {
@ -117,7 +117,7 @@ public class AirFlight extends FlightAbility {
} }
player.setAllowFlight(true); player.setAllowFlight(true);
if (flight == null) { if (flight == null) {
flight = new Flight(player); flight = new Flight(player);
player.setFlying(true); player.setFlying(true);
@ -128,12 +128,7 @@ public class AirFlight extends FlightAbility {
vec.setY(0); vec.setY(0);
player.setVelocity(vec); player.setVelocity(vec);
if (player.getLocation().getBlockY() != hoverY) { if (player.getLocation().getBlockY() != hoverY) {
Location loc = new Location(player.getWorld(), Location loc = new Location(player.getWorld(), player.getLocation().getX(), hoverY + 0.5, player.getLocation().getZ(), player.getLocation().getYaw(), player.getLocation().getPitch());
player.getLocation().getX(),
hoverY + 0.5,
player.getLocation().getZ(),
player.getLocation().getYaw(),
player.getLocation().getPitch());
player.teleport(loc); player.teleport(loc);
} }
} else { } else {
@ -179,4 +174,4 @@ public class AirFlight extends FlightAbility {
return true; return true;
} }
} }

View file

@ -10,11 +10,11 @@ import com.projectkorra.projectkorra.ability.PassiveAbility;
import com.projectkorra.projectkorra.configuration.ConfigManager; import com.projectkorra.projectkorra.configuration.ConfigManager;
public class AirAgilityPassive extends AirAbility implements PassiveAbility { public class AirAgilityPassive extends AirAbility implements PassiveAbility {
// Configurable variables // Configurable variables
private int jumpPower; private int jumpPower;
private int speedPower; private int speedPower;
// Instance related variables // Instance related variables
private boolean jumpActivate; private boolean jumpActivate;
private boolean speedActivate; private boolean speedActivate;
@ -23,7 +23,7 @@ public class AirAgilityPassive extends AirAbility implements PassiveAbility {
super(player); super(player);
setFields(); setFields();
} }
public void setFields() { public void setFields() {
this.jumpPower = ConfigManager.getConfig().getInt("Abilities.Air.Passive.AirAgility.JumpPower"); this.jumpPower = ConfigManager.getConfig().getInt("Abilities.Air.Passive.AirAgility.JumpPower");
this.speedPower = ConfigManager.getConfig().getInt("Abilities.Air.Passive.AirAgility.SpeedPower"); this.speedPower = ConfigManager.getConfig().getInt("Abilities.Air.Passive.AirAgility.SpeedPower");
@ -34,7 +34,7 @@ public class AirAgilityPassive extends AirAbility implements PassiveAbility {
if (!player.isSprinting()) { if (!player.isSprinting()) {
return; return;
} }
// Jump Buff // Jump Buff
jumpActivate = true; jumpActivate = true;
if (player.hasPotionEffect(PotionEffectType.JUMP)) { if (player.hasPotionEffect(PotionEffectType.JUMP)) {

View file

@ -3,7 +3,7 @@ package com.projectkorra.projectkorra.airbending.passive;
import com.projectkorra.projectkorra.configuration.ConfigManager; import com.projectkorra.projectkorra.configuration.ConfigManager;
public class AirPassive { public class AirPassive {
public static double getExhaustionFactor() { public static double getExhaustionFactor() {
return getFactor(); return getFactor();
} }

View file

@ -14,7 +14,7 @@ public class AirSaturation extends AirAbility implements PassiveAbility {
@Override @Override
public void progress() { public void progress() {
} }
@Override @Override
@ -34,7 +34,7 @@ public class AirSaturation extends AirAbility implements PassiveAbility {
@Override @Override
public String getName() { public String getName() {
return "AirSaturation" ; return "AirSaturation";
} }
@Override @Override

View file

@ -14,7 +14,7 @@ public class GracefulDescent extends AirAbility implements PassiveAbility {
@Override @Override
public void progress() { public void progress() {
} }
@Override @Override

View file

@ -29,10 +29,10 @@ public class AvatarState extends AvatarAbility {
private long duration; private long duration;
private long cooldown; private long cooldown;
private double factor; private double factor;
public AvatarState(Player player) { public AvatarState(Player player) {
super(player); super(player);
AvatarState oldAbil = getAbility(player, AvatarState.class); AvatarState oldAbil = getAbility(player, AvatarState.class);
if (oldAbil != null) { if (oldAbil != null) {
oldAbil.remove(); oldAbil.remove();
@ -42,7 +42,7 @@ public class AvatarState extends AvatarAbility {
} else if (GLOBAL_COOLDOWNS.containsKey(player.getUniqueId())) { } else if (GLOBAL_COOLDOWNS.containsKey(player.getUniqueId())) {
return; return;
} }
this.regenEnabled = getConfig().getBoolean("Abilities.Avatar.AvatarState.PotionEffects.Regeneration.Enabled"); this.regenEnabled = getConfig().getBoolean("Abilities.Avatar.AvatarState.PotionEffects.Regeneration.Enabled");
this.speedEnabled = getConfig().getBoolean("Abilities.Avatar.AvatarState.PotionEffects.Speed.Enabled"); this.speedEnabled = getConfig().getBoolean("Abilities.Avatar.AvatarState.PotionEffects.Speed.Enabled");
this.resistanceEnabled = getConfig().getBoolean("Abilities.Avatar.AvatarState.PotionEffects.DamageResistance.Enabled"); this.resistanceEnabled = getConfig().getBoolean("Abilities.Avatar.AvatarState.PotionEffects.DamageResistance.Enabled");
@ -52,12 +52,12 @@ public class AvatarState extends AvatarAbility {
this.resistancePower = getConfig().getInt("Abilities.Avatar.AvatarState.PotionEffects.DamageResistance.Power") - 1; this.resistancePower = getConfig().getInt("Abilities.Avatar.AvatarState.PotionEffects.DamageResistance.Power") - 1;
this.fireResistancePower = getConfig().getInt("Abilities.Avatar.AvatarState.PotionEffects.FireResistance.Power") - 1; this.fireResistancePower = getConfig().getInt("Abilities.Avatar.AvatarState.PotionEffects.FireResistance.Power") - 1;
this.duration = getConfig().getLong("Abilities.Avatar.AvatarState.Duration"); this.duration = getConfig().getLong("Abilities.Avatar.AvatarState.Duration");
this.cooldown = getConfig().getLong("Abilities.Avatar.AvatarState.Cooldown"); this.cooldown = getConfig().getLong("Abilities.Avatar.AvatarState.Cooldown");
this.factor = getConfig().getDouble("Abilities.Avatar.AvatarState.PowerMultiplier"); this.factor = getConfig().getDouble("Abilities.Avatar.AvatarState.PowerMultiplier");
new Flight(player); new Flight(player);
playAvatarSound(player.getLocation()); playAvatarSound(player.getLocation());
start(); start();
bPlayer.addCooldown(this); bPlayer.addCooldown(this);
if (duration != 0) { if (duration != 0) {
@ -69,7 +69,7 @@ public class AvatarState extends AvatarAbility {
public void run() { public void run() {
GLOBAL_COOLDOWNS.remove(id); GLOBAL_COOLDOWNS.remove(id);
} }
}, cooldown/50); }, cooldown / 50);
} }
} }
@ -120,7 +120,7 @@ public class AvatarState extends AvatarAbility {
public static int getValue(int value) { public static int getValue(int value) {
return (int) getValue((double) value); return (int) getValue((double) value);
} }
public static double getValue(double value, Player player) { public static double getValue(double value, Player player) {
AvatarState astate = getAbility(player, AvatarState.class); AvatarState astate = getAbility(player, AvatarState.class);
if (astate != null) { if (astate != null) {
@ -143,7 +143,7 @@ public class AvatarState extends AvatarAbility {
public long getCooldown() { public long getCooldown() {
return cooldown; return cooldown;
} }
@Override @Override
public boolean isSneakAbility() { public boolean isSneakAbility() {
return false; return false;

View file

@ -11,23 +11,23 @@ import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ability.ChiAbility; import com.projectkorra.projectkorra.ability.ChiAbility;
public class AcrobatStance extends ChiAbility { public class AcrobatStance extends ChiAbility {
private int speed; private int speed;
private int jump; private int jump;
private double chiBlockBoost; private double chiBlockBoost;
private double paralyzeDodgeBoost; private double paralyzeDodgeBoost;
public AcrobatStance(Player player) { public AcrobatStance(Player player) {
super(player); super(player);
if (!bPlayer.canBend(this)) { if (!bPlayer.canBend(this)) {
return; return;
} }
this.speed = getConfig().getInt("Abilities.Chi.AcrobatStance.Speed") + 1; this.speed = getConfig().getInt("Abilities.Chi.AcrobatStance.Speed") + 1;
this.jump = getConfig().getInt("Abilities.Chi.AcrobatStance.Jump") + 1; this.jump = getConfig().getInt("Abilities.Chi.AcrobatStance.Jump") + 1;
this.chiBlockBoost = getConfig().getDouble("Abilities.Chi.AcrobatStance.ChiBlockBoost"); this.chiBlockBoost = getConfig().getDouble("Abilities.Chi.AcrobatStance.ChiBlockBoost");
this.paralyzeDodgeBoost = getConfig().getDouble("Abilities.Chi.AcrobatStance.ParalyzeChanceDecrease"); this.paralyzeDodgeBoost = getConfig().getDouble("Abilities.Chi.AcrobatStance.ParalyzeChanceDecrease");
ChiAbility stance = bPlayer.getStance(); ChiAbility stance = bPlayer.getStance();
if (stance != null) { if (stance != null) {
if (stance instanceof AcrobatStance) { if (stance instanceof AcrobatStance) {
@ -50,7 +50,7 @@ public class AcrobatStance extends ChiAbility {
remove(); remove();
return; return;
} }
if (!player.hasPotionEffect(PotionEffectType.SPEED)) { if (!player.hasPotionEffect(PotionEffectType.SPEED)) {
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 60, speed, true)); player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 60, speed, true));
} }
@ -58,7 +58,7 @@ public class AcrobatStance extends ChiAbility {
player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 60, jump, true)); player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 60, jump, true));
} }
} }
@Override @Override
public void remove() { public void remove() {
super.remove(); super.remove();
@ -68,7 +68,7 @@ public class AcrobatStance extends ChiAbility {
player.removePotionEffect(PotionEffectType.SPEED); player.removePotionEffect(PotionEffectType.SPEED);
player.removePotionEffect(PotionEffectType.JUMP); player.removePotionEffect(PotionEffectType.JUMP);
} }
@Override @Override
public String getName() { public String getName() {
return "AcrobatStance"; return "AcrobatStance";
@ -93,7 +93,7 @@ public class AcrobatStance extends ChiAbility {
public boolean isHarmlessAbility() { public boolean isHarmlessAbility() {
return true; return true;
} }
public int getSpeed() { public int getSpeed() {
return speed; return speed;
} }
@ -125,5 +125,5 @@ public class AcrobatStance extends ChiAbility {
public void setParalyzeDodgeBoost(double paralyzeDodgeBoost) { public void setParalyzeDodgeBoost(double paralyzeDodgeBoost) {
this.paralyzeDodgeBoost = paralyzeDodgeBoost; this.paralyzeDodgeBoost = paralyzeDodgeBoost;
} }
} }

View file

@ -14,7 +14,7 @@ public class HighJump extends ChiAbility {
private int height; private int height;
private long cooldown; private long cooldown;
public HighJump(Player player) { public HighJump(Player player) {
super(player); super(player);
if (!bPlayer.canBend(this)) { if (!bPlayer.canBend(this)) {
@ -48,9 +48,9 @@ public class HighJump extends ChiAbility {
if (waw != null) { if (waw != null) {
waw.setGrabbed(false); waw.setGrabbed(false);
} }
} }
@Override @Override
public String getName() { public String getName() {
return "HighJump"; return "HighJump";
@ -75,7 +75,7 @@ public class HighJump extends ChiAbility {
public boolean isHarmlessAbility() { public boolean isHarmlessAbility() {
return true; return true;
} }
public int getHeight() { public int getHeight() {
return height; return height;
} }
@ -87,5 +87,5 @@ public class HighJump extends ChiAbility {
public void setCooldown(long cooldown) { public void setCooldown(long cooldown) {
this.cooldown = cooldown; this.cooldown = cooldown;
} }
} }

View file

@ -29,7 +29,7 @@ public class Paralyze extends ChiAbility {
this.cooldown = getConfig().getLong("Abilities.Chi.Paralyze.Cooldown"); this.cooldown = getConfig().getLong("Abilities.Chi.Paralyze.Cooldown");
start(); start();
} }
@Override @Override
public void progress() { public void progress() {
if (bPlayer.canBend(this)) { if (bPlayer.canBend(this)) {
@ -81,7 +81,7 @@ public class Paralyze extends ChiAbility {
public String getName() { public String getName() {
return "Paralyze"; return "Paralyze";
} }
@Override @Override
public Location getLocation() { public Location getLocation() {
return target != null ? target.getLocation() : null; return target != null ? target.getLocation() : null;
@ -91,7 +91,7 @@ public class Paralyze extends ChiAbility {
public long getCooldown() { public long getCooldown() {
return cooldown; return cooldown;
} }
@Override @Override
public boolean isSneakAbility() { public boolean isSneakAbility() {
return false; return false;
@ -101,7 +101,7 @@ public class Paralyze extends ChiAbility {
public boolean isHarmlessAbility() { public boolean isHarmlessAbility() {
return false; return false;
} }
public static long getDuration() { public static long getDuration() {
return getConfig().getLong("Abilities.Chi.Paralyze.Duration"); return getConfig().getLong("Abilities.Chi.Paralyze.Duration");
} }
@ -117,5 +117,5 @@ public class Paralyze extends ChiAbility {
public static Map<Entity, Long> getEntities() { public static Map<Entity, Long> getEntities() {
return ENTITIES; return ENTITIES;
} }
} }

View file

@ -44,7 +44,7 @@ public class QuickStrike extends ChiAbility {
if (target instanceof Player && ChiPassive.willChiBlock(player, (Player) target)) { if (target instanceof Player && ChiPassive.willChiBlock(player, (Player) target)) {
ChiPassive.blockChi((Player) target); ChiPassive.blockChi((Player) target);
} }
remove(); remove();
} }

View file

@ -19,7 +19,7 @@ public class RapidPunch extends ChiAbility {
private long cooldown; private long cooldown;
private int numPunches; private int numPunches;
private Entity target; private Entity target;
public RapidPunch(Player sourceplayer, Entity targetentity) { public RapidPunch(Player sourceplayer, Entity targetentity) {
super(sourceplayer); super(sourceplayer);
if (!bPlayer.canBend(this)) { if (!bPlayer.canBend(this)) {
@ -39,10 +39,10 @@ public class RapidPunch extends ChiAbility {
remove(); remove();
return; return;
} }
LivingEntity lt = (LivingEntity) target; LivingEntity lt = (LivingEntity) target;
DamageHandler.damageEntity(target, damage, this); DamageHandler.damageEntity(target, damage, this);
if (target instanceof Player) { if (target instanceof Player) {
if (ChiPassive.willChiBlock(player, (Player) target)) { if (ChiPassive.willChiBlock(player, (Player) target)) {
ChiPassive.blockChi((Player) target); ChiPassive.blockChi((Player) target);
@ -51,12 +51,12 @@ public class RapidPunch extends ChiAbility {
Suffocate.remove((Player) target); Suffocate.remove((Player) target);
} }
} }
lt.setNoDamageTicks(0); lt.setNoDamageTicks(0);
bPlayer.addCooldown(this); bPlayer.addCooldown(this);
numPunches++; numPunches++;
} }
@Override @Override
public String getName() { public String getName() {
return "RapidPunch"; return "RapidPunch";
@ -71,7 +71,7 @@ public class RapidPunch extends ChiAbility {
public long getCooldown() { public long getCooldown() {
return cooldown; return cooldown;
} }
@Override @Override
public boolean isSneakAbility() { public boolean isSneakAbility() {
return false; return false;
@ -125,5 +125,5 @@ public class RapidPunch extends ChiAbility {
public void setCooldown(long cooldown) { public void setCooldown(long cooldown) {
this.cooldown = cooldown; this.cooldown = cooldown;
} }
} }

View file

@ -24,7 +24,7 @@ public class Smokescreen extends ChiAbility {
private int duration; private int duration;
private long cooldown; private long cooldown;
private double radius; private double radius;
public Smokescreen(Player player) { public Smokescreen(Player player) {
super(player); super(player);
if (!bPlayer.canBend(this)) { if (!bPlayer.canBend(this)) {
@ -35,7 +35,7 @@ public class Smokescreen extends ChiAbility {
this.radius = getConfig().getDouble("Abilities.Chi.Smokescreen.Radius"); this.radius = getConfig().getDouble("Abilities.Chi.Smokescreen.Radius");
start(); start();
} }
@Override @Override
public void progress() { public void progress() {
SNOWBALLS.put(player.launchProjectile(Snowball.class).getEntityId(), this); SNOWBALLS.put(player.launchProjectile(Snowball.class).getEntityId(), this);
@ -47,7 +47,7 @@ public class Smokescreen extends ChiAbility {
int z = -2; int z = -2;
int x = -2; int x = -2;
int y = 0; int y = 0;
for (int i = 0; i < 125; i++) { for (int i = 0; i < 125; i++) {
Location newLoc = new Location(loc.getWorld(), loc.getX() + x, loc.getY() + y, loc.getZ() + z); Location newLoc = new Location(loc.getWorld(), loc.getX() + x, loc.getY() + y, loc.getZ() + z);
for (int direction = 0; direction < 8; direction++) { for (int direction = 0; direction < 8; direction++) {
@ -90,7 +90,6 @@ public class Smokescreen extends ChiAbility {
} }
} }
} }
@Override @Override
public String getName() { public String getName() {
@ -106,7 +105,7 @@ public class Smokescreen extends ChiAbility {
public long getCooldown() { public long getCooldown() {
return cooldown; return cooldown;
} }
@Override @Override
public boolean isSneakAbility() { public boolean isSneakAbility() {
return false; return false;
@ -116,7 +115,7 @@ public class Smokescreen extends ChiAbility {
public boolean isHarmlessAbility() { public boolean isHarmlessAbility() {
return false; return false;
} }
public void setCooldown(long cooldown) { public void setCooldown(long cooldown) {
this.cooldown = cooldown; this.cooldown = cooldown;
} }

View file

@ -10,12 +10,12 @@ import com.projectkorra.projectkorra.chiblocking.passive.ChiPassive;
import com.projectkorra.projectkorra.util.DamageHandler; import com.projectkorra.projectkorra.util.DamageHandler;
public class SwiftKick extends ChiAbility { public class SwiftKick extends ChiAbility {
private int damage; private int damage;
private int blockChance; private int blockChance;
private long cooldown; private long cooldown;
private Entity target; private Entity target;
public SwiftKick(Player sourceplayer, Entity targetentity) { public SwiftKick(Player sourceplayer, Entity targetentity) {
super(sourceplayer); super(sourceplayer);
if (!bPlayer.canBend(this)) { if (!bPlayer.canBend(this)) {
@ -45,7 +45,7 @@ public class SwiftKick extends ChiAbility {
bPlayer.addCooldown(this); bPlayer.addCooldown(this);
remove(); remove();
} }
@Override @Override
public String getName() { public String getName() {
return "SwiftKick"; return "SwiftKick";
@ -60,7 +60,7 @@ public class SwiftKick extends ChiAbility {
public long getCooldown() { public long getCooldown() {
return cooldown; return cooldown;
} }
@Override @Override
public boolean isSneakAbility() { public boolean isSneakAbility() {
return true; return true;
@ -98,5 +98,5 @@ public class SwiftKick extends ChiAbility {
public void setCooldown(long cooldown) { public void setCooldown(long cooldown) {
this.cooldown = cooldown; this.cooldown = cooldown;
} }
} }

View file

@ -14,7 +14,7 @@ public class WarriorStance extends ChiAbility {
private int strength; private int strength;
private int resistance; private int resistance;
public WarriorStance(Player player) { public WarriorStance(Player player) {
super(player); super(player);
if (!bPlayer.canBend(this)) { if (!bPlayer.canBend(this)) {
@ -22,7 +22,7 @@ public class WarriorStance extends ChiAbility {
} }
this.strength = getConfig().getInt("Abilities.Chi.WarriorStance.Strength") - 1; this.strength = getConfig().getInt("Abilities.Chi.WarriorStance.Strength") - 1;
this.resistance = getConfig().getInt("Abilities.Chi.WarriorStance.Resistance"); this.resistance = getConfig().getInt("Abilities.Chi.WarriorStance.Resistance");
ChiAbility stance = bPlayer.getStance(); ChiAbility stance = bPlayer.getStance();
if (stance != null) { if (stance != null) {
if (stance instanceof WarriorStance) { if (stance instanceof WarriorStance) {
@ -45,7 +45,7 @@ public class WarriorStance extends ChiAbility {
remove(); remove();
return; return;
} }
if (!player.hasPotionEffect(PotionEffectType.DAMAGE_RESISTANCE)) { if (!player.hasPotionEffect(PotionEffectType.DAMAGE_RESISTANCE)) {
player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 60, resistance, true)); player.addPotionEffect(new PotionEffect(PotionEffectType.DAMAGE_RESISTANCE, 60, resistance, true));
} }
@ -53,7 +53,7 @@ public class WarriorStance extends ChiAbility {
player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 60, strength, true)); player.addPotionEffect(new PotionEffect(PotionEffectType.INCREASE_DAMAGE, 60, strength, true));
} }
} }
@Override @Override
public void remove() { public void remove() {
super.remove(); super.remove();
@ -63,7 +63,7 @@ public class WarriorStance extends ChiAbility {
player.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE); player.removePotionEffect(PotionEffectType.DAMAGE_RESISTANCE);
player.removePotionEffect(PotionEffectType.INCREASE_DAMAGE); player.removePotionEffect(PotionEffectType.INCREASE_DAMAGE);
} }
@Override @Override
public String getName() { public String getName() {
return "WarriorStance"; return "WarriorStance";
@ -78,7 +78,7 @@ public class WarriorStance extends ChiAbility {
public long getCooldown() { public long getCooldown() {
return 0; return 0;
} }
@Override @Override
public boolean isSneakAbility() { public boolean isSneakAbility() {
return false; return false;
@ -104,5 +104,5 @@ public class WarriorStance extends ChiAbility {
public void setResistance(int resistance) { public void setResistance(int resistance) {
this.resistance = resistance; this.resistance = resistance;
} }
} }

View file

@ -14,7 +14,7 @@ public class Acrobatics extends ChiAbility implements PassiveAbility {
@Override @Override
public void progress() { public void progress() {
} }
@Override @Override

View file

@ -15,7 +15,7 @@ public class ChiAgilityPassive extends ChiAbility implements PassiveAbility {
// Configurable variables // Configurable variables
private int jumpPower; private int jumpPower;
private int speedPower; private int speedPower;
// Instance related variables // Instance related variables
private boolean jumpActivate; private boolean jumpActivate;
private boolean speedActivate; private boolean speedActivate;
@ -24,7 +24,7 @@ public class ChiAgilityPassive extends ChiAbility implements PassiveAbility {
super(player); super(player);
setFields(); setFields();
} }
public void setFields() { public void setFields() {
this.jumpPower = ConfigManager.getConfig().getInt("Abilities.Chi.Passive.ChiAgility.JumpPower"); this.jumpPower = ConfigManager.getConfig().getInt("Abilities.Chi.Passive.ChiAgility.JumpPower");
this.speedPower = ConfigManager.getConfig().getInt("Abilities.Chi.Passive.ChiAgility.SpeedPower"); this.speedPower = ConfigManager.getConfig().getInt("Abilities.Chi.Passive.ChiAgility.SpeedPower");
@ -35,7 +35,7 @@ public class ChiAgilityPassive extends ChiAbility implements PassiveAbility {
if (!player.isSprinting()) { if (!player.isSprinting()) {
return; return;
} }
// Jump Buff // Jump Buff
int jMax = jumpPower; int jMax = jumpPower;
if (hasAbility(player, AcrobatStance.class)) { if (hasAbility(player, AcrobatStance.class)) {

View file

@ -20,22 +20,22 @@ public class ChiPassive {
if (bPlayer == null) { if (bPlayer == null) {
return false; return false;
} }
ChiAbility stance = bPlayer.getStance(); ChiAbility stance = bPlayer.getStance();
QuickStrike quickStrike = CoreAbility.getAbility(player, QuickStrike.class); QuickStrike quickStrike = CoreAbility.getAbility(player, QuickStrike.class);
SwiftKick swiftKick = CoreAbility.getAbility(player, SwiftKick.class); SwiftKick swiftKick = CoreAbility.getAbility(player, SwiftKick.class);
double newChance = 0; double newChance = 0;
if (stance != null && stance instanceof AcrobatStance) { if (stance != null && stance instanceof AcrobatStance) {
newChance = getChance() + ((AcrobatStance) stance).getChiBlockBoost(); newChance = getChance() + ((AcrobatStance) stance).getChiBlockBoost();
} }
if (quickStrike != null) { if (quickStrike != null) {
newChance = getChance() + quickStrike.getBlockChance(); newChance = getChance() + quickStrike.getBlockChance();
} else if (swiftKick != null) { } else if (swiftKick != null) {
newChance = getChance() + swiftKick.getBlockChance(); newChance = getChance() + swiftKick.getBlockChance();
} }
if (Math.random() > newChance / 100.0) { if (Math.random() > newChance / 100.0) {
return false; return false;
} else if (bPlayer.isChiBlocked()) { } else if (bPlayer.isChiBlocked()) {
@ -48,7 +48,7 @@ public class ChiPassive {
if (Suffocate.isChannelingSphere(player)) { if (Suffocate.isChannelingSphere(player)) {
Suffocate.remove(player); Suffocate.remove(player);
} }
final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (bPlayer == null) { if (bPlayer == null) {
return; return;
@ -66,7 +66,7 @@ public class ChiPassive {
public static double getExhaustionFactor() { public static double getExhaustionFactor() {
return ConfigManager.getConfig().getDouble("Abilities.Chi.Passive.ChiSaturation.ExhaustionFactor"); return ConfigManager.getConfig().getDouble("Abilities.Chi.Passive.ChiSaturation.ExhaustionFactor");
} }
public static double getFallReductionFactor() { public static double getFallReductionFactor() {
return ConfigManager.getConfig().getDouble("Abilities.Chi.Passive.Acrobatics.FallReductionFactor"); return ConfigManager.getConfig().getDouble("Abilities.Chi.Passive.Acrobatics.FallReductionFactor");
} }

View file

@ -14,7 +14,7 @@ public class ChiSaturation extends ChiAbility implements PassiveAbility {
@Override @Override
public void progress() { public void progress() {
} }
@Override @Override

View file

@ -15,7 +15,7 @@ public class ChiblockingManager implements Runnable {
public ChiblockingManager(ProjectKorra plugin) { public ChiblockingManager(ProjectKorra plugin) {
this.plugin = plugin; this.plugin = plugin;
} }
@Override @Override
public void run() { public void run() {
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {

View file

@ -36,7 +36,7 @@ public class AddCommand extends PKCommand {
public AddCommand() { public AddCommand() {
super("add", "/bending add <Element/SubElement> [Player]", ConfigManager.languageConfig.get().getString("Commands.Add.Description"), new String[] { "add", "a" }); super("add", "/bending add <Element/SubElement> [Player]", ConfigManager.languageConfig.get().getString("Commands.Add.Description"), new String[] { "add", "a" });
this.playerNotFound = ConfigManager.languageConfig.get().getString("Commands.Add.PlayerNotFound"); this.playerNotFound = ConfigManager.languageConfig.get().getString("Commands.Add.PlayerNotFound");
this.invalidElement = ConfigManager.languageConfig.get().getString("Commands.Add.InvalidElement"); this.invalidElement = ConfigManager.languageConfig.get().getString("Commands.Add.InvalidElement");
this.addedOtherCFW = ConfigManager.languageConfig.get().getString("Commands.Add.Other.SuccessfullyAddedCFW"); this.addedOtherCFW = ConfigManager.languageConfig.get().getString("Commands.Add.Other.SuccessfullyAddedCFW");
@ -78,12 +78,12 @@ public class AddCommand extends PKCommand {
* @param element The element to add * @param element The element to add
*/ */
private void add(CommandSender sender, Player target, String element) { private void add(CommandSender sender, Player target, String element) {
Element e = Element.fromString(element); Element e = Element.fromString(element);
if (e == null) { if (e == null) {
e = SubElement.fromString(element); e = SubElement.fromString(element);
} }
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(target); BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(target);
if (bPlayer == null) { if (bPlayer == null) {
GeneralMethods.createBendingPlayer(target.getUniqueId(), target.getName()); GeneralMethods.createBendingPlayer(target.getUniqueId(), target.getName());
@ -109,9 +109,9 @@ public class AddCommand extends PKCommand {
bPlayer.addSubElement(sub); bPlayer.addSubElement(sub);
} }
} }
ChatColor color = e.getColor(); ChatColor color = e.getColor();
if (!(sender instanceof Player) || !((Player) sender).equals(target)) { if (!(sender instanceof Player) || !((Player) sender).equals(target)) {
if (e != Element.AIR && e != Element.EARTH) { if (e != Element.AIR && e != Element.EARTH) {
sender.sendMessage(color + addedOtherCFW.replace("{target}", ChatColor.DARK_AQUA + target.getName() + color).replace("{element}", e.getName() + e.getType().getBender())); sender.sendMessage(color + addedOtherCFW.replace("{target}", ChatColor.DARK_AQUA + target.getName() + color).replace("{element}", e.getName() + e.getType().getBender()));
@ -125,7 +125,7 @@ public class AddCommand extends PKCommand {
target.sendMessage(color + addedCFW.replace("{element}", e.getName() + e.getType().getBender())); target.sendMessage(color + addedCFW.replace("{element}", e.getName() + e.getType().getBender()));
else else
target.sendMessage(color + addedAE.replace("{element}", e.getName() + e.getType().getBender())); target.sendMessage(color + addedAE.replace("{element}", e.getName() + e.getType().getBender()));
} }
GeneralMethods.saveElements(bPlayer); GeneralMethods.saveElements(bPlayer);
GeneralMethods.saveSubElements(bPlayer); GeneralMethods.saveSubElements(bPlayer);
@ -143,13 +143,13 @@ public class AddCommand extends PKCommand {
} }
bPlayer.addSubElement(sub); bPlayer.addSubElement(sub);
ChatColor color = e.getColor(); ChatColor color = e.getColor();
if (!(sender instanceof Player) || !((Player) sender).equals(target)) { if (!(sender instanceof Player) || !((Player) sender).equals(target)) {
if (e != Element.AIR && e != Element.EARTH) if (e != Element.AIR && e != Element.EARTH)
sender.sendMessage(color + addedOtherCFW.replace("{target}", ChatColor.DARK_AQUA + target.getName() + color).replace("{element}", sub.getName() + sub.getType().getBender())); sender.sendMessage(color + addedOtherCFW.replace("{target}", ChatColor.DARK_AQUA + target.getName() + color).replace("{element}", sub.getName() + sub.getType().getBender()));
else else
sender.sendMessage(color + addedOtherAE.replace("{target}", ChatColor.DARK_AQUA + target.getName() + color).replace("{element}", sub.getName() + sub.getType().getBender())); sender.sendMessage(color + addedOtherAE.replace("{target}", ChatColor.DARK_AQUA + target.getName() + color).replace("{element}", sub.getName() + sub.getType().getBender()));
} else { } else {
if (e != Element.AIR && e != Element.EARTH) if (e != Element.AIR && e != Element.EARTH)
target.sendMessage(color + addedCFW.replace("{element}", sub.getName() + sub.getType().getBender())); target.sendMessage(color + addedCFW.replace("{element}", sub.getName() + sub.getType().getBender()));
@ -163,17 +163,18 @@ public class AddCommand extends PKCommand {
sender.sendMessage(ChatColor.RED + invalidElement); sender.sendMessage(ChatColor.RED + invalidElement);
} }
} }
public static boolean isVowel(char c) { public static boolean isVowel(char c) {
return "AEIOUaeiou".indexOf(c) != -1; return "AEIOUaeiou".indexOf(c) != -1;
} }
@Override @Override
protected List<String> getTabCompletion(CommandSender sender, List<String> args) { protected List<String> getTabCompletion(CommandSender sender, List<String> args) {
if (args.size() >= 2 || !sender.hasPermission("bending.command.add")) return new ArrayList<String>(); if (args.size() >= 2 || !sender.hasPermission("bending.command.add"))
return new ArrayList<String>();
List<String> l = new ArrayList<String>(); List<String> l = new ArrayList<String>();
if (args.size() == 0) { if (args.size() == 0) {
l.add("Air"); l.add("Air");
l.add("Earth"); l.add("Earth");
l.add("Fire"); l.add("Fire");
@ -182,7 +183,7 @@ public class AddCommand extends PKCommand {
for (Element e : Element.getAddonElements()) { for (Element e : Element.getAddonElements()) {
l.add(e.getName()); l.add(e.getName());
} }
l.add("Blood"); l.add("Blood");
l.add("Combustion"); l.add("Combustion");
l.add("Flight"); l.add("Flight");

View file

@ -13,26 +13,26 @@ import java.util.List;
* Completes tabbing for the bending command/subcommands. * Completes tabbing for the bending command/subcommands.
* *
* @author StrangeOne101 * @author StrangeOne101
* */ */
public class BendingTabComplete implements TabCompleter { public class BendingTabComplete implements TabCompleter {
@Override @Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) { public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
if (args.length == 0 || args.length == 1) if (args.length == 0 || args.length == 1)
return getPossibleCompletions(args, getCommandsForUser(sender)); return getPossibleCompletions(args, getCommandsForUser(sender));
else if (args.length > 1){ else if (args.length > 1) {
for (PKCommand cmd : PKCommand.instances.values()) { for (PKCommand cmd : PKCommand.instances.values()) {
if (Arrays.asList(cmd.getAliases()).contains(args[0].toLowerCase()) && sender.hasPermission("bending.command." + cmd.getName())) { if (Arrays.asList(cmd.getAliases()).contains(args[0].toLowerCase()) && sender.hasPermission("bending.command." + cmd.getName())) {
List<String> newargs = new ArrayList<String>(); List<String> newargs = new ArrayList<String>();
for (int i = 1; i < args.length - 1; i++) { for (int i = 1; i < args.length - 1; i++) {
if (!(args[i].equals("") || args[i].equals(" ")) && args.length >= 1) if (!(args[i].equals("") || args[i].equals(" ")) && args.length >= 1)
newargs.add(args[i]); newargs.add(args[i]);
} }
return getPossibleCompletions(args, cmd.getTabCompletion(sender, newargs)); return getPossibleCompletions(args, cmd.getTabCompletion(sender, newargs));
} }
} }
} }
return new ArrayList<String>(); return new ArrayList<String>();
} }
@ -41,7 +41,7 @@ public class BendingTabComplete implements TabCompleter {
* what the user has currently typed. * what the user has currently typed.
* *
* @author D4rKDeagle<br> * @author D4rKDeagle<br>
* <br> * <br>
* (Found at * (Found at
* <a>https://bukkit.org/threads/help-with-bukkit-tab-completion * <a>https://bukkit.org/threads/help-with-bukkit-tab-completion
* -api.166436</a>) * -api.166436</a>)

View file

@ -30,8 +30,8 @@ public class BindCommand extends PKCommand {
private String noSubElement; private String noSubElement;
public BindCommand() { public BindCommand() {
super("bind", "/bending bind <Ability> [Slot]", ConfigManager.languageConfig.get().getString("Commands.Bind.Description"), new String[]{ "bind", "b" }); super("bind", "/bending bind <Ability> [Slot]", ConfigManager.languageConfig.get().getString("Commands.Bind.Description"), new String[] { "bind", "b" });
this.abilityDoesntExist = ConfigManager.languageConfig.get().getString("Commands.Bind.AbilityDoesntExist"); this.abilityDoesntExist = ConfigManager.languageConfig.get().getString("Commands.Bind.AbilityDoesntExist");
this.wrongNumber = ConfigManager.languageConfig.get().getString("Commands.Bind.WrongNumber"); this.wrongNumber = ConfigManager.languageConfig.get().getString("Commands.Bind.WrongNumber");
this.loadingInfo = ConfigManager.languageConfig.get().getString("Commands.Bind.LoadingInfo"); this.loadingInfo = ConfigManager.languageConfig.get().getString("Commands.Bind.LoadingInfo");
@ -52,17 +52,18 @@ public class BindCommand extends PKCommand {
sender.sendMessage(ChatColor.RED + abilityDoesntExist.replace("{ability}", args.get(0))); sender.sendMessage(ChatColor.RED + abilityDoesntExist.replace("{ability}", args.get(0)));
return; return;
} }
// bending bind [Ability] // bending bind [Ability]
if (args.size() == 1) { if (args.size() == 1) {
bind(sender, args.get(0), ((Player) sender).getInventory().getHeldItemSlot()+1); bind(sender, args.get(0), ((Player) sender).getInventory().getHeldItemSlot() + 1);
} }
// bending bind [ability] [#] // bending bind [ability] [#]
if (args.size() == 2) { if (args.size() == 2) {
try { try {
bind(sender, args.get(0), Integer.parseInt(args.get(1))); bind(sender, args.get(0), Integer.parseInt(args.get(1)));
} catch (NumberFormatException ex) { }
catch (NumberFormatException ex) {
sender.sendMessage(ChatColor.RED + wrongNumber); sender.sendMessage(ChatColor.RED + wrongNumber);
} }
} }
@ -100,15 +101,16 @@ public class BindCommand extends PKCommand {
} else if (!bPlayer.isElementToggled(coreAbil.getElement())) { } else if (!bPlayer.isElementToggled(coreAbil.getElement())) {
sender.sendMessage(ChatColor.RED + toggledElementOff); sender.sendMessage(ChatColor.RED + toggledElementOff);
} }
String name = coreAbil != null ? coreAbil.getName() : null; String name = coreAbil != null ? coreAbil.getName() : null;
GeneralMethods.bindAbility((Player) sender, name, slot); GeneralMethods.bindAbility((Player) sender, name, slot);
} }
@Override @Override
protected List<String> getTabCompletion(CommandSender sender, List<String> args) { protected List<String> getTabCompletion(CommandSender sender, List<String> args) {
if (args.size() >= 2 || !sender.hasPermission("bending.command.bind") || !(sender instanceof Player)) return new ArrayList<String>(); if (args.size() >= 2 || !sender.hasPermission("bending.command.bind") || !(sender instanceof Player))
return new ArrayList<String>();
List<String> abilities = new ArrayList<String>(); List<String> abilities = new ArrayList<String>();
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(sender.getName()); BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(sender.getName());
if (args.size() == 0) { if (args.size() == 0) {
@ -126,4 +128,4 @@ public class BindCommand extends PKCommand {
Collections.sort(abilities); Collections.sort(abilities);
return abilities; return abilities;
} }
} }

View file

@ -20,7 +20,7 @@ public class CheckCommand extends PKCommand {
public CheckCommand() { public CheckCommand() {
super("check", "/bending check", ConfigManager.languageConfig.get().getString("Commands.Check.Description"), new String[] { "check", "chk" }); super("check", "/bending check", ConfigManager.languageConfig.get().getString("Commands.Check.Description"), new String[] { "check", "chk" });
this.newVersionAvailable = ConfigManager.languageConfig.get().getString("Commands.Check.NewVersionAvailable"); this.newVersionAvailable = ConfigManager.languageConfig.get().getString("Commands.Check.NewVersionAvailable");
this.curVersion = ConfigManager.languageConfig.get().getString("Commands.Check.CurrentVersion"); this.curVersion = ConfigManager.languageConfig.get().getString("Commands.Check.CurrentVersion");
this.newVersion = ConfigManager.languageConfig.get().getString("Commands.Check.LatestVersion"); this.newVersion = ConfigManager.languageConfig.get().getString("Commands.Check.LatestVersion");

View file

@ -33,7 +33,7 @@ public class ChooseCommand extends PKCommand {
public ChooseCommand() { public ChooseCommand() {
super("choose", "/bending choose <Element> [Player]", ConfigManager.languageConfig.get().getString("Commands.Choose.Description"), new String[] { "choose", "ch" }); super("choose", "/bending choose <Element> [Player]", ConfigManager.languageConfig.get().getString("Commands.Choose.Description"), new String[] { "choose", "ch" });
this.playerNotFound = ConfigManager.languageConfig.get().getString("Commands.Choose.PlayerNotFound"); this.playerNotFound = ConfigManager.languageConfig.get().getString("Commands.Choose.PlayerNotFound");
this.invalidElement = ConfigManager.languageConfig.get().getString("Commands.Choose.InvalidElement"); this.invalidElement = ConfigManager.languageConfig.get().getString("Commands.Choose.InvalidElement");
this.chosenCFW = ConfigManager.languageConfig.get().getString("Commands.Choose.SuccessfullyChosenCFW"); this.chosenCFW = ConfigManager.languageConfig.get().getString("Commands.Choose.SuccessfullyChosenCFW");
@ -66,11 +66,16 @@ public class ChooseCommand extends PKCommand {
return; return;
} }
String element = args.get(0).toLowerCase(); String element = args.get(0).toLowerCase();
if (element.equalsIgnoreCase("a")) element = "air"; if (element.equalsIgnoreCase("a"))
else if (element.equalsIgnoreCase("e")) element = "earth"; element = "air";
else if (element.equalsIgnoreCase("f")) element = "fire"; else if (element.equalsIgnoreCase("e"))
else if (element.equalsIgnoreCase("w")) element = "water"; element = "earth";
else if (element.equalsIgnoreCase("c")) element = "chi"; else if (element.equalsIgnoreCase("f"))
element = "fire";
else if (element.equalsIgnoreCase("w"))
element = "water";
else if (element.equalsIgnoreCase("c"))
element = "chi";
Element targetElement = Element.getElement(element); Element targetElement = Element.getElement(element);
if (Arrays.asList(Element.getAllElements()).contains(targetElement)) { if (Arrays.asList(Element.getAllElements()).contains(targetElement)) {
if (!hasPermission(sender, element)) { if (!hasPermission(sender, element)) {
@ -93,11 +98,16 @@ public class ChooseCommand extends PKCommand {
return; return;
} }
String element = args.get(0).toLowerCase(); String element = args.get(0).toLowerCase();
if (element.equalsIgnoreCase("a")) element = "air"; if (element.equalsIgnoreCase("a"))
else if (element.equalsIgnoreCase("e")) element = "earth"; element = "air";
else if (element.equalsIgnoreCase("f")) element = "fire"; else if (element.equalsIgnoreCase("e"))
else if (element.equalsIgnoreCase("w")) element = "water"; element = "earth";
else if (element.equalsIgnoreCase("c")) element = "chi"; else if (element.equalsIgnoreCase("f"))
element = "fire";
else if (element.equalsIgnoreCase("w"))
element = "water";
else if (element.equalsIgnoreCase("c"))
element = "chi";
Element targetElement = Element.getElement(element); Element targetElement = Element.getElement(element);
if (Arrays.asList(Element.getAllElements()).contains(targetElement) && targetElement != Element.AVATAR) { if (Arrays.asList(Element.getAllElements()).contains(targetElement) && targetElement != Element.AVATAR) {
add(sender, target, targetElement); add(sender, target, targetElement);
@ -117,7 +127,7 @@ public class ChooseCommand extends PKCommand {
*/ */
private void add(CommandSender sender, Player target, Element element) { private void add(CommandSender sender, Player target, Element element) {
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(target); BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(target);
if (bPlayer == null) { if (bPlayer == null) {
return; return;
} }
@ -140,7 +150,7 @@ public class ChooseCommand extends PKCommand {
bPlayer.addSubElement(sub); bPlayer.addSubElement(sub);
} }
} }
ChatColor color = element != null ? element.getColor() : ChatColor.WHITE; ChatColor color = element != null ? element.getColor() : ChatColor.WHITE;
if (!(sender instanceof Player) || !((Player) sender).equals(target)) { if (!(sender instanceof Player) || !((Player) sender).equals(target)) {
if (element != Element.AIR && element != Element.EARTH) if (element != Element.AIR && element != Element.EARTH)
@ -157,24 +167,23 @@ public class ChooseCommand extends PKCommand {
GeneralMethods.saveSubElements(bPlayer); GeneralMethods.saveSubElements(bPlayer);
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, target, element, Result.CHOOSE)); Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, target, element, Result.CHOOSE));
} }
GeneralMethods.removeUnusableAbilities(target.getName()); GeneralMethods.removeUnusableAbilities(target.getName());
} }
public static boolean isVowel(char c) { public static boolean isVowel(char c) {
return "AEIOUaeiou".indexOf(c) != -1; return "AEIOUaeiou".indexOf(c) != -1;
} }
@Override @Override
protected List<String> getTabCompletion(CommandSender sender, List<String> args) { protected List<String> getTabCompletion(CommandSender sender, List<String> args) {
if (args.size() >= 2 || !sender.hasPermission("bending.command.choose")) return new ArrayList<String>(); if (args.size() >= 2 || !sender.hasPermission("bending.command.choose"))
return new ArrayList<String>();
List<String> l = new ArrayList<String>(); List<String> l = new ArrayList<String>();
if (args.size() == 0) { if (args.size() == 0) {
l.add("Air"); l.add("Air");
l.add("Earth"); l.add("Earth");
l.add("Fire"); l.add("Fire");

View file

@ -23,10 +23,10 @@ public class ClearCommand extends PKCommand {
private String wrongNumber; private String wrongNumber;
private String clearedSlot; private String clearedSlot;
private String alreadyEmpty; private String alreadyEmpty;
public ClearCommand() { public ClearCommand() {
super("clear", "/bending clear [Slot]", ConfigManager.languageConfig.get().getString("Commands.Clear.Description"), new String[] { "clear", "cl", "c" }); super("clear", "/bending clear [Slot]", ConfigManager.languageConfig.get().getString("Commands.Clear.Description"), new String[] { "clear", "cl", "c" });
this.cantEditBinds = ConfigManager.languageConfig.get().getString("Commands.Clear.CantEditBinds"); this.cantEditBinds = ConfigManager.languageConfig.get().getString("Commands.Clear.CantEditBinds");
this.cleared = ConfigManager.languageConfig.get().getString("Commands.Clear.Cleared"); this.cleared = ConfigManager.languageConfig.get().getString("Commands.Clear.Cleared");
this.wrongNumber = ConfigManager.languageConfig.get().getString("Commands.Clear.WrongNumber"); this.wrongNumber = ConfigManager.languageConfig.get().getString("Commands.Clear.WrongNumber");
@ -63,19 +63,21 @@ public class ClearCommand extends PKCommand {
if (bPlayer.getAbilities().get(slot) != null) { if (bPlayer.getAbilities().get(slot) != null) {
bPlayer.getAbilities().remove(slot); bPlayer.getAbilities().remove(slot);
GeneralMethods.saveAbility(bPlayer, slot, null); GeneralMethods.saveAbility(bPlayer, slot, null);
sender.sendMessage(ChatColor.YELLOW + clearedSlot.replace("{slot}", String.valueOf(slot))); sender.sendMessage(ChatColor.YELLOW + clearedSlot.replace("{slot}", String.valueOf(slot)));
} else { } else {
sender.sendMessage(ChatColor.YELLOW + alreadyEmpty); sender.sendMessage(ChatColor.YELLOW + alreadyEmpty);
} }
} catch (NumberFormatException e) { }
catch (NumberFormatException e) {
sender.sendMessage(ChatColor.RED + wrongNumber); sender.sendMessage(ChatColor.RED + wrongNumber);
} }
} }
} }
@Override @Override
protected List<String> getTabCompletion(CommandSender sender, List<String> args) { protected List<String> getTabCompletion(CommandSender sender, List<String> args) {
if (args.size() >= 1 || !sender.hasPermission("bending.command.clear")) return new ArrayList<String>(); if (args.size() >= 1 || !sender.hasPermission("bending.command.clear"))
return new ArrayList<String>();
return Arrays.asList("123456789".split("")); return Arrays.asList("123456789".split(""));
} }

View file

@ -38,7 +38,7 @@ public class Commands {
public static String[] wateraliases = { "water", "w", "waterbending", "waterbender" }; public static String[] wateraliases = { "water", "w", "waterbending", "waterbender" };
public static String[] elementaliases = { "air", "a", "airbending", "airbender", "chi", "c", "chiblocking", "chiblocker", "earth", "e", "earthbending", "earthbender", "fire", "f", "firebending", "firebender", "water", "w", "waterbending", "waterbender" }; public static String[] elementaliases = { "air", "a", "airbending", "airbender", "chi", "c", "chiblocking", "chiblocker", "earth", "e", "earthbending", "earthbender", "fire", "f", "firebending", "firebender", "water", "w", "waterbending", "waterbender" };
public static String[] avataraliases = { "avatar", "av", "avy", "aang", "korra" }; public static String[] avataraliases = { "avatar", "av", "avy", "aang", "korra" };
/* /*
* Combo Aliases * Combo Aliases
*/ */
@ -53,9 +53,9 @@ public class Commands {
/* /*
* Passive Aliases * Passive Aliases
*/ */
public static String[] passivealiases = { "airpassive", "ap", "airpassives", "airbendingpassives", "chipassive", "cp", "chipassives", "chiblockingpassives", "chiblockerpassives", "earthpassive", "ep", "earthpassives", "earthbendingpassives", "firepassive", "fp", "firepassives", "firebendingpassives", "waterpassive", "wp", "waterpassives", "waterbendingpassives" }; public static String[] passivealiases = { "airpassive", "ap", "airpassives", "airbendingpassives", "chipassive", "cp", "chipassives", "chiblockingpassives", "chiblockerpassives", "earthpassive", "ep", "earthpassives", "earthbendingpassives", "firepassive", "fp", "firepassives", "firebendingpassives", "waterpassive", "wp", "waterpassives", "waterbendingpassives" };
/* /*
* Subelement Aliases * Subelement Aliases
*/ */
@ -79,12 +79,12 @@ public class Commands {
//Firebending //Firebending
public static String[] combustionaliases = { "combustionbending", "combustion", "cb" }; public static String[] combustionaliases = { "combustionbending", "combustion", "cb" };
public static String[] lightningaliases = { "lightningbending", "lightning" }; public static String[] lightningaliases = { "lightningbending", "lightning" };
//Miscellaneous //Miscellaneous
public static String[] commandaliases = { "b", "pk", "projectkorra", "bending", "mtla", "tla", "korra", "bend" }; public static String[] commandaliases = { "b", "pk", "projectkorra", "bending", "mtla", "tla", "korra", "bend" };
private List<String> help; private List<String> help;
private void init() { private void init() {
PluginCommand projectkorra = plugin.getCommand("projectkorra"); PluginCommand projectkorra = plugin.getCommand("projectkorra");
new AddCommand(); new AddCommand();
@ -107,7 +107,7 @@ public class Commands {
new WhoCommand(); new WhoCommand();
help = ConfigManager.languageConfig.get().getStringList("Commands.GeneralHelpLines"); help = ConfigManager.languageConfig.get().getStringList("Commands.GeneralHelpLines");
/** /**
* Set of all of the Classes which extend Command * Set of all of the Classes which extend Command
*/ */
@ -117,7 +117,7 @@ public class Commands {
exe = new CommandExecutor() { exe = new CommandExecutor() {
@Override @Override
public boolean onCommand(CommandSender s, Command c, String label, String[] args) { public boolean onCommand(CommandSender s, Command c, String label, String[] args) {
if (args.length == 0 && Arrays.asList(commandaliases).contains(label.toLowerCase())) { if (args.length == 0 && Arrays.asList(commandaliases).contains(label.toLowerCase())) {
for (String line : help) for (String line : help)
s.sendMessage(ChatColor.translateAlternateColorCodes('&', line)); s.sendMessage(ChatColor.translateAlternateColorCodes('&', line));
@ -131,10 +131,10 @@ public class Commands {
return true; return true;
} }
} }
for (String line : help) for (String line : help)
s.sendMessage(ChatColor.translateAlternateColorCodes('&', line)); s.sendMessage(ChatColor.translateAlternateColorCodes('&', line));
return true; return true;
} }
}; };

View file

@ -16,7 +16,7 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
public class CopyCommand extends PKCommand { public class CopyCommand extends PKCommand {
private String playerNotFound; private String playerNotFound;
private String copied; private String copied;
private String failedToBindAll; private String failedToBindAll;
@ -24,7 +24,7 @@ public class CopyCommand extends PKCommand {
public CopyCommand() { public CopyCommand() {
super("copy", "/bending copy <Player> [Player]", ConfigManager.languageConfig.get().getString("Commands.Copy.Description"), new String[] { "copy", "co" }); super("copy", "/bending copy <Player> [Player]", ConfigManager.languageConfig.get().getString("Commands.Copy.Description"), new String[] { "copy", "co" });
this.playerNotFound = ConfigManager.languageConfig.get().getString("Commands.Copy.PlayerNotFound"); this.playerNotFound = ConfigManager.languageConfig.get().getString("Commands.Copy.PlayerNotFound");
this.copied = ConfigManager.languageConfig.get().getString("Commands.Copy.SuccessfullyCopied"); this.copied = ConfigManager.languageConfig.get().getString("Commands.Copy.SuccessfullyCopied");
this.failedToBindAll = ConfigManager.languageConfig.get().getString("Commands.Copy.FailedToBindAll"); this.failedToBindAll = ConfigManager.languageConfig.get().getString("Commands.Copy.FailedToBindAll");
@ -47,7 +47,6 @@ public class CopyCommand extends PKCommand {
return; return;
} }
boolean boundAll = assignAbilities(sender, orig, (Player) sender, true); boolean boundAll = assignAbilities(sender, orig, (Player) sender, true);
sender.sendMessage(ChatColor.GREEN + copied.replace("{target}", ChatColor.YELLOW + orig.getName() + ChatColor.GREEN)); sender.sendMessage(ChatColor.GREEN + copied.replace("{target}", ChatColor.YELLOW + orig.getName() + ChatColor.GREEN));
if (!boundAll) { if (!boundAll) {
@ -75,7 +74,7 @@ public class CopyCommand extends PKCommand {
} }
} }
} }
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
private boolean assignAbilities(CommandSender sender, Player player, Player player2, boolean self) { private boolean assignAbilities(CommandSender sender, Player player, Player player2, boolean self) {
@ -98,7 +97,7 @@ public class CopyCommand extends PKCommand {
} }
return false; return false;
} }
HashMap<Integer, String> abilities = (HashMap<Integer, String>) orig.getAbilities().clone(); HashMap<Integer, String> abilities = (HashMap<Integer, String>) orig.getAbilities().clone();
boolean boundAll = true; boolean boundAll = true;
for (int i = 1; i <= 9; i++) { for (int i = 1; i <= 9; i++) {
@ -111,10 +110,11 @@ public class CopyCommand extends PKCommand {
target.setAbilities(abilities); target.setAbilities(abilities);
return boundAll; return boundAll;
} }
@Override @Override
protected List<String> getTabCompletion(CommandSender sender, List<String> args) { protected List<String> getTabCompletion(CommandSender sender, List<String> args) {
if (!sender.hasPermission("bending.command.copy") || args.size() >= 2 || (args.size() >= 1 && !sender.hasPermission("bending.command.copy.assign"))) return new ArrayList<String>(); //Return nothing if (!sender.hasPermission("bending.command.copy") || args.size() >= 2 || (args.size() >= 1 && !sender.hasPermission("bending.command.copy.assign")))
return new ArrayList<String>(); //Return nothing
List<String> l = new ArrayList<String>(); List<String> l = new ArrayList<String>();
for (Player p : Bukkit.getOnlinePlayers()) { for (Player p : Bukkit.getOnlinePlayers()) {
l.add(p.getName()); l.add(p.getName());
@ -122,4 +122,4 @@ public class CopyCommand extends PKCommand {
return l; return l;
} }
} }

View file

@ -24,7 +24,7 @@ import com.projectkorra.rpg.commands.RPGCommand;
* Executor for /bending help. Extends {@link PKCommand}. * Executor for /bending help. Extends {@link PKCommand}.
*/ */
public class HelpCommand extends PKCommand { public class HelpCommand extends PKCommand {
private String required; private String required;
private String optional; private String optional;
private String properUsage; private String properUsage;
@ -39,7 +39,7 @@ public class HelpCommand extends PKCommand {
public HelpCommand() { public HelpCommand() {
super("help", "/bending help <Page/Topic>", ConfigManager.languageConfig.get().getString("Commands.Help.Description"), new String[] { "help", "h" }); super("help", "/bending help <Page/Topic>", ConfigManager.languageConfig.get().getString("Commands.Help.Description"), new String[] { "help", "h" });
this.required = ConfigManager.languageConfig.get().getString("Commands.Help.Required"); this.required = ConfigManager.languageConfig.get().getString("Commands.Help.Required");
this.optional = ConfigManager.languageConfig.get().getString("Commands.Help.Optional"); this.optional = ConfigManager.languageConfig.get().getString("Commands.Help.Optional");
this.properUsage = ConfigManager.languageConfig.get().getString("Commands.Help.ProperUsage"); this.properUsage = ConfigManager.languageConfig.get().getString("Commands.Help.ProperUsage");
@ -155,10 +155,11 @@ public class HelpCommand extends PKCommand {
sender.sendMessage(ChatColor.RED + invalidTopic); sender.sendMessage(ChatColor.RED + invalidTopic);
} }
} }
@Override @Override
protected List<String> getTabCompletion(CommandSender sender, List<String> args) { protected List<String> getTabCompletion(CommandSender sender, List<String> args) {
if (args.size() >= 1 || !sender.hasPermission("bending.command.help")) return new ArrayList<String>(); if (args.size() >= 1 || !sender.hasPermission("bending.command.help"))
return new ArrayList<String>();
List<String> list = new ArrayList<String>(); List<String> list = new ArrayList<String>();
for (Element e : Element.getAllElements()) { for (Element e : Element.getAllElements()) {
list.add(e.getName()); list.add(e.getName());

View file

@ -40,7 +40,7 @@ public class ImportCommand extends PKCommand {
public ImportCommand() { public ImportCommand() {
super("import", "/bending import", ConfigManager.languageConfig.get().getString("Commands.Import.Description"), new String[] { "import", "i" }); super("import", "/bending import", ConfigManager.languageConfig.get().getString("Commands.Import.Description"), new String[] { "import", "i" });
this.disabled = ConfigManager.languageConfig.get().getString("Commands.Import.Description"); this.disabled = ConfigManager.languageConfig.get().getString("Commands.Import.Description");
this.preparingData = ConfigManager.languageConfig.get().getString("Commands.Import.PreparingData"); this.preparingData = ConfigManager.languageConfig.get().getString("Commands.Import.PreparingData");
this.importStarted = ConfigManager.languageConfig.get().getString("Commands.Import.ImportStarted"); this.importStarted = ConfigManager.languageConfig.get().getString("Commands.Import.ImportStarted");
@ -74,13 +74,13 @@ public class ImportCommand extends PKCommand {
boolean permaremoved = bendingPlayers.getBoolean(string + ".Permaremoved"); boolean permaremoved = bendingPlayers.getBoolean(string + ".Permaremoved");
Element[] mainElements = Element.getMainElements(); Element[] mainElements = Element.getMainElements();
Element[] allElements = Element.getAllElements(); Element[] allElements = Element.getAllElements();
for (int i : bendingTypes) { for (int i : bendingTypes) {
if (i < mainElements.length) { if (i < mainElements.length) {
elements.add(mainElements[i]); elements.add(mainElements[i]);
} }
} }
for (Element e : allElements) { for (Element e : allElements) {
if (e instanceof SubElement) { if (e instanceof SubElement) {
SubElement s = (SubElement) e; SubElement s = (SubElement) e;

View file

@ -16,16 +16,15 @@ import org.bukkit.entity.Player;
import com.projectkorra.projectkorra.configuration.ConfigManager; import com.projectkorra.projectkorra.configuration.ConfigManager;
/** /**
* Abstract representation of a command executor. Implements * Abstract representation of a command executor. Implements {@link SubCommand}.
* {@link SubCommand}.
* *
* @author kingbirdy * @author kingbirdy
* *
*/ */
public abstract class PKCommand implements SubCommand { public abstract class PKCommand implements SubCommand {
protected String noPermissionMessage, mustBePlayerMessage; protected String noPermissionMessage, mustBePlayerMessage;
/** /**
* The full name of the command. * The full name of the command.
*/ */
@ -53,10 +52,10 @@ public abstract class PKCommand implements SubCommand {
this.properUse = properUse; this.properUse = properUse;
this.description = description; this.description = description;
this.aliases = aliases; this.aliases = aliases;
this.noPermissionMessage = ChatColor.RED + ConfigManager.languageConfig.get().getString("Commands.NoPermission"); this.noPermissionMessage = ChatColor.RED + ConfigManager.languageConfig.get().getString("Commands.NoPermission");
this.mustBePlayerMessage = ChatColor.RED + ConfigManager.languageConfig.get().getString("Commands.MustBePlayer"); this.mustBePlayerMessage = ChatColor.RED + ConfigManager.languageConfig.get().getString("Commands.MustBePlayer");
instances.put(name, this); instances.put(name, this);
} }
@ -170,7 +169,7 @@ public abstract class PKCommand implements SubCommand {
else if (Arrays.asList(Commands.lightningaliases).contains(element)) else if (Arrays.asList(Commands.lightningaliases).contains(element))
return "lightning"; return "lightning";
else if (Arrays.asList(Commands.earthaliases).contains(element) || Arrays.asList(Commands.earthcomboaliases).contains(element)) else if (Arrays.asList(Commands.earthaliases).contains(element) || Arrays.asList(Commands.earthcomboaliases).contains(element))
return "earth"; return "earth";
else if (Arrays.asList(Commands.metalbendingaliases).contains(element)) else if (Arrays.asList(Commands.metalbendingaliases).contains(element))
return "metal"; return "metal";
else if (Arrays.asList(Commands.sandbendingaliases).contains(element)) else if (Arrays.asList(Commands.sandbendingaliases).contains(element))
@ -178,18 +177,18 @@ public abstract class PKCommand implements SubCommand {
else if (Arrays.asList(Commands.lavabendingaliases).contains(element)) else if (Arrays.asList(Commands.lavabendingaliases).contains(element))
return "lava"; return "lava";
else if (Arrays.asList(Commands.airaliases).contains(element) || Arrays.asList(Commands.aircomboaliases).contains(element)) else if (Arrays.asList(Commands.airaliases).contains(element) || Arrays.asList(Commands.aircomboaliases).contains(element))
return "air"; return "air";
else if (Arrays.asList(Commands.spiritualprojectionaliases).contains(element)) else if (Arrays.asList(Commands.spiritualprojectionaliases).contains(element))
return "spiritual"; return "spiritual";
else if (Arrays.asList(Commands.flightaliases).contains(element)) else if (Arrays.asList(Commands.flightaliases).contains(element))
return "flight"; return "flight";
else if (Arrays.asList(Commands.wateraliases).contains(element) || Arrays.asList(Commands.watercomboaliases).contains(element)) else if (Arrays.asList(Commands.wateraliases).contains(element) || Arrays.asList(Commands.watercomboaliases).contains(element))
return "water"; return "water";
else if (Arrays.asList(Commands.healingaliases).contains(element)) else if (Arrays.asList(Commands.healingaliases).contains(element))
return "healing"; return "healing";
else if (Arrays.asList(Commands.bloodaliases).contains(element)) else if (Arrays.asList(Commands.bloodaliases).contains(element))
return "blood"; return "blood";
else if (Arrays.asList(Commands.icealiases).contains(element)) else if (Arrays.asList(Commands.icealiases).contains(element))
return "ice"; return "ice";
else if (Arrays.asList(Commands.plantaliases).contains(element)) else if (Arrays.asList(Commands.plantaliases).contains(element))
return "plant"; return "plant";
@ -197,9 +196,10 @@ public abstract class PKCommand implements SubCommand {
return "chi"; return "chi";
return null; return null;
} }
/** /**
* Returns a boolean if the string provided is numerical. * Returns a boolean if the string provided is numerical.
*
* @param id * @param id
* @return boolean * @return boolean
*/ */
@ -209,9 +209,10 @@ public abstract class PKCommand implements SubCommand {
formatter.parse(id, pos); formatter.parse(id, pos);
return id.length() == pos.getIndex(); return id.length() == pos.getIndex();
} }
/** /**
* Returns a list for of commands for a page. * Returns a list for of commands for a page.
*
* @param entries * @param entries
* @param title * @param title
* @param page * @param page
@ -222,7 +223,7 @@ public abstract class PKCommand implements SubCommand {
if (sort) { if (sort) {
Collections.sort(entries); Collections.sort(entries);
} }
if (page < 1) { if (page < 1) {
page = 1; page = 1;
} }
@ -232,25 +233,24 @@ public abstract class PKCommand implements SubCommand {
page = 1; page = 1;
} }
} }
strings.add(ChatColor.GOLD + "ProjectKorra " + ChatColor.DARK_GRAY + "- [" + ChatColor.GRAY + page + "/" + (int) Math.ceil((entries.size()+.0)/(8+.0)) + ChatColor.DARK_GRAY + "]"); strings.add(ChatColor.GOLD + "ProjectKorra " + ChatColor.DARK_GRAY + "- [" + ChatColor.GRAY + page + "/" + (int) Math.ceil((entries.size() + .0) / (8 + .0)) + ChatColor.DARK_GRAY + "]");
strings.add(title); strings.add(title);
if (entries.size() > ((page * 8) - 8)) { if (entries.size() > ((page * 8) - 8)) {
for (int i = ((page * 8) - 8); i < entries.size(); i++) { for (int i = ((page * 8) - 8); i < entries.size(); i++) {
if (entries.get(i) != null) { if (entries.get(i) != null) {
strings.add(entries.get(i).toString()); strings.add(entries.get(i).toString());
} }
if (i >= (page * 8)-1) { if (i >= (page * 8) - 1) {
break; break;
} }
} }
} }
return strings; return strings;
} }
/**Gets a list of valid arguments that can be used in tabbing.*/ /** Gets a list of valid arguments that can be used in tabbing. */
protected List<String> getTabCompletion(CommandSender sender, List<String> args) protected List<String> getTabCompletion(CommandSender sender, List<String> args) {
{
return new ArrayList<String>(); return new ArrayList<String>();
} }
} }

View file

@ -18,16 +18,16 @@ import java.util.List;
* Executor for /bending permaremove. Extends {@link PKCommand}. * Executor for /bending permaremove. Extends {@link PKCommand}.
*/ */
public class PermaremoveCommand extends PKCommand { public class PermaremoveCommand extends PKCommand {
private String playerIsOffline; private String playerIsOffline;
private String restored; private String restored;
private String restoredConfirm; private String restoredConfirm;
private String removed; private String removed;
private String removedConfirm; private String removedConfirm;
public PermaremoveCommand() { public PermaremoveCommand() {
super("permaremove", "/bending permaremove <Player>", ConfigManager.languageConfig.get().getString("Commands.PermaRemove.Description"), new String[] { "permaremove", "premove", "permremove", "pr" }); super("permaremove", "/bending permaremove <Player>", ConfigManager.languageConfig.get().getString("Commands.PermaRemove.Description"), new String[] { "permaremove", "premove", "permremove", "pr" });
this.playerIsOffline = ConfigManager.languageConfig.get().getString("Commands.PermaRemove.PlayerOffline"); this.playerIsOffline = ConfigManager.languageConfig.get().getString("Commands.PermaRemove.PlayerOffline");
this.restored = ConfigManager.languageConfig.get().getString("Commands.PermaRemove.Restored"); this.restored = ConfigManager.languageConfig.get().getString("Commands.PermaRemove.Restored");
this.restoredConfirm = ConfigManager.languageConfig.get().getString("Commands.PermaRemove.RestoredConfirm"); this.restoredConfirm = ConfigManager.languageConfig.get().getString("Commands.PermaRemove.RestoredConfirm");
@ -99,10 +99,11 @@ public class PermaremoveCommand extends PKCommand {
} }
return true; return true;
} }
@Override @Override
protected List<String> getTabCompletion(CommandSender sender, List<String> args) { protected List<String> getTabCompletion(CommandSender sender, List<String> args) {
if (args.size() >= 1 || !sender.hasPermission("bending.command.permaremove")) return new ArrayList<String>(); if (args.size() >= 1 || !sender.hasPermission("bending.command.permaremove"))
return new ArrayList<String>();
List<String> players = new ArrayList<String>(); List<String> players = new ArrayList<String>();
for (Player p : Bukkit.getOnlinePlayers()) { for (Player p : Bukkit.getOnlinePlayers()) {
players.add(p.getName()); players.add(p.getName());

View file

@ -25,7 +25,7 @@ public class PresetCommand extends PKCommand {
private static final String[] deletealiases = { "delete", "d", "del" }; private static final String[] deletealiases = { "delete", "d", "del" };
private static final String[] listaliases = { "list", "l" }; private static final String[] listaliases = { "list", "l" };
private static final String[] bindaliases = { "bind", "b" }; private static final String[] bindaliases = { "bind", "b" };
private String noPresets; private String noPresets;
private String noPresetName; private String noPresetName;
private String deletePreset; private String deletePreset;
@ -40,10 +40,10 @@ public class PresetCommand extends PKCommand {
private String alreadyExists; private String alreadyExists;
private String createdNewPreset; private String createdNewPreset;
private String cantEditBinds; private String cantEditBinds;
public PresetCommand() { public PresetCommand() {
super("preset", "/bending preset <Bind/Create/Delete/List> [Preset]", ConfigManager.languageConfig.get().getString("Commands.Preset.Description"), new String[] { "preset", "presets", "pre", "set", "p" }); super("preset", "/bending preset <Bind/Create/Delete/List> [Preset]", ConfigManager.languageConfig.get().getString("Commands.Preset.Description"), new String[] { "preset", "presets", "pre", "set", "p" });
this.noPresets = ConfigManager.languageConfig.get().getString("Commands.Preset.NoPresets"); this.noPresets = ConfigManager.languageConfig.get().getString("Commands.Preset.NoPresets");
this.noPresetName = ConfigManager.languageConfig.get().getString("Commands.Preset.NoPresetName"); this.noPresetName = ConfigManager.languageConfig.get().getString("Commands.Preset.NoPresetName");
this.deletePreset = ConfigManager.languageConfig.get().getString("Commands.Preset.Delete"); this.deletePreset = ConfigManager.languageConfig.get().getString("Commands.Preset.Delete");
@ -218,7 +218,7 @@ public class PresetCommand extends PKCommand {
help(sender, false); help(sender, false);
} }
} }
@Override @Override
protected List<String> getTabCompletion(CommandSender sender, List<String> args) { protected List<String> getTabCompletion(CommandSender sender, List<String> args) {
if (args.size() >= 3 || !sender.hasPermission("bending.command.preset") || !(sender instanceof Player)) if (args.size() >= 3 || !sender.hasPermission("bending.command.preset") || !(sender instanceof Player))
@ -245,8 +245,9 @@ public class PresetCommand extends PKCommand {
} }
} }
} }
if (presetNames.size() == 0) return new ArrayList<String>(); if (presetNames.size() == 0)
return new ArrayList<String>();
} }
return l; return l;
} }
} }

View file

@ -23,23 +23,19 @@ import java.util.List;
*/ */
public class RemoveCommand extends PKCommand { public class RemoveCommand extends PKCommand {
private String succesfullyRemovedElementSelf, wrongElementSelf, invalidElement, playerOffline, wrongElementTarget, private String succesfullyRemovedElementSelf, wrongElementSelf, invalidElement, playerOffline,
succesfullyRemovedElementTarget, succesfullyRemovedElementTargetConfirm, succesfullyRemovedAllElementsTarget, wrongElementTarget, succesfullyRemovedElementTarget,
succesfullyRemovedAllElementsTargetConfirm; succesfullyRemovedElementTargetConfirm, succesfullyRemovedAllElementsTarget,
succesfullyRemovedAllElementsTargetConfirm;
public RemoveCommand() { public RemoveCommand() {
super("remove", "/bending remove <Player> [Element]", super("remove", "/bending remove <Player> [Element]", ConfigManager.languageConfig.get().getString("Commands.Remove.Description"), new String[] { "remove", "rm" });
ConfigManager.languageConfig.get().getString("Commands.Remove.Description"), new String[] { "remove", "rm" });
this.succesfullyRemovedElementSelf = ConfigManager.languageConfig.get().getString("Commands.Remove.RemovedElement"); this.succesfullyRemovedElementSelf = ConfigManager.languageConfig.get().getString("Commands.Remove.RemovedElement");
this.succesfullyRemovedAllElementsTarget = ConfigManager.languageConfig.get() this.succesfullyRemovedAllElementsTarget = ConfigManager.languageConfig.get().getString("Commands.Remove.Other.RemovedAllElements");
.getString("Commands.Remove.Other.RemovedAllElements"); this.succesfullyRemovedAllElementsTargetConfirm = ConfigManager.languageConfig.get().getString("Commands.Remove.Other.RemovedAllElementsConfirm");
this.succesfullyRemovedAllElementsTargetConfirm = ConfigManager.languageConfig.get() this.succesfullyRemovedElementTarget = ConfigManager.languageConfig.get().getString("Commands.Remove.Other.RemovedElement");
.getString("Commands.Remove.Other.RemovedAllElementsConfirm"); this.succesfullyRemovedElementTargetConfirm = ConfigManager.languageConfig.get().getString("Commands.Remove.Other.RemovedElementConfirm");
this.succesfullyRemovedElementTarget = ConfigManager.languageConfig.get()
.getString("Commands.Remove.Other.RemovedElement");
this.succesfullyRemovedElementTargetConfirm = ConfigManager.languageConfig.get()
.getString("Commands.Remove.Other.RemovedElementConfirm");
this.invalidElement = ConfigManager.languageConfig.get().getString("Commands.Remove.InvalidElement"); this.invalidElement = ConfigManager.languageConfig.get().getString("Commands.Remove.InvalidElement");
this.wrongElementSelf = ConfigManager.languageConfig.get().getString("Commands.Remove.WrongElement"); this.wrongElementSelf = ConfigManager.languageConfig.get().getString("Commands.Remove.WrongElement");
this.wrongElementTarget = ConfigManager.languageConfig.get().getString("Commands.Remove.Other.WrongElement"); this.wrongElementTarget = ConfigManager.languageConfig.get().getString("Commands.Remove.Other.WrongElement");
@ -65,12 +61,8 @@ public class RemoveCommand extends PKCommand {
senderBPlayer.getSubElements().remove(e); senderBPlayer.getSubElements().remove(e);
GeneralMethods.saveSubElements(senderBPlayer); GeneralMethods.saveSubElements(senderBPlayer);
GeneralMethods.removeUnusableAbilities(sender.getName()); GeneralMethods.removeUnusableAbilities(sender.getName());
sender.sendMessage(e.getColor() + this.succesfullyRemovedElementSelf sender.sendMessage(e.getColor() + this.succesfullyRemovedElementSelf.replace("{element}", e.getName() + e.getType().getBending()).replace("{sender}", ChatColor.DARK_AQUA + sender.getName() + e.getColor()));
.replace("{element}", e.getName() + e.getType().getBending()) Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeSubElementEvent(sender, player, (SubElement) e, com.projectkorra.projectkorra.event.PlayerChangeSubElementEvent.Result.REMOVE));
.replace("{sender}", ChatColor.DARK_AQUA + sender.getName() + e.getColor()));
Bukkit.getServer().getPluginManager()
.callEvent(new PlayerChangeSubElementEvent(sender, player, (SubElement) e,
com.projectkorra.projectkorra.event.PlayerChangeSubElementEvent.Result.REMOVE));
} else } else
sender.sendMessage(ChatColor.RED + wrongElementSelf); sender.sendMessage(ChatColor.RED + wrongElementSelf);
return; return;
@ -84,8 +76,7 @@ public class RemoveCommand extends PKCommand {
GeneralMethods.removeUnusableAbilities(sender.getName()); GeneralMethods.removeUnusableAbilities(sender.getName());
sender.sendMessage(e.getColor() + succesfullyRemovedElementSelf.replace("{element}", e.getName() + e.getType().getBending())); sender.sendMessage(e.getColor() + succesfullyRemovedElementSelf.replace("{element}", e.getName() + e.getType().getBending()));
Bukkit.getServer().getPluginManager() Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, (Player) sender, e, Result.REMOVE));
.callEvent(new PlayerChangeElementEvent(sender, (Player) sender, e, Result.REMOVE));
return; return;
} else } else
sender.sendMessage(ChatColor.RED + wrongElementSelf); sender.sendMessage(ChatColor.RED + wrongElementSelf);
@ -128,12 +119,8 @@ public class RemoveCommand extends PKCommand {
} }
GeneralMethods.removeUnusableAbilities(player.getName()); GeneralMethods.removeUnusableAbilities(player.getName());
player.sendMessage(e.getColor() player.sendMessage(e.getColor() + this.succesfullyRemovedElementTarget.replace("{element}", e.getName() + e.getType().getBending()).replace("{sender}", ChatColor.DARK_AQUA + sender.getName() + e.getColor()));
+ this.succesfullyRemovedElementTarget.replace("{element}", e.getName() + e.getType().getBending()) sender.sendMessage(e.getColor() + this.succesfullyRemovedElementTargetConfirm.replace("{element}", e.getName() + e.getType().getBending()).replace("{target}", ChatColor.DARK_AQUA + player.getName() + e.getColor()));
.replace("{sender}", ChatColor.DARK_AQUA + sender.getName() + e.getColor()));
sender.sendMessage(e.getColor()
+ this.succesfullyRemovedElementTargetConfirm.replace("{element}", e.getName() + e.getType().getBending())
.replace("{target}", ChatColor.DARK_AQUA + player.getName() + e.getColor()));
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, player, e, Result.REMOVE)); Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, player, e, Result.REMOVE));
return; return;
} }
@ -146,17 +133,15 @@ public class RemoveCommand extends PKCommand {
if (GeneralMethods.hasRPG()) if (GeneralMethods.hasRPG())
RPGMethods.revokeAvatar(bPlayer.getUUID()); RPGMethods.revokeAvatar(bPlayer.getUUID());
if (!player.getName().equalsIgnoreCase(sender.getName())) if (!player.getName().equalsIgnoreCase(sender.getName()))
sender.sendMessage(ChatColor.YELLOW + this.succesfullyRemovedAllElementsTargetConfirm.replace("{target}", sender.sendMessage(ChatColor.YELLOW + this.succesfullyRemovedAllElementsTargetConfirm.replace("{target}", ChatColor.DARK_AQUA + player.getName() + ChatColor.YELLOW));
ChatColor.DARK_AQUA + player.getName() + ChatColor.YELLOW)); player.sendMessage(ChatColor.YELLOW + this.succesfullyRemovedAllElementsTarget.replace("{sender}", ChatColor.DARK_AQUA + sender.getName() + ChatColor.YELLOW));
player.sendMessage(ChatColor.YELLOW + this.succesfullyRemovedAllElementsTarget.replace("{sender}",
ChatColor.DARK_AQUA + sender.getName() + ChatColor.YELLOW));
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, player, null, Result.REMOVE)); Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, player, null, Result.REMOVE));
} }
} }
/** /**
* Checks if the CommandSender has the permission 'bending.admin.remove'. If not, it tells them * Checks if the CommandSender has the permission 'bending.admin.remove'. If
* they don't have permission to use the command. * not, it tells them they don't have permission to use the command.
* *
* @return True if they have the permission, false otherwise * @return True if they have the permission, false otherwise
*/ */
@ -206,4 +191,4 @@ public class RemoveCommand extends PKCommand {
} }
return l; return l;
} }
} }

View file

@ -19,21 +19,22 @@ import java.util.List;
* Executor for /bending toggle. Extends {@link PKCommand}. * Executor for /bending toggle. Extends {@link PKCommand}.
*/ */
public class ToggleCommand extends PKCommand { public class ToggleCommand extends PKCommand {
private String toggledOffForAll, toggleOffSelf, toggleOnSelf, toggleOffAll, toggleOnAll, private String toggledOffForAll, toggleOffSelf, toggleOnSelf, toggleOffAll, toggleOnAll,
toggledOffSingleElement, toggledOnSingleElement, wrongElementOther, toggledOnOtherElementConfirm, toggledOffSingleElement, toggledOnSingleElement, wrongElementOther,
toggledOffOtherElementConfirm, toggledOnOtherElement, toggledOffOtherElement, wrongElement, notFound; toggledOnOtherElementConfirm, toggledOffOtherElementConfirm, toggledOnOtherElement,
toggledOffOtherElement, wrongElement, notFound;
//config.addDefault("Commands.Toggle.Other.ToggledOnElementConfirm", "You've toggled on {target}'s {element}"); //config.addDefault("Commands.Toggle.Other.ToggledOnElementConfirm", "You've toggled on {target}'s {element}");
//config.addDefault("Commands.Toggle.Other.ToggledOffElementConfirm", "You've toggled off {target}'s {element}"); //config.addDefault("Commands.Toggle.Other.ToggledOffElementConfirm", "You've toggled off {target}'s {element}");
//config.addDefault("Commands.Toggle.Other.ToggledOnElementConfirm", "Your {element} has been toggled on by {sender}."); //config.addDefault("Commands.Toggle.Other.ToggledOnElementConfirm", "Your {element} has been toggled on by {sender}.");
//config.addDefault("Commands.Toggle.Other.ToggledOffElementConfirm", "Your {element} has been toggled off by {sender}."); //config.addDefault("Commands.Toggle.Other.ToggledOffElementConfirm", "Your {element} has been toggled off by {sender}.");
public ToggleCommand() { public ToggleCommand() {
super("toggle", "/bending toggle <All/Element/Player> [Player]", ConfigManager.languageConfig.get().getString("Commands.Toggle.Description"), new String[] { "toggle", "t" }); super("toggle", "/bending toggle <All/Element/Player> [Player]", ConfigManager.languageConfig.get().getString("Commands.Toggle.Description"), new String[] { "toggle", "t" });
FileConfiguration c = ConfigManager.languageConfig.get(); FileConfiguration c = ConfigManager.languageConfig.get();
this.toggledOffForAll = c.getString("Commands.Toggle.All.ToggledOffForAll"); this.toggledOffForAll = c.getString("Commands.Toggle.All.ToggledOffForAll");
this.toggleOffSelf = c.getString("Commands.Toggle.ToggledOff"); this.toggleOffSelf = c.getString("Commands.Toggle.ToggledOff");
this.toggleOnSelf = c.getString("Commands.Toggle.ToggledOn"); this.toggleOnSelf = c.getString("Commands.Toggle.ToggledOn");
@ -74,7 +75,7 @@ public class ToggleCommand extends PKCommand {
sender.sendMessage(ChatColor.GREEN + toggleOnSelf); sender.sendMessage(ChatColor.GREEN + toggleOnSelf);
bPlayer.toggleBending(); bPlayer.toggleBending();
} }
} else if (args.size() == 1 ) { } else if (args.size() == 1) {
if (args.size() == 1 && args.get(0).equalsIgnoreCase("all") && hasPermission(sender, "all")) { //bending toggle all 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. if (Commands.isToggledForAll) { // Bending is toggled off for all players.
Commands.isToggledForAll = false; Commands.isToggledForAll = false;
@ -91,8 +92,7 @@ public class ToggleCommand extends PKCommand {
if (!(sender instanceof Player)) if (!(sender instanceof Player))
sender.sendMessage(ChatColor.RED + toggleOffAll); sender.sendMessage(ChatColor.RED + toggleOffAll);
} }
} else if (sender instanceof Player && args.size() == 1 } else if (sender instanceof Player && args.size() == 1 && Element.fromString(args.get(0)) != null) {
&& Element.fromString(args.get(0)) != null) {
if (!BendingPlayer.getBendingPlayer(sender.getName()).hasElement(Element.fromString(args.get(0)))) { if (!BendingPlayer.getBendingPlayer(sender.getName()).hasElement(Element.fromString(args.get(0)))) {
sender.sendMessage(ChatColor.RED + wrongElement); sender.sendMessage(ChatColor.RED + wrongElement);
return; return;
@ -108,10 +108,10 @@ public class ToggleCommand extends PKCommand {
sender.sendMessage(color + toggledOffSingleElement.replace("{element}", e.getName() + (e.getType() != null ? e.getType().getBending() : ""))); sender.sendMessage(color + toggledOffSingleElement.replace("{element}", e.getName() + (e.getType() != null ? e.getType().getBending() : "")));
} }
} }
} else if (sender instanceof Player && args.size() == 2 } else if (sender instanceof Player && args.size() == 2 && Element.fromString(args.get(0)) != null) {
&& Element.fromString(args.get(0)) != null) {
Player target = Bukkit.getPlayer(args.get(1)); Player target = Bukkit.getPlayer(args.get(1));
if (!hasAdminPermission(sender)) return; if (!hasAdminPermission(sender))
return;
if (target == null) { if (target == null) {
sender.sendMessage(ChatColor.RED + notFound); sender.sendMessage(ChatColor.RED + notFound);
return; return;
@ -144,10 +144,11 @@ public class ToggleCommand extends PKCommand {
} }
return true; return true;
} }
@Override @Override
protected List<String> getTabCompletion(CommandSender sender, List<String> args) { protected List<String> getTabCompletion(CommandSender sender, List<String> args) {
if (args.size() >= 2 || !sender.hasPermission("bending.command.toggle.others")) return new ArrayList<String>(); if (args.size() >= 2 || !sender.hasPermission("bending.command.toggle.others"))
return new ArrayList<String>();
List<String> l = new ArrayList<String>(); List<String> l = new ArrayList<String>();
if (args.size() == 0) { if (args.size() == 0) {
List<String> elements = new ArrayList<String>(); List<String> elements = new ArrayList<String>();

View file

@ -42,4 +42,4 @@ public class VersionCommand extends PKCommand {
sender.sendMessage(ChatColor.GREEN + "Learn More: " + ChatColor.RED + "http://projectkorra.com"); sender.sendMessage(ChatColor.GREEN + "Learn More: " + ChatColor.RED + "http://projectkorra.com");
} }
} }

View file

@ -39,47 +39,41 @@ public class WhoCommand extends PKCommand {
/** /**
* Map storage of all ProjectKorra staffs' UUIDs and titles * Map storage of all ProjectKorra staffs' UUIDs and titles
*/ */
final Map<String, String> staff = new HashMap<String, String>(), playerInfoWords = new HashMap<String, String>(); final Map<String, String> staff = new HashMap<String, String>(),
playerInfoWords = new HashMap<String, String>();
private String databaseOverload, noPlayersOnline, playerOffline; private String databaseOverload, noPlayersOnline, playerOffline;
public WhoCommand() { public WhoCommand() {
super("who", "/bending who [Page/Player]", ConfigManager.languageConfig.get().getString("Commands.Who.Description"), new String[] { "who", "w" }); super("who", "/bending who [Page/Player]", ConfigManager.languageConfig.get().getString("Commands.Who.Description"), new String[] { "who", "w" });
databaseOverload = ConfigManager.languageConfig.get().getString("Commands.Who.DatabaseOverload"); databaseOverload = ConfigManager.languageConfig.get().getString("Commands.Who.DatabaseOverload");
noPlayersOnline = ConfigManager.languageConfig.get().getString("Commands.Who.NoPlayersOnline"); noPlayersOnline = ConfigManager.languageConfig.get().getString("Commands.Who.NoPlayersOnline");
playerOffline = ConfigManager.languageConfig.get().getString("Commands.Who.PlayerOffline"); playerOffline = ConfigManager.languageConfig.get().getString("Commands.Who.PlayerOffline");
new BukkitRunnable() new BukkitRunnable() {
{ public void run() {
public void run() try {
{
try
{
staff.clear(); staff.clear();
// Create a URL for the desired page // Create a URL for the desired page
URLConnection url = new URL("http://www.projectkorra.com/staff.txt").openConnection(); URLConnection url = new URL("http://www.projectkorra.com/staff.txt").openConnection();
url.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11"); url.setRequestProperty("User-Agent", "Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.11 (KHTML, like Gecko) Chrome/23.0.1271.95 Safari/537.11");
// Read all the text returned by the server // Read all the text returned by the server
BufferedReader in = new BufferedReader(new InputStreamReader(url.getInputStream(), Charset.forName("UTF-8"))); BufferedReader in = new BufferedReader(new InputStreamReader(url.getInputStream(), Charset.forName("UTF-8")));
String unparsed; String unparsed;
while ((unparsed = in.readLine()) != null) while ((unparsed = in.readLine()) != null) {
{
String[] staffEntry = unparsed.split("/"); String[] staffEntry = unparsed.split("/");
if (staffEntry.length >= 2) if (staffEntry.length >= 2) {
{
staff.put(staffEntry[0], ChatColor.translateAlternateColorCodes('&', staffEntry[1])); staff.put(staffEntry[0], ChatColor.translateAlternateColorCodes('&', staffEntry[1]));
} }
} }
in.close(); in.close();
} }
catch (MalformedURLException e) catch (MalformedURLException e) {
{
e.printStackTrace(); e.printStackTrace();
} }
catch (IOException e) catch (IOException e) {
{
e.printStackTrace(); e.printStackTrace();
} }
} }
@ -102,7 +96,7 @@ public class WhoCommand extends PKCommand {
String playerName = player.getName(); String playerName = player.getName();
String result = ""; String result = "";
BendingPlayer bp = BendingPlayer.getBendingPlayer(playerName); BendingPlayer bp = BendingPlayer.getBendingPlayer(playerName);
if (bp == null) { if (bp == null) {
GeneralMethods.createBendingPlayer(player.getUniqueId(), player.getName()); GeneralMethods.createBendingPlayer(player.getUniqueId(), player.getName());
bp = BendingPlayer.getBendingPlayer(player.getName()); bp = BendingPlayer.getBendingPlayer(player.getName());
@ -139,10 +133,8 @@ public class WhoCommand extends PKCommand {
/** /**
* Sends information on the given player to the CommandSender. * Sends information on the given player to the CommandSender.
* *
* @param sender * @param sender The CommandSender to display the information to
* The CommandSender to display the information to * @param playerName The Player to look up
* @param playerName
* The Player to look up
*/ */
private void whoPlayer(final CommandSender sender, final String playerName) { private void whoPlayer(final CommandSender sender, final String playerName) {
//Player player = Bukkit.getPlayer(playerName); //Player player = Bukkit.getPlayer(playerName);
@ -153,10 +145,9 @@ public class WhoCommand extends PKCommand {
return; return;
} }
if (!player.isOnline() && !BendingPlayer.getPlayers().containsKey(player.getUniqueId())) { if (!player.isOnline() && !BendingPlayer.getPlayers().containsKey(player.getUniqueId())) {
sender.sendMessage(ChatColor.GRAY + playerOffline.replace("{player}", ChatColor.WHITE + player.getName() + ChatColor.GRAY) sender.sendMessage(ChatColor.GRAY + playerOffline.replace("{player}", ChatColor.WHITE + player.getName() + ChatColor.GRAY).replace("{target}", ChatColor.WHITE + player.getName() + ChatColor.GRAY));
.replace("{target}", ChatColor.WHITE + player.getName() + ChatColor.GRAY));
} }
Player player_ = (Player) (player.isOnline() ? player : null); Player player_ = (Player) (player.isOnline() ? player : null);
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
@ -188,17 +179,17 @@ public class WhoCommand extends PKCommand {
runnable.runTaskAsynchronously(ProjectKorra.plugin); runnable.runTaskAsynchronously(ProjectKorra.plugin);
return; return;
} }
bPlayer = BendingPlayer.getBendingPlayer(player); bPlayer = BendingPlayer.getBendingPlayer(player);
if (bPlayer != null) { if (bPlayer != null) {
sender.sendMessage(player.getName() + (!player.isOnline() ? ChatColor.RESET + " (Offline)" : "") + " - "); sender.sendMessage(player.getName() + (!player.isOnline() ? ChatColor.RESET + " (Offline)" : "") + " - ");
if (bPlayer.hasElement(Element.AIR)) { if (bPlayer.hasElement(Element.AIR)) {
if(bPlayer.isElementToggled(Element.AIR)) { if (bPlayer.isElementToggled(Element.AIR)) {
sender.sendMessage(Element.AIR.getColor() + "- Airbender"); sender.sendMessage(Element.AIR.getColor() + "- Airbender");
} else { } else {
sender.sendMessage(Element.AIR.getColor() + "" + ChatColor.STRIKETHROUGH + "- Airbender"); sender.sendMessage(Element.AIR.getColor() + "" + ChatColor.STRIKETHROUGH + "- Airbender");
} }
if (player_ != null) { if (player_ != null) {
if (bPlayer.canUseFlight()) { if (bPlayer.canUseFlight()) {
sender.sendMessage(Element.FLIGHT.getColor() + " Can Fly"); sender.sendMessage(Element.FLIGHT.getColor() + " Can Fly");
@ -214,12 +205,12 @@ public class WhoCommand extends PKCommand {
} }
} }
if (bPlayer.hasElement(Element.WATER)) { if (bPlayer.hasElement(Element.WATER)) {
if(bPlayer.isElementToggled(Element.WATER)) { if (bPlayer.isElementToggled(Element.WATER)) {
sender.sendMessage(Element.WATER.getColor() + "- Waterbender"); sender.sendMessage(Element.WATER.getColor() + "- Waterbender");
} else { } else {
sender.sendMessage(Element.WATER.getColor() + "" + ChatColor.STRIKETHROUGH + "- Waterbender"); sender.sendMessage(Element.WATER.getColor() + "" + ChatColor.STRIKETHROUGH + "- Waterbender");
} }
if (player_ != null) { if (player_ != null) {
if (bPlayer.canPlantbend()) { if (bPlayer.canPlantbend()) {
sender.sendMessage(Element.PLANT.getColor() + " Can Plantbend"); sender.sendMessage(Element.PLANT.getColor() + " Can Plantbend");
@ -245,12 +236,12 @@ public class WhoCommand extends PKCommand {
} }
} }
if (bPlayer.hasElement(Element.EARTH)) { if (bPlayer.hasElement(Element.EARTH)) {
if(bPlayer.isElementToggled(Element.EARTH)) { if (bPlayer.isElementToggled(Element.EARTH)) {
sender.sendMessage(Element.EARTH.getColor() + "- Earthbender"); sender.sendMessage(Element.EARTH.getColor() + "- Earthbender");
} else { } else {
sender.sendMessage(Element.EARTH.getColor() + "" + ChatColor.STRIKETHROUGH + "- Earthbender"); sender.sendMessage(Element.EARTH.getColor() + "" + ChatColor.STRIKETHROUGH + "- Earthbender");
} }
if (player_ != null) { if (player_ != null) {
if (bPlayer.canMetalbend()) { if (bPlayer.canMetalbend()) {
sender.sendMessage(Element.METAL.getColor() + " Can Metalbend"); sender.sendMessage(Element.METAL.getColor() + " Can Metalbend");
@ -269,12 +260,12 @@ public class WhoCommand extends PKCommand {
} }
} }
if (bPlayer.hasElement(Element.FIRE)) { if (bPlayer.hasElement(Element.FIRE)) {
if(bPlayer.isElementToggled(Element.FIRE)) { if (bPlayer.isElementToggled(Element.FIRE)) {
sender.sendMessage(Element.FIRE.getColor() + "- Firebender"); sender.sendMessage(Element.FIRE.getColor() + "- Firebender");
} else { } else {
sender.sendMessage(Element.FIRE.getColor() + "" + ChatColor.STRIKETHROUGH + "- Firebender"); sender.sendMessage(Element.FIRE.getColor() + "" + ChatColor.STRIKETHROUGH + "- Firebender");
} }
if (player_ != null) { if (player_ != null) {
if (bPlayer.canCombustionbend()) { if (bPlayer.canCombustionbend()) {
sender.sendMessage(Element.COMBUSTION.getColor() + " Can Combustionbend"); sender.sendMessage(Element.COMBUSTION.getColor() + " Can Combustionbend");
@ -290,7 +281,7 @@ public class WhoCommand extends PKCommand {
} }
} }
if (bPlayer.hasElement(Element.CHI)) { if (bPlayer.hasElement(Element.CHI)) {
if(bPlayer.isElementToggled(Element.CHI)) { if (bPlayer.isElementToggled(Element.CHI)) {
sender.sendMessage(Element.CHI.getColor() + "- Chiblocker"); sender.sendMessage(Element.CHI.getColor() + "- Chiblocker");
} else { } else {
sender.sendMessage(Element.CHI.getColor() + "" + ChatColor.STRIKETHROUGH + "- Chiblocker"); sender.sendMessage(Element.CHI.getColor() + "" + ChatColor.STRIKETHROUGH + "- Chiblocker");
@ -320,7 +311,7 @@ public class WhoCommand extends PKCommand {
} }
} }
} }
UUID uuid = player.getUniqueId(); UUID uuid = player.getUniqueId();
if (bPlayer != null) { if (bPlayer != null) {
sender.sendMessage("Abilities: "); sender.sendMessage("Abilities: ");
@ -347,12 +338,13 @@ public class WhoCommand extends PKCommand {
sender.sendMessage(staff.get(uuid.toString())); sender.sendMessage(staff.get(uuid.toString()));
} }
} }
} }
@Override @Override
protected List<String> getTabCompletion(CommandSender sender, List<String> args) { protected List<String> getTabCompletion(CommandSender sender, List<String> args) {
if (args.size() >= 1 || !sender.hasPermission("bending.command.who")) return new ArrayList<String>(); if (args.size() >= 1 || !sender.hasPermission("bending.command.who"))
return new ArrayList<String>();
List<String> l = new ArrayList<String>(); List<String> l = new ArrayList<String>();
for (Player p : Bukkit.getOnlinePlayers()) { for (Player p : Bukkit.getOnlinePlayers()) {
l.add(p.getName()); l.add(p.getName());

View file

@ -303,7 +303,7 @@ public class ConfigManager {
config.addDefault("Abilities.Water.Combo.IceBullet.DeathMessage", "{victim}'s heart was frozen by {attacker}'s {ability}"); config.addDefault("Abilities.Water.Combo.IceBullet.DeathMessage", "{victim}'s heart was frozen by {attacker}'s {ability}");
config.addDefault("Abilities.Water.Combo.IceWave.Description", "PhaseChange your WaterWave into an IceWave that freezes and damages enemies."); config.addDefault("Abilities.Water.Combo.IceWave.Description", "PhaseChange your WaterWave into an IceWave that freezes and damages enemies.");
config.addDefault("Abilities.Water.Combo.IceWave.DeathMessage", "{victim} was frozen solid by {attacker}'s {ability}"); config.addDefault("Abilities.Water.Combo.IceWave.DeathMessage", "{victim} was frozen solid by {attacker}'s {ability}");
config.addDefault("Abilities.Water.Passive.FastSwim.Description", "FastSwim is a passive ability for waterbenders allowing them to travel quickly through the water. Simple hold shift while underwater to propell yourself forward."); config.addDefault("Abilities.Water.Passive.FastSwim.Description", "FastSwim is a passive ability for waterbenders allowing them to travel quickly through the water. Simple hold shift while underwater to propel yourself forward.");
config.addDefault("Abilities.Water.Passive.Hydrosink.Description", "Hydrosink is a passive ability for waterbenders enabling them to softly land on any waterbendable surface, cancelling all damage."); config.addDefault("Abilities.Water.Passive.Hydrosink.Description", "Hydrosink is a passive ability for waterbenders enabling them to softly land on any waterbendable surface, cancelling all damage.");
config.addDefault("Commands.Help.Elements.Earth", "Earth is the element of substance. Earthbenders share many of the same fundamental techniques as Waterbenders, but their domain is quite different and more readily accessible. Earthbenders dominate the ground and subterranean, having abilities to pull columns of rock straight up from the earth or drill their way through the mountain. They can also launch themselves through the air using pillars of rock, and will not hurt themselves assuming they land on something they can bend. The more skilled Earthbenders can even bend metal."); config.addDefault("Commands.Help.Elements.Earth", "Earth is the element of substance. Earthbenders share many of the same fundamental techniques as Waterbenders, but their domain is quite different and more readily accessible. Earthbenders dominate the ground and subterranean, having abilities to pull columns of rock straight up from the earth or drill their way through the mountain. They can also launch themselves through the air using pillars of rock, and will not hurt themselves assuming they land on something they can bend. The more skilled Earthbenders can even bend metal.");
@ -394,7 +394,7 @@ public class ConfigManager {
config.addDefault("Abilities.Chi.Passive.ChiAgility.Description", "ChiAgility is a passive ability which enables chiblockers to run faster and jump higher."); config.addDefault("Abilities.Chi.Passive.ChiAgility.Description", "ChiAgility is a passive ability which enables chiblockers to run faster and jump higher.");
config.addDefault("Abilities.Chi.Passive.ChiSaturation.Description", "ChiSaturation is a passive ability which causes chiblockers' hunger to deplete at a slower rate."); config.addDefault("Abilities.Chi.Passive.ChiSaturation.Description", "ChiSaturation is a passive ability which causes chiblockers' hunger to deplete at a slower rate.");
config.addDefault("Abilities.Chi.Passive.Acrobatics.Description", "Acrobatics is a passive ability which negates all fall damage based on a percent chance."); config.addDefault("Abilities.Chi.Passive.Acrobatics.Description", "Acrobatics is a passive ability which negates all fall damage based on a percent chance.");
languageConfig.save(); languageConfig.save();
} else if (type == ConfigType.DEFAULT) { } else if (type == ConfigType.DEFAULT) {
config = defaultConfig.get(); config = defaultConfig.get();
@ -532,7 +532,7 @@ public class ConfigManager {
config.addDefault("Abilities.Avatar.AvatarState.PotionEffects.DamageResistance.Power", 3); config.addDefault("Abilities.Avatar.AvatarState.PotionEffects.DamageResistance.Power", 3);
config.addDefault("Abilities.Avatar.AvatarState.PotionEffects.FireResistance.Enabled", true); config.addDefault("Abilities.Avatar.AvatarState.PotionEffects.FireResistance.Enabled", true);
config.addDefault("Abilities.Avatar.AvatarState.PotionEffects.FireResistance.Power", 3); config.addDefault("Abilities.Avatar.AvatarState.PotionEffects.FireResistance.Power", 3);
config.addDefault("Abilities.Avatar.AvatarState.Air.AirBlast.Push.Entities", 4.5); config.addDefault("Abilities.Avatar.AvatarState.Air.AirBlast.Push.Entities", 4.5);
config.addDefault("Abilities.Avatar.AvatarState.Air.AirBlast.Push.Self", 4.0); config.addDefault("Abilities.Avatar.AvatarState.Air.AirBlast.Push.Self", 4.0);
config.addDefault("Abilities.Avatar.AvatarState.AirSpout.Height", 26); config.addDefault("Abilities.Avatar.AvatarState.AirSpout.Height", 26);
@ -547,7 +547,7 @@ public class ConfigManager {
config.addDefault("Abilities.Avatar.AvatarState.Air.Suffocate.ChargeTime", 1000); config.addDefault("Abilities.Avatar.AvatarState.Air.Suffocate.ChargeTime", 1000);
config.addDefault("Abilities.Avatar.AvatarState.Air.Suffocate.Damage", 3); config.addDefault("Abilities.Avatar.AvatarState.Air.Suffocate.Damage", 3);
config.addDefault("Abilities.Avatar.AvatarState.Air.Suffocate.Range", 16); config.addDefault("Abilities.Avatar.AvatarState.Air.Suffocate.Range", 16);
config.addDefault("Abilities.Avatar.AvatarState.Earth.Catapult.Length", 10); config.addDefault("Abilities.Avatar.AvatarState.Earth.Catapult.Length", 10);
config.addDefault("Abilities.Avatar.AvatarState.Earth.Catapult.Push", 8); config.addDefault("Abilities.Avatar.AvatarState.Earth.Catapult.Push", 8);
config.addDefault("Abilities.Avatar.AvatarState.Earth.Catapult.Cooldown", 0); config.addDefault("Abilities.Avatar.AvatarState.Earth.Catapult.Cooldown", 0);
@ -585,8 +585,7 @@ public class ConfigManager {
config.addDefault("Abilities.Avatar.AvatarState.Earth.EarthSmash.FlightTimer", 10000); config.addDefault("Abilities.Avatar.AvatarState.Earth.EarthSmash.FlightTimer", 10000);
config.addDefault("Abilities.Avatar.AvatarState.Earth.EarthSmash.ShootRange", 30); config.addDefault("Abilities.Avatar.AvatarState.Earth.EarthSmash.ShootRange", 30);
config.addDefault("Abilities.Avatar.AvatarState.Earth.EarthTunnel.Radius", 0.05); config.addDefault("Abilities.Avatar.AvatarState.Earth.EarthTunnel.Radius", 0.05);
config.addDefault("Abilities.Avatar.AvatarState.Fire.Blaze.Ring.Range", 14); config.addDefault("Abilities.Avatar.AvatarState.Fire.Blaze.Ring.Range", 14);
config.addDefault("Abilities.Avatar.AvatarState.Fire.FireJet.IsAvatarStateToggle", true); config.addDefault("Abilities.Avatar.AvatarState.Fire.FireJet.IsAvatarStateToggle", true);
config.addDefault("Abilities.Avatar.AvatarState.Fire.Lightning.ChargeTime", 1500); config.addDefault("Abilities.Avatar.AvatarState.Fire.Lightning.ChargeTime", 1500);
@ -597,7 +596,7 @@ public class ConfigManager {
config.addDefault("Abilities.Avatar.AvatarState.Fire.FireBurst.Cooldown", 0); config.addDefault("Abilities.Avatar.AvatarState.Fire.FireBurst.Cooldown", 0);
config.addDefault("Abilities.Avatar.AvatarState.Fire.FireBlast.Charged.ChargeTime", 1500); config.addDefault("Abilities.Avatar.AvatarState.Fire.FireBlast.Charged.ChargeTime", 1500);
config.addDefault("Abilities.Avatar.AvatarState.Fire.FireBlast.Charged.Damage", 5); config.addDefault("Abilities.Avatar.AvatarState.Fire.FireBlast.Charged.Damage", 5);
config.addDefault("Abilities.Avatar.AvatarState.Water.Surge.Wall.Radius", 4); config.addDefault("Abilities.Avatar.AvatarState.Water.Surge.Wall.Radius", 4);
config.addDefault("Abilities.Avatar.AvatarState.Water.Surge.Wave.Radius", 20); config.addDefault("Abilities.Avatar.AvatarState.Water.Surge.Wave.Radius", 20);
config.addDefault("Abilities.Avatar.AvatarState.Water.WaterManipulation.Damage", 5); config.addDefault("Abilities.Avatar.AvatarState.Water.WaterManipulation.Damage", 5);

View file

@ -6,21 +6,21 @@ import java.util.HashMap;
import java.util.List; import java.util.List;
public class ConfigType { public class ConfigType {
private static final HashMap<String, ConfigType> ALL_TYPES = new HashMap<>(); private static final HashMap<String, ConfigType> ALL_TYPES = new HashMap<>();
public static final ConfigType DEFAULT = new ConfigType("Default"); public static final ConfigType DEFAULT = new ConfigType("Default");
public static final ConfigType PRESETS = new ConfigType("Presets"); public static final ConfigType PRESETS = new ConfigType("Presets");
public static final ConfigType LANGUAGE = new ConfigType("Language"); public static final ConfigType LANGUAGE = new ConfigType("Language");
public static final ConfigType[] CORE_TYPES = {DEFAULT, PRESETS, LANGUAGE}; public static final ConfigType[] CORE_TYPES = { DEFAULT, PRESETS, LANGUAGE };
private String string; private String string;
public ConfigType(String string) { public ConfigType(String string) {
this.string = string; this.string = string;
ALL_TYPES.put(string, this); ALL_TYPES.put(string, this);
} }
public static List<ConfigType> addonValues() { public static List<ConfigType> addonValues() {
List<ConfigType> values = new ArrayList<>(); List<ConfigType> values = new ArrayList<>();
for (String key : ALL_TYPES.keySet()) { for (String key : ALL_TYPES.keySet()) {
@ -30,15 +30,15 @@ public class ConfigType {
} }
return values; return values;
} }
public static List<ConfigType> coreValues() { public static List<ConfigType> coreValues() {
return Arrays.asList(CORE_TYPES); return Arrays.asList(CORE_TYPES);
} }
public String toString() { public String toString() {
return string; return string;
} }
public static List<ConfigType> values() { public static List<ConfigType> values() {
List<ConfigType> values = new ArrayList<>(); List<ConfigType> values = new ArrayList<>();
for (String key : ALL_TYPES.keySet()) { for (String key : ALL_TYPES.keySet()) {

View file

@ -22,13 +22,13 @@ public class Catapult extends EarthAbility {
private Location origin; private Location origin;
private Location location; private Location location;
private Vector direction; private Vector direction;
public Catapult(Player player) { public Catapult(Player player) {
super(player); super(player);
setFields(); setFields();
this.origin = player.getEyeLocation().clone(); this.origin = player.getEyeLocation().clone();
this.direction = origin.getDirection().clone().normalize(); this.direction = origin.getDirection().clone().normalize();
if (!bPlayer.canBend(this)) { if (!bPlayer.canBend(this)) {
return; return;
} }
@ -36,7 +36,7 @@ public class Catapult extends EarthAbility {
Vector neg = direction.clone().multiply(-1); Vector neg = direction.clone().multiply(-1);
Block block; Block block;
distance = 0; distance = 0;
for (int i = 0; i <= length; i++) { for (int i = 0; i <= length; i++) {
location = origin.clone().add(neg.clone().multiply((double) i)); location = origin.clone().add(neg.clone().multiply((double) i));
block = location.getBlock(); block = location.getBlock();
@ -57,12 +57,12 @@ public class Catapult extends EarthAbility {
} }
moving = true; moving = true;
if (bPlayer.isAvatarState()) { if (bPlayer.isAvatarState()) {
this.length = getConfig().getInt("Abilities.Avatar.AvatarState.Earth.Catapult.Length"); this.length = getConfig().getInt("Abilities.Avatar.AvatarState.Earth.Catapult.Length");
this.push = getConfig().getDouble("Abilities.Avatar.AvatarState.Earth.Catapult.Push"); this.push = getConfig().getDouble("Abilities.Avatar.AvatarState.Earth.Catapult.Push");
this.cooldown = getConfig().getLong("Abilities.Avatar.AvatarState.Earth.Catapult.Cooldown"); this.cooldown = getConfig().getLong("Abilities.Avatar.AvatarState.Earth.Catapult.Cooldown");
} }
start(); start();
bPlayer.addCooldown(this); bPlayer.addCooldown(this);
@ -82,7 +82,7 @@ public class Catapult extends EarthAbility {
playEarthbendingSound(player.getLocation()); playEarthbendingSound(player.getLocation());
fly(); fly();
} }
private void setFields() { private void setFields() {
this.length = getConfig().getInt("Abilities.Earth.Catapult.Length"); this.length = getConfig().getInt("Abilities.Earth.Catapult.Length");
this.push = getConfig().getDouble("Abilities.Earth.Catapult.Push"); this.push = getConfig().getDouble("Abilities.Earth.Catapult.Push");
@ -114,7 +114,7 @@ public class Catapult extends EarthAbility {
return; return;
} }
} }
Vector vector = direction.clone().multiply(push * distance / length); Vector vector = direction.clone().multiply(push * distance / length);
vector.setY(player.getVelocity().getY()); vector.setY(player.getVelocity().getY());
player.setVelocity(vector); player.setVelocity(vector);
@ -184,7 +184,7 @@ public class Catapult extends EarthAbility {
public long getCooldown() { public long getCooldown() {
return cooldown; return cooldown;
} }
@Override @Override
public boolean isSneakAbility() { public boolean isSneakAbility() {
return false; return false;
@ -266,5 +266,5 @@ public class Catapult extends EarthAbility {
public void setCooldown(long cooldown) { public void setCooldown(long cooldown) {
this.cooldown = cooldown; this.cooldown = cooldown;
} }
} }

View file

@ -23,10 +23,10 @@ public class CollapseWall extends EarthAbility {
private Location location; private Location location;
private Map<Block, Block> blocks; private Map<Block, Block> blocks;
private Map<Block, Integer> baseBlocks; private Map<Block, Integer> baseBlocks;
public CollapseWall(Player player) { public CollapseWall(Player player) {
super(player); super(player);
if (!bPlayer.canBend(this) || bPlayer.isOnCooldown("CollapseWall")) { if (!bPlayer.canBend(this) || bPlayer.isOnCooldown("CollapseWall")) {
return; return;
} }
@ -47,7 +47,7 @@ public class CollapseWall extends EarthAbility {
} else { } else {
location = sblock.getLocation(); location = sblock.getLocation();
} }
for (Block block : GeneralMethods.getBlocksAroundPoint(location, radius)) { for (Block block : GeneralMethods.getBlocksAroundPoint(location, radius)) {
if (isEarthbendable(block) && !blocks.containsKey(block) && block.getY() >= location.getBlockY()) { if (isEarthbendable(block) && !blocks.containsKey(block) && block.getY() >= location.getBlockY()) {
getAffectedBlocks(block); getAffectedBlocks(block);
@ -78,7 +78,7 @@ public class CollapseWall extends EarthAbility {
break; break;
} }
} }
baseBlocks.put(baseBlock, tall); baseBlocks.put(baseBlock, tall);
for (Block blocki : bendableBlocks) { for (Block blocki : bendableBlocks) {
blocks.put(blocki, baseBlock); blocks.put(blocki, baseBlock);
@ -91,7 +91,8 @@ public class CollapseWall extends EarthAbility {
} }
@Override @Override
public void progress() {} public void progress() {
}
@Override @Override
public Location getLocation() { public Location getLocation() {
@ -102,7 +103,7 @@ public class CollapseWall extends EarthAbility {
public long getCooldown() { public long getCooldown() {
return cooldown; return cooldown;
} }
@Override @Override
public boolean isSneakAbility() { public boolean isSneakAbility() {
return true; return true;

View file

@ -39,13 +39,13 @@ public class EarthArmor extends EarthAbility {
private PotionEffect oldAbsorbtion = null; private PotionEffect oldAbsorbtion = null;
private float goldHearts; private float goldHearts;
private int maxGoldHearts; private int maxGoldHearts;
public EarthArmor(Player player) { public EarthArmor(Player player) {
super(player); super(player);
if (hasAbility(player, EarthArmor.class) || !bPlayer.canBend(this)) { if (hasAbility(player, EarthArmor.class) || !bPlayer.canBend(this)) {
return; return;
} }
this.formed = false; this.formed = false;
this.active = true; this.active = true;
this.interval = 2000; this.interval = 2000;
@ -54,15 +54,14 @@ public class EarthArmor extends EarthAbility {
this.maxDuration = getConfig().getLong("Abilities.Earth.EarthArmor.MaxDuration"); this.maxDuration = getConfig().getLong("Abilities.Earth.EarthArmor.MaxDuration");
this.selectRange = getConfig().getDouble("Abilities.Earth.EarthArmor.SelectRange"); this.selectRange = getConfig().getDouble("Abilities.Earth.EarthArmor.SelectRange");
this.maxGoldHearts = getConfig().getInt("Abilities.Earth.EarthArmor.GoldHearts"); this.maxGoldHearts = getConfig().getInt("Abilities.Earth.EarthArmor.GoldHearts");
if (bPlayer.isAvatarState()) { if (bPlayer.isAvatarState()) {
this.cooldown = getConfig().getLong("Abilities.Avatar.AvatarState.Earth.EarthArmor.Cooldown"); this.cooldown = getConfig().getLong("Abilities.Avatar.AvatarState.Earth.EarthArmor.Cooldown");
this.maxGoldHearts = getConfig().getInt("Abilities.Avatar.AvatarState.Earth.EarthArmor.GoldHearts"); this.maxGoldHearts = getConfig().getInt("Abilities.Avatar.AvatarState.Earth.EarthArmor.GoldHearts");
} }
headBlock = getTargetEarthBlock((int) selectRange); headBlock = getTargetEarthBlock((int) selectRange);
if (!GeneralMethods.isRegionProtectedFromBuild(this, headBlock.getLocation()) if (!GeneralMethods.isRegionProtectedFromBuild(this, headBlock.getLocation()) && getEarthbendableBlocksLength(headBlock, new Vector(0, -1, 0), 2) >= 2) {
&& getEarthbendableBlocksLength(headBlock, new Vector(0, -1, 0), 2) >= 2) {
this.legsBlock = headBlock.getRelative(BlockFace.DOWN); this.legsBlock = headBlock.getRelative(BlockFace.DOWN);
this.headData = headBlock.getState().getData(); this.headData = headBlock.getState().getData();
this.legsData = legsBlock.getState().getData(); this.legsData = legsBlock.getState().getData();
@ -82,10 +81,10 @@ public class EarthArmor extends EarthAbility {
GeneralMethods.removeBlock(oldHeadBlock); GeneralMethods.removeBlock(oldHeadBlock);
GeneralMethods.removeBlock(oldLegsBlock); GeneralMethods.removeBlock(oldLegsBlock);
} }
playEarthbendingSound(headBlock.getLocation()); playEarthbendingSound(headBlock.getLocation());
bPlayer.addCooldown(this, getCooldown() / 2); //Prevents spamming of the move to remove blocks bPlayer.addCooldown(this, getCooldown() / 2); //Prevents spamming of the move to remove blocks
start(); start();
} }
} }
@ -98,32 +97,32 @@ public class EarthArmor extends EarthAbility {
if (TempBlock.isTempBlock(legsBlock)) { if (TempBlock.isTempBlock(legsBlock)) {
TempBlock.revertBlock(legsBlock, Material.AIR); TempBlock.revertBlock(legsBlock, Material.AIR);
} }
ItemStack head = new ItemStack(Material.LEATHER_HELMET, 1); ItemStack head = new ItemStack(Material.LEATHER_HELMET, 1);
ItemStack chestplate = new ItemStack(Material.LEATHER_CHESTPLATE, 1); ItemStack chestplate = new ItemStack(Material.LEATHER_CHESTPLATE, 1);
ItemStack leggings = new ItemStack(Material.LEATHER_LEGGINGS, 1); ItemStack leggings = new ItemStack(Material.LEATHER_LEGGINGS, 1);
ItemStack boots = new ItemStack(Material.LEATHER_BOOTS, 1); ItemStack boots = new ItemStack(Material.LEATHER_BOOTS, 1);
LeatherArmorMeta metaHead = (LeatherArmorMeta) head.getItemMeta(); LeatherArmorMeta metaHead = (LeatherArmorMeta) head.getItemMeta();
LeatherArmorMeta metaChest = (LeatherArmorMeta) chestplate.getItemMeta(); LeatherArmorMeta metaChest = (LeatherArmorMeta) chestplate.getItemMeta();
LeatherArmorMeta metaLegs = (LeatherArmorMeta) leggings.getItemMeta(); LeatherArmorMeta metaLegs = (LeatherArmorMeta) leggings.getItemMeta();
LeatherArmorMeta metaBottom = (LeatherArmorMeta) boots.getItemMeta(); LeatherArmorMeta metaBottom = (LeatherArmorMeta) boots.getItemMeta();
metaHead.setColor(Color.fromRGB(getColor(headData.getItemType(), headData.getData()))); metaHead.setColor(Color.fromRGB(getColor(headData.getItemType(), headData.getData())));
metaChest.setColor(Color.fromRGB(getColor(headData.getItemType(), headData.getData()))); metaChest.setColor(Color.fromRGB(getColor(headData.getItemType(), headData.getData())));
metaLegs.setColor(Color.fromRGB(getColor(legsData.getItemType(), legsData.getData()))); metaLegs.setColor(Color.fromRGB(getColor(legsData.getItemType(), legsData.getData())));
metaBottom.setColor(Color.fromRGB(getColor(legsData.getItemType(), legsData.getData()))); metaBottom.setColor(Color.fromRGB(getColor(legsData.getItemType(), legsData.getData())));
head.setItemMeta(metaHead); head.setItemMeta(metaHead);
chestplate.setItemMeta(metaChest); chestplate.setItemMeta(metaChest);
leggings.setItemMeta(metaLegs); leggings.setItemMeta(metaLegs);
boots.setItemMeta(metaBottom); boots.setItemMeta(metaBottom);
ItemStack armors[] = { boots, leggings, chestplate, head }; ItemStack armors[] = { boots, leggings, chestplate, head };
TempArmor armor = new TempArmor(player, 72000000L, this, armors); //Duration of 2 hours TempArmor armor = new TempArmor(player, 72000000L, this, armors); //Duration of 2 hours
armor.setRemovesAbilityOnForceRevert(true); armor.setRemovesAbilityOnForceRevert(true);
formed = true; formed = true;
for (PotionEffect effect : player.getActivePotionEffects()) { for (PotionEffect effect : player.getActivePotionEffects()) {
if (effect.getType() == PotionEffectType.ABSORPTION) { if (effect.getType() == PotionEffectType.ABSORPTION) {
this.oldAbsorbtion = effect; this.oldAbsorbtion = effect;
@ -133,11 +132,11 @@ public class EarthArmor extends EarthAbility {
} }
int level = (int) (maxGoldHearts / 2 - 1 + (maxGoldHearts % 2)); int level = (int) (maxGoldHearts / 2 - 1 + (maxGoldHearts % 2));
player.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION, Integer.MAX_VALUE, level, true, false)); player.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION, Integer.MAX_VALUE, level, true, false));
this.goldHearts = maxGoldHearts * 2; this.goldHearts = maxGoldHearts * 2;
GeneralMethods.setAbsorbationHealth(player, goldHearts); GeneralMethods.setAbsorbationHealth(player, goldHearts);
} }
private boolean inPosition() { private boolean inPosition() {
return headBlock.equals(player.getEyeLocation().getBlock()) && legsBlock.equals(player.getLocation().getBlock()); return headBlock.equals(player.getEyeLocation().getBlock()) && legsBlock.equals(player.getLocation().getBlock());
} }
@ -148,22 +147,22 @@ public class EarthArmor extends EarthAbility {
remove(); remove();
return false; return false;
} }
Location headLocation = player.getEyeLocation(); Location headLocation = player.getEyeLocation();
Location legsLocation = player.getLocation(); Location legsLocation = player.getLocation();
Vector headDirection = headLocation.toVector().subtract(headBlockLocation.toVector()).normalize().multiply(.5); Vector headDirection = headLocation.toVector().subtract(headBlockLocation.toVector()).normalize().multiply(.5);
//Vector legsDirection = legsLocation.toVector().subtract(legsBlockLocation.toVector()).normalize().multiply(.5); //Vector legsDirection = legsLocation.toVector().subtract(legsBlockLocation.toVector()).normalize().multiply(.5);
Block newHeadBlock = headBlock; Block newHeadBlock = headBlock;
Block newLegsBlock = legsBlock; Block newLegsBlock = legsBlock;
int yDiff = player.getEyeLocation().getBlockY() - headBlock.getY(); int yDiff = player.getEyeLocation().getBlockY() - headBlock.getY();
if (yDiff != 0) { if (yDiff != 0) {
Block checkBlock = yDiff > 0 ? headBlock.getRelative(BlockFace.UP) : legsBlock.getRelative(BlockFace.DOWN); Block checkBlock = yDiff > 0 ? headBlock.getRelative(BlockFace.UP) : legsBlock.getRelative(BlockFace.DOWN);
if (isTransparent(checkBlock) && !checkBlock.isLiquid()) { if (isTransparent(checkBlock) && !checkBlock.isLiquid()) {
GeneralMethods.breakBlock(checkBlock); //Destroy any minor blocks that are in the way GeneralMethods.breakBlock(checkBlock); //Destroy any minor blocks that are in the way
headDirection = new Vector(0, yDiff > 0 ? 0.5 : -0.5, 0); headDirection = new Vector(0, yDiff > 0 ? 0.5 : -0.5, 0);
} }
} }
@ -219,20 +218,20 @@ public class EarthArmor extends EarthAbility {
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
@Override @Override
public void progress() { public void progress() {
if (!bPlayer.canBendIgnoreBindsCooldowns(this)) { if (!bPlayer.canBendIgnoreBindsCooldowns(this)) {
remove(); remove();
return; return;
} }
if (System.currentTimeMillis() - getStartTime() > maxDuration) { if (System.currentTimeMillis() - getStartTime() > maxDuration) {
player.getLocation().getWorld().playSound(player.getLocation(), Sound.BLOCK_STONE_BREAK, 2, 1); player.getLocation().getWorld().playSound(player.getLocation(), Sound.BLOCK_STONE_BREAK, 2, 1);
player.getLocation().getWorld().playSound(player.getLocation(), Sound.BLOCK_STONE_BREAK, 2, 1); player.getLocation().getWorld().playSound(player.getLocation(), Sound.BLOCK_STONE_BREAK, 2, 1);
player.getLocation().getWorld().playSound(player.getLocation(), Sound.BLOCK_STONE_BREAK, 2, 1); player.getLocation().getWorld().playSound(player.getLocation(), Sound.BLOCK_STONE_BREAK, 2, 1);
ParticleEffect.BLOCK_CRACK.display(new ParticleEffect.BlockData(headData.getItemType(), headData.getData()), 0.1F, 0.1F, 0.1F, 1, 32, player.getEyeLocation(), 128); ParticleEffect.BLOCK_CRACK.display(new ParticleEffect.BlockData(headData.getItemType(), headData.getData()), 0.1F, 0.1F, 0.1F, 1, 32, player.getEyeLocation(), 128);
ParticleEffect.BLOCK_CRACK.display(new ParticleEffect.BlockData(legsData.getItemType(), legsData.getData()), 0.1F, 0.1F, 0.1F, 1, 32, player.getLocation(), 128); ParticleEffect.BLOCK_CRACK.display(new ParticleEffect.BlockData(legsData.getItemType(), legsData.getData()), 0.1F, 0.1F, 0.1F, 1, 32, player.getLocation(), 128);
bPlayer.addCooldown(this); bPlayer.addCooldown(this);
remove(); remove();
remove(); remove();
@ -245,13 +244,13 @@ public class EarthArmor extends EarthAbility {
player.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION, Integer.MAX_VALUE, 1, true, false)); player.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION, Integer.MAX_VALUE, 1, true, false));
GeneralMethods.setAbsorbationHealth(player, goldHearts); GeneralMethods.setAbsorbationHealth(player, goldHearts);
} }
if (!active) { if (!active) {
bPlayer.addCooldown(this); bPlayer.addCooldown(this);
remove(); remove();
return; return;
} }
player.setFireTicks(0); player.setFireTicks(0);
} else { } else {
if (!moveBlocks()) { if (!moveBlocks()) {
@ -277,17 +276,17 @@ public class EarthArmor extends EarthAbility {
headBlock.breakNaturally(); headBlock.breakNaturally();
legsBlock.breakNaturally(); legsBlock.breakNaturally();
} }
if (TempArmor.hasTempArmor(player) && TempArmor.getTempArmor(player).getAbility().equals(this)) { if (TempArmor.hasTempArmor(player) && TempArmor.getTempArmor(player).getAbility().equals(this)) {
TempArmor.getTempArmor(player).revert(); TempArmor.getTempArmor(player).revert();
} }
player.removePotionEffect(PotionEffectType.ABSORPTION); player.removePotionEffect(PotionEffectType.ABSORPTION);
if (oldAbsorbtion != null) { if (oldAbsorbtion != null) {
player.addPotionEffect(oldAbsorbtion); player.addPotionEffect(oldAbsorbtion);
} }
} }
public void updateAbsorbtion() { public void updateAbsorbtion() {
@ -298,87 +297,129 @@ public class EarthArmor extends EarthAbility {
goldHearts = GeneralMethods.getAbsorbationHealth(player); goldHearts = GeneralMethods.getAbsorbationHealth(player);
if (formed && goldHearts < 0.9F) { if (formed && goldHearts < 0.9F) {
bPlayer.addCooldown(abil); bPlayer.addCooldown(abil);
player.getLocation().getWorld().playSound(player.getLocation(), Sound.BLOCK_STONE_BREAK, 2, 1); player.getLocation().getWorld().playSound(player.getLocation(), Sound.BLOCK_STONE_BREAK, 2, 1);
player.getLocation().getWorld().playSound(player.getLocation(), Sound.BLOCK_STONE_BREAK, 2, 1); player.getLocation().getWorld().playSound(player.getLocation(), Sound.BLOCK_STONE_BREAK, 2, 1);
player.getLocation().getWorld().playSound(player.getLocation(), Sound.BLOCK_STONE_BREAK, 2, 1); player.getLocation().getWorld().playSound(player.getLocation(), Sound.BLOCK_STONE_BREAK, 2, 1);
ParticleEffect.BLOCK_CRACK.display(new ParticleEffect.BlockData(headData.getItemType(), headData.getData()), 0.1F, 0.1F, 0.1F, 1, 32, player.getEyeLocation(), 128); ParticleEffect.BLOCK_CRACK.display(new ParticleEffect.BlockData(headData.getItemType(), headData.getData()), 0.1F, 0.1F, 0.1F, 1, 32, player.getEyeLocation(), 128);
ParticleEffect.BLOCK_CRACK.display(new ParticleEffect.BlockData(legsData.getItemType(), legsData.getData()), 0.1F, 0.1F, 0.1F, 1, 32, player.getLocation(), 128); ParticleEffect.BLOCK_CRACK.display(new ParticleEffect.BlockData(legsData.getItemType(), legsData.getData()), 0.1F, 0.1F, 0.1F, 1, 32, player.getLocation(), 128);
remove(); remove();
} }
} }
}.runTaskLater(ProjectKorra.plugin, 1L); }.runTaskLater(ProjectKorra.plugin, 1L);
} }
public static int getColor(Material material) { public static int getColor(Material material) {
return getColor(material, (byte) 0x0); return getColor(material, (byte) 0x0);
} }
/**Returns the color for the specified material.*/ /** Returns the color for the specified material. */
public static int getColor(Material material, byte damage) { public static int getColor(Material material, byte damage) {
if (material == Material.DIRT) return 0xa86e45; //Default dirt brown if (material == Material.DIRT)
if (material == Material.GRASS) return 0xa86e45; //Default dirt brown return 0xa86e45; //Default dirt brown
if (material == Material.MYCEL) return 0xa86e45; //Default dirt brown if (material == Material.GRASS)
if (material == Material.CLAY) return 0xBAC2D1; //Dull gray-brown return 0xa86e45; //Default dirt brown
if (material == Material.STONE && damage == 0x0) return 0x9e9e9e; //Gray if (material == Material.MYCEL)
if (material == Material.STONE && (damage == 0x1 || damage == 0x2)) return 0xc69489; //Pink return 0xa86e45; //Default dirt brown
if (material == Material.STONE && (damage == 0x3 || damage == 0x4)) return 0xe3e3e5; //White if (material == Material.CLAY)
if (material == Material.STONE && (damage == 0x5 || damage == 0x6)) return 0xa3a3a3; //Gray return 0xBAC2D1; //Dull gray-brown
if (material == Material.COBBLESTONE) return 0x6B6B6B; //Dark Gray if (material == Material.STONE && damage == 0x0)
if (material == Material.SAND && damage == 0x0) return 0xffffaf; //Sand yellow return 0x9e9e9e; //Gray
if (material == Material.SAND && damage == 0x1) return 0xb85f25; //Sand orange if (material == Material.STONE && (damage == 0x1 || damage == 0x2))
if (material == Material.SANDSTONE) return 0xffffaf; //Sand return 0xc69489; //Pink
if (material == Material.RED_SANDSTONE) return 0xbc5a1a; //Red sandstone if (material == Material.STONE && (damage == 0x3 || damage == 0x4))
if (material == Material.GRAVEL) return 0xaaa49e; //Dark Gray return 0xe3e3e5; //White
if (material == Material.GOLD_ORE) return 0xa2a38f; //Gray-yellow if (material == Material.STONE && (damage == 0x5 || damage == 0x6))
if (material == Material.GOLD_BLOCK) return 0xF2F204; //Gold - Could be a tiny bit darker return 0xa3a3a3; //Gray
if (material == Material.IRON_ORE) return 0xa39d91; //Gray-brown if (material == Material.COBBLESTONE)
if (material == Material.IRON_BLOCK) return 0xf4f4f4; //Silver/Gray return 0x6B6B6B; //Dark Gray
if (material == Material.COAL_ORE) return 0x7c7c7c; //Stone gray if (material == Material.SAND && damage == 0x0)
if (material == Material.LAPIS_ORE) return 0x9198a3; //Gray-azure return 0xffffaf; //Sand yellow
if (material == Material.LAPIS_BLOCK) return 0x0060BA; //Dark blue if (material == Material.SAND && damage == 0x1)
if (material == Material.DIAMOND_ORE) return 0xa8bebf; //Gray-cyan return 0xb85f25; //Sand orange
if (material == Material.NETHERRACK) return 0x9b3131; //Pinkish-red if (material == Material.SANDSTONE)
if (material == Material.QUARTZ_ORE) return 0xb75656; //Pinkish-red return 0xffffaf; //Sand
if (material == Material.QUARTZ_BLOCK) return 0xfff4f4; //White if (material == Material.RED_SANDSTONE)
if (material == Material.STAINED_CLAY && damage == 0x0) return 0xCFAFA0; //White Stained Clay return 0xbc5a1a; //Red sandstone
if (material == Material.STAINED_CLAY && damage == 0x1) return 0xA75329; //Orange if (material == Material.GRAVEL)
if (material == Material.STAINED_CLAY && damage == 0x2) return 0x95596E; //Magenta return 0xaaa49e; //Dark Gray
if (material == Material.STAINED_CLAY && damage == 0x3) return 0x736E8A; //Light blue if (material == Material.GOLD_ORE)
if (material == Material.STAINED_CLAY && damage == 0x4) return 0xBA8825; //Yellow return 0xa2a38f; //Gray-yellow
if (material == Material.STAINED_CLAY && damage == 0x5) return 0x6B7736; //Lime if (material == Material.GOLD_BLOCK)
if (material == Material.STAINED_CLAY && damage == 0x6) return 0xA24D4F; //Pink return 0xF2F204; //Gold - Could be a tiny bit darker
if (material == Material.STAINED_CLAY && damage == 0x7) return 0x3A2923; //Gray if (material == Material.IRON_ORE)
if (material == Material.STAINED_CLAY && damage == 0x8) return 0x876A61; //Light Gray return 0xa39d91; //Gray-brown
if (material == Material.STAINED_CLAY && damage == 0x9) return 0x575B5B; //Cyan if (material == Material.IRON_BLOCK)
if (material == Material.STAINED_CLAY && damage == 0xA) return 0x734453; //Purple return 0xf4f4f4; //Silver/Gray
if (material == Material.STAINED_CLAY && damage == 0xB) return 0x493A5A; //Blue if (material == Material.COAL_ORE)
if (material == Material.STAINED_CLAY && damage == 0xC) return 0x4C3223; //Brown return 0x7c7c7c; //Stone gray
if (material == Material.STAINED_CLAY && damage == 0xD) return 0x4B522A; //Green if (material == Material.LAPIS_ORE)
if (material == Material.STAINED_CLAY && damage == 0xE) return 0x8D3B2E; //Red return 0x9198a3; //Gray-azure
if (material == Material.STAINED_CLAY && damage == 0xF) return 0x251610; //Black if (material == Material.LAPIS_BLOCK)
return 0x0060BA; //Dark blue
if (material == Material.DIAMOND_ORE)
return 0xa8bebf; //Gray-cyan
if (material == Material.NETHERRACK)
return 0x9b3131; //Pinkish-red
if (material == Material.QUARTZ_ORE)
return 0xb75656; //Pinkish-red
if (material == Material.QUARTZ_BLOCK)
return 0xfff4f4; //White
if (material == Material.STAINED_CLAY && damage == 0x0)
return 0xCFAFA0; //White Stained Clay
if (material == Material.STAINED_CLAY && damage == 0x1)
return 0xA75329; //Orange
if (material == Material.STAINED_CLAY && damage == 0x2)
return 0x95596E; //Magenta
if (material == Material.STAINED_CLAY && damage == 0x3)
return 0x736E8A; //Light blue
if (material == Material.STAINED_CLAY && damage == 0x4)
return 0xBA8825; //Yellow
if (material == Material.STAINED_CLAY && damage == 0x5)
return 0x6B7736; //Lime
if (material == Material.STAINED_CLAY && damage == 0x6)
return 0xA24D4F; //Pink
if (material == Material.STAINED_CLAY && damage == 0x7)
return 0x3A2923; //Gray
if (material == Material.STAINED_CLAY && damage == 0x8)
return 0x876A61; //Light Gray
if (material == Material.STAINED_CLAY && damage == 0x9)
return 0x575B5B; //Cyan
if (material == Material.STAINED_CLAY && damage == 0xA)
return 0x734453; //Purple
if (material == Material.STAINED_CLAY && damage == 0xB)
return 0x493A5A; //Blue
if (material == Material.STAINED_CLAY && damage == 0xC)
return 0x4C3223; //Brown
if (material == Material.STAINED_CLAY && damage == 0xD)
return 0x4B522A; //Green
if (material == Material.STAINED_CLAY && damage == 0xE)
return 0x8D3B2E; //Red
if (material == Material.STAINED_CLAY && damage == 0xF)
return 0x251610; //Black
return 0x9e9e9e; //Stone return 0x9e9e9e; //Stone
} }
@SuppressWarnings("deprecation") @SuppressWarnings("deprecation")
public void click() { public void click() {
if (!this.player.isSneaking()) return; if (!this.player.isSneaking())
return;
player.getLocation().getWorld().playSound(player.getLocation(), Sound.BLOCK_STONE_BREAK, 2, 1); player.getLocation().getWorld().playSound(player.getLocation(), Sound.BLOCK_STONE_BREAK, 2, 1);
player.getLocation().getWorld().playSound(player.getLocation(), Sound.BLOCK_STONE_BREAK, 2, 1); player.getLocation().getWorld().playSound(player.getLocation(), Sound.BLOCK_STONE_BREAK, 2, 1);
player.getLocation().getWorld().playSound(player.getLocation(), Sound.BLOCK_STONE_BREAK, 2, 1); player.getLocation().getWorld().playSound(player.getLocation(), Sound.BLOCK_STONE_BREAK, 2, 1);
ParticleEffect.BLOCK_CRACK.display(new ParticleEffect.BlockData(headData.getItemType(), headData.getData()), 0.1F, 0.1F, 0.1F, 1, 32, player.getEyeLocation(), 128); ParticleEffect.BLOCK_CRACK.display(new ParticleEffect.BlockData(headData.getItemType(), headData.getData()), 0.1F, 0.1F, 0.1F, 1, 32, player.getEyeLocation(), 128);
ParticleEffect.BLOCK_CRACK.display(new ParticleEffect.BlockData(legsData.getItemType(), legsData.getData()), 0.1F, 0.1F, 0.1F, 1, 32, player.getLocation(), 128); ParticleEffect.BLOCK_CRACK.display(new ParticleEffect.BlockData(legsData.getItemType(), legsData.getData()), 0.1F, 0.1F, 0.1F, 1, 32, player.getLocation(), 128);
bPlayer.addCooldown(this); bPlayer.addCooldown(this);
remove(); remove();
} }
@Override @Override
public String getName() { public String getName() {
return "EarthArmor"; return "EarthArmor";
@ -403,7 +444,7 @@ public class EarthArmor extends EarthAbility {
public boolean isHarmlessAbility() { public boolean isHarmlessAbility() {
return false; return false;
} }
public boolean isFormed() { public boolean isFormed() {
return formed; return formed;
} }
@ -427,7 +468,7 @@ public class EarthArmor extends EarthAbility {
public void setLegsData(MaterialData materialdata) { public void setLegsData(MaterialData materialdata) {
this.legsData = materialdata; this.legsData = materialdata;
} }
public double getSelectRange() { public double getSelectRange() {
return selectRange; return selectRange;
} }
@ -479,21 +520,21 @@ public class EarthArmor extends EarthAbility {
public void setCooldown(long cooldown) { public void setCooldown(long cooldown) {
this.cooldown = cooldown; this.cooldown = cooldown;
} }
public float getGoldHearts() { public float getGoldHearts() {
return goldHearts; return goldHearts;
} }
public int getMaxGoldHearts() { public int getMaxGoldHearts() {
return maxGoldHearts; return maxGoldHearts;
} }
public void setGoldHearts(float goldHearts) { public void setGoldHearts(float goldHearts) {
this.goldHearts = goldHearts; this.goldHearts = goldHearts;
} }
public void setMaxGoldHearts(int maxGoldHearts) { public void setMaxGoldHearts(int maxGoldHearts) {
this.maxGoldHearts = maxGoldHearts; this.maxGoldHearts = maxGoldHearts;
} }
} }

View file

@ -60,11 +60,11 @@ public class EarthBlast extends EarthAbility {
this.selectRange = getConfig().getDouble("Abilities.Earth.EarthBlast.SelectRange"); this.selectRange = getConfig().getDouble("Abilities.Earth.EarthBlast.SelectRange");
this.time = System.currentTimeMillis(); this.time = System.currentTimeMillis();
this.interval = (long) (1000.0 / speed); this.interval = (long) (1000.0 / speed);
if (bPlayer.isAvatarState()) { if (bPlayer.isAvatarState()) {
this.cooldown = getConfig().getLong("Abilities.Avatar.AvatarState.Earth.EarthBlast.Cooldown"); this.cooldown = getConfig().getLong("Abilities.Avatar.AvatarState.Earth.EarthBlast.Cooldown");
this.damage = getConfig().getDouble("Abilities.Avatar.AvatarState.Earth.EarthBlast.Damage"); this.damage = getConfig().getDouble("Abilities.Avatar.AvatarState.Earth.EarthBlast.Damage");
} }
if (prepare()) { if (prepare()) {
@ -510,7 +510,7 @@ public class EarthBlast extends EarthAbility {
public boolean isCollidable() { public boolean isCollidable() {
return isProgressing; return isProgressing;
} }
@Override @Override
public double getCollisionRadius() { public double getCollisionRadius() {
return collisionRadius; return collisionRadius;

View file

@ -51,13 +51,13 @@ public class EarthGrab extends EarthAbility {
if (!bPlayer.canBend(this)) { if (!bPlayer.canBend(this)) {
return; return;
} }
if (bPlayer.isAvatarState()) { if (bPlayer.isAvatarState()) {
this.cooldown = getConfig().getLong("Abilities.Avatar.AvatarState.Earth.EarthGrab.Cooldown"); this.cooldown = getConfig().getLong("Abilities.Avatar.AvatarState.Earth.EarthGrab.Cooldown");
this.height = getConfig().getDouble("Abilities.Avatar.AvatarState.Earth.EarthGrab.Height"); this.height = getConfig().getDouble("Abilities.Avatar.AvatarState.Earth.EarthGrab.Height");
} }
if (player.isSneaking()) { if (player.isSneaking()) {
start(); start();
} else { } else {

View file

@ -112,7 +112,7 @@ public class EarthTunnel extends EarthAbility {
block.setType(Material.AIR); block.setType(Material.AIR);
} else { } else {
airBlocks.put(new TempBlock(block, Material.AIR, (byte) 0), System.currentTimeMillis()); airBlocks.put(new TempBlock(block, Material.AIR, (byte) 0), System.currentTimeMillis());
if(isPlant(block.getRelative(BlockFace.UP)) || isSnow(block.getRelative(BlockFace.UP))){ if (isPlant(block.getRelative(BlockFace.UP)) || isSnow(block.getRelative(BlockFace.UP))) {
Block above = block.getRelative(BlockFace.UP); Block above = block.getRelative(BlockFace.UP);
Block above2 = above.getRelative(BlockFace.UP); Block above2 = above.getRelative(BlockFace.UP);
if (isPlant(above) || isSnow(above)) { if (isPlant(above) || isSnow(above)) {

View file

@ -18,7 +18,7 @@ import com.projectkorra.projectkorra.util.BlockSource;
import com.projectkorra.projectkorra.util.ClickType; import com.projectkorra.projectkorra.util.ClickType;
public class RaiseEarth extends EarthAbility { public class RaiseEarth extends EarthAbility {
private static final Map<Block, Block> ALL_AFFECTED_BLOCKS = new ConcurrentHashMap<>(); private static final Map<Block, Block> ALL_AFFECTED_BLOCKS = new ConcurrentHashMap<>();
private int distance; private int distance;
@ -33,11 +33,11 @@ public class RaiseEarth extends EarthAbility {
private Location origin; private Location origin;
private Location location; private Location location;
private ConcurrentHashMap<Block, Block> affectedBlocks; private ConcurrentHashMap<Block, Block> affectedBlocks;
public RaiseEarth(Player player) { public RaiseEarth(Player player) {
super(player); super(player);
setFields(); setFields();
if (!bPlayer.canBend(this) || bPlayer.isOnCooldown("RaiseEarthPillar")) { if (!bPlayer.canBend(this) || bPlayer.isOnCooldown("RaiseEarthPillar")) {
return; return;
} }
@ -50,7 +50,7 @@ public class RaiseEarth extends EarthAbility {
if (block == null) { if (block == null) {
return; return;
} }
origin = block.getLocation(); origin = block.getLocation();
location = origin.clone(); location = origin.clone();
distance = getEarthbendableBlocksLength(block, direction.clone().multiply(-1), height); distance = getEarthbendableBlocksLength(block, direction.clone().multiply(-1), height);
@ -75,7 +75,7 @@ public class RaiseEarth extends EarthAbility {
public RaiseEarth(Player player, Location origin, int height) { public RaiseEarth(Player player, Location origin, int height) {
super(player); super(player);
setFields(); setFields();
this.height = height; this.height = height;
this.origin = origin; this.origin = origin;
this.location = origin.clone(); this.location = origin.clone();
@ -89,7 +89,7 @@ public class RaiseEarth extends EarthAbility {
start(); start();
} }
} }
private void setFields() { private void setFields() {
this.speed = getConfig().getDouble("Abilities.Earth.RaiseEarth.Speed"); this.speed = getConfig().getDouble("Abilities.Earth.RaiseEarth.Speed");
this.height = getConfig().getInt("Abilities.Earth.RaiseEarth.Column.Height"); this.height = getConfig().getInt("Abilities.Earth.RaiseEarth.Column.Height");
@ -99,12 +99,12 @@ public class RaiseEarth extends EarthAbility {
this.interval = (long) (1000.0 / speed); this.interval = (long) (1000.0 / speed);
this.affectedBlocks = new ConcurrentHashMap<>(); this.affectedBlocks = new ConcurrentHashMap<>();
} }
private boolean canInstantiate() { private boolean canInstantiate() {
if (location.getBlock().getRelative(BlockFace.UP).getType() == Material.STATIONARY_LAVA) { if (location.getBlock().getRelative(BlockFace.UP).getType() == Material.STATIONARY_LAVA) {
return false; return false;
} }
for (Block block : affectedBlocks.keySet()) { for (Block block : affectedBlocks.keySet()) {
if (!isEarthbendable(block) || ALL_AFFECTED_BLOCKS.containsKey(block)) { if (!isEarthbendable(block) || ALL_AFFECTED_BLOCKS.containsKey(block)) {
return false; return false;
@ -124,7 +124,7 @@ public class RaiseEarth extends EarthAbility {
} }
} }
} }
@Override @Override
public void progress() { public void progress() {
if (System.currentTimeMillis() - time >= interval) { if (System.currentTimeMillis() - time >= interval) {
@ -134,7 +134,7 @@ public class RaiseEarth extends EarthAbility {
if (!block.isLiquid()) { if (!block.isLiquid()) {
moveEarth(block, direction, distance); moveEarth(block, direction, distance);
} }
loadAffectedBlocks(); loadAffectedBlocks();
if (location.distanceSquared(origin) >= distance * distance) { if (location.distanceSquared(origin) >= distance * distance) {
@ -169,7 +169,7 @@ public class RaiseEarth extends EarthAbility {
public long getCooldown() { public long getCooldown() {
return cooldown; return cooldown;
} }
@Override @Override
public boolean isSneakAbility() { public boolean isSneakAbility() {
return true; return true;
@ -179,7 +179,7 @@ public class RaiseEarth extends EarthAbility {
public boolean isHarmlessAbility() { public boolean isHarmlessAbility() {
return false; return false;
} }
@Override @Override
public List<Location> getLocations() { public List<Location> getLocations() {
ArrayList<Location> locations = new ArrayList<>(); ArrayList<Location> locations = new ArrayList<>();
@ -272,5 +272,5 @@ public class RaiseEarth extends EarthAbility {
public void setSelectRange(double selectRange) { public void setSelectRange(double selectRange) {
this.selectRange = selectRange; this.selectRange = selectRange;
} }
} }

View file

@ -18,7 +18,7 @@ public class RaiseEarthWall extends EarthAbility {
private int width; private int width;
private long cooldown; private long cooldown;
private Location location; private Location location;
public RaiseEarthWall(Player player) { public RaiseEarthWall(Player player) {
super(player); super(player);
this.selectRange = getConfig().getInt("Abilities.Earth.RaiseEarth.Wall.SelectRange"); this.selectRange = getConfig().getInt("Abilities.Earth.RaiseEarth.Wall.SelectRange");
@ -41,19 +41,19 @@ public class RaiseEarthWall extends EarthAbility {
ox = -direction.getZ(); ox = -direction.getZ();
oy = 0; oy = 0;
oz = direction.getX(); oz = direction.getX();
Vector orth = new Vector(ox, oy, oz); Vector orth = new Vector(ox, oy, oz);
orth = orth.normalize(); orth = orth.normalize();
orth = getDegreeRoundedVector(orth, 0.25); orth = getDegreeRoundedVector(orth, 0.25);
Block sblock = BlockSource.getEarthSourceBlock(player, selectRange, ClickType.SHIFT_DOWN); Block sblock = BlockSource.getEarthSourceBlock(player, selectRange, ClickType.SHIFT_DOWN);
if (sblock == null) { if (sblock == null) {
location = getTargetEarthBlock(selectRange).getLocation(); location = getTargetEarthBlock(selectRange).getLocation();
} else { } else {
location = sblock.getLocation(); location = sblock.getLocation();
} }
World world = location.getWorld(); World world = location.getWorld();
boolean shouldAddCooldown = false; boolean shouldAddCooldown = false;
@ -91,22 +91,22 @@ public class RaiseEarthWall extends EarthAbility {
bPlayer.addCooldown("RaiseEarthWall", cooldown); bPlayer.addCooldown("RaiseEarthWall", cooldown);
} }
} }
private static Vector getDegreeRoundedVector(Vector vec, double degreeIncrement) { private static Vector getDegreeRoundedVector(Vector vec, double degreeIncrement) {
if (vec == null) { if (vec == null) {
return null; return null;
} }
vec = vec.normalize(); vec = vec.normalize();
double[] dims = {vec.getX(), vec.getY(), vec.getZ()}; double[] dims = { vec.getX(), vec.getY(), vec.getZ() };
for (int i = 0; i < dims.length; i++) { for (int i = 0; i < dims.length; i++) {
double dim = dims[i]; double dim = dims[i];
int sign = dim >= 0 ? 1 : -1; int sign = dim >= 0 ? 1 : -1;
int dimDivIncr = (int)(dim / degreeIncrement); int dimDivIncr = (int) (dim / degreeIncrement);
double lowerBound = dimDivIncr * degreeIncrement; double lowerBound = dimDivIncr * degreeIncrement;
double upperBound = (dimDivIncr + (1 * sign)) * degreeIncrement; double upperBound = (dimDivIncr + (1 * sign)) * degreeIncrement;
if (Math.abs(dim - lowerBound) < Math.abs(dim - upperBound)) { if (Math.abs(dim - lowerBound) < Math.abs(dim - upperBound)) {
dims[i] = lowerBound; dims[i] = lowerBound;
} else { } else {
@ -122,7 +122,8 @@ public class RaiseEarthWall extends EarthAbility {
} }
@Override @Override
public void progress() {} public void progress() {
}
@Override @Override
public Location getLocation() { public Location getLocation() {
@ -133,7 +134,7 @@ public class RaiseEarthWall extends EarthAbility {
public long getCooldown() { public long getCooldown() {
return cooldown; return cooldown;
} }
@Override @Override
public boolean isSneakAbility() { public boolean isSneakAbility() {
return true; return true;
@ -183,5 +184,5 @@ public class RaiseEarthWall extends EarthAbility {
public void setSelectRange(int selectRange) { public void setSelectRange(int selectRange) {
this.selectRange = selectRange; this.selectRange = selectRange;
} }
} }

View file

@ -231,7 +231,7 @@ public class Ripple extends EarthAbility {
setMoved(block); setMoved(block);
Block botBlock = block.getRelative(BlockFace.DOWN); Block botBlock = block.getRelative(BlockFace.DOWN);
int length = 1; int length = 1;
if (isEarthbendable(botBlock)) { if (isEarthbendable(botBlock)) {
length = 2; length = 2;
block = botBlock; block = botBlock;
@ -327,12 +327,12 @@ public class Ripple extends EarthAbility {
public boolean isHarmlessAbility() { public boolean isHarmlessAbility() {
return false; return false;
} }
@Override @Override
public ArrayList<Location> getLocations() { public ArrayList<Location> getLocations() {
return locations; return locations;
} }
public int getStep() { public int getStep() {
return step; return step;
} }

View file

@ -9,7 +9,7 @@ import org.bukkit.entity.Player;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
public class Shockwave extends EarthAbility { public class Shockwave extends EarthAbility {
private boolean charged; private boolean charged;
private long chargeTime; private long chargeTime;
private long cooldown; private long cooldown;
@ -19,28 +19,28 @@ public class Shockwave extends EarthAbility {
public Shockwave(Player player, boolean fall) { public Shockwave(Player player, boolean fall) {
super(player); super(player);
this.angle = Math.toRadians(getConfig().getDouble("Abilities.Earth.Shockwave.Angle")); this.angle = Math.toRadians(getConfig().getDouble("Abilities.Earth.Shockwave.Angle"));
this.cooldown = getConfig().getLong("Abilities.Earth.Shockwave.Cooldown"); this.cooldown = getConfig().getLong("Abilities.Earth.Shockwave.Cooldown");
this.chargeTime = getConfig().getLong("Abilities.Earth.Shockwave.ChargeTime"); this.chargeTime = getConfig().getLong("Abilities.Earth.Shockwave.ChargeTime");
this.threshold = getConfig().getDouble("Abilities.Earth.Shockwave.FallThreshold"); this.threshold = getConfig().getDouble("Abilities.Earth.Shockwave.FallThreshold");
this.range = getConfig().getDouble("Abilities.Earth.Shockwave.Range"); this.range = getConfig().getDouble("Abilities.Earth.Shockwave.Range");
if (bPlayer.isAvatarState()) { if (bPlayer.isAvatarState()) {
range = getConfig().getDouble("Abilities.Avatar.AvatarState.Earth.Shockwave.Range"); range = getConfig().getDouble("Abilities.Avatar.AvatarState.Earth.Shockwave.Range");
cooldown = getConfig().getLong("Abilities.Avatar.AvatarState.Earth.Shockwave.Cooldown"); cooldown = getConfig().getLong("Abilities.Avatar.AvatarState.Earth.Shockwave.Cooldown");
chargeTime = getConfig().getLong("Abilities.Avatar.AvatarState.Earth.Shockwave.ChargeTime"); chargeTime = getConfig().getLong("Abilities.Avatar.AvatarState.Earth.Shockwave.ChargeTime");
} }
if (!bPlayer.canBend(this) || hasAbility(player, Shockwave.class)) { if (!bPlayer.canBend(this) || hasAbility(player, Shockwave.class)) {
return; return;
} }
if (fall) { if (fall) {
fallShockwave(); fallShockwave();
return; return;
} }
start(); start();
} }
@ -52,7 +52,7 @@ public class Shockwave extends EarthAbility {
} else if (bPlayer.isOnCooldown("Shockwave")) { } else if (bPlayer.isOnCooldown("Shockwave")) {
return; return;
} }
areaShockwave(); areaShockwave();
bPlayer.addCooldown(this); bPlayer.addCooldown(this);
remove(); remove();
@ -103,7 +103,7 @@ public class Shockwave extends EarthAbility {
if (shockWave != null) { if (shockWave != null) {
if (shockWave.charged) { if (shockWave.charged) {
double dtheta = 360.0 / (2 * Math.PI * shockWave.range) - 1; double dtheta = 360.0 / (2 * Math.PI * shockWave.range) - 1;
for (double theta = 0; theta < 360; theta += dtheta) { for (double theta = 0; theta < 360; theta += dtheta) {
double rtheta = Math.toRadians(theta); double rtheta = Math.toRadians(theta);
Vector vector = new Vector(Math.cos(rtheta), 0, Math.sin(rtheta)); Vector vector = new Vector(Math.cos(rtheta), 0, Math.sin(rtheta));
@ -131,7 +131,7 @@ public class Shockwave extends EarthAbility {
public long getCooldown() { public long getCooldown() {
return cooldown; return cooldown;
} }
@Override @Override
public boolean isSneakAbility() { public boolean isSneakAbility() {
return true; return true;
@ -185,5 +185,5 @@ public class Shockwave extends EarthAbility {
public void setCooldown(long cooldown) { public void setCooldown(long cooldown) {
this.cooldown = cooldown; this.cooldown = cooldown;
} }
} }

View file

@ -24,26 +24,26 @@ public class Tremorsense extends EarthAbility {
private int radius; private int radius;
private long cooldown; private long cooldown;
private Block block; private Block block;
public Tremorsense(Player player, boolean clicked) { public Tremorsense(Player player, boolean clicked) {
super(player); super(player);
if (!bPlayer.canBendIgnoreBinds(this)) { if (!bPlayer.canBendIgnoreBinds(this)) {
return; return;
} }
setFields(); setFields();
byte lightLevel = player.getLocation().getBlock().getLightLevel(); byte lightLevel = player.getLocation().getBlock().getLightLevel();
if (lightLevel < this.lightThreshold && isEarthbendable(player.getLocation().getBlock().getRelative(BlockFace.DOWN))) { if (lightLevel < this.lightThreshold && isEarthbendable(player.getLocation().getBlock().getRelative(BlockFace.DOWN))) {
if(clicked) { if (clicked) {
bPlayer.addCooldown(this); bPlayer.addCooldown(this);
activate(); activate();
} }
start(); start();
} }
} }
private void setFields() { private void setFields() {
this.maxDepth = getConfig().getInt("Abilities.Earth.Tremorsense.MaxDepth"); this.maxDepth = getConfig().getInt("Abilities.Earth.Tremorsense.MaxDepth");
this.radius = getConfig().getInt("Abilities.Earth.Tremorsense.Radius"); this.radius = getConfig().getInt("Abilities.Earth.Tremorsense.Radius");
@ -58,7 +58,7 @@ public class Tremorsense extends EarthAbility {
boolean earth = false; boolean earth = false;
boolean foundAir = false; boolean foundAir = false;
Block smokeBlock = null; Block smokeBlock = null;
for (int k = 0; k <= maxDepth; k++) { for (int k = 0; k <= maxDepth; k++) {
Block blocki = block.getRelative(BlockFace.EAST, i).getRelative(BlockFace.NORTH, j).getRelative(BlockFace.DOWN, k); Block blocki = block.getRelative(BlockFace.EAST, i).getRelative(BlockFace.NORTH, j).getRelative(BlockFace.DOWN, k);
if (GeneralMethods.isRegionProtectedFromBuild(this, blocki.getLocation())) { if (GeneralMethods.isRegionProtectedFromBuild(this, blocki.getLocation())) {
@ -90,7 +90,7 @@ public class Tremorsense extends EarthAbility {
} }
return; return;
} }
boolean isBendable = isEarthbendable(standBlock); boolean isBendable = isEarthbendable(standBlock);
if (isBendable && block == null) { if (isBendable && block == null) {
@ -117,16 +117,16 @@ public class Tremorsense extends EarthAbility {
player.sendBlockChange(block.getLocation(), block.getTypeId(), block.getData()); player.sendBlockChange(block.getLocation(), block.getTypeId(), block.getData());
} }
} }
@Override @Override
public void remove() { public void remove() {
super.remove(); super.remove();
revertGlowBlock(); revertGlowBlock();
} }
@Override @Override
public void progress() { public void progress() {
if (!bPlayer.canBendIgnoreBindsCooldowns(this) || player.getLocation().getBlock().getLightLevel() > lightThreshold) { if (!bPlayer.canBendIgnoreBindsCooldowns(this) || player.getLocation().getBlock().getLightLevel() > lightThreshold) {
remove(); remove();
return; return;
} else { } else {
@ -136,23 +136,23 @@ public class Tremorsense extends EarthAbility {
public static void manage(Server server) { public static void manage(Server server) {
for (Player player : server.getOnlinePlayers()) { for (Player player : server.getOnlinePlayers()) {
if (canTremorSense(player) && !hasAbility(player, Tremorsense.class)) { if (canTremorSense(player) && !hasAbility(player, Tremorsense.class)) {
new Tremorsense(player, false); new Tremorsense(player, false);
} }
} }
} }
public static boolean canTremorSense(Player player) { public static boolean canTremorSense(Player player) {
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (bPlayer != null && bPlayer.canBendIgnoreBindsCooldowns(getAbility("Tremorsense"))) { if (bPlayer != null && bPlayer.canBendIgnoreBindsCooldowns(getAbility("Tremorsense"))) {
return true; return true;
} }
return false; return false;
} }
public static Map<Block, Player> getBlocks() { public static Map<Block, Player> getBlocks() {
return BLOCKS; return BLOCKS;
} }
@ -171,7 +171,7 @@ public class Tremorsense extends EarthAbility {
public long getCooldown() { public long getCooldown() {
return cooldown; return cooldown;
} }
@Override @Override
public boolean isSneakAbility() { public boolean isSneakAbility() {
return true; return true;
@ -217,5 +217,5 @@ public class Tremorsense extends EarthAbility {
public void setCooldown(long cooldown) { public void setCooldown(long cooldown) {
this.cooldown = cooldown; this.cooldown = cooldown;
} }
} }

View file

@ -121,7 +121,7 @@ public class LavaFlow extends LavaAbility {
clickLavaCooldown = getConfig().getLong("Abilities.Avatar.AvatarState.Earth.LavaFlow.ClickLavaCooldown"); clickLavaCooldown = getConfig().getLong("Abilities.Avatar.AvatarState.Earth.LavaFlow.ClickLavaCooldown");
clickLandCooldown = getConfig().getLong("Abilities.Avatar.AvatarState.Earth.LavaFlow.ClickLandCooldown"); clickLandCooldown = getConfig().getLong("Abilities.Avatar.AvatarState.Earth.LavaFlow.ClickLandCooldown");
shiftPlatformRadius = getConfig().getDouble("Abilities.Avatar.AvatarState.Earth.LavaFlow.ShiftPlatformRadius"); shiftPlatformRadius = getConfig().getDouble("Abilities.Avatar.AvatarState.Earth.LavaFlow.ShiftPlatformRadius");
clickLavaRadius = getConfig().getDouble("Abilities.Avatar.AvatarState.Earth.LavaFlow.ClickRadius"); clickLavaRadius = getConfig().getDouble("Abilities.Avatar.AvatarState.Earth.LavaFlow.ClickRadius");
shiftMaxRadius = getConfig().getDouble("Abilities.Avatar.AvatarState.LavaFlow.Earth.ShiftRadius"); shiftMaxRadius = getConfig().getDouble("Abilities.Avatar.AvatarState.LavaFlow.Earth.ShiftRadius");
} }
@ -286,10 +286,9 @@ public class LavaFlow extends LavaAbility {
Location loc = origin.clone().add(x, 0, z); Location loc = origin.clone().add(x, 0, z);
Block tempBlock = GeneralMethods.getTopBlock(loc, upwardFlow, downwardFlow); Block tempBlock = GeneralMethods.getTopBlock(loc, upwardFlow, downwardFlow);
if (!isWater(tempBlock)) { if (!isWater(tempBlock)) {
if (tempBlock != null && !isLava(tempBlock) && Math.random() < particleDensity && tempBlock if (tempBlock != null && !isLava(tempBlock) && Math.random() < particleDensity && tempBlock.getLocation().distanceSquared(origin) <= Math.pow(clickLavaRadius, 2)) {
.getLocation().distanceSquared(origin) <= Math.pow(clickLavaRadius, 2)) {
if (random.nextInt(3) == 0) { if (random.nextInt(3) == 0) {
ParticleEffect.LAVA.display(loc, (float) Math.random(), (float) Math.random(),(float) Math.random(), 0, 1); ParticleEffect.LAVA.display(loc, (float) Math.random(), (float) Math.random(), (float) Math.random(), 0, 1);
} }
} }
} }

View file

@ -27,7 +27,7 @@ import java.util.Random;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
public class LavaSurge extends LavaAbility { public class LavaSurge extends LavaAbility {
private static final HashSet<FallingBlock> ALL_FALLING_BLOCKS = new HashSet<>(); private static final HashSet<FallingBlock> ALL_FALLING_BLOCKS = new HashSet<>();
private boolean hasSurgeStarted; private boolean hasSurgeStarted;
@ -49,15 +49,15 @@ public class LavaSurge extends LavaAbility {
private Vector direction; private Vector direction;
private Location startLocation; private Location startLocation;
private ArrayList<FallingBlock> fallingBlocks; private ArrayList<FallingBlock> fallingBlocks;
private ArrayList<Block> fracture; private ArrayList<Block> fracture;
private ArrayList<TempBlock> fractureTempBlocks; private ArrayList<TempBlock> fractureTempBlocks;
private ArrayList<TempBlock> movingLava; private ArrayList<TempBlock> movingLava;
private Map<FallingBlock, TempBlock> lavaBlocks; private Map<FallingBlock, TempBlock> lavaBlocks;
private ListIterator<Block> listIterator; private ListIterator<Block> listIterator;
public LavaSurge(Player player) { public LavaSurge(Player player) {
super(player); super(player);
this.impactDamage = getConfig().getInt("Abilities.Earth.LavaSurge.Damage"); this.impactDamage = getConfig().getInt("Abilities.Earth.LavaSurge.Damage");
this.cooldown = getConfig().getLong("Abilities.Earth.LavaSurge.Cooldown"); this.cooldown = getConfig().getLong("Abilities.Earth.LavaSurge.Cooldown");
this.fractureRadius = getConfig().getDouble("Abilities.Earth.LavaSurge.FractureRadius"); this.fractureRadius = getConfig().getDouble("Abilities.Earth.LavaSurge.FractureRadius");
@ -67,198 +67,196 @@ public class LavaSurge extends LavaAbility {
this.canSourceBeEarth = getConfig().getBoolean("Abilities.Earth.LavaSurge.SourceCanBeEarth"); this.canSourceBeEarth = getConfig().getBoolean("Abilities.Earth.LavaSurge.SourceCanBeEarth");
this.particleInterval = 100; this.particleInterval = 100;
this.fallingBlockInterval = 100; this.fallingBlockInterval = 100;
this.random = new Random(); this.random = new Random();
this.fallingBlocks = new ArrayList<>(); this.fallingBlocks = new ArrayList<>();
this.fracture = new ArrayList<>(); this.fracture = new ArrayList<>();
this.fractureTempBlocks = new ArrayList<>(); this.fractureTempBlocks = new ArrayList<>();
this.movingLava = new ArrayList<>(); this.movingLava = new ArrayList<>();
this.lavaBlocks = new ConcurrentHashMap<>(); this.lavaBlocks = new ConcurrentHashMap<>();
if(!isEligible()) { if (!isEligible()) {
return; return;
} else if(bPlayer.isOnCooldown(this)) { } else if (bPlayer.isOnCooldown(this)) {
return; return;
} }
lastTime = System.currentTimeMillis(); lastTime = System.currentTimeMillis();
if(prepare()) { if (prepare()) {
start(); start();
} }
} }
public boolean isEligible() { public boolean isEligible() {
return bPlayer.canBend(this) && bPlayer.canLavabend(); return bPlayer.canBend(this) && bPlayer.canLavabend();
} }
public boolean prepare() { public boolean prepare() {
Block targetBlock = BlockSource.getEarthSourceBlock(player, prepareRange, ClickType.SHIFT_DOWN); Block targetBlock = BlockSource.getEarthSourceBlock(player, prepareRange, ClickType.SHIFT_DOWN);
if(targetBlock == null if (targetBlock == null || !(targetBlock.getRelative(BlockFace.UP).getType() == Material.AIR) && !isLava(targetBlock.getRelative(BlockFace.UP))) {
|| !(targetBlock.getRelative(BlockFace.UP).getType() == Material.AIR)
&& !isLava(targetBlock.getRelative(BlockFace.UP))) {
return false; return false;
} }
LavaSurge otherSurge = getAbility(player, this.getClass()); LavaSurge otherSurge = getAbility(player, this.getClass());
if (otherSurge != null) { if (otherSurge != null) {
otherSurge.revertFracture(); otherSurge.revertFracture();
} }
if((canSourceBeEarth && isEarthbendable(targetBlock)) || isLavabendable(targetBlock)) { if ((canSourceBeEarth && isEarthbendable(targetBlock)) || isLavabendable(targetBlock)) {
startLocation = targetBlock.getLocation().add(0, 1, 0); startLocation = targetBlock.getLocation().add(0, 1, 0);
sourceBlock = targetBlock; sourceBlock = targetBlock;
return true; return true;
} }
return false; return false;
} }
public void launch() {
Location targetLocation = GeneralMethods.getTargetedLocation(player, travelRange*2);
try { public void launch() {
targetLocation = GeneralMethods.getTargetedEntity(player, travelRange*2, null).getLocation(); Location targetLocation = GeneralMethods.getTargetedLocation(player, travelRange * 2);
} catch(NullPointerException e) {}
try {
if(targetLocation == null) { targetLocation = GeneralMethods.getTargetedEntity(player, travelRange * 2, null).getLocation();
}
catch (NullPointerException e) {
}
if (targetLocation == null) {
remove(); remove();
return; return;
} }
time = System.currentTimeMillis(); time = System.currentTimeMillis();
direction = GeneralMethods.getDirection(startLocation, targetLocation).multiply(0.07); direction = GeneralMethods.getDirection(startLocation, targetLocation).multiply(0.07);
if(direction.getY() < 0) { if (direction.getY() < 0) {
direction.setY(0); direction.setY(0);
} }
if(canSourceBeEarth) { if (canSourceBeEarth) {
openFracture(); openFracture();
} else { } else {
skipFracture(); skipFracture();
} }
} }
public void openFracture() { public void openFracture() {
List<Block> affectedBlocks = GeneralMethods.getBlocksAroundPoint(sourceBlock.getLocation(), fractureRadius); List<Block> affectedBlocks = GeneralMethods.getBlocksAroundPoint(sourceBlock.getLocation(), fractureRadius);
for(Block b : affectedBlocks) { for (Block b : affectedBlocks) {
if(isEarthbendable(b)) { if (isEarthbendable(b)) {
fracture.add(b); fracture.add(b);
} }
} }
listIterator = fracture.listIterator(); listIterator = fracture.listIterator();
isFractureOpen = true; isFractureOpen = true;
bPlayer.addCooldown(this); bPlayer.addCooldown(this);
} }
public void skipFracture() { public void skipFracture() {
listIterator = fracture.listIterator(); listIterator = fracture.listIterator();
isFractureOpen = true; isFractureOpen = true;
} }
public void revertFracture() { public void revertFracture() {
for(TempBlock tb : fractureTempBlocks) { for (TempBlock tb : fractureTempBlocks) {
tb.revertBlock(); tb.revertBlock();
} }
fracture.clear(); fracture.clear();
} }
@Override @Override
public void remove() { public void remove() {
super.remove(); super.remove();
revertFracture(); revertFracture();
} }
public boolean canMoveThrough(Block block) { public boolean canMoveThrough(Block block) {
if(isTransparent(startLocation.getBlock()) || if (isTransparent(startLocation.getBlock()) || isEarthbendable(startLocation.getBlock()) || isLavabendable(startLocation.getBlock())) {
isEarthbendable(startLocation.getBlock()) ||
isLavabendable(startLocation.getBlock())) {
return true; return true;
} }
return false; return false;
} }
public void removeLava() { public void removeLava() {
for(TempBlock tb : lavaBlocks.values()) { for (TempBlock tb : lavaBlocks.values()) {
tb.revertBlock(); tb.revertBlock();
} }
movingLava.clear(); movingLava.clear();
} }
@Override @Override
public void progress() { public void progress() {
long curTime = System.currentTimeMillis(); long curTime = System.currentTimeMillis();
if(!player.isOnline() || player.isDead()) { if (!player.isOnline() || player.isDead()) {
remove(); remove();
return; return;
} else if(!hasSurgeStarted && !bPlayer.getBoundAbilityName().equals(getName())) { } else if (!hasSurgeStarted && !bPlayer.getBoundAbilityName().equals(getName())) {
remove(); remove();
return; return;
} }
if(!hasSurgeStarted && sourceBlock != null && curTime > lastTime + particleInterval) { if (!hasSurgeStarted && sourceBlock != null && curTime > lastTime + particleInterval) {
lastTime = curTime; lastTime = curTime;
ParticleEffect.LAVA.display(sourceBlock.getLocation(), 0, 0, 0, 0, 1); ParticleEffect.LAVA.display(sourceBlock.getLocation(), 0, 0, 0, 0, 1);
} else if(hasSurgeStarted && curTime > lastTime + particleInterval) { } else if (hasSurgeStarted && curTime > lastTime + particleInterval) {
lastTime = curTime; lastTime = curTime;
for(FallingBlock fblock : fallingBlocks) { for (FallingBlock fblock : fallingBlocks) {
ParticleEffect.LAVA.display(fblock.getLocation(), 0, 0, 0, 0, 1); ParticleEffect.LAVA.display(fblock.getLocation(), 0, 0, 0, 0, 1);
} }
} }
if(isFractureOpen && !hasSurgeStarted) { if (isFractureOpen && !hasSurgeStarted) {
if(!listIterator.hasNext()) { if (!listIterator.hasNext()) {
hasSurgeStarted = true; hasSurgeStarted = true;
} else { } else {
Block b = listIterator.next(); Block b = listIterator.next();
playEarthbendingSound(b.getLocation()); playEarthbendingSound(b.getLocation());
for(int i = 0; i < 2; i++) { for (int i = 0; i < 2; i++) {
TempBlock tb = new TempBlock(b, Material.STATIONARY_LAVA, (byte) 0); TempBlock tb = new TempBlock(b, Material.STATIONARY_LAVA, (byte) 0);
fractureTempBlocks.add(tb); fractureTempBlocks.add(tb);
} }
} }
} }
if(hasSurgeStarted) { if (hasSurgeStarted) {
if(fallingBlocksCount >= maxBlocks) { if (fallingBlocksCount >= maxBlocks) {
return; return;
} }
if(curTime > time + (fallingBlockInterval * fallingBlocksCount)) { if (curTime > time + (fallingBlockInterval * fallingBlocksCount)) {
FallingBlock fbs = GeneralMethods.spawnFallingBlock(sourceBlock.getLocation().add(0, 1, 0), 11, (byte) 0); FallingBlock fbs = GeneralMethods.spawnFallingBlock(sourceBlock.getLocation().add(0, 1, 0), 11, (byte) 0);
fallingBlocks.add(fbs); fallingBlocks.add(fbs);
ALL_FALLING_BLOCKS.add(fbs); ALL_FALLING_BLOCKS.add(fbs);
double x = random.nextDouble()/5; double x = random.nextDouble() / 5;
double z = random.nextDouble()/5; double z = random.nextDouble() / 5;
x = (random.nextBoolean()) ? -x : x; x = (random.nextBoolean()) ? -x : x;
z = (random.nextBoolean()) ? -z : z; z = (random.nextBoolean()) ? -z : z;
fbs.setVelocity(direction.clone().add(new Vector(x, 0.2, z)).multiply(1.2)); fbs.setVelocity(direction.clone().add(new Vector(x, 0.2, z)).multiply(1.2));
fbs.setDropItem(false); fbs.setDropItem(false);
for(Block b : fracture) { for (Block b : fracture) {
if(random.nextBoolean() && b != sourceBlock) { if (random.nextBoolean() && b != sourceBlock) {
FallingBlock fb = GeneralMethods.spawnFallingBlock(b.getLocation().add(new Vector(0, 1, 0)), 11, (byte) 0); FallingBlock fb = GeneralMethods.spawnFallingBlock(b.getLocation().add(new Vector(0, 1, 0)), 11, (byte) 0);
ALL_FALLING_BLOCKS.add(fb); ALL_FALLING_BLOCKS.add(fb);
fallingBlocks.add(fb); fallingBlocks.add(fb);
fb.setVelocity(direction.clone().add(new Vector(random.nextDouble()/10, 0.1, random.nextDouble()/10)).multiply(1.2)); fb.setVelocity(direction.clone().add(new Vector(random.nextDouble() / 10, 0.1, random.nextDouble() / 10)).multiply(1.2));
fb.setDropItem(false); fb.setDropItem(false);
} }
} }
fallingBlocksCount++; fallingBlocksCount++;
} }
for(FallingBlock fb : fallingBlocks) { for (FallingBlock fb : fallingBlocks) {
for(Entity e : GeneralMethods.getEntitiesAroundPoint(fb.getLocation(), 2)) { for (Entity e : GeneralMethods.getEntitiesAroundPoint(fb.getLocation(), 2)) {
if(e instanceof LivingEntity) { if (e instanceof LivingEntity) {
if(e.getEntityId() != player.getEntityId()) { if (e.getEntityId() != player.getEntityId()) {
DamageHandler.damageEntity(e, impactDamage, this); DamageHandler.damageEntity(e, impactDamage, this);
e.setFireTicks(100); e.setFireTicks(100);
GeneralMethods.setVelocity(e, direction.clone()); GeneralMethods.setVelocity(e, direction.clone());
@ -283,7 +281,7 @@ public class LavaSurge extends LavaAbility {
public long getCooldown() { public long getCooldown() {
return cooldown; return cooldown;
} }
@Override @Override
public boolean isSneakAbility() { public boolean isSneakAbility() {
return true; return true;
@ -293,11 +291,11 @@ public class LavaSurge extends LavaAbility {
public boolean isHarmlessAbility() { public boolean isHarmlessAbility() {
return false; return false;
} }
public static HashSet<FallingBlock> getAllFallingBlocks() { public static HashSet<FallingBlock> getAllFallingBlocks() {
return ALL_FALLING_BLOCKS; return ALL_FALLING_BLOCKS;
} }
public boolean isHasSurgeStarted() { public boolean isHasSurgeStarted() {
return hasSurgeStarted; return hasSurgeStarted;
} }
@ -465,5 +463,5 @@ public class LavaSurge extends LavaAbility {
public void setCooldown(long cooldown) { public void setCooldown(long cooldown) {
this.cooldown = cooldown; this.cooldown = cooldown;
} }
} }

View file

@ -22,11 +22,11 @@ import java.util.Map;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
public class LavaSurgeWall extends LavaAbility { public class LavaSurgeWall extends LavaAbility {
private static final Map<Block, Block> AFFECTED_BLOCKS = new ConcurrentHashMap<Block, Block>(); private static final Map<Block, Block> AFFECTED_BLOCKS = new ConcurrentHashMap<Block, Block>();
private static final Map<Block, Player> WALL_BLOCKS = new ConcurrentHashMap<Block, Player>(); private static final Map<Block, Player> WALL_BLOCKS = new ConcurrentHashMap<Block, Player>();
private static final int SURGE_WAVE_RANGE = 20; // TODO: remove this private static final int SURGE_WAVE_RANGE = 20; // TODO: remove this
private boolean progressing; private boolean progressing;
private boolean settingUp; private boolean settingUp;
private boolean forming; private boolean forming;
@ -41,15 +41,15 @@ public class LavaSurgeWall extends LavaAbility {
private Location targetDestination; private Location targetDestination;
private Vector firstDirection; private Vector firstDirection;
private Vector targetDirection; private Vector targetDirection;
public LavaSurgeWall(Player player) { public LavaSurgeWall(Player player) {
super(player); super(player);
this.interval = 30; this.interval = 30;
this.radius = getConfig().getDouble("Abilities.Water.Surge.Wall.Radius"); this.radius = getConfig().getDouble("Abilities.Water.Surge.Wall.Radius");
this.range = getConfig().getDouble("Abilities.Water.Surge.Wall.Range"); this.range = getConfig().getDouble("Abilities.Water.Surge.Wall.Range");
this.cooldown = GeneralMethods.getGlobalCooldown(); this.cooldown = GeneralMethods.getGlobalCooldown();
LavaSurgeWave wave = getAbility(player, LavaSurgeWave.class); LavaSurgeWave wave = getAbility(player, LavaSurgeWave.class);
if (wave != null && wave.isProgressing()) { if (wave != null && wave.isProgressing()) {
LavaSurgeWave.launch(player); LavaSurgeWave.launch(player);
@ -99,7 +99,7 @@ public class LavaSurgeWall extends LavaAbility {
public void moveLava() { public void moveLava() {
if (sourceBlock != null) { if (sourceBlock != null) {
targetDestination = getTargetEarthBlock((int) range).getLocation(); targetDestination = getTargetEarthBlock((int) range).getLocation();
if (targetDestination.distanceSquared(location) <= 1) { if (targetDestination.distanceSquared(location) <= 1) {
progressing = false; progressing = false;
targetDestination = null; targetDestination = null;
@ -145,19 +145,19 @@ public class LavaSurgeWall extends LavaAbility {
remove(); remove();
return; return;
} }
if (System.currentTimeMillis() - time >= interval) { if (System.currentTimeMillis() - time >= interval) {
time = System.currentTimeMillis(); time = System.currentTimeMillis();
if (progressing && !player.isSneaking()) { if (progressing && !player.isSneaking()) {
remove(); remove();
return; return;
} }
if (!progressing) { if (!progressing) {
sourceBlock.getWorld().playEffect(location, Effect.SMOKE, 4, (int) range); sourceBlock.getWorld().playEffect(location, Effect.SMOKE, 4, (int) range);
return; return;
} }
if (forming) { if (forming) {
ArrayList<Block> blocks = new ArrayList<Block>(); ArrayList<Block> blocks = new ArrayList<Block>();
Location loc = GeneralMethods.getTargetedLocation(player, (int) range, 8, 9, 79); Location loc = GeneralMethods.getTargetedLocation(player, (int) range, 8, 9, 79);
@ -165,19 +165,18 @@ public class LavaSurgeWall extends LavaAbility {
Vector dir = player.getEyeLocation().getDirection(); Vector dir = player.getEyeLocation().getDirection();
Vector vec; Vector vec;
Block block; Block block;
for (double i = 0; i <= radius; i += 0.5) { for (double i = 0; i <= radius; i += 0.5) {
for (double angle = 0; angle < 360; angle += 10) { for (double angle = 0; angle < 360; angle += 10) {
vec = GeneralMethods.getOrthogonalVector(dir.clone(), angle, i); vec = GeneralMethods.getOrthogonalVector(dir.clone(), angle, i);
block = loc.clone().add(vec).getBlock(); block = loc.clone().add(vec).getBlock();
if (GeneralMethods.isRegionProtectedFromBuild(player, "LavaSurge", block.getLocation())) { if (GeneralMethods.isRegionProtectedFromBuild(player, "LavaSurge", block.getLocation())) {
continue; continue;
} }
if (WALL_BLOCKS.containsKey(block)) { if (WALL_BLOCKS.containsKey(block)) {
blocks.add(block); blocks.add(block);
} else if (!blocks.contains(block) } else if (!blocks.contains(block) && (block.getType() == Material.AIR || block.getType() == Material.FIRE || isLavabendable(block))) {
&& (block.getType() == Material.AIR || block.getType() == Material.FIRE || isLavabendable(block))) {
WALL_BLOCKS.put(block, player); WALL_BLOCKS.put(block, player);
addWallBlock(block); addWallBlock(block);
blocks.add(block); blocks.add(block);
@ -185,34 +184,34 @@ public class LavaSurgeWall extends LavaAbility {
} }
} }
} }
for (Block blocki : WALL_BLOCKS.keySet()) { for (Block blocki : WALL_BLOCKS.keySet()) {
if (WALL_BLOCKS.get(blocki) == player && !blocks.contains(blocki)) { if (WALL_BLOCKS.get(blocki) == player && !blocks.contains(blocki)) {
finalRemoveLava(blocki); finalRemoveLava(blocki);
} }
} }
return; return;
} }
if (sourceBlock.getLocation().distanceSquared(firstDestination) < 0.5 * 0.5 && settingUp) { if (sourceBlock.getLocation().distanceSquared(firstDestination) < 0.5 * 0.5 && settingUp) {
settingUp = false; settingUp = false;
} }
Vector direction; Vector direction;
if (settingUp) { if (settingUp) {
direction = firstDirection; direction = firstDirection;
} else { } else {
direction = targetDirection; direction = targetDirection;
} }
location = location.clone().add(direction); location = location.clone().add(direction);
Block block = location.getBlock(); Block block = location.getBlock();
if (block.getLocation().equals(sourceBlock.getLocation())) { if (block.getLocation().equals(sourceBlock.getLocation())) {
location = location.clone().add(direction); location = location.clone().add(direction);
block = location.getBlock(); block = location.getBlock();
} }
if (block.getType() != Material.AIR) { if (block.getType() != Material.AIR) {
breakBlock(); breakBlock();
return; return;
@ -220,7 +219,7 @@ public class LavaSurgeWall extends LavaAbility {
breakBlock(); breakBlock();
return; return;
} }
addLava(block); addLava(block);
removeLava(sourceBlock); removeLava(sourceBlock);
sourceBlock = block; sourceBlock = block;
@ -320,7 +319,7 @@ public class LavaSurgeWall extends LavaAbility {
} }
return false; return false;
} }
public static Map<Block, Block> getAffectedBlocks() { public static Map<Block, Block> getAffectedBlocks() {
return AFFECTED_BLOCKS; return AFFECTED_BLOCKS;
} }
@ -353,7 +352,7 @@ public class LavaSurgeWall extends LavaAbility {
public boolean isHarmlessAbility() { public boolean isHarmlessAbility() {
return false; return false;
} }
public boolean isProgressing() { public boolean isProgressing() {
return progressing; return progressing;
} }
@ -457,5 +456,5 @@ public class LavaSurgeWall extends LavaAbility {
public void setLocation(Location location) { public void setLocation(Location location) {
this.location = location; this.location = location;
} }
} }

View file

@ -35,15 +35,15 @@ public class LavaSurgeWave extends LavaAbility {
private double verticalPush; private double verticalPush;
private double interval; private double interval;
private Location location; private Location location;
private Block sourceBlock ; private Block sourceBlock;
private Location targetDestination; private Location targetDestination;
private Vector targetDirection; private Vector targetDirection;
private ConcurrentHashMap<Block, Block> waveBlocks; private ConcurrentHashMap<Block, Block> waveBlocks;
private ConcurrentHashMap<Block, Block> frozenBlocks; private ConcurrentHashMap<Block, Block> frozenBlocks;
public LavaSurgeWave(Player player) { public LavaSurgeWave(Player player) {
super(player); super(player);
this.progressing = false; this.progressing = false;
this.canHitSelf = true; this.canHitSelf = true;
this.range = 20; this.range = 20;
@ -62,7 +62,7 @@ public class LavaSurgeWave extends LavaAbility {
horizontalPush = AvatarState.getValue(horizontalPush); horizontalPush = AvatarState.getValue(horizontalPush);
verticalPush = AvatarState.getValue(verticalPush); verticalPush = AvatarState.getValue(verticalPush);
} }
if (prepare()) { if (prepare()) {
LavaSurgeWave wave = getAbility(player, LavaSurgeWave.class); LavaSurgeWave wave = getAbility(player, LavaSurgeWave.class);
if (wave != null) { if (wave != null) {
@ -76,7 +76,7 @@ public class LavaSurgeWave extends LavaAbility {
public boolean prepare() { public boolean prepare() {
cancelPrevious(); cancelPrevious();
Block block = BlockSource.getSourceBlock(player, range, BlockSourceType.LAVA, ClickType.SHIFT_DOWN); Block block = BlockSource.getSourceBlock(player, range, BlockSourceType.LAVA, ClickType.SHIFT_DOWN);
if (block != null) { if (block != null) {
sourceBlock = block; sourceBlock = block;
focusBlock(); focusBlock();
@ -117,7 +117,7 @@ public class LavaSurgeWave extends LavaAbility {
} else { } else {
targetDestination = ((LivingEntity) target).getEyeLocation(); targetDestination = ((LivingEntity) target).getEyeLocation();
} }
if (targetDestination.distanceSquared(location) <= 1) { if (targetDestination.distanceSquared(location) <= 1) {
progressing = false; progressing = false;
targetDestination = null; targetDestination = null;
@ -125,7 +125,7 @@ public class LavaSurgeWave extends LavaAbility {
progressing = true; progressing = true;
targetDirection = getDirection(sourceBlock.getLocation(), targetDestination).normalize(); targetDirection = getDirection(sourceBlock.getLocation(), targetDestination).normalize();
targetDestination = location.clone().add(targetDirection.clone().multiply(range)); targetDestination = location.clone().add(targetDirection.clone().multiply(range));
if (!GeneralMethods.isAdjacentToThreeOrMoreSources(sourceBlock)) { if (!GeneralMethods.isAdjacentToThreeOrMoreSources(sourceBlock)) {
sourceBlock.setType(Material.AIR); sourceBlock.setType(Material.AIR);
} }
@ -152,39 +152,33 @@ public class LavaSurgeWave extends LavaAbility {
breakBlock(); breakBlock();
return; return;
} }
if (System.currentTimeMillis() - time >= interval) { if (System.currentTimeMillis() - time >= interval) {
time = System.currentTimeMillis(); time = System.currentTimeMillis();
if (!progressing) { if (!progressing) {
sourceBlock.getWorld().playEffect(location, Effect.SMOKE, 4, (int) range); sourceBlock.getWorld().playEffect(location, Effect.SMOKE, 4, (int) range);
return; return;
} }
Vector direction = targetDirection; Vector direction = targetDirection;
location = location.clone().add(direction); location = location.clone().add(direction);
Block blockl = location.getBlock(); Block blockl = location.getBlock();
ArrayList<Block> blocks = new ArrayList<Block>(); ArrayList<Block> blocks = new ArrayList<Block>();
if (!GeneralMethods.isRegionProtectedFromBuild(this, location) && blockl.getType() != Material.LEAVES if (!GeneralMethods.isRegionProtectedFromBuild(this, location) && blockl.getType() != Material.LEAVES && (blockl.getType() == Material.AIR || blockl.getType() == Material.FIRE || WaterAbility.isPlant(blockl) || isLava(blockl))) {
&& (blockl.getType() == Material.AIR
|| blockl.getType() == Material.FIRE
|| WaterAbility.isPlant(blockl)
|| isLava(blockl))) {
for (double i = 0; i <= radius; i += 0.5) { for (double i = 0; i <= radius; i += 0.5) {
for (double angle = 0; angle < 360; angle += 10) { for (double angle = 0; angle < 360; angle += 10) {
Vector vec = GeneralMethods.getOrthogonalVector(targetDirection, angle, i); Vector vec = GeneralMethods.getOrthogonalVector(targetDirection, angle, i);
Block block = location.clone().add(vec).getBlock(); Block block = location.clone().add(vec).getBlock();
if (!blocks.contains(block) && (block.getType() == Material.AIR if (!blocks.contains(block) && (block.getType() == Material.AIR || block.getType() == Material.FIRE) || isLavabendable(block)) {
|| block.getType() == Material.FIRE)
|| isLavabendable(block)) {
blocks.add(block); blocks.add(block);
FireBlast.removeFireBlastsAroundPoint(block.getLocation(), 2); FireBlast.removeFireBlastsAroundPoint(block.getLocation(), 2);
} }
} }
} }
} }
for (Block block : waveBlocks.keySet()) { for (Block block : waveBlocks.keySet()) {
if (!blocks.contains(block)) { if (!blocks.contains(block)) {
finalRemoveLava(block); finalRemoveLava(block);
@ -200,7 +194,7 @@ public class LavaSurgeWave extends LavaAbility {
progressing = false; progressing = false;
return; return;
} }
for (Entity entity : GeneralMethods.getEntitiesAroundPoint(location, 2 * radius)) { for (Entity entity : GeneralMethods.getEntitiesAroundPoint(location, 2 * radius)) {
boolean knockback = false; boolean knockback = false;
for (Block block : waveBlocks.keySet()) { for (Block block : waveBlocks.keySet()) {
@ -215,14 +209,14 @@ public class LavaSurgeWave extends LavaAbility {
dir.setY(dir.getY() * verticalPush); dir.setY(dir.getY() * verticalPush);
entity.setVelocity(entity.getVelocity().clone().add(dir.clone().multiply(horizontalPush))); entity.setVelocity(entity.getVelocity().clone().add(dir.clone().multiply(horizontalPush)));
entity.setFallDistance(0); entity.setFallDistance(0);
if (entity.getFireTicks() > 0) { if (entity.getFireTicks() > 0) {
entity.getWorld().playEffect(entity.getLocation(), Effect.EXTINGUISH, 0); entity.getWorld().playEffect(entity.getLocation(), Effect.EXTINGUISH, 0);
} }
entity.setFireTicks(0); entity.setFireTicks(0);
} }
} }
if (!progressing) { if (!progressing) {
breakBlock(); breakBlock();
return; return;
@ -306,7 +300,7 @@ public class LavaSurgeWave extends LavaAbility {
public String getName() { public String getName() {
return null; return null;
} }
@Override @Override
public Location getLocation() { public Location getLocation() {
return location; return location;
@ -316,7 +310,7 @@ public class LavaSurgeWave extends LavaAbility {
public long getCooldown() { public long getCooldown() {
return cooldown; return cooldown;
} }
@Override @Override
public boolean isSneakAbility() { public boolean isSneakAbility() {
return true; return true;
@ -438,5 +432,5 @@ public class LavaSurgeWave extends LavaAbility {
public void setLocation(Location location) { public void setLocation(Location location) {
this.location = location; this.location = location;
} }
} }

View file

@ -19,15 +19,15 @@ public class Extraction extends MetalAbility {
private int selectRange; private int selectRange;
private long cooldown; private long cooldown;
private Block originBlock; private Block originBlock;
public Extraction(Player player) { public Extraction(Player player) {
super(player); super(player);
this.doubleChance = getConfig().getInt("Abilities.Earth.Extraction.DoubleLootChance"); this.doubleChance = getConfig().getInt("Abilities.Earth.Extraction.DoubleLootChance");
this.tripleChance = getConfig().getInt("Abilities.Earth.Extraction.TripleLootChance"); this.tripleChance = getConfig().getInt("Abilities.Earth.Extraction.TripleLootChance");
this.cooldown = getConfig().getLong("Abilities.Earth.Extraction.Cooldown"); this.cooldown = getConfig().getLong("Abilities.Earth.Extraction.Cooldown");
this.selectRange = getConfig().getInt("Abilities.Earth.Extraction.SelectRange"); this.selectRange = getConfig().getInt("Abilities.Earth.Extraction.SelectRange");
if (!bPlayer.canBend(this)) { if (!bPlayer.canBend(this)) {
return; return;
} }
@ -91,7 +91,8 @@ public class Extraction extends MetalAbility {
} }
@Override @Override
public void progress() {} public void progress() {
}
@Override @Override
public Location getLocation() { public Location getLocation() {
@ -107,7 +108,7 @@ public class Extraction extends MetalAbility {
public long getCooldown() { public long getCooldown() {
return cooldown; return cooldown;
} }
@Override @Override
public boolean isSneakAbility() { public boolean isSneakAbility() {
return true; return true;
@ -153,5 +154,5 @@ public class Extraction extends MetalAbility {
public void setCooldown(long cooldown) { public void setCooldown(long cooldown) {
this.cooldown = cooldown; this.cooldown = cooldown;
} }
} }

View file

@ -24,15 +24,11 @@ import com.projectkorra.projectkorra.util.DamageHandler;
import com.projectkorra.projectkorra.util.TempArmor; import com.projectkorra.projectkorra.util.TempArmor;
public class MetalClips extends MetalAbility { public class MetalClips extends MetalAbility {
private static final Map<Entity, Integer> ENTITY_CLIPS_COUNT = new ConcurrentHashMap<>(); private static final Map<Entity, Integer> ENTITY_CLIPS_COUNT = new ConcurrentHashMap<>();
private static final Map<Entity, MetalClips> TARGET_TO_ABILITY = new ConcurrentHashMap<>(); private static final Map<Entity, MetalClips> TARGET_TO_ABILITY = new ConcurrentHashMap<>();
private static final Material[] METAL_ITEMS = { private static final Material[] METAL_ITEMS = { Material.IRON_INGOT, Material.IRON_HELMET, Material.IRON_CHESTPLATE, Material.IRON_LEGGINGS, Material.IRON_BOOTS, Material.IRON_BLOCK, Material.IRON_AXE, Material.IRON_PICKAXE, Material.IRON_SWORD, Material.IRON_HOE, Material.IRON_SPADE, Material.IRON_DOOR };
Material.IRON_INGOT, Material.IRON_HELMET, Material.IRON_CHESTPLATE, Material.IRON_LEGGINGS,
Material.IRON_BOOTS, Material.IRON_BLOCK, Material.IRON_AXE, Material.IRON_PICKAXE,
Material.IRON_SWORD, Material.IRON_HOE, Material.IRON_SPADE, Material.IRON_DOOR
};
private boolean isBeingWorn; private boolean isBeingWorn;
private boolean isControlling; private boolean isControlling;
private boolean canThrow; private boolean canThrow;
@ -55,7 +51,7 @@ public class MetalClips extends MetalAbility {
private LivingEntity targetEntity; private LivingEntity targetEntity;
//private ItemStack[] oldArmor; //private ItemStack[] oldArmor;
private List<Item> trackedIngots; private List<Item> trackedIngots;
public MetalClips(Player player, int abilityType) { public MetalClips(Player player, int abilityType) {
super(player); super(player);
if (hasAbility(player, MetalClips.class)) { if (hasAbility(player, MetalClips.class)) {
@ -75,14 +71,15 @@ public class MetalClips extends MetalAbility {
this.crushDamage = getConfig().getDouble("Abilities.Earth.MetalClips.CrushDamage"); this.crushDamage = getConfig().getDouble("Abilities.Earth.MetalClips.CrushDamage");
this.damage = getConfig().getDouble("Abilities.Earth.MetalClips.Damage"); this.damage = getConfig().getDouble("Abilities.Earth.MetalClips.Damage");
this.canThrow = (getConfig().getBoolean("Abilities.Earth.MetalClips.ThrowEnabled") && player.hasPermission("bending.ability.metalclips.throw")); this.canThrow = (getConfig().getBoolean("Abilities.Earth.MetalClips.ThrowEnabled") && player.hasPermission("bending.ability.metalclips.throw"));
this.trackedIngots = new ArrayList<>(); this.trackedIngots = new ArrayList<>();
if (!bPlayer.canBend(this)) { if (!bPlayer.canBend(this)) {
return; return;
} }
if (bPlayer.isAvatarState()) { if (bPlayer.isAvatarState()) {
cooldown = getConfig().getLong("Abilities.Avatar.AvatarState.Earth.MetalClips.Cooldown");; cooldown = getConfig().getLong("Abilities.Avatar.AvatarState.Earth.MetalClips.Cooldown");
;
range = getConfig().getDouble("Abilities.Avatar.AvatarState.Earth.MetalClips.Range"); range = getConfig().getDouble("Abilities.Avatar.AvatarState.Earth.MetalClips.Range");
crushDamage = getConfig().getLong("Abilities.Avatar.AvatarState.Earth.MetalClips.CrushDamage"); crushDamage = getConfig().getLong("Abilities.Avatar.AvatarState.Earth.MetalClips.CrushDamage");
} }
@ -95,46 +92,28 @@ public class MetalClips extends MetalAbility {
start(); start();
} }
/*public static ItemStack getOriginalHelmet(LivingEntity ent) {
MetalClips clips = TARGET_TO_ABILITY.get(ent);
if (clips != null) {
return clips.oldArmor[3];
}
return null;
}
public static ItemStack getOriginalChestplate(LivingEntity ent) { /*
MetalClips clips = TARGET_TO_ABILITY.get(ent); * public static ItemStack getOriginalHelmet(LivingEntity ent) { MetalClips
if (clips != null) { * clips = TARGET_TO_ABILITY.get(ent); if (clips != null) { return
return clips.oldArmor[2]; * clips.oldArmor[3]; } return null; }
} *
return null; * public static ItemStack getOriginalChestplate(LivingEntity ent) {
} * MetalClips clips = TARGET_TO_ABILITY.get(ent); if (clips != null) {
* return clips.oldArmor[2]; } return null; }
public static ItemStack getOriginalLeggings(LivingEntity ent) { *
MetalClips clips = TARGET_TO_ABILITY.get(ent); * public static ItemStack getOriginalLeggings(LivingEntity ent) {
if (clips != null) { * MetalClips clips = TARGET_TO_ABILITY.get(ent); if (clips != null) {
return clips.oldArmor[1]; * return clips.oldArmor[1]; } return null; }
} *
return null; * public static ItemStack getOriginalBoots(LivingEntity ent) { MetalClips
} * clips = TARGET_TO_ABILITY.get(ent); if (clips != null) { return
* clips.oldArmor[0]; } return null; }
public static ItemStack getOriginalBoots(LivingEntity ent) { *
MetalClips clips = TARGET_TO_ABILITY.get(ent); * public static ItemStack[] getOriginalArmor(LivingEntity ent) { MetalClips
if (clips != null) { * clips = TARGET_TO_ABILITY.get(ent); if (clips != null) { return
return clips.oldArmor[0]; * clips.oldArmor; } return null; }
} */
return null;
}
public static ItemStack[] getOriginalArmor(LivingEntity ent) {
MetalClips clips = TARGET_TO_ABILITY.get(ent);
if (clips != null) {
return clips.oldArmor;
}
return null;
}*/
public void shootMetal() { public void shootMetal() {
if (bPlayer.isOnCooldown("MetalClips Shoot")) { if (bPlayer.isOnCooldown("MetalClips Shoot")) {
@ -184,10 +163,11 @@ public class MetalClips extends MetalAbility {
metalArmor[1] = (metalClipsCount >= 3) ? new ItemStack(Material.IRON_LEGGINGS) : new ItemStack(Material.AIR); metalArmor[1] = (metalClipsCount >= 3) ? new ItemStack(Material.IRON_LEGGINGS) : new ItemStack(Material.AIR);
metalArmor[3] = (metalClipsCount >= 4) ? new ItemStack(Material.IRON_HELMET) : new ItemStack(Material.AIR); metalArmor[3] = (metalClipsCount >= 4) ? new ItemStack(Material.IRON_HELMET) : new ItemStack(Material.AIR);
ENTITY_CLIPS_COUNT.put(target, metalClipsCount); ENTITY_CLIPS_COUNT.put(target, metalClipsCount);
TempArmor armor = TempArmor.getTempArmor(target); TempArmor armor = TempArmor.getTempArmor(target);
if (armor != null) armor.revert(); if (armor != null)
armor.revert();
new TempArmor(target, this, metalArmor); new TempArmor(target, this, metalArmor);
} else { } else {
@ -198,10 +178,11 @@ public class MetalClips extends MetalAbility {
metalarmor[1] = (metalClipsCount >= 3) ? new ItemStack(Material.IRON_LEGGINGS) : new ItemStack(Material.AIR); metalarmor[1] = (metalClipsCount >= 3) ? new ItemStack(Material.IRON_LEGGINGS) : new ItemStack(Material.AIR);
metalarmor[3] = (metalClipsCount >= 4) ? new ItemStack(Material.IRON_HELMET) : new ItemStack(Material.AIR); metalarmor[3] = (metalClipsCount >= 4) ? new ItemStack(Material.IRON_HELMET) : new ItemStack(Material.AIR);
ENTITY_CLIPS_COUNT.put(targetEntity, metalClipsCount); ENTITY_CLIPS_COUNT.put(targetEntity, metalClipsCount);
TempArmor armor = TempArmor.getTempArmor(targetEntity); TempArmor armor = TempArmor.getTempArmor(targetEntity);
if (armor != null) armor.revert(); if (armor != null)
armor.revert();
new TempArmor(targetEntity, this, metalarmor); new TempArmor(targetEntity, this, metalarmor);
} }
armorStartTime = System.currentTimeMillis(); armorStartTime = System.currentTimeMillis();
@ -212,7 +193,7 @@ public class MetalClips extends MetalAbility {
if (targetEntity == null || !TempArmor.hasTempArmor(targetEntity) || targetEntity.isDead()) { if (targetEntity == null || !TempArmor.hasTempArmor(targetEntity) || targetEntity.isDead()) {
return; return;
} }
TempArmor.getTempArmor(targetEntity).revert(); TempArmor.getTempArmor(targetEntity).revert();
player.getWorld().dropItem(targetEntity.getLocation(), new ItemStack(Material.IRON_INGOT, metalClipsCount)); player.getWorld().dropItem(targetEntity.getLocation(), new ItemStack(Material.IRON_INGOT, metalClipsCount));
@ -224,7 +205,7 @@ public class MetalClips extends MetalAbility {
if (!canThrow) { if (!canThrow) {
return; return;
} }
if (targetEntity == null) { if (targetEntity == null) {
return; return;
} }
@ -237,10 +218,10 @@ public class MetalClips extends MetalAbility {
dz = target.getZ() - location.getZ(); dz = target.getZ() - location.getZ();
Vector vector = new Vector(dx, dy, dz); Vector vector = new Vector(dx, dy, dz);
vector.normalize(); vector.normalize();
targetEntity.setVelocity(vector.multiply(metalClipsCount/2).normalize()); targetEntity.setVelocity(vector.multiply(metalClipsCount / 2).normalize());
remove(); remove();
} }
public void crush() { public void crush() {
if (bPlayer.isOnCooldown("MetalClips Crush")) { if (bPlayer.isOnCooldown("MetalClips Crush")) {
return; return;
@ -262,7 +243,7 @@ public class MetalClips extends MetalAbility {
return; return;
} }
} }
if (player.isSneaking()) { if (player.isSneaking()) {
hasSnuck = true; hasSnuck = true;
} }
@ -283,7 +264,7 @@ public class MetalClips extends MetalAbility {
for (Entity entity : GeneralMethods.getEntitiesAroundPoint(player.getLocation(), magnetRange)) { for (Entity entity : GeneralMethods.getEntitiesAroundPoint(player.getLocation(), magnetRange)) {
Vector vector = GeneralMethods.getDirection(entity.getLocation(), player.getLocation()); Vector vector = GeneralMethods.getDirection(entity.getLocation(), player.getLocation());
ItemStack itemInHand = player.getInventory().getItemInMainHand(); ItemStack itemInHand = player.getInventory().getItemInMainHand();
if (entity instanceof Player && canLoot && itemInHand.getType() == Material.IRON_INGOT && itemInHand.getItemMeta().getDisplayName().equalsIgnoreCase("Magnet")) { if (entity instanceof Player && canLoot && itemInHand.getType() == Material.IRON_INGOT && itemInHand.getItemMeta().getDisplayName().equalsIgnoreCase("Magnet")) {
Player targetPlayer = (Player) entity; Player targetPlayer = (Player) entity;
@ -322,10 +303,7 @@ public class MetalClips extends MetalAbility {
} }
} }
if ((entity instanceof Zombie || entity instanceof Skeleton) if ((entity instanceof Zombie || entity instanceof Skeleton) && canLoot && itemInHand.getType() == Material.IRON_INGOT && itemInHand.getItemMeta().getDisplayName().equalsIgnoreCase("Magnet")) {
&& canLoot
&& itemInHand.getType() == Material.IRON_INGOT
&& itemInHand.getItemMeta().getDisplayName().equalsIgnoreCase("Magnet")) {
LivingEntity livingEntity = (LivingEntity) entity; LivingEntity livingEntity = (LivingEntity) entity;
ItemStack[] armor = livingEntity.getEquipment().getArmorContents(); ItemStack[] armor = livingEntity.getEquipment().getArmorContents();
@ -364,11 +342,11 @@ public class MetalClips extends MetalAbility {
if (metalClipsCount == 1) { if (metalClipsCount == 1) {
Location oldLocation = targetEntity.getLocation(); Location oldLocation = targetEntity.getLocation();
Location loc = oldLocation; Location loc = oldLocation;
if(player.getWorld().equals(oldLocation.getWorld())) { if (player.getWorld().equals(oldLocation.getWorld())) {
loc = GeneralMethods.getTargetedLocation(player, (int) player.getLocation().distance(oldLocation)); loc = GeneralMethods.getTargetedLocation(player, (int) player.getLocation().distance(oldLocation));
} }
double distance = 0; double distance = 0;
if(loc.getWorld().equals(oldLocation.getWorld())) { if (loc.getWorld().equals(oldLocation.getWorld())) {
distance = loc.distance(oldLocation); distance = loc.distance(oldLocation);
} }
Vector vector = GeneralMethods.getDirection(targetEntity.getLocation(), player.getLocation()); Vector vector = GeneralMethods.getDirection(targetEntity.getLocation(), player.getLocation());
@ -381,11 +359,11 @@ public class MetalClips extends MetalAbility {
if (metalClipsCount == 2) { if (metalClipsCount == 2) {
Location oldLocation = targetEntity.getLocation(); Location oldLocation = targetEntity.getLocation();
Location loc = oldLocation; Location loc = oldLocation;
if(player.getWorld().equals(oldLocation.getWorld())) { if (player.getWorld().equals(oldLocation.getWorld())) {
loc = GeneralMethods.getTargetedLocation(player, (int) player.getLocation().distance(oldLocation)); loc = GeneralMethods.getTargetedLocation(player, (int) player.getLocation().distance(oldLocation));
} }
double distance = 0; double distance = 0;
if(loc.getWorld().equals(oldLocation.getWorld())) { if (loc.getWorld().equals(oldLocation.getWorld())) {
distance = loc.distance(oldLocation); distance = loc.distance(oldLocation);
} }
Vector vector = GeneralMethods.getDirection(targetEntity.getLocation(), GeneralMethods.getTargetedLocation(player, 10)); Vector vector = GeneralMethods.getDirection(targetEntity.getLocation(), GeneralMethods.getTargetedLocation(player, 10));
@ -398,15 +376,15 @@ public class MetalClips extends MetalAbility {
if (metalClipsCount >= 3) { if (metalClipsCount >= 3) {
Location oldLocation = targetEntity.getLocation(); Location oldLocation = targetEntity.getLocation();
Location loc = oldLocation; Location loc = oldLocation;
if(player.getWorld().equals(oldLocation.getWorld())) { if (player.getWorld().equals(oldLocation.getWorld())) {
loc = GeneralMethods.getTargetedLocation(player, (int) player.getLocation().distance(oldLocation)); loc = GeneralMethods.getTargetedLocation(player, (int) player.getLocation().distance(oldLocation));
} }
double distance = 0; double distance = 0;
if(loc.getWorld().equals(oldLocation.getWorld())) { if (loc.getWorld().equals(oldLocation.getWorld())) {
distance = loc.distance(oldLocation); distance = loc.distance(oldLocation);
} }
Vector vector = GeneralMethods.getDirection(oldLocation, GeneralMethods.getTargetedLocation(player, 10)); Vector vector = GeneralMethods.getDirection(oldLocation, GeneralMethods.getTargetedLocation(player, 10));
if (distance > 1.2) { if (distance > 1.2) {
targetEntity.setVelocity(vector.normalize().multiply(.5)); targetEntity.setVelocity(vector.normalize().multiply(.5));
} else { } else {
@ -471,11 +449,11 @@ public class MetalClips extends MetalAbility {
@Override @Override
public void remove() { public void remove() {
super.remove(); super.remove();
resetArmor(); resetArmor();
trackedIngots.clear(); trackedIngots.clear();
metalClipsCount = 0; metalClipsCount = 0;
if (targetEntity != null) { if (targetEntity != null) {
ENTITY_CLIPS_COUNT.remove(targetEntity); ENTITY_CLIPS_COUNT.remove(targetEntity);
TARGET_TO_ABILITY.remove(targetEntity); TARGET_TO_ABILITY.remove(targetEntity);
@ -485,22 +463,23 @@ public class MetalClips extends MetalAbility {
public static boolean isControlled(LivingEntity player) { public static boolean isControlled(LivingEntity player) {
return TARGET_TO_ABILITY.containsKey(player); return TARGET_TO_ABILITY.containsKey(player);
} }
public static boolean isControllingEntity(Player player) { public static boolean isControllingEntity(Player player) {
MetalClips clips = getAbility(player, MetalClips.class); MetalClips clips = getAbility(player, MetalClips.class);
return clips != null && player.isSneaking() && clips.targetEntity != null; return clips != null && player.isSneaking() && clips.targetEntity != null;
} }
public static Map<Entity, Integer> getEntityClipsCount() { public static Map<Entity, Integer> getEntityClipsCount() {
return ENTITY_CLIPS_COUNT; return ENTITY_CLIPS_COUNT;
} }
public static Map<Entity, MetalClips> getTargetToAbility() { public static Map<Entity, MetalClips> getTargetToAbility() {
return TARGET_TO_ABILITY; return TARGET_TO_ABILITY;
} }
public static boolean removeControlledEnitity(LivingEntity entity) { public static boolean removeControlledEnitity(LivingEntity entity) {
if (entity == null) return false; if (entity == null)
return false;
for (MetalClips metalclips : CoreAbility.getAbilities(MetalClips.class)) { for (MetalClips metalclips : CoreAbility.getAbilities(MetalClips.class)) {
if (metalclips.targetEntity == entity) { if (metalclips.targetEntity == entity) {
metalclips.remove(); metalclips.remove();
@ -529,15 +508,15 @@ public class MetalClips extends MetalAbility {
public long getCooldown() { public long getCooldown() {
return cooldown; return cooldown;
} }
public long getShootCooldown() { public long getShootCooldown() {
return shootCooldown; return shootCooldown;
} }
public long getCrushCooldown() { public long getCrushCooldown() {
return crushCooldown; return crushCooldown;
} }
@Override @Override
public boolean isSneakAbility() { public boolean isSneakAbility() {
return true; return true;

View file

@ -14,7 +14,7 @@ public class DensityShift extends EarthAbility implements PassiveAbility {
@Override @Override
public void progress() { public void progress() {
} }
@Override @Override

View file

@ -33,7 +33,7 @@ public class EarthPassive {
if (Commands.isToggledForAll && ConfigManager.defaultConfig.get().getBoolean("Properties.TogglePassivesWithAllBending")) { if (Commands.isToggledForAll && ConfigManager.defaultConfig.get().getBoolean("Properties.TogglePassivesWithAllBending")) {
return false; return false;
} }
Block block = player.getLocation().getBlock().getRelative(BlockFace.DOWN); Block block = player.getLocation().getBlock().getRelative(BlockFace.DOWN);
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (bPlayer == null) { if (bPlayer == null) {
@ -41,7 +41,7 @@ public class EarthPassive {
} else if (bPlayer.canMetalbend() && ElementalAbility.isMetalBlock(block)) { } else if (bPlayer.canMetalbend() && ElementalAbility.isMetalBlock(block)) {
return true; return true;
} }
if (EarthAbility.isEarthbendable(player, block) || ElementalAbility.isTransparent(player, block)) { if (EarthAbility.isEarthbendable(player, block) || ElementalAbility.isTransparent(player, block)) {
if (!ElementalAbility.isTransparent(player, block)) { if (!ElementalAbility.isTransparent(player, block)) {
MaterialData type = block.getState().getData(); MaterialData type = block.getState().getData();
@ -81,8 +81,7 @@ public class EarthPassive {
return true; return true;
} }
return (TempBlock.isTempBlock(block) && EarthAbility.isEarthbendable(TempBlock.get(block).getBlock().getType())) return (TempBlock.isTempBlock(block) && EarthAbility.isEarthbendable(TempBlock.get(block).getBlock().getType())) || EarthAbility.isEarthbendable(player, block) || EarthAbility.isTransparent(player, block);
|| EarthAbility.isEarthbendable(player, block) || EarthAbility.isTransparent(player, block);
} }
public static boolean isPassiveSand(Block block) { public static boolean isPassiveSand(Block block) {
@ -94,7 +93,7 @@ public class EarthPassive {
MaterialData materialdata = SAND_ID_ENTITIES.get(block); MaterialData materialdata = SAND_ID_ENTITIES.get(block);
SAND_ID_ENTITIES.remove(block); SAND_ID_ENTITIES.remove(block);
SAND_BLOCKS.remove(block); SAND_BLOCKS.remove(block);
if (block.getType() == Material.SAND) { if (block.getType() == Material.SAND) {
block.setType(materialdata.getItemType()); block.setType(materialdata.getItemType());
block.setData(materialdata.getData()); block.setData(materialdata.getData());
@ -105,14 +104,14 @@ public class EarthPassive {
public static void handleMetalPassives() { public static void handleMetalPassives() {
for (Player player : Bukkit.getOnlinePlayers()) { for (Player player : Bukkit.getOnlinePlayers()) {
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (bPlayer != null && bPlayer.canBendPassive(Element.EARTH) && bPlayer.canMetalbend()) { if (bPlayer != null && bPlayer.canBendPassive(Element.EARTH) && bPlayer.canMetalbend()) {
if (player.isSneaking() && !bPlayer.isOnCooldown("MetalPassive")) { if (player.isSneaking() && !bPlayer.isOnCooldown("MetalPassive")) {
Block block = player.getTargetBlock((HashSet<Material>) null, 5); Block block = player.getTargetBlock((HashSet<Material>) null, 5);
if (block == null) { if (block == null) {
continue; continue;
} }
if (block.getType() == Material.IRON_DOOR_BLOCK && !GeneralMethods.isRegionProtectedFromBuild(player, block.getLocation())) { if (block.getType() == Material.IRON_DOOR_BLOCK && !GeneralMethods.isRegionProtectedFromBuild(player, block.getLocation())) {
if (block.getData() >= 8) { if (block.getData() >= 8) {
block = block.getRelative(BlockFace.DOWN); block = block.getRelative(BlockFace.DOWN);
@ -178,7 +177,7 @@ public class EarthPassive {
} }
return true; return true;
} }
public static Map<Block, Long> getSandBlocks() { public static Map<Block, Long> getSandBlocks() {
return SAND_BLOCKS; return SAND_BLOCKS;
} }

View file

@ -32,10 +32,10 @@ public class SandSpout extends SandAbility {
private boolean couldFly; private boolean couldFly;
private boolean wasFlying; private boolean wasFlying;
private Flight flight; private Flight flight;
public SandSpout(Player player) { public SandSpout(Player player) {
super(player); super(player);
this.currentHeight = 0; this.currentHeight = 0;
this.angle = 0; this.angle = 0;
this.interval = getConfig().getLong("Abilities.Earth.SandSpout.Interval"); this.interval = getConfig().getLong("Abilities.Earth.SandSpout.Interval");
@ -43,16 +43,16 @@ public class SandSpout extends SandAbility {
this.height = getConfig().getDouble("Abilities.Earth.SandSpout.Height"); this.height = getConfig().getDouble("Abilities.Earth.SandSpout.Height");
this.blindnessTime = getConfig().getInt("Abilities.Earth.SandSpout.BlindnessTime"); this.blindnessTime = getConfig().getInt("Abilities.Earth.SandSpout.BlindnessTime");
this.damage = getConfig().getInt("Abilities.Earth.SandSpout.SpoutDamage"); this.damage = getConfig().getInt("Abilities.Earth.SandSpout.SpoutDamage");
this.couldFly = player.getAllowFlight(); this.couldFly = player.getAllowFlight();
this.wasFlying = player.isFlying(); this.wasFlying = player.isFlying();
SandSpout oldSandSpout = getAbility(player, SandSpout.class); SandSpout oldSandSpout = getAbility(player, SandSpout.class);
if (oldSandSpout != null) { if (oldSandSpout != null) {
oldSandSpout.remove(); oldSandSpout.remove();
return; return;
} }
if (!bPlayer.canBend(this)) { if (!bPlayer.canBend(this)) {
return; return;
} }
@ -62,16 +62,16 @@ public class SandSpout extends SandAbility {
if (topBlock == null) { if (topBlock == null) {
topBlock = player.getLocation().getBlock(); topBlock = player.getLocation().getBlock();
} }
Material mat = topBlock.getType(); Material mat = topBlock.getType();
if (mat != Material.SAND && mat != Material.SANDSTONE && mat != Material.RED_SANDSTONE) { if (mat != Material.SAND && mat != Material.SANDSTONE && mat != Material.RED_SANDSTONE) {
return; return;
} }
if (EarthPassive.isPassiveSand(topBlock)) { if (EarthPassive.isPassiveSand(topBlock)) {
return; return;
} }
flight = new Flight(player); flight = new Flight(player);
start(); start();
bPlayer.addCooldown(this); bPlayer.addCooldown(this);
@ -90,14 +90,14 @@ public class SandSpout extends SandAbility {
if ((new Random()).nextInt(2) == 0) { if ((new Random()).nextInt(2) == 0) {
playSandBendingSound(player.getLocation()); playSandBendingSound(player.getLocation());
} }
Block block = getGround(); Block block = getGround();
if (EarthPassive.isPassiveSand(block)) { if (EarthPassive.isPassiveSand(block)) {
remove(); remove();
return; return;
} }
if (block != null && (block.getType() == Material.SAND || block.getType() == Material.SANDSTONE || block.getType() == Material.RED_SANDSTONE)) { if (block != null && (block.getType() == Material.SAND || block.getType() == Material.SANDSTONE || block.getType() == Material.RED_SANDSTONE)) {
double dy = player.getLocation().getY() - block.getY(); double dy = player.getLocation().getY() - block.getY();
if (dy > height) { if (dy > height) {
@ -146,7 +146,7 @@ public class SandSpout extends SandAbility {
if (dy > height) { if (dy > height) {
dy = height; dy = height;
} }
Integer[] directions = { 0, 1, 2, 3, 5, 6, 7, 8 }; Integer[] directions = { 0, 1, 2, 3, 5, 6, 7, 8 };
int index = angle; int index = angle;
@ -190,7 +190,7 @@ public class SandSpout extends SandAbility {
if (this.currentHeight >= player.getY() - location.getY()) { if (this.currentHeight >= player.getY() - location.getY()) {
this.currentHeight = 0D; this.currentHeight = 0D;
} }
for (int points = 0; points <= 5; points++) { for (int points = 0; points <= 5; points++) {
double x = Math.cos(currentHeight); double x = Math.cos(currentHeight);
double z = Math.sin(currentHeight); double z = Math.sin(currentHeight);
@ -198,7 +198,7 @@ public class SandSpout extends SandAbility {
double nz = z * -1; double nz = z * -1;
Location newLoc = new Location(player.getWorld(), location.getX() + x, location.getY() + currentHeight, location.getZ() + z); Location newLoc = new Location(player.getWorld(), location.getX() + x, location.getY() + currentHeight, location.getZ() + z);
Location secondLoc = new Location(player.getWorld(), location.getX() + nx, location.getY() + currentHeight, location.getZ() + nz); Location secondLoc = new Location(player.getWorld(), location.getX() + nx, location.getY() + currentHeight, location.getZ() + nz);
if (block != null && ((block.getType() == Material.SAND && block.getData() == (byte) 0) || block.getType() == Material.SANDSTONE)) { if (block != null && ((block.getType() == Material.SAND && block.getData() == (byte) 0) || block.getType() == Material.SANDSTONE)) {
displaySandParticle(newLoc.add(0.5, 0.5, 0.5), 0.1F, 0.1F, 0.1F, 2, 1, false); displaySandParticle(newLoc.add(0.5, 0.5, 0.5), 0.1F, 0.1F, 0.1F, 2, 1, false);
displaySandParticle(secondLoc.add(0.5, 0.5, 0.5), 0.1F, 0.1F, 0.1F, 2, 1, false); displaySandParticle(secondLoc.add(0.5, 0.5, 0.5), 0.1F, 0.1F, 0.1F, 2, 1, false);
@ -252,7 +252,7 @@ public class SandSpout extends SandAbility {
public long getCooldown() { public long getCooldown() {
return 0; return 0;
} }
@Override @Override
public boolean isSneakAbility() { public boolean isSneakAbility() {
return true; return true;
@ -262,7 +262,7 @@ public class SandSpout extends SandAbility {
public boolean isHarmlessAbility() { public boolean isHarmlessAbility() {
return false; return false;
} }
@Override @Override
public List<Location> getLocations() { public List<Location> getLocations() {
ArrayList<Location> locations = new ArrayList<>(); ArrayList<Location> locations = new ArrayList<>();
@ -340,5 +340,5 @@ public class SandSpout extends SandAbility {
public void setCurrentHeight(double currentHeight) { public void setCurrentHeight(double currentHeight) {
this.currentHeight = currentHeight; this.currentHeight = currentHeight;
} }
} }

View file

@ -38,5 +38,5 @@ public class AbilityCollisionEvent extends Event implements Cancellable {
public HandlerList getHandlers() { public HandlerList getHandlers() {
return HANDLERS; return HANDLERS;
} }
} }

View file

@ -10,21 +10,23 @@ import com.projectkorra.projectkorra.ability.Ability;
/** /**
* Called when an ability damages an {@link Entity} * Called when an ability damages an {@link Entity}
*
* @author kingbirdy * @author kingbirdy
* *
*/ */
public class AbilityDamageEntityEvent extends Event implements Cancellable { public class AbilityDamageEntityEvent extends Event implements Cancellable {
private static final HandlerList handlers = new HandlerList(); private static final HandlerList handlers = new HandlerList();
private boolean cancelled = false; private boolean cancelled = false;
private Entity entity; private Entity entity;
private Ability ability; private Ability ability;
private double damage; private double damage;
private boolean ignoreArmor; private boolean ignoreArmor;
/** /**
* Create a new AbilityDamageEntityEvent * Create a new AbilityDamageEntityEvent
*
* @param entity The entity that was damaged * @param entity The entity that was damaged
* @param ability The damaging ability * @param ability The damaging ability
* @param damage The amount of damage done * @param damage The amount of damage done
@ -35,9 +37,10 @@ public class AbilityDamageEntityEvent extends Event implements Cancellable {
this.damage = damage; this.damage = damage;
this.ignoreArmor = ignoreArmor; this.ignoreArmor = ignoreArmor;
} }
/** /**
* Returns the damage dealt to the entity * Returns the damage dealt to the entity
*
* @return the amount of damage done * @return the amount of damage done
*/ */
public double getDamage() { public double getDamage() {
@ -46,6 +49,7 @@ public class AbilityDamageEntityEvent extends Event implements Cancellable {
/** /**
* Sets the damage dealt to the entity * Sets the damage dealt to the entity
*
* @param damage the amount of damage done * @param damage the amount of damage done
*/ */
public void setDamage(double damage) { public void setDamage(double damage) {
@ -54,6 +58,7 @@ public class AbilityDamageEntityEvent extends Event implements Cancellable {
/** /**
* Gets the entity that was damaged * Gets the entity that was damaged
*
* @return the damaged entity * @return the damaged entity
*/ */
public Entity getEntity() { public Entity getEntity() {
@ -62,30 +67,32 @@ public class AbilityDamageEntityEvent extends Event implements Cancellable {
/** /**
* Gets the ability used * Gets the ability used
*
* @return ability used * @return ability used
*/ */
public Ability getAbility() { public Ability getAbility() {
return ability; return ability;
} }
public boolean doesIgnoreArmor() { public boolean doesIgnoreArmor() {
return ignoreArmor; return ignoreArmor;
} }
/** /**
* Gets the player that used the ability * Gets the player that used the ability
*
* @return player that used ability * @return player that used ability
*/ */
public Player getSource() { public Player getSource() {
return ability.getPlayer(); return ability.getPlayer();
} }
public HandlerList getHandlers() { public HandlerList getHandlers() {
return handlers; return handlers;
} }
public static HandlerList getHandlerList() { public static HandlerList getHandlerList() {
return handlers; return handlers;
} }
@Override @Override

Some files were not shown because too many files have changed in this diff Show more