diff --git a/README.md b/README.md index ba41f7d..042833f 100644 --- a/README.md +++ b/README.md @@ -5,6 +5,15 @@ Join our [Discord](https://discord.gg/gh9MfDmwZm) to discuss the plugin, suggest ## Changelog +### 2.9.7 +- Used World#getMinHeight and World#getMaxHeight instead of hard-coded Y-values for certain abilities' cancellations (for 1.18 world height changes) +- Added getters and setters to almost all abilities for improved data accessibility +- Fixed many warnings and instances of poor style +- Made almost all abilities adhere to standards concerning the possible cancellation of the AbilityStartEvent, so no irreversible changes take place if the event is cancelled +- Converted all instances of Entity#setVelocity to the new GeneralMethods#setVelocity, which calls its own event +- Removed unnecessary "time" variables that can be replaced with getStartTime() calls +- Made FirePunch not static + ### 2.9.6.2 - Started using jitpack for ProjectKorra dependency diff --git a/pom.xml b/pom.xml index a8f79b8..ed29ea5 100644 --- a/pom.xml +++ b/pom.xml @@ -4,7 +4,7 @@ com.jedk1 jedcore - 2.9.6.2-Spigot1.18-PK1.9.3 + 2.9.7-Spigot1.18-PK1.9.3 jar JedCore diff --git a/src/com/jedk1/jedcore/JCManager.java b/src/com/jedk1/jedcore/JCManager.java index d9c01a7..a842497 100644 --- a/src/com/jedk1/jedcore/JCManager.java +++ b/src/com/jedk1/jedcore/JCManager.java @@ -1,13 +1,12 @@ package com.jedk1.jedcore; -import com.jedk1.jedcore.ability.firebending.FirePunch; -import com.jedk1.jedcore.ability.firebending.LightningBurst; -import com.jedk1.jedcore.ability.waterbending.HealingWaters; -import com.jedk1.jedcore.ability.waterbending.IcePassive; -import com.jedk1.jedcore.util.RegenTempBlock; -import com.jedk1.jedcore.util.TempFallingBlock; + import org.bukkit.Bukkit; -import org.bukkit.Bukkit; + import com.jedk1.jedcore.ability.firebending.LightningBurst; + import com.jedk1.jedcore.ability.waterbending.HealingWaters; + import com.jedk1.jedcore.ability.waterbending.IcePassive; + import com.jedk1.jedcore.util.RegenTempBlock; + import com.jedk1.jedcore.util.TempFallingBlock; public class JCManager implements Runnable { @@ -18,12 +17,11 @@ public JCManager(JedCore plugin) { } public void run() { - FirePunch.display(Bukkit.getServer()); LightningBurst.progressAll(); HealingWaters.heal(Bukkit.getServer()); IcePassive.handleSkating(); - //IceWall.progressAll(); +// IceWall.progressAll(); RegenTempBlock.manage(); TempFallingBlock.manage(); diff --git a/src/com/jedk1/jedcore/JCMethods.java b/src/com/jedk1/jedcore/JCMethods.java index 5caf29c..2f3f06e 100644 --- a/src/com/jedk1/jedcore/JCMethods.java +++ b/src/com/jedk1/jedcore/JCMethods.java @@ -71,8 +71,8 @@ public static void registerCombos() { /** * Gets the points of a line between two points. - * @param start - * @param end + * @param startLoc + * @param endLoc * @param points * @return locations */ @@ -123,7 +123,7 @@ public static List getCirclePoints(Location location, int points, doub * @return */ public static List getVerticalCirclePoints(Location location, int points, double size, float yawOffset) { - List locations = new ArrayList(); + List locations = new ArrayList<>(); Location fakeLoc = location.clone(); fakeLoc.setPitch(0); fakeLoc.setYaw(yawOffset); diff --git a/src/com/jedk1/jedcore/ability/airbending/AirBlade.java b/src/com/jedk1/jedcore/ability/airbending/AirBlade.java index 8f09f10..0fac15c 100644 --- a/src/com/jedk1/jedcore/ability/airbending/AirBlade.java +++ b/src/com/jedk1/jedcore/ability/airbending/AirBlade.java @@ -45,8 +45,10 @@ public AirBlade(Player player) { this.location = player.getEyeLocation().clone(); this.direction = player.getEyeLocation().getDirection().clone(); - bPlayer.addCooldown(this); + start(); + if (!isRemoved()) + bPlayer.addCooldown(this); } public void setFields() { @@ -200,16 +202,60 @@ public String getDescription() { ConfigurationSection config = JedCoreConfig.getConfig(this.player); return "* JedCore Addon *\n" + config.getString("Abilities.Air.AirBlade.Description"); } - - @Override - public void load() { + public Vector getDirection() { + return direction; } - @Override - public void stop() { + public void setDirection(Vector direction) { + this.direction = direction; + } + + public double getTravelled() { + return travelled; + } + public void setTravelled(double travelled) { + this.travelled = travelled; } + + public double getGrowth() { + return growth; + } + + public void setGrowth(double growth) { + this.growth = growth; + } + + public double getRange() { + return range; + } + + public void setRange(double range) { + this.range = range; + } + + public double getDamage() { + return damage; + } + + public void setDamage(double damage) { + this.damage = damage; + } + + public double getEntityCollisionRadius() { + return entityCollisionRadius; + } + + public void setEntityCollisionRadius(double entityCollisionRadius) { + this.entityCollisionRadius = entityCollisionRadius; + } + + @Override + public void load() {} + + @Override + public void stop() {} @Override public boolean isEnabled() { diff --git a/src/com/jedk1/jedcore/ability/airbending/AirBreath.java b/src/com/jedk1/jedcore/ability/airbending/AirBreath.java index 8689cc6..3b959b8 100644 --- a/src/com/jedk1/jedcore/ability/airbending/AirBreath.java +++ b/src/com/jedk1/jedcore/ability/airbending/AirBreath.java @@ -24,7 +24,6 @@ public class AirBreath extends AirAbility implements AddonAbility { - private long time; private boolean isAvatar; @Attribute(Attribute.COOLDOWN) @@ -63,7 +62,6 @@ public AirBreath(Player player) { } setFields(); - time = System.currentTimeMillis(); isAvatar = bPlayer.isAvatarState(); if (isAvatar && avatarAmplify) { range = avatarRange; @@ -109,15 +107,13 @@ public void progress() { remove(); return; } - if (System.currentTimeMillis() < time + duration) { + if (System.currentTimeMillis() < getStartTime() + duration) { playAirbendingSound(player.getLocation()); createBeam(); } else { bPlayer.addCooldown(this); remove(); - return; } - return; } private boolean isLocationSafe(Location loc) { @@ -125,10 +121,7 @@ private boolean isLocationSafe(Location loc) { if (GeneralMethods.isRegionProtectedFromBuild(player, "AirBreath", loc)) { return false; } - if (!isTransparent(block)) { - return false; - } - return true; + return isTransparent(block); } private void createBeam() { @@ -146,7 +139,7 @@ private void createBeam() { if (!isLocationSafe(loc)) { if (!isTransparent(loc.getBlock())) { if (player.getLocation().getPitch() > 30) { - player.setVelocity(player.getLocation().getDirection().multiply(-launch)); + GeneralMethods.setVelocity(this, player, player.getLocation().getDirection().multiply(-launch)); } } return; @@ -154,7 +147,7 @@ private void createBeam() { for (Entity entity : GeneralMethods.getEntitiesAroundPoint(loc, damageregion)) { if (entity.getEntityId() != player.getEntityId() && !(entity instanceof ArmorStand)) { - if (GeneralMethods.isRegionProtectedFromBuild(this, entity.getLocation()) || ((entity instanceof Player) && Commands.invincible.contains(((Player) entity).getName()))){ + if (GeneralMethods.isRegionProtectedFromBuild(this, entity.getLocation()) || ((entity instanceof Player) && Commands.invincible.contains(entity.getName()))){ continue; } if (entity instanceof LivingEntity) { @@ -175,7 +168,7 @@ private void createBeam() { } dir.multiply(knockback); - entity.setVelocity(dir); + GeneralMethods.setVelocity(this, entity, dir); } } @@ -206,7 +199,7 @@ public long getCooldown() { @Override public Location getLocation() { - return null; + return player.getEyeLocation(); } @Override @@ -240,15 +233,131 @@ public String getDescription() { return "* JedCore Addon *\n" + config.getString("Abilities.Air.AirBreath.Description"); } - @Override - public void load() { - return; + public long getDuration() { + return duration; } - @Override - public void stop() { - return; + public void setDuration(long duration) { + this.duration = duration; + } + + public int getParticles() { + return particles; + } + + public void setParticles(int particles) { + this.particles = particles; + } + + public boolean isCoolLava() { + return coolLava; + } + + public void setCoolLava(boolean coolLava) { + this.coolLava = coolLava; + } + + public boolean canExtinguishFire() { + return extinguishFire; + } + + public void setExtinguishFire(boolean extinguishFire) { + this.extinguishFire = extinguishFire; + } + + public boolean canExtinguishMobs() { + return extinguishMobs; + } + + public void setExtinguishMobs(boolean extinguishMobs) { + this.extinguishMobs = extinguishMobs; + } + + public boolean isDamageEnabled() { + return damageEnabled; + } + + public void setDamageEnabled(boolean damageEnabled) { + this.damageEnabled = damageEnabled; + } + + public double getPlayerDamage() { + return playerDamage; + } + + public void setPlayerDamage(double playerDamage) { + this.playerDamage = playerDamage; + } + + public double getMobDamage() { + return mobDamage; + } + + public void setMobDamage(double mobDamage) { + this.mobDamage = mobDamage; + } + + public double getKnockback() { + return knockback; + } + + public void setKnockback(double knockback) { + this.knockback = knockback; + } + + public int getRange() { + return range; + } + + public void setRange(int range) { + this.range = range; + } + + public double getLaunch() { + return launch; + } + + public void setLaunch(double launch) { + this.launch = launch; + } + + public boolean canRegenOxygen() { + return regenOxygen; + } + + public void setRegenOxygen(boolean regenOxygen) { + this.regenOxygen = regenOxygen; } + + public boolean isAvatarAmplify() { + return avatarAmplify; + } + + public void setAvatarAmplify(boolean avatarAmplify) { + this.avatarAmplify = avatarAmplify; + } + + public int getAvatarRange() { + return avatarRange; + } + + public void setAvatarRange(int avatarRange) { + this.avatarRange = avatarRange; + } + + public double getAvatarKnockback() { + return avatarKnockback; + } + + public void setAvatarKnockback(double avatarKnockback) { + this.avatarKnockback = avatarKnockback; + } + + @Override + public void load() {} + + @Override + public void stop() {} @Override public boolean isEnabled() { diff --git a/src/com/jedk1/jedcore/ability/airbending/AirGlide.java b/src/com/jedk1/jedcore/ability/airbending/AirGlide.java index 4534eed..054af57 100644 --- a/src/com/jedk1/jedcore/ability/airbending/AirGlide.java +++ b/src/com/jedk1/jedcore/ability/airbending/AirGlide.java @@ -3,6 +3,7 @@ import com.jedk1.jedcore.JedCore; import com.jedk1.jedcore.collision.CollisionDetector; import com.jedk1.jedcore.configuration.JedCoreConfig; +import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ability.AddonAbility; import com.projectkorra.projectkorra.ability.AirAbility; import com.projectkorra.projectkorra.airbending.AirSpout; @@ -117,7 +118,7 @@ private void update(long time) { Vector shootFromPlayer = new Vector(directionVector.getX() * distanceFromPlayer, -fallSpeed, directionVector.getZ() * distanceFromPlayer); firstLocation.add(shootFromPlayer.getX(), shootFromPlayer.getY(), shootFromPlayer.getZ()); - player.setVelocity(shootFromPlayer); + GeneralMethods.setVelocity(this, player, shootFromPlayer); playAirbendingParticles(player.getLocation(), particles); } else if (!isTransparent(player.getLocation().getBlock().getRelative(BlockFace.DOWN))) { remove(); @@ -135,10 +136,7 @@ public void remove() { } private boolean hasAirGlide() { - if (bPlayer.getAbilities().containsValue("AirGlide")) { - return true; - } - return false; + return bPlayer.getAbilities().containsValue("AirGlide"); } @Override @@ -148,7 +146,7 @@ public long getCooldown() { @Override public Location getLocation() { - return null; + return player.getLocation(); } @Override @@ -182,15 +180,75 @@ public String getDescription() { return "* JedCore Addon *\n" + config.getString("Abilities.Air.AirGlide.Description"); } - @Override - public void load() { - return; + public boolean isRequireGround() { + return requireGround; } - @Override - public void stop() { - return; + public void setRequireGround(boolean requireGround) { + this.requireGround = requireGround; + } + + public double getSpeed() { + return speed; + } + + public void setSpeed(double speed) { + this.speed = speed; + } + + public double getFallSpeed() { + return fallSpeed; } + + public void setFallSpeed(double fallSpeed) { + this.fallSpeed = fallSpeed; + } + + public int getParticles() { + return particles; + } + + public void setParticles(int particles) { + this.particles = particles; + } + + public boolean allowsAirSpout() { + return airspout; + } + + public void setAllowAirSpout(boolean airspout) { + this.airspout = airspout; + } + + public long getDuration() { + return duration; + } + + public void setDuration(long duration) { + this.duration = duration; + } + + public long getLastCooldown() { + return lastCooldown; + } + + public void setLastCooldown(long lastCooldown) { + this.lastCooldown = lastCooldown; + } + + public boolean isProgressing() { + return progressing; + } + + public void setProgressing(boolean progressing) { + this.progressing = progressing; + } + + @Override + public void load() {} + + @Override + public void stop() {} @Override public boolean isEnabled() { diff --git a/src/com/jedk1/jedcore/ability/airbending/AirPunch.java b/src/com/jedk1/jedcore/ability/airbending/AirPunch.java index 86e6240..f821eda 100644 --- a/src/com/jedk1/jedcore/ability/airbending/AirPunch.java +++ b/src/com/jedk1/jedcore/ability/airbending/AirPunch.java @@ -22,7 +22,7 @@ public class AirPunch extends AirAbility implements AddonAbility { - private Map locations = new ConcurrentHashMap<>(); + private final Map locations = new ConcurrentHashMap<>(); @Attribute(Attribute.COOLDOWN) private long cooldown; @@ -53,7 +53,8 @@ public AirPunch(Player player) { setFields(); start(); - createShot(); + if (!isRemoved()) + createShot(); } public void setFields() { @@ -200,15 +201,59 @@ public String getDescription() { return "* JedCore Addon *\n" + config.getString("Abilities.Air.AirPunch.Description"); } - @Override - public void load() { + public long getThreshold() { + return threshold; + } + public void setThreshold(long threshold) { + this.threshold = threshold; } - @Override - public void stop() { + public double getRange() { + return range; + } + + public void setRange(double range) { + this.range = range; + } + + public double getDamage() { + return damage; + } + + public void setDamage(double damage) { + this.damage = damage; + } + + public double getEntityCollisionRadius() { + return entityCollisionRadius; + } + public void setEntityCollisionRadius(double entityCollisionRadius) { + this.entityCollisionRadius = entityCollisionRadius; } + + public int getShots() { + return shots; + } + + public void setShots(int shots) { + this.shots = shots; + } + + public long getLastShotTime() { + return lastShotTime; + } + + public void setLastShotTime(long lastShotTime) { + this.lastShotTime = lastShotTime; + } + + @Override + public void load() {} + + @Override + public void stop() {} @Override public boolean isEnabled() { diff --git a/src/com/jedk1/jedcore/ability/airbending/Meditate.java b/src/com/jedk1/jedcore/ability/airbending/Meditate.java index 60debd8..da270f2 100644 --- a/src/com/jedk1/jedcore/ability/airbending/Meditate.java +++ b/src/com/jedk1/jedcore/ability/airbending/Meditate.java @@ -16,7 +16,6 @@ public class Meditate extends AirAbility implements AddonAbility { - private long time; private double startHealth; private String unfocusMsg; @@ -53,8 +52,7 @@ public void setFields() { absorptionBoost = config.getInt("Abilities.Air.Meditate.AbsorptionBoost"); speedBoost = config.getInt("Abilities.Air.Meditate.SpeedBoost"); jumpBoost = config.getInt("Abilities.Air.Meditate.JumpBoost"); - - time = System.currentTimeMillis(); + startHealth = player.getHealth(); } @@ -70,50 +68,40 @@ public void progress() { } if (player.getHealth() < startHealth) { if (lossFocusMessage) { - player.sendMessage(new StringBuilder().append(Element.AIR.getColor()).append(unfocusMsg).toString()); + player.sendMessage(Element.AIR.getColor() + unfocusMsg); } remove(); return; } - if (System.currentTimeMillis() > time + warmup) { + if (System.currentTimeMillis() > getStartTime() + warmup) { ParticleEffect.SPELL_INSTANT.display(player.getLocation(), particleDensity, Math.random(), Math.random(), Math.random(), 0.0); if (!player.isSneaking()) { bPlayer.addCooldown(this); givePlayerBuffs(); remove(); - return; } - return; } else if (player.isSneaking()) { ParticleEffect.SPELL_MOB_AMBIENT.display(player.getLocation(), particleDensity, Math.random(), Math.random(), Math.random(), 0.0); } else { remove(); - return; } - return; } private void givePlayerBuffs() { if (player.hasPotionEffect(PotionEffectType.SPEED)) { player.removePotionEffect(PotionEffectType.SPEED); - player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, boostDuration/50, speedBoost - 1)); - } else { - player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, boostDuration/50, speedBoost - 1)); } + player.addPotionEffect(new PotionEffect(PotionEffectType.SPEED, boostDuration/50, speedBoost - 1)); if (player.hasPotionEffect(PotionEffectType.JUMP)) { player.removePotionEffect(PotionEffectType.JUMP); - player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, boostDuration/50, jumpBoost - 1)); - } else { - player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, boostDuration/50, jumpBoost - 1)); } + player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, boostDuration/50, jumpBoost - 1)); if (player.hasPotionEffect(PotionEffectType.ABSORPTION)) { player.removePotionEffect(PotionEffectType.ABSORPTION); - player.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION, boostDuration/50, absorptionBoost - 1)); - } else { - player.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION, boostDuration/50, absorptionBoost - 1)); } + player.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION, boostDuration/50, absorptionBoost - 1)); } @Override @@ -123,7 +111,7 @@ public long getCooldown() { @Override public Location getLocation() { - return null; + return player.getLocation(); } @Override @@ -157,15 +145,83 @@ public String getDescription() { return "* JedCore Addon *\n" + config.getString("Abilities.Air.Meditate.Description"); } - @Override - public void load() { - return; + public double getStartHealth() { + return startHealth; } - @Override - public void stop() { - return; + public void setStartHealth(double startHealth) { + this.startHealth = startHealth; + } + + public String getUnfocusMsg() { + return unfocusMsg; + } + + public void setUnfocusMsg(String unfocusMsg) { + this.unfocusMsg = unfocusMsg; + } + + public boolean hasUnfocusMessage() { + return lossFocusMessage; + } + + public void setHasUnfocusMessage(boolean hasUnfocusMessage) { + this.lossFocusMessage = hasUnfocusMessage; + } + + public long getWarmup() { + return warmup; + } + + public void setWarmup(long warmup) { + this.warmup = warmup; + } + + public int getBoostDuration() { + return boostDuration; } + + public void setBoostDuration(int boostDuration) { + this.boostDuration = boostDuration; + } + + public int getParticleDensity() { + return particleDensity; + } + + public void setParticleDensity(int particleDensity) { + this.particleDensity = particleDensity; + } + + public int getAbsorptionBoost() { + return absorptionBoost; + } + + public void setAbsorptionBoost(int absorptionBoost) { + this.absorptionBoost = absorptionBoost; + } + + public int getSpeedBoost() { + return speedBoost; + } + + public void setSpeedBoost(int speedBoost) { + this.speedBoost = speedBoost; + } + + public int getJumpBoost() { + return jumpBoost; + } + + public void setJumpBoost(int jumpBoost) { + this.jumpBoost = jumpBoost; + } + + @Override + public void load() {} + + @Override + public void stop() {} @Override public boolean isEnabled() { diff --git a/src/com/jedk1/jedcore/ability/airbending/SonicBlast.java b/src/com/jedk1/jedcore/ability/airbending/SonicBlast.java index da6e06f..3d5970f 100644 --- a/src/com/jedk1/jedcore/ability/airbending/SonicBlast.java +++ b/src/com/jedk1/jedcore/ability/airbending/SonicBlast.java @@ -22,7 +22,6 @@ public class SonicBlast extends AirAbility implements AddonAbility { - private long time; private Location location; private Vector direction; private boolean isCharged; @@ -64,7 +63,6 @@ public void setFields() { chargeSwapping = config.getBoolean("Abilities.Air.SonicBlast.ChargeSwapping"); nauseaDur = config.getInt("Abilities.Air.SonicBlast.Effects.NauseaDuration"); blindDur = config.getInt("Abilities.Air.SonicBlast.Effects.BlindnessDuration"); - time = System.currentTimeMillis(); } @Override @@ -86,7 +84,7 @@ public void progress() { if (isCharged) { playAirbendingParticles(player.getLocation().add(0, 1, 0), 5, (float) Math.random(), (float) Math.random(), (float) Math.random()); - } else if (System.currentTimeMillis() > time + warmup) { + } else if (System.currentTimeMillis() > getStartTime() + warmup) { isCharged = true; } } else { @@ -198,14 +196,10 @@ public String getDescription() { } @Override - public void load() { - - } + public void load() {} @Override - public void stop() { - - } + public void stop() {} @Override public boolean isEnabled() { diff --git a/src/com/jedk1/jedcore/ability/airbending/combo/AirSlam.java b/src/com/jedk1/jedcore/ability/airbending/combo/AirSlam.java index f9359b0..bd2b56f 100644 --- a/src/com/jedk1/jedcore/ability/airbending/combo/AirSlam.java +++ b/src/com/jedk1/jedcore/ability/airbending/combo/AirSlam.java @@ -32,7 +32,6 @@ public class AirSlam extends AirAbility implements AddonAbility, ComboAbility { private int range; private LivingEntity target; - private long time; public AirSlam(Player player) { super(player); @@ -42,19 +41,19 @@ public AirSlam(Player player) { } setFields(); - Entity target = GeneralMethods.getTargetedEntity(player, range, new ArrayList()); - if (target != null && target instanceof LivingEntity) { - if (GeneralMethods.isRegionProtectedFromBuild(this, target.getLocation()) || ((target instanceof Player) && Commands.invincible.contains(((Player) target).getName()))) { - return; - } - this.target = (LivingEntity) target; - target.setVelocity(new Vector(0, 2, 0)); - } else { + + Entity target = GeneralMethods.getTargetedEntity(player, range, new ArrayList<>()); + if (!(target instanceof LivingEntity) + || GeneralMethods.isRegionProtectedFromBuild(this, target.getLocation()) + || ((target instanceof Player) && Commands.invincible.contains(target.getName()))) return; - } - time = System.currentTimeMillis(); - bPlayer.addCooldown(this); + this.target = (LivingEntity) target; + start(); + if (!isRemoved()) { + bPlayer.addCooldown(this); + GeneralMethods.setVelocity(this, target, new Vector(0, 2, 0)); + } } public void setFields() { @@ -71,14 +70,14 @@ public void progress() { remove(); return; } - if (System.currentTimeMillis() > time + 50) { + if (System.currentTimeMillis() > getStartTime() + 50) { Vector dir = player.getLocation().getDirection(); - GeneralMethods.setVelocity(target, new Vector(dir.getX(), 0.05, dir.getZ()).multiply(power)); + GeneralMethods.setVelocity(this, target, new Vector(dir.getX(), 0.05, dir.getZ()).multiply(power)); new HorizontalVelocityTracker(target, player, 0L, this); new ThrownEntityTracker(this, target, player, 0L); target.setFallDistance(0); } - if (System.currentTimeMillis() > time + 400) { + if (System.currentTimeMillis() > getStartTime() + 400) { remove(); return; } @@ -92,7 +91,7 @@ public long getCooldown() { @Override public Location getLocation() { - return null; + return target != null ? target.getLocation() : null; } @Override @@ -150,13 +149,35 @@ public String getVersion() { return JedCore.version; } - @Override - public void load() { + public double getPower() { + return power; } - @Override - public void stop() { + public void setPower(double power) { + this.power = power; + } + + public int getRange() { + return range; + } + + public void setRange(int range) { + this.range = range; + } + + public LivingEntity getTarget() { + return target; + } + + public void setTarget(LivingEntity target) { + this.target = target; } + + @Override + public void load() {} + + @Override + public void stop() {} @Override public boolean isEnabled() { diff --git a/src/com/jedk1/jedcore/ability/airbending/combo/SwiftStream.java b/src/com/jedk1/jedcore/ability/airbending/combo/SwiftStream.java index 0a56db7..154fd23 100644 --- a/src/com/jedk1/jedcore/ability/airbending/combo/SwiftStream.java +++ b/src/com/jedk1/jedcore/ability/airbending/combo/SwiftStream.java @@ -29,9 +29,7 @@ public class SwiftStream extends FlightAbility implements AddonAbility, ComboAbi @Attribute(Attribute.DURATION) public long duration; - private List affectedEntities = new ArrayList(); - - private long startTime; + private final List affectedEntities = new ArrayList<>(); public SwiftStream(Player player) { super(player); @@ -40,10 +38,11 @@ public SwiftStream(Player player) { } setFields(); - startTime = System.currentTimeMillis(); - launch(); start(); - bPlayer.addCooldown(this); + if (!isRemoved()) { + launch(); + bPlayer.addCooldown(this); + } } public void setFields() { @@ -60,7 +59,7 @@ public void launch() { v = v.multiply(5); v.add(new Vector(0, 0.2, 0)); - GeneralMethods.setVelocity(player, v); + GeneralMethods.setVelocity(this, player, v); } public void affectNearby() { @@ -74,7 +73,7 @@ public void affectNearby() { v = v.add(new Vector(0, 0.15, 0)); - GeneralMethods.setVelocity(e, v); + GeneralMethods.setVelocity(this, e, v); affectedEntities.add((LivingEntity) e); new HorizontalVelocityTracker(e, player, 200, this); } @@ -93,7 +92,7 @@ public void progress() { return; } - if (System.currentTimeMillis() > startTime + duration) { + if (System.currentTimeMillis() > getStartTime() + duration) { remove(); return; } @@ -109,7 +108,7 @@ public long getCooldown() { @Override public Location getLocation() { - return null; + return player.getLocation(); } @Override @@ -167,13 +166,31 @@ public String getVersion() { return JedCore.version; } - @Override - public void load() { + public double getDragFactor() { + return dragFactor; } - @Override - public void stop() { + public void setDragFactor(double dragFactor) { + this.dragFactor = dragFactor; + } + + public long getDuration() { + return duration; + } + + public void setDuration(long duration) { + this.duration = duration; + } + + public List getAffectedEntities() { + return affectedEntities; } + + @Override + public void load() {} + + @Override + public void stop() {} @Override public boolean isEnabled() { diff --git a/src/com/jedk1/jedcore/ability/avatar/SpiritBeam.java b/src/com/jedk1/jedcore/ability/avatar/SpiritBeam.java index 1b8ceb9..8877983 100644 --- a/src/com/jedk1/jedcore/ability/avatar/SpiritBeam.java +++ b/src/com/jedk1/jedcore/ability/avatar/SpiritBeam.java @@ -30,14 +30,13 @@ public class SpiritBeam extends AvatarAbility implements AddonAbility { private long cooldown; @Attribute(Attribute.RANGE) private double range; - private boolean avataronly; + private boolean avatarOnly; @Attribute(Attribute.DAMAGE) private double damage; - private boolean blockdamage; + private boolean damagesBlocks; private long regen; @Attribute(Attribute.RADIUS) private double radius; - private long time; public SpiritBeam(Player player) { super(player); @@ -47,11 +46,10 @@ public SpiritBeam(Player player) { setFields(); - if (avataronly && !bPlayer.isAvatarState()) { + if (avatarOnly && !bPlayer.isAvatarState()) { return; } - time = System.currentTimeMillis(); start(); } @@ -62,8 +60,8 @@ public void setFields() { cooldown = config.getInt("Abilities.Avatar.SpiritBeam.Cooldown"); damage = config.getDouble("Abilities.Avatar.SpiritBeam.Damage"); range = config.getInt("Abilities.Avatar.SpiritBeam.Range"); - avataronly = config.getBoolean("Abilities.Avatar.SpiritBeam.AvatarStateOnly"); - blockdamage = config.getBoolean("Abilities.Avatar.SpiritBeam.BlockDamage.Enabled"); + avatarOnly = config.getBoolean("Abilities.Avatar.SpiritBeam.AvatarStateOnly"); + damagesBlocks = config.getBoolean("Abilities.Avatar.SpiritBeam.BlockDamage.Enabled"); regen = config.getLong("Abilities.Avatar.SpiritBeam.BlockDamage.Regen"); radius = config.getDouble("Abilities.Avatar.SpiritBeam.BlockDamage.Radius"); } @@ -79,7 +77,7 @@ public void progress() { remove(); return; } - if (System.currentTimeMillis() > time + duration) { + if (System.currentTimeMillis() > getStartTime() + duration) { bPlayer.addCooldown(this); remove(); return; @@ -89,7 +87,7 @@ public void progress() { remove(); return; } - if (avataronly && !bPlayer.isAvatarState()) { + if (avatarOnly && !bPlayer.isAvatarState()) { bPlayer.addCooldown(this); remove(); return; @@ -121,7 +119,7 @@ private void createBeam() { if (location.getBlock().getType().isSolid()) { location.getWorld().createExplosion(location, 0F); - if (blockdamage) { + if (damagesBlocks) { //new TempExplosion(player, location.getBlock(), "SpiritBeam", radius, regen, damage, false); for (Location loc : GeneralMethods.getCircle(location, (int) radius, 0, false, true, 0)) { if (JCMethods.isUnbreakable(loc.getBlock())) continue; @@ -174,16 +172,76 @@ public String getDescription() { return "* JedCore Addon *\n" + config.getString("Abilities.Avatar.SpiritBeam.Description"); } - @Override - public void load() { - return; + public Vector getDirection() { + return direction; } - @Override - public void stop() { - return; + public void setDirection(Vector direction) { + this.direction = direction; + } + + public long getDuration() { + return duration; + } + + public void setDuration(long duration) { + this.duration = duration; + } + + public double getRange() { + return range; + } + + public void setRange(double range) { + this.range = range; + } + + public boolean isAvatarOnly() { + return avatarOnly; + } + + public void setAvatarOnly(boolean avatarOnly) { + this.avatarOnly = avatarOnly; + } + + public double getDamage() { + return damage; + } + + public void setDamage(double damage) { + this.damage = damage; + } + + public boolean damagesBlocks() { + return damagesBlocks; + } + + public void setDamagesBlocks(boolean blockdamage) { + this.damagesBlocks = blockdamage; + } + + public long getRegen() { + return regen; + } + + public void setRegen(long regen) { + this.regen = regen; } + public double getRadius() { + return radius; + } + + public void setRadius(double radius) { + this.radius = radius; + } + + @Override + public void load() {} + + @Override + public void stop() {} + @Override public boolean isEnabled() { ConfigurationSection config = JedCoreConfig.getConfig(this.player); diff --git a/src/com/jedk1/jedcore/ability/avatar/elementsphere/ESAir.java b/src/com/jedk1/jedcore/ability/avatar/elementsphere/ESAir.java index 709c0b8..7d68496 100644 --- a/src/com/jedk1/jedcore/ability/avatar/elementsphere/ESAir.java +++ b/src/com/jedk1/jedcore/ability/avatar/elementsphere/ESAir.java @@ -46,13 +46,15 @@ public ESAir(Player player) { return; } setFields(); - if(GeneralMethods.isRegionProtectedFromBuild(this, player.getTargetBlock(getTransparentMaterialSet(), (int)range).getLocation())){ + if (GeneralMethods.isRegionProtectedFromBuild(this, player.getTargetBlock(getTransparentMaterialSet(), (int) range).getLocation())) { return; } - bPlayer.addCooldown("ESAir", getCooldown()); - currES.setAirUses(currES.getAirUses() - 1); location = player.getEyeLocation().clone().add(player.getEyeLocation().getDirection().multiply(1)); start(); + if (!isRemoved()) { + bPlayer.addCooldown("ESAir", getCooldown()); + currES.setAirUses(currES.getAirUses() - 1); + } } public void setFields() { @@ -84,7 +86,7 @@ private void advanceAttack() { if (travelled >= range) return; location = location.add(location.getDirection().clone().multiply(1)); - if(GeneralMethods.isRegionProtectedFromBuild(this, location)){ + if (GeneralMethods.isRegionProtectedFromBuild(this, location)) { travelled = range; return; } @@ -99,7 +101,7 @@ private void advanceAttack() { for (Entity entity : GeneralMethods.getEntitiesAroundPoint(location, 2.5)) { if (entity instanceof LivingEntity && entity.getEntityId() != player.getEntityId() && !(entity instanceof ArmorStand) && !GeneralMethods.isRegionProtectedFromBuild(this, entity.getLocation()) && !((entity instanceof Player) && Commands.invincible.contains(((Player) entity).getName()))) { DamageHandler.damageEntity(entity, damage, this); - entity.setVelocity(location.getDirection().multiply(knockback)); + GeneralMethods.setVelocity(this, entity, location.getDirection().multiply(knockback)); travelled = range; } } @@ -151,15 +153,51 @@ public String getDescription() { return null; } - @Override - public void load() { - return; + public double getDistanceTravelled() { + return travelled; } - @Override - public void stop() { - return; + public void setDistanceTravelled(double travelled) { + this.travelled = travelled; + } + + public double getRange() { + return range; + } + + public void setRange(double range) { + this.range = range; + } + + public double getDamage() { + return damage; } + + public void setDamage(double damage) { + this.damage = damage; + } + + public double getKnockback() { + return knockback; + } + + public void setKnockback(double knockback) { + this.knockback = knockback; + } + + public int getSpeed() { + return speed; + } + + public void setSpeed(int speed) { + this.speed = speed; + } + + @Override + public void load() {} + + @Override + public void stop() {} @Override public boolean isEnabled() { diff --git a/src/com/jedk1/jedcore/ability/avatar/elementsphere/ESEarth.java b/src/com/jedk1/jedcore/ability/avatar/elementsphere/ESEarth.java index 1cd6314..3a35a18 100644 --- a/src/com/jedk1/jedcore/ability/avatar/elementsphere/ESEarth.java +++ b/src/com/jedk1/jedcore/ability/avatar/elementsphere/ESEarth.java @@ -54,15 +54,17 @@ public ESEarth(Player player) { if (bPlayer.isOnCooldown("ESEarth")) { return; } - setFields(); - if(GeneralMethods.isRegionProtectedFromBuild(this, player.getTargetBlock(getTransparentMaterialSet(), 40).getLocation())){ + if (GeneralMethods.isRegionProtectedFromBuild(this, player.getTargetBlock(getTransparentMaterialSet(), 40).getLocation())) { return; } - bPlayer.addCooldown("ESEarth", getCooldown()); - currES.setEarthUses(currES.getEarthUses() - 1); - Location location = player.getEyeLocation().clone().add(player.getEyeLocation().getDirection().multiply(1)); - tfb = new TempFallingBlock(location, Material.DIRT.createBlockData(), location.getDirection().multiply(3), this); + setFields(); start(); + if (!isRemoved()) { + bPlayer.addCooldown("ESEarth", getCooldown()); + currES.setEarthUses(currES.getEarthUses() - 1); + Location location = player.getEyeLocation().clone().add(player.getEyeLocation().getDirection().multiply(1)); + tfb = new TempFallingBlock(location, Material.DIRT.createBlockData(), location.getDirection().multiply(3), this); + } } public void setFields() { @@ -84,7 +86,7 @@ public void progress() { remove(); return; } - if(GeneralMethods.isRegionProtectedFromBuild(this, tfb.getLocation())){ + if (GeneralMethods.isRegionProtectedFromBuild(this, tfb.getLocation())){ remove(); return; } @@ -112,13 +114,13 @@ public static void explodeEarth(TempFallingBlock tempfallingblock) { // TempBlock.revertBlock(l.getBlock(), Material.AIR); // TempBlock.removeBlock(l.getBlock()); //} - if (!isUnbreakable(l.getBlock()) && !GeneralMethods.isRegionProtectedFromBuild(player, "ElementSphere", l) && EarthAbility.isEarthbendable(player, l.getBlock())) { + if (isBreakable(l.getBlock()) && !GeneralMethods.isRegionProtectedFromBuild(player, "ElementSphere", l) && EarthAbility.isEarthbendable(player, l.getBlock())) { ParticleEffect.SMOKE_LARGE.display(l, 0, 0, 0, 0.1F, 2); //new RegenTempBlock(l.getBlock(), Material.AIR, (byte) 0, (long) rand.nextInt((int) es.revertDelay - (int) (es.revertDelay - 1000)) + (es.revertDelay - 1000)); new RegenTempBlock(l.getBlock(), Material.AIR, Material.AIR.createBlockData(), (long) rand.nextInt((int) es.revertDelay - (int) (es.revertDelay - 1000)) + (es.revertDelay - 1000), false); } - if (GeneralMethods.isSolid(l.getBlock().getRelative(BlockFace.DOWN)) && !isUnbreakable(l.getBlock()) && ElementalAbility.isAir(l.getBlock().getType()) && rand.nextInt(20) == 0 && EarthAbility.isEarthbendable(player, l.getBlock().getRelative(BlockFace.DOWN))) { + if (GeneralMethods.isSolid(l.getBlock().getRelative(BlockFace.DOWN)) && isBreakable(l.getBlock()) && ElementalAbility.isAir(l.getBlock().getType()) && rand.nextInt(20) == 0 && EarthAbility.isEarthbendable(player, l.getBlock().getRelative(BlockFace.DOWN))) { Material type = l.getBlock().getRelative(BlockFace.DOWN).getType(); new RegenTempBlock(l.getBlock(), type, type.createBlockData(), (long) rand.nextInt((int) es.revertDelay - (int) (es.revertDelay - 1000)) + (es.revertDelay - 1000)); } @@ -130,10 +132,8 @@ public static void explodeEarth(TempFallingBlock tempfallingblock) { static Material[] unbreakables = { Material.BEDROCK, Material.BARRIER, Material.NETHER_PORTAL, Material.END_PORTAL, Material.END_PORTAL_FRAME, Material.ENDER_CHEST, Material.CHEST, Material.TRAPPED_CHEST }; - public static boolean isUnbreakable(Block block) { - if (Arrays.asList(unbreakables).contains(block.getType())) - return true; - return false; + public static boolean isBreakable(Block block) { + return !Arrays.asList(unbreakables).contains(block.getType()); } @Override @@ -143,7 +143,7 @@ public long getCooldown() { @Override public Location getLocation() { - return null; + return tfb.getLocation(); } @Override @@ -181,16 +181,40 @@ public String getDescription() { return null; } - @Override - public void load() { - return; + public long getRevertDelay() { + return revertDelay; } - @Override - public void stop() { - return; + public void setRevertDelay(long revertDelay) { + this.revertDelay = revertDelay; + } + + public double getDamage() { + return damage; + } + + public void setDamage(double damage) { + this.damage = damage; } + public int getImpactSize() { + return impactSize; + } + + public void setImpactSize(int impactSize) { + this.impactSize = impactSize; + } + + public TempFallingBlock getTempFallingBlock() { + return tfb; + } + + @Override + public void load() {} + + @Override + public void stop() {} + @Override public boolean isEnabled() { ConfigurationSection config = JedCoreConfig.getConfig(this.player); diff --git a/src/com/jedk1/jedcore/ability/avatar/elementsphere/ESFire.java b/src/com/jedk1/jedcore/ability/avatar/elementsphere/ESFire.java index ee42af6..c3a1bc3 100644 --- a/src/com/jedk1/jedcore/ability/avatar/elementsphere/ESFire.java +++ b/src/com/jedk1/jedcore/ability/avatar/elementsphere/ESFire.java @@ -55,15 +55,17 @@ public ESFire(Player player) { if (bPlayer.isOnCooldown("ESFire")) { return; } - setFields(); - if(GeneralMethods.isRegionProtectedFromBuild(this, player.getTargetBlock(getTransparentMaterialSet(), (int)range).getLocation())){ + if (GeneralMethods.isRegionProtectedFromBuild(this, player.getTargetBlock(getTransparentMaterialSet(), (int) range).getLocation())) { return; } - bPlayer.addCooldown("ESFire", getCooldown()); - currES.setFireUses(currES.getFireUses() - 1); - location = player.getEyeLocation().clone().add(player.getEyeLocation().getDirection().multiply(1)); - direction = location.getDirection().clone(); + setFields(); start(); + if (!isRemoved()) { + bPlayer.addCooldown("ESFire", getCooldown()); + currES.setFireUses(currES.getFireUses() - 1); + location = player.getEyeLocation().clone().add(player.getEyeLocation().getDirection().multiply(1)); + direction = location.getDirection().clone(); + } } public void setFields() { @@ -110,7 +112,7 @@ private void advanceAttack() { direction = GeneralMethods.getDirection(player.getLocation(), GeneralMethods.getTargetedLocation(player, range, Material.WATER)).normalize(); location = location.add(direction.clone().multiply(1)); - if(GeneralMethods.isRegionProtectedFromBuild(this, location)){ + if (GeneralMethods.isRegionProtectedFromBuild(this, location)) { travelled = range; return; } @@ -129,7 +131,7 @@ private void advanceAttack() { for (Entity entity : GeneralMethods.getEntitiesAroundPoint(location, 2.5)) { if (entity instanceof LivingEntity && entity.getEntityId() != player.getEntityId() && !(entity instanceof ArmorStand) && !GeneralMethods.isRegionProtectedFromBuild(this, entity.getLocation()) && !((entity instanceof Player) && Commands.invincible.contains(((Player) entity).getName()))) { DamageHandler.damageEntity(entity, damage, this); - entity.setFireTicks((int) Math.round(burnTime / 50)); + entity.setFireTicks(Math.round(burnTime / 50F)); travelled = range; } } @@ -188,15 +190,67 @@ public String getDescription() { return null; } - @Override - public void load() { - return; + public Vector getDirection() { + return direction; } - @Override - public void stop() { - return; + public void setDirection(Vector direction) { + this.direction = direction; + } + + public double getDistanceTravelled() { + return travelled; + } + + public void setDistanceTravelled(double travelled) { + this.travelled = travelled; + } + + public double getRange() { + return range; + } + + public void setRange(double range) { + this.range = range; + } + + public double getDamage() { + return damage; + } + + public void setDamage(double damage) { + this.damage = damage; } + + public long getBurnTime() { + return burnTime; + } + + public void setBurnTime(long burnTime) { + this.burnTime = burnTime; + } + + public int getSpeed() { + return speed; + } + + public void setSpeed(int speed) { + this.speed = speed; + } + + public boolean isControllable() { + return controllable; + } + + public void setControllable(boolean controllable) { + this.controllable = controllable; + } + + @Override + public void load() {} + + @Override + public void stop() {} @Override public boolean isEnabled() { diff --git a/src/com/jedk1/jedcore/ability/avatar/elementsphere/ESStream.java b/src/com/jedk1/jedcore/ability/avatar/elementsphere/ESStream.java index 5f87a95..291c5e5 100644 --- a/src/com/jedk1/jedcore/ability/avatar/elementsphere/ESStream.java +++ b/src/com/jedk1/jedcore/ability/avatar/elementsphere/ESStream.java @@ -75,7 +75,7 @@ public ESStream(Player player) { return; } - if(GeneralMethods.isRegionProtectedFromBuild(this, player.getTargetBlock(getTransparentMaterialSet(), (int)range).getLocation())){ + if (GeneralMethods.isRegionProtectedFromBuild(this, player.getTargetBlock(getTransparentMaterialSet(), (int) range).getLocation())) { return; } @@ -88,14 +88,15 @@ public ESStream(Player player) { currES.setWaterUses(currES.getWaterUses()-requiredUses); } - bPlayer.addCooldown("ESStream", getCooldown()); - stream = player.getEyeLocation(); origin = player.getEyeLocation(); dir = player.getEyeLocation().getDirection(); an = 0; start(); + if (!isRemoved()) { + bPlayer.addCooldown("ESStream", getCooldown()); + } } public void setFields() { @@ -111,7 +112,6 @@ public void setFields() { regen = config.getLong("Abilities.Avatar.ElementSphere.Stream.ImpactRevert"); } - @SuppressWarnings("deprecation") @Override public void progress() { if (player == null || !player.isOnline()) { @@ -130,10 +130,10 @@ public void progress() { } for (Entity e : GeneralMethods.getEntitiesAroundPoint(stream, 1.5)) { - if (e instanceof Player && ((Player) e) == player) { + if (e instanceof Player && e == player) { continue; } - e.setVelocity(dir.normalize().multiply(knockback)); + GeneralMethods.setVelocity(this, e, dir.normalize().multiply(knockback)); if (e instanceof LivingEntity) { DamageHandler.damageEntity(e, damage, this); } @@ -141,13 +141,13 @@ public void progress() { if (!player.isDead() && hasAbility(player, ElementSphere.class)) { Location loc = stream.clone(); - dir = GeneralMethods.getDirection(loc, player.getTargetBlock((HashSet) null, (int) range).getLocation()).normalize().multiply(1.2); + dir = GeneralMethods.getDirection(loc, player.getTargetBlock(null, (int) range).getLocation()).normalize().multiply(1.2); } stream.add(dir); if (!isTransparent(stream.getBlock())) { - List blocks = new ArrayList(); + List blocks = new ArrayList<>(); for (Location loc : GeneralMethods.getCircle(stream, (int) radius, 0, false, true, 0)) { if (JCMethods.isUnbreakable(loc.getBlock())) continue; if (GeneralMethods.isRegionProtectedFromBuild(this, loc)) continue; @@ -155,13 +155,13 @@ public void progress() { new RegenTempBlock(loc.getBlock(), Material.AIR, Material.AIR.createBlockData(), regen, false); } for (Entity e : GeneralMethods.getEntitiesAroundPoint(stream, radius)) { - if (e instanceof Player && ((Player) e) == player) { + if (e instanceof Player && e == player) { continue; } if (GeneralMethods.isRegionProtectedFromBuild(this, e.getLocation()) || ((e instanceof Player) && Commands.invincible.contains(((Player) e).getName()))){ continue; } - e.setVelocity(dir.normalize().multiply(knockback)); + GeneralMethods.setVelocity(this, e, dir.normalize().multiply(knockback)); if (e instanceof LivingEntity) { DamageHandler.damageEntity(e, damage, this); } @@ -227,7 +227,6 @@ public void progress() { } } } - return; } @Override @@ -275,15 +274,83 @@ public String getDescription() { return null; } - @Override - public void load() { - return; + public double getKnockback() { + return knockback; } - @Override - public void stop() { - return; + public void setKnockback(double knockback) { + this.knockback = knockback; + } + + public double getRange() { + return range; + } + + public void setRange(double range) { + this.range = range; + } + + public double getDamage() { + return damage; + } + + public void setDamage(double damage) { + this.damage = damage; + } + + public boolean cancelsAbility() { + return cancelAbility; + } + + public void setCancelsAbility(boolean cancelAbility) { + this.cancelAbility = cancelAbility; + } + + public int getRequiredUses() { + return requiredUses; + } + + public void setRequiredUses(int requiredUses) { + this.requiredUses = requiredUses; } + + public double getRadius() { + return radius; + } + + public void setRadius(double radius) { + this.radius = radius; + } + + public long getRegenTime() { + return regen; + } + + public void setRegenTime(long regen) { + this.regen = regen; + } + + public Location getOrigin() { + return origin; + } + + public void setOrigin(Location origin) { + this.origin = origin; + } + + public Vector getDirection() { + return dir; + } + + public void setDirection(Vector dir) { + this.dir = dir; + } + + @Override + public void load() {} + + @Override + public void stop() {} @Override public boolean isEnabled() { diff --git a/src/com/jedk1/jedcore/ability/avatar/elementsphere/ESWater.java b/src/com/jedk1/jedcore/ability/avatar/elementsphere/ESWater.java index 2ab1769..34d24d4 100644 --- a/src/com/jedk1/jedcore/ability/avatar/elementsphere/ESWater.java +++ b/src/com/jedk1/jedcore/ability/avatar/elementsphere/ESWater.java @@ -48,14 +48,16 @@ public ESWater(Player player) { if (bPlayer.isOnCooldown("ESWater")) { return; } - setFields(); - if(GeneralMethods.isRegionProtectedFromBuild(this, player.getTargetBlock(getTransparentMaterialSet(), (int)range).getLocation())){ + if (GeneralMethods.isRegionProtectedFromBuild(this, player.getTargetBlock(getTransparentMaterialSet(), (int) range).getLocation())) { return; } - bPlayer.addCooldown("ESWater", getCooldown()); - currES.setWaterUses(currES.getWaterUses() - 1); + setFields(); location = player.getEyeLocation().clone().add(player.getEyeLocation().getDirection().multiply(1)); start(); + if (!isRemoved()) { + bPlayer.addCooldown("ESWater", getCooldown()); + currES.setWaterUses(currES.getWaterUses() - 1); + } } public void setFields() { @@ -99,7 +101,7 @@ private void advanceAttack() { } WaterAbility.playWaterbendingSound(location); - new RegenTempBlock(location.getBlock(), Material.WATER, Material.WATER.createBlockData(bd -> ((Levelled)bd).setLevel(0)), 100L); + new RegenTempBlock(location.getBlock(), Material.WATER, Material.WATER.createBlockData(bd -> ((Levelled) bd).setLevel(0)), 100L); for (Entity entity : GeneralMethods.getEntitiesAroundPoint(location, 2.5)) { if (entity instanceof LivingEntity && entity.getEntityId() != player.getEntityId() && !(entity instanceof ArmorStand) && !GeneralMethods.isRegionProtectedFromBuild(this, entity.getLocation()) && !((entity instanceof Player) && Commands.invincible.contains(((Player) entity).getName()))) { @@ -155,15 +157,51 @@ public String getDescription() { return null; } - @Override - public void load() { - return; + public Vector getDirection() { + return direction; } - @Override - public void stop() { - return; + public void setDirection(Vector direction) { + this.direction = direction; + } + + public double getDistanceTravelled() { + return travelled; + } + + public void setDistanceTravelled(double travelled) { + this.travelled = travelled; + } + + public double getRange() { + return range; + } + + public void setRange(double range) { + this.range = range; } + + public double getDamage() { + return damage; + } + + public void setDamage(double damage) { + this.damage = damage; + } + + public int getSpeed() { + return speed; + } + + public void setSpeed(int speed) { + this.speed = speed; + } + + @Override + public void load() {} + + @Override + public void stop() {} @Override public boolean isEnabled() { diff --git a/src/com/jedk1/jedcore/ability/avatar/elementsphere/ElementSphere.java b/src/com/jedk1/jedcore/ability/avatar/elementsphere/ElementSphere.java index 867969e..b87f31f 100644 --- a/src/com/jedk1/jedcore/ability/avatar/elementsphere/ElementSphere.java +++ b/src/com/jedk1/jedcore/ability/avatar/elementsphere/ElementSphere.java @@ -54,18 +54,7 @@ public class ElementSphere extends AvatarAbility implements AddonAbility, MultiA private Location location; private double yaw; private int point; - private long time; - - @Attribute("CooldownAir") - public long cooldownAir; - @Attribute("CooldownEarth") - public long cooldownEarth; - @Attribute("CooldownFire") - public long cooldownFire; - @Attribute("CooldownWater") - public long cooldownWater; - @Attribute("CooldownStream") - public long cooldownStream; + private long endTime; private long lastClickTime; @@ -122,14 +111,15 @@ public ElementSphere(Player player) { if (bPlayer.canBend(this)) { world = player.getWorld(); - time = System.currentTimeMillis() + duration; - MultiAbilityManager.bindMultiAbility(player, "ElementSphere"); - bPlayer.addCooldown(this); - flightHandler.createInstance(player, this.getName()); + endTime = System.currentTimeMillis() + duration; start(); - if (ChatColor.stripColor(bPlayer.getBoundAbilityName()) == null) { - remove(); - return; + if (!isRemoved()) { + MultiAbilityManager.bindMultiAbility(player, "ElementSphere"); + bPlayer.addCooldown(this); + flightHandler.createInstance(player, this.getName()); + if (ChatColor.stripColor(bPlayer.getBoundAbilityName()) == null) { + remove(); + } } } } @@ -165,7 +155,7 @@ public void progress() { remove(); return; } - if (System.currentTimeMillis() > time && duration > 0) { + if (System.currentTimeMillis() > endTime && duration > 0) { remove(); return; } @@ -282,20 +272,20 @@ private void playParticles() { point = 0; } - private Vector rotateAroundAxisX(Vector v, double angle) { + private void rotateAroundAxisX(Vector v, double angle) { double cos = Math.cos(angle); double sin = Math.sin(angle); double y = v.getY() * cos - v.getZ() * sin; double z = v.getY() * sin + v.getZ() * cos; - return v.setY(y).setZ(z); + v.setY(y).setZ(z); } - private Vector rotateAroundAxisY(Vector v, double angle) { + private void rotateAroundAxisY(Vector v, double angle) { double cos = Math.cos(angle); double sin = Math.sin(angle); double x = v.getX() * cos + v.getZ() * sin; double z = v.getX() * -sin + v.getZ() * cos; - return v.setX(x).setZ(z); + v.setX(x).setZ(z); } @Override diff --git a/src/com/jedk1/jedcore/ability/chiblocking/Backstab.java b/src/com/jedk1/jedcore/ability/chiblocking/Backstab.java index 8e39d5f..f6c87ec 100644 --- a/src/com/jedk1/jedcore/ability/chiblocking/Backstab.java +++ b/src/com/jedk1/jedcore/ability/chiblocking/Backstab.java @@ -21,6 +21,9 @@ public Backstab(Player player) { super(player); } + @Override + public void progress() {} + public static boolean punch(Player player, LivingEntity target) { BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); CoreAbility ability = CoreAbility.getAbility("Backstab"); @@ -98,23 +101,14 @@ public String getDescription() { } @Override - public void load() { - - } + public void load() {} @Override - public void stop() { - - } + public void stop() {} @Override public boolean isEnabled() { ConfigurationSection config = JedCoreConfig.getConfig(this.player); return config.getBoolean("Abilities.Chi.Backstab.Enabled"); } - - @Override - public void progress() { - - } } diff --git a/src/com/jedk1/jedcore/ability/chiblocking/DaggerThrow.java b/src/com/jedk1/jedcore/ability/chiblocking/DaggerThrow.java index 95e98f9..04fa3c4 100644 --- a/src/com/jedk1/jedcore/ability/chiblocking/DaggerThrow.java +++ b/src/com/jedk1/jedcore/ability/chiblocking/DaggerThrow.java @@ -28,12 +28,11 @@ import java.util.stream.Collectors; public class DaggerThrow extends ChiAbility implements AddonAbility { - private static List interactions = new ArrayList<>(); + private static final List INTERACTIONS = new ArrayList<>(); private static boolean particles; private static double damage; - private Location location; - private long time; + private long endTime; private int shots = 1; @Attribute(Attribute.COOLDOWN) private long cooldown; @@ -41,7 +40,7 @@ public class DaggerThrow extends ChiAbility implements AddonAbility { @Attribute("MaxShots") private int maxShots; private int hits = 0; - private List arrows = new ArrayList<>(); + private final List arrows = new ArrayList<>(); public DaggerThrow(Player player) { super(player); @@ -65,10 +64,11 @@ public DaggerThrow(Player player) { } setFields(); - - time = System.currentTimeMillis() + 500; + start(); - shootArrow(); + if (!isRemoved()) { + shootArrow(); + } } public void setFields() { @@ -84,14 +84,14 @@ public void setFields() { } private void loadInteractions() { - interactions.clear(); + INTERACTIONS.clear(); String path = "Abilities.Chi.DaggerThrow.Interactions"; ConfigurationSection config = JedCoreConfig.getConfig(this.player); ConfigurationSection section = config.getConfigurationSection(path); for (String abilityName : section.getKeys(false)) { - interactions.add(new AbilityInteraction(abilityName)); + INTERACTIONS.add(new AbilityInteraction(abilityName)); } } @@ -101,7 +101,7 @@ public void progress() { remove(); return; } - if (System.currentTimeMillis() > time) { + if (System.currentTimeMillis() > endTime) { bPlayer.addCooldown(this); remove(); return; @@ -115,7 +115,7 @@ public void progress() { private void shootArrow() { if (JCMethods.removeItemFromInventory(player, Material.ARROW, 1)) { shots++; - location = player.getEyeLocation(); + Location location = player.getEyeLocation(); Vector vector = location.toVector(). add(location.getDirection().multiply(2.5)). @@ -134,12 +134,12 @@ private void shootArrow() { } arrows.add(arrow); - time = System.currentTimeMillis() + 500; + endTime = System.currentTimeMillis() + 500; bPlayer.addCooldown("DaggerThrowShot", 100); } } - public static void damageEntityFromArrow(Player player, LivingEntity entity, Arrow arrow) { + public static void damageEntityFromArrow(LivingEntity entity, Arrow arrow) { if (GeneralMethods.isRegionProtectedFromBuild((Player) arrow.getShooter(), "DaggerThrow", arrow.getLocation())) { return; } @@ -169,7 +169,7 @@ public static void damageEntityFromArrow(Player player, LivingEntity entity, Arr Player target = (Player)entity; BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(target); - for (AbilityInteraction interaction : interactions) { + for (AbilityInteraction interaction : INTERACTIONS) { if (!interaction.enabled) continue; if (dt.hits < interaction.hitRequirement) continue; @@ -250,15 +250,67 @@ public String getDescription() { return "* JedCore Addon *\n" + config.getString("Abilities.Chi.DaggerThrow.Description"); } - @Override - public void load() { + public static boolean hasParticleTrail() { + return particles; + } + public static double getDamage() { + return damage; } - @Override - public void stop() { + public long getEndTime() { + return endTime; + } + + public void setEndTime(long endTime) { + this.endTime = endTime; + } + + public int getShots() { + return shots; + } + + public void setShots(int shots) { + this.shots = shots; + } + + public void setCooldown(long cooldown) { + this.cooldown = cooldown; + } + public boolean isLimitEnabled() { + return limitEnabled; } + + public void setLimitEnabled(boolean limitEnabled) { + this.limitEnabled = limitEnabled; + } + + public int getMaxShots() { + return maxShots; + } + + public void setMaxShots(int maxShots) { + this.maxShots = maxShots; + } + + public int getHits() { + return hits; + } + + public void setHits(int hits) { + this.hits = hits; + } + + public List getArrows() { + return arrows; + } + + @Override + public void load() {} + + @Override + public void stop() {} @Override public boolean isEnabled() { diff --git a/src/com/jedk1/jedcore/ability/earthbending/EarthKick.java b/src/com/jedk1/jedcore/ability/earthbending/EarthKick.java index 330f5ca..b3f0423 100644 --- a/src/com/jedk1/jedcore/ability/earthbending/EarthKick.java +++ b/src/com/jedk1/jedcore/ability/earthbending/EarthKick.java @@ -31,11 +31,11 @@ import static java.util.stream.Collectors.toList; public class EarthKick extends EarthAbility implements AddonAbility { - private List temps = new ArrayList<>(); + private final List temps = new ArrayList<>(); private BlockData materialData; private Location location; - private Random rand = new Random(); + private final Random rand = new Random(); @Attribute(Attribute.COOLDOWN) private long cooldown; @@ -57,7 +57,7 @@ public EarthKick(Player player) { setFields(); location = player.getLocation(); if ((player.getLocation().getPitch() > -5) && prepare()) { - if(GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation())){ + if (GeneralMethods.isRegionProtectedFromBuild(this, block.getLocation())) { return; } launchBlocks(); @@ -129,7 +129,7 @@ private void launchBlocks() { Vector direction = location.getDirection(); location.add(direction.clone().multiply(1.0)); - if(!ElementalAbility.isAir(location.getBlock().getType())){ + if (!ElementalAbility.isAir(location.getBlock().getType())) { location.setY(location.getY() + 1.0); } @@ -235,16 +235,60 @@ public String getDescription() { return "* JedCore Addon *\n" + config.getString("Abilities.Earth.EarthKick.Description"); } - @Override - public void load() { + public List getTemps() { + return temps; + } + public BlockData getMaterialData() { + return materialData; } - @Override - public void stop() { + public void setMaterialData(BlockData materialData) { + this.materialData = materialData; + } + + public void setLocation(Location location) { + this.location = location; + } + + public int getEarthBlocksQuantity() { + return earthBlocks; + } + + public void setEarthBlocksQuantity(int earthBlocks) { + this.earthBlocks = earthBlocks; + } + + public double getDamage() { + return damage; + } + public void setDamage(double damage) { + this.damage = damage; } + public double getEntityCollisionRadius() { + return entityCollisionRadius; + } + + public void setEntityCollisionRadius(double entityCollisionRadius) { + this.entityCollisionRadius = entityCollisionRadius; + } + + public Block getBlock() { + return block; + } + + public void setBlock(Block block) { + this.block = block; + } + + @Override + public void load() {} + + @Override + public void stop() {} + @Override public boolean isEnabled() { ConfigurationSection config = JedCoreConfig.getConfig(this.player); diff --git a/src/com/jedk1/jedcore/ability/earthbending/EarthLine.java b/src/com/jedk1/jedcore/ability/earthbending/EarthLine.java index 769b88c..b5fa8d6 100644 --- a/src/com/jedk1/jedcore/ability/earthbending/EarthLine.java +++ b/src/com/jedk1/jedcore/ability/earthbending/EarthLine.java @@ -8,7 +8,6 @@ import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ability.AddonAbility; import com.projectkorra.projectkorra.ability.EarthAbility; -import com.projectkorra.projectkorra.ability.ElementalAbility; import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.command.Commands; import com.projectkorra.projectkorra.earthbending.passive.DensityShift; @@ -31,24 +30,24 @@ public class EarthLine extends EarthAbility implements AddonAbility { private Location location; private Location endLocation; - private Block sourceblock; - private Material sourcetype; + private Block sourceBlock; + private Material sourceType; private boolean progressing; private boolean hitted; private int goOnAfterHit; private long removalTime = -1; - private long usecooldown; - private long preparecooldown; + private long useCooldown; + private long prepareCooldown; @Attribute(Attribute.DURATION) - private long maxduration; + private long maxDuration; @Attribute(Attribute.RANGE) private double range; @Attribute(Attribute.SELECT_RANGE) - private double preparerange; - private double sourcekeeprange; + private double prepareRange; + private double sourceKeepRange; @Attribute(Attribute.RADIUS) - private int affectingradius; + private int affectingRadius; @Attribute(Attribute.DAMAGE) private double damage; private boolean allowChangeDirection; @@ -63,17 +62,14 @@ public EarthLine(Player player) { if (!bPlayer.canBend(this)) { return; } - location = null; - endLocation = null; - sourceblock = null; - sourcetype = null; - progressing = false; goOnAfterHit = 1; setFields(); if (prepare()) { - if (preparecooldown != 0) bPlayer.addCooldown(this, preparecooldown); start(); + if (!isRemoved() && prepareCooldown != 0) { + bPlayer.addCooldown(this, prepareCooldown); + } } } @@ -89,27 +85,27 @@ public void setFields() { this.removalPolicy.load(config); - usecooldown = config.getLong("Abilities.Earth.EarthLine.Cooldown"); - preparecooldown = config.getLong("Abilities.Earth.EarthLine.PrepareCooldown"); + useCooldown = config.getLong("Abilities.Earth.EarthLine.Cooldown"); + prepareCooldown = config.getLong("Abilities.Earth.EarthLine.PrepareCooldown"); range = config.getInt("Abilities.Earth.EarthLine.Range"); - preparerange = config.getDouble("Abilities.Earth.EarthLine.PrepareRange"); - sourcekeeprange = config.getDouble("Abilities.Earth.EarthLine.SourceKeepRange"); - affectingradius = config.getInt("Abilities.Earth.EarthLine.AffectingRadius"); + prepareRange = config.getDouble("Abilities.Earth.EarthLine.PrepareRange"); + sourceKeepRange = config.getDouble("Abilities.Earth.EarthLine.SourceKeepRange"); + affectingRadius = config.getInt("Abilities.Earth.EarthLine.AffectingRadius"); damage = config.getDouble("Abilities.Earth.EarthLine.Damage"); allowChangeDirection = config.getBoolean("Abilities.Earth.EarthLine.AllowChangeDirection"); - maxduration = config.getLong("Abilities.Earth.EarthLine.MaxDuration"); + maxDuration = config.getLong("Abilities.Earth.EarthLine.MaxDuration"); } public boolean prepare() { if (hasAbility(player, EarthLine.class)) { - EarthLine el = (EarthLine) getAbility(player, EarthLine.class); + EarthLine el = getAbility(player, EarthLine.class); if (!el.progressing) { el.remove(); } } - Block block = BlockSource.getEarthSourceBlock(player, preparerange, ClickType.SHIFT_DOWN); + Block block = BlockSource.getEarthSourceBlock(player, prepareRange, ClickType.SHIFT_DOWN); if (block != null) { - sourceblock = block; + sourceBlock = block; focusBlock(); return true; } else { @@ -118,36 +114,36 @@ public boolean prepare() { } private void focusBlock() { - if (sourceblock.getType() == Material.SAND) { - if (DensityShift.isPassiveSand(this.sourceblock)) { - DensityShift.revertSand(this.sourceblock); - this.sourcetype = this.sourceblock.getType(); + if (sourceBlock.getType() == Material.SAND) { + if (DensityShift.isPassiveSand(this.sourceBlock)) { + DensityShift.revertSand(this.sourceBlock); + this.sourceType = this.sourceBlock.getType(); } else { - sourcetype = Material.SAND; + sourceType = Material.SAND; } - sourceblock.setType(Material.SANDSTONE); - } else if (sourceblock.getType() == Material.STONE) { - sourcetype = sourceblock.getType(); - sourceblock.setType(Material.COBBLESTONE); + sourceBlock.setType(Material.SANDSTONE); + } else if (sourceBlock.getType() == Material.STONE) { + sourceType = sourceBlock.getType(); + sourceBlock.setType(Material.COBBLESTONE); } else { - sourcetype = sourceblock.getType(); - sourceblock.setType(Material.STONE); + sourceType = sourceBlock.getType(); + sourceBlock.setType(Material.STONE); } - location = sourceblock.getLocation(); + location = sourceBlock.getLocation(); } private void unfocusBlock() { - sourceblock.setType(sourcetype); + sourceBlock.setType(sourceType); } private void breakSourceBlock() { - sourceblock.setType(sourcetype); - new RegenTempBlock(sourceblock, Material.AIR, Material.AIR.createBlockData(), 5000L); + sourceBlock.setType(sourceType); + new RegenTempBlock(sourceBlock, Material.AIR, Material.AIR.createBlockData(), 5000L); } @Override public void remove() { - sourceblock.setType(sourcetype); + sourceBlock.setType(sourceType); super.remove(); } @@ -164,28 +160,26 @@ private static Location getTargetLocation(Player player) { return location; } - public void shootline(Location endLocation) { - if (usecooldown != 0 && bPlayer.getCooldown(this.getName()) < usecooldown) bPlayer.addCooldown(this, usecooldown); - if (maxduration > 0) removalTime = System.currentTimeMillis() + maxduration; + public void shootLine(Location endLocation) { + if (useCooldown != 0 && bPlayer.getCooldown(this.getName()) < useCooldown) bPlayer.addCooldown(this, useCooldown); + if (maxDuration > 0) removalTime = System.currentTimeMillis() + maxDuration; this.endLocation = endLocation; progressing = true; breakSourceBlock(); - sourceblock.getWorld().playEffect(sourceblock.getLocation(), Effect.GHAST_SHOOT, 0, 10); + sourceBlock.getWorld().playEffect(sourceBlock.getLocation(), Effect.GHAST_SHOOT, 0, 10); } - public static boolean shootLine(Player player) { + public static void shootLine(Player player) { if (hasAbility(player, EarthLine.class)) { - EarthLine el = (EarthLine) getAbility(player, EarthLine.class); + EarthLine el = getAbility(player, EarthLine.class); if (!el.progressing) { - el.shootline(getTargetLocation(player)); - return true; + el.shootLine(getTargetLocation(player)); } } - return false; } private boolean sourceOutOfRange() { - return sourceblock == null || sourceblock.getLocation().add(0.5, 0.5, 0.5).distanceSquared(player.getLocation()) > sourcekeeprange * sourcekeeprange || sourceblock.getWorld() != player.getWorld(); + return sourceBlock == null || sourceBlock.getLocation().add(0.5, 0.5, 0.5).distanceSquared(player.getLocation()) > sourceKeepRange * sourceKeepRange || sourceBlock.getWorld() != player.getWorld(); } public void progress() { @@ -202,7 +196,7 @@ public void progress() { return; } - if (sourceblock == null || GeneralMethods.isRegionProtectedFromBuild(this, location)) { + if (sourceBlock == null || GeneralMethods.isRegionProtectedFromBuild(this, location)) { remove(); return; } @@ -228,11 +222,11 @@ public void progress() { double x1 = endLocation.getX(); double z1 = endLocation.getZ(); - double x0 = sourceblock.getX(); - double z0 = sourceblock.getZ(); + double x0 = sourceBlock.getX(); + double z0 = sourceBlock.getZ(); Vector looking = new Vector(x1 - x0, 0.0D, z1 - z0); Vector push = new Vector(x1 - x0, 0.34999999999999998D, z1 - z0); - if (location.distance(sourceblock.getLocation()) < range) { + if (location.distance(sourceBlock.getLocation()) < range) { Material cloneType = location.getBlock().getType(); Location locationYUP = location.getBlock().getLocation().clone().add(0.5, 0.1, 0.5); @@ -257,12 +251,12 @@ public void progress() { return; } } else { - for (Entity entity : GeneralMethods.getEntitiesAroundPoint(location, affectingradius)) { - if (GeneralMethods.isRegionProtectedFromBuild(this, entity.getLocation()) || ((entity instanceof Player) && Commands.invincible.contains(((Player) entity).getName()))){ + for (Entity entity : GeneralMethods.getEntitiesAroundPoint(location, affectingRadius)) { + if (GeneralMethods.isRegionProtectedFromBuild(this, entity.getLocation()) || ((entity instanceof Player) && Commands.invincible.contains(entity.getName()))){ return; } if ((entity instanceof LivingEntity) && entity.getEntityId() != player.getEntityId()) { - entity.setVelocity(push.normalize().multiply(2)); + GeneralMethods.setVelocity(this, entity, push.normalize().multiply(2)); DamageHandler.damageEntity(entity, damage, this); hitted = true; } @@ -274,9 +268,7 @@ public void progress() { } if (!isEarthbendable(player, location.getBlock()) && !isTransparent(location.getBlock())) { remove(); - return; } - return; } private boolean climb() { @@ -302,7 +294,7 @@ private boolean climb() { @Override public long getCooldown() { - return usecooldown; + return useCooldown; } @Override @@ -341,16 +333,132 @@ public String getDescription() { return "* JedCore Addon *\n" + config.getString("Abilities.Earth.EarthLine.Description"); } - @Override - public void load() { - return; + public Location getEndLocation() { + return endLocation; } - @Override - public void stop() { - return; + public void setEndLocation(Location endLocation) { + this.endLocation = endLocation; + } + + public Block getSourceBlock() { + return sourceBlock; + } + + public void setSourceBlock(Block sourceBlock) { + this.sourceBlock = sourceBlock; + } + + public Material getSourceType() { + return sourceType; + } + + public void setSourceType(Material sourceType) { + this.sourceType = sourceType; + } + + public boolean isProgressing() { + return progressing; + } + + public void setProgressing(boolean progressing) { + this.progressing = progressing; + } + + public int getGoOnAfterHit() { + return goOnAfterHit; + } + + public void setGoOnAfterHit(int goOnAfterHit) { + this.goOnAfterHit = goOnAfterHit; + } + + public long getRemovalTime() { + return removalTime; + } + + public void setRemovalTime(long removalTime) { + this.removalTime = removalTime; + } + + public long getUseCooldown() { + return useCooldown; + } + + public void setUseCooldown(long useCooldown) { + this.useCooldown = useCooldown; + } + + public long getPrepareCooldown() { + return prepareCooldown; + } + + public void setPrepareCooldown(long prepareCooldown) { + this.prepareCooldown = prepareCooldown; + } + + public long getMaxDuration() { + return maxDuration; + } + + public void setMaxDuration(long maxDuration) { + this.maxDuration = maxDuration; + } + + public double getRange() { + return range; + } + + public void setRange(double range) { + this.range = range; + } + + public double getPrepareRange() { + return prepareRange; + } + + public void setPrepareRange(double prepareRange) { + this.prepareRange = prepareRange; + } + + public double getSourceKeepRange() { + return sourceKeepRange; + } + + public void setSourceKeepRange(double sourceKeepRange) { + this.sourceKeepRange = sourceKeepRange; } + public int getAffectingRadius() { + return affectingRadius; + } + + public void setAffectingRadius(int affectingRadius) { + this.affectingRadius = affectingRadius; + } + + public double getDamage() { + return damage; + } + + public void setDamage(double damage) { + this.damage = damage; + } + + public boolean isAllowChangeDirection() { + return allowChangeDirection; + } + + public void setAllowChangeDirection(boolean allowChangeDirection) { + this.allowChangeDirection = allowChangeDirection; + } + + @Override + public void load() {} + + @Override + public void stop() {} + @Override public boolean isEnabled() { ConfigurationSection config = JedCoreConfig.getConfig(this.player); diff --git a/src/com/jedk1/jedcore/ability/earthbending/EarthPillar.java b/src/com/jedk1/jedcore/ability/earthbending/EarthPillar.java index bb6e131..1935c15 100644 --- a/src/com/jedk1/jedcore/ability/earthbending/EarthPillar.java +++ b/src/com/jedk1/jedcore/ability/earthbending/EarthPillar.java @@ -10,7 +10,6 @@ import com.projectkorra.projectkorra.util.ClickType; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; import org.bukkit.configuration.ConfigurationSection; @@ -18,14 +17,13 @@ import org.bukkit.util.Vector; import java.util.ArrayList; -import java.util.HashSet; import java.util.List; import java.util.concurrent.ConcurrentHashMap; public class EarthPillar extends EarthAbility implements AddonAbility { - private static ConcurrentHashMap affectedblocks = new ConcurrentHashMap(); - private static ConcurrentHashMap> affected = new ConcurrentHashMap>(); + private static final ConcurrentHashMap AFFECTED_BLOCKS = new ConcurrentHashMap<>(); + private static final ConcurrentHashMap> AFFECTED = new ConcurrentHashMap<>(); private Block block; private BlockFace face; @@ -35,17 +33,19 @@ public class EarthPillar extends EarthAbility implements AddonAbility { private int range; private int step; - private List blocks = new ArrayList(); + private final List blocks = new ArrayList<>(); public EarthPillar(Player player) { super(player); + if (!bPlayer.canBend(this)) { return; } + setFields(); Block target = BlockSource.getEarthSourceBlock(player, range, ClickType.SHIFT_DOWN); - if (target != null && !affectedblocks.containsKey(target)) { - List blocks = player.getLastTwoTargetBlocks((HashSet) null, range); + if (target != null && !AFFECTED_BLOCKS.containsKey(target)) { + List blocks = player.getLastTwoTargetBlocks(null, range); if (blocks.size() > 1) { this.player = player; face = blocks.get(1).getFace(blocks.get(0)); @@ -53,14 +53,14 @@ public EarthPillar(Player player) { height = getEarthbendableBlocksLength(block, getDirection(face).clone().multiply(-1), height); start(); } - } else if (target != null && affectedblocks.containsKey(target)) { - List blocks = affected.get(affectedblocks.get(target)); + } else if (target != null && AFFECTED_BLOCKS.containsKey(target)) { + List blocks = AFFECTED.get(AFFECTED_BLOCKS.get(target)); if (blocks != null && !blocks.isEmpty()) { for (Block b : blocks) { Collapse.revertBlock(b); } playEarthbendingSound(target.getLocation()); - affected.remove(affectedblocks.get(target)); + AFFECTED.remove(AFFECTED_BLOCKS.get(target)); } } } @@ -78,17 +78,15 @@ public void progress() { step++; movePillar(); } else { - affected.put(this, blocks); + AFFECTED.put(this, blocks); remove(); - return; } - return; } private void movePillar() { moveEarth(block, getDirection(face), height); block = block.getRelative(face); - affectedblocks.put(block, this); + AFFECTED_BLOCKS.put(block, this); blocks.add(block); } @@ -112,9 +110,9 @@ private Vector getDirection(BlockFace face) { } public static void progressAll() { - for (Block block : affectedblocks.keySet()) { - if (!EarthAbility.isEarthbendable(affectedblocks.get(block).getPlayer(), block)) { - affectedblocks.remove(block); + for (Block block : AFFECTED_BLOCKS.keySet()) { + if (!EarthAbility.isEarthbendable(AFFECTED_BLOCKS.get(block).getPlayer(), block)) { + AFFECTED_BLOCKS.remove(block); } } } @@ -126,7 +124,7 @@ public long getCooldown() { @Override public Location getLocation() { - return null; + return block != null ? block.getLocation() : null; } @Override @@ -160,16 +158,56 @@ public String getDescription() { return "* JedCore Addon *\n" + config.getString("Abilities.Earth.EarthPillar.Description"); } - @Override - public void load() { - return; + public Block getBlock() { + return block; } - @Override - public void stop() { - return; + public void setBlock(Block block) { + this.block = block; + } + + public BlockFace getFace() { + return face; } + public void setFace(BlockFace face) { + this.face = face; + } + + public int getHeight() { + return height; + } + + public void setHeight(int height) { + this.height = height; + } + + public int getRange() { + return range; + } + + public void setRange(int range) { + this.range = range; + } + + public int getStep() { + return step; + } + + public void setStep(int step) { + this.step = step; + } + + public List getBlocks() { + return blocks; + } + + @Override + public void load() {} + + @Override + public void stop() {} + @Override public boolean isEnabled() { ConfigurationSection config = JedCoreConfig.getConfig(this.player); diff --git a/src/com/jedk1/jedcore/ability/earthbending/EarthShard.java b/src/com/jedk1/jedcore/ability/earthbending/EarthShard.java index 9c8384a..584c5b6 100644 --- a/src/com/jedk1/jedcore/ability/earthbending/EarthShard.java +++ b/src/com/jedk1/jedcore/ability/earthbending/EarthShard.java @@ -50,9 +50,9 @@ public class EarthShard extends EarthAbility implements AddonAbility { private double abilityCollisionRadius; private double entityCollisionRadius; - private List tblockTracker = new ArrayList<>(); - private List readyBlocksTracker = new ArrayList<>(); - private List fallingBlocks = new ArrayList<>(); + private final List tblockTracker = new ArrayList<>(); + private final List readyBlocksTracker = new ArrayList<>(); + private final List fallingBlocks = new ArrayList<>(); public EarthShard(Player player) { super(player); @@ -347,16 +347,100 @@ public String getDescription() { return "* JedCore Addon *\n" + config.getString("Abilities.Earth.EarthShard.Description"); } - @Override - public void load() { + public static int getRange() { + return range; + } + public static void setRange(int range) { + EarthShard.range = range; } - @Override - public void stop() { + public static int getAbilityRange() { + return abilityRange; + } + + public static void setAbilityRange(int abilityRange) { + EarthShard.abilityRange = abilityRange; + } + + public static double getNormalDmg() { + return normalDmg; + } + + public static void setNormalDmg(double normalDmg) { + EarthShard.normalDmg = normalDmg; + } + + public static double getMetalDmg() { + return metalDmg; + } + public static void setMetalDmg(double metalDmg) { + EarthShard.metalDmg = metalDmg; } + public static int getMaxShards() { + return maxShards; + } + + public static void setMaxShards(int maxShards) { + EarthShard.maxShards = maxShards; + } + + public static void setCooldown(long cooldown) { + EarthShard.cooldown = cooldown; + } + + public boolean isThrown() { + return isThrown; + } + + public void setThrown(boolean thrown) { + isThrown = thrown; + } + + public Location getOrigin() { + return origin; + } + + public void setOrigin(Location origin) { + this.origin = origin; + } + + public double getAbilityCollisionRadius() { + return abilityCollisionRadius; + } + + public void setAbilityCollisionRadius(double abilityCollisionRadius) { + this.abilityCollisionRadius = abilityCollisionRadius; + } + + public double getEntityCollisionRadius() { + return entityCollisionRadius; + } + + public void setEntityCollisionRadius(double entityCollisionRadius) { + this.entityCollisionRadius = entityCollisionRadius; + } + + public List getTblockTracker() { + return tblockTracker; + } + + public List getReadyBlocksTracker() { + return readyBlocksTracker; + } + + public List getFallingBlocks() { + return fallingBlocks; + } + + @Override + public void load() {} + + @Override + public void stop() {} + @Override public boolean isEnabled() { ConfigurationSection config = JedCoreConfig.getConfig(this.player); diff --git a/src/com/jedk1/jedcore/ability/earthbending/EarthSurf.java b/src/com/jedk1/jedcore/ability/earthbending/EarthSurf.java index e16e4ee..db35d42 100644 --- a/src/com/jedk1/jedcore/ability/earthbending/EarthSurf.java +++ b/src/com/jedk1/jedcore/ability/earthbending/EarthSurf.java @@ -31,9 +31,6 @@ public class EarthSurf extends EarthAbility implements AddonAbility { private Location location; private double prevHealth; - //Player Positioning - private double distOffset = 2.5; - @Attribute(Attribute.COOLDOWN) private long cooldown; private long minimumCooldown; @@ -45,7 +42,7 @@ public class EarthSurf extends EarthAbility implements AddonAbility { @Attribute(Attribute.SPEED) private double speed; private double springStiffness; - private Set ridingBlocks = new HashSet<>(); + private final Set ridingBlocks = new HashSet<>(); private CollisionDetector collisionDetector = new DefaultCollisionDetector(); private DoubleSmoother heightSmoother; @@ -200,6 +197,8 @@ private void rideWave() { if (i < 2) loc.add(getSideDirection(i)); + //Player Positioning + double distOffset = 2.5; Location bL = loc.clone().add(0, -2.9, 0).toVector().add(location.clone().getDirection().multiply(distOffset)).toLocation(player.getWorld()); while (!ElementalAbility.isAir(loc.clone().add(0, -2.9, 0).toVector().add(location.clone().getDirection().multiply(distOffset)).toLocation(player.getWorld()).getBlock().getType())) { loc.add(0, 0.1, 0); @@ -232,7 +231,7 @@ private void rideWave() { if (GeneralMethods.isSolid(block)) { ridingBlocks.add(block); - new RegenTempBlock(block, Material.AIR, Material.AIR.createBlockData(), 1000L, true, b -> ridingBlocks.remove(b)); + new RegenTempBlock(block, Material.AIR, Material.AIR.createBlockData(), 1000L, true, ridingBlocks::remove); } else { new RegenTempBlock(block, Material.AIR, Material.AIR.createBlockData(), 1000L); } @@ -318,20 +317,111 @@ public String getVersion() { @Override public String getDescription() { ConfigurationSection config = JedCoreConfig.getConfig(this.player); - return "* JedCore Addon *\n" + config.getString("Abilities.Earth.EarthSurf.Description"); } - @Override - public void load() { - return; + public static double getTargetHeight() { + return TARGET_HEIGHT; } - @Override - public void stop() { - return; + public void setLocation(Location location) { + this.location = location; + } + + public double getPrevHealth() { + return prevHealth; + } + + public void setPrevHealth(double prevHealth) { + this.prevHealth = prevHealth; + } + + public void setCooldown(long cooldown) { + this.cooldown = cooldown; + } + + public long getMinimumCooldown() { + return minimumCooldown; + } + + public void setMinimumCooldown(long minimumCooldown) { + this.minimumCooldown = minimumCooldown; + } + + public long getDuration() { + return duration; + } + + public void setDuration(long duration) { + this.duration = duration; + } + + public boolean isCooldownEnabled() { + return cooldownEnabled; + } + + public void setCooldownEnabled(boolean cooldownEnabled) { + this.cooldownEnabled = cooldownEnabled; + } + + public boolean isDurationEnabled() { + return durationEnabled; + } + + public void setDurationEnabled(boolean durationEnabled) { + this.durationEnabled = durationEnabled; } + public boolean isRemoveOnAnyDamage() { + return removeOnAnyDamage; + } + + public void setRemoveOnAnyDamage(boolean removeOnAnyDamage) { + this.removeOnAnyDamage = removeOnAnyDamage; + } + + public double getSpeed() { + return speed; + } + + public void setSpeed(double speed) { + this.speed = speed; + } + + public double getSpringStiffness() { + return springStiffness; + } + + public void setSpringStiffness(double springStiffness) { + this.springStiffness = springStiffness; + } + + public Set getRidingBlocks() { + return ridingBlocks; + } + + public CollisionDetector getCollisionDetector() { + return collisionDetector; + } + + public void setCollisionDetector(CollisionDetector collisionDetector) { + this.collisionDetector = collisionDetector; + } + + public DoubleSmoother getHeightSmoother() { + return heightSmoother; + } + + public void setHeightSmoother(DoubleSmoother heightSmoother) { + this.heightSmoother = heightSmoother; + } + + @Override + public void load() {} + + @Override + public void stop() {} + @Override public boolean isEnabled() { ConfigurationSection config = JedCoreConfig.getConfig(this.player); @@ -343,7 +433,7 @@ private interface CollisionDetector { boolean isColliding(Player player); } - private abstract class AbstractCollisionDetector implements CollisionDetector { + private abstract static class AbstractCollisionDetector implements CollisionDetector { protected boolean isCollision(Location location) { Block block = location.getBlock(); return !MaterialUtil.isTransparent(block) || block.isLiquid() || block.getType().isSolid(); @@ -390,8 +480,8 @@ public boolean isColliding(Player player) { } private static class DoubleSmoother { - private double[] values; - private int size; + private final double[] values; + private final int size; private int index; public DoubleSmoother(int size) { diff --git a/src/com/jedk1/jedcore/ability/earthbending/Fissure.java b/src/com/jedk1/jedcore/ability/earthbending/Fissure.java index 211e2a0..1245fa2 100644 --- a/src/com/jedk1/jedcore/ability/earthbending/Fissure.java +++ b/src/com/jedk1/jedcore/ability/earthbending/Fissure.java @@ -24,7 +24,6 @@ import java.util.ArrayList; import java.util.Collections; -import java.util.HashSet; import java.util.List; import java.util.Random; @@ -42,7 +41,7 @@ public class Fissure extends LavaAbility implements AddonAbility { private Location location; private Vector direction; - private Vector blockdirection; + private Vector blockDirection; private long time; private long step; private int slap; @@ -51,8 +50,8 @@ public class Fissure extends LavaAbility implements AddonAbility { static Random rand = new Random(); - private List centerSlap = new ArrayList(); - private List blocks = new ArrayList(); + private final List centerSlap = new ArrayList<>(); + private final List blocks = new ArrayList<>(); public Fissure(Player player) { super(player); @@ -67,11 +66,13 @@ public Fissure(Player player) { location = player.getLocation().clone(); location.setPitch(0); direction = location.getDirection(); - blockdirection = this.direction.clone().setX(Math.round(this.direction.getX())); - blockdirection = blockdirection.setZ(Math.round(direction.getZ())); + blockDirection = this.direction.clone().setX(Math.round(this.direction.getX())); + blockDirection = blockDirection.setZ(Math.round(direction.getZ())); if (prepareLine()) { start(); - bPlayer.addCooldown(this); + if (!isRemoved()) { + bPlayer.addCooldown(this); + } } } @@ -99,22 +100,21 @@ public void progress() { } if (System.currentTimeMillis() > time + duration) { remove(); - return; } } private boolean prepareLine() { direction = player.getEyeLocation().getDirection().setY(0).normalize(); - blockdirection = this.direction.clone().setX(Math.round(this.direction.getX())); - blockdirection = blockdirection.setZ(Math.round(direction.getZ())); - Location origin = player.getLocation().add(0, -1, 0).add(blockdirection.multiply(2)); + blockDirection = this.direction.clone().setX(Math.round(this.direction.getX())); + blockDirection = blockDirection.setZ(Math.round(direction.getZ())); + Location origin = player.getLocation().add(0, -1, 0).add(blockDirection.multiply(2)); if (isEarthbendable(player, origin.getBlock())) { BlockIterator bi = new BlockIterator(player.getWorld(), origin.toVector(), direction, 0, slapRange); while (bi.hasNext()) { Block b = bi.next(); - if (b != null && b.getY() > 1 && b.getY() < 255 && !GeneralMethods.isRegionProtectedFromBuild(this, b.getLocation())) { + if (b.getY() > 1 && b.getY() < 255 && !GeneralMethods.isRegionProtectedFromBuild(this, b.getLocation())) { if (EarthAbility.getMovedEarth().containsKey(b)){ Information info = EarthAbility.getMovedEarth().get(b); if(!info.getBlock().equals(b)) { @@ -124,7 +124,7 @@ private boolean prepareLine() { while (!isEarthbendable(player, b)) { b = b.getRelative(BlockFace.DOWN); - if (b == null || b.getY() < 1 || b.getY() > 255) { + if (b.getY() < b.getWorld().getMinHeight() || b.getY() > b.getWorld().getMaxHeight()) { break; } if (isEarthbendable(player, b)) { @@ -134,7 +134,7 @@ private boolean prepareLine() { while (!isTransparent(b.getRelative(BlockFace.UP))) { b = b.getRelative(BlockFace.UP); - if (b == null || b.getY() < 1 || b.getY() > 255) { + if (b.getY() < b.getWorld().getMinHeight() || b.getY() > b.getWorld().getMaxHeight()) { break; } if (isEarthbendable(player, b.getRelative(BlockFace.UP))) { @@ -167,14 +167,14 @@ private void slapCenter() { public static void performAction(Player player) { if (hasAbility(player, Fissure.class)) { - ((Fissure) getAbility(player, Fissure.class)).performAction(); + getAbility(player, Fissure.class).performAction(); } } private void performAction() { if (width < maxWidth) { expandFissure(); - } else if (width >= maxWidth && blocks.contains(player.getTargetBlock((HashSet) null, (int) 10))) { + } else if (blocks.contains(player.getTargetBlock(null, 10))) { forceRevert(); } } @@ -183,10 +183,10 @@ private void expandFissure() { if (progressed && width <= maxWidth) { width++; for (Location location : centerSlap) { - Block left = location.getBlock().getRelative(getLeftBlockFace(GeneralMethods.getCardinalDirection(blockdirection)), width); + Block left = location.getBlock().getRelative(getLeftBlockFace(GeneralMethods.getCardinalDirection(blockDirection)), width); expand(left); - Block right = location.getBlock().getRelative(getLeftBlockFace(GeneralMethods.getCardinalDirection(blockdirection)).getOppositeFace(), width); + Block right = location.getBlock().getRelative(getLeftBlockFace(GeneralMethods.getCardinalDirection(blockDirection)).getOppositeFace(), width); expand(right); } } @@ -204,7 +204,7 @@ private void expand(Block block) { while (!isEarthbendable(player, block)) { block = block.getRelative(BlockFace.DOWN); - if (block == null || block.getY() < 1 || block.getY() > 255) { + if (block.getY() < 1 || block.getY() > 255) { break; } if (isEarthbendable(player, block)) { @@ -214,7 +214,7 @@ private void expand(Block block) { while (!isTransparent(player, block.getRelative(BlockFace.UP))) { block = block.getRelative(BlockFace.UP); - if (block == null || block.getY() < 1 || block.getY() > 255) { + if (block.getY() < 1 || block.getY() > 255) { break; } if (isEarthbendable(player, block.getRelative(BlockFace.UP))) { @@ -224,8 +224,6 @@ private void expand(Block block) { if (isEarthbendable(player, block)) { addTempBlock(block, Material.LAVA); - } else { - return; } } } @@ -258,7 +256,6 @@ public BlockFace getLeftBlockFace(BlockFace forward) { return BlockFace.SOUTH_EAST; case SOUTH_EAST: return BlockFace.NORTH_EAST; - default: return BlockFace.NORTH; } @@ -325,16 +322,116 @@ public String getDescription() { return "* JedCore Addon *\n" + config.getString("Abilities.Earth.Fissure.Description"); } - @Override - public void load() { - return; + public int getSlapRange() { + return slapRange; } - @Override - public void stop() { - return; + public void setSlapRange(int slapRange) { + this.slapRange = slapRange; + } + + public int getMaxWidth() { + return maxWidth; + } + + public void setMaxWidth(int maxWidth) { + this.maxWidth = maxWidth; + } + + public long getSlapDelay() { + return slapDelay; + } + + public void setSlapDelay(long slapDelay) { + this.slapDelay = slapDelay; + } + + public long getDuration() { + return duration; + } + + public void setDuration(long duration) { + this.duration = duration; + } + + public void setCooldown(long cooldown) { + this.cooldown = cooldown; + } + + public void setLocation(Location location) { + this.location = location; + } + + public Vector getDirection() { + return direction; + } + + public void setDirection(Vector direction) { + this.direction = direction; + } + + public Vector getBlockDirection() { + return blockDirection; + } + + public void setBlockDirection(Vector blockDirection) { + this.blockDirection = blockDirection; } + public long getTime() { + return time; + } + + public void setTime(long time) { + this.time = time; + } + + public long getStep() { + return step; + } + + public void setStep(long step) { + this.step = step; + } + + public int getSlap() { + return slap; + } + + public void setSlap(int slap) { + this.slap = slap; + } + + public int getWidth() { + return width; + } + + public void setWidth(int width) { + this.width = width; + } + + public boolean isProgressed() { + return progressed; + } + + public void setProgressed(boolean progressed) { + this.progressed = progressed; + } + + public List getCenterSlap() { + return centerSlap; + } + + public List getBlocks() { + return blocks; + } + + @Override + public void load() {} + + @Override + public void stop() {} + @Override public boolean isEnabled() { ConfigurationSection config = JedCoreConfig.getConfig(this.player); diff --git a/src/com/jedk1/jedcore/ability/earthbending/LavaDisc.java b/src/com/jedk1/jedcore/ability/earthbending/LavaDisc.java index c16bb0a..ac39eec 100644 --- a/src/com/jedk1/jedcore/ability/earthbending/LavaDisc.java +++ b/src/com/jedk1/jedcore/ability/earthbending/LavaDisc.java @@ -52,7 +52,7 @@ public class LavaDisc extends LavaAbility implements AddonAbility { private CompositeRemovalPolicy removalPolicy; private DiscRenderer discRenderer; private State state; - private Set trailBlocks = new HashSet<>(); + private final Set trailBlocks = new HashSet<>(); public LavaDisc(Player player) { super(player); @@ -167,7 +167,7 @@ private boolean isLocationSafe() { Block block = location.getBlock(); - return block != null && isTransparent(block); + return isTransparent(block); } private boolean isLocationSafe(Location location) { @@ -226,16 +226,88 @@ public String getDescription() { return "* JedCore Addon *\n" + config.getString("Abilities.Earth.LavaDisc.Description"); } - @Override - public void load() { + public void setLocation(Location location) { + this.location = location; + } + public int getRecallCount() { + return recallCount; } - @Override - public void stop() { + public void setRecallCount(int recallCount) { + this.recallCount = recallCount; + } + + public long getTime() { + return time; + } + + public void setTime(long time) { + this.time = time; + } + + public double getDamage() { + return damage; + } + + public void setDamage(double damage) { + this.damage = damage; + } + + public void setCooldown(long cooldown) { + this.cooldown = cooldown; + } + + public long getDuration() { + return duration; + } + + public void setDuration(long duration) { + this.duration = duration; + } + + public int getRecallLimit() { + return recallLimit; + } + + public void setRecallLimit(int recallLimit) { + this.recallLimit = recallLimit; + } + + public boolean isTrailFlow() { + return trailFlow; + } + public void setTrailFlow(boolean trailFlow) { + this.trailFlow = trailFlow; } + public DiscRenderer getDiscRenderer() { + return discRenderer; + } + + public void setDiscRenderer(DiscRenderer discRenderer) { + this.discRenderer = discRenderer; + } + + public State getState() { + return state; + } + + public void setState(State state) { + this.state = state; + } + + public Set getTrailBlocks() { + return trailBlocks; + } + + @Override + public void load() {} + + @Override + public void stop() {} + @Override public boolean isEnabled() { ConfigurationSection config = JedCoreConfig.getConfig(this.player); @@ -276,7 +348,7 @@ public void update() { } private abstract class TravelState implements State { - private boolean passHit; + private final boolean passHit; protected Vector direction; protected boolean hasHit; @@ -388,8 +460,8 @@ public void update() { // Waits for the RegenTempBlocks to revert. // This exists so the instance stays alive and block flow events can stop the lava from flowing. private class CleanupState implements State { - private long startTime; - private long regenTime; + private final long startTime; + private final long regenTime; public CleanupState() { this.startTime = System.currentTimeMillis(); @@ -409,15 +481,15 @@ public void update() { } private class DiscRenderer { - private Player player; + private final Player player; private int angle; - private boolean damageBlocks; - private List meltable; - private long regenTime; - private boolean lavaTrail; + private final boolean damageBlocks; + private final List meltable; + private final long regenTime; + private final boolean lavaTrail; - private int particles; + private final int particles; public DiscRenderer(Player player) { @@ -465,7 +537,7 @@ private void damageBlocks(Location l) { } if (lavaTrail) { - new RegenTempBlock(l.getBlock(), Material.LAVA, Material.LAVA.createBlockData(bd -> ((Levelled)bd).setLevel(4)), regenTime); + new RegenTempBlock(l.getBlock(), Material.LAVA, Material.LAVA.createBlockData(bd -> ((Levelled) bd).setLevel(4)), regenTime); trailBlocks.add(l.getBlock()); } else { diff --git a/src/com/jedk1/jedcore/ability/earthbending/LavaFlux.java b/src/com/jedk1/jedcore/ability/earthbending/LavaFlux.java index c2c0fe2..26d0ccb 100644 --- a/src/com/jedk1/jedcore/ability/earthbending/LavaFlux.java +++ b/src/com/jedk1/jedcore/ability/earthbending/LavaFlux.java @@ -45,8 +45,6 @@ public class LavaFlux extends LavaAbility implements AddonAbility { private boolean wave; private Location location; - private Vector direction; - private Vector blockdirection; private int step; private int counter; private long time; @@ -54,7 +52,7 @@ public class LavaFlux extends LavaAbility implements AddonAbility { Random rand = new Random(); - private List flux = new ArrayList(); + private final List flux = new ArrayList<>(); public LavaFlux(Player player) { super(player); @@ -66,8 +64,10 @@ public LavaFlux(Player player) { setFields(); time = System.currentTimeMillis(); if (prepareLine()) { - bPlayer.addCooldown(this); start(); + if (!isRemoved()) { + bPlayer.addCooldown(this); + } } } @@ -108,14 +108,13 @@ public void progress() { new RegenTempBlock(location.getBlock(), Material.STONE, Material.STONE.createBlockData(), cleanup + rand.nextInt(1000)); } remove(); - return; } } } private boolean prepareLine() { - direction = player.getEyeLocation().getDirection().setY(0).normalize(); - blockdirection = this.direction.clone().setX(Math.round(this.direction.getX())); + Vector direction = player.getEyeLocation().getDirection().setY(0).normalize(); + Vector blockdirection = direction.clone().setX(Math.round(direction.getX())); blockdirection = blockdirection.setZ(Math.round(direction.getZ())); Location origin = player.getLocation().add(0, -1, 0).add(blockdirection.multiply(2)); if (isEarthbendable(player, origin.getBlock())) { @@ -124,11 +123,11 @@ private boolean prepareLine() { while (bi.hasNext()) { Block b = bi.next(); - if (b != null && b.getY() > 1 && b.getY() < 255 && !GeneralMethods.isRegionProtectedFromBuild(this, b.getLocation()) && !EarthAbility.getMovedEarth().containsKey(b)) { + if (b.getY() > b.getWorld().getMinHeight() && b.getY() < b.getWorld().getMaxHeight() && !GeneralMethods.isRegionProtectedFromBuild(this, b.getLocation()) && !EarthAbility.getMovedEarth().containsKey(b)) { if (isWater(b)) break; while (!isEarthbendable(player, b)) { b = b.getRelative(BlockFace.DOWN); - if (b == null || b.getY() < 1 || b.getY() > 255) { + if (b.getY() < b.getWorld().getMinHeight() || b.getY() > b.getWorld().getMaxHeight()) { break; } if (isEarthbendable(player, b)) { @@ -138,7 +137,7 @@ private boolean prepareLine() { while (!isTransparent(b.getRelative(BlockFace.UP))) { b = b.getRelative(BlockFace.UP); - if (b == null || b.getY() < 1 || b.getY() > 255) { + if (b.getY() < b.getWorld().getMinHeight() || b.getY() > b.getWorld().getMaxHeight()) { break; } if (isEarthbendable(player, b.getRelative(BlockFace.UP))) { @@ -207,7 +206,7 @@ private void expand(Block block) { if (isWater(block)) return; while (!isEarthbendable(block)) { block = block.getRelative(BlockFace.DOWN); - if (block == null || block.getY() < 1 || block.getY() > 255) { + if (block.getY() < 1 || block.getY() > 255) { break; } if (isEarthbendable(block)) { @@ -217,7 +216,7 @@ private void expand(Block block) { while (!isTransparent(block.getRelative(BlockFace.UP))) { block = block.getRelative(BlockFace.UP); - if (block == null || block.getY() < 1 || block.getY() > 255) { + if (block.getY() < 1 || block.getY() > 255) { break; } if (isEarthbendable(block.getRelative(BlockFace.UP))) { @@ -227,8 +226,6 @@ private void expand(Block block) { if (isEarthbendable(block)) { flux.add(block.getLocation()); - } else { - return; } } } @@ -251,7 +248,6 @@ public BlockFace getLeftBlockFace(BlockFace forward) { return BlockFace.SOUTH_EAST; case SOUTH_EAST: return BlockFace.NORTH_EAST; - default: return BlockFace.NORTH; } @@ -298,6 +294,98 @@ public String getDescription() { return "* JedCore Addon *\n" + config.getString("Abilities.Earth.LavaFlux.Description"); } + public int getSpeed() { + return speed; + } + + public void setSpeed(int speed) { + this.speed = speed; + } + + public int getRange() { + return range; + } + + public void setRange(int range) { + this.range = range; + } + + public void setCooldown(long cooldown) { + this.cooldown = cooldown; + } + + public long getDuration() { + return duration; + } + + public void setDuration(long duration) { + this.duration = duration; + } + + public long getCleanup() { + return cleanup; + } + + public void setCleanup(long cleanup) { + this.cleanup = cleanup; + } + + public double getDamage() { + return damage; + } + + public void setDamage(double damage) { + this.damage = damage; + } + + public boolean isWave() { + return wave; + } + + public void setWave(boolean wave) { + this.wave = wave; + } + + public void setLocation(Location location) { + this.location = location; + } + + public int getStep() { + return step; + } + + public void setStep(int step) { + this.step = step; + } + + public int getCounter() { + return counter; + } + + public void setCounter(int counter) { + this.counter = counter; + } + + public long getTime() { + return time; + } + + public void setTime(long time) { + this.time = time; + } + + public boolean isComplete() { + return complete; + } + + public void setComplete(boolean complete) { + this.complete = complete; + } + + public List getFlux() { + return flux; + } + @Override public void load() { ConfigurationSection config = JedCoreConfig.getConfig(this.player); @@ -307,13 +395,10 @@ public void load() { JedCore.plugin.saveConfig(); JedCore.plugin.reloadConfig(); } - return; } @Override - public void stop() { - return; - } + public void stop() {} @Override public boolean isEnabled() { diff --git a/src/com/jedk1/jedcore/ability/earthbending/LavaThrow.java b/src/com/jedk1/jedcore/ability/earthbending/LavaThrow.java index 01af884..957d5ca 100644 --- a/src/com/jedk1/jedcore/ability/earthbending/LavaThrow.java +++ b/src/com/jedk1/jedcore/ability/earthbending/LavaThrow.java @@ -45,7 +45,7 @@ public class LavaThrow extends LavaAbility implements AddonAbility { private Location location; private int shots; - private ConcurrentHashMap blasts = new ConcurrentHashMap<>(); + private final ConcurrentHashMap blasts = new ConcurrentHashMap<>(); public LavaThrow(Player player) { super(player); @@ -65,11 +65,13 @@ public LavaThrow(Player player) { location.setPitch(0); location = location.toVector().add(location.getDirection().multiply(sourceRange)).toLocation(location.getWorld()); - sourceRange = Math.round(sourceRange / 2); + sourceRange = Math.round(sourceRange / 2F); if (prepare()) { - createBlast(); start(); + if (!isRemoved()) { + createBlast(); + } } } @@ -119,11 +121,7 @@ public void progress() { private boolean prepare() { Block block = getRandomSourceBlock(location, 3); - if (block != null) { - return true; - } - - return false; + return block != null; } public void createBlast() { @@ -206,7 +204,7 @@ public static Block getRandomSourceBlock(Location location, int radius) { Block block = blocks.get(index); - if (block == null || !LavaAbility.isLava(block)) { + if (!LavaAbility.isLava(block)) { continue; } @@ -267,16 +265,80 @@ public String getDescription() { return "* JedCore Addon *\n" + config.getString("Abilities.Earth.LavaThrow.Description"); } - @Override - public void load() { + public void setCooldown(long cooldown) { + this.cooldown = cooldown; + } + public int getRange() { + return range; } - @Override - public void stop() { + public void setRange(int range) { + this.range = range; + } + + public double getDamage() { + return damage; + } + + public void setDamage(double damage) { + this.damage = damage; + } + + public int getSourceRange() { + return sourceRange; + } + + public void setSourceRange(int sourceRange) { + this.sourceRange = sourceRange; + } + + public long getSourceRegen() { + return sourceRegen; + } + + public void setSourceRegen(long sourceRegen) { + this.sourceRegen = sourceRegen; + } + + public int getShotMax() { + return shotMax; + } + + public void setShotMax(int shotMax) { + this.shotMax = shotMax; + } + public int getFireTicks() { + return fireTicks; } + public void setFireTicks(int fireTicks) { + this.fireTicks = fireTicks; + } + + public void setLocation(Location location) { + this.location = location; + } + + public int getShots() { + return shots; + } + + public void setShots(int shots) { + this.shots = shots; + } + + public ConcurrentHashMap getBlasts() { + return blasts; + } + + @Override + public void load() {} + + @Override + public void stop() {} + @Override public boolean isEnabled() { ConfigurationSection config = JedCoreConfig.getConfig(this.player); diff --git a/src/com/jedk1/jedcore/ability/earthbending/MagnetShield.java b/src/com/jedk1/jedcore/ability/earthbending/MagnetShield.java index 6bcf486..8a1e5ff 100644 --- a/src/com/jedk1/jedcore/ability/earthbending/MagnetShield.java +++ b/src/com/jedk1/jedcore/ability/earthbending/MagnetShield.java @@ -29,7 +29,7 @@ public MagnetShield(Player player) { } if (hasAbility(player, MagnetShield.class)) { - ((MagnetShield) getAbility(player, MagnetShield.class)).remove(); + getAbility(player, MagnetShield.class).remove(); return; } @@ -71,7 +71,6 @@ else if (e instanceof FallingBlock) { } } } - return; } @Override @@ -81,7 +80,7 @@ public long getCooldown() { @Override public Location getLocation() { - return null; + return player.getLocation(); } @Override @@ -116,14 +115,10 @@ public String getDescription() { } @Override - public void load() { - return; - } + public void load() {} @Override - public void stop() { - return; - } + public void stop() {} @Override public boolean isEnabled() { diff --git a/src/com/jedk1/jedcore/ability/earthbending/MetalArmor.java b/src/com/jedk1/jedcore/ability/earthbending/MetalArmor.java index c1f9e54..e431c9f 100644 --- a/src/com/jedk1/jedcore/ability/earthbending/MetalArmor.java +++ b/src/com/jedk1/jedcore/ability/earthbending/MetalArmor.java @@ -23,6 +23,7 @@ import java.util.List; public class MetalArmor extends EarthAbility implements AddonAbility { + private static final int GOLD_BLOCK_COLOR = 0xF2F204; private static final List METAL_COLORS = Arrays.asList( 0xa39d91, 0xf4f4f4, 0xa2a38f, 0xF2F204, 0xb75656, 0xfff4f4 @@ -173,16 +174,36 @@ public String getDescription() { return null; } - @Override - public void load() { + public boolean isUseIronArmor() { + return useIronArmor; + } + public void setUseIronArmor(boolean useIronArmor) { + this.useIronArmor = useIronArmor; } - @Override - public void stop() { + public int getResistStrength() { + return resistStrength; + } + + public void setResistStrength(int resistStrength) { + this.resistStrength = resistStrength; + } + public int getResistDuration() { + return resistDuration; } + public void setResistDuration(int resistDuration) { + this.resistDuration = resistDuration; + } + + @Override + public void load() {} + + @Override + public void stop() {} + @Override public boolean isEnabled() { ConfigurationSection config = JedCoreConfig.getConfig(this.player); diff --git a/src/com/jedk1/jedcore/ability/earthbending/MetalFragments.java b/src/com/jedk1/jedcore/ability/earthbending/MetalFragments.java index c0250e1..2b90463 100644 --- a/src/com/jedk1/jedcore/ability/earthbending/MetalFragments.java +++ b/src/com/jedk1/jedcore/ability/earthbending/MetalFragments.java @@ -41,11 +41,11 @@ public class MetalFragments extends MetalAbility implements AddonAbility { @Attribute(Attribute.COOLDOWN) private long cooldown; - public List sources = new ArrayList(); - private List thrownFragments = new ArrayList(); - private List tblockTracker = new ArrayList(); - //private List fblockTracker = new ArrayList(); - private HashMap counters = new HashMap(); + public List sources = new ArrayList<>(); + private final List thrownFragments = new ArrayList<>(); + private final List tblockTracker = new ArrayList<>(); + //private List fblockTracker = new ArrayList<>(); + private final HashMap counters = new HashMap<>(); public MetalFragments(Player player) { super(player); @@ -67,12 +67,14 @@ public MetalFragments(Player player) { if (prepare()) { Block b = selectSource(); - if (GeneralMethods.isRegionProtectedFromBuild(player, "MetalFragments", b.getLocation())) { - return; + if (GeneralMethods.isRegionProtectedFromBuild(player, "MetalFragments", b.getLocation())) { + return; } - translateUpward(b); start(); + if (!isRemoved()) { + translateUpward(b); + } } } @@ -86,48 +88,40 @@ public void setFields() { cooldown = config.getInt("Abilities.Earth.MetalFragments.Cooldown"); } - public static void shootFragment(Player player, boolean left) { + public static void shootFragment(Player player) { if (hasAbility(player, MetalFragments.class)) { - ((MetalFragments) getAbility(player, MetalFragments.class)).shootFragment(left); + getAbility(player, MetalFragments.class).shootFragment(); } } - private void shootFragment(boolean left) { + private void shootFragment() { if (sources.size() <= 0) return; Random randy = new Random(); int i = randy.nextInt(sources.size()); Block source = sources.get(i); - ItemStack is = null; + ItemStack is; switch (source.getType()) { - case IRON_BLOCK: - is = new ItemStack(Material.IRON_INGOT, 1); - break; - case GOLD_BLOCK: - is = new ItemStack(Material.GOLD_INGOT, 1); - break; - case IRON_ORE: - is = new ItemStack(Material.IRON_INGOT, 1); - break; - case GOLD_ORE: - is = new ItemStack(Material.GOLD_INGOT, 1); - break; - case COAL_BLOCK: - is = new ItemStack(Material.COAL, 1); - break; - case COAL_ORE: - is = new ItemStack(Material.COAL_ORE, 1); - break; - default: - is = new ItemStack(Material.IRON_INGOT, 1); - break; + case GOLD_BLOCK: + case GOLD_ORE: + is = new ItemStack(Material.GOLD_INGOT, 1); + break; + case COAL_BLOCK: + is = new ItemStack(Material.COAL, 1); + break; + case COAL_ORE: + is = new ItemStack(Material.COAL_ORE, 1); + break; + default: + is = new ItemStack(Material.IRON_INGOT, 1); + break; } Vector direction; - if (GeneralMethods.getTargetedEntity(player, 30, new ArrayList()) != null) { - direction = GeneralMethods.getDirection(source.getLocation(), GeneralMethods.getTargetedEntity(player, 30, new ArrayList()).getLocation()); + if (GeneralMethods.getTargetedEntity(player, 30, new ArrayList<>()) != null) { + direction = GeneralMethods.getDirection(source.getLocation(), GeneralMethods.getTargetedEntity(player, 30, new ArrayList<>()).getLocation()); } else { direction = GeneralMethods.getDirection(source.getLocation(), GeneralMethods.getTargetedLocation(player, 30)); } @@ -157,14 +151,13 @@ private void shootFragment(boolean left) { if (sources.size() == 0) { remove(); - return; } } } public static void selectAnotherSource(Player player) { if (hasAbility(player, MetalFragments.class)) { - ((MetalFragments) getAbility(player, MetalFragments.class)).selectAnotherSource(); + getAbility(player, MetalFragments.class).selectAnotherSource(); } } @@ -184,10 +177,7 @@ public boolean prepare() { if (block == null) return false; - if (isMetal(block)) - return true; - - return false; + return isMetal(block); } public Block selectSource() { @@ -228,9 +218,9 @@ public void progress() { return; } - Iterator itr = tblockTracker.iterator(); + Iterator itr = tblockTracker.iterator(); while (itr.hasNext()) { - TempBlock tb = (TempBlock)itr.next(); + TempBlock tb = itr.next(); if (player.getLocation().distance(tb.getLocation()) >= 10) { player.getWorld().spawnFallingBlock(tb.getLocation().add(0.5,0.0,0.5), tb.getBlockData()); sources.remove(tb.getBlock()); @@ -272,7 +262,6 @@ public void progress() { } //removeDeadFBlocks(); - return; } /* @@ -306,7 +295,7 @@ public void removeFragments() { public static void remove(Player player, Block block) { if (hasAbility(player, MetalFragments.class)) { - MetalFragments mf = (MetalFragments) getAbility(player, MetalFragments.class); + MetalFragments mf = getAbility(player, MetalFragments.class); if (mf.sources.contains(block)) { mf.remove(); } @@ -365,16 +354,68 @@ public String getDescription() { return "* JedCore Addon *\n" + config.getString("Abilities.Earth.MetalFragments.Description"); } - @Override - public void load() { - return; + public int getMaxSources() { + return maxSources; } - @Override - public void stop() { - return; + public void setMaxSources(int maxSources) { + this.maxSources = maxSources; + } + + public int getSelectRange() { + return selectRange; + } + + public void setSelectRange(int selectRange) { + this.selectRange = selectRange; + } + + public int getMaxFragments() { + return maxFragments; + } + + public void setMaxFragments(int maxFragments) { + this.maxFragments = maxFragments; + } + + public double getDamage() { + return damage; } + public void setDamage(double damage) { + this.damage = damage; + } + + public void setCooldown(long cooldown) { + this.cooldown = cooldown; + } + + public List getSources() { + return sources; + } + + public void setSources(List sources) { + this.sources = sources; + } + + public List getThrownFragments() { + return thrownFragments; + } + + public List getTblockTracker() { + return tblockTracker; + } + + public HashMap getCounters() { + return counters; + } + + @Override + public void load() {} + + @Override + public void stop() {} + @Override public boolean isEnabled() { ConfigurationSection config = JedCoreConfig.getConfig(this.player); diff --git a/src/com/jedk1/jedcore/ability/earthbending/MetalHook.java b/src/com/jedk1/jedcore/ability/earthbending/MetalHook.java index 4b78f15..3cbf551 100644 --- a/src/com/jedk1/jedcore/ability/earthbending/MetalHook.java +++ b/src/com/jedk1/jedcore/ability/earthbending/MetalHook.java @@ -31,10 +31,10 @@ public class MetalHook extends MetalAbility implements AddonAbility { @Attribute(Attribute.RANGE) private int range; @Attribute("MaxHooks") - private int maxhooks; + private int maxHooks; private int totalHooks; private int hooksUsed; - private boolean nosource; + private boolean noSource; private boolean barrierHooking; private boolean hasHook; @@ -43,8 +43,8 @@ public class MetalHook extends MetalAbility implements AddonAbility { private Location destination; - private ConcurrentHashMap hooks = new ConcurrentHashMap<>(); - private List hookIds = new ArrayList<>(); + private final ConcurrentHashMap hooks = new ConcurrentHashMap<>(); + private final List hookIds = new ArrayList<>(); public MetalHook(Player player) { super(player); @@ -78,9 +78,9 @@ public void setFields() { cooldown = config.getLong("Abilities.Earth.MetalHook.Cooldown"); range = config.getInt("Abilities.Earth.MetalHook.Range"); - maxhooks = config.getInt("Abilities.Earth.MetalHook.MaxHooks"); + maxHooks = config.getInt("Abilities.Earth.MetalHook.MaxHooks"); totalHooks = config.getInt("Abilities.Earth.MetalHook.TotalHooks"); - nosource = config.getBoolean("Abilities.Earth.MetalHook.RequireItem"); + noSource = config.getBoolean("Abilities.Earth.MetalHook.RequireItem"); barrierHooking = config.getBoolean("Abilities.Earth.MetalHook.BarrierHooking"); } @@ -144,8 +144,6 @@ public void progress() { if (hooks.get(a)) { target.add(GeneralMethods.getDirection(player.getEyeLocation(), a.getLocation())); } - } else { - hooks.remove(a); } } @@ -156,14 +154,14 @@ public void progress() { player.setFlying(false); double velocity = 0.8; - player.setVelocity(target.clone().normalize().multiply(velocity)); + GeneralMethods.setVelocity(this, player, target.clone().normalize().multiply(velocity)); } else if (player.getLocation().distance(destination) < 2 && player.getLocation().distance(destination) >= 1) { player.setFlying(false); double velocity = 0.35; - player.setVelocity(target.clone().normalize().multiply(velocity)); + GeneralMethods.setVelocity(this, player, target.clone().normalize().multiply(velocity)); } else { - player.setVelocity(new Vector(0, 0, 0)); + GeneralMethods.setVelocity(this, player, new Vector(0, 0, 0)); if (player.getAllowFlight()) { player.setFlying(true); @@ -199,7 +197,7 @@ public void launchHook() { Vector dir = GeneralMethods.getDirection(player.getEyeLocation(), GeneralMethods.getTargetedLocation(player, range)); - if (!hookIds.isEmpty() && hookIds.size() > (maxhooks - 1)) { + if (!hookIds.isEmpty() && hookIds.size() > (maxHooks - 1)) { for (Arrow a : hooks.keySet()) { if (a.getUniqueId().equals(hookIds.get(0))) { hooks.remove(a); @@ -229,7 +227,7 @@ public void removeAllArrows() { } public boolean hasRequiredInv() { - if (nosource) return true; + if (noSource) return true; if (player.getInventory().getChestplate() != null) { Material[] chestplates = {Material.IRON_CHESTPLATE, Material.CHAINMAIL_CHESTPLATE}; @@ -252,11 +250,11 @@ public boolean hasRequiredInv() { } public int getMaxHooks() { - return this.maxhooks; + return this.maxHooks; } public void setMaxHooks(int maxhooks) { - this.maxhooks = maxhooks; + this.maxHooks = maxhooks; } @Override @@ -300,16 +298,96 @@ public String getDescription() { return "* JedCore Addon *\n" + config.getString("Abilities.Earth.MetalHook.Description"); } - @Override - public void load() { + public void setCooldown(long cooldown) { + this.cooldown = cooldown; + } + public int getRange() { + return range; } - @Override - public void stop() { + public void setRange(int range) { + this.range = range; + } + + public int getTotalHooks() { + return totalHooks; + } + + public void setTotalHooks(int totalHooks) { + this.totalHooks = totalHooks; + } + + public int getHooksUsed() { + return hooksUsed; + } + public void setHooksUsed(int hooksUsed) { + this.hooksUsed = hooksUsed; } + public boolean isNoSource() { + return noSource; + } + + public void setNoSource(boolean noSource) { + this.noSource = noSource; + } + + public boolean isBarrierHooking() { + return barrierHooking; + } + + public void setBarrierHooking(boolean barrierHooking) { + this.barrierHooking = barrierHooking; + } + + public boolean isHasHook() { + return hasHook; + } + + public void setHasHook(boolean hasHook) { + this.hasHook = hasHook; + } + + public boolean isWasSprinting() { + return wasSprinting; + } + + public void setWasSprinting(boolean wasSprinting) { + this.wasSprinting = wasSprinting; + } + + public long getTime() { + return time; + } + + public void setTime(long time) { + this.time = time; + } + + public Location getDestination() { + return destination; + } + + public void setDestination(Location destination) { + this.destination = destination; + } + + public ConcurrentHashMap getHooks() { + return hooks; + } + + public List getHookIds() { + return hookIds; + } + + @Override + public void load() {} + + @Override + public void stop() {} + @Override public boolean isEnabled() { ConfigurationSection config = JedCoreConfig.getConfig(this.player); diff --git a/src/com/jedk1/jedcore/ability/earthbending/MetalShred.java b/src/com/jedk1/jedcore/ability/earthbending/MetalShred.java index bab32df..c41dcfb 100644 --- a/src/com/jedk1/jedcore/ability/earthbending/MetalShred.java +++ b/src/com/jedk1/jedcore/ability/earthbending/MetalShred.java @@ -44,13 +44,13 @@ public class MetalShred extends MetalAbility implements AddonAbility { private long lastExtendTime; private Block source; private Block lastBlock; - private List tblocks = new ArrayList(); + private final List tblocks = new ArrayList<>(); public MetalShred(Player player) { super(player); if (hasAbility(player, MetalShred.class)) { - ((MetalShred) getAbility(player, MetalShred.class)).remove(); + getAbility(player, MetalShred.class).remove(); } if (!bPlayer.canBend(this)) { @@ -202,22 +202,17 @@ private void peelCoil(Block b) { public static void startShred(Player player) { if (hasAbility(player, MetalShred.class)) { - ((MetalShred) getAbility(player, MetalShred.class)).startShred(); + getAbility(player, MetalShred.class).startShred(); } } private void startShred() { - if (!horizontal) { - started = true; - return; - } - started = true; } public static void extend(Player player) { if (hasAbility(player, MetalShred.class)) { - ((MetalShred) getAbility(player, MetalShred.class)).extend(); + getAbility(player, MetalShred.class).extend(); } } @@ -266,14 +261,14 @@ public void progress() { peelCoil(b); for (Entity e : GeneralMethods.getEntitiesAroundPoint(b.getLocation(), 2)) { - if(!(e instanceof LivingEntity) || e.getEntityId() == player.getEntityId()){ + if (!(e instanceof LivingEntity) || e.getEntityId() == player.getEntityId()) { continue; } - if(GeneralMethods.isRegionProtectedFromBuild(this, e.getLocation()) || ((e instanceof Player) && Commands.invincible.contains(((Player) e).getName()))){ + if (GeneralMethods.isRegionProtectedFromBuild(this, e.getLocation()) || ((e instanceof Player) && Commands.invincible.contains(e.getName()))) { continue; } DamageHandler.damageEntity(e, damage, this); - e.setVelocity(e.getVelocity().add(player.getLocation().getDirection().add(new Vector(0, 0.1, 0)))); + GeneralMethods.setVelocity(this, e, e.getVelocity().add(player.getLocation().getDirection().add(new Vector(0, 0.1, 0)))); } lastBlock = b; @@ -298,8 +293,6 @@ public void progress() { if (!isMetal(b)) { if (!ElementalAbility.isAir(b.getType())) { remove(); - return; - } return; } @@ -313,7 +306,6 @@ public void progress() { length++; lastBlock = b; } - return; } private void revertAll() { @@ -369,16 +361,121 @@ public String getDescription() { return "* JedCore Addon *\n" + config.getString("Abilities.Earth.MetalShred.Description"); } - @Override - public void load() { - return; + public int getSelectRange() { + return selectRange; + } + + public void setSelectRange(int selectRange) { + this.selectRange = selectRange; + } + + public int getExtendTick() { + return extendTick; + } + + public void setExtendTick(int extendTick) { + this.extendTick = extendTick; + } + + public double getDamage() { + return damage; + } + + public void setDamage(double damage) { + this.damage = damage; + } + + public boolean isHorizontal() { + return horizontal; + } + + public void setHorizontal(boolean horizontal) { + this.horizontal = horizontal; } @Override - public void stop() { - return; + public boolean isStarted() { + return started; + } + + public void setStarted(boolean started) { + this.started = started; + } + + public boolean isStop() { + return stop; } + public void setStop(boolean stop) { + this.stop = stop; + } + + public boolean isStopCoil() { + return stopCoil; + } + + public void setStopCoil(boolean stopCoil) { + this.stopCoil = stopCoil; + } + + public boolean isExtending() { + return extending; + } + + public void setExtending(boolean extending) { + this.extending = extending; + } + + public int getLength() { + return length; + } + + public void setLength(int length) { + this.length = length; + } + + public int getFullLength() { + return fullLength; + } + + public void setFullLength(int fullLength) { + this.fullLength = fullLength; + } + + public long getLastExtendTime() { + return lastExtendTime; + } + + public void setLastExtendTime(long lastExtendTime) { + this.lastExtendTime = lastExtendTime; + } + + public Block getSource() { + return source; + } + + public void setSource(Block source) { + this.source = source; + } + + public Block getLastBlock() { + return lastBlock; + } + + public void setLastBlock(Block lastBlock) { + this.lastBlock = lastBlock; + } + + public List getTblocks() { + return tblocks; + } + + @Override + public void load() {} + + @Override + public void stop() {} + @Override public boolean isEnabled() { ConfigurationSection config = JedCoreConfig.getConfig(this.player); diff --git a/src/com/jedk1/jedcore/ability/earthbending/MudSurge.java b/src/com/jedk1/jedcore/ability/earthbending/MudSurge.java index 90d260b..b8d9008 100644 --- a/src/com/jedk1/jedcore/ability/earthbending/MudSurge.java +++ b/src/com/jedk1/jedcore/ability/earthbending/MudSurge.java @@ -51,7 +51,6 @@ public class MudSurge extends EarthAbility implements AddonAbility { public static int surgeInterval = 300; public static int mudPoolRadius = 2; - public static long mudCreationInterval = 100; public static Material[] mudTypes = new Material[] { Material.SAND, Material.CLAY, Material.TERRACOTTA, Material.BLACK_TERRACOTTA, Material.BLUE_TERRACOTTA, Material.BROWN_TERRACOTTA, Material.CYAN_TERRACOTTA, Material.GRAY_TERRACOTTA, Material.GREEN_TERRACOTTA, @@ -67,20 +66,19 @@ public class MudSurge extends EarthAbility implements AddonAbility { private TempBlock sourceTB; private int wavesOnTheRun = 0; - private long lastSurgeTime = 0; private boolean mudFormed = false; private boolean doNotSurge = false; public boolean started = false; - private List mudArea = new ArrayList<>(); + private final List mudArea = new ArrayList<>(); private ListIterator mudAreaItr; - private List mudBlocks = new ArrayList<>(); - private List blind = new ArrayList<>(); - private List affectedEntities = new ArrayList<>(); + private final List mudBlocks = new ArrayList<>(); + private final List blind = new ArrayList<>(); + private final List affectedEntities = new ArrayList<>(); - private List fallingBlocks = new ArrayList<>(); + private final List fallingBlocks = new ArrayList<>(); - private Random rand = new Random(); + private final Random rand = new Random(); public MudSurge(Player player) { super(player); @@ -102,17 +100,17 @@ public MudSurge(Player player) { new CannotBendRemovalPolicy(this.bPlayer, this, true, true), new IsOfflineRemovalPolicy(this.player), new IsDeadRemovalPolicy(this.player), - new OutOfRangeRemovalPolicy(this.player, 25.0, () -> { - return this.source.getLocation(); - }), + new OutOfRangeRemovalPolicy(this.player, 25.0, () -> this.source.getLocation()), new SwappedSlotsRemovalPolicy<>(bPlayer, MudSurge.class) ); setFields(); if (getSource()) { - loadMudPool(); start(); + if (!isRemoved()) { + loadMudPool(); + } } } @@ -140,6 +138,7 @@ public void progress() { return; } + long lastSurgeTime = 0; if (mudFormed && started && System.currentTimeMillis() > lastSurgeTime + surgeInterval) { surge(); affect(); @@ -362,7 +361,7 @@ private void affect() { tfb.remove(); continue; } - if (GeneralMethods.isRegionProtectedFromBuild(this, e.getLocation()) || ((e instanceof Player) && Commands.invincible.contains(((Player) e).getName()))){ + if (GeneralMethods.isRegionProtectedFromBuild(this, e.getLocation()) || ((e instanceof Player) && Commands.invincible.contains(e.getName()))){ continue; } @@ -455,16 +454,189 @@ public String getDescription() { return "* JedCore Addon *\n" + config.getString("Abilities.Earth.MudSurge.Description"); } - @Override - public void load() { + public int getPrepareRange() { + return prepareRange; + } + + public void setPrepareRange(int prepareRange) { + this.prepareRange = prepareRange; + } + + public int getBlindChance() { + return blindChance; + } + + public void setBlindChance(int blindChance) { + this.blindChance = blindChance; + } + + public int getBlindTicks() { + return blindTicks; + } + + public void setBlindTicks(int blindTicks) { + this.blindTicks = blindTicks; + } + + public boolean isMultipleHits() { + return multipleHits; + } + + public void setMultipleHits(boolean multipleHits) { + this.multipleHits = multipleHits; + } + + public double getDamage() { + return damage; + } + + public void setDamage(double damage) { + this.damage = damage; + } + + public int getWaves() { + return waves; + } + + public void setWaves(int waves) { + this.waves = waves; + } + + public int getWaterSearchRadius() { + return waterSearchRadius; + } + + public void setWaterSearchRadius(int waterSearchRadius) { + this.waterSearchRadius = waterSearchRadius; + } + + public boolean isWetSource() { + return wetSource; + } + + public void setWetSource(boolean wetSource) { + this.wetSource = wetSource; + } + + public void setCooldown(long cooldown) { + this.cooldown = cooldown; + } + + public void setCollisionRadius(double collisionRadius) { + this.collisionRadius = collisionRadius; + } + + public static int getSurgeInterval() { + return surgeInterval; + } + + public static void setSurgeInterval(int surgeInterval) { + MudSurge.surgeInterval = surgeInterval; + } + + public static int getMudPoolRadius() { + return mudPoolRadius; + } + + public static void setMudPoolRadius(int mudPoolRadius) { + MudSurge.mudPoolRadius = mudPoolRadius; + } + + public static Material[] getMudTypes() { + return mudTypes; + } + + public static void setMudTypes(Material[] mudTypes) { + MudSurge.mudTypes = mudTypes; + } + + public CompositeRemovalPolicy getRemovalPolicy() { + return removalPolicy; + } + + public void setRemovalPolicy(CompositeRemovalPolicy removalPolicy) { + this.removalPolicy = removalPolicy; + } + + public void setSource(Block source) { + this.source = source; + } + + public TempBlock getSourceTB() { + return sourceTB; + } + + public void setSourceTB(TempBlock sourceTB) { + this.sourceTB = sourceTB; + } + + public int getWavesOnTheRun() { + return wavesOnTheRun; + } + + public void setWavesOnTheRun(int wavesOnTheRun) { + this.wavesOnTheRun = wavesOnTheRun; + } + + public boolean isMudFormed() { + return mudFormed; + } + + public void setMudFormed(boolean mudFormed) { + this.mudFormed = mudFormed; + } + + public boolean isDoNotSurge() { + return doNotSurge; + } + public void setDoNotSurge(boolean doNotSurge) { + this.doNotSurge = doNotSurge; } @Override - public void stop() { + public boolean isStarted() { + return started; + } + + public void setStarted(boolean started) { + this.started = started; + } + + public List getMudArea() { + return mudArea; + } + + public ListIterator getMudAreaItr() { + return mudAreaItr; + } + + public void setMudAreaItr(ListIterator mudAreaItr) { + this.mudAreaItr = mudAreaItr; + } + + public List getMudBlocks() { + return mudBlocks; + } + public List getBlind() { + return blind; } + public List getAffectedEntities() { + return affectedEntities; + } + + public List getFallingBlocks() { + return fallingBlocks; + } + + @Override + public void load() {} + + @Override + public void stop() {} + @Override public boolean isEnabled() { ConfigurationSection config = JedCoreConfig.getConfig(this.player); diff --git a/src/com/jedk1/jedcore/ability/earthbending/SandBlast.java b/src/com/jedk1/jedcore/ability/earthbending/SandBlast.java index b44a671..43630c9 100644 --- a/src/com/jedk1/jedcore/ability/earthbending/SandBlast.java +++ b/src/com/jedk1/jedcore/ability/earthbending/SandBlast.java @@ -41,7 +41,7 @@ public class SandBlast extends SandAbility implements AddonAbility { @Attribute(Attribute.COOLDOWN) private long cooldown; @Attribute(Attribute.SELECT_RANGE) - private double sourcerange; + private double sourceRange; @Attribute(Attribute.RANGE) private int range; @Attribute("MaxShots") @@ -54,9 +54,9 @@ public class SandBlast extends SandAbility implements AddonAbility { private int blasts; private boolean blasting; private Vector direction; - private TempBlock tempblock; - private List affectedEntities = new ArrayList<>(); - private List fallingBlocks = new ArrayList<>(); + private TempBlock tempBlock; + private final List affectedEntities = new ArrayList<>(); + private final List fallingBlocks = new ArrayList<>(); Random rand = new Random(); @@ -68,7 +68,7 @@ public SandBlast(Player player) { } if (hasAbility(player, SandBlast.class)) { - SandBlast sb = (SandBlast) getAbility(player, SandBlast.class); + SandBlast sb = getAbility(player, SandBlast.class); sb.remove(); } @@ -82,14 +82,14 @@ public void setFields() { ConfigurationSection config = JedCoreConfig.getConfig(this.player); cooldown = config.getLong("Abilities.Earth.SandBlast.Cooldown"); - sourcerange = config.getDouble("Abilities.Earth.SandBlast.SourceRange"); + sourceRange = config.getDouble("Abilities.Earth.SandBlast.SourceRange"); range = config.getInt("Abilities.Earth.SandBlast.Range"); maxBlasts = config.getInt("Abilities.Earth.SandBlast.MaxSandBlocks"); damage = config.getDouble("Abilities.Earth.SandBlast.Damage"); } private boolean prepare() { - source = BlockSource.getEarthSourceBlock(player, sourcerange, ClickType.SHIFT_DOWN); + source = BlockSource.getEarthSourceBlock(player, sourceRange, ClickType.SHIFT_DOWN); if (source != null) { if (isSand(source) && ElementalAbility.isAir(source.getRelative(BlockFace.UP).getType())) { @@ -97,7 +97,7 @@ private boolean prepare() { if (DensityShift.isPassiveSand(source)) { DensityShift.revertSand(source); } - tempblock = new TempBlock(source, Material.SANDSTONE, Material.SANDSTONE.createBlockData()); + tempBlock = new TempBlock(source, Material.SANDSTONE, Material.SANDSTONE.createBlockData()); return true; } } @@ -133,15 +133,15 @@ public void progress() { @Override public void remove() { - if (this.tempblock != null) { - this.tempblock.revertBlock(); + if (this.tempBlock != null) { + this.tempBlock.revertBlock(); } super.remove(); } public static void blastSand(Player player) { if (hasAbility(player, SandBlast.class)) { - SandBlast sb = (SandBlast) getAbility(player, SandBlast.class); + SandBlast sb = getAbility(player, SandBlast.class); if (sb.blasting) { return; } @@ -155,7 +155,7 @@ private void blastSand() { direction = GeneralMethods.getDirection(source.getLocation().clone().add(0, 1, 0), GeneralMethods.getTargetedLocation(player, range)).multiply(0.07); this.bPlayer.addCooldown(this); } - tempblock.revertBlock(); + tempBlock.revertBlock(); //FallingBlock fblock = source.getWorld().spawnFallingBlock(source.getLocation().clone().add(0, 1, 0), source.getType(), source.getData()); @@ -272,16 +272,104 @@ public String getDescription() { return "* JedCore Addon *\n" + config.getString("Abilities.Earth.SandBlast.Description"); } - @Override - public void load() { - return; + public void setCooldown(long cooldown) { + this.cooldown = cooldown; } - @Override - public void stop() { - return; + public double getSourceRange() { + return sourceRange; + } + + public void setSourceRange(double sourceRange) { + this.sourceRange = sourceRange; + } + + public int getRange() { + return range; + } + + public void setRange(int range) { + this.range = range; + } + + public int getMaxBlasts() { + return maxBlasts; + } + + public void setMaxBlasts(int maxBlasts) { + this.maxBlasts = maxBlasts; + } + + public static double getDamage() { + return damage; + } + + public static void setDamage(double damage) { + SandBlast.damage = damage; + } + + public Block getSource() { + return source; + } + + public void setSource(Block source) { + this.source = source; + } + + public BlockData getSourceData() { + return sourceData; + } + + public void setSourceData(BlockData sourceData) { + this.sourceData = sourceData; } + public int getBlasts() { + return blasts; + } + + public void setBlasts(int blasts) { + this.blasts = blasts; + } + + public boolean isBlasting() { + return blasting; + } + + public void setBlasting(boolean blasting) { + this.blasting = blasting; + } + + public Vector getDirection() { + return direction; + } + + public void setDirection(Vector direction) { + this.direction = direction; + } + + public TempBlock getTempBlock() { + return tempBlock; + } + + public void setTempBlock(TempBlock tempBlock) { + this.tempBlock = tempBlock; + } + + public List getAffectedEntities() { + return affectedEntities; + } + + public List getFallingBlocks() { + return fallingBlocks; + } + + @Override + public void load() {} + + @Override + public void stop() {} + @Override public boolean isEnabled() { ConfigurationSection config = JedCoreConfig.getConfig(this.player); diff --git a/src/com/jedk1/jedcore/ability/earthbending/combo/Crevice.java b/src/com/jedk1/jedcore/ability/earthbending/combo/Crevice.java index 5aab24b..d0cbcea 100644 --- a/src/com/jedk1/jedcore/ability/earthbending/combo/Crevice.java +++ b/src/com/jedk1/jedcore/ability/earthbending/combo/Crevice.java @@ -26,6 +26,7 @@ import java.util.Collections; import java.util.HashSet; import java.util.List; +import java.util.Objects; import java.util.Random; public class Crevice extends EarthAbility implements AddonAbility, ComboAbility { @@ -44,11 +45,10 @@ public class Crevice extends EarthAbility implements AddonAbility, ComboAbility private Vector direction; private double travelled; private boolean skip; - private long time; - private List> columns = new ArrayList<>(); + private final List> columns = new ArrayList<>(); - private Random rand = new Random(); + private final Random rand = new Random(); public Crevice(Player player) { super(player); @@ -57,7 +57,6 @@ public Crevice(Player player) { } setFields(); - time = System.currentTimeMillis(); createInstance(); } @@ -72,19 +71,21 @@ public void setFields() { } private void createInstance() { - origin = player.getTargetBlock((HashSet) null, (int) 6).getLocation(); + origin = player.getTargetBlock(null, 6).getLocation(); if (isEarthbendable(origin.getBlock())) { Location tempLoc = player.getLocation().clone(); tempLoc.setPitch(0); direction = tempLoc.getDirection().clone(); origin.setDirection(tempLoc.getDirection()); location = origin.clone(); - bPlayer.addCooldown(this); if (bPlayer.isAvatarState()) { randomDepth = avatarDepth; } start(); + if (!isRemoved()) { + bPlayer.addCooldown(this); + } } } @@ -96,7 +97,7 @@ public void progress() { return; } if (travelled >= range || skip) { - if (System.currentTimeMillis() > time + regenDelay) { + if (System.currentTimeMillis() > getStartTime() + regenDelay) { prepareRevert(); remove(); return; @@ -113,7 +114,7 @@ public void remove() { } public static void closeCrevice(Player player) { - Block target = player.getTargetBlock((HashSet) null, (int) 10); + Block target = player.getTargetBlock(null, 10); for (Block near : GeneralMethods.getBlocksAroundPoint(target.getLocation(), 2)) { for (Crevice c : getAbilities(Crevice.class)) { for (List tbs : c.columns) { @@ -192,7 +193,7 @@ private void removePillar(Location location, int depth) { Location tempLoc = location.clone().getBlock().getLocation(); tempLoc.add(0, 1, 0); for (int i = 0; i < depth + 1; i++) { - if (tempLoc.getY() < 2 || tempLoc.getY() > 255) { + if (tempLoc.getY() < Objects.requireNonNull(tempLoc.getWorld()).getMinHeight() || tempLoc.getY() > tempLoc.getWorld().getMaxHeight()) { break; } if (GeneralMethods.isRegionProtectedFromBuild(player, "Crevice", tempLoc)) { @@ -227,7 +228,7 @@ private void prepareRevert() { for (Entity entity : GeneralMethods.getEntitiesAroundPoint(tb.getLocation(), 1)) { entity.setVelocity(new Vector(0, 0.7, 0)); } - new RegenTempBlock(tb.getBlock(), Material.AIR, Material.AIR.createBlockData(), i * 50); + new RegenTempBlock(tb.getBlock(), Material.AIR, Material.AIR.createBlockData(), i * 50L); } } columns.clear(); @@ -240,7 +241,7 @@ public long getCooldown() { @Override public Location getLocation() { - return null; + return location; } @Override @@ -299,13 +300,71 @@ public String getVersion() { return JedCore.version; } - @Override - public void load() { + public double getRange() { + return range; } - @Override - public void stop() { + public void setRange(double range) { + this.range = range; + } + + public long getRegenDelay() { + return regenDelay; + } + + public void setRegenDelay(long regenDelay) { + this.regenDelay = regenDelay; + } + + public int getDepth() { + return randomDepth; + } + + public void setDepth(int depth) { + this.randomDepth = depth; + } + + public int getAvatarDepth() { + return avatarDepth; + } + + public void setAvatarDepth(int avatarDepth) { + this.avatarDepth = avatarDepth; + } + + public Location getOrigin() { + return origin; } + + public void setOrigin(Location origin) { + this.origin = origin; + } + + public Vector getDirection() { + return direction; + } + + public void setDirection(Vector direction) { + this.direction = direction; + } + + public double getDistanceTravelled() { + return travelled; + } + + public void setDistanceTravelled(double travelled) { + this.travelled = travelled; + } + + public List> getColumns() { + return columns; + } + + @Override + public void load() {} + + @Override + public void stop() {} @Override public boolean isEnabled() { diff --git a/src/com/jedk1/jedcore/ability/earthbending/combo/MagmaBlast.java b/src/com/jedk1/jedcore/ability/earthbending/combo/MagmaBlast.java index 3d5a97d..84de972 100644 --- a/src/com/jedk1/jedcore/ability/earthbending/combo/MagmaBlast.java +++ b/src/com/jedk1/jedcore/ability/earthbending/combo/MagmaBlast.java @@ -36,11 +36,11 @@ public class MagmaBlast extends LavaAbility implements AddonAbility, ComboAbility { private static final int PARTICLE_COUNT = 20; private static final int RAISE_HEIGHT = 3; - private static Random rand = new Random(); + private static final Random rand = new Random(); - private Set sources = new HashSet<>(); - private List blocks = new ArrayList<>(); - private List firedBlocks = new ArrayList<>(); + private final Set sources = new HashSet<>(); + private final List blocks = new ArrayList<>(); + private final List firedBlocks = new ArrayList<>(); @Attribute(Attribute.COOLDOWN) private long cooldown; @@ -96,7 +96,7 @@ public void setFields() { playerCollisions = config.getBoolean("Abilities.Earth.EarthCombo.MagmaBlast.PlayerCollisions"); entitySelection = config.getBoolean("Abilities.Earth.EarthCombo.MagmaBlast.EntitySelection"); selectRange = config.getDouble("Abilities.Earth.EarthCombo.MagmaBlast.SelectRange"); - explosionRadius = (float)config.getDouble("Abilities.Earth.EarthCombo.MagmaBlast.ExplosionRadius"); + explosionRadius = (float) config.getDouble("Abilities.Earth.EarthCombo.MagmaBlast.ExplosionRadius"); fireSpeed = config.getDouble("Abilities.Earth.EarthCombo.MagmaBlast.FireSpeed"); maxDuration = config.getLong("Abilities.Earth.EarthCombo.MagmaBlast.MaxDuration"); maxDistanceFromSources = config.getLong("Abilities.Earth.EarthCombo.MagmaBlast.MaxDistanceFromSources"); @@ -271,7 +271,7 @@ public boolean hasBlocks() { } private Location getOffsetLocation(Location loc, double offset) { - return loc.clone().add((float) ((Math.random() - 0.5)*offset), (float) ((Math.random() - 0.5)*offset), (float) ((Math.random() - 0.5)*offset)); + return loc.clone().add((float) ((Math.random() - 0.5) * offset), (float) ((Math.random() - 0.5) * offset), (float) ((Math.random() - 0.5) * offset)); } public static void performAction(Player player) { @@ -292,7 +292,7 @@ private void performAction() { if (entitySelection) { Entity targetEntity = GeneralMethods.getTargetedEntity(player, selectRange); - if (targetEntity != null && targetEntity instanceof LivingEntity) { + if (targetEntity instanceof LivingEntity) { target = ((LivingEntity) targetEntity).getEyeLocation(); } } @@ -334,8 +334,8 @@ private TempBlock getClosestSource(Location target) { return closest; } - public static boolean blast(TempFallingBlock tfb) { - return blast(tfb, false); + public static void blast(TempFallingBlock tfb) { + blast(tfb, false); } public static boolean blast(TempFallingBlock tfb, boolean entityCollision) { @@ -462,14 +462,136 @@ public String getVersion() { return JedCore.version; } - @Override - public void load() { + public Set getSources() { + return sources; } - @Override - public void stop() { + public List getBlocks() { + return blocks; + } + + public List getFiredBlocks() { + return firedBlocks; + } + + public long getMaxDuration() { + return maxDuration; + } + + public void setMaxDuration(long maxDuration) { + this.maxDuration = maxDuration; + } + + public long getShotCooldown() { + return shotCooldown; + } + + public void setShotCooldown(long shotCooldown) { + this.shotCooldown = shotCooldown; + } + + public int getMaxSources() { + return maxSources; + } + + public void setMaxSources(int maxSources) { + this.maxSources = maxSources; + } + + public int getSourceRange() { + return sourceRange; + } + + public void setSourceRange(int sourceRange) { + this.sourceRange = sourceRange; + } + + public double getSelectRange() { + return selectRange; + } + + public void setSelectRange(double selectRange) { + this.selectRange = selectRange; + } + + public double getFireSpeed() { + return fireSpeed; + } + + public void setFireSpeed(double fireSpeed) { + this.fireSpeed = fireSpeed; + } + + public double getMaxDistanceFromSources() { + return maxDistanceFromSources; + } + + public void setMaxDistanceFromSources(double maxDistanceFromSources) { + this.maxDistanceFromSources = maxDistanceFromSources; } + public float getExplosionRadius() { + return explosionRadius; + } + + public void setExplosionRadius(float explosionRadius) { + this.explosionRadius = explosionRadius; + } + + public boolean isRequireLavaFlow() { + return requireLavaFlow; + } + + public void setRequireLavaFlow(boolean requireLavaFlow) { + this.requireLavaFlow = requireLavaFlow; + } + + public boolean isPlayerCollisions() { + return playerCollisions; + } + + public void setPlayerCollisions(boolean playerCollisions) { + this.playerCollisions = playerCollisions; + } + + public boolean isEntitySelection() { + return entitySelection; + } + + public void setEntitySelection(boolean entitySelection) { + this.entitySelection = entitySelection; + } + + public Location getOrigin() { + return origin; + } + + public void setOrigin(Location origin) { + this.origin = origin; + } + + public long getCanLavaFlowTime() { + return canLavaFlowTime; + } + + public void setCanLavaFlowTime(long canLavaFlowTime) { + this.canLavaFlowTime = canLavaFlowTime; + } + + public long getLastShotTime() { + return lastShot; + } + + public void setLastShotTime(long lastShot) { + this.lastShot = lastShot; + } + + @Override + public void load() {} + + @Override + public void stop() {} + @Override public boolean isEnabled() { ConfigurationSection config = JedCoreConfig.getConfig(this.player); diff --git a/src/com/jedk1/jedcore/ability/firebending/Combustion.java b/src/com/jedk1/jedcore/ability/firebending/Combustion.java index a80d764..b53d666 100644 --- a/src/com/jedk1/jedcore/ability/firebending/Combustion.java +++ b/src/com/jedk1/jedcore/ability/firebending/Combustion.java @@ -35,6 +35,7 @@ import java.util.Random; public class Combustion extends CombustionAbility implements AddonAbility { + private State state; private Location location; @Attribute(Attribute.COOLDOWN) @@ -150,14 +151,10 @@ public String getDescription() { } @Override - public void load() { - - } + public void load() {} @Override - public void stop() { - - } + public void stop() {} @Override public boolean isEnabled() { @@ -174,11 +171,11 @@ private interface State { // This state transitions to TravelState if the player stops sneaking after charging is done. // This state transitions to CombustState if the player takes damage while charging. private class ChargeState implements State { - private long startTime; + private final long startTime; private int currPoint; - private long warmup; - private double playerStartHealth; - private boolean instantExplodeIfHit; + private final long warmup; + private final double playerStartHealth; + private final boolean instantExplodeIfHit; public ChargeState() { this.startTime = System.currentTimeMillis(); @@ -247,9 +244,9 @@ private void playParticleRing(int points, float size, int speed) { private class TravelState implements State { private Vector direction; private int ticks; - private int range; - private boolean explodeOnDeath; - private double entityCollisionRadius; + private final int range; + private final boolean explodeOnDeath; + private final double entityCollisionRadius; public TravelState() { removalPolicy.removePolicyType(SwappedSlotsRemovalPolicy.class); @@ -358,8 +355,8 @@ public void handleCollision(final Collision collision) { // ChargeState can transition to this state if the player takes damage while charging. // TravelState can transition to this state if the projectile collides with terrain, entity, or collidable ability. private class CombustState implements State { - private long startTime; - private long regenTime; + private final long startTime; + private final long regenTime; private boolean waitForRegen; public CombustState(Location location) { @@ -434,8 +431,8 @@ private abstract class AbstractExplosionMethod implements ExplosionMethod { Material.DISPENSER, Material.HOPPER, Material.BEACON, Material.BARRIER, Material.SPAWNER ); - private boolean destroy; - private Random rand = new Random(); + private final boolean destroy; + private final Random rand = new Random(); public AbstractExplosionMethod(boolean destroy) { this.destroy = destroy; @@ -520,7 +517,7 @@ protected void placeRandomBlock(Location location) { } private class RegenExplosionMethod extends AbstractExplosionMethod { - private long regenTime; + private final long regenTime; public RegenExplosionMethod(boolean destroy, long regenTime) { super(destroy); diff --git a/src/com/jedk1/jedcore/ability/firebending/Discharge.java b/src/com/jedk1/jedcore/ability/firebending/Discharge.java index 518e4f9..16e73c6 100644 --- a/src/com/jedk1/jedcore/ability/firebending/Discharge.java +++ b/src/com/jedk1/jedcore/ability/firebending/Discharge.java @@ -20,24 +20,24 @@ import java.util.ArrayList; import java.util.HashMap; +import java.util.Iterator; import java.util.List; import java.util.Random; public class Discharge extends LightningAbility implements AddonAbility { - private HashMap branches = new HashMap<>(); - - private long time; + private final HashMap branches = new HashMap<>(); + private Location location; private Vector direction; private boolean hit; private int spaces; private double branchSpace; - private Random rand = new Random(); + private final Random rand = new Random(); @Attribute(Attribute.DAMAGE) private double damage; @Attribute(Attribute.COOLDOWN) - private long cooldown, avatarcooldown; + private long cooldown, avatarCooldown; @Attribute(Attribute.DURATION) private long duration; private boolean slotSwapping; @@ -56,11 +56,13 @@ public Discharge(Player player) { direction = player.getEyeLocation().getDirection().normalize(); if (bPlayer.isAvatarState() || JCMethods.isSozinsComet(player.getWorld())) { - this.cooldown = avatarcooldown; + this.cooldown = avatarCooldown; } - bPlayer.addCooldown(this); start(); + if (!isRemoved()) { + bPlayer.addCooldown(this); + } } public void setFields() { @@ -68,13 +70,12 @@ public void setFields() { damage = config.getDouble("Abilities.Fire.Discharge.Damage"); cooldown = config.getLong("Abilities.Fire.Discharge.Cooldown"); - avatarcooldown = config.getLong("Abilities.Fire.Discharge.AvatarCooldown"); + avatarCooldown = config.getLong("Abilities.Fire.Discharge.AvatarCooldown"); duration = config.getLong("Abilities.Fire.Discharge.Duration"); slotSwapping = config.getBoolean("Abilities.Fire.Discharge.SlotSwapping"); entityCollisionRadius = config.getDouble("Abilities.Fire.Discharge.EntityCollisionRadius"); branchSpace = 0.2; - time = System.currentTimeMillis(); } @Override @@ -89,7 +90,7 @@ public void progress() { return; } - if (System.currentTimeMillis() < (time + duration) && !hit) { + if (System.currentTimeMillis() < (getStartTime() + duration) && !hit) { advanceLocation(); } else { remove(); @@ -98,29 +99,23 @@ public void progress() { private boolean canBend() { if (!slotSwapping) { - if (!bPlayer.canBendIgnoreCooldowns(this)) { - return false; - } + return bPlayer.canBendIgnoreCooldowns(this); } else { - if (!bPlayer.canBendIgnoreBindsCooldowns(this)) { - return false; - } + return bPlayer.canBendIgnoreBindsCooldowns(this); } - - return true; } private void advanceLocation() { if (location == null) { Location origin = player.getEyeLocation().clone(); location = origin.clone(); - branches.put(branches.size()+1, location); + branches.put(branches.size() + 1, location); } spaces++; if (spaces % 3 == 0) { Location prevBranch = branches.get(1); - branches.put(branches.size()+1, prevBranch); + branches.put(branches.size() + 1, prevBranch); } List cleanup = new ArrayList<>(); @@ -136,7 +131,7 @@ private void advanceLocation() { continue; } - l.add(createBranch(l.getX()), createBranch(l.getY()), createBranch(l.getZ())); + l.add(createBranch(), createBranch(), createBranch()); branchSpace += 0.001; for (int j = 0; j < 5; j++) { @@ -149,11 +144,11 @@ private void advanceLocation() { Vector vec = l.toVector(); hit = CollisionDetector.checkEntityCollisions(player, new Sphere(l.toVector(), entityCollisionRadius), (entity) -> { - if (GeneralMethods.isRegionProtectedFromBuild(this, entity.getLocation()) || ((entity instanceof Player) && Commands.invincible.contains(((Player) entity).getName()))){ + if (GeneralMethods.isRegionProtectedFromBuild(this, entity.getLocation()) || ((entity instanceof Player) && Commands.invincible.contains(entity.getName()))) { return true; } Vector knockbackVector = entity.getLocation().toVector().subtract(vec).normalize().multiply(0.8); - entity.setVelocity(knockbackVector); + GeneralMethods.setVelocity(this, entity, knockbackVector); DamageHandler.damageEntity(entity, damage, this); @@ -181,18 +176,16 @@ private void advanceLocation() { cleanup.clear(); } - private double createBranch(double start) { + private double createBranch() { int i = rand.nextInt(3); switch (i) { - case 0: - return branchSpace; - case 1: - return 0.0; - case 2: - return -branchSpace; - default: - return 0.0; + case 0: + return branchSpace; + case 2: + return -branchSpace; + default: + return 0.0; } } @@ -248,15 +241,95 @@ public String getDescription() { return "* JedCore Addon *\n" + config.getString("Abilities.Fire.Discharge.Description"); } - @Override - public void load() { + public HashMap getBranches() { + return branches; + } + public void setLocation(Location location) { + this.location = location; } - @Override - public void stop() { + public Vector getDirection() { + return direction; + } + + public void setDirection(Vector direction) { + this.direction = direction; + } + + public boolean isHit() { + return hit; + } + + public void setHit(boolean hit) { + this.hit = hit; + } + + public int getSpaces() { + return spaces; + } + + public void setSpaces(int spaces) { + this.spaces = spaces; + } + + public double getBranchSpace() { + return branchSpace; + } + + public void setBranchSpace(double branchSpace) { + this.branchSpace = branchSpace; + } + public double getDamage() { + return damage; } + + public void setDamage(double damage) { + this.damage = damage; + } + + public void setCooldown(long cooldown) { + this.cooldown = cooldown; + } + + public long getAvatarCooldown() { + return avatarCooldown; + } + + public void setAvatarCooldown(long avatarCooldown) { + this.avatarCooldown = avatarCooldown; + } + + public long getDuration() { + return duration; + } + + public void setDuration(long duration) { + this.duration = duration; + } + + public boolean isSlotSwapping() { + return slotSwapping; + } + + public void setSlotSwapping(boolean slotSwapping) { + this.slotSwapping = slotSwapping; + } + + public double getEntityCollisionRadius() { + return entityCollisionRadius; + } + + public void setEntityCollisionRadius(double entityCollisionRadius) { + this.entityCollisionRadius = entityCollisionRadius; + } + + @Override + public void load() {} + + @Override + public void stop() {} @Override public boolean isEnabled() { diff --git a/src/com/jedk1/jedcore/ability/firebending/FireBall.java b/src/com/jedk1/jedcore/ability/firebending/FireBall.java index 352ca65..ff892df 100644 --- a/src/com/jedk1/jedcore/ability/firebending/FireBall.java +++ b/src/com/jedk1/jedcore/ability/firebending/FireBall.java @@ -28,6 +28,7 @@ import com.projectkorra.projectkorra.util.ParticleEffect; public class FireBall extends FireAbility implements AddonAbility { + private Location location; private Vector direction; private double distanceTravelled; @@ -35,7 +36,7 @@ public class FireBall extends FireAbility implements AddonAbility { @Attribute(Attribute.RANGE) private long range; @Attribute(Attribute.FIRE_TICK) - private long fireticks; + private long fireTicks; @Attribute(Attribute.COOLDOWN) private long cooldown; @Attribute(Attribute.DAMAGE) @@ -45,7 +46,7 @@ public class FireBall extends FireAbility implements AddonAbility { @Attribute("CollisionRadius") private double collisionRadius; - public FireBall(Player player){ + public FireBall(Player player) { super(player); if (!bPlayer.canBend(this)) { return; @@ -56,15 +57,17 @@ public FireBall(Player player){ location = player.getEyeLocation(); direction = player.getEyeLocation().getDirection().normalize(); - bPlayer.addCooldown(this); start(); + if (!isRemoved()) { + bPlayer.addCooldown(this); + } } public void setFields() { ConfigurationSection config = JedCoreConfig.getConfig(this.player); range = config.getLong("Abilities.Fire.FireBall.Range"); - fireticks = config.getLong("Abilities.Fire.FireBall.FireDuration"); + fireTicks = config.getLong("Abilities.Fire.FireBall.FireDuration"); cooldown = config.getLong("Abilities.Fire.FireBall.Cooldown"); damage = config.getDouble("Abilities.Fire.FireBall.Damage"); controllable = config.getBoolean("Abilities.Fire.FireBall.Controllable"); @@ -90,12 +93,12 @@ private void applyModifiers() { @Override public void progress(){ - if(player.isDead() || !player.isOnline()){ + if (player.isDead() || !player.isOnline()) { remove(); return; } - if(distanceTravelled >= range){ + if (distanceTravelled >= range) { remove(); return; } @@ -108,8 +111,8 @@ public void progress(){ progressFireball(); } - private void progressFireball(){ - for(int i = 0; i < 2; i++){ + private void progressFireball() { + for (int i = 0; i < 2; i++) { distanceTravelled ++; if (distanceTravelled >= range) { return; @@ -119,8 +122,8 @@ private void progressFireball(){ direction = player.getLocation().getDirection(); } - location = location.add(direction.clone().multiply(1)); - if(GeneralMethods.isSolid(location.getBlock()) || isWater(location.getBlock())){ + location = location.add(direction); + if (GeneralMethods.isSolid(location.getBlock()) || isWater(location.getBlock())) { distanceTravelled = range; return; } @@ -144,13 +147,13 @@ private void progressFireball(){ } } - private boolean doDamage(Entity entity){ + private boolean doDamage(Entity entity) { if (!(entity instanceof LivingEntity)) return false; distanceTravelled = range; DamageHandler.damageEntity(entity, damage, this); - FireTick.set(entity, Math.round(fireticks / 50)); + FireTick.set(entity, Math.round(fireTicks / 50F)); new FireDamageTimer(entity, player); return false; } @@ -214,15 +217,84 @@ public String getDescription() { return "* JedCore Addon *\n" + config.getString("Abilities.Fire.FireBall.Description"); } - @Override - public void load() { - return; + public void setLocation(Location location) { + this.location = location; + } + + public Vector getDirection() { + return direction; + } + + public void setDirection(Vector direction) { + this.direction = direction; + } + + public double getDistanceTravelled() { + return distanceTravelled; + } + + public void setDistanceTravelled(double distanceTravelled) { + this.distanceTravelled = distanceTravelled; + } + + public long getRange() { + return range; + } + + public void setRange(long range) { + this.range = range; + } + + public long getFireTicks() { + return fireTicks; + } + + public void setFireTicks(long fireTicks) { + this.fireTicks = fireTicks; + } + + public void setCooldown(long cooldown) { + this.cooldown = cooldown; + } + + public double getDamage() { + return damage; + } + + public void setDamage(double damage) { + this.damage = damage; + } + + public boolean isControllable() { + return controllable; + } + + public void setControllable(boolean controllable) { + this.controllable = controllable; + } + + public boolean isFireTrail() { + return fireTrail; + } + + public void setFireTrail(boolean fireTrail) { + this.fireTrail = fireTrail; } @Override - public void stop() { - return; + public double getCollisionRadius() { + return collisionRadius; + } + + public void setCollisionRadius(double collisionRadius) { + this.collisionRadius = collisionRadius; } + + @Override + public void load() {} + + @Override + public void stop() {} @Override public boolean isEnabled() { diff --git a/src/com/jedk1/jedcore/ability/firebending/FireBreath.java b/src/com/jedk1/jedcore/ability/firebending/FireBreath.java index de2e5ef..6626362 100644 --- a/src/com/jedk1/jedcore/ability/firebending/FireBreath.java +++ b/src/com/jedk1/jedcore/ability/firebending/FireBreath.java @@ -3,6 +3,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Random; +import java.util.Set; import java.util.UUID; import com.jedk1.jedcore.JCMethods; @@ -34,11 +35,15 @@ public class FireBreath extends FireAbility implements AddonAbility { - public static List rainbowPlayer = new ArrayList(); + public static List rainbowPlayer = new ArrayList<>(); + private static boolean easterEgg; + private static String bindMsg; + private static String unbindMsg; + private static String deniedMsg; - private long time; private int ticks; Random rand = new Random(); + private final List locations = new ArrayList<>(); @Attribute(Attribute.COOLDOWN) private long cooldown; @@ -56,10 +61,7 @@ public class FireBreath extends FireAbility implements AddonAbility { private boolean spawnFire; private boolean meltEnabled; private int meltChance; - private static boolean easterEgg; - private static String bindMsg; - private static String unbindMsg; - private static String deniedMsg; + public FireBreath(Player player) { super(player); @@ -79,7 +81,6 @@ public FireBreath(Player player) { playerDamage = playerDamage * 1.5; mobDamage = mobDamage * 2; } - time = System.currentTimeMillis(); start(); } @@ -136,14 +137,12 @@ public void progress() { remove(); return; } - if (System.currentTimeMillis() < time + duration) { + if (System.currentTimeMillis() < getStartTime() + duration) { createBeam(); } else { bPlayer.addCooldown(this); remove(); - return; } - return; } private boolean isLocationSafe(Location loc) { @@ -154,10 +153,7 @@ private boolean isLocationSafe(Location loc) { if (!isTransparent(block)) { return false; } - if (isWater(block)) { - return false; - } - return true; + return !isWater(block); } private void createBeam() { @@ -166,15 +162,17 @@ private void createBeam() { double step = 1; double size = 0; double offset = 0; - double damageregion = 1.5; + double damageRegion = 1.5; + + locations.clear(); for (double k = 0; k < range; k += step) { loc = loc.add(dir.clone().multiply(step)); size += 0.005; offset += 0.3; - damageregion += 0.01; + damageRegion += 0.01; if (meltEnabled) { - for (Block b : GeneralMethods.getBlocksAroundPoint(loc, damageregion)) { + for (Block b : GeneralMethods.getBlocksAroundPoint(loc, damageRegion)) { if (isIce(b) && rand.nextInt(meltChance) == 0) { if (TempBlock.isTempBlock(b)) { TempBlock temp = TempBlock.get(b); @@ -188,7 +186,10 @@ private void createBeam() { } if (!isLocationSafe(loc)) return; - for (Entity entity : GeneralMethods.getEntitiesAroundPoint(loc, damageregion)) { + + locations.add(loc); + + for (Entity entity : GeneralMethods.getEntitiesAroundPoint(loc, damageRegion)) { if (entity instanceof LivingEntity && entity.getEntityId() != player.getEntityId()) { if (entity instanceof Player) { FireTick.set(entity, fireDuration / 50); @@ -228,7 +229,6 @@ private void createBeam() { for (int i = 0; i < 6; i++) displayParticle(getOffsetLocation(loc, offset), 1, 128, 36, 171); } - } else { playFirebendingParticles(loc, particles, Math.random(), Math.random(), Math.random()); ParticleEffect.SMOKE_NORMAL.display(loc, particles, Math.random(), Math.random(), Math.random(), size); @@ -247,10 +247,6 @@ private boolean isInRange(int x, int min, int max) { /** * Generates an offset location around a given location with variable offset * amount. - * - * @param loc - * @param offset - * @return */ private Location getOffsetLocation(Location loc, double offset) { return loc.clone().add((float) ((Math.random() - 0.5) * offset), (float) ((Math.random() - 0.5) * offset), (float) ((Math.random() - 0.5) * offset)); @@ -259,7 +255,8 @@ private Location getOffsetLocation(Location loc, double offset) { public static void toggleRainbowBreath(Player player, boolean activate) { if (easterEgg && (player.hasPermission("bending.ability.FireBreath.RainbowBreath") || player.getUniqueId().equals(UUID.fromString("4eb6315e-9dd1-49f7-b582-c1170e497ab0")) - || player.getUniqueId().equals(UUID.fromString("d57565a5-e6b0-44e3-a026-979d5de10c4d")))) { + || player.getUniqueId().equals(UUID.fromString("d57565a5-e6b0-44e3-a026-979d5de10c4d")) + || player.getUniqueId().equals(UUID.fromString("e98a2f7d-d571-4900-a625-483cbe6774fe")))) { if (activate) { if (!rainbowPlayer.contains(player.getUniqueId())) { rainbowPlayer.add(player.getUniqueId()); @@ -283,7 +280,12 @@ public long getCooldown() { @Override public Location getLocation() { - return null; + return player.getLocation(); + } + + @Override + public List getLocations() { + return locations; } @Override @@ -317,16 +319,136 @@ public String getDescription() { return "* JedCore Addon *\n" + config.getString("Abilities.Fire.FireBreath.Description"); } - @Override - public void load() { - return; + public static List getRainbowPlayer() { + return rainbowPlayer; } - @Override - public void stop() { - return; + public static void setRainbowPlayer(List rainbowPlayer) { + FireBreath.rainbowPlayer = rainbowPlayer; + } + + public int getTicks() { + return ticks; + } + + public void setTicks(int ticks) { + this.ticks = ticks; + } + + public void setCooldown(long cooldown) { + this.cooldown = cooldown; + } + + public long getDuration() { + return duration; + } + + public void setDuration(long duration) { + this.duration = duration; + } + + public int getParticles() { + return particles; + } + + public void setParticles(int particles) { + this.particles = particles; + } + + public double getPlayerDamage() { + return playerDamage; + } + + public void setPlayerDamage(double playerDamage) { + this.playerDamage = playerDamage; + } + + public double getMobDamage() { + return mobDamage; } + public void setMobDamage(double mobDamage) { + this.mobDamage = mobDamage; + } + + public int getFireDuration() { + return fireDuration; + } + + public void setFireDuration(int fireDuration) { + this.fireDuration = fireDuration; + } + + public int getRange() { + return range; + } + + public void setRange(int range) { + this.range = range; + } + + public boolean isSpawnFire() { + return spawnFire; + } + + public void setSpawnFire(boolean spawnFire) { + this.spawnFire = spawnFire; + } + + public boolean isMeltEnabled() { + return meltEnabled; + } + + public void setMeltEnabled(boolean meltEnabled) { + this.meltEnabled = meltEnabled; + } + + public int getMeltChance() { + return meltChance; + } + + public void setMeltChance(int meltChance) { + this.meltChance = meltChance; + } + + public static boolean isEasterEgg() { + return easterEgg; + } + + public static void setEasterEgg(boolean easterEgg) { + FireBreath.easterEgg = easterEgg; + } + + public static String getBindMsg() { + return bindMsg; + } + + public static void setBindMsg(String bindMsg) { + FireBreath.bindMsg = bindMsg; + } + + public static String getUnbindMsg() { + return unbindMsg; + } + + public static void setUnbindMsg(String unbindMsg) { + FireBreath.unbindMsg = unbindMsg; + } + + public static String getDeniedMsg() { + return deniedMsg; + } + + public static void setDeniedMsg(String deniedMsg) { + FireBreath.deniedMsg = deniedMsg; + } + + @Override + public void load() {} + + @Override + public void stop() {} + @Override public boolean isEnabled() { ConfigurationSection config = JedCoreConfig.getConfig(this.player); diff --git a/src/com/jedk1/jedcore/ability/firebending/FireComet.java b/src/com/jedk1/jedcore/ability/firebending/FireComet.java index e388d3a..bed8bb1 100644 --- a/src/com/jedk1/jedcore/ability/firebending/FireComet.java +++ b/src/com/jedk1/jedcore/ability/firebending/FireComet.java @@ -17,6 +17,7 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Sound; +import org.bukkit.SoundCategory; import org.bukkit.block.BlockState; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.Entity; @@ -26,6 +27,7 @@ import java.util.ArrayList; import java.util.List; +import java.util.Objects; import java.util.Random; public class FireComet extends FireAbility implements AddonAbility { @@ -52,10 +54,11 @@ public class FireComet extends FireAbility implements AddonAbility { private boolean fire; private long time; + private boolean charged; private int point; - private Random rand = new Random(); + private final Random rand = new Random(); public FireComet(Player player) { super(player); @@ -128,6 +131,11 @@ public void progress() { return; } + if (!charged) { + charged = true; + Objects.requireNonNull(location.getWorld()).playSound(location, Sound.ENTITY_GENERIC_EXPLODE, 2F, 0.8F); + } + if (!isFired()) { if (!player.isSneaking()) { vector = player.getLocation().getDirection(); @@ -212,8 +220,8 @@ public void blast() { playFirebendingParticles(location, 20, Math.random(), Math.random(), Math.random()); ParticleEffect.FIREWORKS_SPARK.display(location, 20, Math.random(), Math.random(), Math.random(), 0.5); - location.getWorld().playSound(location, (rand.nextBoolean()) ? Sound.ENTITY_FIREWORK_ROCKET_BLAST : Sound.ENTITY_FIREWORK_ROCKET_BLAST_FAR, 5f, 1f); - location.getWorld().playSound(location, Sound.ENTITY_GENERIC_EXPLODE, 5f, 0.8f); + location.getWorld().playSound(location, (rand.nextBoolean()) ? Sound.ENTITY_FIREWORK_ROCKET_BLAST : Sound.ENTITY_FIREWORK_ROCKET_BLAST_FAR, 5F, 1F); + location.getWorld().playSound(location, Sound.ENTITY_GENERIC_EXPLODE, 5F, 0.8F); int i = 0; for (BlockState block : blocks) { @@ -245,33 +253,36 @@ public void displayChargingAnim() { rotateAroundAxisX(v1, -xRotation); rotateAroundAxisY(v1, -((location.getYaw() * Math.PI / 180) - 1.575)); - if (bPlayer.canUseSubElement(SubElement.BLUE_FIRE)) { - ParticleEffect.SOUL_FIRE_FLAME.display(location.clone().add(v), 1, 0, 0, 0, 0.02); - ParticleEffect.SMOKE_LARGE.display(location.clone().add(v), 1, 0, 0, 0, 0.02); - ParticleEffect.SOUL_FIRE_FLAME.display(location.clone().add(v1), 1, 0, 0, 0, 0.01); - ParticleEffect.SMOKE_LARGE.display(location.clone().add(v1), 1, 0, 0, 0, 0.02); - } else { - ParticleEffect.FLAME.display(location.clone().add(v), 1, 0, 0, 0, 0.02); - ParticleEffect.SMOKE_LARGE.display(location.clone().add(v), 1, 0, 0, 0, 0.02); - ParticleEffect.FLAME.display(location.clone().add(v1), 1, 0, 0, 0, 0.01); - ParticleEffect.SMOKE_LARGE.display(location.clone().add(v1), 1, 0, 0, 0, 0.02); - } +// if (bPlayer.canUseSubElement(SubElement.BLUE_FIRE)) { +// ParticleEffect.SOUL_FIRE_FLAME.display(location.clone().add(v), 1, 0, 0, 0, 0.02); +// ParticleEffect.SMOKE_LARGE.display(location.clone().add(v), 1, 0, 0, 0, 0.02); +// ParticleEffect.SOUL_FIRE_FLAME.display(location.clone().add(v1), 1, 0, 0, 0, 0.01); +// } else { +// ParticleEffect.FLAME.display(location.clone().add(v), 1, 0, 0, 0, 0.02); +// ParticleEffect.SMOKE_LARGE.display(location.clone().add(v), 1, 0, 0, 0, 0.02); +// ParticleEffect.FLAME.display(location.clone().add(v1), 1, 0, 0, 0, 0.01); +// } + playFirebendingParticles(location.clone().add(v), 1, 0, 0, 0); + playFirebendingParticles(location.clone().add(v1), 1, 0, 0, 0); + ParticleEffect.SMOKE_LARGE.display(location.clone().add(v), 1, 0, 0, 0, 0.02); + ParticleEffect.SMOKE_LARGE.display(location.clone().add(v1), 1, 0, 0, 0, 0.02); if (this.angle == 360) { this.angle = 0; } long init = getTime() + getCharge(); - int percentage = (int) (((init - System.currentTimeMillis()) * 100)/getCharge()); - double size = (1-(percentage/100.0f)) * 1.5; + int percentage = (int) (((init - System.currentTimeMillis()) * 100) / getCharge()); + double size = (1 - (percentage / 100.0F)) * 1.5; for (int i = 0; i < 360; i += 45) { for (Location l : JCMethods.getVerticalCirclePoints(location.clone().subtract(0, size, 0), 45, size, i)) { - if (bPlayer.canUseSubElement(SubElement.BLUE_FIRE)) { - ParticleEffect.SOUL_FIRE_FLAME.display(l, 1, 0, 0, 0, 0.02); - } else { - ParticleEffect.FLAME.display(l, 1, 0, 0, 0, 0.02); - } +// if (bPlayer.canUseSubElement(SubElement.BLUE_FIRE)) { +// ParticleEffect.SOUL_FIRE_FLAME.display(l, 1, 0, 0, 0, 0.02); +// } else { +// ParticleEffect.FLAME.display(l, 1, 0, 0, 0, 0.02); +// } + playFirebendingParticles(l, 1, 0, 0, 0); } } @@ -281,13 +292,14 @@ public void displayChargingAnim() { } public void displayComet() { - for (int angle = 0; angle < 360; angle+=45) { + for (int angle = 0; angle < 360; angle += 45) { for (Location l : JCMethods.getVerticalCirclePoints(location.clone().subtract(0, 1.5, 0), 45, 1.5, angle)) { - if (bPlayer.canUseSubElement(SubElement.BLUE_FIRE)) { - ParticleEffect.SOUL_FIRE_FLAME.display(l, 1, 0, 0, 0, 0.05); - } else { - ParticleEffect.FLAME.display(l, 1, 0, 0, 0, 0.05); - } +// if (bPlayer.canUseSubElement(SubElement.BLUE_FIRE)) { +// ParticleEffect.SOUL_FIRE_FLAME.display(l, 1, 0, 0, 0, 0.05); +// } else { +// ParticleEffect.FLAME.display(l, 1, 0, 0, 0, 0.05); +// } + playFirebendingParticles(l, 1, 0, 0, 0); } } @@ -305,17 +317,19 @@ public void displayComet() { rotateAroundAxisX(v1, -xRotation); rotateAroundAxisY(v1, -((location.getYaw() * Math.PI / 180) - 1.575)); - if (bPlayer.canUseSubElement(SubElement.BLUE_FIRE)) { - ParticleEffect.SOUL_FIRE_FLAME.display(location.clone().add(v), 1, 0, 0, 0, 0.02); - ParticleEffect.SMOKE_LARGE.display(location.clone().add(v), 1, 0, 0, 0, 0.02); - ParticleEffect.SOUL_FIRE_FLAME.display(location.clone().add(v1), 1, 0, 0, 0, 0.01); - ParticleEffect.SMOKE_LARGE.display(location.clone().add(v1), 1, 0, 0, 0, 0.02); - } else { - ParticleEffect.FLAME.display(location.clone().add(v), 1, 0, 0, 0, 0.02); - ParticleEffect.SMOKE_LARGE.display(location.clone().add(v), 1, 0, 0, 0, 0.02); - ParticleEffect.FLAME.display(location.clone().add(v1), 1, 0, 0, 0, 0.01); - ParticleEffect.SMOKE_LARGE.display(location.clone().add(v1), 1, 0, 0, 0, 0.02); - } +// if (bPlayer.canUseSubElement(SubElement.BLUE_FIRE)) { +// ParticleEffect.SOUL_FIRE_FLAME.display(location.clone().add(v), 1, 0, 0, 0, 0.02); +// ParticleEffect.SMOKE_LARGE.display(location.clone().add(v), 1, 0, 0, 0, 0.02); +// ParticleEffect.SOUL_FIRE_FLAME.display(location.clone().add(v1), 1, 0, 0, 0, 0.01); +// } else { +// ParticleEffect.FLAME.display(location.clone().add(v), 1, 0, 0, 0, 0.02); +// ParticleEffect.SMOKE_LARGE.display(location.clone().add(v), 1, 0, 0, 0, 0.02); +// ParticleEffect.FLAME.display(location.clone().add(v1), 1, 0, 0, 0, 0.01); +// } + playFirebendingParticles(location.clone().add(v), 1, 0, 0, 0); + playFirebendingParticles(location.clone().add(v1), 1, 0, 0, 0); + ParticleEffect.SMOKE_LARGE.display(location.clone().add(v), 1, 0, 0, 0, 0.02); + ParticleEffect.SMOKE_LARGE.display(location.clone().add(v1), 1, 0, 0, 0, 0.02); } if (point == 360) { @@ -323,22 +337,22 @@ public void displayComet() { } } - private Vector rotateAroundAxisX(Vector v, double angle) { + private void rotateAroundAxisX(Vector v, double angle) { double cos = Math.cos(angle); double sin = Math.sin(angle); double y = v.getY() * cos - v.getZ() * sin; double z = v.getY() * sin + v.getZ() * cos; - return v.setY(y).setZ(z); + v.setY(y).setZ(z); } - private Vector rotateAroundAxisY(Vector v, double angle) { + private void rotateAroundAxisY(Vector v, double angle) { double cos = Math.cos(angle); double sin = Math.sin(angle); double x = v.getX() * cos + v.getZ() * sin; double z = v.getX() * -sin + v.getZ() * cos; - return v.setX(x).setZ(z); + v.setX(x).setZ(z); } @Override @@ -428,14 +442,10 @@ public String getDescription() { } @Override - public void load() { - - } + public void load() {} @Override - public void stop() { - - } + public void stop() {} @Override public boolean isEnabled() { diff --git a/src/com/jedk1/jedcore/ability/firebending/FirePunch.java b/src/com/jedk1/jedcore/ability/firebending/FirePunch.java index f451416..bf3ce92 100644 --- a/src/com/jedk1/jedcore/ability/firebending/FirePunch.java +++ b/src/com/jedk1/jedcore/ability/firebending/FirePunch.java @@ -1,121 +1,96 @@ package com.jedk1.jedcore.ability.firebending; -import java.util.ArrayList; -import java.util.List; -import java.util.UUID; - -import com.jedk1.jedcore.configuration.JedCoreConfig; -import com.jedk1.jedcore.util.FireTick; import org.bukkit.Location; -import org.bukkit.Server; -import org.bukkit.World; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.LivingEntity; import org.bukkit.entity.Player; -import org.bukkit.util.Vector; import com.jedk1.jedcore.JedCore; -import com.projectkorra.projectkorra.BendingPlayer; +import com.jedk1.jedcore.configuration.JedCoreConfig; +import com.jedk1.jedcore.util.FireTick; import com.projectkorra.projectkorra.Element; import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ability.AddonAbility; +import com.projectkorra.projectkorra.ability.BlueFireAbility; import com.projectkorra.projectkorra.ability.FireAbility; +import com.projectkorra.projectkorra.attribute.Attribute; import com.projectkorra.projectkorra.firebending.util.FireDamageTimer; import com.projectkorra.projectkorra.util.DamageHandler; import com.projectkorra.projectkorra.util.ParticleEffect; public class FirePunch extends FireAbility implements AddonAbility { - public static List recent = new ArrayList(); + @Attribute(Attribute.COOLDOWN) + private long cooldown; + @Attribute(Attribute.DAMAGE) + private double damage; + @Attribute(Attribute.FIRE_TICK) + private int fireTicks; + + private Location location; public FirePunch(Player player) { super(player); - if (!getRecent().contains(player.getUniqueId())) { - getRecent().add(player.getUniqueId()); - } - } - public static void display(Server server) { - if (!getEnabled()) return; + setFields(); - for (Player player : server.getOnlinePlayers()) { - BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); - if (bPlayer != null && bPlayer.canBend(getAbility("FirePunch"))) { - display(player); - } - } + start(); } - private static void display(Player player) { - Location offset = GeneralMethods.getRightSide(player.getLocation(), .55).add(0, 1.2, 0); - Vector dir = player.getEyeLocation().getDirection(); - Location righthand = offset.toVector().add(dir.clone().multiply(.8D)).toLocation(player.getWorld()); - BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); - ParticleEffect flame = bPlayer.hasSubElement(Element.BLUE_FIRE) ? ParticleEffect.SOUL_FIRE_FLAME : ParticleEffect.FLAME; - flame.display(righthand, 3, 0, 0, 0, 0); - ParticleEffect.SMOKE_NORMAL.display(righthand, 3, 0, 0, 0, 0); + private void setFields() { + ConfigurationSection config = JedCoreConfig.getConfig(player); + + cooldown = config.getLong("Abilities.Fire.FirePunch.Cooldown"); + damage = config.getDouble("Abilities.Fire.FirePunch.Damage"); + fireTicks = config.getInt("Abilities.Fire.FirePunch.FireTicks"); + + applyModifiers(); } - public static boolean punch(Player player, LivingEntity target) { - if (!getEnabled()) return false; - if (player == null || player.isDead() || !player.isOnline()) { - return false; - } - BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); - if (bPlayer.canBend(getAbility("FirePunch")) && getRecent().contains(player.getUniqueId())) { - bPlayer.addCooldown(getAbility("FirePunch"), getStaticCooldown(player.getWorld())); - getRecent().remove(player.getUniqueId()); - // playFirebendingParticles(target.getLocation().add(0, 1, 0), 1, 0f, 0f, 0f); - DamageAbility da = new DamageAbility(player); - da.remove(); - DamageHandler.damageEntity(target, getDamage(target.getWorld()), da); - - FireTick.set(target, getFireTicks(target.getWorld()) / 50); - if (getStaticCooldown(target.getWorld()) > getFireTicks(target.getWorld())) { - new FireDamageTimer(target, player); - } - return true; + private void applyModifiers() { + if (bPlayer.canUseSubElement(Element.BLUE_FIRE)) { + cooldown *= BlueFireAbility.getCooldownFactor(); + damage *= BlueFireAbility.getDamageFactor(); } - return false; - } - public static boolean getEnabled() { - ConfigurationSection config = JedCoreConfig.getConfig((World)null); - return config.getBoolean("Abilities.Fire.FirePunch.Enabled"); - } - - public static double getDamage(World world) { - ConfigurationSection config = JedCoreConfig.getConfig(world); - return config.getDouble("Abilities.Fire.FirePunch.Damage"); - } - - public static int getFireTicks(World world) { - ConfigurationSection config = JedCoreConfig.getConfig(world); - return config.getInt("Abilities.Fire.FirePunch.FireTicks"); - } - - public static long getStaticCooldown(World world) { - ConfigurationSection config = JedCoreConfig.getConfig(world); - return config.getLong("Abilities.Fire.FirePunch.Cooldown"); - } - - public static List getRecent() { - return recent; + if (isDay(player.getWorld())) { + cooldown -= ((long) getDayFactor(cooldown) - cooldown); + damage = getDayFactor(damage); + } } @Override public void progress() { + if (!player.isOnline() || player.isDead() || !bPlayer.canBend(this)) { + remove(); + return; + } + + location = GeneralMethods.getRightSide(player.getLocation(), 0.55) + .add(0, 1.2, 0) + .add(player.getLocation().getDirection().multiply(0.8)); + playFirebendingParticles(location, 3, 0, 0, 0); + ParticleEffect.SMOKE_LARGE.display(location, 3); + } + + public void punch(LivingEntity target) { + DamageHandler.damageEntity(target, damage, this); + FireTick.set(target, fireTicks / 50); + if (cooldown > fireTicks) { + new FireDamageTimer(target, player); + } + bPlayer.addCooldown(this); + remove(); } @Override public long getCooldown() { - ConfigurationSection config = JedCoreConfig.getConfig(this.player); - return config.getLong("Abilities.Fire.FirePunch.Cooldown"); + return cooldown; } @Override public Location getLocation() { - return null; + return location; } @Override @@ -149,58 +124,35 @@ public String getDescription() { return "* JedCore Addon *\n" + config.getString("Abilities.Fire.FirePunch.Description"); } - @Override - public void load() { - return; + public void setCooldown(long cooldown) { + this.cooldown = cooldown; } - @Override - public void stop() { - return; + public double getDamage() { + return damage; } - @Override - public boolean isEnabled() { - ConfigurationSection config = JedCoreConfig.getConfig(this.player); - return config.getBoolean("Abilities.Fire.FirePunch.Enabled"); + public void setDamage(double damage) { + this.damage = damage; } - - public static class DamageAbility extends FirePunch { - - public DamageAbility(Player player) { - super(player); - start(); - } - @Override - public long getCooldown() { - return 0; - } - - @Override - public Location getLocation() { - return null; - } + public int getFireTicks() { + return fireTicks; + } - @Override - public String getName() { - return "FirePunch"; - } + public void setFireTicks(int fireTicks) { + this.fireTicks = fireTicks; + } - @Override - public boolean isHarmlessAbility() { - return false; - } + @Override + public void load() {} - @Override - public boolean isSneakAbility() { - return false; - } + @Override + public void stop() {} - @Override - public void progress() { - remove(); - return; - } + @Override + public boolean isEnabled() { + ConfigurationSection config = JedCoreConfig.getConfig(this.player); + return config.getBoolean("Abilities.Fire.FirePunch.Enabled"); } } diff --git a/src/com/jedk1/jedcore/ability/firebending/FireShots.java b/src/com/jedk1/jedcore/ability/firebending/FireShots.java index 52a743e..aa7fd5a 100644 --- a/src/com/jedk1/jedcore/ability/firebending/FireShots.java +++ b/src/com/jedk1/jedcore/ability/firebending/FireShots.java @@ -1,9 +1,9 @@ package com.jedk1.jedcore.ability.firebending; import java.util.ArrayList; -import java.util.Iterator; import java.util.List; import java.util.Optional; +import java.util.stream.Collectors; import com.jedk1.jedcore.collision.CollisionDetector; import com.jedk1.jedcore.collision.Sphere; @@ -30,10 +30,9 @@ import com.projectkorra.projectkorra.util.ParticleEffect; import org.bukkit.util.Vector; -import static java.util.stream.Collectors.toList; - public class FireShots extends FireAbility implements AddonAbility { - private List shots = new ArrayList<>(); + + private final List shots = new ArrayList<>(); @Attribute(Attribute.COOLDOWN) private long cooldown; @Attribute("MaxShots") @@ -91,21 +90,21 @@ private void applyModifiers() { public class FireShot { - private Ability ability; - private Player player; + private final Ability ability; + private final Player player; private Location location; - private int range; - private int fireticks; + private final int range; + private final int fireTicks; private double distanceTravelled; - private double damage; + private final double damage; private Vector direction = null; - public FireShot(Ability ability, Player player, Location location, int range, int fireticks, double damage) { + public FireShot(Ability ability, Player player, Location location, int range, int fireTicks, double damage) { this.ability = ability; this.player = player; this.location = location; this.range = range; - this.fireticks = fireticks; + this.fireTicks = fireTicks; this.damage = damage; } @@ -143,7 +142,7 @@ public boolean progress() { boolean hit = CollisionDetector.checkEntityCollisions(player, collider, (entity) -> { DamageHandler.damageEntity(entity, damage, ability); - FireTick.set(entity, Math.round(fireticks / 50)); + FireTick.set(entity, Math.round(fireTicks / 50F)); new FireDamageTimer(entity, player); return true; }); @@ -154,6 +153,50 @@ public boolean progress() { } return true; } + + public Ability getAbility() { + return ability; + } + + public Player getPlayer() { + return player; + } + + public Location getLocation() { + return location; + } + + public void setLocation(Location location) { + this.location = location; + } + + public int getRange() { + return range; + } + + public int getFireTicks() { + return fireTicks; + } + + public double getDistanceTravelled() { + return distanceTravelled; + } + + public void setDistanceTravelled(double distanceTravelled) { + this.distanceTravelled = distanceTravelled; + } + + public double getDamage() { + return damage; + } + + public Vector getDirection() { + return direction; + } + + public void setDirection(Vector direction) { + this.direction = direction; + } } @Override @@ -170,13 +213,7 @@ public void progress() { } } - for (Iterator iterator = shots.iterator(); iterator.hasNext();) { - FireShot shot = iterator.next(); - - if (!shot.progress()) { - iterator.remove(); - } - } + shots.removeIf(shot -> !shot.progress()); if (amount <= 0 && shots.isEmpty()) { remove(); @@ -225,7 +262,9 @@ public Location getLocation() { @Override public List getLocations() { - return shots.stream().map(shot -> shot.location).collect(toList()); + List list = shots.stream().map(shot -> shot.location).collect(Collectors.toList()); + list.add(getRightHandPos()); + return list; } @Override @@ -233,9 +272,7 @@ public void handleCollision(Collision collision) { if (collision.isRemovingFirst()) { Optional collidedShot = shots.stream().filter(shot -> shot.location.equals(collision.getLocationFirst())).findAny(); - if (collidedShot.isPresent()) { - shots.remove(collidedShot.get()); - } + collidedShot.ifPresent(shots::remove); } else { CoreAbility second = collision.getAbilitySecond(); if (second instanceof AirShield) { @@ -288,15 +325,68 @@ public String getDescription() { return "* JedCore Addon *\n" + config.getString("Abilities.Fire.FireShots.Description"); } - @Override - public void load() { + public List getShots() { + return shots; + } + + public void setCooldown(long cooldown) { + this.cooldown = cooldown; + } + + public int getStartAmount() { + return startAmount; + } + + public void setStartAmount(int startAmount) { + this.startAmount = startAmount; + } + + public int getFireticks() { + return fireticks; + } + + public void setFireticks(int fireticks) { + this.fireticks = fireticks; + } + + public int getRange() { + return range; + } + + public void setRange(int range) { + this.range = range; + } + public double getDamage() { + return damage; + } + + public void setDamage(double damage) { + this.damage = damage; } @Override - public void stop() { + public double getCollisionRadius() { + return collisionRadius; + } + + public void setCollisionRadius(double collisionRadius) { + this.collisionRadius = collisionRadius; + } + + public int getAmount() { + return amount; + } + public void setAmount(int amount) { + this.amount = amount; } + + @Override + public void load() {} + + @Override + public void stop() {} @Override public boolean isEnabled() { diff --git a/src/com/jedk1/jedcore/ability/firebending/FireSki.java b/src/com/jedk1/jedcore/ability/firebending/FireSki.java index dd09523..1ea2ec0 100644 --- a/src/com/jedk1/jedcore/ability/firebending/FireSki.java +++ b/src/com/jedk1/jedcore/ability/firebending/FireSki.java @@ -24,7 +24,6 @@ public class FireSki extends FireAbility implements AddonAbility { private Location location; - private long time; @Attribute(Attribute.COOLDOWN) private long cooldown; @@ -61,7 +60,6 @@ public FireSki(Player player) { this.flightHandler.createInstance(player, this.getName()); - time = System.currentTimeMillis(); location = player.getLocation(); player.setAllowFlight(true); player.setFlying(true); @@ -115,23 +113,19 @@ public void progress() { } if (!collision()) { movePlayer(); - if (System.currentTimeMillis() > time + duration || isWater(player.getLocation().getBlock())) { + if (System.currentTimeMillis() > getStartTime() + duration || isWater(player.getLocation().getBlock())) { remove(); - return; } } else { remove(); - return; } - return; } private void movePlayer() { - location = player.getEyeLocation(); location.setPitch(0); Vector dV = location.getDirection().normalize(); - Vector travel = new Vector(); + Vector travel; if (getPlayerDistance() > 1.8) { removeFlight(); @@ -154,13 +148,13 @@ private void movePlayer() { } } - player.setVelocity(travel); + GeneralMethods.setVelocity(this, player, travel); player.setFallDistance(0); } private double getPlayerDistance() { Location l = player.getLocation().clone(); - while (l.getBlock() != null && l.getBlockY() > 1 && !GeneralMethods.isSolid(l.getBlock())) { + while (l.getBlockY() > l.getWorld().getMinHeight() && !GeneralMethods.isSolid(l.getBlock())) { l.add(0, -0.1, 0); } return player.getLocation().getY() - l.getY(); @@ -213,10 +207,7 @@ private boolean collision() { if (l.clone().add(0, -1, 0).getBlock().getType().isSolid()) { return true; } - if (l.clone().add(0, -2, 0).getBlock().getType().isSolid()) { - return true; - } - return false; + return l.clone().add(0, -2, 0).getBlock().getType().isSolid(); } @Override @@ -273,16 +264,60 @@ public String getDescription() { return null; } - @Override - public void load() { - return; + public void setLocation(Location location) { + this.location = location; } - @Override - public void stop() { - return; + public void setCooldown(long cooldown) { + this.cooldown = cooldown; + } + + public long getDuration() { + return duration; + } + + public void setDuration(long duration) { + this.duration = duration; + } + + public double getSpeed() { + return speed; + } + + public void setSpeed(double speed) { + this.speed = speed; } + public boolean isIgnite() { + return ignite; + } + + public void setIgnite(boolean ignite) { + this.ignite = ignite; + } + + public int getFireTicks() { + return fireTicks; + } + + public void setFireTicks(int fireTicks) { + this.fireTicks = fireTicks; + } + + public double getRequiredHeight() { + return requiredHeight; + } + + public void setRequiredHeight(double requiredHeight) { + this.requiredHeight = requiredHeight; + } + + @Override + public void load() {} + + @Override + public void stop() {} + @Override public boolean isEnabled() { ConfigurationSection config = JedCoreConfig.getConfig(this.player); diff --git a/src/com/jedk1/jedcore/ability/firebending/LightningBurst.java b/src/com/jedk1/jedcore/ability/firebending/LightningBurst.java index d6e1ff4..ac4c6d5 100644 --- a/src/com/jedk1/jedcore/ability/firebending/LightningBurst.java +++ b/src/com/jedk1/jedcore/ability/firebending/LightningBurst.java @@ -22,21 +22,19 @@ public class LightningBurst extends LightningAbility implements AddonAbility { - private static ConcurrentHashMap bolts = new ConcurrentHashMap(); + private static final ConcurrentHashMap BOLTS = new ConcurrentHashMap<>(); Random rand = new Random(); @Attribute(Attribute.COOLDOWN) - private long cooldown, avatarcooldown; + private long cooldown, avatarCooldown; @Attribute(Attribute.CHARGE_DURATION) - private long chargeup, avatarchargeup; + private long chargeUp, avatarChargeup; @Attribute(Attribute.DAMAGE) private double damage; @Attribute(Attribute.RADIUS) private double radius; - private long time; private boolean charged; - private int id; private static int ID = Integer.MIN_VALUE; public LightningBurst(Player player) { @@ -47,11 +45,10 @@ public LightningBurst(Player player) { setFields(); if (bPlayer.isAvatarState() || JCMethods.isSozinsComet(player.getWorld())) { - chargeup = avatarchargeup; - cooldown = avatarcooldown; - + chargeUp = avatarChargeup; + cooldown = avatarCooldown; } - time = System.currentTimeMillis(); + start(); } @@ -59,97 +56,13 @@ public void setFields() { ConfigurationSection config = JedCoreConfig.getConfig(this.player); cooldown = config.getLong("Abilities.Fire.LightningBurst.Cooldown"); - chargeup = config.getLong("Abilities.Fire.LightningBurst.ChargeUp"); - avatarcooldown = config.getLong("Abilities.Fire.LightningBurst.AvatarCooldown"); - avatarchargeup = config.getLong("Abilities.Fire.LightningBurst.AvatarChargeUp"); + chargeUp = config.getLong("Abilities.Fire.LightningBurst.ChargeUp"); + avatarCooldown = config.getLong("Abilities.Fire.LightningBurst.AvatarCooldown"); + avatarChargeup = config.getLong("Abilities.Fire.LightningBurst.AvatarChargeUp"); damage = config.getDouble("Abilities.Fire.LightningBurst.Damage"); radius = config.getDouble("Abilities.Fire.LightningBurst.Radius"); } - private void spawnBolt(Player player, Location location, double max, double gap, int arc, boolean dodamage){ - id = ID; - bolts.put(id, new Bolt(this, location, id, max, gap, arc, dodamage)); - if (ID == Integer.MAX_VALUE) - ID = Integer.MIN_VALUE; - ID++; - } - - public class Bolt { - - private LightningBurst ability; - private Location location; - private float initYaw; - private float initPitch; - private double step; - private double max; - private double gap; - private int id; - private int arc; - private boolean dodamage; - - public Bolt(LightningBurst ability, Location location, int id, double max, double gap, int arc, boolean dodamage) { - this.ability = ability; - this.location = location; - this.id = id; - this.max = max; - this.arc = arc; - this.gap = gap; - this.dodamage = dodamage; - initYaw = location.getYaw(); - initPitch = location.getPitch(); - } - - private void progress() { - if (this.step >= max) { - bolts.remove(id); - return; - } - if (GeneralMethods.isRegionProtectedFromBuild(player, "LightningBurst", location) || !isTransparent(location.getBlock())) { - bolts.remove(id); - return; - } - double step = 0.2; - for(double i = 0; i < gap; i+= step){ - this.step += step; - location = location.add(location.getDirection().clone().multiply(step)); - - playLightningbendingParticle(location, 0f, 0f, 0f); - } - switch (rand.nextInt(3)) { - case 0: - location.setYaw(initYaw - arc); - break; - case 1: - location.setYaw(initYaw + arc); - break; - default: - location.setYaw(initYaw); - break; - } - switch (rand.nextInt(3)) { - case 0: - location.setPitch(initPitch - arc); - break; - case 1: - location.setPitch(initPitch + arc); - break; - default: - location.setPitch(initPitch); - break; - } - - if(rand.nextInt(3) == 0) { - location.getWorld().playSound(location, Sound.ENTITY_CREEPER_PRIMED, 1, 0); - } - - for (Entity entity : GeneralMethods.getEntitiesAroundPoint(location, 2)) { - if (entity instanceof LivingEntity && entity.getEntityId() != player.getEntityId() && dodamage) { - DamageHandler.damageEntity(entity, damage, ability); - } - } - } - } - @Override public void progress() { if (player.isDead() || !player.isOnline()) { @@ -168,53 +81,54 @@ public void progress() { if (!isCharging()) { Location fake = player.getLocation().add(0, -2, 0); fake.setPitch(0); - for(int i = -180; i < 180; i += 55){ + for (int i = -180; i < 180; i += 55) { fake.setYaw(i); - for(double j = -180; j <= 180; j += 55){ + for (double j = -180; j <= 180; j += 55) { Location temp = fake.clone(); Vector dir = fake.getDirection().clone().multiply(2 * Math.cos(Math.toRadians(j))); temp.add(dir); temp.setY(temp.getY() + 2 + (2 * Math.sin(Math.toRadians(j)))); dir = GeneralMethods.getDirection(player.getLocation().add(0, 0, 0), temp); - spawnBolt(player, player.getLocation().clone().add(0, 1, 0).setDirection(dir), radius, 1, 20, true); + spawnBolt(player.getLocation().clone().add(0, 1, 0).setDirection(dir), radius, 1, 20, true); } } bPlayer.addCooldown(this); - remove(); - return; - } else { - remove(); - return; } - } else if (System.currentTimeMillis() > time + chargeup){ + remove(); + } else if (System.currentTimeMillis() > getStartTime() + chargeUp){ setCharging(false); displayCharging(); } - return; + } + + private void spawnBolt(Location location, double max, double gap, int arc, boolean doDamage) { + int id = ID; + BOLTS.put(id, new Bolt(this, location, id, max, gap, arc, doDamage)); + if (ID == Integer.MAX_VALUE) + ID = Integer.MIN_VALUE; + ID++; } private void displayCharging() { Location fake = player.getLocation().add(0, 0, 0); fake.setPitch(0); - for(int i = -180; i < 180; i += 55){ + for (int i = -180; i < 180; i += 55) { fake.setYaw(i); - for(double j = -180; j <= 180; j += 55){ + for (double j = -180; j <= 180; j += 55) { if (rand.nextInt(100) == 0) { Location temp = fake.clone(); Vector dir = fake.getDirection().clone().multiply(1.2 * Math.cos(Math.toRadians(j))); temp.add(dir); temp.setY(temp.getY() + 1.2 + (1.2 * Math.sin(Math.toRadians(j)))); dir = GeneralMethods.getDirection(temp, player.getLocation().add(0, 1, 0)); - spawnBolt(player, temp.setDirection(dir), 1, 0.2, 20, false); + spawnBolt(temp.setDirection(dir), 1, 0.2, 20, false); } } } } public static void progressAll() { - for (int id : bolts.keySet()) { - bolts.get(id).progress(); - } + BOLTS.values().forEach(Bolt::progress); } public boolean isCharging() { @@ -266,19 +180,183 @@ public String getDescription() { return "* JedCore Addon *\n" + config.getString("Abilities.Fire.LightningBurst.Description"); } - @Override - public void load() { - return; + public void setCooldown(long cooldown) { + this.cooldown = cooldown; } - @Override - public void stop() { - return; + public long getAvatarCooldown() { + return avatarCooldown; + } + + public void setAvatarCooldown(long avatarCooldown) { + this.avatarCooldown = avatarCooldown; + } + + public long getChargeUp() { + return chargeUp; } + + public void setChargeUp(long chargeUp) { + this.chargeUp = chargeUp; + } + + public long getAvatarChargeup() { + return avatarChargeup; + } + + public void setAvatarChargeup(long avatarChargeup) { + this.avatarChargeup = avatarChargeup; + } + + public double getDamage() { + return damage; + } + + public void setDamage(double damage) { + this.damage = damage; + } + + public double getRadius() { + return radius; + } + + public void setRadius(double radius) { + this.radius = radius; + } + + public boolean isCharged() { + return charged; + } + + public void setCharged(boolean charged) { + this.charged = charged; + } + + @Override + public void load() {} + + @Override + public void stop() {} @Override public boolean isEnabled() { ConfigurationSection config = JedCoreConfig.getConfig(this.player); return config.getBoolean("Abilities.Fire.LightningBurst.Enabled"); } + + public class Bolt { + + private final LightningBurst ability; + private Location location; + private final float initYaw; + private final float initPitch; + private double step; + private final double max; + private final double gap; + private final int id; + private final int arc; + private final boolean doDamage; + + public Bolt(LightningBurst ability, Location location, int id, double max, double gap, int arc, boolean doDamage) { + this.ability = ability; + this.location = location; + this.id = id; + this.max = max; + this.arc = arc; + this.gap = gap; + this.doDamage = doDamage; + initYaw = location.getYaw(); + initPitch = location.getPitch(); + } + + private void progress() { + if (this.step >= max) { + BOLTS.remove(id); + return; + } + if (GeneralMethods.isRegionProtectedFromBuild(player, "LightningBurst", location) || !isTransparent(location.getBlock())) { + BOLTS.remove(id); + return; + } + double step = 0.2; + for (double i = 0; i < gap; i+= step) { + this.step += step; + location = location.add(location.getDirection().clone().multiply(step)); + + playLightningbendingParticle(location, 0f, 0f, 0f); + } + switch (rand.nextInt(3)) { + case 0: + location.setYaw(initYaw - arc); + break; + case 1: + location.setYaw(initYaw + arc); + break; + default: + location.setYaw(initYaw); + break; + } + switch (rand.nextInt(3)) { + case 0: + location.setPitch(initPitch - arc); + break; + case 1: + location.setPitch(initPitch + arc); + break; + default: + location.setPitch(initPitch); + break; + } + + if (rand.nextInt(3) == 0) { + location.getWorld().playSound(location, Sound.ENTITY_CREEPER_PRIMED, 1, 0); + } + + for (Entity entity : GeneralMethods.getEntitiesAroundPoint(location, 2)) { + if (entity instanceof LivingEntity && entity.getEntityId() != player.getEntityId() && doDamage) { + DamageHandler.damageEntity(entity, damage, ability); + } + } + } + + public LightningBurst getAbility() { + return ability; + } + + public Location getLocation() { + return location; + } + + public float getInitYaw() { + return initYaw; + } + + public float getInitPitch() { + return initPitch; + } + + public double getStep() { + return step; + } + + public double getMax() { + return max; + } + + public double getGap() { + return gap; + } + + public int getId() { + return id; + } + + public int getArc() { + return arc; + } + + public boolean isDoDamage() { + return doDamage; + } + } } \ No newline at end of file diff --git a/src/com/jedk1/jedcore/ability/passive/WallRun.java b/src/com/jedk1/jedcore/ability/passive/WallRun.java index 992469d..a60418f 100644 --- a/src/com/jedk1/jedcore/ability/passive/WallRun.java +++ b/src/com/jedk1/jedcore/ability/passive/WallRun.java @@ -4,6 +4,7 @@ import com.jedk1.jedcore.JedCore; import com.jedk1.jedcore.configuration.JedCoreConfig; import com.projectkorra.projectkorra.Element; +import com.projectkorra.projectkorra.GeneralMethods; import com.projectkorra.projectkorra.ability.AddonAbility; import com.projectkorra.projectkorra.ability.AirAbility; import com.projectkorra.projectkorra.ability.ChiAbility; @@ -19,7 +20,6 @@ import org.bukkit.util.Vector; import java.util.List; -import java.util.Random; public class WallRun extends ChiAbility implements AddonAbility { @@ -39,10 +39,6 @@ public class WallRun extends ChiAbility implements AddonAbility { private List invalid; - private long time; - - Random rand = new Random(); - public WallRun(Player player) { super(player); @@ -52,7 +48,7 @@ public WallRun(Player player) { if (bPlayer.isOnCooldown("WallRun")) return; if (hasAbility(player, WallRun.class)) { - ((WallRun) getAbility(player, WallRun.class)).remove(); + getAbility(player, WallRun.class).remove(); return; } @@ -60,8 +56,6 @@ public WallRun(Player player) { return; } - time = System.currentTimeMillis(); - if (isEligible() && !JCMethods.isDisabledWorld(player.getWorld())) { start(); } @@ -98,11 +92,7 @@ private boolean isEligible() { return true; } else if (bPlayer.getElements().contains(Element.FIRE) && fire) { return true; - } else if (bPlayer.getElements().contains(Element.CHI) && chi) { - return true; - } - - return false; + } else return bPlayer.getElements().contains(Element.CHI) && chi; } private boolean isAgainstWall() { @@ -113,10 +103,7 @@ private boolean isAgainstWall() { return true; } else if (location.getBlock().getRelative(BlockFace.WEST).getType().isSolid() && !invalid.contains(location.getBlock().getRelative(BlockFace.WEST).getType().name())) { return true; - } else if (location.getBlock().getRelative(BlockFace.EAST).getType().isSolid() && !invalid.contains(location.getBlock().getRelative(BlockFace.EAST).getType().name())) { - return true; - } - return false; + } else return location.getBlock().getRelative(BlockFace.EAST).getType().isSolid() && !invalid.contains(location.getBlock().getRelative(BlockFace.EAST).getType().name()); } @Override @@ -129,12 +116,12 @@ public void progress() { remove(); return; } - if (System.currentTimeMillis() > time + duration) { + if (System.currentTimeMillis() > getStartTime() + duration) { remove(); return; } - if (System.currentTimeMillis() - time > 50L) { + if (System.currentTimeMillis() - getStartTime() > 50L) { bPlayer.addCooldown("WallRun", getCooldown()); } @@ -146,7 +133,7 @@ public void progress() { Vector dir = player.getLocation().getDirection(); dir.multiply(1.15); - player.setVelocity(dir); + GeneralMethods.setVelocity(this, player, dir); } public long getCooldown() { @@ -191,16 +178,84 @@ public String getVersion() { public String getDescription() { return "To use WallRun, sprint towards a wall, jump, then rapidly click to activate. You don't have to bind this ability to use it. It is a passive."; } - - @Override - public void load() { - return; + + public void setCooldown(long cooldown) { + this.cooldown = cooldown; } - @Override - public void stop() { - return; + public long getDuration() { + return duration; + } + + public void setDuration(long duration) { + this.duration = duration; + } + + public void setEnabled(boolean enabled) { + this.enabled = enabled; + } + + public boolean hasParticles() { + return particles; + } + + public void setHasParticles(boolean particles) { + this.particles = particles; + } + + public boolean allowsAir() { + return air; + } + + public void setAllowsAir(boolean air) { + this.air = air; + } + + public boolean allowsEarth() { + return earth; + } + + public void setAllowsEarth(boolean earth) { + this.earth = earth; + } + + public boolean allowsWater() { + return water; + } + + public void setAllowsWater(boolean water) { + this.water = water; + } + + public boolean allowsFire() { + return fire; + } + + public void setAllowsFire(boolean fire) { + this.fire = fire; } + + public boolean allowsChi() { + return chi; + } + + public void setAllowsChi(boolean chi) { + this.chi = chi; + } + + public List getInvalid() { + return invalid; + } + + public void setInvalid(List invalid) { + this.invalid = invalid; + } + + @Override + public void load() {} + + @Override + public void stop() {} @Override public boolean isEnabled() { diff --git a/src/com/jedk1/jedcore/ability/waterbending/BloodPuppet.java b/src/com/jedk1/jedcore/ability/waterbending/BloodPuppet.java index 1f30d38..f8075e4 100644 --- a/src/com/jedk1/jedcore/ability/waterbending/BloodPuppet.java +++ b/src/com/jedk1/jedcore/ability/waterbending/BloodPuppet.java @@ -6,7 +6,6 @@ import com.projectkorra.projectkorra.ability.ElementalAbility; import com.projectkorra.projectkorra.attribute.Attribute; import org.bukkit.Location; -import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; import org.bukkit.entity.*; import org.bukkit.potion.Potion; @@ -22,22 +21,20 @@ import com.projectkorra.projectkorra.command.Commands; import com.projectkorra.projectkorra.util.DamageHandler; -@SuppressWarnings("deprecation") public class BloodPuppet extends BloodAbility implements AddonAbility { private boolean nightOnly; private boolean fullMoonOnly; private boolean undeadMobs; - private boolean bloodpuppetThroughBlocks; + private boolean bloodPuppetThroughBlocks; private boolean requireBound; private int distance; @Attribute(Attribute.DURATION) - private long holdtime; + private long holdTime; @Attribute(Attribute.COOLDOWN) private long cooldown; - private long time; - private long damagecd = 0; + private long endTime; public LivingEntity puppet; private long lastDamageTime = 0; @@ -51,7 +48,7 @@ public BloodPuppet(Player player) { } setFields(); - time = System.currentTimeMillis() + holdtime; + endTime = System.currentTimeMillis() + holdTime; if (grab()) { start(); @@ -64,10 +61,10 @@ public void setFields() { nightOnly = config.getBoolean("Abilities.Water.BloodPuppet.NightOnly"); fullMoonOnly = config.getBoolean("Abilities.Water.BloodPuppet.FullMoonOnly"); undeadMobs = config.getBoolean("Abilities.Water.BloodPuppet.UndeadMobs"); - bloodpuppetThroughBlocks = config.getBoolean("Abilities.Water.BloodPuppet.IgnoreWalls"); + bloodPuppetThroughBlocks = config.getBoolean("Abilities.Water.BloodPuppet.IgnoreWalls"); requireBound = config.getBoolean("Abilities.Water.BloodPuppet.RequireBound"); distance = config.getInt("Abilities.Water.BloodPuppet.Distance"); - holdtime = config.getLong("Abilities.Water.BloodPuppet.HoldTime"); + holdTime = config.getLong("Abilities.Water.BloodPuppet.HoldTime"); cooldown = config.getLong("Abilities.Water.BloodPuppet.Cooldown"); } @@ -83,67 +80,45 @@ public boolean isEligible(Player player, boolean hasAbility) { private boolean canAttack() { switch (puppet.getType()) { - case CREEPER: - break; - case SKELETON: - return true; - case SPIDER: - return true; - case GIANT: - return true; - case ZOMBIE: - return true; - case SLIME: - return true; - case GHAST: - return true; - case PIGLIN: - return true; - case ZOMBIFIED_PIGLIN: - return true; - case ENDERMAN: - return true; - case CAVE_SPIDER: - return true; - case SILVERFISH: - return true; - case BLAZE: - return true; - case MAGMA_CUBE: - return true; - case WITCH: - return true; - case ENDERMITE: - return true; - case DROWNED: - return true; - case PLAYER: - return true; - default: - break; + case SKELETON: + case SPIDER: + case GIANT: + case ZOMBIE: + case SLIME: + case GHAST: + case PIGLIN: + case ZOMBIFIED_PIGLIN: + case ENDERMAN: + case CAVE_SPIDER: + case SILVERFISH: + case BLAZE: + case MAGMA_CUBE: + case WITCH: + case ENDERMITE: + case DROWNED: + case PLAYER: + return true; + default: + return false; } - - return false; } private boolean grab() { - List entities = new ArrayList(); + List entities = new ArrayList<>(); for (int i = 1; i < distance; i++) { - Location location = null; - if (bloodpuppetThroughBlocks) { - location = player.getTargetBlock((HashSet) null, i).getLocation(); + Location location; + if (bloodPuppetThroughBlocks) { + location = player.getTargetBlock(null, i).getLocation(); } else { location = GeneralMethods.getTargetedLocation(player, i, ElementalAbility.getTransparentMaterials()); } entities = GeneralMethods.getEntitiesAroundPoint(location, 1.7); - if (entities.contains(player)) { - entities.remove(player); - } - if (entities != null && !entities.isEmpty() && !entities.contains(player)) { + entities.remove(player); + if (!entities.isEmpty() && !entities.contains(player)) { break; } } - if (entities == null || entities.isEmpty()) { + if (entities.isEmpty()) { return false; } Entity e = entities.get(0); @@ -192,14 +167,10 @@ private boolean canBeBloodbent(Player player) { if (bPlayer.getAbilities().containsValue("Bloodbending")) { return false; } - if (bPlayer.getAbilities().containsValue("BloodPuppet")) { - return false; - } + return !bPlayer.getAbilities().containsValue("BloodPuppet"); } else { if (bPlayer.canBind(getAbility("Bloodbending")) && bPlayer.canBloodbend()) { - if ((!isDay(player.getWorld()) || bPlayer.canBloodbendAtAnytime())) { - return false; - } + return isDay(player.getWorld()) && !bPlayer.canBloodbendAtAnytime(); } } return true; @@ -207,7 +178,7 @@ private boolean canBeBloodbent(Player player) { public static void attack(Player player) { if (hasAbility(player, BloodPuppet.class)) { - ((BloodPuppet) getAbility(player, BloodPuppet.class)).attack(); + getAbility(player, BloodPuppet.class).attack(); } } @@ -215,14 +186,14 @@ private void attack() { if (!canAttack()) return; - if (System.currentTimeMillis() > lastDamageTime + damagecd) { + long damageCd = 0; + if (System.currentTimeMillis() > lastDamageTime + damageCd) { lastDamageTime = System.currentTimeMillis(); if (puppet instanceof Skeleton) { Skeleton skelly = (Skeleton) puppet; List nearby = GeneralMethods.getEntitiesAroundPoint(skelly.getLocation(), 5); - if (nearby.contains(puppet)) - nearby.remove(puppet); + nearby.remove(puppet); if (nearby.size() < 1) return; int randy = rand.nextInt(nearby.size()); @@ -235,20 +206,17 @@ private void attack() { if (e instanceof Creature) ((Creature) e).setTarget(puppet); } - return; } else if (puppet instanceof Creeper) { Creeper creep = (Creeper) puppet; creep.setPowered(true); - return; } else if (puppet instanceof Ghast) { Ghast gaga = (Ghast) puppet; List nearby = GeneralMethods.getEntitiesAroundPoint(gaga.getLocation(), 5); - if (nearby.contains(puppet)) - nearby.remove(puppet); + nearby.remove(puppet); if (nearby.size() < 1) return; int randy = rand.nextInt(nearby.size()); @@ -263,15 +231,12 @@ else if (puppet instanceof Ghast) { if (e instanceof Creature) ((Creature) e).setTarget(puppet); } - - return; } else if (puppet instanceof Blaze) { Blaze balawalaze = (Blaze) puppet; List nearby = GeneralMethods.getEntitiesAroundPoint(balawalaze.getLocation(), 5); - if (nearby.contains(puppet)) - nearby.remove(puppet); + nearby.remove(puppet); if (nearby.size() < 1) return; int randy = rand.nextInt(nearby.size()); @@ -285,23 +250,18 @@ else if (puppet instanceof Blaze) { if (e instanceof Creature) ((Creature) e).setTarget(puppet); } - - return; } else if (puppet instanceof Witch) { Witch missmagus = (Witch) puppet; List nearby = GeneralMethods.getEntitiesAroundPoint(missmagus.getLocation(), 5); - if (nearby.contains(puppet)) - nearby.remove(puppet); + nearby.remove(puppet); if (nearby.size() < 1) return; int randy = rand.nextInt(nearby.size()); Entity target = nearby.get(randy); if (target instanceof LivingEntity) { LivingEntity e = (LivingEntity) target; - @SuppressWarnings("unused") - Location loc = puppet.getLocation().getBlock().getRelative(GeneralMethods.getCardinalDirection(GeneralMethods.getDirection(puppet.getEyeLocation(), e.getEyeLocation()))).getLocation(); ThrownPotion tp = missmagus.launchProjectile(ThrownPotion.class, GeneralMethods.getDirection(puppet.getEyeLocation(), e.getEyeLocation())); Potion potion = new Potion(PotionType.INSTANT_DAMAGE); potion.setSplash(true); @@ -311,8 +271,6 @@ else if (puppet instanceof Witch) { if (e instanceof Creature) ((Creature) e).setTarget(puppet); } - - return; } else { @@ -325,7 +283,7 @@ else if (puppet instanceof Witch) { if (puppet instanceof Player) { Player p = (Player) puppet; - switch (p.getItemInHand().getType()) { + switch (p.getInventory().getItemInMainHand().getType()) { case WOODEN_SWORD: case GOLDEN_SWORD: damage = 5; @@ -368,7 +326,7 @@ public void progress() { return; } - if (System.currentTimeMillis() > time) { + if (System.currentTimeMillis() > endTime) { remove(); return; } @@ -378,14 +336,14 @@ public void progress() { return; } - Location newlocation = puppet.getLocation(); + Location newLocation = puppet.getLocation(); Location location = GeneralMethods.getTargetedLocation(player, distance + 1); - double distance = location.distance(newlocation); + double distance = location.distance(newLocation); double dx, dy, dz; - dx = location.getX() - newlocation.getX(); - dy = location.getY() - newlocation.getY(); - dz = location.getZ() - newlocation.getZ(); + dx = location.getX() - newLocation.getX(); + dy = location.getY() - newLocation.getY(); + dz = location.getZ() - newLocation.getZ(); Vector vector = new Vector(dx, dy, dz); if (distance > .5) { puppet.setVelocity(vector.normalize().multiply(.5)); @@ -397,7 +355,6 @@ public void progress() { ((Creature) puppet).setTarget(null); } AirAbility.breakBreathbendingHold(puppet); - return; } @Override @@ -405,7 +362,7 @@ public void remove() { if (player.isOnline()) { bPlayer.addCooldown(this); } - if (puppet instanceof Player && puppet != null && ((Player) puppet).isOnline()) { + if (puppet instanceof Player && ((Player) puppet).isOnline()) { BendingPlayer.getBendingPlayer((Player) puppet).unblockChi(); } super.remove(); @@ -452,15 +409,95 @@ public String getDescription() { return "* JedCore Addon *\n" + config.getString("Abilities.Water.BloodPuppet.Description"); } - @Override - public void load() { - return; + public boolean isNightOnly() { + return nightOnly; } - @Override - public void stop() { - return; + public void setNightOnly(boolean nightOnly) { + this.nightOnly = nightOnly; + } + + public boolean isFullMoonOnly() { + return fullMoonOnly; + } + + public void setFullMoonOnly(boolean fullMoonOnly) { + this.fullMoonOnly = fullMoonOnly; + } + + public boolean isUndeadMobs() { + return undeadMobs; + } + + public void setUndeadMobs(boolean undeadMobs) { + this.undeadMobs = undeadMobs; + } + + public boolean canBloodPuppetThroughBlocks() { + return bloodPuppetThroughBlocks; + } + + public void setCanBloodPuppetThroughBlocks(boolean bloodPuppetThroughBlocks) { + this.bloodPuppetThroughBlocks = bloodPuppetThroughBlocks; + } + + public boolean requiresBound() { + return requireBound; } + + public void setRequireBound(boolean requireBound) { + this.requireBound = requireBound; + } + + public int getDistance() { + return distance; + } + + public void setDistance(int distance) { + this.distance = distance; + } + + public long getHoldTime() { + return holdTime; + } + + public void setHoldTime(long holdTime) { + this.holdTime = holdTime; + } + + public void setCooldown(long cooldown) { + this.cooldown = cooldown; + } + + public long getEndTime() { + return endTime; + } + + public void setEndTime(long endTime) { + this.endTime = endTime; + } + + public LivingEntity getPuppet() { + return puppet; + } + + public void setPuppet(LivingEntity puppet) { + this.puppet = puppet; + } + + public long getLastDamageTime() { + return lastDamageTime; + } + + public void setLastDamageTime(long lastDamageTime) { + this.lastDamageTime = lastDamageTime; + } + + @Override + public void load() {} + + @Override + public void stop() {} @Override public boolean isEnabled() { diff --git a/src/com/jedk1/jedcore/ability/waterbending/Bloodbending.java b/src/com/jedk1/jedcore/ability/waterbending/Bloodbending.java index 8a336ad..5960651 100644 --- a/src/com/jedk1/jedcore/ability/waterbending/Bloodbending.java +++ b/src/com/jedk1/jedcore/ability/waterbending/Bloodbending.java @@ -14,8 +14,6 @@ import com.projectkorra.projectkorra.object.HorizontalVelocityTracker; import com.projectkorra.projectkorra.util.DamageHandler; -import org.bukkit.Bukkit; -import org.bukkit.ChatColor; import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.configuration.ConfigurationSection; @@ -36,7 +34,7 @@ public class Bloodbending extends BloodAbility implements AddonAbility { private boolean requireBound; private int distance; @Attribute(Attribute.DURATION) - private long holdtime; + private long holdTime; @Attribute(Attribute.COOLDOWN) private long cooldown; @@ -51,7 +49,7 @@ public Bloodbending(Player player) { return; } setFields(); - time = System.currentTimeMillis() + holdtime; + time = System.currentTimeMillis() + holdTime; if (grab()) { start(); } @@ -66,7 +64,7 @@ public void setFields() { bloodbendingThroughBlocks = config.getBoolean("Abilities.Water.Bloodbending.IgnoreWalls"); requireBound = config.getBoolean("Abilities.Water.Bloodbending.RequireBound"); distance = config.getInt("Abilities.Water.Bloodbending.Distance"); - holdtime = config.getLong("Abilities.Water.Bloodbending.HoldTime"); + holdTime = config.getLong("Abilities.Water.Bloodbending.HoldTime"); cooldown = config.getLong("Abilities.Water.Bloodbending.Cooldown"); } @@ -82,7 +80,7 @@ public boolean isEligible(Player player, boolean hasAbility) { public static void launch(Player player) { if (hasAbility(player, Bloodbending.class)) { - ((Bloodbending) getAbility(player, Bloodbending.class)).launch(); + getAbility(player, Bloodbending.class).launch(); } } @@ -100,11 +98,11 @@ private void launch() { } private boolean grab() { - List entities = new ArrayList(); + List entities = new ArrayList<>(); for (int i = 1; i < distance; i++) { Location location; if (bloodbendingThroughBlocks) { - location = player.getTargetBlock((HashSet) null, i).getLocation(); + location = player.getTargetBlock(null, i).getLocation(); } else { location = GeneralMethods.getTargetedLocation(player, i, ElementalAbility.getTransparentMaterials()); } @@ -164,14 +162,10 @@ private boolean canBeBloodbent(Player player) { if (bPlayer.getAbilities().containsValue("Bloodbending")) { return false; } - if (bPlayer.getAbilities().containsValue("BloodPuppet")) { - return false; - } + return !bPlayer.getAbilities().containsValue("BloodPuppet"); } else { if (bPlayer.canBind(getAbility("Bloodbending")) && bPlayer.canBloodbend()) { - if ((!isDay(player.getWorld()) || bPlayer.canBloodbendAtAnytime())) { - return false; - } + return isDay(player.getWorld()) && !bPlayer.canBloodbendAtAnytime(); } } return true; @@ -278,15 +272,103 @@ public String getDescription() { return "* JedCore Addon *\n" + config.getString("Abilities.Water.Bloodbending.Description"); } - @Override - public void load() { - return; + public boolean isNightOnly() { + return nightOnly; } - @Override - public void stop() { - return; + public void setNightOnly(boolean nightOnly) { + this.nightOnly = nightOnly; + } + + public boolean isFullMoonOnly() { + return fullMoonOnly; + } + + public void setFullMoonOnly(boolean fullMoonOnly) { + this.fullMoonOnly = fullMoonOnly; + } + + public boolean isUndeadMobs() { + return undeadMobs; + } + + public void setUndeadMobs(boolean undeadMobs) { + this.undeadMobs = undeadMobs; + } + + public boolean isBloodbendingThroughBlocks() { + return bloodbendingThroughBlocks; + } + + public void setBloodbendingThroughBlocks(boolean bloodbendingThroughBlocks) { + this.bloodbendingThroughBlocks = bloodbendingThroughBlocks; + } + + public boolean isRequireBound() { + return requireBound; + } + + public void setRequireBound(boolean requireBound) { + this.requireBound = requireBound; + } + + public int getDistance() { + return distance; + } + + public void setDistance(int distance) { + this.distance = distance; + } + + public long getHoldTime() { + return holdTime; + } + + public void setHoldTime(long holdTime) { + this.holdTime = holdTime; + } + + public void setCooldown(long cooldown) { + this.cooldown = cooldown; + } + + public long getTime() { + return time; + } + + public void setTime(long time) { + this.time = time; + } + + public LivingEntity getVictim() { + return victim; + } + + public void setVictim(LivingEntity victim) { + this.victim = victim; } + + public BendingPlayer getVictimBPlayer() { + return victimBPlayer; + } + + public void setVictimBPlayer(BendingPlayer victimBPlayer) { + this.victimBPlayer = victimBPlayer; + } + + public boolean isGrabbed() { + return grabbed; + } + + public void setGrabbed(boolean grabbed) { + this.grabbed = grabbed; + } + + @Override + public void load() {} + + @Override + public void stop() {} @Override public boolean isEnabled() { diff --git a/src/com/jedk1/jedcore/ability/waterbending/Drain.java b/src/com/jedk1/jedcore/ability/waterbending/Drain.java index a8c074e..d875c5c 100644 --- a/src/com/jedk1/jedcore/ability/waterbending/Drain.java +++ b/src/com/jedk1/jedcore/ability/waterbending/Drain.java @@ -32,7 +32,8 @@ import java.util.Random; public class Drain extends WaterAbility implements AddonAbility { - private List locations = new ArrayList<>(); + + private final List locations = new ArrayList<>(); private static final Biome[] INVALID_BIOMES = { Biome.DESERT, Biome.BASALT_DELTAS, @@ -72,13 +73,13 @@ public class Drain extends WaterAbility implements AddonAbility { private boolean drainTemps; - private long time; + private long endTime; private int absorbed = 0; private int charge = 7; private boolean noFill; private int blasts; private boolean hasCharge; - private Material[] fillables = { Material.GLASS_BOTTLE, Material.BUCKET }; + private final Material[] fillables = { Material.GLASS_BOTTLE, Material.BUCKET }; Random rand = new Random(); @@ -89,7 +90,7 @@ public Drain(Player player) { } setFields(); this.usePlants = bPlayer.canPlantbend(); - time = System.currentTimeMillis() + duration; + endTime = System.currentTimeMillis() + duration; if (!canFill()) { if (!blastsEnabled) return; @@ -155,7 +156,7 @@ public void progress() { remove(); return; } - if (System.currentTimeMillis() > time) { + if (System.currentTimeMillis() > endTime) { bPlayer.addCooldown(this); remove(); return; @@ -192,12 +193,11 @@ public void progress() { } } dragWater(); - return; } public static void fireBlast(Player player) { if (hasAbility(player, Drain.class)) { - ((Drain) getAbility(player, Drain.class)).fireBlast(); + getAbility(player, Drain.class).fireBlast(); } } @@ -214,9 +214,7 @@ private void displayWaterSource() { Location location = player.getEyeLocation().add(player.getLocation().getDirection().multiply(holdRange)); if (!GeneralMethods.isSolid(location.getBlock()) || isTransparent(location.getBlock())) { Block block = location.getBlock(); - //revert.put(block, 0l); - //new TempBlock(block, Material.STATIONARY_WATER, (byte) charge); - new RegenTempBlock(block, Material.WATER, Material.WATER.createBlockData(bd -> ((Levelled)bd).setLevel(charge)), 100l); + new RegenTempBlock(block, Material.WATER, Material.WATER.createBlockData(bd -> ((Levelled)bd).setLevel(charge)), 100L); } } @@ -267,7 +265,7 @@ private void checkForValidSource() { List locs = GeneralMethods.getCircle(player.getLocation(), radius, radius, false, true, 0); for (int i = 0; i < locs.size(); i++) { Block block = locs.get(rand.nextInt(locs.size()-1)).getBlock(); - if (block != null && block.getY() > 2 && block.getY() < 255) { + if (block.getY() > block.getWorld().getMinHeight() && block.getY() < block.getWorld().getMaxHeight()) { if (rand.nextInt(chance) == 0) { Biome biome = player.getLocation().getBlock().getBiome(); if (useRain && player.getWorld().hasStorm() && isValidBiome(biome)) { @@ -306,8 +304,6 @@ private boolean isObstructed(Location location1, Location location2) { for (double i = 1; i <= max; i++) { loc = location1.clone().add(direction.clone().multiply(i)); - //Material type = loc.getBlock().getType(); - //if (type != Material.AIR && !Arrays.asList(plantIds).contains(type.getId()) && !isWater(loc.getBlock())) if (!isTransparent(loc.getBlock())) return true; } @@ -320,17 +316,13 @@ private void drainPlant(Block block) { if (JCMethods.isSmallPlant(block.getRelative(BlockFace.DOWN))) { if (JCMethods.isDoublePlant(block.getType())) { block = block.getRelative(BlockFace.DOWN); - //revert.put(block, System.currentTimeMillis() + regenDelay); locations.add(block.getLocation().clone().add(.5, .5, .5)); - //new TempBlock(block, Material.DEAD_BUSH, (byte) 0); new RegenTempBlock(block, Material.DEAD_BUSH, Material.DEAD_BUSH.createBlockData(), regenDelay); return; } block = block.getRelative(BlockFace.DOWN); } - //revert.put(block, System.currentTimeMillis() + regenDelay); locations.add(block.getLocation().clone().add(.5, .5, .5)); - //new TempBlock(block, Material.DEAD_BUSH, (byte) 0); new RegenTempBlock(block, Material.DEAD_BUSH, Material.DEAD_BUSH.createBlockData(), regenDelay); } } @@ -347,7 +339,7 @@ private void drainWater(Block block) { } private void dragWater() { - List toRemove = new ArrayList(); + List toRemove = new ArrayList<>(); if (!locations.isEmpty()) { for (Location l : locations) { Location playerLoc = player.getLocation().add(0, 1, 0); @@ -414,15 +406,200 @@ public String getDescription() { } @Override - public void load() { - return; + public List getLocations() { + return locations; } - @Override - public void stop() { - return; + public long getRegenDelay() { + return regenDelay; + } + + public void setRegenDelay(long regenDelay) { + this.regenDelay = regenDelay; + } + + public long getDuration() { + return duration; + } + + public void setDuration(long duration) { + this.duration = duration; + } + + public void setCooldown(long cooldown) { + this.cooldown = cooldown; + } + + public double getAbsorbSpeed() { + return absorbSpeed; + } + + public void setAbsorbSpeed(double absorbSpeed) { + this.absorbSpeed = absorbSpeed; + } + + public int getRadius() { + return radius; + } + + public void setRadius(int radius) { + this.radius = radius; + } + + public int getChance() { + return chance; + } + + public void setChance(int chance) { + this.chance = chance; + } + + public int getAbsorbRate() { + return absorbRate; + } + + public void setAbsorbRate(int absorbRate) { + this.absorbRate = absorbRate; + } + + public int getHoldRange() { + return holdRange; + } + + public void setHoldRange(int holdRange) { + this.holdRange = holdRange; + } + + public boolean isBlastsEnabled() { + return blastsEnabled; + } + + public void setBlastsEnabled(boolean blastsEnabled) { + this.blastsEnabled = blastsEnabled; + } + + public int getMaxBlasts() { + return maxBlasts; + } + + public void setMaxBlasts(int maxBlasts) { + this.maxBlasts = maxBlasts; + } + + public boolean isKeepSrc() { + return keepSrc; + } + + public void setKeepSrc(boolean keepSrc) { + this.keepSrc = keepSrc; + } + + public boolean isUseRain() { + return useRain; + } + + public void setUseRain(boolean useRain) { + this.useRain = useRain; + } + + public boolean isUsePlants() { + return usePlants; } + public void setUsePlants(boolean usePlants) { + this.usePlants = usePlants; + } + + public double getBlastRange() { + return blastRange; + } + + public void setBlastRange(double blastRange) { + this.blastRange = blastRange; + } + + public double getBlastDamage() { + return blastDamage; + } + + public void setBlastDamage(double blastDamage) { + this.blastDamage = blastDamage; + } + + public double getBlastSpeed() { + return blastSpeed; + } + + public void setBlastSpeed(double blastSpeed) { + this.blastSpeed = blastSpeed; + } + + public boolean isDrainTemps() { + return drainTemps; + } + + public void setDrainTemps(boolean drainTemps) { + this.drainTemps = drainTemps; + } + + public long getEndTime() { + return endTime; + } + + public void setEndTime(long endTime) { + this.endTime = endTime; + } + + public int getAbsorbed() { + return absorbed; + } + + public void setAbsorbed(int absorbed) { + this.absorbed = absorbed; + } + + public int getCharge() { + return charge; + } + + public void setCharge(int charge) { + this.charge = charge; + } + + public boolean isNoFill() { + return noFill; + } + + public void setNoFill(boolean noFill) { + this.noFill = noFill; + } + + public int getBlasts() { + return blasts; + } + + public void setBlasts(int blasts) { + this.blasts = blasts; + } + + public boolean isHasCharge() { + return hasCharge; + } + + public void setHasCharge(boolean hasCharge) { + this.hasCharge = hasCharge; + } + + public Material[] getFillables() { + return fillables; + } + + @Override + public void load() {} + + @Override + public void stop() {} + @Override public boolean isEnabled() { ConfigurationSection config = JedCoreConfig.getConfig(this.player); diff --git a/src/com/jedk1/jedcore/ability/waterbending/DrainBlast.java b/src/com/jedk1/jedcore/ability/waterbending/DrainBlast.java index 0092346..4cfe1c8 100644 --- a/src/com/jedk1/jedcore/ability/waterbending/DrainBlast.java +++ b/src/com/jedk1/jedcore/ability/waterbending/DrainBlast.java @@ -26,20 +26,18 @@ public class DrainBlast extends WaterAbility implements AddonAbility { private double travelled; @Attribute(Attribute.RANGE) - private double blastRange; // 20 + private final double blastRange; // 20 @Attribute(Attribute.DAMAGE) - private double blastDamage; // 1.5 + private final double blastDamage; // 1.5 @Attribute(Attribute.SPEED) - private double blastSpeed; // 2 - private int holdRange; // 2 + private final double blastSpeed; // 2 public DrainBlast(Player player, double range, double damage, double speed, int holdrange) { super(player); this.blastRange = range; this.blastDamage = damage; this.blastSpeed = speed; - this.holdRange = holdrange; - location = player.getEyeLocation().clone().add(player.getEyeLocation().getDirection().multiply(holdRange)); + location = player.getEyeLocation().clone().add(player.getEyeLocation().getDirection().multiply(holdrange)); start(); } @@ -54,7 +52,6 @@ public void progress() { return; } advanceAttack(); - return; } private void advanceAttack() { @@ -72,7 +69,7 @@ private void advanceAttack() { } playWaterbendingSound(location); - new RegenTempBlock(location.getBlock(), Material.WATER, Material.WATER.createBlockData(bd -> ((Levelled)bd).setLevel(0)), 100L); + new RegenTempBlock(location.getBlock(), Material.WATER, Material.WATER.createBlockData(bd -> ((Levelled) bd).setLevel(0)), 100L); for (Entity entity : GeneralMethods.getEntitiesAroundPoint(location, 2.5)) { if (entity instanceof LivingEntity && entity.getEntityId() != player.getEntityId() && !(entity instanceof ArmorStand)) { @@ -90,7 +87,7 @@ public long getCooldown() { @Override public Location getLocation() { - return null; + return location; } @Override @@ -124,15 +121,43 @@ public String getDescription() { return "* JedCore Addon *\n" + config.getString("Abilities.Water.Drain.Description"); } - @Override - public void load() { + public void setLocation(Location location) { + this.location = location; + } + public Vector getDirection() { + return direction; } - @Override - public void stop() { + public void setDirection(Vector direction) { + this.direction = direction; + } + + public double getDistanceTravelled() { + return travelled; + } + + public void setDistanceTravelled(double travelled) { + this.travelled = travelled; + } + public double getBlastRange() { + return blastRange; } + + public double getBlastDamage() { + return blastDamage; + } + + public double getBlastSpeed() { + return blastSpeed; + } + + @Override + public void load() {} + + @Override + public void stop() {} @Override public boolean isEnabled() { diff --git a/src/com/jedk1/jedcore/ability/waterbending/FrostBreath.java b/src/com/jedk1/jedcore/ability/waterbending/FrostBreath.java index e0be946..e9dbb63 100644 --- a/src/com/jedk1/jedcore/ability/waterbending/FrostBreath.java +++ b/src/com/jedk1/jedcore/ability/waterbending/FrostBreath.java @@ -30,6 +30,7 @@ import com.projectkorra.projectkorra.util.TempBlock; public class FrostBreath extends IceAbility implements AddonAbility { + private static final List INVALID_MATERIALS = Arrays.asList( Material.ICE, Material.LAVA, @@ -56,7 +57,7 @@ public class FrostBreath extends IceAbility implements AddonAbility { public Config config; private State state; - private List frozenBlocks = new ArrayList<>(); + private final List frozenBlocks = new ArrayList<>(); public FrostBreath(Player player) { super(player); @@ -148,16 +149,32 @@ public String getDescription() { return "* JedCore Addon *\n" + config.getString("Abilities.Water.FrostBreath.Description"); } - @Override - public void load() { + public static List getInvalidMaterials() { + return INVALID_MATERIALS; + } + public static List getInvalidBiomes() { + return INVALID_BIOMES; } - @Override - public void stop() { + public State getState() { + return state; + } + public void setState(State state) { + this.state = state; } + public List getFrozenBlocks() { + return frozenBlocks; + } + + @Override + public void load() {} + + @Override + public void stop() {} + @Override public boolean isEnabled() { ConfigurationSection config = JedCoreConfig.getConfig(this.player); @@ -234,18 +251,18 @@ private void createBeam() { double step = 1; double size = 0; double offset = 0; - double damageregion = 1.5; + double damageRegion = 1.5; for (double i = 0; i < config.range; i += step) { loc = loc.add(dir.clone().multiply(step)); size += 0.005; offset += 0.3; - damageregion += 0.01; + damageRegion += 0.01; if (!isLocationSafe(loc)) return; - for (Entity entity : GeneralMethods.getEntitiesAroundPoint(loc, damageregion)) { + for (Entity entity : GeneralMethods.getEntitiesAroundPoint(loc, damageRegion)) { if (entity instanceof LivingEntity && entity.getEntityId() != player.getEntityId()) { for (Location cageLocation : createCage(entity.getLocation())) { if (isFreezable(cageLocation, entity)) { diff --git a/src/com/jedk1/jedcore/ability/waterbending/HealingWaters.java b/src/com/jedk1/jedcore/ability/waterbending/HealingWaters.java index 9031fbe..4a75fbf 100644 --- a/src/com/jedk1/jedcore/ability/waterbending/HealingWaters.java +++ b/src/com/jedk1/jedcore/ability/waterbending/HealingWaters.java @@ -38,11 +38,11 @@ public HealingWaters(Player player) { super(player); } - public static void heal(Server server){ + public static void heal(Server server) { if (enabled) { - if(System.currentTimeMillis() - time >= 1000){ + if (System.currentTimeMillis() - time >= 1000) { time = System.currentTimeMillis(); - for(Player player : server.getOnlinePlayers()){ + for (Player player : server.getOnlinePlayers()) { BendingPlayer bPlayer = BendingPlayer.getBendingPlayer(player); if (bPlayer != null && bPlayer.canBend(getAbility("HealingWaters"))) { heal(player); @@ -54,29 +54,29 @@ public static void heal(Server server){ @SuppressWarnings("deprecation") private static void heal(Player player) { - if(inWater(player)){ - if(player.isSneaking()){ - Entity entity = GeneralMethods.getTargetedEntity(player, getRange(player), new ArrayList()); - if(entity instanceof LivingEntity && inWater(entity)){ + if (inWater(player)) { + if (player.isSneaking()) { + Entity entity = GeneralMethods.getTargetedEntity(player, getRange(player), new ArrayList<>()); + if (entity instanceof LivingEntity && inWater(entity)) { Location playerLoc = entity.getLocation(); playerLoc.add(0, 1, 0); ParticleEffect.SPELL_MOB_AMBIENT.display(playerLoc, 3, Math.random(), Math.random(), Math.random(), 0.0); ParticleEffect.WATER_WAKE.display(playerLoc, 25, 0, 0, 0, 0.05F); giveHPToEntity((LivingEntity) entity); } - }else{ + } else { Location playerLoc = player.getLocation(); playerLoc.add(0, 1, 0); ParticleEffect.SPELL_MOB_AMBIENT.display(playerLoc, 3, Math.random(), Math.random(), Math.random(), 0.0); ParticleEffect.WATER_WAKE.display(playerLoc, 25, 0, 0, 0, 0.05F); giveHP(player); } - }else if(hasWaterSupply(player) && player.isSneaking()){ - Entity entity = GeneralMethods.getTargetedEntity(player, getRange(player), new ArrayList()); - if(entity != null){ - if(entity instanceof LivingEntity){ - Damageable dLe = (Damageable)entity; - if(dLe.getHealth() < dLe.getMaxHealth()){ + } else if(hasWaterSupply(player) && player.isSneaking()) { + Entity entity = GeneralMethods.getTargetedEntity(player, getRange(player), new ArrayList<>()); + if (entity != null) { + if (entity instanceof LivingEntity) { + Damageable dLe = (Damageable) entity; + if (dLe.getHealth() < dLe.getMaxHealth()) { Location playerLoc = entity.getLocation(); playerLoc.add(0, 1, 0); ParticleEffect.SPELL_MOB_AMBIENT.display(playerLoc, 3, Math.random(), Math.random(), Math.random(), 0.0); @@ -84,11 +84,11 @@ private static void heal(Player player) { giveHPToEntity((LivingEntity) entity); entity.setFireTicks(0); Random rand = new Random(); - if(rand.nextInt(getDrainChance(player)) == 0) + if (rand.nextInt(getDrainChance(player)) == 0) drainWaterSupply(player); } } - }else{ + } else { Location playerLoc = player.getLocation(); playerLoc.add(0, 1, 0); ParticleEffect.SPELL_MOB_AMBIENT.display(playerLoc, 3, Math.random(), Math.random(), Math.random(), 0.0); @@ -96,7 +96,7 @@ private static void heal(Player player) { giveHP(player); player.setFireTicks(0); Random rand = new Random(); - if(rand.nextInt(getDrainChance(player)) == 0) + if (rand.nextInt(getDrainChance(player)) == 0) drainWaterSupply(player); } } @@ -104,20 +104,18 @@ private static void heal(Player player) { @SuppressWarnings("deprecation") private static void giveHPToEntity(LivingEntity le) { - Damageable dLe = (Damageable)le; - if (!le.isDead() && dLe.getHealth() < dLe.getMaxHealth()) { + if (!le.isDead() && le.getHealth() < le.getMaxHealth()) { applyHealingToEntity(le); } - for(PotionEffect effect : le.getActivePotionEffects()) { - if(isNegativeEffect(effect.getType())) { + for (PotionEffect effect : le.getActivePotionEffects()) { + if (isNegativeEffect(effect.getType())) { le.removePotionEffect(effect.getType()); } } } private static void giveHP(Player player){ - Damageable dP = (Damageable)player; - if (!player.isDead() && dP.getHealth() < 20) { + if (!player.isDead() && player.getHealth() < 20) { applyHealing(player); } for(PotionEffect effect : player.getActivePotionEffects()) { @@ -134,26 +132,24 @@ private static void giveHP(Player player){ private static boolean inWater(Entity entity) { Block block = entity.getLocation().getBlock(); - if (isWater(block) && !TempBlock.isTempBlock(block)) - return true; - return false; + return isWater(block) && !TempBlock.isTempBlock(block); } private static boolean hasWaterSupply(Player player){ ItemStack heldItem = player.getInventory().getItemInMainHand(); - return(heldItem.isSimilar(WaterReturn.waterBottleItem()) || heldItem.getType() == Material.WATER_BUCKET); + return (heldItem.isSimilar(WaterReturn.waterBottleItem()) || heldItem.getType() == Material.WATER_BUCKET); } private static void drainWaterSupply(Player player){ ItemStack heldItem = player.getInventory().getItemInMainHand(); ItemStack emptyBottle = new ItemStack(Material.GLASS_BOTTLE, 1); - if(heldItem.isSimilar(WaterReturn.waterBottleItem())) { + if (heldItem.isSimilar(WaterReturn.waterBottleItem())) { if (heldItem.getAmount() > 1) { heldItem.setAmount(heldItem.getAmount() - 1); - HashMap cantfit = player.getInventory().addItem(emptyBottle); - for (int id : cantfit.keySet()) { - player.getWorld().dropItem(player.getEyeLocation(), cantfit.get(id)); + HashMap cantFit = player.getInventory().addItem(emptyBottle); + for (int id : cantFit.keySet()) { + player.getWorld().dropItem(player.getEyeLocation(), cantFit.get(id)); } } else { player.getInventory().setItemInMainHand(emptyBottle); @@ -163,9 +159,8 @@ private static void drainWaterSupply(Player player){ @SuppressWarnings("deprecation") private static void applyHealing(Player player) { - Damageable dP = (Damageable)player; if (!GeneralMethods.isRegionProtectedFromBuild(player, "HealingWaters", player.getLocation())) - if(dP.getHealth() < dP.getMaxHealth()) { + if(player.getHealth() < player.getMaxHealth()) { player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 70, getPower(player))); AirAbility.breakBreathbendingHold(player); } @@ -173,8 +168,7 @@ private static void applyHealing(Player player) { @SuppressWarnings("deprecation") private static void applyHealingToEntity(LivingEntity le) { - Damageable dLe = (Damageable)le; - if(dLe.getHealth() < dLe.getMaxHealth()) { + if (le.getHealth() < le.getMaxHealth()) { le.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 70, 1)); AirAbility.breakBreathbendingHold(le); } @@ -237,14 +231,10 @@ public String getDescription() { } @Override - public void load() { - return; - } + public void load() {} @Override - public void stop() { - return; - } + public void stop() {} @Override public boolean isEnabled() { @@ -254,6 +244,5 @@ public boolean isEnabled() { } @Override - public void progress() { - } + public void progress() {} } \ No newline at end of file diff --git a/src/com/jedk1/jedcore/ability/waterbending/IceClaws.java b/src/com/jedk1/jedcore/ability/waterbending/IceClaws.java index fadee60..b09b6c1 100644 --- a/src/com/jedk1/jedcore/ability/waterbending/IceClaws.java +++ b/src/com/jedk1/jedcore/ability/waterbending/IceClaws.java @@ -34,7 +34,6 @@ public class IceClaws extends IceAbility implements AddonAbility { private Location head; private Location origin; private boolean launched; - private long time; public IceClaws(Player player) { super(player); @@ -43,7 +42,7 @@ public IceClaws(Player player) { } if (hasAbility(player, IceClaws.class)) { - IceClaws ic = ((IceClaws) getAbility(player, IceClaws.class)); + IceClaws ic = getAbility(player, IceClaws.class); if (!ic.throwable) { ic.remove(); } @@ -51,7 +50,6 @@ public IceClaws(Player player) { } setFields(); - time = System.currentTimeMillis(); start(); } @@ -84,22 +82,19 @@ public void progress() { remove(); return; } - if (System.currentTimeMillis() > time + chargeUp) { + if (System.currentTimeMillis() > getStartTime() + chargeUp) { if (!launched && throwable) { displayClaws(); } else { if (!shoot()) { remove(); - return; } } } else if (player.isSneaking()) { displayChargeUp(); } else { remove(); - return; } - return; } public boolean shoot() { @@ -123,7 +118,7 @@ public boolean shoot() { public static void throwClaws(Player player) { if (hasAbility(player, IceClaws.class)) { - IceClaws ic = ((IceClaws) getAbility(player, IceClaws.class)); + IceClaws ic = getAbility(player, IceClaws.class); if (!ic.launched && player.isSneaking()) { ic.launched = true; ic.origin = ic.player.getEyeLocation(); @@ -132,11 +127,11 @@ public static void throwClaws(Player player) { } } - public Location getRightHandPos(){ + public Location getRightHandPos() { return GeneralMethods.getRightSide(player.getLocation(), .55).add(0, 1.2, 0); } - private void displayClaws(){ + private void displayClaws() { Location location = getRightHandPos().toVector().add(player.getEyeLocation().getDirection().clone().multiply(.75D)).toLocation(player.getWorld()); GeneralMethods.displayColoredParticle("66FFFF", location); GeneralMethods.displayColoredParticle("CCFFFF", location); @@ -149,7 +144,7 @@ private void displayChargeUp() { public static boolean freezeEntity(Player player, LivingEntity entity) { if (hasAbility(player, IceClaws.class)) { - ((IceClaws) getAbility(player, IceClaws.class)).freezeEntity(entity); + getAbility(player, IceClaws.class).freezeEntity(entity); return true; } return false; @@ -158,14 +153,11 @@ public static boolean freezeEntity(Player player, LivingEntity entity) { private void freezeEntity(LivingEntity entity) { if (entity.hasPotionEffect(PotionEffectType.SPEED)) { entity.removePotionEffect(PotionEffectType.SPEED); - entity.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, slowDur, 3)); - } else { - entity.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, slowDur, 3)); } + entity.addPotionEffect(new PotionEffect(PotionEffectType.SLOW, slowDur, 3)); bPlayer.addCooldown(this); remove(); DamageHandler.damageEntity(entity, damage, this); - return; } @Override @@ -175,7 +167,7 @@ public long getCooldown() { @Override public Location getLocation() { - return null; + return head; } @Override @@ -209,15 +201,79 @@ public String getDescription() { return "* JedCore Addon *\n" + config.getString("Abilities.Water.IceClaws.Description"); } - @Override - public void load() { - return; + public void setCooldown(long cooldown) { + this.cooldown = cooldown; } - @Override - public void stop() { - return; + public long getChargeUp() { + return chargeUp; + } + + public void setChargeUp(long chargeUp) { + this.chargeUp = chargeUp; + } + + public int getSlowDuration() { + return slowDur; + } + + public void setSlowDuration(int slowDuration) { + this.slowDur = slowDuration; + } + + public double getDamage() { + return damage; + } + + public void setDamage(double damage) { + this.damage = damage; + } + + public double getRange() { + return range; + } + + public void setRange(double range) { + this.range = range; + } + + public boolean isThrowable() { + return throwable; + } + + public void setThrowable(boolean throwable) { + this.throwable = throwable; + } + + public Location getHead() { + return head; } + + public void setHead(Location head) { + this.head = head; + } + + public Location getOrigin() { + return origin; + } + + public void setOrigin(Location origin) { + this.origin = origin; + } + + public boolean isLaunched() { + return launched; + } + + public void setLaunched(boolean launched) { + this.launched = launched; + } + + @Override + public void load() {} + + @Override + public void stop() {} @Override public boolean isEnabled() { diff --git a/src/com/jedk1/jedcore/ability/waterbending/IceWall.java b/src/com/jedk1/jedcore/ability/waterbending/IceWall.java index 8788da9..d35a2c8 100644 --- a/src/com/jedk1/jedcore/ability/waterbending/IceWall.java +++ b/src/com/jedk1/jedcore/ability/waterbending/IceWall.java @@ -1,6 +1,7 @@ package com.jedk1.jedcore.ability.waterbending; import java.util.ArrayList; +import java.util.Iterator; import java.util.List; import java.util.ListIterator; import java.util.Random; @@ -35,7 +36,7 @@ public class IceWall extends IceAbility implements AddonAbility { - public static List instances = new ArrayList(); + public static List instances = new ArrayList<>(); @Attribute(Attribute.HEIGHT) private int maxHeight; private int minHeight; @@ -57,24 +58,24 @@ public class IceWall extends IceAbility implements AddonAbility { public int torrentDamage; public int torrentFreezeDamage; - public int iceblastDamage; - public int fireblastDamage; - public int fireblastChargedDamage; + public int iceBlastDamage; + public int fireBlastDamage; + public int fireBlastChargedDamage; public int lightningDamage; public int combustionDamage; public int earthSmashDamage; public int airBlastDamage; public boolean isWallDoneFor = false; - public List affectedBlocks = new ArrayList(); + public List affectedBlocks = new ArrayList<>(); private boolean rising = false; private long lastDamageTime = 0; private long lifetime = 0; private int wallHealth; private int tankedDamage; - private List lastBlocks = new ArrayList(); - private List tempBlocks = new ArrayList(); + private final List lastBlocks = new ArrayList<>(); + private final List tempBlocks = new ArrayList<>(); Random rand = new Random(); @@ -127,9 +128,9 @@ public void setFields() { lifetimeTime = config.getLong("Abilities.Water.IceWall.LifeTime.Duration"); torrentDamage = config.getInt("Abilities.Water.IceWall.WallDamage.Torrent"); torrentFreezeDamage = config.getInt("Abilities.Water.IceWall.WallDamage.TorrentFreeze"); - iceblastDamage = config.getInt("Abilities.Water.IceWall.WallDamage.IceBlast"); - fireblastDamage = config.getInt("Abilities.Water.IceWall.WallDamage.Fireblast"); - fireblastChargedDamage = config.getInt("Abilities.Water.IceWall.WallDamage.FireblastCharged"); + iceBlastDamage = config.getInt("Abilities.Water.IceWall.WallDamage.IceBlast"); + fireBlastDamage = config.getInt("Abilities.Water.IceWall.WallDamage.Fireblast"); + fireBlastChargedDamage = config.getInt("Abilities.Water.IceWall.WallDamage.FireblastCharged"); lightningDamage = config.getInt("Abilities.Water.IceWall.WallDamage.Lightning"); combustionDamage = config.getInt("Abilities.Water.IceWall.WallDamage.Combustion"); earthSmashDamage = config.getInt("Abilities.Water.IceWall.WallDamage.EarthSmash"); @@ -152,12 +153,9 @@ public Block getSourceBlock(Player player, int range) { } public boolean isBendable(Block b) { - if (b.getType() == Material.WATER || b.getType() == Material.ICE || b.getType() == Material.PACKED_ICE + return b.getType() == Material.WATER || b.getType() == Material.ICE || b.getType() == Material.PACKED_ICE //|| b.getType() == Material.SNOW - || b.getType() == Material.SNOW_BLOCK) - return true; - - return false; + || b.getType() == Material.SNOW_BLOCK; } public void loadAffectedBlocks(Player player, Block block) { @@ -242,7 +240,7 @@ public void progress() { return; } - List theseBlocks = new ArrayList(lastBlocks); + List theseBlocks = new ArrayList<>(lastBlocks); lastBlocks.clear(); @@ -370,9 +368,10 @@ public static boolean isIceWallBlock(Block block) { } public static void removeAll() { - for (int i = 0; i < instances.size(); i++) { - IceWall iw = instances.get(i); - iw.remove(); + Iterator it = instances.iterator(); + while (it.hasNext()) { + it.next().remove(); + it.remove(); } } @@ -413,7 +412,7 @@ public static void progressAll() { break; if (ice.getLocation().getWorld() == ib.source.getLocation().getWorld() && ice.getLocation().distance(ib.source.getLocation()) <= 2) { - iw.damageWall(ib.getPlayer(), (int) (iw.iceblastDamage * getNightFactor(ice.getWorld()))); + iw.damageWall(ib.getPlayer(), (int) (iw.iceBlastDamage * getNightFactor(ice.getWorld()))); if (!iw.isWallDoneFor) ib.remove(); @@ -425,7 +424,7 @@ public static void progressAll() { if (fb.getLocation() == null) continue; for (Block ice : iw.affectedBlocks) { if (ice.getLocation().getWorld() == fb.getLocation().getWorld() && fb.getLocation().distance(ice.getLocation()) <= 1.5) { - iw.damageWall(fb.getPlayer(), iw.fireblastChargedDamage); + iw.damageWall(fb.getPlayer(), iw.fireBlastChargedDamage); if (!iw.isWallDoneFor) fb.remove();; } @@ -436,7 +435,7 @@ public static void progressAll() { if (fb.getLocation() == null) continue; for (Block ice : iw.affectedBlocks) { if (ice.getLocation().getWorld() == fb.getLocation().getWorld() && fb.getLocation().distance(ice.getLocation()) <= 1.5) { - iw.damageWall(fb.getPlayer(), iw.fireblastDamage); + iw.damageWall(fb.getPlayer(), iw.fireBlastDamage); if (!iw.isWallDoneFor) fb.remove();; } @@ -547,20 +546,88 @@ public String getDescription() { return "* JedCore Addon *\n" + config.getString("Abilities.Water.IceWall.Description"); } - @Override - public void load() { - return; + public int getRange() { + return range; } - @Override - public void stop() { - return; + public void setRange(int range) { + this.range = range; } - @Override - public boolean isEnabled() { - ConfigurationSection config = JedCoreConfig.getConfig(this.player); - return config.getBoolean("Abilities.Water.IceWall.Enabled"); + public int getMaxHealth() { + return maxHealth; + } + + public void setMaxHealth(int maxHealth) { + this.maxHealth = maxHealth; + } + + public int getMinHealth() { + return minHealth; + } + + public void setMinHealth(int minHealth) { + this.minHealth = minHealth; + } + + public double getDamage() { + return damage; + } + + public void setDamage(double damage) { + this.damage = damage; + } + + public void setCooldown(long cooldown) { + this.cooldown = cooldown; + } + + public boolean isRising() { + return rising; + } + + public void setRising(boolean rising) { + this.rising = rising; + } + + public long getLastDamageTime() { + return lastDamageTime; + } + + public void setLastDamageTime(long lastDamageTime) { + this.lastDamageTime = lastDamageTime; + } + + public long getLifetime() { + return lifetime; + } + + public void setLifetime(long lifetime) { + this.lifetime = lifetime; + } + + public int getWallHealth() { + return wallHealth; + } + + public void setWallHealth(int wallHealth) { + this.wallHealth = wallHealth; + } + + public int getTankedDamage() { + return tankedDamage; + } + + public void setTankedDamage(int tankedDamage) { + this.tankedDamage = tankedDamage; + } + + public List getLastBlocks() { + return lastBlocks; + } + + public List getTempBlocks() { + return tempBlocks; } public int getMaxHeight() { @@ -586,4 +653,16 @@ public int getWidth() { public void setWidth(int width) { this.width = width; } + + @Override + public void load() {} + + @Override + public void stop() {} + + @Override + public boolean isEnabled() { + ConfigurationSection config = JedCoreConfig.getConfig(this.player); + return config.getBoolean("Abilities.Water.IceWall.Enabled"); + } } diff --git a/src/com/jedk1/jedcore/ability/waterbending/WakeFishing.java b/src/com/jedk1/jedcore/ability/waterbending/WakeFishing.java index 61802ff..6f4bf55 100644 --- a/src/com/jedk1/jedcore/ability/waterbending/WakeFishing.java +++ b/src/com/jedk1/jedcore/ability/waterbending/WakeFishing.java @@ -23,6 +23,7 @@ import java.util.Random; public class WakeFishing extends WaterAbility implements AddonAbility { + private final static Material[] FISH_TYPES = { Material.COD, Material.PUFFERFISH, Material.TROPICAL_FISH, Material.SALMON }; @@ -37,7 +38,6 @@ public class WakeFishing extends WaterAbility implements AddonAbility { private long duration; @Attribute(Attribute.RANGE) private long range; - private long time; Random rand = new Random(); @@ -48,8 +48,7 @@ public WakeFishing(Player player) { } setFields(); - - time = System.currentTimeMillis(); + if (prepare()) start(); } @@ -74,7 +73,7 @@ private void applyModifiers() { @SuppressWarnings("deprecation") private boolean prepare() { Block block = BlockSource.getWaterSourceBlock(player, range, ClickType.SHIFT_DOWN, true, false, false); - if (block != null && isWater(block) && block.getData() == 0) { + if (isWater(block) && block.getData() == 0) { focusedBlock = block; location = focusedBlock.getLocation(); return true; @@ -84,10 +83,7 @@ private boolean prepare() { private boolean isFocused() { Block block = BlockSource.getWaterSourceBlock(player, range, ClickType.SHIFT_DOWN, true, false, false); - if (block != null && block.equals(focusedBlock)) { - return true; - } - return false; + return block != null && block.equals(focusedBlock); } @Override @@ -101,14 +97,13 @@ public void progress() { remove(); return; } - if (System.currentTimeMillis() > time + duration) { + if (System.currentTimeMillis() > getStartTime() + duration) { bPlayer.addCooldown(this); remove(); return; } displayParticles(); spawnFishRandom(); - return; } private void displayParticles() { @@ -188,15 +183,51 @@ public String getDescription() { return "* JedCore Addon *\n" + config.getString("Abilities.Water.WakeFishing.Description"); } - @Override - public void load() { - return; + public Block getFocusedBlock() { + return focusedBlock; } - @Override - public void stop() { - return; + public void setFocusedBlock(Block focusedBlock) { + this.focusedBlock = focusedBlock; + } + + public void setLocation(Location location) { + this.location = location; + } + + public int getPoint() { + return point; + } + + public void setPoint(int point) { + this.point = point; } + + public void setCooldown(long cooldown) { + this.cooldown = cooldown; + } + + public long getDuration() { + return duration; + } + + public void setDuration(long duration) { + this.duration = duration; + } + + public long getRange() { + return range; + } + + public void setRange(long range) { + this.range = range; + } + + @Override + public void load() {} + + @Override + public void stop() {} @Override public boolean isEnabled() { diff --git a/src/com/jedk1/jedcore/ability/waterbending/WaterBlast.java b/src/com/jedk1/jedcore/ability/waterbending/WaterBlast.java index 4d70cc9..ca28598 100644 --- a/src/com/jedk1/jedcore/ability/waterbending/WaterBlast.java +++ b/src/com/jedk1/jedcore/ability/waterbending/WaterBlast.java @@ -20,21 +20,22 @@ import org.bukkit.util.Vector; public class WaterBlast extends WaterAbility implements AddonAbility { + private Location location; private Vector direction; - private Ability ability; + private final Ability ability; private double travelled; @Attribute(Attribute.RANGE) - private double range; + private final double range; @Attribute(Attribute.DAMAGE) - private double damage; + private final double damage; @Attribute(Attribute.SPEED) - private double speed; + private final double speed; @Attribute("CollisionRadius") - private double entityCollisionRadius; + private final double entityCollisionRadius; @Attribute("CollisionRadius") - private double abilityCollisionRadius; + private final double abilityCollisionRadius; static { CollisionInitializer.abilityMap.put("WaterBlast", "WaterGimbal"); @@ -186,15 +187,55 @@ public String getDescription() { return null; } - @Override - public void load() { + public void setLocation(Location location) { + this.location = location; + } + public Vector getDirection() { + return direction; } - @Override - public void stop() { + public void setDirection(Vector direction) { + this.direction = direction; + } + + public Ability getAbility() { + return ability; + } + + public double getTravelled() { + return travelled; + } + + public void setTravelled(double travelled) { + this.travelled = travelled; + } + + public double getRange() { + return range; + } + + public double getDamage() { + return damage; + } + + public double getSpeed() { + return speed; + } + + public double getEntityCollisionRadius() { + return entityCollisionRadius; + } + public double getAbilityCollisionRadius() { + return abilityCollisionRadius; } + + @Override + public void load() {} + + @Override + public void stop() {} @Override public boolean isEnabled() { diff --git a/src/com/jedk1/jedcore/ability/waterbending/combo/Maelstrom.java b/src/com/jedk1/jedcore/ability/waterbending/combo/Maelstrom.java index 95e015f..439cf9f 100644 --- a/src/com/jedk1/jedcore/ability/waterbending/combo/Maelstrom.java +++ b/src/com/jedk1/jedcore/ability/waterbending/combo/Maelstrom.java @@ -37,14 +37,13 @@ public class Maelstrom extends WaterAbility implements AddonAbility, ComboAbilit @Attribute(Attribute.DURATION) private long duration; - private List pool = new ArrayList(); - private List wave = new ArrayList(); + private final List pool = new ArrayList<>(); + private final List wave = new ArrayList<>(); private Location origin; private int step; private int levelStep; private int angle; private boolean canRemove; - private long start; public Maelstrom(Player player) { super(player); @@ -54,10 +53,12 @@ public Maelstrom(Player player) { setFields(); if (setOrigin()) { start(); - bPlayer.addCooldown(this); - Torrent t = getAbility(player, Torrent.class); - if (t != null) { - t.remove(); + if (!isRemoved()) { + bPlayer.addCooldown(this); + Torrent t = getAbility(player, Torrent.class); + if (t != null) { + t.remove(); + } } } } @@ -70,7 +71,6 @@ public void setFields() { depth = config.getInt("Abilities.Water.WaterCombo.Maelstrom.MaxDepth"); range = config.getInt("Abilities.Water.WaterCombo.Maelstrom.Range"); canRemove = true; - start = System.currentTimeMillis(); applyModifiers(); } @@ -118,7 +118,7 @@ public void progress() { remove(); return; } - if (System.currentTimeMillis() > start + duration) { + if (System.currentTimeMillis() > getStartTime() + duration) { remove(); return; } @@ -177,7 +177,7 @@ public void playAnimation() { for (int i = 0; i < levelStep; i++) { for (int degree = 0; degree < waves; degree++) { double size = (levelStep - i) - 1; - double angle = ((newAngle + (degree * (360/waves))) * Math.PI / 180); + double angle = ((newAngle + (degree * (360F / waves))) * Math.PI / 180); double x = size * Math.cos(angle); double z = size * Math.sin(angle); Location loc = origin.clone(); @@ -185,13 +185,13 @@ public void playAnimation() { Block b = loc.getBlock(); for (int j = 0; j < 2; j++) { wave.add(b.getRelative(BlockFace.DOWN, j)); - new RegenTempBlock(b.getRelative(BlockFace.DOWN, j), Material.WATER, Material.WATER.createBlockData(bd -> ((Levelled)bd).setLevel(1)), 0); + new RegenTempBlock(b.getRelative(BlockFace.DOWN, j), Material.WATER, Material.WATER.createBlockData(bd -> ((Levelled) bd).setLevel(1)), 0); ParticleEffect.WATER_SPLASH.display(loc, 3, Math.random(), Math.random(), Math.random(), 0); } } - newAngle+=15; + newAngle += 15; } - this.angle+=(levelStep*2); + this.angle+=(levelStep * 2); } @@ -268,16 +268,64 @@ public String getDescription() { return "* JedCore Addon *\n" + config.getString("Abilities.Water.WaterCombo.Maelstrom.Description"); } - @Override - public void load() { - return; + public int getRange() { + return range; } - @Override - public void stop() { - return; + public void setRange(int range) { + this.range = range; + } + + public void setCooldown(long cooldown) { + this.cooldown = cooldown; + } + + public long getDuration() { + return duration; + } + + public void setDuration(long duration) { + this.duration = duration; + } + + public List getPool() { + return pool; + } + + public List getWave() { + return wave; + } + + public Location getOrigin() { + return origin; + } + + public void setOrigin(Location origin) { + this.origin = origin; + } + + public int getAngle() { + return angle; + } + + public void setAngle(int angle) { + this.angle = angle; } + public boolean canRemove() { + return canRemove; + } + + public void setCanRemove(boolean canRemove) { + this.canRemove = canRemove; + } + + @Override + public void load() {} + + @Override + public void stop() {} + @Override public boolean isEnabled() { ConfigurationSection config = JedCoreConfig.getConfig(this.player); diff --git a/src/com/jedk1/jedcore/ability/waterbending/combo/WaterFlow.java b/src/com/jedk1/jedcore/ability/waterbending/combo/WaterFlow.java index 688cbec..059d1d2 100644 --- a/src/com/jedk1/jedcore/ability/waterbending/combo/WaterFlow.java +++ b/src/com/jedk1/jedcore/ability/waterbending/combo/WaterFlow.java @@ -37,28 +37,28 @@ public class WaterFlow extends WaterAbility implements AddonAbility, ComboAbility { @Attribute(Attribute.SELECT_RANGE) - private int sourcerange; //10 + private int sourceRange; //10 @Attribute(Attribute.RANGE) - private int maxrange; //40 - private int minrange; //8 + private int maxRange; //40 + private int minRange; //8 @Attribute(Attribute.DURATION) private long duration; //10000 @Attribute(Attribute.COOLDOWN) private long cooldown; //15000 - private long meltdelay; //5000 + private long meltDelay; //5000 @Attribute("Length") private long trail; //80 private boolean avatar; //true - private boolean stayatsource; //true - private int stayrange; //100 - private boolean fullmoonEnabled; - private int fullmoonCooldown; - private int fullmoonDuration; + private boolean stayAtSource; //true + private int stayRange; //100 + private boolean fullMoonEnabled; + private int fullMoonCooldown; + private int fullMoonDuration; private boolean playerRideOwnFlow; private int size; //1; private int avatarSize; //3; - private int fullmoonSizeSmall; //2; - private int fullmoonSizeLarge; //3; + private int fullMoonSizeSmall; //2; + private int fullMoonSizeLarge; //3; private long avatarDuration; //60000; private boolean canUseBottle; private boolean canUsePlants; @@ -68,16 +68,14 @@ public class WaterFlow extends WaterAbility implements AddonAbility, ComboAbilit private Location origin; private Location head; private int range; - private Vector direction; - private Block sourceblock; + private Block sourceBlock; private boolean frozen; private double prevHealth; - private int headsize; + private int headSize; private boolean usingBottle; - private ConcurrentHashMap directions = new ConcurrentHashMap(); - private List blocks = new ArrayList(); - private List sources = new ArrayList(); - + private final ConcurrentHashMap directions = new ConcurrentHashMap<>(); + private final List blocks = new ArrayList<>(); + Random rand = new Random(); public WaterFlow(Player player) { @@ -89,7 +87,7 @@ public WaterFlow(Player player) { return; } if (hasAbility(player, WaterFlow.class)) { - ((WaterFlow) getAbility(player, WaterFlow.class)).remove(); + getAbility(player, WaterFlow.class).remove(); return; } setFields(); @@ -97,31 +95,29 @@ public WaterFlow(Player player) { usingBottle = false; if (prepare()) { - headsize = size; + headSize = size; trail = trail * size; - range = maxrange; + range = maxRange; prevHealth = player.getHealth(); time = System.currentTimeMillis(); int augment = (int) Math.round(getNightFactor(player.getWorld())); - if (isFullMoon(player.getWorld()) && fullmoonEnabled && sourceblock != null) { - sources = getNearbySources(sourceblock, 3); - if (sources != null) { - if (sources.size() > 9) { - headsize = fullmoonSizeSmall; - } - if (sources.size() > 36) { - headsize = fullmoonSizeLarge; - } - trail = trail * augment; - range = range - (range / 3); - maxrange = range; - duration = duration * fullmoonDuration; - cooldown = cooldown * fullmoonCooldown; + if (isFullMoon(player.getWorld()) && fullMoonEnabled && sourceBlock != null) { + List sources = getNearbySources(sourceBlock, 3); + if (sources.size() > 9) { + headSize = fullMoonSizeSmall; + } + if (sources.size() > 36) { + headSize = fullMoonSizeLarge; } + trail = trail * augment; + range = range - (range / 3); + maxRange = range; + duration = duration * fullMoonDuration; + cooldown = cooldown * fullMoonCooldown; } if (bPlayer.isAvatarState()) { - headsize = avatarSize; + headSize = avatarSize; if (avatar) { duration = 0; } else { @@ -130,7 +126,7 @@ public WaterFlow(Player player) { } start(); if (hasAbility(player, WaterManipulation.class)) { - WaterManipulation manip = (WaterManipulation) getAbility(player, WaterManipulation.class); + WaterManipulation manip = getAbility(player, WaterManipulation.class); manip.remove(); } } @@ -139,51 +135,51 @@ public WaterFlow(Player player) { public void setFields() { ConfigurationSection config = JedCoreConfig.getConfig(this.player); - sourcerange = config.getInt("Abilities.Water.WaterCombo.WaterFlow.SourceRange"); - maxrange = config.getInt("Abilities.Water.WaterCombo.WaterFlow.MaxRange"); - minrange = config.getInt("Abilities.Water.WaterCombo.WaterFlow.MinRange"); + sourceRange = config.getInt("Abilities.Water.WaterCombo.WaterFlow.SourceRange"); + maxRange = config.getInt("Abilities.Water.WaterCombo.WaterFlow.MaxRange"); + minRange = config.getInt("Abilities.Water.WaterCombo.WaterFlow.MinRange"); duration = config.getLong("Abilities.Water.WaterCombo.WaterFlow.Duration"); cooldown = config.getInt("Abilities.Water.WaterCombo.WaterFlow.Cooldown"); - meltdelay = config.getInt("Abilities.Water.WaterCombo.WaterFlow.MeltDelay"); + meltDelay = config.getInt("Abilities.Water.WaterCombo.WaterFlow.MeltDelay"); trail = config.getInt("Abilities.Water.WaterCombo.WaterFlow.Trail"); avatar = config.getBoolean("Abilities.Water.WaterCombo.WaterFlow.IsAvatarStateToggle"); avatarDuration = config.getLong("Abilities.Water.WaterCombo.WaterFlow.AvatarStateDuration"); - stayatsource = config.getBoolean("Abilities.Water.WaterCombo.WaterFlow.PlayerStayNearSource"); - stayrange = config.getInt("Abilities.Water.WaterCombo.WaterFlow.MaxDistanceFromSource"); + stayAtSource = config.getBoolean("Abilities.Water.WaterCombo.WaterFlow.PlayerStayNearSource"); + stayRange = config.getInt("Abilities.Water.WaterCombo.WaterFlow.MaxDistanceFromSource"); canUseBottle = config.getBoolean("Abilities.Water.WaterCombo.WaterFlow.BottleSource"); canUsePlants = config.getBoolean("Abilities.Water.WaterCombo.WaterFlow.PlantSource"); removeOnAnyDamage = config.getBoolean("Abilities.Water.WaterCombo.WaterFlow.RemoveOnAnyDamage"); - fullmoonCooldown = config.getInt("Abilities.Water.WaterCombo.WaterFlow.FullMoon.Modifier.Cooldown"); - fullmoonDuration = config.getInt("Abilities.Water.WaterCombo.WaterFlow.FullMoon.Modifier.Duration"); - fullmoonEnabled = config.getBoolean("Abilities.Water.WaterCombo.WaterFlow.FullMoon.Enabled"); + fullMoonCooldown = config.getInt("Abilities.Water.WaterCombo.WaterFlow.FullMoon.Modifier.Cooldown"); + fullMoonDuration = config.getInt("Abilities.Water.WaterCombo.WaterFlow.FullMoon.Modifier.Duration"); + fullMoonEnabled = config.getBoolean("Abilities.Water.WaterCombo.WaterFlow.FullMoon.Enabled"); playerRideOwnFlow = config.getBoolean("Abilities.Water.WaterCombo.WaterFlow.PlayerRideOwnFlow"); size = config.getInt("Abilities.Water.WaterCombo.WaterFlow.Size.Normal"); avatarSize = config.getInt("Abilities.Water.WaterCombo.WaterFlow.Size.AvatarState"); - fullmoonSizeSmall = config.getInt("Abilities.Water.WaterCombo.WaterFlow.Size.FullmoonSmall"); - fullmoonSizeLarge = config.getInt("Abilities.Water.WaterCombo.WaterFlow.Size.FullmoonLarge"); + fullMoonSizeSmall = config.getInt("Abilities.Water.WaterCombo.WaterFlow.Size.FullmoonSmall"); + fullMoonSizeLarge = config.getInt("Abilities.Water.WaterCombo.WaterFlow.Size.FullmoonLarge"); applyModifiers(); } private void applyModifiers() { if (isNight(player.getWorld())) { - maxrange = (int) getNightFactor(maxrange); + maxRange = (int) getNightFactor(maxRange); cooldown -= ((long) getNightFactor(cooldown) - cooldown); } } - public static List getNearbySources(Block block, int searchrange) { - List sources = new ArrayList(); - for (Location l : GeneralMethods.getCircle(block.getLocation(), searchrange, 2, false, false, -1)) { - Block blocki = l.getBlock(); + public static List getNearbySources(Block block, int searchRange) { + List sources = new ArrayList<>(); + for (Location l : GeneralMethods.getCircle(block.getLocation(), searchRange, 2, false, false, -1)) { + Block blockI = l.getBlock(); if (isWater(block)) { - if (blocki.getType() == Material.WATER && JCMethods.isLiquidSource(blocki) && WaterManipulation.canPhysicsChange(blocki)) { - sources.add(blocki); + if (blockI.getType() == Material.WATER && JCMethods.isLiquidSource(blockI) && WaterManipulation.canPhysicsChange(blockI)) { + sources.add(blockI); } } if (isLava(block)) { - if (blocki.getType() == Material.LAVA && JCMethods.isLiquidSource(blocki) && WaterManipulation.canPhysicsChange(blocki)) { - sources.add(blocki); + if (blockI.getType() == Material.LAVA && JCMethods.isLiquidSource(blockI) && WaterManipulation.canPhysicsChange(blockI)) { + sources.add(blockI); } } } @@ -191,17 +187,17 @@ public static List getNearbySources(Block block, int searchrange) { } private boolean prepare() { - sourceblock = BlockSource.getWaterSourceBlock(player, sourcerange, ClickType.SHIFT_DOWN, true, bPlayer.canIcebend(), canUsePlants); - if (sourceblock != null) { - boolean isGoodSource = GeneralMethods.isAdjacentToThreeOrMoreSources(sourceblock, false) || (TempBlock.isTempBlock(sourceblock) && WaterAbility.isBendableWaterTempBlock(sourceblock)); + sourceBlock = BlockSource.getWaterSourceBlock(player, sourceRange, ClickType.SHIFT_DOWN, true, bPlayer.canIcebend(), canUsePlants); + if (sourceBlock != null) { + boolean isGoodSource = GeneralMethods.isAdjacentToThreeOrMoreSources(sourceBlock, false) || (TempBlock.isTempBlock(sourceBlock) && WaterAbility.isBendableWaterTempBlock(sourceBlock)); // canUsePlants needs to be checked here due to a bug with PK dynamic source caching. // getWaterSourceBlock can return a plant even if canUsePlants is passed as false. - if (isGoodSource || (canUsePlants && isPlant(sourceblock))) { - head = sourceblock.getLocation().clone(); - origin = sourceblock.getLocation().clone(); - if (isPlant(sourceblock)) { - new PlantRegrowth(player, sourceblock); + if (isGoodSource || (canUsePlants && isPlant(sourceBlock))) { + head = sourceBlock.getLocation().clone(); + origin = sourceBlock.getLocation().clone(); + if (isPlant(sourceBlock)) { + new PlantRegrowth(player, sourceBlock); } return true; } @@ -237,7 +233,7 @@ public void progress() { remove(); return; } - if ((stayatsource && player.getLocation().distance(origin) >= stayrange) || head.getY() > 255 || head.getY() < 1) { + if ((stayAtSource && player.getLocation().distance(origin) >= stayRange) || head.getY() > head.getWorld().getMaxHeight() || head.getY() < head.getWorld().getMinHeight()) { remove(); return; } @@ -261,12 +257,12 @@ public void progress() { if (!frozen) { if (player.isSneaking()) { - if (range >= minrange) { + if (range >= minRange) { range -= 2; } - //BlockSource.update(player, sourcerange, ClickType.RIGHT_CLICK); + //BlockSource.update(player, sourceRange, ClickType.RIGHT_CLICK); } else { - if (range < maxrange) { + if (range < maxRange) { range += 2; } } @@ -279,26 +275,29 @@ public void progress() { private void manageLength() { int pos = 0; int ids = 0; - List templist = new ArrayList(blocks); - for (Block block : templist) { + List tempList = new ArrayList<>(blocks); + for (Block block : tempList) { for (Entity entity : GeneralMethods.getEntitiesAroundPoint(block.getLocation(), 2.8)) { if (entity.getEntityId() == player.getEntityId() && !playerRideOwnFlow) { continue; } - if (getPlayers(AirSpout.class).contains(entity)) { - continue; - } else if (getPlayers(WaterSpout.class).contains(entity)) { - continue; - } else if (getPlayers(Catapult.class).contains(entity)) { - continue; + boolean isPlayer = entity instanceof Player; + if (isPlayer) { + if (getPlayers(AirSpout.class).contains(entity)) { + continue; + } else if (getPlayers(WaterSpout.class).contains(entity)) { + continue; + } else if (getPlayers(Catapult.class).contains(entity)) { + continue; + } } - if(GeneralMethods.isRegionProtectedFromBuild(this, entity.getLocation()) || ((entity instanceof Player) && Commands.invincible.contains(((Player) entity).getName()))){ + if (GeneralMethods.isRegionProtectedFromBuild(this, entity.getLocation()) || (isPlayer && Commands.invincible.contains(entity.getName()))) { continue; } Location temp = directions.get(block); Vector dir = GeneralMethods.getDirection(entity.getLocation(), directions.get(block).add(temp.getDirection().multiply(1.5))); - entity.setVelocity(dir.clone().normalize().multiply(1)); + GeneralMethods.setVelocity(this, entity, dir.clone().normalize().multiply(1)); entity.setFallDistance(0f); } @@ -310,7 +309,7 @@ private void manageLength() { } } else { if (!isWater(block)) { - new TempBlock(block, Material.WATER, Material.WATER.createBlockData(bd -> ((Levelled)bd).setLevel(0))); + new TempBlock(block, Material.WATER, Material.WATER.createBlockData(bd -> ((Levelled) bd).setLevel(0))); } } pos++; @@ -329,18 +328,18 @@ private void manageLength() { TempBlock.revertBlock(block, Material.AIR); } } - templist.clear(); + tempList.clear(); } private void moveWater() { if (!MaterialUtil.isTransparent(head.getBlock()) || GeneralMethods.isRegionProtectedFromBuild(player, "Torrent", head)) { range -= 2; } - direction = GeneralMethods.getDirection(head, GeneralMethods.getTargetedLocation(player, range, Material.WATER)).normalize(); + Vector direction = GeneralMethods.getDirection(head, GeneralMethods.getTargetedLocation(player, range, Material.WATER)).normalize(); head = head.add(direction.clone().multiply(1)); head.setDirection(direction); playWaterbendingSound(head); - for (Block block : GeneralMethods.getBlocksAroundPoint(head, headsize)) { + for (Block block : GeneralMethods.getBlocksAroundPoint(head, headSize)) { if (directions.containsKey(block)) { directions.replace(block, head.clone()); } else { @@ -360,7 +359,7 @@ private void removeBlocks() { public static void freeze(Player player) { if (hasAbility(player, WaterFlow.class)) { - WaterFlow wf = (WaterFlow) getAbility(player, WaterFlow.class); + WaterFlow wf = getAbility(player, WaterFlow.class); if (!wf.bPlayer.canIcebend()) return; if (!wf.frozen) { wf.bPlayer.addCooldown(wf); @@ -376,7 +375,7 @@ private void freeze() { if (rand.nextInt(5) == 0) { playIcebendingSound(block.getLocation()); } - new RegenTempBlock(block, Material.ICE, Material.ICE.createBlockData(), randInt((int) meltdelay - 250, (int) meltdelay + 250)); + new RegenTempBlock(block, Material.ICE, Material.ICE.createBlockData(), randInt((int) meltDelay - 250, (int) meltDelay + 250)); } } } @@ -468,13 +467,263 @@ public String getVersion() { return JedCore.version; } - @Override - public void load() { + public int getSourceRange() { + return sourceRange; } - @Override - public void stop() { + public void setSourceRange(int sourceRange) { + this.sourceRange = sourceRange; + } + + public int getMaxRange() { + return maxRange; + } + + public void setMaxRange(int maxRange) { + this.maxRange = maxRange; + } + + public int getMinRange() { + return minRange; + } + + public void setMinRange(int minRange) { + this.minRange = minRange; + } + + public long getDuration() { + return duration; + } + + public void setDuration(long duration) { + this.duration = duration; + } + + public void setCooldown(long cooldown) { + this.cooldown = cooldown; + } + + public long getMeltDelay() { + return meltDelay; + } + + public void setMeltDelay(long meltDelay) { + this.meltDelay = meltDelay; + } + + public long getTrail() { + return trail; + } + + public void setTrail(long trail) { + this.trail = trail; + } + + public boolean isAvatar() { + return avatar; + } + + public void setAvatar(boolean avatar) { + this.avatar = avatar; + } + + public boolean isStayAtSource() { + return stayAtSource; + } + + public void setStayAtSource(boolean stayAtSource) { + this.stayAtSource = stayAtSource; + } + + public int getStayRange() { + return stayRange; + } + + public void setStayRange(int stayRange) { + this.stayRange = stayRange; + } + + public boolean isFullMoonEnabled() { + return fullMoonEnabled; + } + + public void setFullMoonEnabled(boolean fullMoonEnabled) { + this.fullMoonEnabled = fullMoonEnabled; + } + + public int getFullMoonCooldown() { + return fullMoonCooldown; + } + + public void setFullMoonCooldown(int fullMoonCooldown) { + this.fullMoonCooldown = fullMoonCooldown; + } + + public int getFullMoonDuration() { + return fullMoonDuration; + } + + public void setFullMoonDuration(int fullMoonDuration) { + this.fullMoonDuration = fullMoonDuration; + } + + public boolean isPlayerRideOwnFlow() { + return playerRideOwnFlow; + } + + public void setPlayerRideOwnFlow(boolean playerRideOwnFlow) { + this.playerRideOwnFlow = playerRideOwnFlow; + } + + public int getSize() { + return size; + } + + public void setSize(int size) { + this.size = size; + } + + public int getAvatarSize() { + return avatarSize; + } + + public void setAvatarSize(int avatarSize) { + this.avatarSize = avatarSize; } + + public int getFullMoonSizeSmall() { + return fullMoonSizeSmall; + } + + public void setFullMoonSizeSmall(int fullMoonSizeSmall) { + this.fullMoonSizeSmall = fullMoonSizeSmall; + } + + public int getFullMoonSizeLarge() { + return fullMoonSizeLarge; + } + + public void setFullMoonSizeLarge(int fullMoonSizeLarge) { + this.fullMoonSizeLarge = fullMoonSizeLarge; + } + + public long getAvatarDuration() { + return avatarDuration; + } + + public void setAvatarDuration(long avatarDuration) { + this.avatarDuration = avatarDuration; + } + + public boolean isCanUseBottle() { + return canUseBottle; + } + + public void setCanUseBottle(boolean canUseBottle) { + this.canUseBottle = canUseBottle; + } + + public boolean isCanUsePlants() { + return canUsePlants; + } + + public void setCanUsePlants(boolean canUsePlants) { + this.canUsePlants = canUsePlants; + } + + public boolean isRemoveOnAnyDamage() { + return removeOnAnyDamage; + } + + public void setRemoveOnAnyDamage(boolean removeOnAnyDamage) { + this.removeOnAnyDamage = removeOnAnyDamage; + } + + public long getTime() { + return time; + } + + public void setTime(long time) { + this.time = time; + } + + public Location getOrigin() { + return origin; + } + + public void setOrigin(Location origin) { + this.origin = origin; + } + + public Location getHead() { + return head; + } + + public void setHead(Location head) { + this.head = head; + } + + public int getRange() { + return range; + } + + public void setRange(int range) { + this.range = range; + } + + public Block getSourceBlock() { + return sourceBlock; + } + + public void setSourceBlock(Block sourceBlock) { + this.sourceBlock = sourceBlock; + } + + public boolean isFrozen() { + return frozen; + } + + public void setFrozen(boolean frozen) { + this.frozen = frozen; + } + + public double getPrevHealth() { + return prevHealth; + } + + public void setPrevHealth(double prevHealth) { + this.prevHealth = prevHealth; + } + + public int getHeadSize() { + return headSize; + } + + public void setHeadSize(int headSize) { + this.headSize = headSize; + } + + public boolean isUsingBottle() { + return usingBottle; + } + + public void setUsingBottle(boolean usingBottle) { + this.usingBottle = usingBottle; + } + + public ConcurrentHashMap getDirections() { + return directions; + } + + public List getBlocks() { + return blocks; + } + + @Override + public void load() {} + + @Override + public void stop() {} @Override public boolean isEnabled() { diff --git a/src/com/jedk1/jedcore/ability/waterbending/combo/WaterGimbal.java b/src/com/jedk1/jedcore/ability/waterbending/combo/WaterGimbal.java index cbcf820..93f5199 100644 --- a/src/com/jedk1/jedcore/ability/waterbending/combo/WaterGimbal.java +++ b/src/com/jedk1/jedcore/ability/waterbending/combo/WaterGimbal.java @@ -43,18 +43,18 @@ public class WaterGimbal extends WaterAbility implements AddonAbility, ComboAbility { @Attribute(Attribute.SELECT_RANGE) - private int sourcerange; + private int sourceRange; @Attribute(Attribute.COOLDOWN) private long cooldown; @Attribute("Width") - private double ringsize; + private double ringSize; @Attribute(Attribute.RANGE) private double range; @Attribute(Attribute.DAMAGE) private double damage; @Attribute(Attribute.SPEED) private double speed; - private int animspeed; + private int animSpeed; private boolean plantSourcing; private boolean snowSourcing; private boolean requireAdjacentPlants; @@ -63,20 +63,19 @@ public class WaterGimbal extends WaterAbility implements AddonAbility, ComboAbil private double entityCollisionRadius; private int step; - private double velocity = 0.15; private boolean initializing; - private boolean leftvisible = true; - private boolean rightvisible = true; - private boolean rightconsumed = false; - private boolean leftconsumed = false; - private Block sourceblock; + private boolean leftVisible = true; + private boolean rightVisible = true; + private boolean rightConsumed = false; + private boolean leftConsumed = false; + private Block sourceBlock; private TempBlock source; - private Location sourceloc; + private Location sourceLoc; private Location origin1; private Location origin2; private boolean usingBottle; - private Random rand = new Random(); + private final Random rand = new Random(); static { CollisionInitializer.abilityMap.put("WaterGimbal", ""); @@ -99,10 +98,10 @@ public WaterGimbal(Player player) { start(); initializing = true; if (hasAbility(player, Torrent.class)) { - ((Torrent) getAbility(player, Torrent.class)).remove(); + getAbility(player, Torrent.class).remove(); } if (hasAbility(player, WaterManipulation.class)) { - ((WaterManipulation) getAbility(player, WaterManipulation.class)).remove(); + getAbility(player, WaterManipulation.class).remove(); } } } @@ -110,13 +109,13 @@ public WaterGimbal(Player player) { public void setFields() { ConfigurationSection config = JedCoreConfig.getConfig(this.player); - sourcerange = config.getInt("Abilities.Water.WaterCombo.WaterGimbal.SourceRange"); + sourceRange = config.getInt("Abilities.Water.WaterCombo.WaterGimbal.SourceRange"); cooldown = config.getLong("Abilities.Water.WaterCombo.WaterGimbal.Cooldown"); - ringsize = config.getDouble("Abilities.Water.WaterCombo.WaterGimbal.RingSize"); + ringSize = config.getDouble("Abilities.Water.WaterCombo.WaterGimbal.RingSize"); range = config.getDouble("Abilities.Water.WaterCombo.WaterGimbal.Range"); damage = config.getDouble("Abilities.Water.WaterCombo.WaterGimbal.Damage"); speed = config.getDouble("Abilities.Water.WaterCombo.WaterGimbal.Speed"); - animspeed = config.getInt("Abilities.Water.WaterCombo.WaterGimbal.AnimationSpeed"); + animSpeed = config.getInt("Abilities.Water.WaterCombo.WaterGimbal.AnimationSpeed"); plantSourcing = config.getBoolean("Abilities.Water.WaterCombo.WaterGimbal.PlantSource"); snowSourcing = config.getBoolean("Abilities.Water.WaterCombo.WaterGimbal.SnowSource"); requireAdjacentPlants = config.getBoolean("Abilities.Water.WaterCombo.WaterGimbal.RequireAdjacentPlants"); @@ -144,37 +143,37 @@ public void progress() { return; } if (hasAbility(player, WaterManipulation.class)) { - ((WaterManipulation) getAbility(player, WaterManipulation.class)).remove(); + getAbility(player, WaterManipulation.class).remove(); } - if (leftconsumed && rightconsumed) { + if (leftConsumed && rightConsumed) { remove(); return; } if (!initializing) { getGimbalBlocks(player.getLocation()); - if (!leftvisible && !leftconsumed && origin1 != null) { + if (!leftVisible && !leftConsumed && origin1 != null) { if (origin1.getBlockY() <= player.getEyeLocation().getBlockY()) { new WaterBlast(player, origin1, range, damage, speed, entityCollisionRadius, abilityCollisionRadius, this); - leftconsumed = true; + leftConsumed = true; } } - if (!rightvisible && !rightconsumed && origin2 != null) { + if (!rightVisible && !rightConsumed && origin2 != null) { if (origin2.getBlockY() <= player.getEyeLocation().getBlockY()) { new WaterBlast(player, origin2, range, damage, speed, entityCollisionRadius, abilityCollisionRadius, this); - rightconsumed = true; + rightConsumed = true; } } } else { - Vector direction = GeneralMethods.getDirection(sourceloc, player.getEyeLocation()); - sourceloc = sourceloc.add(direction.multiply(1).normalize()); + Vector direction = GeneralMethods.getDirection(sourceLoc, player.getEyeLocation()); + sourceLoc = sourceLoc.add(direction.multiply(1).normalize()); - if (source == null || !sourceloc.getBlock().getLocation().equals(source.getLocation())) { + if (source == null || !sourceLoc.getBlock().getLocation().equals(source.getLocation())) { if (source != null) { source.revertBlock(); } - if (isTransparent(sourceloc.getBlock())) { - source = new TempBlock(sourceloc.getBlock(), Material.WATER, Material.WATER.createBlockData(bd -> ((Levelled)bd).setLevel(0))); + if (isTransparent(sourceLoc.getBlock())) { + source = new TempBlock(sourceLoc.getBlock(), Material.WATER, Material.WATER.createBlockData(bd -> ((Levelled) bd).setLevel(0))); } } @@ -186,30 +185,30 @@ public void progress() { } private boolean grabSource() { - sourceblock = BlockSource.getWaterSourceBlock(player, sourcerange, ClickType.SHIFT_DOWN, true, true, plantSourcing, snowSourcing, false); - if (sourceblock != null) { + sourceBlock = BlockSource.getWaterSourceBlock(player, sourceRange, ClickType.SHIFT_DOWN, true, true, plantSourcing, snowSourcing, false); + if (sourceBlock != null) { // All of these extra checks need to be done because PK sourcing system is buggy. - boolean usingSnow = snowSourcing && (sourceblock.getType() == Material.SNOW_BLOCK || sourceblock.getType() == Material.SNOW); + boolean usingSnow = snowSourcing && (sourceBlock.getType() == Material.SNOW_BLOCK || sourceBlock.getType() == Material.SNOW); - if (isPlant(sourceblock) || usingSnow) { - if (usingSnow || !requireAdjacentPlants || JCMethods.isAdjacentToThreeOrMoreSources(sourceblock, sourceblock.getType())) { - playFocusWaterEffect(sourceblock); - sourceloc = sourceblock.getLocation(); + if (isPlant(sourceBlock) || usingSnow) { + if (usingSnow || !requireAdjacentPlants || JCMethods.isAdjacentToThreeOrMoreSources(sourceBlock, sourceBlock.getType())) { + playFocusWaterEffect(sourceBlock); + sourceLoc = sourceBlock.getLocation(); - new PlantRegrowth(this.player, sourceblock); - sourceblock.setType(Material.AIR); + new PlantRegrowth(this.player, sourceBlock); + sourceBlock.setType(Material.AIR); return true; } - } else if (!ElementalAbility.isSnow(sourceblock)) { - boolean isTempBlock = TempBlock.isTempBlock(sourceblock); + } else if (!ElementalAbility.isSnow(sourceBlock)) { + boolean isTempBlock = TempBlock.isTempBlock(sourceBlock); - if (GeneralMethods.isAdjacentToThreeOrMoreSources(sourceblock, false) || (isTempBlock && WaterAbility.isBendableWaterTempBlock(sourceblock))) { - playFocusWaterEffect(sourceblock); - sourceloc = sourceblock.getLocation(); + if (GeneralMethods.isAdjacentToThreeOrMoreSources(sourceBlock, false) || (isTempBlock && WaterAbility.isBendableWaterTempBlock(sourceBlock))) { + playFocusWaterEffect(sourceBlock); + sourceLoc = sourceBlock.getLocation(); if (isTempBlock) { - PhaseChange.thaw(sourceblock); + PhaseChange.thaw(sourceBlock); } return true; @@ -223,8 +222,8 @@ private boolean grabSource() { Location forward = eye.clone().add(eye.getDirection()); if (isTransparent(eye.getBlock()) && isTransparent(forward.getBlock())) { - sourceloc = forward; - sourceblock = sourceloc.getBlock(); + sourceLoc = forward; + sourceBlock = sourceLoc.getBlock(); usingBottle = true; WaterReturn.emptyWaterBottle(player); return true; @@ -237,9 +236,9 @@ private boolean grabSource() { // This is to get around the WaterReturn limitation since OctopusForm will currently be using the bottle. private boolean hasWaterBottle(Player player) { PlayerInventory inventory = player.getInventory(); - if(inventory.contains(Material.POTION)) { + if (inventory.contains(Material.POTION)) { ItemStack item = inventory.getItem(inventory.first(Material.POTION)); - PotionMeta meta = (PotionMeta)item.getItemMeta(); + PotionMeta meta = (PotionMeta) item.getItemMeta(); return meta.getBasePotionData().getType().equals(PotionType.WATER); } @@ -248,42 +247,42 @@ private boolean hasWaterBottle(Player player) { public static void prepareBlast(Player player) { if (hasAbility(player, WaterGimbal.class)) { - ((WaterGimbal) getAbility(player, WaterGimbal.class)).prepareBlast(); + getAbility(player, WaterGimbal.class).prepareBlast(); if (hasAbility(player, WaterManipulation.class)) { - ((WaterManipulation) getAbility(player, WaterManipulation.class)).remove(); + getAbility(player, WaterManipulation.class).remove(); } } } public void prepareBlast() { - if (leftvisible) { - leftvisible = false; + if (leftVisible) { + leftVisible = false; return; } - if (rightvisible) { - rightvisible = false; - return; + if (rightVisible) { + rightVisible = false; } } private void getGimbalBlocks(Location location) { - List ring1 = new ArrayList(); - List ring2 = new ArrayList(); + List ring1 = new ArrayList<>(); + List ring2 = new ArrayList<>(); Location l = location.clone().add(0, 1, 0); int count = 0; - while (count < animspeed) { + while (count < animSpeed) { boolean completed = false; - double angle = 3.0 + this.step * this.velocity; + double velocity = 0.15; + double angle = 3.0 + this.step * velocity; double xRotation = Math.PI / 2.82 * 2.1; - Vector v1 = new Vector(Math.cos(angle), Math.sin(angle), 0.0D).multiply(ringsize); - Vector v2 = new Vector(Math.cos(angle), Math.sin(angle), 0.0D).multiply(ringsize); + Vector v1 = new Vector(Math.cos(angle), Math.sin(angle), 0.0D).multiply(ringSize); + Vector v2 = new Vector(Math.cos(angle), Math.sin(angle), 0.0D).multiply(ringSize); rotateAroundAxisX(v1, xRotation); rotateAroundAxisX(v2, -xRotation); - rotateAroundAxisY(v1, -((location.getYaw() * Math.PI / 180)-1.575)); - rotateAroundAxisY(v2, -((location.getYaw() * Math.PI / 180)-1.575)); + rotateAroundAxisY(v1, -((location.getYaw() * Math.PI / 180) - 1.575)); + rotateAroundAxisY(v2, -((location.getYaw() * Math.PI / 180) - 1.575)); - if (!ring1.contains(l.clone().add(v1).getBlock()) && !leftconsumed) { + if (!ring1.contains(l.clone().add(v1).getBlock()) && !leftConsumed) { completed = true; Block block = l.clone().add(v1).getBlock(); if (isTransparent(block)) { @@ -298,7 +297,7 @@ private void getGimbalBlocks(Location location) { } } - if (!ring2.contains(l.clone().add(v2).getBlock()) && !rightconsumed) { + if (!ring2.contains(l.clone().add(v2).getBlock()) && !rightConsumed) { completed = true; Block block = l.clone().add(v2).getBlock(); if (isTransparent(block)) { @@ -317,37 +316,33 @@ private void getGimbalBlocks(Location location) { count++; } - if (leftconsumed && rightconsumed) { + if (leftConsumed && rightConsumed) { break; } this.step++; } - if (!leftconsumed) { + if (!leftConsumed) { if (!ring1.isEmpty()) { Collections.reverse(ring1); origin1 = ring1.get(0).getLocation(); } for (Block block : ring1) { - //new TempBlock(block, Material.STATIONARY_WATER, (byte) 8); - //revert.put(block, System.currentTimeMillis() + 150L); - new RegenTempBlock(block, Material.WATER, Material.WATER.createBlockData(bd -> ((Levelled)bd).setLevel(0)), 150L); + new RegenTempBlock(block, Material.WATER, Material.WATER.createBlockData(bd -> ((Levelled) bd).setLevel(0)), 150L); if (rand.nextInt(10) == 0) { playWaterbendingSound(block.getLocation()); } } } - if (!rightconsumed) { + if (!rightConsumed) { if (!ring2.isEmpty()) { Collections.reverse(ring2); origin2 = ring2.get(0).getLocation(); } for (Block block : ring2) { - //new TempBlock(block, Material.STATIONARY_WATER, (byte) 8); - //revert.put(block, System.currentTimeMillis() + 150L); - new RegenTempBlock(block, Material.WATER, Material.WATER.createBlockData(bd -> ((Levelled)bd).setLevel(0)), 150L); + new RegenTempBlock(block, Material.WATER, Material.WATER.createBlockData(bd -> ((Levelled) bd).setLevel(0)), 150L); if (rand.nextInt(10) == 0) { playWaterbendingSound(block.getLocation()); } @@ -355,20 +350,20 @@ private void getGimbalBlocks(Location location) { } } - private Vector rotateAroundAxisX(Vector v, double angle) { + private void rotateAroundAxisX(Vector v, double angle) { double cos = Math.cos(angle); double sin = Math.sin(angle); double y = v.getY() * cos - v.getZ() * sin; double z = v.getY() * sin + v.getZ() * cos; - return v.setY(y).setZ(z); + v.setY(y).setZ(z); } - private Vector rotateAroundAxisY(Vector v, double angle) { + private void rotateAroundAxisY(Vector v, double angle) { double cos = Math.cos(angle); double sin = Math.sin(angle); double x = v.getX() * cos + v.getZ() * sin; double z = v.getX() * -sin + v.getZ() * cos; - return v.setX(x).setZ(z); + v.setX(x).setZ(z); } @Override @@ -381,7 +376,7 @@ public void remove() { } if (usingBottle) { - new WaterReturn(player, sourceblock); + new WaterReturn(player, sourceBlock); } super.remove(); } @@ -457,13 +452,207 @@ public String getVersion() { return JedCore.version; } - @Override - public void load() { + public int getSourceRange() { + return sourceRange; } - @Override - public void stop() { + public void setSourceRange(int sourceRange) { + this.sourceRange = sourceRange; + } + + public void setCooldown(long cooldown) { + this.cooldown = cooldown; + } + + public double getRingSize() { + return ringSize; + } + + public void setRingSize(double ringSize) { + this.ringSize = ringSize; + } + + public double getRange() { + return range; + } + + public void setRange(double range) { + this.range = range; + } + + public double getDamage() { + return damage; + } + + public void setDamage(double damage) { + this.damage = damage; + } + + public double getSpeed() { + return speed; + } + + public void setSpeed(double speed) { + this.speed = speed; + } + + public int getAnimSpeed() { + return animSpeed; + } + + public void setAnimSpeed(int animSpeed) { + this.animSpeed = animSpeed; + } + + public boolean isPlantSourcing() { + return plantSourcing; + } + + public void setPlantSourcing(boolean plantSourcing) { + this.plantSourcing = plantSourcing; + } + + public boolean isSnowSourcing() { + return snowSourcing; + } + + public void setSnowSourcing(boolean snowSourcing) { + this.snowSourcing = snowSourcing; + } + + public boolean isRequireAdjacentPlants() { + return requireAdjacentPlants; + } + + public void setRequireAdjacentPlants(boolean requireAdjacentPlants) { + this.requireAdjacentPlants = requireAdjacentPlants; + } + + public boolean isCanUseBottle() { + return canUseBottle; + } + + public void setCanUseBottle(boolean canUseBottle) { + this.canUseBottle = canUseBottle; + } + + public double getAbilityCollisionRadius() { + return abilityCollisionRadius; + } + + public void setAbilityCollisionRadius(double abilityCollisionRadius) { + this.abilityCollisionRadius = abilityCollisionRadius; + } + + public double getEntityCollisionRadius() { + return entityCollisionRadius; + } + + public void setEntityCollisionRadius(double entityCollisionRadius) { + this.entityCollisionRadius = entityCollisionRadius; + } + + public int getStep() { + return step; } + + public void setStep(int step) { + this.step = step; + } + + public boolean isInitializing() { + return initializing; + } + + public void setInitializing(boolean initializing) { + this.initializing = initializing; + } + + public boolean isLeftVisible() { + return leftVisible; + } + + public void setLeftVisible(boolean leftVisible) { + this.leftVisible = leftVisible; + } + + public boolean isRightVisible() { + return rightVisible; + } + + public void setRightVisible(boolean rightVisible) { + this.rightVisible = rightVisible; + } + + public boolean isRightConsumed() { + return rightConsumed; + } + + public void setRightConsumed(boolean rightConsumed) { + this.rightConsumed = rightConsumed; + } + + public boolean isLeftConsumed() { + return leftConsumed; + } + + public void setLeftConsumed(boolean leftConsumed) { + this.leftConsumed = leftConsumed; + } + + public Block getSourceBlock() { + return sourceBlock; + } + + public void setSourceBlock(Block sourceBlock) { + this.sourceBlock = sourceBlock; + } + + public TempBlock getSource() { + return source; + } + + public void setSource(TempBlock source) { + this.source = source; + } + + public Location getSourceLoc() { + return sourceLoc; + } + + public void setSourceLoc(Location sourceLoc) { + this.sourceLoc = sourceLoc; + } + + public Location getOrigin1() { + return origin1; + } + + public void setOrigin1(Location origin1) { + this.origin1 = origin1; + } + + public Location getOrigin2() { + return origin2; + } + + public void setOrigin2(Location origin2) { + this.origin2 = origin2; + } + + public boolean isUsingBottle() { + return usingBottle; + } + + public void setUsingBottle(boolean usingBottle) { + this.usingBottle = usingBottle; + } + + @Override + public void load() {} + + @Override + public void stop() {} @Override public boolean isEnabled() { diff --git a/src/com/jedk1/jedcore/listener/AbilityListener.java b/src/com/jedk1/jedcore/listener/AbilityListener.java index a15d8a6..8fcef68 100644 --- a/src/com/jedk1/jedcore/listener/AbilityListener.java +++ b/src/com/jedk1/jedcore/listener/AbilityListener.java @@ -221,7 +221,7 @@ public void onPlayerSwing(PlayerInteractEvent event) { new LavaThrow(player); } if (abil.equalsIgnoreCase("metalfragments")) { - MetalFragments.shootFragment(player, true); + MetalFragments.shootFragment(player); } if (abil.equalsIgnoreCase("metalhook")) { new MetalHook(player); @@ -489,7 +489,7 @@ public void onArrowHit(EntityDamageByEntityEvent event) { @EventHandler(priority = EventPriority.NORMAL) public void onPlayerInteraction(PlayerInteractEvent event) { if (event.getAction() == Action.RIGHT_CLICK_BLOCK) { - MetalFragments.shootFragment(event.getPlayer(), false); + MetalFragments.shootFragment(event.getPlayer()); } } } diff --git a/src/com/jedk1/jedcore/listener/JCListener.java b/src/com/jedk1/jedcore/listener/JCListener.java index 64caaea..ec2ee9a 100644 --- a/src/com/jedk1/jedcore/listener/JCListener.java +++ b/src/com/jedk1/jedcore/listener/JCListener.java @@ -139,7 +139,9 @@ public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { // Only activate these in melee range if (distSq <= 5 * 5) { - if (FirePunch.punch((Player) event.getDamager(), (LivingEntity) event.getEntity())) { + FirePunch fp = CoreAbility.getAbility((Player) event.getDamager(), FirePunch.class); + if (fp != null) { + fp.punch((LivingEntity) event.getEntity()); event.setCancelled(true); return; } @@ -163,7 +165,7 @@ public void onEntityDamageByEntity(EntityDamageByEntityEvent event) { if (event.getEntity() instanceof LivingEntity) { if (arrow.hasMetadata("daggerthrow") && arrow.getShooter() instanceof Player) { if (event.getEntity().getEntityId() != ((Player) arrow.getShooter()).getEntityId()) { - DaggerThrow.damageEntityFromArrow((Player) arrow.getShooter(), (LivingEntity) event.getEntity(), arrow); + DaggerThrow.damageEntityFromArrow(((LivingEntity) event.getEntity()), arrow); } event.setDamage(0); event.setCancelled(true);