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

View file

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

View file

@ -133,34 +133,26 @@ import net.sacredlabyrinth.Phaed.PreciousStones.PreciousStones;
@SuppressWarnings("deprecation")
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,
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 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 };
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
private static final Map<String, Map<Block, BlockCacheElement>> BLOCK_CACHE = new ConcurrentHashMap<>();
private static final ArrayList<Ability> INVINCIBLE = new ArrayList<>();
private static ProjectKorra plugin;
private static Method getAbsorption;
private static Method setAbsorption;
public GeneralMethods(ProjectKorra plugin) {
GeneralMethods.plugin = plugin;
try {
getAbsorption = ReflectionHandler.getMethod("EntityPlayer", PackageType.MINECRAFT_SERVER, "getAbsorptionHearts");
setAbsorption = ReflectionHandler.getMethod("EntityPlayer", PackageType.MINECRAFT_SERVER, "setAbsorptionHearts", Float.class);
} catch (Exception e) {
}
catch (Exception e) {
e.printStackTrace();
}
}
@ -204,12 +196,12 @@ public class GeneralMethods {
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player.getName());
CoreAbility coreAbil = CoreAbility.getAbility(ability);
if (bPlayer == null) {
return;
}
bPlayer.getAbilities().put(slot, ability);
if (coreAbil != null) {
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")) {
hasBlocked = AirSwipe.removeSwipesAroundPoint(loc, radius) || hasBlocked;
} else if (ability.equalsIgnoreCase("AirBlast")) {
hasBlocked = AirBlast.removeAirBlastsAroundPoint(loc, radius) || hasBlocked;
hasBlocked = AirBlast.removeAirBlastsAroundPoint(loc, radius) || hasBlocked;
} else if (ability.equalsIgnoreCase("AirSuction")) {
hasBlocked = AirSuction.removeAirSuctionsAroundPoint(loc, radius) || hasBlocked;
hasBlocked = AirSuction.removeAirSuctionsAroundPoint(loc, radius) || hasBlocked;
} else if (ability.equalsIgnoreCase("Combustion")) {
hasBlocked = Combustion.removeAroundPoint(loc, radius) || hasBlocked;
} else if (ability.equalsIgnoreCase("FireShield")) {
@ -290,12 +282,12 @@ public class GeneralMethods {
* @throws SQLException
*/
public static void createBendingPlayer(final UUID uuid, final String player) {
// new BukkitRunnable() {
// @Override
// public void run() {
// createBendingPlayerAsynchronously(uuid, player);
// }
// }.runTaskAsynchronously(ProjectKorra.plugin);
// new BukkitRunnable() {
// @Override
// public void run() {
// createBendingPlayerAsynchronously(uuid, player);
// }
// }.runTaskAsynchronously(ProjectKorra.plugin);
createBendingPlayerAsynchronously(uuid, player); // "async"
}
@ -355,14 +347,12 @@ public class GeneralMethods {
if (subelement.equals("-")) {
Player playero = Bukkit.getPlayer(uuid);
for (SubElement sub : Element.getAllSubElements()) {
if ((playero != null && playero.hasPermission("bending." + sub.getParentElement().getName().toLowerCase() + "." + sub.getName().toLowerCase()
+ sub.getType().getBending())) && elements.contains(sub.getParentElement())) {
if ((playero != null && playero.hasPermission("bending." + sub.getParentElement().getName().toLowerCase() + "." + sub.getName().toLowerCase() + sub.getType().getBending())) && elements.contains(sub.getParentElement())) {
subelements.add(sub);
shouldSave = true && playero != null;
}
}
}
else if (split[0] != null) {
} else if (split[0] != null) {
if (split[0].contains("m")) {
subelements.add(Element.METAL);
}
@ -399,7 +389,7 @@ public class GeneralMethods {
if (hasAddon) {
for (String addon : split[split.length - 1].split(",")) {
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();
}
}
/**
* Deserializes the configuration file "bendingPlayers.yml" of the old
@ -448,7 +437,7 @@ public class GeneralMethods {
if (readFile.exists()) {
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;
while ((line = reader.readLine()) != null) {
@ -583,19 +572,18 @@ public class GeneralMethods {
block.getWorld().dropItem(block.getLocation(), item);
}
}
public static void displayMovePreview(Player player, CoreAbility ability) {
String displayedMessage = null;
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (ConfigManager.defaultConfig.get().getBoolean("Properties.BendingPreview") == true) {
if (ability != null && bPlayer != null) {
if (bPlayer.isOnCooldown(ability)) {
displayedMessage = ability.getElement().getColor() + "" + ChatColor.STRIKETHROUGH + ability.getName();
} else {
if (bPlayer.getStance() instanceof AcrobatStance && ability.getName().equals("AcrobatStance") ||
bPlayer.getStance() instanceof WarriorStance && ability.getName().equals("WarriorStance")) {
if (bPlayer.getStance() instanceof AcrobatStance && ability.getName().equals("AcrobatStance") || bPlayer.getStance() instanceof WarriorStance && ability.getName().equals("WarriorStance")) {
displayedMessage = ability.getElement().getColor() + "" + ChatColor.UNDERLINE + ability.getName();
} else {
displayedMessage = ability.getElement().getColor() + ability.getName();
@ -604,31 +592,33 @@ public class GeneralMethods {
} else {
displayedMessage = "";
}
ActionBar.sendActionBar(displayedMessage, player);
}
}
public static float getAbsorbationHealth(Player player) {
try {
Object entityplayer = ActionBar.getHandle.invoke(player);
Object hearts = getAbsorption.invoke(entityplayer);
//player.sendMessage(hearts.toString());
return (float) hearts;
} catch (Exception e) {
}
catch (Exception e) {
e.printStackTrace();
}
return 0;
}
public static void setAbsorbationHealth(Player player, float hearts) {
try {
Object entityplayer = ActionBar.getHandle.invoke(player);
setAbsorption.invoke(entityplayer, hearts);
//player.sendMessage(hearts.toString());
} catch (Exception e) {
}
catch (Exception e) {
e.printStackTrace();
}
}
@ -838,37 +828,37 @@ public class GeneralMethods {
List<Entity> entities = new ArrayList<Entity>();
World world = location.getWorld();
// To find chunks we use chunk coordinates (not block coordinates!)
int smallX = (int) (location.getX() - radius) >> 4;
int bigX = (int) (location.getX() + radius) >> 4;
int smallZ = (int) (location.getZ() - radius) >> 4;
int bigZ = (int) (location.getZ() + radius) >> 4;
// To find chunks we use chunk coordinates (not block coordinates!)
int smallX = (int) (location.getX() - radius) >> 4;
int bigX = (int) (location.getX() + radius) >> 4;
int smallZ = (int) (location.getZ() - radius) >> 4;
int bigZ = (int) (location.getZ() + radius) >> 4;
for (int x = smallX; x <= bigX; x++) {
for (int z = smallZ; z <= bigZ; z++) {
if (world.isChunkLoaded(x, z)) {
entities.addAll(Arrays.asList(world.getChunkAt(x, z).getEntities()));
}
}
}
for (int x = smallX; x <= bigX; x++) {
for (int z = smallZ; z <= bigZ; z++) {
if (world.isChunkLoaded(x, z)) {
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;
}
public static long getGlobalCooldown() {
return ConfigManager.defaultConfig.get().getLong("Properties.GlobalCooldown");
}
/**
*
* @param one One location being tested
@ -878,7 +868,7 @@ public class GeneralMethods {
public static double getHorizontalDistance(Location one, Location two) {
double x = one.getX() - two.getX();
double z = one.getZ() - two.getZ();
return Math.sqrt((x*x) + (z*z));
return Math.sqrt((x * x) + (z * z));
}
@SuppressWarnings("incomplete-switch")
@ -994,28 +984,28 @@ public class GeneralMethods {
float angle = location.getYaw() / 60;
return location.clone().subtract(new Vector(Math.cos(angle), 0, Math.sin(angle)).normalize().multiply(distance));
}
public static Plugin getProbending() {
if (hasProbending()) {
return Bukkit.getServer().getPluginManager().getPlugin("Probending");
}
return null;
}
public static Plugin getRPG() {
if (hasRPG()) {
return Bukkit.getServer().getPluginManager().getPlugin("ProjectKorraRPG");
}
return null;
}
public static Plugin getSpirits() {
if (hasSpirits()) {
return Bukkit.getServer().getPluginManager().getPlugin("ProjectKorraSpirits");
}
return null;
}
@SuppressWarnings("unused")
public static Entity getTargetedEntity(Player player, double range, List<Entity> avoid) {
double longestr = range + 1;
@ -1027,11 +1017,7 @@ public class GeneralMethods {
continue;
}
if (entity.getWorld().equals(origin.getWorld())) {
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)))) {
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)))) {
target = entity;
longestr = entity.getLocation().distance(origin);
}
@ -1049,7 +1035,7 @@ public class GeneralMethods {
}
return target;
}
public static Entity getTargetedEntity(Player player, double range) {
return getTargetedEntity(player, range, new ArrayList<Entity>());
}
@ -1071,7 +1057,7 @@ public class GeneralMethods {
Block block = player.getTargetBlock(trans, (int) originselectrange + 1);
double distance = originselectrange;
if(block.getWorld().equals(origin.getWorld())) {
if (block.getWorld().equals(origin.getWorld())) {
distance = block.getLocation().distance(origin) - 1.5;
}
Location location = origin.add(direction.multiply(distance));
@ -1136,13 +1122,12 @@ public class GeneralMethods {
}
}
return blockHolder;
}
public static ArrayList<Element> getElementsWithNoWeaponBending() {
ArrayList<Element> elements = new ArrayList<Element>();
if (!plugin.getConfig().getBoolean("Properties.Air.CanBendWithWeapons"))
elements.add(Element.AIR);
if (!plugin.getConfig().getBoolean("Properties.Water.CanBendWithWeapons"))
@ -1153,14 +1138,14 @@ public class GeneralMethods {
elements.add(Element.FIRE);
if (!plugin.getConfig().getBoolean("Properties.Chi.CanBendWithWeapons"))
elements.add(Element.CHI);
return elements;
}
public static boolean hasItems() {
return Bukkit.getServer().getPluginManager().getPlugin("ProjectKorraItems") != null;
}
public static boolean hasProbending() {
return Bukkit.getServer().getPluginManager().getPlugin("Probending") != null;
}
@ -1168,7 +1153,7 @@ public class GeneralMethods {
public static boolean hasRPG() {
return Bukkit.getServer().getPluginManager().getPlugin("ProjectKorraRPG") != null;
}
public static boolean hasSpirits() {
return Bukkit.getServer().getPluginManager().getPlugin("ProjectKorraSpirits") != null;
}
@ -1195,7 +1180,7 @@ public class GeneralMethods {
public static boolean isImportEnabled() {
return ConfigManager.defaultConfig.get().getBoolean("Properties.ImportEnabled");
}
public static boolean isInteractable(Block block) {
return Arrays.asList(INTERACTABLE_MATERIALS).contains(block.getType());
}
@ -1210,7 +1195,7 @@ public class GeneralMethods {
Location loc;
double max = 0;
if(location1.getWorld().equals(location2.getWorld()))
if (location1.getWorld().equals(location2.getWorld()))
max = location1.distance(location2);
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()));
return value;
}
public static boolean isRegionProtectedFromBuild(Ability ability, Location loc) {
return isRegionProtectedFromBuild(ability.getPlayer(), ability.getName(), loc);
}
public static boolean isRegionProtectedFromBuild(Player player, Location loc) {
return isRegionProtectedFromBuild(player, null, loc);
}
@ -1417,7 +1402,7 @@ public class GeneralMethods {
return true;
}
}
if (residence != null && respectResidence) {
ClaimedResidence res = Residence.getResidenceManager().getByLoc(loc);
if (res != null) {
@ -1427,12 +1412,12 @@ public class GeneralMethods {
}
}
}
if (kingdoms != null && respectKingdoms) {
SimpleLocation location_ = new SimpleLocation(loc);
SimpleChunkLocation chunk = location_.toSimpleChunk();
SimpleLocation location_ = new SimpleLocation(loc);
SimpleChunkLocation chunk = location_.toSimpleChunk();
Land land = GameManagement.getLandManager().getOrLoadLand(chunk);
if (land.getOwner() != null) {
KingdomPlayer kp = GameManagement.getPlayerManager().getSession(player);
@ -1441,25 +1426,21 @@ public class GeneralMethods {
return true;
} else if (kp.getKingdom() == null) { //If the player isn't in a kingdom but it's claimed land
return true;
}
else
{
} else {
Kingdom kingdom = kp.getKingdom();
String kingdomName = kingdom.getKingdomName();
if (!kingdomName.equals(land.getOwner())) //If the player's kingdom doesn't match
{
return true;
}
//If it's within the nexus area, test for higher permission
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;
}
}
}
}
}
}
}
@ -1471,16 +1452,15 @@ public class GeneralMethods {
return !Arrays.asList(NON_OPAQUE).contains(block.getTypeId());
}
/** Checks if an entity is Undead **/
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);
}
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) {
Player player = Bukkit.getPlayer(pl.getUUID());
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
@ -1497,17 +1477,17 @@ public class GeneralMethods {
Preset.loadPresets(player);
Element element = null;
String prefix = "";
boolean chatEnabled = ConfigManager.languageConfig.get().getBoolean("Chat.Enable");
if (bPlayer.getElements().size() > 1) {
prefix = Element.AVATAR.getPrefix();
} else if (bPlayer.getElements().size() == 1){
} else if (bPlayer.getElements().size() == 1) {
element = bPlayer.getElements().get(0);
prefix = element.getPrefix();
} 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) {
player.setDisplayName(player.getName());
player.setDisplayName(prefix + ChatColor.RESET + player.getDisplayName());
@ -1552,14 +1532,14 @@ public class GeneralMethods {
CoreAbility.registerAbilities();
new ComboManager();
new MultiAbilityManager();
DBConnection.host = ConfigManager.defaultConfig.get().getString("Storage.MySQL.host");
DBConnection.port = ConfigManager.defaultConfig.get().getInt("Storage.MySQL.port");
DBConnection.pass = ConfigManager.defaultConfig.get().getString("Storage.MySQL.pass");
DBConnection.db = ConfigManager.defaultConfig.get().getString("Storage.MySQL.db");
DBConnection.user = ConfigManager.defaultConfig.get().getString("Storage.MySQL.user");
DBConnection.init();
if (!DBConnection.isOpen()) {
ProjectKorra.log.severe("Unable to enable ProjectKorra due to the database not being open");
stopPlugin();
@ -1586,7 +1566,7 @@ public class GeneralMethods {
if (bPlayer == null) {
return;
}
HashMap<Integer, String> slots = bPlayer.getAbilities();
HashMap<Integer, String> finalAbilities = new HashMap<Integer, String>();
for (int i : slots.keySet()) {
@ -1658,7 +1638,7 @@ public class GeneralMethods {
writeToDebug(line);
}
}
writeToDebug("");
writeToDebug("Supported Plugins");
writeToDebug("====================");
@ -1704,15 +1684,14 @@ public class GeneralMethods {
writeToDebug("");
writeToDebug("Plugins Hooking Into ProjectKorra (Core)");
writeToDebug("====================");
String[] pkPlugins = new String[] {"projectkorrarpg", "projectkorraitems", "projectkorraspirits", "probending"};
String[] pkPlugins = new String[] { "projectkorrarpg", "projectkorraitems", "projectkorraspirits", "probending" };
for (Plugin plugin : Bukkit.getPluginManager().getPlugins()) {
if (plugin.getDescription().getDepend() != null && plugin.getDescription().getDepend().contains("ProjectKorra")
&& !Arrays.asList(pkPlugins).contains(plugin.getName().toLowerCase())) {
if (plugin.getDescription().getDepend() != null && plugin.getDescription().getDepend().contains("ProjectKorra") && !Arrays.asList(pkPlugins).contains(plugin.getName().toLowerCase())) {
writeToDebug(plugin.getDescription().getName() + " v" + plugin.getDescription().getVersion());
}
}
writeToDebug("");
writeToDebug("Ability Information");
writeToDebug("====================");
@ -1737,7 +1716,7 @@ public class GeneralMethods {
writeToDebug(ability + " - UNOFFICAL");
}
}
writeToDebug("");
writeToDebug("Collection Sizes");
writeToDebug("====================");
@ -1745,34 +1724,36 @@ public class GeneralMethods {
try {
for (final ClassPath.ClassInfo info : ClassPath.from(loader).getTopLevelClasses()) {
if (info.getName().startsWith("com.projectkorra.")) {
final Class<?> clazz = info.load();
for (Field field : clazz.getDeclaredFields()) {
String simpleName = clazz.getSimpleName();
field.setAccessible(true);
try {
Object obj = field.get(null);
if (obj instanceof Collection) {
writeToDebug(simpleName + ": " + field.getName() + " size=" + ((Collection<?>) obj).size());
} else if (obj instanceof Map) {
writeToDebug(simpleName + ": " + field.getName() + " size=" + ((Map<?,?>) obj).size());
}
} catch (Exception e) {
}
}
final Class<?> clazz = info.load();
for (Field field : clazz.getDeclaredFields()) {
String simpleName = clazz.getSimpleName();
field.setAccessible(true);
try {
Object obj = field.get(null);
if (obj instanceof Collection) {
writeToDebug(simpleName + ": " + field.getName() + " size=" + ((Collection<?>) obj).size());
} else if (obj instanceof Map) {
writeToDebug(simpleName + ": " + field.getName() + " size=" + ((Map<?, ?>) obj).size());
}
}
catch (Exception e) {
}
}
}
}
} catch (IOException e) {
}
catch (IOException e) {
e.printStackTrace();
}
writeToDebug("");
writeToDebug("CoreAbility Debugger");
writeToDebug("====================");
for (String line : CoreAbility.getDebugString().split("\\n")) {
writeToDebug(line);
}
}
public static void saveAbility(BendingPlayer bPlayer, int slot, String ability) {
@ -1780,7 +1761,7 @@ public class GeneralMethods {
return;
}
String uuid = bPlayer.getUUIDString();
BindChangeEvent event = new BindChangeEvent(Bukkit.getPlayer(UUID.fromString(uuid)), ability, slot, false);
Bukkit.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
@ -1830,13 +1811,13 @@ public class GeneralMethods {
DBConnection.sql.modifyQuery("UPDATE pk_players SET element = '" + elements + "' WHERE uuid = '" + uuid + "'");
}
public static void saveSubElements(BendingPlayer bPlayer) {
if (bPlayer == null) {
return;
}
String uuid = bPlayer.getUUIDString();
StringBuilder subs = new StringBuilder();
if (bPlayer.hasSubElement(Element.METAL)) {
subs.append("m");
@ -1873,7 +1854,8 @@ public class GeneralMethods {
}
boolean hasAddon = false;
for (Element element : bPlayer.getElements()) {
if (!(element instanceof SubElement)) continue;
if (!(element instanceof SubElement))
continue;
if (Arrays.asList(Element.getAddonElements()).contains(element)) {
if (!hasAddon) {
hasAddon = true;
@ -1882,7 +1864,7 @@ public class GeneralMethods {
subs.append(element.getName() + ",");
}
}
DBConnection.sql.modifyQuery("UPDATE pk_players SET subelement = '" + subs + "' WHERE uuid = '" + uuid + "'");
}
@ -1908,26 +1890,26 @@ public class GeneralMethods {
}
return;
}
// Attempt to stop velocity from going over the packet cap.
if(velocity.getX() > 4){
velocity.setX(4);
} else if(velocity.getX() < -4){
velocity.setX(-4);
}
if(velocity.getY() > 4){
velocity.setY(4);
} else if(velocity.getY() < -4){
velocity.setY(-4);
}
if(velocity.getZ() > 4){
velocity.setZ(4);
} else if(velocity.getZ() < -4){
velocity.setZ(-4);
}
if (velocity.getX() > 4) {
velocity.setX(4);
} else if (velocity.getX() < -4) {
velocity.setX(-4);
}
if (velocity.getY() > 4) {
velocity.setY(4);
} else if (velocity.getY() < -4) {
velocity.setY(-4);
}
if (velocity.getZ() > 4) {
velocity.setZ(4);
} else if (velocity.getZ() < -4) {
velocity.setZ(-4);
}
entity.setVelocity(velocity);
}

View file

@ -40,7 +40,7 @@ public class ProjectKorra extends JavaPlugin {
public static CollisionInitializer collisionInitializer;
public static long time_step = 1;
public Updater updater;
@Override
public void onEnable() {
plugin = this;
@ -56,7 +56,7 @@ public class ProjectKorra extends JavaPlugin {
catch (SecurityException | IOException e) {
e.printStackTrace();
}
new ConfigManager();
new GeneralMethods(this);
updater = new Updater(this, "http://projectkorra.com/forums/dev-builds.16/index.rss");
@ -65,12 +65,12 @@ public class ProjectKorra extends JavaPlugin {
new ComboManager();
collisionManager = new CollisionManager();
collisionInitializer = new CollisionInitializer(collisionManager);
CoreAbility.registerAbilities();
CoreAbility.registerAbilities();
collisionInitializer.initializeDefaultCollisions(); // must be called after abilities have been registered
collisionManager.startCollisionDetection();
Preset.loadExternalPresets();
DBConnection.host = getConfig().getString("Storage.MySQL.host");
DBConnection.port = getConfig().getInt("Storage.MySQL.port");
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().runTaskTimerAsynchronously(this, new RevertChecker(this), 0, 200);
TempBlock.startReversion();
for (final Player player : Bukkit.getOnlinePlayers()) {
PKListener.getJumpStatistics().put(player, player.getStatistic(Statistic.JUMP));
GeneralMethods.createBendingPlayer(player.getUniqueId(), player.getName());
GeneralMethods.removeUnusableAbilities(player.getName());
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;
/**
* The Ability interface defines the set of methods that any CoreAbility, AddonAbility, ComboAbility, or
* MultiAbility should implement. {@link CoreAbility} provides a default implementation for a few of these
* The Ability interface defines the set of methods that any CoreAbility,
* 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.
*/
public interface Ability {
@ -34,45 +35,49 @@ public interface Ability {
public void remove();
/**
* Determines if this ability uses the {@link PlayerToggleSneakEvent} as a controlling
* mechanism. Currently {@link WaterPassive} will not work while the player has a sneak ability
* bound.
* Determines if this ability uses the {@link PlayerToggleSneakEvent} as a
* controlling mechanism. Currently {@link WaterPassive} will not work while
* the player has a sneak ability bound.
*
* @return true if the ability uses sneak as a controlling mechanism
*/
public boolean isSneakAbility();
/**
* Determines if this ability is considered harmless against other players. A harmless ability
* cannot manipulate another player. For example: AirPassive, WaterSpout, AirSpout, and FireJet.
* Determines if this ability is considered harmless against other players.
* 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();
/**
* Determines if this ability can ignite blocks. For example: {@link Blaze}, {@link FireBlast},
* and {@link FireBurst}.
* Determines if this ability can ignite blocks. For example: {@link Blaze},
* {@link FireBlast}, and {@link FireBurst}.
*/
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();
/**
* A hidden ability is an ability that should not be shown by commands such as <b>/bending
* display</b> and <b>/bending help</b>. For example: Combos, MultiAbility sub abilities, and
* helper abilities.
* A hidden ability is an ability that should not be shown by commands such
* as <b>/bending display</b> and <b>/bending help</b>. For example: Combos,
* MultiAbility sub abilities, and helper abilities.
*
* @return true if the ability should not be displayed to the players
*/
public boolean isHiddenAbility();
/**
* Returns true if the ability is enabled through the config.yml. Usually the Enabled option
* follows the format Abilities.ElementName.AbilityName.Enabled.
* Returns true if the ability is enabled through the config.yml. Usually
* the Enabled option follows the format
* Abilities.ElementName.AbilityName.Enabled.
*/
public boolean isEnabled();
@ -82,40 +87,45 @@ public interface Ability {
public long getCooldown();
/**
* Returns the player that caused this ability to be initiated. The player can be null in
* certain circumstances, for example when calling {@link CoreAbility#getAbility(String)}, or if
* an ability decided to set player to null.
* Returns the player that caused this ability to be initiated. The player
* can be null in certain circumstances, for example when calling
* {@link CoreAbility#getAbility(String)}, or if an ability decided to set
* player to null.
*
* @return the player that this ability belongs to
*/
public Player getPlayer();
/**
* The name of the ability is used for commands such as <b>/bending display</b> and <b>/bending
* help</b>. The name is also used for determining the tag for cooldowns
* {@link BendingPlayer#addCooldown(Ability)}, therefore if two abilities have the same name
* they will also share cooldowns. If two classes share the same name (SurgeWall/SurgeWave) but
* need to have independent cooldowns, then {@link BendingPlayer#addCooldown(String, long)}
* should be called explicitly.
* The name of the ability is used for commands such as <b>/bending
* display</b> and <b>/bending help</b>. The name is also used for
* determining the tag for cooldowns
* {@link BendingPlayer#addCooldown(Ability)}, therefore if two abilities
* have the same name they will also share cooldowns. If two classes share
* 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
*/
public String getName();
/**
* Return's the instructions of an ability.
* ProjectKorra's help command will then use this method to display the instructions of an ability when the command is run.
/**
* Return's the instructions of an ability. ProjectKorra's help command will
* then use this method to display the instructions of an ability when the
* command is run.
*
* @return the instructions for this ability
* @see HelpCommand
* @see CoreAbility#getInstructions()
*/
public String getInstructions();
/**
* The description of an ability is a few sentences used to describe how the player can fully
* utilize the ability. In most cases the description will be specified in the config.yml file
* and will be retrieved by accessing the FileConfiguration via {@link CoreAbility#getConfig}.
/**
* The description of an ability is a few sentences used to describe how the
* player can fully utilize the ability. In most cases the description will
* 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
* @see HelpCommand
@ -124,9 +134,9 @@ public interface Ability {
public String getDescription();
/**
* Specifies the Element used to represent this type of ability, favoring SubElements over
* Elements. For example, a LightningAbility would return {@link Element#LIGHTNING} instead of
* {@link Element#FIRE}.
* Specifies the Element used to represent this type of ability, favoring
* SubElements over Elements. For example, a LightningAbility would return
* {@link Element#LIGHTNING} instead of {@link Element#FIRE}.
*
* @return the most accurate Element that this ability belongs to
* @see SubElement#getParentElement
@ -134,10 +144,12 @@ public interface Ability {
public Element getElement();
/**
* Specifies the Location of the ability, which may be slightly inaccurate depending on the
* Ability implementation. For example, a {@link TorrentWave} could not be fully specified by a
* single location, 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.
* Specifies the Location of the ability, which may be slightly inaccurate
* depending on the Ability implementation. For example, a
* {@link TorrentWave} could not be fully specified by a single location,
* 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
* @see BendingPlayer#canBend(CoreAbility)

View file

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

View file

@ -18,7 +18,7 @@ import java.util.ArrayList;
import java.util.List;
public abstract class AirAbility extends ElementalAbility {
public AirAbility(Player player) {
super(player);
}
@ -27,17 +27,17 @@ public abstract class AirAbility extends ElementalAbility {
public boolean isIgniteAbility() {
return false;
}
@Override
public boolean isExplosiveAbility() {
return false;
}
@Override
public Element getElement() {
return Element.AIR;
}
@Override
public void handleCollision(Collision 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);
}
}
/**
* 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
*/
@ -66,7 +66,7 @@ public abstract class AirAbility extends ElementalAbility {
}
}
}
/**
* Gets the Air Particles from the config.
*
@ -88,7 +88,7 @@ public abstract class AirAbility extends ElementalAbility {
return ParticleEffect.CLOUD;
}
}
/**
* This method was used for the old collision detection system. Please see
* {@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
* zOffset.
* Plays an integer amount of air particles in a location with a given
* xOffset, yOffset, and zOffset.
*
* @param loc The location to use
* @param amount The amount of particles

View file

@ -7,16 +7,16 @@ import org.bukkit.Sound;
import org.bukkit.entity.Player;
public abstract class AvatarAbility extends ElementalAbility {
public AvatarAbility(Player player) {
super(player);
}
@Override
public boolean isIgniteAbility() {
return false;
}
@Override
public boolean isExplosiveAbility() {
return false;
@ -26,14 +26,16 @@ public abstract class AvatarAbility extends ElementalAbility {
public final Element getElement() {
return Element.AVATAR;
}
public static void playAvatarSound(Location loc) {
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
* players needing to have the avatar element*/
/**
* 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 players needing to have the avatar element
*/
public boolean requireAvatar() {
return true;
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -35,7 +35,7 @@ import com.projectkorra.projectkorra.util.ParticleEffect.ParticleData;
import com.projectkorra.projectkorra.util.TempBlock;
public abstract class EarthAbility extends ElementalAbility {
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<Integer, Information> TEMP_AIR_LOCATIONS = new ConcurrentHashMap<Integer, Information>();
@ -44,7 +44,7 @@ public abstract class EarthAbility extends ElementalAbility {
public EarthAbility(Player player) {
super(player);
}
public int getEarthbendableBlocksLength(Block block, Vector direction, int maxlength) {
Location location = block.getLocation();
direction = direction.normalize();
@ -56,11 +56,11 @@ public abstract class EarthAbility extends ElementalAbility {
}
return maxlength;
}
public Block getEarthSourceBlock(double range) {
return getEarthSourceBlock(player, getName(), range);
}
@Override
public Element getElement() {
return Element.EARTH;
@ -78,12 +78,12 @@ public abstract class EarthAbility extends ElementalAbility {
public boolean isExplosiveAbility() {
return false;
}
@Override
public boolean isIgniteAbility() {
return false;
}
@Override
public void handleCollision(Collision 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);
}
}
public static boolean isEarthbendable(Material 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) {
return isEarthbendable(player, getName(), block);
}
public static boolean isEarthbendable(Player player, Block block) {
return isEarthbendable(player, null, block);
}
@ -116,7 +116,7 @@ public abstract class EarthAbility extends ElementalAbility {
public boolean isMetalbendable(Material material) {
return isMetalbendable(player, material);
}
public boolean isSandbendable(Block block) {
return isSandbendable(block.getType());
}
@ -128,7 +128,7 @@ public abstract class EarthAbility extends ElementalAbility {
public void moveEarth(Block block, Vector direction, int chainlength) {
moveEarth(block, direction, chainlength, true);
}
public boolean moveEarth(Block block, Vector direction, int chainlength, boolean throwplayer) {
if (isEarthbendable(block) && !GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation())) {
boolean up = false;
@ -167,15 +167,13 @@ public abstract class EarthAbility extends ElementalAbility {
for (Entity entity : GeneralMethods.getEntitiesAroundPoint(affectedblock.getLocation(), 1.75)) {
if (entity instanceof LivingEntity) {
LivingEntity lentity = (LivingEntity) entity;
if (lentity.getEyeLocation().getBlockX() == affectedblock.getX()
&& lentity.getEyeLocation().getBlockZ() == affectedblock.getZ()) {
if (lentity.getEyeLocation().getBlockX() == affectedblock.getX() && lentity.getEyeLocation().getBlockZ() == affectedblock.getZ()) {
if (!(entity instanceof FallingBlock)) {
entity.setVelocity(norm.clone().multiply(.75));
}
}
} else {
if (entity.getLocation().getBlockX() == affectedblock.getX()
&& entity.getLocation().getBlockZ() == affectedblock.getZ()) {
if (entity.getLocation().getBlockX() == affectedblock.getX() && entity.getLocation().getBlockZ() == affectedblock.getZ()) {
if (!(entity instanceof FallingBlock)) {
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();
if (!isEarthbendable(affectedblock)) {
if (down) {
if (isTransparent(affectedblock) && !affectedblock.isLiquid()
&& affectedblock.getType() != Material.AIR) {
if (isTransparent(affectedblock) && !affectedblock.isLiquid() && affectedblock.getType() != Material.AIR) {
moveEarthBlock(affectedblock, block);
}
}
@ -251,7 +248,7 @@ public abstract class EarthAbility extends ElementalAbility {
public void moveEarth(Location location, Vector direction, int chainlength, boolean throwplayer) {
moveEarth(location.getBlock(), direction, chainlength, throwplayer);
}
/**
* Creates a temporary air block.
*
@ -260,14 +257,14 @@ public abstract class EarthAbility extends ElementalAbility {
@SuppressWarnings("deprecation")
public static void addTempAirBlock(Block block) {
Information info;
if (MOVED_EARTH.containsKey(block)) {
info = MOVED_EARTH.get(block);
MOVED_EARTH.remove(block);
} else {
info = new Information();
info.setBlock(block);
info.setState(block.getState());
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
* BlockSource.getEarthSourceBlock() instead of this method. Dynamic source selection saves the
* user's previous source for future use.
* Finds a valid Earth source for a Player. To use dynamic source selection,
* use BlockSource.getEarthSourceBlock() instead of this method. Dynamic
* source selection saves the user's previous source for future use.
* {@link BlockSource#getEarthSourceBlock(Player, double, com.projectkorra.projectkorra.util.ClickType)}
*
* @param range the maximum block selection range.
@ -327,15 +324,15 @@ public abstract class EarthAbility extends ElementalAbility {
}
return null;
}
public static Block getLavaSourceBlock(Player player, double range) {
return getLavaSourceBlock(player, null, range);
}
/**
* Finds a valid Lava source for a Player. To use dynamic source selection, use
* BlockSource.getLavaSourceBlock() instead of this method. Dynamic source selection saves the
* user's previous source for future use.
* Finds a valid Lava source for a Player. To use dynamic source selection,
* use BlockSource.getLavaSourceBlock() instead of this method. Dynamic
* source selection saves the user's previous source for future use.
* {@link BlockSource#getLavaSourceBlock(Player, double, com.projectkorra.projectkorra.util.ClickType)}
*
* @param range the maximum block selection range.
@ -364,22 +361,22 @@ public abstract class EarthAbility extends ElementalAbility {
}
return null;
}
public static double getMetalAugment(double value) {
return value * getConfig().getDouble("Properties.Earth.MetalPowerFactor");
}
public static Map<Block, Information> getMovedEarth() {
return MOVED_EARTH;
}
/**
* Attempts to find the closest earth block near a given location.
*
* @param loc the initial location to search from.
* @param radius the maximum radius to search for the earth block.
* @param maxVertical the maximum block height difference between the starting location and the
* earth bendable block.
* @param maxVertical the maximum block height difference between the
* starting location and the earth bendable block.
* @return an earth bendable block, or null.
*/
public static Block getNearbyEarthBlock(Location loc, double radius, int maxVertical) {
@ -402,11 +399,11 @@ public abstract class EarthAbility extends ElementalAbility {
}
return null;
}
public static HashSet<Block> getPreventEarthbendingBlocks() {
return PREVENT_EARTHBENDING;
}
public static ArrayList<Block> getPreventPhysicsBlocks() {
return PREVENT_PHYSICS;
}
@ -419,21 +416,20 @@ public abstract class EarthAbility extends ElementalAbility {
public static Block getTargetEarthBlock(Player player, int range) {
return player.getTargetBlock(getTransparentMaterialSet(), range);
}
public static Map<Integer, Information> getTempAirLocations() {
return TEMP_AIR_LOCATIONS;
}
public static boolean isEarthbendable(Player player, String abilityName, Block block) {
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (bPlayer == null || !isEarthbendable(block.getType()) || PREVENT_EARTHBENDING.contains(block)
|| GeneralMethods.isRegionProtectedFromBuild(player, abilityName, block.getLocation())) {
if (bPlayer == null || !isEarthbendable(block.getType()) || PREVENT_EARTHBENDING.contains(block) || GeneralMethods.isRegionProtectedFromBuild(player, abilityName, block.getLocation())) {
return false;
} else if (isMetal(block) && !bPlayer.canMetalbend()) {
return false;
} else if (isSand(block) && !bPlayer.canSandbend()) {
return false;
} else if (isLava(block) && !bPlayer.canLavabend()) {
} else if (isLava(block) && !bPlayer.canLavabend()) {
return false;
}
return true;
@ -442,7 +438,7 @@ public abstract class EarthAbility extends ElementalAbility {
public static boolean isEarthRevertOn() {
return getConfig().getBoolean("Properties.Earth.RevertEarthbending");
}
@SuppressWarnings("deprecation")
public static boolean isLavabendable(Player player, Block block) {
byte full = 0x0;
@ -462,7 +458,7 @@ public abstract class EarthAbility extends ElementalAbility {
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
return bPlayer == null ? null : isMetal(material) && bPlayer.canMetalbend();
}
public static boolean isSandbendable(Player player, Material material) {
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
return bPlayer == null ? null : isSand(material) && bPlayer.canSandbend();
@ -485,7 +481,7 @@ public abstract class EarthAbility extends ElementalAbility {
MOVED_EARTH.put(target, info);
source.setType(Material.AIR);
if (info.getState().getType() == Material.SAND) {
if (info.getState().getRawData() == (byte) 0x1) {
target.setType(Material.RED_SANDSTONE);
@ -505,7 +501,7 @@ public abstract class EarthAbility extends ElementalAbility {
loc.getWorld().playEffect(loc, Effect.GHAST_SHOOT, 0, 10);
}
}
public static void playMetalbendingSound(Location loc) {
if (getConfig().getBoolean("Properties.Earth.PlaySound")) {
loc.getWorld().playSound(loc, Sound.ENTITY_IRONGOLEM_HURT, 1, 10);
@ -540,11 +536,11 @@ public abstract class EarthAbility extends ElementalAbility {
MOVED_EARTH.remove(block);
}
}
public static void revertAirBlock(int i) {
revertAirBlock(i, false);
}
public static void revertAirBlock(int i, boolean force) {
if (!TEMP_AIR_LOCATIONS.containsKey(i)) {
return;
@ -565,7 +561,7 @@ public abstract class EarthAbility extends ElementalAbility {
TEMP_AIR_LOCATIONS.remove(i);
}
}
@SuppressWarnings("deprecation")
public static boolean revertBlock(Block block) {
byte full = 0x0;
@ -623,11 +619,11 @@ public abstract class EarthAbility extends ElementalAbility {
MOVED_EARTH.remove(block);
}
return true;
}
}
public static void stopBending() {
EarthPassive.removeAll();
if (isEarthRevertOn()) {
removeAllEarthbendedBlocks();
}
@ -636,6 +632,7 @@ public abstract class EarthAbility extends ElementalAbility {
public static void removeSandSpouts(Location loc, double radius, Player source) {
SandSpout.removeSpouts(loc, radius, source);
}
public static void removeSandSpouts(Location loc, Player 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
* Air, Water, Earth, Fire, Chi, or AvatarAbility. This class is mainly used to keep
* CoreAbility from becoming too cluttered.
* Air, Water, Earth, Fire, Chi, or AvatarAbility. This class is mainly used to
* keep CoreAbility from becoming too cluttered.
*/
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[] 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,
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};
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};
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 };
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) {
super(player);
}
public boolean isTransparent(Block block) {
return isTransparent(player, getName(), block);
}
public static Integer[] getTransparentMaterial() {
return TRANSPARENT_MATERIAL;
}
public static HashSet<Byte> getTransparentMaterialSet() {
HashSet<Byte> set = new HashSet<Byte>();
for (int i : TRANSPARENT_MATERIAL) {
@ -50,7 +47,7 @@ public abstract class ElementalAbility extends CoreAbility {
}
return set;
}
public static boolean isDay(World world) {
long time = world.getTime();
if (world.getEnvironment() == Environment.NETHER || world.getEnvironment() == Environment.THE_END) {
@ -61,15 +58,15 @@ public abstract class ElementalAbility extends CoreAbility {
}
return false;
}
public static boolean isEarth(Block block) {
return block != null ? isEarth(block.getType()) : false;
}
public static boolean isEarth(Material material) {
return getConfig().getStringList("Properties.Earth.EarthBlocks").contains(material.toString());
}
public static boolean isFullMoon(World world) {
if (GeneralMethods.hasRPG()) {
return EventManager.marker.get(world).equalsIgnoreCase("FullMoon");
@ -94,57 +91,55 @@ public abstract class ElementalAbility extends CoreAbility {
public static boolean isLava(Block block) {
return block != null ? isLava(block.getType()) : false;
}
public static boolean isLava(Material material) {
return material == Material.LAVA || material == Material.STATIONARY_LAVA;
}
public static boolean isSnow(Block block) {
return block != null ? isSnow(block.getType()) : false;
}
public static boolean isSnow(Material material) {
return getConfig().getStringList("Properties.Water.SnowBlocks").contains(material.toString());
}
public static boolean isLunarEclipse(World world) {
if (world == null || !GeneralMethods.hasRPG()) {
return false;
}
return EventManager.marker.get(world).equalsIgnoreCase("LunarEclipse");
}
public static boolean isSolarEclipse(World world) {
if (world == null || !GeneralMethods.hasRPG() || !EventManager.marker.containsKey(world)) {
return false;
}
return EventManager.marker.get(world).equalsIgnoreCase("SolarEclipse");
}
public static boolean isMeltable(Block block) {
if (block.getType() == Material.ICE || block.getType() == Material.SNOW) {
return true;
}
return false;
}
public static boolean isMetal(Block block) {
return block != null ? isMetal(block.getType()) : false;
}
public static boolean isMetal(Material material) {
return getConfig().getStringList("Properties.Earth.MetalBlocks").contains(material.toString());
}
public static boolean isMetalBlock(Block 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) {
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) {
return true;
}
return false;
}
public static boolean isNegativeEffect(PotionEffectType effect) {
for (PotionEffectType effect2 : NEGATIVE_EFFECTS) {
if (effect2.equals(effect)) {
@ -153,7 +148,7 @@ public abstract class ElementalAbility extends CoreAbility {
}
return false;
}
public static boolean isNeutralEffect(PotionEffectType effect) {
for (PotionEffectType effect2 : NEUTRAL_EFFECTS) {
if (effect2.equals(effect)) {
@ -162,7 +157,7 @@ public abstract class ElementalAbility extends CoreAbility {
}
return false;
}
public static boolean isNight(World world) {
if (world.getEnvironment() == Environment.NETHER || world.getEnvironment() == Environment.THE_END) {
return false;
@ -174,11 +169,11 @@ public abstract class ElementalAbility extends CoreAbility {
}
return false;
}
public static boolean isPlant(Block block) {
return block != null ? isPlant(block.getType()) : false;
}
public static boolean isPlant(Material material) {
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) {
return block != null ? isSand(block.getType()) : false;
return block != null ? isSand(block.getType()) : false;
}
public static boolean isSand(Material material) {
return getConfig().getStringList("Properties.Earth.SandBlocks").contains(material.toString());
}
@ -213,18 +208,13 @@ public abstract class ElementalAbility extends CoreAbility {
@SuppressWarnings("deprecation")
public static boolean isTransparent(Player player, String abilityName, Block block) {
return Arrays.asList(TRANSPARENT_MATERIAL).contains(block.getTypeId())
&& !GeneralMethods.isRegionProtectedFromBuild(player, abilityName, block.getLocation());
return Arrays.asList(TRANSPARENT_MATERIAL).contains(block.getTypeId()) && !GeneralMethods.isRegionProtectedFromBuild(player, abilityName, block.getLocation());
}
public static boolean isUndead(Entity entity) {
if (entity == null) {
return false;
} 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) {
} 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) {
return true;
}
return false;
@ -233,9 +223,9 @@ public abstract class ElementalAbility extends CoreAbility {
public static boolean isWater(Block block) {
return block != null ? isWater(block.getType()) : null;
}
public static boolean isWater(Material material) {
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;
public abstract class FireAbility extends ElementalAbility {
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,
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 };
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 };
public FireAbility(Player player) {
super(player);
}
@Override
public boolean isIgniteAbility() {
return true;
}
@Override
public boolean isExplosiveAbility() {
return true;
@ -61,7 +50,7 @@ public abstract class FireAbility extends ElementalAbility {
public Element getElement() {
return Element.FIRE;
}
@Override
public void handleCollision(Collision 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);
}
}
public double getDayFactor(double value) {
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
* block.
* Returns if fire is allowed to completely replace blocks or if it should
* place a temp fire block.
*/
public static boolean canFireGrief() {
return getConfig().getBoolean("Properties.Fire.FireGriefing");
}
/**
* Creates a fire block meant to replace other blocks but reverts when the fire dissipates or is
* destroyed.
* Creates a fire block meant to replace other blocks but reverts when the
* fire dissipates or is destroyed.
*/
public static void createTempFire(Location loc) {
if (loc.getBlock().getType() == Material.AIR) {
@ -93,8 +82,7 @@ public abstract class FireAbility extends ElementalAbility {
return;
}
Information info = new Information();
long time = getConfig().getLong("Properties.Fire.RevertTicks")
+ (long) ((new Random()).nextDouble() * getConfig().getLong("Properties.Fire.RevertTicks"));
long time = getConfig().getLong("Properties.Fire.RevertTicks") + (long) ((new Random()).nextDouble() * getConfig().getLong("Properties.Fire.RevertTicks"));
if (TEMP_FIRE.containsKey(loc)) {
info = TEMP_FIRE.get(loc);
} else {
@ -110,13 +98,15 @@ public abstract class FireAbility extends ElementalAbility {
public static double getDayFactor() {
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 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 />
* value The specified value in the parameters
*/
@ -136,7 +126,7 @@ public abstract class FireAbility extends ElementalAbility {
}
return value;
}
public static ChatColor getSubChatColor() {
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) {
return block != null ? isIgnitable(block.getType()) : false;
}
public static boolean isIgnitable(Material material) {
return Arrays.asList(IGNITABLE_MATERIALS).contains(material);
}
/**
* This method was used for the old collision detection system. Please see
* {@link Collision} for the new system.
@ -198,8 +188,7 @@ public abstract class FireAbility extends ElementalAbility {
while (it.hasNext()) {
Location loc = it.next();
Information info = TEMP_FIRE.get(loc);
if (info.getLocation().getBlock().getType() != Material.FIRE
&& info.getLocation().getBlock().getType() != Material.AIR) {
if (info.getLocation().getBlock().getType() != Material.FIRE && info.getLocation().getBlock().getType() != Material.AIR) {
revertTempFire(loc);
} else if (info.getBlock().getType() == Material.AIR || System.currentTimeMillis() > info.getTime()) {
revertTempFire(loc);
@ -211,7 +200,7 @@ public abstract class FireAbility extends ElementalAbility {
* Revert the temp fire at the location if any is there.
*
* @param location The Location
* */
*/
@SuppressWarnings("deprecation")
public static void revertTempFire(Location location) {
if (!TEMP_FIRE.containsKey(location)) {
@ -236,5 +225,5 @@ public abstract class FireAbility extends ElementalAbility {
revertTempFire(loc);
}
}
}

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -5,13 +5,15 @@ import com.projectkorra.projectkorra.ability.util.MultiAbilityManager.MultiAbili
import java.util.ArrayList;
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);}
*
* @return a list of sub MultiAbilities
*/
public abstract ArrayList<MultiAbilityInfoSub> getMultiAbilities();
}

View file

@ -1,10 +1,11 @@
package com.projectkorra.projectkorra.ability;
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();

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -50,11 +50,11 @@ public class AirSpout extends AirAbility {
}
new Flight(player);
if (bPlayer.isAvatarState()) {
this.height = getConfig().getDouble("Abilities.Avatar.AvatarState.AirSpout.Height");
}
start();
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.pushFactor = getConfig().getDouble("Abilities.Avatar.AvatarState.Air.AirSwipe.Push");
}
start();
}
@ -137,8 +137,7 @@ public class AirSwipe extends AirAbility {
location = location.clone().add(direction.clone().multiply(speed));
elements.put(direction, location);
if (location.distanceSquared(origin) > range * range
|| GeneralMethods.isRegionProtectedFromBuild(this, location)) {
if (location.distanceSquared(origin) > range * range || GeneralMethods.isRegionProtectedFromBuild(this, location)) {
elements.remove(direction);
} else {
Block block = location.getBlock();
@ -225,9 +224,9 @@ public class AirSwipe extends AirAbility {
elements.remove(fDirection);
}
} 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);
@ -286,9 +285,8 @@ public class AirSwipe extends AirAbility {
double factor = 1;
if (System.currentTimeMillis() >= getStartTime() + maxChargeTime) {
factor = maxChargeFactor;
} else {
factor = maxChargeFactor * (double) (System.currentTimeMillis() - getStartTime())
/ (double) maxChargeTime;
} else {
factor = maxChargeFactor * (double) (System.currentTimeMillis() - getStartTime()) / (double) maxChargeTime;
}
charging = false;

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -36,7 +36,7 @@ public class AddCommand extends PKCommand {
public AddCommand() {
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.invalidElement = ConfigManager.languageConfig.get().getString("Commands.Add.InvalidElement");
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
*/
private void add(CommandSender sender, Player target, String element) {
Element e = Element.fromString(element);
if (e == null) {
e = SubElement.fromString(element);
}
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(target);
if (bPlayer == null) {
GeneralMethods.createBendingPlayer(target.getUniqueId(), target.getName());
@ -109,9 +109,9 @@ public class AddCommand extends PKCommand {
bPlayer.addSubElement(sub);
}
}
ChatColor color = e.getColor();
if (!(sender instanceof Player) || !((Player) sender).equals(target)) {
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()));
@ -125,7 +125,7 @@ public class AddCommand extends PKCommand {
target.sendMessage(color + addedCFW.replace("{element}", e.getName() + e.getType().getBender()));
else
target.sendMessage(color + addedAE.replace("{element}", e.getName() + e.getType().getBender()));
}
GeneralMethods.saveElements(bPlayer);
GeneralMethods.saveSubElements(bPlayer);
@ -143,13 +143,13 @@ public class AddCommand extends PKCommand {
}
bPlayer.addSubElement(sub);
ChatColor color = e.getColor();
if (!(sender instanceof Player) || !((Player) sender).equals(target)) {
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()));
else
sender.sendMessage(color + addedOtherAE.replace("{target}", ChatColor.DARK_AQUA + target.getName() + color).replace("{element}", sub.getName() + sub.getType().getBender()));
} else {
if (e != Element.AIR && e != Element.EARTH)
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);
}
}
public static boolean isVowel(char c) {
return "AEIOUaeiou".indexOf(c) != -1;
}
@Override
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>();
if (args.size() == 0) {
l.add("Air");
l.add("Earth");
l.add("Fire");
@ -182,7 +183,7 @@ public class AddCommand extends PKCommand {
for (Element e : Element.getAddonElements()) {
l.add(e.getName());
}
l.add("Blood");
l.add("Combustion");
l.add("Flight");

View file

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

View file

@ -30,8 +30,8 @@ public class BindCommand extends PKCommand {
private String noSubElement;
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.wrongNumber = ConfigManager.languageConfig.get().getString("Commands.Bind.WrongNumber");
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)));
return;
}
// bending bind [Ability]
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] [#]
if (args.size() == 2) {
try {
bind(sender, args.get(0), Integer.parseInt(args.get(1)));
} catch (NumberFormatException ex) {
}
catch (NumberFormatException ex) {
sender.sendMessage(ChatColor.RED + wrongNumber);
}
}
@ -100,15 +101,16 @@ public class BindCommand extends PKCommand {
} else if (!bPlayer.isElementToggled(coreAbil.getElement())) {
sender.sendMessage(ChatColor.RED + toggledElementOff);
}
String name = coreAbil != null ? coreAbil.getName() : null;
GeneralMethods.bindAbility((Player) sender, name, slot);
}
@Override
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>();
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(sender.getName());
if (args.size() == 0) {
@ -126,4 +128,4 @@ public class BindCommand extends PKCommand {
Collections.sort(abilities);
return abilities;
}
}
}

View file

@ -20,7 +20,7 @@ public class CheckCommand extends PKCommand {
public CheckCommand() {
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.curVersion = ConfigManager.languageConfig.get().getString("Commands.Check.CurrentVersion");
this.newVersion = ConfigManager.languageConfig.get().getString("Commands.Check.LatestVersion");

View file

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

View file

@ -23,10 +23,10 @@ public class ClearCommand extends PKCommand {
private String wrongNumber;
private String clearedSlot;
private String alreadyEmpty;
public ClearCommand() {
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.cleared = ConfigManager.languageConfig.get().getString("Commands.Clear.Cleared");
this.wrongNumber = ConfigManager.languageConfig.get().getString("Commands.Clear.WrongNumber");
@ -63,19 +63,21 @@ public class ClearCommand extends PKCommand {
if (bPlayer.getAbilities().get(slot) != null) {
bPlayer.getAbilities().remove(slot);
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 {
sender.sendMessage(ChatColor.YELLOW + alreadyEmpty);
}
} catch (NumberFormatException e) {
}
catch (NumberFormatException e) {
sender.sendMessage(ChatColor.RED + wrongNumber);
}
}
}
@Override
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(""));
}

View file

@ -38,7 +38,7 @@ public class Commands {
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[] avataraliases = { "avatar", "av", "avy", "aang", "korra" };
/*
* Combo Aliases
*/
@ -53,9 +53,9 @@ public class Commands {
/*
* 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" };
/*
* Subelement Aliases
*/
@ -79,12 +79,12 @@ public class Commands {
//Firebending
public static String[] combustionaliases = { "combustionbending", "combustion", "cb" };
public static String[] lightningaliases = { "lightningbending", "lightning" };
//Miscellaneous
public static String[] commandaliases = { "b", "pk", "projectkorra", "bending", "mtla", "tla", "korra", "bend" };
private List<String> help;
private void init() {
PluginCommand projectkorra = plugin.getCommand("projectkorra");
new AddCommand();
@ -107,7 +107,7 @@ public class Commands {
new WhoCommand();
help = ConfigManager.languageConfig.get().getStringList("Commands.GeneralHelpLines");
/**
* Set of all of the Classes which extend Command
*/
@ -117,7 +117,7 @@ public class Commands {
exe = new CommandExecutor() {
@Override
public boolean onCommand(CommandSender s, Command c, String label, String[] args) {
if (args.length == 0 && Arrays.asList(commandaliases).contains(label.toLowerCase())) {
for (String line : help)
s.sendMessage(ChatColor.translateAlternateColorCodes('&', line));
@ -131,10 +131,10 @@ public class Commands {
return true;
}
}
for (String line : help)
s.sendMessage(ChatColor.translateAlternateColorCodes('&', line));
return true;
}
};

View file

@ -16,7 +16,7 @@ import java.util.HashMap;
import java.util.List;
public class CopyCommand extends PKCommand {
private String playerNotFound;
private String copied;
private String failedToBindAll;
@ -24,7 +24,7 @@ public class CopyCommand extends PKCommand {
public CopyCommand() {
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.copied = ConfigManager.languageConfig.get().getString("Commands.Copy.SuccessfullyCopied");
this.failedToBindAll = ConfigManager.languageConfig.get().getString("Commands.Copy.FailedToBindAll");
@ -47,7 +47,6 @@ public class CopyCommand extends PKCommand {
return;
}
boolean boundAll = assignAbilities(sender, orig, (Player) sender, true);
sender.sendMessage(ChatColor.GREEN + copied.replace("{target}", ChatColor.YELLOW + orig.getName() + ChatColor.GREEN));
if (!boundAll) {
@ -75,7 +74,7 @@ public class CopyCommand extends PKCommand {
}
}
}
@SuppressWarnings("unchecked")
private boolean assignAbilities(CommandSender sender, Player player, Player player2, boolean self) {
@ -98,7 +97,7 @@ public class CopyCommand extends PKCommand {
}
return false;
}
HashMap<Integer, String> abilities = (HashMap<Integer, String>) orig.getAbilities().clone();
boolean boundAll = true;
for (int i = 1; i <= 9; i++) {
@ -111,10 +110,11 @@ public class CopyCommand extends PKCommand {
target.setAbilities(abilities);
return boundAll;
}
@Override
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>();
for (Player p : Bukkit.getOnlinePlayers()) {
l.add(p.getName());
@ -122,4 +122,4 @@ public class CopyCommand extends PKCommand {
return l;
}
}
}

View file

@ -24,7 +24,7 @@ import com.projectkorra.rpg.commands.RPGCommand;
* Executor for /bending help. Extends {@link PKCommand}.
*/
public class HelpCommand extends PKCommand {
private String required;
private String optional;
private String properUsage;
@ -39,7 +39,7 @@ public class HelpCommand extends PKCommand {
public HelpCommand() {
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.optional = ConfigManager.languageConfig.get().getString("Commands.Help.Optional");
this.properUsage = ConfigManager.languageConfig.get().getString("Commands.Help.ProperUsage");
@ -155,10 +155,11 @@ public class HelpCommand extends PKCommand {
sender.sendMessage(ChatColor.RED + invalidTopic);
}
}
@Override
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>();
for (Element e : Element.getAllElements()) {
list.add(e.getName());

View file

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

View file

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

View file

@ -18,16 +18,16 @@ import java.util.List;
* Executor for /bending permaremove. Extends {@link PKCommand}.
*/
public class PermaremoveCommand extends PKCommand {
private String playerIsOffline;
private String restored;
private String restoredConfirm;
private String removed;
private String removedConfirm;
public PermaremoveCommand() {
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.restored = ConfigManager.languageConfig.get().getString("Commands.PermaRemove.Restored");
this.restoredConfirm = ConfigManager.languageConfig.get().getString("Commands.PermaRemove.RestoredConfirm");
@ -99,10 +99,11 @@ public class PermaremoveCommand extends PKCommand {
}
return true;
}
@Override
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>();
for (Player p : Bukkit.getOnlinePlayers()) {
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[] listaliases = { "list", "l" };
private static final String[] bindaliases = { "bind", "b" };
private String noPresets;
private String noPresetName;
private String deletePreset;
@ -40,10 +40,10 @@ public class PresetCommand extends PKCommand {
private String alreadyExists;
private String createdNewPreset;
private String cantEditBinds;
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" });
this.noPresets = ConfigManager.languageConfig.get().getString("Commands.Preset.NoPresets");
this.noPresetName = ConfigManager.languageConfig.get().getString("Commands.Preset.NoPresetName");
this.deletePreset = ConfigManager.languageConfig.get().getString("Commands.Preset.Delete");
@ -218,7 +218,7 @@ public class PresetCommand extends PKCommand {
help(sender, false);
}
}
@Override
protected List<String> getTabCompletion(CommandSender sender, List<String> args) {
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;
}
}
}

View file

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

View file

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

View file

@ -39,47 +39,41 @@ public class WhoCommand extends PKCommand {
/**
* 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;
public WhoCommand() {
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");
noPlayersOnline = ConfigManager.languageConfig.get().getString("Commands.Who.NoPlayersOnline");
playerOffline = ConfigManager.languageConfig.get().getString("Commands.Who.PlayerOffline");
new BukkitRunnable()
{
public void run()
{
try
{
new BukkitRunnable() {
public void run() {
try {
staff.clear();
// Create a URL for the desired page
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");
// Read all the text returned by the server
BufferedReader in = new BufferedReader(new InputStreamReader(url.getInputStream(), Charset.forName("UTF-8")));
String unparsed;
while ((unparsed = in.readLine()) != null)
{
while ((unparsed = in.readLine()) != null) {
String[] staffEntry = unparsed.split("/");
if (staffEntry.length >= 2)
{
if (staffEntry.length >= 2) {
staff.put(staffEntry[0], ChatColor.translateAlternateColorCodes('&', staffEntry[1]));
}
}
in.close();
}
catch (MalformedURLException e)
{
catch (MalformedURLException e) {
e.printStackTrace();
}
catch (IOException e)
{
catch (IOException e) {
e.printStackTrace();
}
}
@ -102,7 +96,7 @@ public class WhoCommand extends PKCommand {
String playerName = player.getName();
String result = "";
BendingPlayer bp = BendingPlayer.getBendingPlayer(playerName);
if (bp == null) {
GeneralMethods.createBendingPlayer(player.getUniqueId(), 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.
*
* @param sender
* The CommandSender to display the information to
* @param playerName
* The Player to look up
* @param sender The CommandSender to display the information to
* @param playerName The Player to look up
*/
private void whoPlayer(final CommandSender sender, final String playerName) {
//Player player = Bukkit.getPlayer(playerName);
@ -153,10 +145,9 @@ public class WhoCommand extends PKCommand {
return;
}
if (!player.isOnline() && !BendingPlayer.getPlayers().containsKey(player.getUniqueId())) {
sender.sendMessage(ChatColor.GRAY + playerOffline.replace("{player}", ChatColor.WHITE + player.getName() + ChatColor.GRAY)
.replace("{target}", 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));
}
Player player_ = (Player) (player.isOnline() ? player : null);
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
@ -188,17 +179,17 @@ public class WhoCommand extends PKCommand {
runnable.runTaskAsynchronously(ProjectKorra.plugin);
return;
}
bPlayer = BendingPlayer.getBendingPlayer(player);
if (bPlayer != null) {
sender.sendMessage(player.getName() + (!player.isOnline() ? ChatColor.RESET + " (Offline)" : "") + " - ");
if (bPlayer.hasElement(Element.AIR)) {
if(bPlayer.isElementToggled(Element.AIR)) {
if (bPlayer.isElementToggled(Element.AIR)) {
sender.sendMessage(Element.AIR.getColor() + "- Airbender");
} else {
sender.sendMessage(Element.AIR.getColor() + "" + ChatColor.STRIKETHROUGH + "- Airbender");
}
if (player_ != null) {
if (bPlayer.canUseFlight()) {
sender.sendMessage(Element.FLIGHT.getColor() + " Can Fly");
@ -214,12 +205,12 @@ public class WhoCommand extends PKCommand {
}
}
if (bPlayer.hasElement(Element.WATER)) {
if(bPlayer.isElementToggled(Element.WATER)) {
if (bPlayer.isElementToggled(Element.WATER)) {
sender.sendMessage(Element.WATER.getColor() + "- Waterbender");
} else {
sender.sendMessage(Element.WATER.getColor() + "" + ChatColor.STRIKETHROUGH + "- Waterbender");
}
if (player_ != null) {
if (bPlayer.canPlantbend()) {
sender.sendMessage(Element.PLANT.getColor() + " Can Plantbend");
@ -245,12 +236,12 @@ public class WhoCommand extends PKCommand {
}
}
if (bPlayer.hasElement(Element.EARTH)) {
if(bPlayer.isElementToggled(Element.EARTH)) {
if (bPlayer.isElementToggled(Element.EARTH)) {
sender.sendMessage(Element.EARTH.getColor() + "- Earthbender");
} else {
sender.sendMessage(Element.EARTH.getColor() + "" + ChatColor.STRIKETHROUGH + "- Earthbender");
}
if (player_ != null) {
if (bPlayer.canMetalbend()) {
sender.sendMessage(Element.METAL.getColor() + " Can Metalbend");
@ -269,12 +260,12 @@ public class WhoCommand extends PKCommand {
}
}
if (bPlayer.hasElement(Element.FIRE)) {
if(bPlayer.isElementToggled(Element.FIRE)) {
if (bPlayer.isElementToggled(Element.FIRE)) {
sender.sendMessage(Element.FIRE.getColor() + "- Firebender");
} else {
sender.sendMessage(Element.FIRE.getColor() + "" + ChatColor.STRIKETHROUGH + "- Firebender");
}
if (player_ != null) {
if (bPlayer.canCombustionbend()) {
sender.sendMessage(Element.COMBUSTION.getColor() + " Can Combustionbend");
@ -290,7 +281,7 @@ public class WhoCommand extends PKCommand {
}
}
if (bPlayer.hasElement(Element.CHI)) {
if(bPlayer.isElementToggled(Element.CHI)) {
if (bPlayer.isElementToggled(Element.CHI)) {
sender.sendMessage(Element.CHI.getColor() + "- Chiblocker");
} else {
sender.sendMessage(Element.CHI.getColor() + "" + ChatColor.STRIKETHROUGH + "- Chiblocker");
@ -320,7 +311,7 @@ public class WhoCommand extends PKCommand {
}
}
}
UUID uuid = player.getUniqueId();
if (bPlayer != null) {
sender.sendMessage("Abilities: ");
@ -347,12 +338,13 @@ public class WhoCommand extends PKCommand {
sender.sendMessage(staff.get(uuid.toString()));
}
}
}
@Override
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>();
for (Player p : Bukkit.getOnlinePlayers()) {
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.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.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("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.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.");
languageConfig.save();
} else if (type == ConfigType.DEFAULT) {
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.FireResistance.Enabled", true);
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.Self", 4.0);
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.Damage", 3);
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.Push", 8);
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.ShootRange", 30);
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.FireJet.IsAvatarStateToggle", true);
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.FireBlast.Charged.ChargeTime", 1500);
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.Wave.Radius", 20);
config.addDefault("Abilities.Avatar.AvatarState.Water.WaterManipulation.Damage", 5);

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -112,7 +112,7 @@ public class EarthTunnel extends EarthAbility {
block.setType(Material.AIR);
} else {
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 above2 = above.getRelative(BlockFace.UP);
if (isPlant(above) || isSnow(above)) {

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

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