getPlayers(final Class extends CoreAbility> clazz) {
/**
* Scans and loads plugin CoreAbilities, and Addon CoreAbilities that are
- * located in a Jar file inside of the /ProjectKorra/Abilities/ folder.
+ * located in a Jar file inside the /ProjectKorra/Abilities/ folder.
*/
public static void registerAbilities() {
ABILITIES_BY_NAME.clear();
@@ -675,8 +655,8 @@ public static void registerPluginAbilities(final JavaPlugin plugin, final String
}
/**
- * Scans all of the Jar files inside of /ProjectKorra/folder and registers
- * all of the CoreAbility class files that were found.
+ * Scans all the Jar files inside /ProjectKorra/folder and registers
+ * all the CoreAbility class files that were found.
*
* @param folder the name of the folder to scan
* @see #getAbilities()
@@ -684,7 +664,7 @@ public static void registerPluginAbilities(final JavaPlugin plugin, final String
*/
public static void registerAddonAbilities(final String folder) {
final ProjectKorra plugin = ProjectKorra.plugin;
- final File path = new File(plugin.getDataFolder().toString() + folder);
+ final File path = new File(plugin.getDataFolder() + folder);
if (!path.exists()) {
path.mkdir();
return;
@@ -821,7 +801,7 @@ public boolean isEnabled() {
elementName = ((SubElement) this.getElement()).getParentElement().getName();
}
- String tag = null;
+ String tag;
if (this instanceof PassiveAbility) {
tag = "Abilities." + elementName + ".Passive." + this.getName() + ".Enabled";
} else {
@@ -987,7 +967,7 @@ public double getCollisionRadius() {
/**
* Called when this ability instance collides with another. Some abilities
- * may want advanced behavior on a Collision; e.g. FireCombos only remove
+ * may want advanced behavior on a Collision; e.g., FireCombos only remove
* the stream that was hit rather than the entire ability.
*
* collision.getAbilitySecond() - the ability that we are colliding with
@@ -1025,7 +1005,7 @@ public List getLocations() {
*/
@Deprecated
public CoreAbility addAttributeModifier(final String attribute, final Number value, final AttributeModifier modification) {
- return this;//.addAttributeModifier(attribute, value, modification, AttributePriority.MEDIUM);
+ return this;
}
/**
@@ -1034,7 +1014,7 @@ public CoreAbility addAttributeModifier(final String attribute, final Number val
*/
@Deprecated
public CoreAbility addAttributeModifier(final String attribute, final Number value, final AttributeModifier modificationType, final AttributePriority priority) {
- return this;//.addAttributeModifier(attribute, value, modificationType, priority, UUID.randomUUID());
+ return this;
}
/**
@@ -1058,7 +1038,7 @@ public CoreAbility setAttribute(final String attribute, final Object value) {
/**
* Recalculate what the ability's attributes should be. This is called
* whenever an ability is created, but should be called whenever you want an
- * ability to recalculate some of it's values. E.g. day turns to night, AvatarState
+ * ability to recalculate some of its values. E.g., day turns to night AvatarState
* gets toggled, etc.
*/
public void recalculateAttributes() {
@@ -1167,10 +1147,10 @@ public static String getDebugString() {
}
}
- sb.append("Class->UUID's in memory: " + playerCounter + "\n");
+ sb.append("Class->UUID's in memory: ").append(playerCounter).append("\n");
sb.append("Abilities in memory:\n");
for (final String className : classCounter.keySet()) {
- sb.append(className + ": " + classCounter.get(className) + "\n");
+ sb.append(className).append(": ").append(classCounter.get(className)).append("\n");
}
return sb.toString();
}
diff --git a/core/src/com/projectkorra/projectkorra/ability/util/FoliaThreadChecker.java b/core/src/com/projectkorra/projectkorra/ability/util/FoliaThreadChecker.java
index ab77bf248..854961405 100644
--- a/core/src/com/projectkorra/projectkorra/ability/util/FoliaThreadChecker.java
+++ b/core/src/com/projectkorra/projectkorra/ability/util/FoliaThreadChecker.java
@@ -11,7 +11,7 @@
*/
public class FoliaThreadChecker implements Runnable {
- private Player player;
+ private final Player player;
private Location oldLocation;
public FoliaThreadChecker(Player player) {
diff --git a/core/src/com/projectkorra/projectkorra/command/BindCommand.java b/core/src/com/projectkorra/projectkorra/command/BindCommand.java
index 22cd68fa1..e588aaf6f 100644
--- a/core/src/com/projectkorra/projectkorra/command/BindCommand.java
+++ b/core/src/com/projectkorra/projectkorra/command/BindCommand.java
@@ -114,10 +114,10 @@ private void bind(final CommandSender sender, final String ability, final int sl
@Override
protected List getTabCompletion(final CommandSender sender, final List args) {
if (args.size() >= 2 || !sender.hasPermission("bending.command.bind") || !(sender instanceof Player)) {
- return new ArrayList();
+ return new ArrayList<>();
}
- List abilities = new ArrayList();
+ List abilities = new ArrayList<>();
final BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(sender.getName());
if (args.size() == 0) {
if (bPlayer != null) {
diff --git a/core/src/com/projectkorra/projectkorra/command/ChooseCommand.java b/core/src/com/projectkorra/projectkorra/command/ChooseCommand.java
index 6944b3e0b..5a13fcc4b 100644
--- a/core/src/com/projectkorra/projectkorra/command/ChooseCommand.java
+++ b/core/src/com/projectkorra/projectkorra/command/ChooseCommand.java
@@ -59,6 +59,10 @@ public void execute(final CommandSender sender, final List args) {
//Don't need to bother with offline players here because the sender is always online
BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(sender.getName());
+ if (bPlayer == null) {
+ return;
+ }
+
if (bPlayer.isPermaRemoved()) {
ChatUtil.sendBrandingMessage(sender, ChatColor.RED + ConfigManager.languageConfig.get().getString("Commands.Preset.BendingPermanentlyRemoved"));
return;
@@ -187,13 +191,11 @@ private void add(final CommandSender sender, final OfflinePlayer target, final E
bPlayer.addElement(e);
if (online) {
- for (final SubElement sub : Element.getSubElements(element)) {
+ for (final SubElement sub : Element.getSubElements(e)) {
if (((BendingPlayer) bPlayer).hasSubElementPermission(sub)) {
PlayerChangeSubElementEvent subEvent = new PlayerChangeSubElementEvent(sender, target, sub, PlayerChangeSubElementEvent.Result.CHOOSE);
-
Bukkit.getServer().getPluginManager().callEvent(subEvent);
if (subEvent.isCancelled()) continue; //Do nothing if cancelled
-
bPlayer.addSubElement(sub);
}
}
diff --git a/core/src/com/projectkorra/projectkorra/configuration/ConfigManager.java b/core/src/com/projectkorra/projectkorra/configuration/ConfigManager.java
index 843b31758..08ba19be6 100644
--- a/core/src/com/projectkorra/projectkorra/configuration/ConfigManager.java
+++ b/core/src/com/projectkorra/projectkorra/configuration/ConfigManager.java
@@ -1061,6 +1061,7 @@ public static void configCheck(final ConfigType type) {
config.addDefault("Abilities.Water.IceBlast.CollisionRadius", 1.0);
config.addDefault("Abilities.Water.IceBlast.Interval", 20);
config.addDefault("Abilities.Water.IceBlast.Cooldown", 1500);
+ config.addDefault("Abilities.Water.IceBlast.SlowCooldown", 5000);
config.addDefault("Abilities.Water.IceBlast.AllowSnow", false);
config.addDefault("Abilities.Water.IceSpike.Enabled", true);
diff --git a/core/src/com/projectkorra/projectkorra/earthbending/EarthSmash.java b/core/src/com/projectkorra/projectkorra/earthbending/EarthSmash.java
index 59d08958e..d07c5a767 100644
--- a/core/src/com/projectkorra/projectkorra/earthbending/EarthSmash.java
+++ b/core/src/com/projectkorra/projectkorra/earthbending/EarthSmash.java
@@ -79,9 +79,9 @@ public static enum State {
private Block origin;
private Location location;
private Location destination;
- private ArrayList affectedEntities;
- private ArrayList currentBlocks;
- private ArrayList affectedBlocks;
+ private final ArrayList affectedEntities;
+ private final ArrayList currentBlocks;
+ private final ArrayList affectedBlocks;
public EarthSmash(final Player player, final ClickType type) {
super(player);
@@ -132,7 +132,6 @@ public EarthSmash(final Player player, final ClickType type) {
smash.location.getWorld().playEffect(smash.location, Effect.GHAST_SHOOT, 0, 10);
}
}
- return;
} else if (type == ClickType.RIGHT_CLICK && player.isSneaking()) {
final EarthSmash grabbedSmash = this.aimingAtSmashCheck(player, State.GRABBED);
if (grabbedSmash != null) {
@@ -142,7 +141,6 @@ public EarthSmash(final Player player, final ClickType type) {
grabbedSmash.setFields();
grabbedSmash.flightStartTime = System.currentTimeMillis();
}
- return;
}
}
@@ -210,7 +208,6 @@ public void progress() {
this.maxDamage = applyMetalPowerFactor(this.maxDamage, this.origin);
} else {
this.remove();
- return;
}
} else if (System.currentTimeMillis() - this.getStartTime() > this.chargeTime) {
final Location tempLoc = this.player.getEyeLocation().add(this.player.getEyeLocation().getDirection().normalize().multiply(1.2));
@@ -236,10 +233,8 @@ public void progress() {
}
}
this.draw();
- return;
} else {
this.state = State.LIFTED;
- return;
}
} else if (this.state == State.SHOT) {
if (System.currentTimeMillis() - this.delay >= this.shootAnimationInterval) {
@@ -272,7 +267,6 @@ public void progress() {
this.draw();
this.smashToSmashCollisionDetection();
}
- return;
} else if (this.state == State.FLYING) {
if (!this.player.isSneaking()) {
this.remove();
@@ -311,7 +305,6 @@ public void progress() {
}
if (System.currentTimeMillis() - this.flightStartTime > this.flightDuration) {
this.remove();
- return;
}
}
}
@@ -457,7 +450,7 @@ public void checkRemainingBlocks() {
final BlockRepresenter brep = this.currentBlocks.get(i);
final Block block = this.location.clone().add(brep.getX(), brep.getY(), brep.getZ()).getBlock();
// Check for grass because sometimes the dirt turns into grass.
- if (block.getType() != brep.getType() && (block.getType() != Material.GRASS) && (block.getType() != Material.COBBLESTONE)) {
+ if (block.getType() != brep.getType() && (block.getType() != Material.GRASS_BLOCK) && (block.getType() != Material.COBBLESTONE)) {
this.currentBlocks.remove(i);
i--;
}
diff --git a/core/src/com/projectkorra/projectkorra/earthbending/Tremorsense.java b/core/src/com/projectkorra/projectkorra/earthbending/Tremorsense.java
index 067138e3b..dcdad7be8 100644
--- a/core/src/com/projectkorra/projectkorra/earthbending/Tremorsense.java
+++ b/core/src/com/projectkorra/projectkorra/earthbending/Tremorsense.java
@@ -12,7 +12,6 @@
import org.bukkit.entity.Player;
import com.projectkorra.projectkorra.BendingPlayer;
-import com.projectkorra.projectkorra.GeneralMethods;
import com.projectkorra.projectkorra.ability.EarthAbility;
import com.projectkorra.projectkorra.ability.ElementalAbility;
import com.projectkorra.projectkorra.attribute.Attribute;
@@ -142,9 +141,17 @@ public void setUpBreaking() {
}
public void revertGlowBlock() {
- if (this.block != null) {
+ if (this.block == null) {
+ return;
+ }
+
+ try {
this.player.sendBlockChange(this.block.getLocation(), this.block.getBlockData());
this.glowing = false;
+ } catch (NullPointerException ignored) {
+ // Ignore invalidated exception since this is not needed
+ } catch (Exception ignored) {
+ // Ignore invalidated exception since this can be ignored
}
}
diff --git a/core/src/com/projectkorra/projectkorra/earthbending/lava/LavaSurge.java b/core/src/com/projectkorra/projectkorra/earthbending/lava/LavaSurge.java
index d18e67c14..ae30f4b8b 100644
--- a/core/src/com/projectkorra/projectkorra/earthbending/lava/LavaSurge.java
+++ b/core/src/com/projectkorra/projectkorra/earthbending/lava/LavaSurge.java
@@ -119,7 +119,9 @@ public void launch() {
try {
targetLocation = GeneralMethods.getTargetedEntity(this.player, this.travelRange * 2, null).getLocation();
- } catch (final NullPointerException e) {}
+ } catch (final NullPointerException ignored) {
+ // Ignore this exception too since it's not needed
+ }
if (targetLocation == null) {
this.remove();
diff --git a/core/src/com/projectkorra/projectkorra/event/AbilityRecalculateAttributeEvent.java b/core/src/com/projectkorra/projectkorra/event/AbilityRecalculateAttributeEvent.java
index bcf1f56e5..e57177718 100644
--- a/core/src/com/projectkorra/projectkorra/event/AbilityRecalculateAttributeEvent.java
+++ b/core/src/com/projectkorra/projectkorra/event/AbilityRecalculateAttributeEvent.java
@@ -1,22 +1,15 @@
package com.projectkorra.projectkorra.event;
-import com.google.common.primitives.Primitives;
import com.projectkorra.projectkorra.ability.CoreAbility;
import com.projectkorra.projectkorra.attribute.AttributeModification;
-import org.apache.commons.lang.math.NumberUtils;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
-import org.bukkit.util.NumberConversions;
import org.jetbrains.annotations.NotNull;
-import javax.lang.model.type.PrimitiveType;
import java.lang.annotation.Annotation;
import java.util.Comparator;
-import java.util.HashMap;
import java.util.Set;
import java.util.TreeSet;
-import java.util.function.Function;
-import java.util.function.Supplier;
public class AbilityRecalculateAttributeEvent extends Event {
diff --git a/core/src/com/projectkorra/projectkorra/util/ThreadUtil.java b/core/src/com/projectkorra/projectkorra/util/ThreadUtil.java
index 3d4f60937..3b04b24c4 100644
--- a/core/src/com/projectkorra/projectkorra/util/ThreadUtil.java
+++ b/core/src/com/projectkorra/projectkorra/util/ThreadUtil.java
@@ -211,7 +211,7 @@ public static Object runSyncLater(Runnable runnable, long delay) {
if (ProjectKorra.isFolia()) {
return Bukkit.getGlobalRegionScheduler().runDelayed(ProjectKorra.plugin, (task) -> runnable.run(), delay);
} else {
- return Bukkit.getScheduler().runTaskLater(ProjectKorra.plugin, runnable, delay);
+ return Bukkit.getScheduler().runTaskLater(ProjectKorra.plugin, runnable, delay);
}
}
diff --git a/core/src/com/projectkorra/projectkorra/waterbending/ice/IceBlast.java b/core/src/com/projectkorra/projectkorra/waterbending/ice/IceBlast.java
index c772a5fd6..a4e683d49 100644
--- a/core/src/com/projectkorra/projectkorra/waterbending/ice/IceBlast.java
+++ b/core/src/com/projectkorra/projectkorra/waterbending/ice/IceBlast.java
@@ -38,6 +38,8 @@ public class IceBlast extends IceAbility {
private long time;
@Attribute(Attribute.COOLDOWN) @DayNightFactor(invert = true)
private long cooldown;
+ @Attribute("Slow" + Attribute.COOLDOWN) @DayNightFactor(invert = true)
+ private long slowCooldown;
private long interval;
@Attribute(Attribute.RANGE) @DayNightFactor
private double range;
@@ -63,6 +65,7 @@ public IceBlast(final Player player) {
this.range = getConfig().getDouble("Abilities.Water.IceBlast.Range");
this.damage = getConfig().getInt("Abilities.Water.IceBlast.Damage");
this.cooldown = getConfig().getInt("Abilities.Water.IceBlast.Cooldown");
+ this.slowCooldown = getConfig().getLong("Abilities.Water.IceBlast.SlowCooldown");
this.allowSnow = getConfig().getBoolean("Abilities.Water.IceBlast.AllowSnow");
if (!this.bPlayer.canBend(this) || !this.bPlayer.canIcebend()) {
@@ -159,17 +162,16 @@ private void returnWater() {
}
private void affect(final LivingEntity entity) {
+ DamageHandler.damageEntity(entity, this.damage, this);
if (entity instanceof Player) {
if (this.bPlayer.canBeSlowed()) {
final PotionEffect effect = new PotionEffect(PotionEffectType.SLOW, 70, 2);
new TempPotionEffect(entity, effect);
- this.bPlayer.slow(10);
- DamageHandler.damageEntity(entity, this.damage, this);
+ this.bPlayer.slow(this.slowCooldown);
}
} else {
final PotionEffect effect = new PotionEffect(PotionEffectType.SLOW, 70, 2);
new TempPotionEffect(entity, effect);
- DamageHandler.damageEntity(entity, this.damage, this);
}
AirAbility.breakBreathbendingHold(entity);
@@ -488,5 +490,13 @@ public void setCooldown(final long cooldown) {
public void setLocation(final Location location) {
this.location = location;
}
+
+ public long getSlowCooldown() {
+ return this.slowCooldown;
+ }
+
+ public void setSlowCooldown(final long slowCooldown) {
+ this.slowCooldown = slowCooldown;
+ }
}
diff --git a/core/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikeBlast.java b/core/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikeBlast.java
index a3952f8e1..5ffc2bee1 100644
--- a/core/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikeBlast.java
+++ b/core/src/com/projectkorra/projectkorra/waterbending/ice/IceSpikeBlast.java
@@ -95,21 +95,16 @@ public IceSpikeBlast(final Player player) {
}
private void affect(final LivingEntity entity) {
+ DamageHandler.damageEntity(entity, this.damage, this);
if (entity instanceof Player) {
- final BendingPlayer targetBPlayer = BendingPlayer.getBendingPlayer((Player) entity);
- if (targetBPlayer == null) {
- return;
- }
- if (targetBPlayer.canBeSlowed()) {
+ if (this.bPlayer.canBeSlowed()) {
final PotionEffect effect = new PotionEffect(PotionEffectType.SLOW, this.slowDuration, this.slowPotency);
new TempPotionEffect(entity, effect);
- targetBPlayer.slow(this.slowCooldown);
- DamageHandler.damageEntity(entity, this.damage, this);
+ this.bPlayer.slow(this.slowCooldown);
}
} else {
final PotionEffect effect = new PotionEffect(PotionEffectType.SLOW, this.slowDuration, this.slowPotency);
new TempPotionEffect(entity, effect);
- DamageHandler.damageEntity(entity, this.damage, this);
}
AirAbility.breakBreathbendingHold(entity);
}