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

@ -113,7 +113,8 @@ public class BendingManager implements Runnable {
ChiCombo.handleParalysis();
HorizontalVelocityTracker.updateAll();
handleCooldowns();
} catch (Exception e) {
}
catch (Exception e) {
e.printStackTrace();
}
}

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<>();
@ -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;
@ -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
@ -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()) {
@ -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,6 +403,7 @@ 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() {
@ -407,7 +411,9 @@ public class BendingPlayer {
}
/**
* 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.
*/
@ -548,6 +554,7 @@ public class BendingPlayer {
/**
* Returns whether the player has permission to bend the subelement
*
* @param sub The SubElement
*/
public boolean hasSubElementPermission(SubElement sub) {
@ -674,8 +681,8 @@ public class BendingPlayer {
}
/**
* 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
*/
@ -775,11 +782,13 @@ public class BendingPlayer {
}
/**
* 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)
*/

View file

@ -13,9 +13,7 @@ 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;
@ -69,8 +67,9 @@ public class Element {
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) {
@ -78,20 +77,24 @@ public class Element {
}
/**
* 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) {
@ -103,7 +106,8 @@ public class Element {
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_)) + " ";
}
@ -126,7 +130,8 @@ public class Element {
}
public ElementType getType() {
if (type == null) return ElementType.NO_SUFFIX;
if (type == null)
return ElementType.NO_SUFFIX;
return type;
}
@ -143,7 +148,9 @@ public class Element {
}
/**
* 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() {
@ -159,6 +166,7 @@ public class Element {
/**
* Returns an array of all the official elements and subelements.
*
* @return Array of all official elements and subelements.
*/
public static Element[] getElements() {
@ -167,6 +175,7 @@ public class Element {
/**
* Returns an array of all the official elements.
*
* @return Array of all official elements.
*/
public static Element[] getMainElements() {
@ -175,6 +184,7 @@ public class Element {
/**
* Returns an array of all the addon elements.
*
* @return Array of all addon elements.
*/
public static Element[] getAddonElements() {
@ -190,6 +200,7 @@ public class Element {
/**
* Returns all subelements, official and addon.
*
* @return Array of all the subelements.
*/
public static SubElement[] getAllSubElements() {
@ -205,6 +216,7 @@ public class Element {
/**
* Return official subelements.
*
* @return Array of official subelements.
*/
public static SubElement[] getSubElements() {
@ -213,6 +225,7 @@ public class Element {
/**
* Return all subelements belonging to a parent element.
*
* @param element
* @return Array of all subelements belonging to a parent element.
*/
@ -228,6 +241,7 @@ public class Element {
/**
* Returns an array of all the addon subelements.
*
* @return Array of all addon subelements.
*/
public static SubElement[] getAddonSubElements() {
@ -242,6 +256,7 @@ public class Element {
/**
* Returns array of addon subelements belonging to a parent element.
*
* @param element
* @return Array of addon subelements belonging to a parent element.
*/
@ -277,8 +292,9 @@ public class 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.
*/
@ -287,22 +303,26 @@ public class Element {
}
/**
* 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) {

View file

@ -134,17 +134,8 @@ 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<>();
@ -160,7 +151,8 @@ public class GeneralMethods {
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();
}
}
@ -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);
}
@ -435,7 +425,6 @@ public class GeneralMethods {
}
}
/**
* Deserializes the configuration file "bendingPlayers.yml" of the old
* BendingPlugin and creates a converted.yml ready for conversion.
@ -594,8 +583,7 @@ public class GeneralMethods {
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();
@ -616,7 +604,8 @@ public class GeneralMethods {
Object hearts = getAbsorption.invoke(entityplayer);
//player.sendMessage(hearts.toString());
return (float) hearts;
} catch (Exception e) {
}
catch (Exception e) {
e.printStackTrace();
}
return 0;
@ -628,7 +617,8 @@ public class GeneralMethods {
Object entityplayer = ActionBar.getHandle.invoke(player);
setAbsorption.invoke(entityplayer, hearts);
//player.sendMessage(hearts.toString());
} catch (Exception e) {
}
catch (Exception e) {
e.printStackTrace();
}
}
@ -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);
}
@ -1136,7 +1122,6 @@ public class GeneralMethods {
}
}
return blockHolder;
}
@ -1441,9 +1426,7 @@ 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
@ -1451,11 +1434,9 @@ public class GeneralMethods {
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,7 +1452,6 @@ 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);
@ -1707,8 +1687,7 @@ public class GeneralMethods {
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());
}
}
@ -1756,13 +1735,15 @@ public class GeneralMethods {
} else if (obj instanceof Map) {
writeToDebug(simpleName + ": " + field.getName() + " size=" + ((Map<?, ?>) obj).size());
}
} catch (Exception e) {
}
catch (Exception e) {
}
}
}
}
} catch (IOException e) {
}
catch (IOException e) {
e.printStackTrace();
}
@ -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;

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,29 +87,33 @@ 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
@ -113,9 +122,10 @@ public interface Ability {
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();

View file

@ -47,9 +47,9 @@ public abstract class AirAbility extends ElementalAbility {
}
}
/**
* 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
*/
@ -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

@ -31,9 +31,11 @@ public abstract class AvatarAbility extends ElementalAbility {
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

@ -643,7 +643,7 @@ public abstract class CoreAbility implements Ability {
if (getElement() instanceof SubElement) {
elementName = ((SubElement) getElement()).getParentElement().getName();
}
return ConfigManager.languageConfig.get().getString("Abilities." + elementName + "." + getName() + ".Instructions");
return ConfigManager.languageConfig.get().contains("Abilities." + elementName + "." + getName() + ".Instructions") ? ConfigManager.languageConfig.get().getString("Abilities." + elementName + "." + getName() + ".Instructions") : "";
}
@Override
@ -685,7 +685,6 @@ public abstract class CoreAbility implements Ability {
}
}
if (!INSTANCES_BY_PLAYER.containsKey(this.getClass())) {
INSTANCES_BY_PLAYER.put(this.getClass(), new ConcurrentHashMap<UUID, Map<Integer, CoreAbility>>());
}

View file

@ -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);
}
}
@ -294,9 +291,9 @@ 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.
@ -333,9 +330,9 @@ public abstract class EarthAbility extends ElementalAbility {
}
/**
* 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.
@ -378,8 +375,8 @@ public abstract class EarthAbility extends ElementalAbility {
*
* @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) {
@ -426,8 +423,7 @@ public abstract class EarthAbility extends ElementalAbility {
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;
@ -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,19 +17,16 @@ 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[] 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[] 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);
@ -137,9 +134,7 @@ public abstract class ElementalAbility extends CoreAbility {
}
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;
@ -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;

View file

@ -30,18 +30,7 @@ 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);
@ -76,16 +65,16 @@ public abstract class FireAbility extends ElementalAbility {
}
/**
* 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 {
@ -112,11 +100,13 @@ public abstract class FireAbility extends ElementalAbility {
}
/**
* 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
*/
@ -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)) {

View file

@ -7,7 +7,9 @@ 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

View file

@ -4,7 +4,8 @@ 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

@ -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

@ -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;
}

View file

@ -56,8 +56,10 @@ public class AbilityLoader<T> implements Listener {
/**
* @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) {
@ -79,7 +81,8 @@ public class AbilityLoader<T> implements Listener {
Class<?> clazz = null;
try {
clazz = Class.forName(className, true, loader);
} catch (Exception | Error e) {
}
catch (Exception | Error e) {
continue;
}
@ -97,15 +100,18 @@ public class AbilityLoader<T> implements Listener {
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

@ -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

@ -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

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

@ -116,7 +116,6 @@ public class AirBlast extends AirAbility {
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

@ -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();
@ -287,8 +286,7 @@ public class AirSwipe extends AirAbility {
if (System.currentTimeMillis() >= getStartTime() + maxChargeTime) {
factor = maxChargeFactor;
} else {
factor = maxChargeFactor * (double) (System.currentTimeMillis() - getStartTime())
/ (double) maxChargeTime;
factor = maxChargeFactor * (double) (System.currentTimeMillis() - getStartTime()) / (double) maxChargeTime;
}
charging = false;

View file

@ -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 {

View file

@ -91,7 +91,6 @@ public class Smokescreen extends ChiAbility {
}
}
@Override
public String getName() {
return "Smokescreen";

View file

@ -170,7 +170,8 @@ public class AddCommand extends PKCommand {
@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) {

View file

@ -13,7 +13,7 @@ import java.util.List;
* Completes tabbing for the bending command/subcommands.
*
* @author StrangeOne101
* */
*/
public class BendingTabComplete implements TabCompleter {
@Override

View file

@ -62,7 +62,8 @@ public class BindCommand extends PKCommand {
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);
}
}
@ -107,7 +108,8 @@ public class BindCommand extends PKCommand {
@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());

View file

@ -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);
@ -158,10 +168,8 @@ public class ChooseCommand extends PKCommand {
Bukkit.getServer().getPluginManager().callEvent(new PlayerChangeElementEvent(sender, target, element, Result.CHOOSE));
}
GeneralMethods.removeUnusableAbilities(target.getName());
}
public static boolean isVowel(char c) {
@ -170,7 +178,8 @@ public class ChooseCommand extends PKCommand {
@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) {

View file

@ -67,7 +67,8 @@ public class ClearCommand extends PKCommand {
} else {
sender.sendMessage(ChatColor.YELLOW + alreadyEmpty);
}
} catch (NumberFormatException e) {
}
catch (NumberFormatException e) {
sender.sendMessage(ChatColor.RED + wrongNumber);
}
}
@ -75,7 +76,8 @@ public class ClearCommand extends PKCommand {
@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

@ -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) {
@ -114,7 +113,8 @@ public class CopyCommand extends PKCommand {
@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());

View file

@ -158,7 +158,8 @@ public class HelpCommand extends PKCommand {
@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

@ -16,8 +16,7 @@ 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
*
@ -200,6 +199,7 @@ public abstract class PKCommand implements SubCommand {
/**
* Returns a boolean if the string provided is numerical.
*
* @param id
* @return boolean
*/
@ -212,6 +212,7 @@ public abstract class PKCommand implements SubCommand {
/**
* Returns a list for of commands for a page.
*
* @param entries
* @param title
* @param page
@ -248,8 +249,7 @@ public abstract class PKCommand implements SubCommand {
}
/** Gets a list of valid arguments that can be used in tabbing. */
protected List<String> getTabCompletion(CommandSender sender, List<String> args)
{
protected List<String> getTabCompletion(CommandSender sender, List<String> args) {
return new ArrayList<String>();
}

View file

@ -102,7 +102,8 @@ public class PermaremoveCommand extends PKCommand {
@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

@ -245,7 +245,8 @@ 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,
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
*/

View file

@ -21,8 +21,9 @@ import java.util.List;
public class ToggleCommand extends PKCommand {
private String toggledOffForAll, toggleOffSelf, toggleOnSelf, toggleOffAll, toggleOnAll,
toggledOffSingleElement, toggledOnSingleElement, wrongElementOther, toggledOnOtherElementConfirm,
toggledOffOtherElementConfirm, toggledOnOtherElement, toggledOffOtherElement, wrongElement, notFound;
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}");
@ -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;
@ -147,7 +147,8 @@ public class ToggleCommand extends PKCommand {
@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

@ -39,7 +39,8 @@ 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;
@ -50,12 +51,9 @@ public class WhoCommand extends PKCommand {
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();
@ -64,22 +62,18 @@ public class WhoCommand extends PKCommand {
// 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();
}
}
@ -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,8 +145,7 @@ 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);
@ -352,7 +343,8 @@ public class WhoCommand extends PKCommand {
@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.");
@ -586,7 +586,6 @@ public class ConfigManager {
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);

View file

@ -91,7 +91,8 @@ public class CollapseWall extends EarthAbility {
}
@Override
public void progress() {}
public void progress() {
}
@Override
public Location getLocation() {

View file

@ -61,8 +61,7 @@ public class EarthArmor extends EarthAbility {
}
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();
@ -312,61 +311,103 @@ public class EarthArmor extends EarthAbility {
}.runTaskLater(ProjectKorra.plugin, 1L);
}
public static int getColor(Material material) {
return getColor(material, (byte) 0x0);
}
/** 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);

View file

@ -122,7 +122,8 @@ public class RaiseEarthWall extends EarthAbility {
}
@Override
public void progress() {}
public void progress() {
}
@Override
public Location getLocation() {

View file

@ -286,8 +286,7 @@ 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);
}

View file

@ -95,9 +95,7 @@ public class LavaSurge extends LavaAbility {
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;
}
@ -120,7 +118,9 @@ public class LavaSurge extends LavaAbility {
try {
targetLocation = GeneralMethods.getTargetedEntity(player, travelRange * 2, null).getLocation();
} catch(NullPointerException e) {}
}
catch (NullPointerException e) {
}
if (targetLocation == null) {
remove();
@ -174,9 +174,7 @@ public class LavaSurge extends LavaAbility {
}
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;

View file

@ -176,8 +176,7 @@ public class LavaSurgeWall extends LavaAbility {
}
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);

View file

@ -165,19 +165,13 @@ public class LavaSurgeWave extends LavaAbility {
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);
}

View file

@ -91,7 +91,8 @@ public class Extraction extends MetalAbility {
}
@Override
public void progress() {}
public void progress() {
}
@Override
public Location getLocation() {

View file

@ -27,11 +27,7 @@ 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;
@ -82,7 +78,8 @@ public class MetalClips extends MetalAbility {
}
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");
}
@ -96,45 +93,27 @@ 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")) {
@ -186,7 +165,8 @@ public class MetalClips extends MetalAbility {
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 {
@ -200,7 +180,8 @@ public class MetalClips extends MetalAbility {
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);
}
@ -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();
@ -500,7 +478,8 @@ public class MetalClips extends MetalAbility {
}
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();

View file

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

View file

@ -10,6 +10,7 @@ import com.projectkorra.projectkorra.ability.Ability;
/**
* Called when an ability damages an {@link Entity}
*
* @author kingbirdy
*
*/
@ -25,6 +26,7 @@ public class AbilityDamageEntityEvent extends Event implements Cancellable {
/**
* Create a new AbilityDamageEntityEvent
*
* @param entity The entity that was damaged
* @param ability The damaging ability
* @param damage The amount of damage done
@ -38,6 +40,7 @@ public class AbilityDamageEntityEvent extends Event implements Cancellable {
/**
* 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,6 +67,7 @@ public class AbilityDamageEntityEvent extends Event implements Cancellable {
/**
* Gets the ability used
*
* @return ability used
*/
public Ability getAbility() {
@ -74,6 +80,7 @@ public class AbilityDamageEntityEvent extends Event implements Cancellable {
/**
* Gets the player that used the ability
*
* @return player that used ability
*/
public Player getSource() {

View file

@ -7,6 +7,7 @@ import com.projectkorra.projectkorra.ability.Ability;
/**
* Called when an ability starts
*
* @author Philip
*
*/

View file

@ -8,6 +8,7 @@ import com.projectkorra.projectkorra.ability.Ability;
/**
* Called when an ability starts
*
* @author Philip
*
*/

View file

@ -4,6 +4,7 @@ import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import com.projectkorra.projectkorra.BendingPlayer;
/**
* Called when a new BendingPlayer is created
*/
@ -32,4 +33,3 @@ public class BendingPlayerCreationEvent extends Event {
return bPlayer;
}
}

View file

@ -4,6 +4,7 @@ import org.bukkit.command.CommandSender;
import org.bukkit.event.Cancellable;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
/**
* Called when the /bending reload command is executed.
*/
@ -43,7 +44,9 @@ public class BendingReloadEvent extends Event implements Cancellable {
/**
* Sets if the event is cancelled
* @param cancel boolean value indicating whether the event is cancelled or not
*
* @param cancel boolean value indicating whether the event is cancelled or
* not
*/
@Override
public void setCancelled(boolean cancel) {

View file

@ -9,7 +9,9 @@ import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
/**
* Called when an entity is killed by {@link GeneralMethods#damageEntity(Player player, Entity entity, double damage, String ability) GeneralMethods.damageEntity}
* Called when an entity is killed by
* {@link GeneralMethods#damageEntity(Player player, Entity entity, double damage, String ability)
* GeneralMethods.damageEntity}
*/
public class EntityBendingDeathEvent extends Event {
@ -23,7 +25,8 @@ public class EntityBendingDeathEvent extends Event {
* Creates a new EntityBendingDeathEvent
*
* @param entity the entity who died
* @param damage the amount of damage done in the attack that killed the victim
* @param damage the amount of damage done in the attack that killed the
* victim
* @param ability the ability used to kill the entity
*/
public EntityBendingDeathEvent(Entity entity, double damage, Ability ability) {

View file

@ -23,7 +23,8 @@ public class PlayerChangeElementEvent extends Event {
* @param sender the {@link CommandSender} who changed the player's bending
* @param target the {@link Player player} who's bending was changed
* @param element the {@link Element element} that was affected
* @param result whether the element was chosen, added, removed, or permaremoved
* @param result whether the element was chosen, added, removed, or
* permaremoved
*/
public PlayerChangeElementEvent(CommandSender sender, Player target, Element element, Result result) {
this.sender = sender;

View file

@ -21,7 +21,8 @@ public class PlayerChangeSubElementEvent extends Event{
* @param sender the {@link CommandSender} who changed the player's bending
* @param target the {@link Player} who's bending was changed
* @param sub the {@link SubElement} that was changed to
* @param result whether the element was chosen, added, removed, or permaremoved
* @param result whether the element was chosen, added, removed, or
* permaremoved
*/
public PlayerChangeSubElementEvent(CommandSender sender, Player target, SubElement sub, Result result) {
this.sender = sender;

View file

@ -19,9 +19,7 @@ import java.util.concurrent.ConcurrentHashMap;
public class BlazeArc extends FireAbility {
private static final long DISSIPATE_REMOVE_TIME = 400;
private static final Material[] OVERWRITABLE_MATERIALS = { Material.SAPLING, Material.LONG_GRASS, Material.DEAD_BUSH,
Material.YELLOW_FLOWER, Material.RED_ROSE, Material.BROWN_MUSHROOM, Material.RED_MUSHROOM,
Material.FIRE, Material.SNOW, Material.TORCH };
private static final Material[] OVERWRITABLE_MATERIALS = { Material.SAPLING, Material.LONG_GRASS, Material.DEAD_BUSH, Material.YELLOW_FLOWER, Material.RED_ROSE, Material.BROWN_MUSHROOM, Material.RED_MUSHROOM, Material.FIRE, Material.SNOW, Material.TORCH };
private static final Map<Block, Player> IGNITED_BLOCKS = new ConcurrentHashMap<Block, Player>();
private static final Map<Block, Long> IGNITED_TIMES = new ConcurrentHashMap<Block, Long>();
private static final Map<Location, MaterialData> REPLACED_BLOCKS = new ConcurrentHashMap<Location, MaterialData>();

View file

@ -56,7 +56,8 @@ public class BlazeRing extends FireAbility {
}
@Override
public void progress() {}
public void progress() {
}
@Override
public Location getLocation() {

View file

@ -137,9 +137,7 @@ public class FireBlast extends FireAbility {
private void ignite(Location location) {
for (Block block : GeneralMethods.getBlocksAroundPoint(location, collisionRadius)) {
if (BlazeArc.isIgnitable(player, block)
&& !safeBlocks.contains(block)
&& !GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation())) {
if (BlazeArc.isIgnitable(player, block) && !safeBlocks.contains(block) && !GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation())) {
if (canFireGrief()) {
if (isPlant(block) || isSnow(block)) {
new PlantRegrowth(player, block);
@ -159,8 +157,7 @@ public class FireBlast extends FireAbility {
@Override
public void progress() {
if (!bPlayer.canBendIgnoreBindsCooldowns(this)
|| GeneralMethods.isRegionProtectedFromBuild(this, location)) {
if (!bPlayer.canBendIgnoreBindsCooldowns(this) || GeneralMethods.isRegionProtectedFromBuild(this, location)) {
remove();
return;
}

View file

@ -79,7 +79,6 @@ public class FireBlastCharged extends FireAbility {
this.maxDamage = getConfig().getDouble("Abilities.Avatar.AvatarState.Fire.FireBlast.Charged.Damage");
}
if (!player.getEyeLocation().getBlock().isLiquid()) {
start();
}
@ -208,8 +207,7 @@ public class FireBlastCharged extends FireAbility {
boolean exploded = false;
for (Entity entity : GeneralMethods.getEntitiesAroundPoint(location, 2 * collisionRadius)) {
if (entity.getEntityId() == player.getEntityId()
|| GeneralMethods.isRegionProtectedFromBuild(this, entity.getLocation())) {
if (entity.getEntityId() == player.getEntityId() || GeneralMethods.isRegionProtectedFromBuild(this, entity.getLocation())) {
continue;
}
entity.setFireTicks((int) (fireTicks * 20));
@ -246,8 +244,7 @@ public class FireBlastCharged extends FireAbility {
} else if (!bPlayer.canBend(CoreAbility.getAbility("FireBlast")) && !launched) {
remove();
return;
}
else if (!player.isSneaking() && !charged) {
} else if (!player.isSneaking() && !charged) {
remove();
return;
}

View file

@ -95,9 +95,9 @@ public class FireBurst extends FireAbility {
}
/**
* To combat the sphere FireBurst lag we are only going to show a certain percentage of
* FireBurst particles at a time per tick. As the bursts spread out then we can show more at a
* time.
* To combat the sphere FireBurst lag we are only going to show a certain
* percentage of FireBurst particles at a time per tick. As the bursts
* spread out then we can show more at a time.
*/
public void handleSmoothParticles() {
for (int i = 0; i < blasts.size(); i++) {

View file

@ -76,8 +76,7 @@ public class FireJet extends FireAbility {
if (player.isDead() || !player.isOnline()) {
remove();
return;
} else if ((isWater(player.getLocation().getBlock()) || System.currentTimeMillis() > time + duration)
&& (!bPlayer.isAvatarState() || !avatarStateToggled)) {
} else if ((isWater(player.getLocation().getBlock()) || System.currentTimeMillis() > time + duration) && (!bPlayer.isAvatarState() || !avatarStateToggled)) {
remove();
return;
} else {

View file

@ -80,8 +80,7 @@ public class FireShield extends FireAbility {
Location tempLoc = playerLoc.clone().add(playerLoc.multiply(fshield.discRadius));
if (!tempLoc.getWorld().equals(loc.getWorld())) {
return false;
} else if (tempLoc.getWorld().equals(loc.getWorld())
&& tempLoc.distance(loc) <= fshield.discRadius * fshield.discRadius) {
} else if (tempLoc.getWorld().equals(loc.getWorld()) && tempLoc.distance(loc) <= fshield.discRadius * fshield.discRadius) {
return true;
}
}
@ -114,8 +113,7 @@ public class FireShield extends FireAbility {
double rphi = Math.toRadians(phi);
double rtheta = Math.toRadians(theta);
Block block = location.clone().add(radius * Math.cos(rphi) * Math.sin(rtheta), radius * Math.cos(rtheta),
radius * Math.sin(rphi) * Math.sin(rtheta)).getBlock();
Block block = location.clone().add(radius * Math.cos(rphi) * Math.sin(rtheta), radius * Math.cos(rtheta), radius * Math.sin(rphi) * Math.sin(rtheta)).getBlock();
if (!blocks.contains(block) && !GeneralMethods.isSolid(block) && !block.isLiquid()) {
blocks.add(block);
}

View file

@ -40,8 +40,7 @@ public class HeatControl extends FireAbility {
COOK, EXTINGUISH, MELT, SOLIDIFY
}
private static final Material[] COOKABLE_MATERIALS = { Material.RAW_BEEF, Material.RAW_CHICKEN,
Material.RAW_FISH, Material.PORK, Material.POTATO_ITEM, Material.RABBIT, Material.MUTTON };
private static final Material[] COOKABLE_MATERIALS = { Material.RAW_BEEF, Material.RAW_CHICKEN, Material.RAW_FISH, Material.PORK, Material.POTATO_ITEM, Material.RABBIT, Material.MUTTON };
private HeatControlType heatControlType;

View file

@ -104,17 +104,11 @@ public class Illumination extends FireAbility {
if (standBlock.getType() == Material.GLOWSTONE) {
revert();
} else if ((BlazeArc.isIgnitable(player, standingBlock)
&& standBlock.getType() != Material.LEAVES && standBlock.getType() != Material.LEAVES_2)
&& block == null && !BLOCKS.containsKey(standBlock)) {
} else if ((BlazeArc.isIgnitable(player, standingBlock) && standBlock.getType() != Material.LEAVES && standBlock.getType() != Material.LEAVES_2) && block == null && !BLOCKS.containsKey(standBlock)) {
this.block = new TempBlock(standingBlock, Material.TORCH, (byte) 0);
BLOCKS.put(block, player);
} else if ((BlazeArc.isIgnitable(player, standingBlock)
&& standBlock.getType() != Material.LEAVES && standBlock.getType() != Material.LEAVES_2)
&& !block.equals(standBlock)
&& !BLOCKS.containsKey(standBlock)
&& GeneralMethods.isSolid(standBlock)) {
} else if ((BlazeArc.isIgnitable(player, standingBlock) && standBlock.getType() != Material.LEAVES && standBlock.getType() != Material.LEAVES_2) && !block.equals(standBlock) && !BLOCKS.containsKey(standBlock) && GeneralMethods.isSolid(standBlock)) {
revert();
this.block = new TempBlock(standingBlock, Material.TORCH, (byte) 0);
@ -189,9 +183,11 @@ public class Illumination extends FireAbility {
return BLOCKS;
}
/**Returns whether the block provided is a torch created by Illumination
/**
* Returns whether the block provided is a torch created by Illumination
*
* @param block The block being tested*/
* @param block The block being tested
*/
public static boolean isIlluminationTorch(Block block) {
for (TempBlock b : BLOCKS.keySet()) {
if (b.getBlock().equals(block)) {

View file

@ -141,7 +141,6 @@ public class WallOfFire extends FireAbility {
}
}
private void initializeBlocks() {
Vector direction = player.getEyeLocation().getDirection();
direction = direction.normalize();

View file

@ -73,8 +73,7 @@ public class Combustion extends CombustionAbility {
Combustion combustion = getAbility(player, Combustion.class);
if (combustion != null) {
combustion.createExplosion(combustion.location, combustion.power, combustion.breakBlocks);
ParticleEffect.EXPLODE.display(combustion.location, (float) Math.random(), (float) Math.random(),
(float) Math.random(), 0, 3);
ParticleEffect.EXPLODE.display(combustion.location, (float) Math.random(), (float) Math.random(), (float) Math.random(), 0, 3);
}
}

View file

@ -131,6 +131,7 @@ public class Lightning extends LightningAbility {
new BukkitRunnable() {
int count = 0;
@Override
public void run() {
if (flent.isDead() || (flent instanceof Player && !((Player) flent).isOnline())) {
@ -154,7 +155,8 @@ public class Lightning extends LightningAbility {
}
/**
* Checks if a block is transparent, also considers the ARC_ON_ICE config option.
* Checks if a block is transparent, also considers the ARC_ON_ICE config
* option.
*
* @param player the player that is viewing the block
* @param block the block
@ -174,11 +176,12 @@ public class Lightning extends LightningAbility {
}
/**
* Progresses the instance of this ability by 1 tick. This is the heart of the ability, it
* checks if it needs to remove itself, and handles the initial Lightning Arc generation.
* Progresses the instance of this ability by 1 tick. This is the heart of
* the ability, it checks if it needs to remove itself, and handles the
* initial Lightning Arc generation.
*
* Once all of the arcs have been created then this ability instance gets removed, but the
* BukkitRunnables continue until they remove themselves.
* Once all of the arcs have been created then this ability instance gets
* removed, but the BukkitRunnables continue until they remove themselves.
**/
@Override
public void progress() {
@ -251,10 +254,7 @@ public class Lightning extends LightningAbility {
for (int j = 0; j < arc.getAnimationLocations().size() - 1; j++) {
final Location iterLoc = arc.getAnimationLocations().get(j).getLocation().clone();
final Location dest = arc.getAnimationLocations().get(j + 1).getLocation().clone();
if (selfHitClose
&& player.getLocation().distanceSquared(iterLoc) < 9
&& !isTransparentForLightning(player, iterLoc.getBlock())
&& !affectedEntities.contains(player)) {
if (selfHitClose && player.getLocation().distanceSquared(iterLoc) < 9 && !isTransparentForLightning(player, iterLoc.getBlock()) && !affectedEntities.contains(player)) {
affectedEntities.add(player);
electrocute(player);
}
@ -289,9 +289,10 @@ public class Lightning extends LightningAbility {
}
/**
* Represents a Lightning Arc Point particle animation. This basically just holds a location and
* counts the amount of times that a particle has been animated.
* **/
* Represents a Lightning Arc Point particle animation. This basically just
* holds a location and counts the amount of times that a particle has been
* animated.
**/
public class AnimationLocation {
private Location location;
private int animationCounter;
@ -319,9 +320,9 @@ public class Lightning extends LightningAbility {
}
/**
* An Arc represents a Lightning arc for the specific ability. These Arcs contain a list of
* Particles that are used to display the entire arc. Arcs can also generate a list of subarcs
* that chain off of their own instance.
* An Arc represents a Lightning arc for the specific ability. These Arcs
* contain a list of Particles that are used to display the entire arc. Arcs
* can also generate a list of subarcs that chain off of their own instance.
**/
public class Arc {
private int animationCounter;
@ -358,9 +359,9 @@ public class Lightning extends LightningAbility {
/**
* Randomly generates subarcs off of this arc.
*
* @param chance The chance that an arc will be generated for each specific point in the
* arc. Note: if you generate a lot of points then chance will need to be
* lowered.
* @param chance The chance that an arc will be generated for each
* specific point in the arc. Note: if you generate a lot of
* points then chance will need to be lowered.
* @param range The length of each subarc.
*
**/
@ -388,14 +389,15 @@ public class Lightning extends LightningAbility {
}
/**
* Runs an arc generation algorithm by first creating two points, the starting point and the
* ending point. Next, it creates a point in the middle that has an offset relative to the
* beginning and end points. Now that the arc is split into 3 points, we continue this
* processes by generating middle points in the two halfs of this arc. This process
* continues the amount of times specified.
* Runs an arc generation algorithm by first creating two points, the
* starting point and the ending point. Next, it creates a point in the
* middle that has an offset relative to the beginning and end points.
* Now that the arc is split into 3 points, we continue this processes
* by generating middle points in the two halfs of this arc. This
* process continues the amount of times specified.
*
* @param times The amount of times that the arc will be split in half causes O(n^2)
* complexity
* @param times The amount of times that the arc will be split in half
* causes O(n^2) complexity
**/
public void generatePoints(int times) {
for (int i = 0; i < times; i++) {
@ -461,12 +463,13 @@ public class Lightning extends LightningAbility {
}
/**
* A Runnable Particle that continuously displays itself until it reaches a certain time limit.
* A Runnable Particle that continuously displays itself until it reaches a
* certain time limit.
*
* These LightningParticles do the actual checking for player collision and handle damaging any
* entities. These Runnables also check to see if they reach water, in which case they will
* generate subarcs to branch out.
* **/
* These LightningParticles do the actual checking for player collision and
* handle damaging any entities. These Runnables also check to see if they
* reach water, in which case they will generate subarcs to branch out.
**/
public class LightningParticle extends BukkitRunnable {
private boolean selfHitWater;
private int count = 0;
@ -490,8 +493,8 @@ public class Lightning extends LightningAbility {
}
/**
* Animates the Location, checks for water/player collision and also deals with any chain
* subarcs.
* Animates the Location, checks for water/player collision and also
* deals with any chain subarcs.
*/
@Override
public void run() {
@ -529,12 +532,11 @@ public class Lightning extends LightningAbility {
for (Entity entity : GeneralMethods.getEntitiesAroundPoint(location, 2.5)) {
/*
* If the player is in water we will electrocute them only if they are standing
* in water. If the lightning hit ice we can electrocute them all the time.
* If the player is in water we will electrocute them only
* if they are standing in water. If the lightning hit ice
* we can electrocute them all the time.
*/
if (entity.equals(player)
&& !(selfHitWater && hitWater && isWater(player.getLocation().getBlock()))
&& !(selfHitWater && hitIce)) {
if (entity.equals(player) && !(selfHitWater && hitWater && isWater(player.getLocation().getBlock())) && !(selfHitWater && hitIce)) {
continue;
}
@ -559,8 +561,7 @@ public class Lightning extends LightningAbility {
if (maxChainArcs >= 1 && Math.random() <= chainArcChance) {
maxChainArcs--;
for (Entity ent : GeneralMethods.getEntitiesAroundPoint(lent.getLocation(), chainRange)) {
if (!ent.equals(player) && !ent.equals(lent) && ent instanceof LivingEntity
&& !affectedEntities.contains(ent)) {
if (!ent.equals(player) && !ent.equals(lent) && ent instanceof LivingEntity && !affectedEntities.contains(ent)) {
origin = lent.getLocation().add(0, 1, 0);
destination = ent.getLocation().add(0, 1, 0);
Arc newArc = new Arc(origin, destination);

View file

@ -23,8 +23,7 @@ public class FirePassive {
player.setFireTicks(80);
}
if (bPlayer != null && !CoreAbility.hasAbility(player, Illumination.class)
&& bPlayer.canBendIgnoreBinds(CoreAbility.getAbility("Illumination")) && ConfigManager.defaultConfig.get().getBoolean("Abilities.Fire.Illumination.Passive")) {
if (bPlayer != null && !CoreAbility.hasAbility(player, Illumination.class) && bPlayer.canBendIgnoreBinds(CoreAbility.getAbility("Illumination")) && ConfigManager.defaultConfig.get().getBoolean("Abilities.Fire.Illumination.Passive")) {
if (!bPlayer.isTremorSensing()) {
new Illumination(player);
}

View file

@ -86,7 +86,8 @@ public class HorizontalVelocityTracker {
if ((diff.getX() > 1 || diff.getX() < -1) || (diff.getZ() > 1 || diff.getZ() < -1)) {
impactLocation = entity.getLocation();
for (Block b : blocks) {
if (b.getType() == Material.BARRIER && barrier == false) return;
if (b.getType() == Material.BARRIER && barrier == false)
return;
if (GeneralMethods.isSolid(b) && (entity.getLocation().getBlock().getRelative(BlockFace.EAST, 1).equals(b) || entity.getLocation().getBlock().getRelative(BlockFace.NORTH, 1).equals(b) || entity.getLocation().getBlock().getRelative(BlockFace.WEST, 1).equals(b) || entity.getLocation().getBlock().getRelative(BlockFace.SOUTH, 1).equals(b))) {
if (!ElementalAbility.isTransparent(instigator, b)) {
hasBeenDamaged = true;

View file

@ -12,6 +12,7 @@ public class PlayerFlyData {
/**
* Does the player have access to fly mode?
*
* @return
*/
public boolean canFly() {
@ -20,6 +21,7 @@ public class PlayerFlyData {
/**
* Was the player flying?
*
* @return
*/
public boolean isFlying() {

View file

@ -192,7 +192,8 @@ public class Preset {
public static void loadExternalPresets() {
HashMap<String, ArrayList<String>> presets = new HashMap<String, ArrayList<String>>();
for (String name : config.getKeys(false)) {
if (!presets.containsKey(name)) if (!config.getStringList(name).isEmpty() && config.getStringList(name).size() <= 9) {
if (!presets.containsKey(name))
if (!config.getStringList(name).isEmpty() && config.getStringList(name).size() <= 9) {
presets.put(name.toLowerCase(), (ArrayList<String>) config.getStringList(name));
}
}

View file

@ -44,7 +44,8 @@ public class DBConnection {
sql.getConnection().setAutoCommit(true);
ProjectKorra.log.info("Database Updated.");
}
} catch (SQLException e) {
}
catch (SQLException e) {
e.printStackTrace();
}
}
@ -80,7 +81,8 @@ public class DBConnection {
ProjectKorra.log.info("Database Updated.");
}
} catch (SQLException e) {
}
catch (SQLException e) {
e.printStackTrace();
}
}

View file

@ -37,11 +37,14 @@ public abstract class Database {
* Print error to console.
*
* @param message The string to print to console
* @param severe If {@param severe} is true print an error, else print a warning
* @param severe If {@param severe} is true print an error, else print a
* warning
*/
protected void printErr(String message, boolean severe) {
if (severe) log.severe(prefix + dbprefix + message);
else log.warning(prefix + dbprefix + message);
if (severe)
log.severe(prefix + dbprefix + message);
else
log.warning(prefix + dbprefix + message);
}
/**
@ -67,7 +70,8 @@ public abstract class Database {
if (connection != null) {
try {
connection.close();
} catch (SQLException e) {
}
catch (SQLException e) {
e.printStackTrace();
}
} else {
@ -76,7 +80,8 @@ public abstract class Database {
}
/**
* Queries the Database, for queries which modify data. Run async by default.
* Queries the Database, for queries which modify data. Run async by
* default.
*
* @param query Query to run
*/
@ -115,7 +120,8 @@ public abstract class Database {
ResultSet rs = stmt.executeQuery();
return rs;
} catch(SQLException e) {
}
catch (SQLException e) {
e.printStackTrace();
return null;
}
@ -133,7 +139,8 @@ public abstract class Database {
ResultSet rs = dmd.getTables(null, null, table, null);
return rs.next();
} catch(Exception e) {
}
catch (Exception e) {
e.printStackTrace();
return false;
}
@ -144,7 +151,8 @@ public abstract class Database {
PreparedStatement stmt = connection.prepareStatement(query);
stmt.execute();
stmt.close();
} catch (SQLException e) {
}
catch (SQLException e) {
e.printStackTrace();
}
}

View file

@ -5,7 +5,6 @@ import java.sql.DriverManager;
import java.sql.SQLException;
import java.util.logging.Logger;
public class MySQL extends Database {
private String host = "localhost";

View file

@ -25,7 +25,8 @@ import java.util.HashMap;
*/
public class BlockSource {
/**
* An enum representation of the source types available for bending abilities.
* An enum representation of the source types available for bending
* abilities.
*
* @author kingbirdy
*/
@ -43,7 +44,8 @@ public class BlockSource {
* Updates all of the player's sources.
*
* @param player the player performing the bending.
* @param clickType either {@link ClickType}.SHIFT_DOWN or ClickType.LEFT_CLICK
* @param clickType either {@link ClickType}.SHIFT_DOWN or
* ClickType.LEFT_CLICK
*/
public static void update(Player player, ClickType clickType) {
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
@ -111,7 +113,8 @@ public class BlockSource {
}
/**
* Access a block's source information, depending on a {@link BlockSourceType} and {@link ClickType}.
* Access a block's source information, depending on a
* {@link BlockSourceType} and {@link ClickType}.
*
* @param player the player that is trying to bend.
* @param clickType the action that was performed to access the source,
@ -131,7 +134,8 @@ public class BlockSource {
}
/**
* Access a block source information depending on a range, {@link BlockSourceType}, and {@link ClickType}.
* Access a block source information depending on a range,
* {@link BlockSourceType}, and {@link ClickType}.
*
* @param player the player that is trying to bend.
* @param range the maximum range to access the block.
@ -146,7 +150,8 @@ public class BlockSource {
}
/**
* Access a specific type of source block depending on a range and {@link ClickType}.
* Access a specific type of source block depending on a range and
* {@link ClickType}.
*
* @param player the player that is trying to bend.
* @param range the maximum range to access the block.

View file

@ -735,8 +735,8 @@ public enum ParticleEffect {
/**
* Displays a single particle which flies into a determined direction and is
* only visible for all players within a certain range in the world of @param
* center
* only visible for all players within a certain range in the world
* of @param center
*
* @param direction Direction of the particle
* @param speed Display speed of the particle
@ -977,11 +977,13 @@ public enum ParticleEffect {
return "_" + packetData[0] + "_" + packetData[1];
}
/**Sets the packet data. Should be an integer array. For ITEM_CRACK
* and BLOCK_DUST, it should be [id, meta] but for BLOCK_CRACK it
* should be [id + (meta * 4096)]
/**
* Sets the packet data. Should be an integer array. For ITEM_CRACK and
* BLOCK_DUST, it should be [id, meta] but for BLOCK_CRACK it should be
* [id + (meta * 4096)]
*
* @param data The packet data.*/
* @param data The packet data.
*/
public void setPacketData(int[] data) {
packetData = data;
}

View file

@ -46,117 +46,91 @@ public class PassiveHandler {
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (bPlayer == null) return;
if (bPlayer == null)
return;
if (!bPlayer.hasElement(Element.AIR)) air = 0;
if (!bPlayer.hasElement(Element.CHI)) chi = 0;
if (!bPlayer.hasElement(Element.AIR))
air = 0;
if (!bPlayer.hasElement(Element.CHI))
chi = 0;
double max = Math.max(air, chi);
if (max == 0) return;
if (max == 0)
return;
else {
player.setExhaustion(getExhaustion(player, player.getExhaustion(), max));
}
}
/*
public static void checkSpeedPassives(Player player) {
if (!player.isSprinting()) return;
int air = AirPassive.getSpeedPower();
int chi = ChiPassive.getSpeedPower();
int earth = EarthPassive.getSandRunSpeed();
if (ConfigManager.defaultConfig.get().getStringList("Properties.DisabledWorlds").contains(player.getWorld().getName())) {
return;
}
if (Commands.isToggledForAll && ConfigManager.defaultConfig.get().getBoolean("Properties.TogglePassivesWithAllBending")) {
return;
}
boolean sandbender = true;
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (bPlayer == null) return;
if (!bPlayer.canBendPassive(Element.EARTH)) sandbender = false;
if (!bPlayer.hasSubElement(SubElement.SAND)) sandbender = false;
if (!bPlayer.canBendPassive(Element.AIR)) air = 0;
if (!bPlayer.canBendPassive(Element.CHI)) chi = 0;
int max = 0;
if (sandbender && EarthAbility.isSand(player.getLocation().getBlock().getRelative(BlockFace.DOWN))) {
if (CoreAbility.hasAbility(player, AcrobatStance.class)) {
AcrobatStance abil = CoreAbility.getAbility(player, AcrobatStance.class);
max = Math.max(air, chi);
max = Math.max(max, abil.getSpeed());
max = Math.max(max, earth);
} else {
max = Math.max(air, chi);
max = Math.max(max, earth);
}
} else {
if (CoreAbility.hasAbility(player, AcrobatStance.class)) {
AcrobatStance abil = CoreAbility.getAbility(player, AcrobatStance.class);
max = Math.max(air, chi);
max = Math.max(max, abil.getSpeed());
} else {
max = Math.max(air, chi);
}
}
if (max == 0) return;
boolean b = true;
if (player.hasPotionEffect(PotionEffectType.SPEED)) {
for (PotionEffect potion : player.getActivePotionEffects()) {
if (potion.getType() == PotionEffectType.SPEED) {
if (potion.getAmplifier() > max - 1) b = false;
}
}
}
if (b) {
player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, 15, max-1, true, false), false);
}
}
public static void checkJumpPassives(Player player) {
if (!player.isSprinting()) return;
int air = AirPassive.getJumpPower();
int chi = ChiPassive.getJumpPower();
if (ConfigManager.defaultConfig.get().getStringList("Properties.DisabledWorlds").contains(player.getWorld().getName())) {
return;
}
if (Commands.isToggledForAll && ConfigManager.defaultConfig.get().getBoolean("Properties.TogglePassivesWithAllBending")) {
return;
}
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (bPlayer == null) return;
if (!bPlayer.canBendPassive(Element.AIR)) air = 0;
if (!bPlayer.canBendPassive(Element.CHI)) chi = 0;
int max = 0;
if (CoreAbility.hasAbility(player, AcrobatStance.class)) {
AcrobatStance abil = CoreAbility.getAbility(player, AcrobatStance.class);
max = Math.max(air, chi);
max = Math.max(max, abil.getSpeed());
} else {
max = Math.max(air, chi);
}
if (max == 0) return;
boolean b = true;
if (player.hasPotionEffect(PotionEffectType.JUMP)) {
for (PotionEffect potion : player.getActivePotionEffects()) {
if (potion.getType() == PotionEffectType.JUMP) {
if (potion.getAmplifier() > max - 1) b = false;
}
}
}
if (b) {
player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 15, max-1, true, false), false);
}
}
* public static void checkSpeedPassives(Player player) { if
* (!player.isSprinting()) return; int air = AirPassive.getSpeedPower(); int
* chi = ChiPassive.getSpeedPower(); int earth =
* EarthPassive.getSandRunSpeed();
*
* if (ConfigManager.defaultConfig.get().getStringList(
* "Properties.DisabledWorlds").contains(player.getWorld().getName())) {
* return; }
*
* if (Commands.isToggledForAll &&
* ConfigManager.defaultConfig.get().getBoolean(
* "Properties.TogglePassivesWithAllBending")) { return; }
*
* boolean sandbender = true; BendingPlayer bPlayer =
* BendingPlayer.getBendingPlayer(player);
*
* if (bPlayer == null) return; if (!bPlayer.canBendPassive(Element.EARTH))
* sandbender = false; if (!bPlayer.hasSubElement(SubElement.SAND))
* sandbender = false; if (!bPlayer.canBendPassive(Element.AIR)) air = 0; if
* (!bPlayer.canBendPassive(Element.CHI)) chi = 0;
*
* int max = 0;
*
* if (sandbender &&
* EarthAbility.isSand(player.getLocation().getBlock().getRelative(BlockFace
* .DOWN))) { if (CoreAbility.hasAbility(player, AcrobatStance.class)) {
* AcrobatStance abil = CoreAbility.getAbility(player, AcrobatStance.class);
* max = Math.max(air, chi); max = Math.max(max, abil.getSpeed()); max =
* Math.max(max, earth); } else { max = Math.max(air, chi); max =
* Math.max(max, earth); } } else { if (CoreAbility.hasAbility(player,
* AcrobatStance.class)) { AcrobatStance abil =
* CoreAbility.getAbility(player, AcrobatStance.class); max = Math.max(air,
* chi); max = Math.max(max, abil.getSpeed()); } else { max = Math.max(air,
* chi); } }
*
* if (max == 0) return; boolean b = true; if
* (player.hasPotionEffect(PotionEffectType.SPEED)) { for (PotionEffect
* potion : player.getActivePotionEffects()) { if (potion.getType() ==
* PotionEffectType.SPEED) { if (potion.getAmplifier() > max - 1) b = false;
* } } } if (b) { player.addPotionEffect(new
* PotionEffect(PotionEffectType.SPEED, 15, max-1, true, false), false); } }
*
* public static void checkJumpPassives(Player player) { if
* (!player.isSprinting()) return; int air = AirPassive.getJumpPower(); int
* chi = ChiPassive.getJumpPower();
*
* if (ConfigManager.defaultConfig.get().getStringList(
* "Properties.DisabledWorlds").contains(player.getWorld().getName())) {
* return; }
*
* if (Commands.isToggledForAll &&
* ConfigManager.defaultConfig.get().getBoolean(
* "Properties.TogglePassivesWithAllBending")) { return; }
*
* BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
*
* if (bPlayer == null) return; if (!bPlayer.canBendPassive(Element.AIR))
* air = 0; if (!bPlayer.canBendPassive(Element.CHI)) chi = 0; int max = 0;
* if (CoreAbility.hasAbility(player, AcrobatStance.class)) { AcrobatStance
* abil = CoreAbility.getAbility(player, AcrobatStance.class); max =
* Math.max(air, chi); max = Math.max(max, abil.getSpeed()); } else { max =
* Math.max(air, chi); }
*
* if (max == 0) return; boolean b = true; if
* (player.hasPotionEffect(PotionEffectType.JUMP)) { for (PotionEffect
* potion : player.getActivePotionEffects()) { if (potion.getType() ==
* PotionEffectType.JUMP) { if (potion.getAmplifier() > max - 1) b = false;
* } } } if (b) { player.addPotionEffect(new
* PotionEffect(PotionEffectType.JUMP, 15, max-1, true, false), false); } }
*/
}

View file

@ -29,50 +29,53 @@ public class TempArmor {
private boolean removeAbilOnForceRevert = false;
/**
* Creates a set of temporary armor on the player. This armor cannot be tinkered with,
* dropped, and will restore the player's old armor when the duration expires or when
* {@link #revert()} is called.
* Creates a set of temporary armor on the player. This armor cannot be
* tinkered with, dropped, and will restore the player's old armor when the
* duration expires or when {@link #revert()} is called.
*
* @param entity The player
* @param armorItems The armor that should be set onto the player. Optional - can be set later.
* */
* @param armorItems The armor that should be set onto the player. Optional
* - can be set later.
*/
public TempArmor(LivingEntity entity, ItemStack[] armorItems) {
this(entity, defaultDuration, null, armorItems);
}
/**
* Creates a set of temporary armor on the player. This armor cannot be tinkered with,
* dropped, and will restore the player's old armor when the duration expires or when
* {@link #revert()} is called.
* Creates a set of temporary armor on the player. This armor cannot be
* tinkered with, dropped, and will restore the player's old armor when the
* duration expires or when {@link #revert()} is called.
*
* @param entity The player
* @param ability The ability that is creating the armor
* @param armorItems The armor that should be set onto the player. Optional - can be set later.
* */
* @param armorItems The armor that should be set onto the player. Optional
* - can be set later.
*/
public TempArmor(LivingEntity entity, CoreAbility ability, ItemStack[] armorItems) {
this(entity, defaultDuration, ability, armorItems);
}
/**
* Creates a set of temporary armor on the player. This armor cannot be tinkered with,
* dropped, and will restore the player's old armor when the duration expires or when
* {@link #revert()} is called.
* Creates a set of temporary armor on the player. This armor cannot be
* tinkered with, dropped, and will restore the player's old armor when the
* duration expires or when {@link #revert()} is called.
*
* @param entity The player
* @param duration How long the armor is to last. In milliseconds.
* @param ability The ability that is creating the armor
* @param armorItems The armor that should be set onto the player. Optional - can be set later.
* */
* @param armorItems The armor that should be set onto the player. Optional
* - can be set later.
*/
public TempArmor(LivingEntity entity, long duration, CoreAbility ability, ItemStack[] armorItems) {
if (duration <= 0) duration = defaultDuration;
if (duration <= 0)
duration = defaultDuration;
this.entity = entity;
this.startTime = System.currentTimeMillis();
this.duration = duration;
this.ability = ability;
this.oldArmor = new ItemStack[] {new ItemStack(Material.AIR), new ItemStack(Material.AIR),
new ItemStack(Material.AIR), new ItemStack(Material.AIR)};
this.oldArmor = new ItemStack[] { new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR) };
for (int i = 0; i < 4; i++) {
if (this.entity.getEquipment().getArmorContents()[i] != null) {
@ -80,7 +83,6 @@ public class TempArmor {
}
}
this.newArmor = armorItems.clone();
ItemStack[] actualArmor = new ItemStack[4];
@ -92,8 +94,6 @@ public class TempArmor {
}
}
this.entity.getEquipment().setArmorContents(actualArmor);
//This auto reverts the armor after a certain amount of time. We're doing it
@ -116,7 +116,7 @@ public class TempArmor {
*
* @param drops The original item drop list
* @return The drop list with the old armor added in place of the temp armor
* */
*/
public List<ItemStack> filterArmor(List<ItemStack> drops) {
List<ItemStack> newDrops = new ArrayList<ItemStack>();
@ -127,7 +127,8 @@ public class TempArmor {
match = true;
break;
}
} if (!match) {
}
if (!match) {
newDrops.add(drop);
}
}
@ -180,17 +181,16 @@ public class TempArmor {
}
/**
* Sets whether the ability that created the TempArmor should be
* forcefully removed if the armor is forced to be reverted. Such
* cases are things like on player death, etc.
* Sets whether the ability that created the TempArmor should be forcefully
* removed if the armor is forced to be reverted. Such cases are things like
* on player death, etc.
*
* @param bool
* */
*/
public void setRemovesAbilityOnForceRevert(boolean bool) {
this.removeAbilOnForceRevert = bool;
}
/** Destroys the TempArmor instance and restores the player's old armor. */
public void revert() {
if (this.endTimer != null) {
@ -206,7 +206,10 @@ public class TempArmor {
INSTANCES.remove(this.entity);
}
/**Reverts all TempArmor instances. <b>Should only be used on server shutdown!</b>*/
/**
* Reverts all TempArmor instances. <b>Should only be used on server
* shutdown!</b>
*/
public static void revertAll() {
for (TempArmor armor : INSTANCES.values()) {
armor.revert();
@ -218,7 +221,7 @@ public class TempArmor {
*
* @param player The player
* @return If the player has temporary armor on
* */
*/
public static boolean hasTempArmor(LivingEntity player) {
return INSTANCES.containsKey(player);
}
@ -227,8 +230,9 @@ public class TempArmor {
* Returns the temporary armor the player is currently wearing
*
* @param player The player
* @return The TempArmor the player is wearing, or <code>null</code> if they aren't wearing any.
* */
* @return The TempArmor the player is wearing, or <code>null</code> if they
* aren't wearing any.
*/
public static TempArmor getTempArmor(LivingEntity player) {
return INSTANCES.get(player);
}

View file

@ -14,13 +14,13 @@ import javax.xml.parsers.DocumentBuilderFactory;
import javax.xml.parsers.ParserConfigurationException;
/**
* Updater class that takes an rss feed and checks for updates there
* <br>
* Updater class that takes an rss feed and checks for updates there <br>
* Will only work on xenforo rss feeds
* <p>
* Methods to look for in this class:
* <ul>
* <li>{@link #checkUpdate()} called in {@code plugin.onEnable()} to display update message in log</li>
* <li>{@link #checkUpdate()} called in {@code plugin.onEnable()} to display
* update message in log</li>
* <li>{@link #getCurrentVersion()} to get the version of the plugin</li>
* <li>{@link #getUpdateVersion()} to get the update version</li>
* <li>{@link #updateAvailable()} to check if theres an update</li>
@ -40,12 +40,12 @@ public class Updater {
private String pluginName;
/**
* Creates a new instance of Updater.
* This constructor should only be called inside of
* {@code plugin.onEnable()} or called after the plugin is loaded.
* <br><br>
* This constructor should NEVER be called to initiate a field.
* If called to initiate a field, Updater will throw NullPointerExceptions
* Creates a new instance of Updater. This constructor should only be called
* inside of {@code plugin.onEnable()} or called after the plugin is loaded.
* <br>
* <br>
* This constructor should NEVER be called to initiate a field. If called to
* initiate a field, Updater will throw NullPointerExceptions
*
* @param plugin Plugin to check updates for
* @param URL RSS feed URL link to check for updates on.
@ -58,9 +58,11 @@ public class Updater {
urlc.setRequestProperty("User-Agent", ""); // Must be used or face 403
urlc.setConnectTimeout(30000); // 30 second time out, throws SocketTimeoutException
document = DocumentBuilderFactory.newInstance().newDocumentBuilder().parse(urlc.getInputStream());
} catch (IOException e) {
}
catch (IOException e) {
plugin.getLogger().info("Could not connect to ProjectKorra.com to check for updates");
} catch (SAXException | ParserConfigurationException e) {
}
catch (SAXException | ParserConfigurationException e) {
e.printStackTrace();
}
this.currentVersion = plugin.getDescription().getVersion();
@ -68,8 +70,8 @@ public class Updater {
}
/**
* Logs and update message in console.
* Displays different messages dependent on {@link #updateAvailable()}
* Logs and update message in console. Displays different messages dependent
* on {@link #updateAvailable()}
*
*/
public void checkUpdate() {

View file

@ -8,15 +8,16 @@ import java.util.logging.LogRecord;
/**
* Main handler used to listen to LogRecords and logs them.
* <p>
* Should be injected into plugin.getLogger().getParent(),
* <br>
* Should be injected into plugin.getLogger().getParent(), <br>
* if used anywhere else the handler may not work to expected.
* </p>
* Current Handler settings:
* <ul>
* <li>Level - Set to log {@link Level#WARNING warnings} and {@link Level#SEVERE errors}</li>
* <li>Level - Set to log {@link Level#WARNING warnings} and {@link Level#SEVERE
* errors}</li>
* <li>Formatter - {@link LogFormatter}</li>
* </ul>
*
* @author Jacklin213
* @version 2.1.0
*/

View file

@ -256,10 +256,7 @@ public class SurgeWall extends WaterAbility {
continue;
} else if (WALL_BLOCKS.containsKey(block)) {
blocks.add(block);
} else if (!blocks.contains(block)
&& (block.getType() == Material.AIR
|| block.getType() == Material.FIRE
|| isWaterbendable(block)) && isTransparent(block)) {
} else if (!blocks.contains(block) && (block.getType() == Material.AIR || block.getType() == Material.FIRE || isWaterbendable(block)) && isTransparent(block)) {
WALL_BLOCKS.put(block, player);
addWallBlock(block);
blocks.add(block);
@ -309,7 +306,8 @@ public class SurgeWall extends WaterAbility {
sourceBlock = block;
if (location.distanceSquared(targetDestination) < 1) {
removeWater(sourceBlock);;
removeWater(sourceBlock);
;
forming = true;
}
}
@ -382,9 +380,7 @@ public class SurgeWall extends WaterAbility {
SurgeWave wave = getAbility(player, SurgeWave.class);
if (wall == null) {
if (wave == null
&& BlockSource.getWaterSourceBlock(player, range, ClickType.LEFT_CLICK, true, true, bPlayer.canPlantbend()) == null
&& WaterReturn.hasWaterBottle(player)) {
if (wave == null && BlockSource.getWaterSourceBlock(player, range, ClickType.LEFT_CLICK, true, true, bPlayer.canPlantbend()) == null && WaterReturn.hasWaterBottle(player)) {
if (bPlayer.isOnCooldown("SurgeWall")) {
return;
}
@ -434,7 +430,6 @@ public class SurgeWall extends WaterAbility {
}
}
public static void thaw(Block block) {
finalRemoveWater(block);
}

View file

@ -261,19 +261,13 @@ public class SurgeWave extends WaterAbility {
Block blockl = location.getBlock();
ArrayList<Block> blocks = new ArrayList<Block>();
if (!GeneralMethods.isRegionProtectedFromBuild(this, location)
&& (((blockl.getType() == Material.AIR || blockl.getType() == Material.FIRE
|| isPlant(blockl) || isWater(blockl)
|| isWaterbendable(player, blockl)))
&& blockl.getType() != Material.LEAVES)) {
if (!GeneralMethods.isRegionProtectedFromBuild(this, location) && (((blockl.getType() == Material.AIR || blockl.getType() == Material.FIRE || isPlant(blockl) || isWater(blockl) || isWaterbendable(player, blockl))) && blockl.getType() != Material.LEAVES)) {
for (double i = 0; i <= currentRadius; i += .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)
|| isWaterbendable(block)) {
if (!blocks.contains(block) && (block.getType() == Material.AIR || block.getType() == Material.FIRE) || isWaterbendable(block)) {
blocks.add(block);
FireBlast.removeFireBlastsAroundPoint(block.getLocation(), 2);
}

View file

@ -105,8 +105,7 @@ public class Torrent extends WaterAbility {
}
time = System.currentTimeMillis();
sourceBlock = BlockSource.getWaterSourceBlock(player, selectRange, ClickType.LEFT_CLICK, true, true,
bPlayer.canPlantbend());
sourceBlock = BlockSource.getWaterSourceBlock(player, selectRange, ClickType.LEFT_CLICK, true, true, bPlayer.canPlantbend());
if (sourceBlock != null && !GeneralMethods.isRegionProtectedFromBuild(this, sourceBlock.getLocation())) {
sourceSelected = true;
start();
@ -233,9 +232,7 @@ public class Torrent extends WaterAbility {
double dz = Math.sin(phi) * radius;
loc.add(dx, dy, dz);
if (isWater(loc.getBlock()) && GeneralMethods.isAdjacentToThreeOrMoreSources(loc.getBlock())) {
ParticleEffect.WATER_BUBBLE.display((float) Math.random(), (float) Math.random(),
(float) Math.random(), 0f, 5, loc.getBlock().getLocation().clone().add(.5, .5, .5),
255.0);
ParticleEffect.WATER_BUBBLE.display((float) Math.random(), (float) Math.random(), (float) Math.random(), 0f, 5, loc.getBlock().getLocation().clone().add(.5, .5, .5), 255.0);
}
loc.subtract(dx, dy, dz);
}
@ -342,8 +339,7 @@ public class Torrent extends WaterAbility {
}
Block locBlock = location.getBlock();
if (location.distanceSquared(player.getLocation()) > range * range
|| GeneralMethods.isRegionProtectedFromBuild(this, location)) {
if (location.distanceSquared(player.getLocation()) > range * range || GeneralMethods.isRegionProtectedFromBuild(this, location)) {
if (layer < maxLayer) {
if (freeze || layer < 1) {
layer++;
@ -375,8 +371,7 @@ public class Torrent extends WaterAbility {
}
if (locBlock.getLocation().distanceSquared(targetLoc) > 1) {
if (isWater(locBlock)) {
ParticleEffect.WATER_BUBBLE.display((float) Math.random(), (float) Math.random(),
(float) Math.random(), 0f, 5, locBlock.getLocation().clone().add(.5, .5, .5), 255.0);
ParticleEffect.WATER_BUBBLE.display((float) Math.random(), (float) Math.random(), (float) Math.random(), 0f, 5, locBlock.getLocation().clone().add(.5, .5, .5), 255.0);
}
newBlocks.add(new TempBlock(locBlock, Material.STATIONARY_WATER, (byte) 8));
} else {
@ -404,15 +399,11 @@ public class Torrent extends WaterAbility {
if (entity.getWorld() != block.getBlock().getWorld()) {
continue;
}
if (entity.getLocation().distanceSquared(block.getLocation()) <= 1.5 * 1.5
&& !affectedEntities.contains(entity)) {
if (entity.getLocation().distanceSquared(block.getLocation()) <= 1.5 * 1.5 && !affectedEntities.contains(entity)) {
if (i == 0) {
affect(entity, dir);
} else {
affect(entity,
GeneralMethods
.getDirection(block.getLocation(), launchedBlocks.get(i - 1).getLocation())
.normalize());
affect(entity, GeneralMethods.getDirection(block.getLocation(), launchedBlocks.get(i - 1).getLocation()).normalize());
}
affectedEntities.add(entity);
}
@ -453,8 +444,7 @@ public class Torrent extends WaterAbility {
if (entity.getWorld() != blockLoc.getWorld()) {
continue;
}
if (!affectedEntities.contains(entity)
&& entity.getLocation().distanceSquared(blockLoc) <= 1.5 * 1.5) {
if (!affectedEntities.contains(entity) && entity.getLocation().distanceSquared(blockLoc) <= 1.5 * 1.5) {
deflect(entity);
}
}
@ -602,8 +592,7 @@ public class Torrent extends WaterAbility {
} else if (block.getBlock().getWorld() != player.getWorld()) {
thaw(block);
continue;
} else if (block.getLocation().distanceSquared(player.getLocation()) > CLEANUP_RANGE * CLEANUP_RANGE
|| !bPlayer.canBendIgnoreBindsCooldowns(getAbility("Torrent"))) {
} else if (block.getLocation().distanceSquared(player.getLocation()) > CLEANUP_RANGE * CLEANUP_RANGE || !bPlayer.canBendIgnoreBindsCooldowns(getAbility("Torrent"))) {
thaw(block);
}
}

View file

@ -146,8 +146,7 @@ public class WaterManipulation extends WaterAbility {
progressing = true;
settingUp = true;
firstDestination = getToEyeLevel();
firstDirection = GeneralMethods.getDirection(sourceBlock.getLocation(), firstDestination)
.normalize();
firstDirection = GeneralMethods.getDirection(sourceBlock.getLocation(), firstDestination).normalize();
targetDestination = GeneralMethods.getPointOnLine(firstDestination, targetDestination, range);
targetDirection = GeneralMethods.getDirection(firstDestination, targetDestination).normalize();
@ -164,8 +163,7 @@ public class WaterManipulation extends WaterAbility {
}
public boolean prepare() {
Block block = BlockSource.getWaterSourceBlock(player, selectRange, ClickType.SHIFT_DOWN, true, true,
bPlayer.canPlantbend());
Block block = BlockSource.getWaterSourceBlock(player, selectRange, ClickType.SHIFT_DOWN, true, true, bPlayer.canPlantbend());
cancelPrevious();
//block(player);
@ -304,8 +302,7 @@ public class WaterManipulation extends WaterAbility {
trail = new TempBlock(sourceBlock, Material.STATIONARY_WATER, (byte) 1);
sourceBlock = block;
if (location.distanceSquared(targetDestination) <= 1
|| location.distanceSquared(firstDestination) > range * range) {
if (location.distanceSquared(targetDestination) <= 1 || location.distanceSquared(firstDestination) > range * range) {
falling = true;
progressing = false;
}
@ -358,8 +355,7 @@ public class WaterManipulation extends WaterAbility {
new TempBlock(block, Material.WATER, (byte) 0);
} else {
if (isWater(block) && !AFFECTED_BLOCKS.containsKey(block)) {
ParticleEffect.WATER_BUBBLE.display((float) Math.random(), (float) Math.random(), (float) Math.random(), 0f,
5, block.getLocation().clone().add(.5, .5, .5), 255.0);
ParticleEffect.WATER_BUBBLE.display((float) Math.random(), (float) Math.random(), (float) Math.random(), 0f, 5, block.getLocation().clone().add(.5, .5, .5), 255.0);
}
}
@ -399,10 +395,7 @@ public class WaterManipulation extends WaterAbility {
Location location = player.getEyeLocation();
Vector vector = location.getDirection();
Location mloc = manip.location;
if (mloc.distanceSquared(location) <= manip.selectRange * manip.selectRange
&& GeneralMethods.getDistanceFromLine(vector, location, manip.location) < manip.deflectRange
&& mloc.distanceSquared(location.clone().add(vector)) < mloc
.distanceSquared(location.clone().add(vector.clone().multiply(-1)))) {
if (mloc.distanceSquared(location) <= manip.selectRange * manip.selectRange && GeneralMethods.getDistanceFromLine(vector, location, manip.location) < manip.deflectRange && mloc.distanceSquared(location.clone().add(vector)) < mloc.distanceSquared(location.clone().add(vector.clone().multiply(-1)))) {
manip.remove();
}
}
@ -526,10 +519,7 @@ public class WaterManipulation extends WaterAbility {
Location location = player.getEyeLocation();
Vector vector = location.getDirection();
Location mloc = manip.location;
if (mloc.distanceSquared(location) <= manip.selectRange * manip.selectRange
&& GeneralMethods.getDistanceFromLine(vector, location, manip.location) < manip.deflectRange
&& mloc.distanceSquared(location.clone().add(vector)) < mloc
.distanceSquared(location.clone().add(vector.clone().multiply(-1)))) {
if (mloc.distanceSquared(location) <= manip.selectRange * manip.selectRange && GeneralMethods.getDistanceFromLine(vector, location, manip.location) < manip.deflectRange && mloc.distanceSquared(location.clone().add(vector)) < mloc.distanceSquared(location.clone().add(vector.clone().multiply(-1)))) {
manip.redirect(player, getTargetLocation(player, manip.selectRange));
}
}

View file

@ -6,6 +6,7 @@ import java.util.HashSet;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.bukkit.Bukkit;
import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
@ -291,6 +292,7 @@ public class WaterSpoutWave extends WaterAbility {
for (Block block : FROZEN_BLOCKS.keySet()) {
TempBlock tBlock = FROZEN_BLOCKS.get(block);
if (tBlock.getBlock().getWorld().equals(player.getWorld()) && tBlock.getLocation().distance(player.getLocation()) >= thawRadius) {
Bukkit.broadcastMessage("revert");
tBlock.revertBlock();
FROZEN_BLOCKS.remove(block);
}

View file

@ -73,11 +73,7 @@ public class Bloodbending extends BloodAbility {
if (entity instanceof Player) {
Player enemyPlayer = (Player) entity;
BendingPlayer enemyBPlayer = BendingPlayer.getBendingPlayer(enemyPlayer);
if (enemyBPlayer == null
|| GeneralMethods.isRegionProtectedFromBuild(this, entity.getLocation())
|| enemyBPlayer.isAvatarState()
|| entity.getEntityId() == player.getEntityId()
|| enemyBPlayer.canBendIgnoreBindsCooldowns(this)) {
if (enemyBPlayer == null || GeneralMethods.isRegionProtectedFromBuild(this, entity.getLocation()) || enemyBPlayer.isAvatarState() || entity.getEntityId() == player.getEntityId() || enemyBPlayer.canBendIgnoreBindsCooldowns(this)) {
continue;
}
}
@ -109,9 +105,7 @@ public class Bloodbending extends BloodAbility {
}
target = entities.get(0);
if (target == null || !(target instanceof LivingEntity)
|| GeneralMethods.isRegionProtectedFromBuild(this, target.getLocation())
|| target.getEntityId() == player.getEntityId()) {
if (target == null || !(target instanceof LivingEntity) || GeneralMethods.isRegionProtectedFromBuild(this, target.getLocation()) || target.getEntityId() == player.getEntityId()) {
return;
} else if (target instanceof Player) {
BendingPlayer targetBPlayer = BendingPlayer.getBendingPlayer(player);
@ -213,7 +207,6 @@ public class Bloodbending extends BloodAbility {
TARGETED_ENTITIES.put(entity, player);
}
if (player.getWorld() != entity.getLocation().getWorld()) {
TARGETED_ENTITIES.remove(entity);
continue;

View file

@ -274,10 +274,7 @@ public class HealingWaters extends HealingAbility {
if (location.getWorld().equals(targetLoc.getWorld())) {
distance = location.distance(targetLoc);
}
Vector vec = new Vector(
targetLoc.getX() - location.getX(),
targetLoc.getY() - location.getY(),
targetLoc.getZ() - location.getZ()).normalize();
Vector vec = new Vector(targetLoc.getX() - location.getX(), targetLoc.getY() - location.getY(), targetLoc.getZ() - location.getZ()).normalize();
if (location.getWorld().equals(targetLoc.getWorld()) && location.distance(targetLoc) <= distance) {
location = location.clone().add(vec.clone().multiply(factor));

View file

@ -107,9 +107,7 @@ public class IceBlast extends IceAbility {
Vector vector = location.getDirection();
Location mloc = iceBlast.location;
if (mloc.distanceSquared(location) <= iceBlast.range * iceBlast.range
&& GeneralMethods.getDistanceFromLine(vector, location, iceBlast.location) < iceBlast.deflectRange
&& mloc.distanceSquared(location.clone().add(vector)) < mloc.distanceSquared(location.clone().add(vector.clone().multiply(-1)))) {
if (mloc.distanceSquared(location) <= iceBlast.range * iceBlast.range && GeneralMethods.getDistanceFromLine(vector, location, iceBlast.location) < iceBlast.deflectRange && mloc.distanceSquared(location.clone().add(vector)) < mloc.distanceSquared(location.clone().add(vector.clone().multiply(-1)))) {
iceBlast.remove();
}
}

View file

@ -62,9 +62,7 @@ public class IceSpikePillar extends IceAbility {
double lowestDistance = range + 1;
Entity closestEntity = null;
for (Entity entity : GeneralMethods.getEntitiesAroundPoint(player.getLocation(), range)) {
if (GeneralMethods.getDistanceFromLine(player.getLocation().getDirection(), player.getLocation(), entity.getLocation()) <= 2
&& (entity instanceof LivingEntity)
&& (entity.getEntityId() != player.getEntityId())) {
if (GeneralMethods.getDistanceFromLine(player.getLocation().getDirection(), player.getLocation(), entity.getLocation()) <= 2 && (entity instanceof LivingEntity) && (entity.getEntityId() != player.getEntityId())) {
double distance = 0;
if (player.getWorld().equals(entity.getWorld())) {
distance = player.getLocation().distance(entity.getLocation());
@ -84,7 +82,8 @@ public class IceSpikePillar extends IceAbility {
}
origin = block.getLocation();
location = origin.clone();
} catch (IllegalStateException e) {
}
catch (IllegalStateException e) {
return;
}
@ -171,9 +170,7 @@ public class IceSpikePillar extends IceAbility {
return false;
}
for (Block block : affectedBlocks.keySet()) {
if (blockInAllAffectedBlocks(block) || ALREADY_DONE_BLOCKS.containsKey(block)
|| block.getType() != Material.AIR
|| (block.getX() == player.getEyeLocation().getBlock().getX() && block.getZ() == player.getEyeLocation().getBlock().getZ())) {
if (blockInAllAffectedBlocks(block) || ALREADY_DONE_BLOCKS.containsKey(block) || block.getType() != Material.AIR || (block.getX() == player.getEyeLocation().getBlock().getX() && block.getZ() == player.getEyeLocation().getBlock().getZ())) {
return false;
}
}

View file

@ -49,10 +49,7 @@ public class IceSpikePillarField extends IceAbility {
for (int y = -1; y <= 1; y++) {
Block testBlock = player.getWorld().getBlockAt(locX + x, locY + y, locZ + z);
if (WaterAbility.isIcebendable(player, testBlock.getType(), false)
&& testBlock.getRelative(BlockFace.UP).getType() == Material.AIR
&& !(testBlock.getX() == player.getEyeLocation().getBlock().getX()
&& testBlock.getZ() == player.getEyeLocation().getBlock().getZ())) {
if (WaterAbility.isIcebendable(player, testBlock.getType(), false) && testBlock.getRelative(BlockFace.UP).getType() == Material.AIR && !(testBlock.getX() == player.getEyeLocation().getBlock().getX() && testBlock.getZ() == player.getEyeLocation().getBlock().getZ())) {
iceBlocks.add(testBlock);
for (int i = 0; i < iceBlocks.size() / 2 + 1; i++) {
Random rand = new Random();
@ -108,7 +105,8 @@ public class IceSpikePillarField extends IceAbility {
}
@Override
public void progress() {}
public void progress() {
}
@Override
public Location getLocation() {

View file

@ -95,7 +95,7 @@ public class PhaseChange extends IceAbility {
}
if (active_types.contains(PhaseChangeType.MELT)) {
if (!player.isSneaking()) {
if (!player.isSneaking() || !bPlayer.canBend(this)) {
active_types.remove(PhaseChangeType.MELT);
bPlayer.addCooldown("PhaseChangeMelt", meltCooldown);
meltRadius = 1;
@ -104,7 +104,6 @@ public class PhaseChange extends IceAbility {
if (meltRadius >= meltMaxRadius) {
meltRadius = 1;
}
Location l = GeneralMethods.getTargetedLocation(player, sourceRange);
resetMeltLocation(l);
meltArea(l, meltRadius);
@ -199,7 +198,8 @@ public class PhaseChange extends IceAbility {
} else if (value < 0) {
return BlockFace.NORTH;
}
default: return null;
default:
return null;
}
}
@ -369,8 +369,10 @@ public class PhaseChange extends IceAbility {
}
playWaterbendingSound(b.getLocation());
}
/**
* Only works with PhaseChange frozen blocks!
*
* @param tb TempBlock being thawed
* @return true when it is thawed successfully
*/
@ -395,6 +397,7 @@ public class PhaseChange extends IceAbility {
/**
* Only works if the block is a {@link TempBlock} and PhaseChange frozen!
*
* @param b Block being thawed
* @return false if not a {@link TempBlock}
*/

View file

@ -134,7 +134,6 @@ public class WaterArms extends WaterAbility {
return;
}
if (bPlayer.canBend(this) && prepare()) {
start();
MultiAbilityManager.bindMultiAbility(player, "WaterArms");
@ -407,10 +406,10 @@ public class WaterArms extends WaterAbility {
public static void progressAllCleanup() {
progressRevert(false);
/*
* There is currently a bug where waterArms will display the arms and then
* progressRevert will revert the same blocks in the same tick before the user is
* able to see them, thus causing invisible arms. Simple fix is just to display the arms
* again.
* There is currently a bug where waterArms will display the arms and
* then progressRevert will revert the same blocks in the same tick
* before the user is able to see them, thus causing invisible arms.
* Simple fix is just to display the arms again.
*/
for (WaterArms waterArms : getAbilities(WaterArms.class)) {
waterArms.displayLeftArm();

View file

@ -242,8 +242,7 @@ public class WaterArmsSpear extends WaterAbility {
}
private boolean canPlaceBlock(Block block) {
if (!isTransparent(player, block)
&& !((isWater(block) || isIcebendable(block)) && (TempBlock.isTempBlock(block) && !getIceBlocks().containsKey(block)))) {
if (!isTransparent(player, block) && !((isWater(block) || isIcebendable(block)) && (TempBlock.isTempBlock(block) && !getIceBlocks().containsKey(block)))) {
return false;
} else if (GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation())) {
return false;

View file

@ -194,7 +194,8 @@ public class WaterArmsWhip extends WaterAbility {
} else if (player.isDead() || !player.isOnline()) {
remove();
return;
} if (!MultiAbilityManager.hasMultiAbilityBound(player, "WaterArms")) {
}
if (!MultiAbilityManager.hasMultiAbilityBound(player, "WaterArms")) {
remove();
return;
}

View file

@ -34,34 +34,27 @@ public class WaterPassive {
* Fast Swim is now managed in FastSwim.java
*/
/*
public static void handlePassive() {
if (Commands.isToggledForAll && ConfigManager.defaultConfig.get().getBoolean("Properties.TogglePassivesWithAllBending")) {
return;
}
double swimSpeed = getSwimSpeed();
for (Player player : Bukkit.getServer().getOnlinePlayers()) {
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player);
if (bPlayer == null) {
continue;
}
String ability = bPlayer.getBoundAbilityName();
CoreAbility coreAbil = CoreAbility.getAbility(ability);
if (bPlayer.canBendPassive(Element.WATER)) {
if (CoreAbility.hasAbility(player, WaterSpout.class) || CoreAbility.hasAbility(player, EarthArmor.class)) {
continue;
} else if (CoreAbility.getAbility(player, WaterArms.class) != null) {
continue;
} else if (coreAbil == null || (coreAbil != null && !coreAbil.isSneakAbility())) {
if (player.isSneaking() && WaterAbility.isWater(player.getLocation().getBlock())) {
player.setVelocity(player.getEyeLocation().getDirection().clone().normalize().multiply(swimSpeed));
}
}
}
}
}
* public static void handlePassive() { if (Commands.isToggledForAll &&
* ConfigManager.defaultConfig.get().getBoolean(
* "Properties.TogglePassivesWithAllBending")) { return; }
*
* double swimSpeed = getSwimSpeed();
*
* for (Player player : Bukkit.getServer().getOnlinePlayers()) {
* BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); if
* (bPlayer == null) { continue; }
*
* String ability = bPlayer.getBoundAbilityName(); CoreAbility coreAbil =
* CoreAbility.getAbility(ability); if
* (bPlayer.canBendPassive(Element.WATER)) { if
* (CoreAbility.hasAbility(player, WaterSpout.class) ||
* CoreAbility.hasAbility(player, EarthArmor.class)) { continue; } else if
* (CoreAbility.getAbility(player, WaterArms.class) != null) { continue; }
* else if (coreAbil == null || (coreAbil != null &&
* !coreAbil.isSneakAbility())) { if (player.isSneaking() &&
* WaterAbility.isWater(player.getLocation().getBlock())) {
* player.setVelocity(player.getEyeLocation().getDirection().clone().
* normalize().multiply(swimSpeed)); } } } } }
*/
public static double getSwimSpeed() {

View file

@ -132,12 +132,9 @@ public class WaterReturn extends WaterAbility {
}
private static boolean isBending(Player player) {
if (hasAbility(player, WaterManipulation.class)
|| hasAbility(player, WaterManipulation.class)
|| hasAbility(player, OctopusForm.class)
if (hasAbility(player, WaterManipulation.class) || hasAbility(player, WaterManipulation.class) || hasAbility(player, OctopusForm.class)
// || hasAbility(player, SurgeWave.class) NOTE: ONLY DISABLED TO PREVENT BOTTLEBENDING FROM BEING DISABLED FOREVER. ONCE BOTTLEBENDING HAS BEEN RECODED IN 1.9, THIS NEEDS TO BE READDED TO THE NEW SYSTEM.
|| hasAbility(player, SurgeWall.class)
|| hasAbility(player, IceSpikeBlast.class)) {
|| hasAbility(player, SurgeWall.class) || hasAbility(player, IceSpikeBlast.class)) {
return true;
}
return false;

View file

@ -56,8 +56,7 @@ public class WaterSourceGrabber {
currentLoc.add(0, animimationSpeed * Math.signum(locDiff), 0);
Block block = currentLoc.getBlock();
if (!(WaterAbility.isWaterbendable(player, null, block) || block.getType() == Material.AIR)
|| GeneralMethods.isRegionProtectedFromBuild(player, "WaterSpout", block.getLocation())) {
if (!(WaterAbility.isWaterbendable(player, null, block) || block.getType() == Material.AIR) || GeneralMethods.isRegionProtectedFromBuild(player, "WaterSpout", block.getLocation())) {
remove();
return;
}
@ -74,8 +73,7 @@ public class WaterSourceGrabber {
currentLoc.add(vec.normalize().multiply(animimationSpeed));
Block block = currentLoc.getBlock();
if (!(WaterAbility.isWaterbendable(player, null, block) || block.getType() == Material.AIR)
|| GeneralMethods.isRegionProtectedFromBuild(player, "WaterManipulation", block.getLocation())) {
if (!(WaterAbility.isWaterbendable(player, null, block) || block.getType() == Material.AIR) || GeneralMethods.isRegionProtectedFromBuild(player, "WaterManipulation", block.getLocation())) {
remove();
return;
}