From ab973bdc0355fdd912410c5d2a9180b6ada2e9eb Mon Sep 17 00:00:00 2001 From: runefist Date: Tue, 23 Sep 2014 12:33:53 +0200 Subject: [PATCH] FallingSand config! Owners can now decide if bending affects fallingsand, there are 2 types of fallingsand: TNT and fallingsand, for both there are 2 config options if bending should affect it, and if it affects it, than what should be the strength multiplier be? 1.0 is the default strength and 0.1 is 1/10 of the normal strength. For developers: new Methods, Methods.setVelocity(entity, vector) --- .../projectkorra/ProjectKorra/ConfigManager.java | 4 ++++ src/com/projectkorra/ProjectKorra/Methods.java | 16 ++++++++++++++++ .../ProjectKorra/airbending/AirBlast.java | 2 +- .../ProjectKorra/airbending/AirShield.java | 2 +- .../ProjectKorra/airbending/AirSuction.java | 2 +- .../ProjectKorra/airbending/AirSwipe.java | 4 ++-- .../ProjectKorra/airbending/Tornado.java | 2 +- .../ProjectKorra/firebending/FireBlast.java | 4 ++-- .../ProjectKorra/firebending/WallOfFire.java | 2 +- .../ProjectKorra/waterbending/Torrent.java | 2 +- .../ProjectKorra/waterbending/Wave.java | 2 +- 11 files changed, 31 insertions(+), 11 deletions(-) diff --git a/src/com/projectkorra/ProjectKorra/ConfigManager.java b/src/com/projectkorra/ProjectKorra/ConfigManager.java index de4e4a59..f5bd80c2 100644 --- a/src/com/projectkorra/ProjectKorra/ConfigManager.java +++ b/src/com/projectkorra/ProjectKorra/ConfigManager.java @@ -49,6 +49,10 @@ public class ConfigManager { config.addDefault("Properties.Chat.Colors.Chi", "GOLD"); config.addDefault("Properties.ImportEnabled", true); + config.addDefault("Properties.BendingAffectFallingSand.Normal", true); + config.addDefault("Properties.BendingAffectFallingSand.NormalStrengthMultiplier", 1.0); + config.addDefault("Properties.BendingAffectFallingSand.TNT", true); + config.addDefault("Properties.BendingAffectFallingSand.TNTStrengthMultiplier", 1.0); config.addDefault("Properties.GlobalCooldown", 500); config.addDefault("Properties.SeaLevel", 62); diff --git a/src/com/projectkorra/ProjectKorra/Methods.java b/src/com/projectkorra/ProjectKorra/Methods.java index 1b866fec..c3d60367 100644 --- a/src/com/projectkorra/ProjectKorra/Methods.java +++ b/src/com/projectkorra/ProjectKorra/Methods.java @@ -119,6 +119,8 @@ import com.sk89q.worldguard.protection.flags.DefaultFlag; import fr.neatmonster.nocheatplus.checks.CheckType; import fr.neatmonster.nocheatplus.hooks.NCPExemptionManager; +import org.bukkit.entity.FallingSand; +import org.bukkit.entity.TNTPrimed; public class Methods { @@ -1892,6 +1894,20 @@ public class Methods { EarthPassive.removeAll(); } + + public static void setVelocity(Entity entity, Vector velocity){ + if (entity instanceof TNTPrimed){ + if (plugin.getConfig().getBoolean("Properties.BendingAffectFallingSand.TNT")) + entity.setVelocity(velocity.multiply(plugin.getConfig().getDouble("Properties.BendingAffectFallingSand.TNTStrengthMultiplier"))); + return; + } + if (entity instanceof FallingSand){ + if (plugin.getConfig().getBoolean("Properties.BendingAffectFallingSand.Normal")) + entity.setVelocity(velocity.multiply(plugin.getConfig().getDouble("Properties.BendingAffectFallingSand.NormalStrengthMultiplier"))); + return; + } + entity.setVelocity(velocity); + } public static double waterbendingNightAugment(double value, World world) { if (isNight(world)) { diff --git a/src/com/projectkorra/ProjectKorra/airbending/AirBlast.java b/src/com/projectkorra/ProjectKorra/airbending/AirBlast.java index 822602c6..c707cf99 100644 --- a/src/com/projectkorra/ProjectKorra/airbending/AirBlast.java +++ b/src/com/projectkorra/ProjectKorra/airbending/AirBlast.java @@ -249,7 +249,7 @@ public class AirBlast { if (Commands.invincible.contains(((Player) entity).getName())) return; } - entity.setVelocity(velocity); + Methods.setVelocity(entity, velocity); entity.setFallDistance(0); if (!isUser && entity instanceof Player) { new Flight((Player) entity, player); diff --git a/src/com/projectkorra/ProjectKorra/airbending/AirShield.java b/src/com/projectkorra/ProjectKorra/airbending/AirShield.java index a78d627b..e982335b 100644 --- a/src/com/projectkorra/ProjectKorra/airbending/AirShield.java +++ b/src/com/projectkorra/ProjectKorra/airbending/AirShield.java @@ -92,7 +92,7 @@ public class AirShield { } velocity.multiply(radius / maxradius); - entity.setVelocity(velocity); + Methods.setVelocity(entity, velocity); entity.setFallDistance(0); } } diff --git a/src/com/projectkorra/ProjectKorra/airbending/AirSuction.java b/src/com/projectkorra/ProjectKorra/airbending/AirSuction.java index f670bd6f..7c71eefd 100644 --- a/src/com/projectkorra/ProjectKorra/airbending/AirSuction.java +++ b/src/com/projectkorra/ProjectKorra/airbending/AirSuction.java @@ -192,7 +192,7 @@ public class AirSuction { if (entity instanceof Player) { if (Commands.invincible.contains(((Player) entity).getName())) continue; } - entity.setVelocity(velocity); + Methods.setVelocity(entity, velocity); entity.setFallDistance(0); if (entity.getEntityId() != player.getEntityId() && entity instanceof Player) { diff --git a/src/com/projectkorra/ProjectKorra/airbending/AirSwipe.java b/src/com/projectkorra/ProjectKorra/airbending/AirSwipe.java index cda6f140..68f8dfda 100644 --- a/src/com/projectkorra/ProjectKorra/airbending/AirSwipe.java +++ b/src/com/projectkorra/ProjectKorra/airbending/AirSwipe.java @@ -247,9 +247,9 @@ public class AirSwipe { } if(surroundingEntities.size() < MAX_AFFECTABLE_ENTITIES){ if (AvatarState.isAvatarState(player)) { - entity.setVelocity(fDirection.multiply(AvatarState.getValue(pushfactor))); + Methods.setVelocity(entity, fDirection.multiply(AvatarState.getValue(pushfactor))); } else { - entity.setVelocity(fDirection.multiply(pushfactor)); + Methods.setVelocity(entity, fDirection.multiply(pushfactor)); } } if (entity instanceof LivingEntity diff --git a/src/com/projectkorra/ProjectKorra/airbending/Tornado.java b/src/com/projectkorra/ProjectKorra/airbending/Tornado.java index a6363879..a8b5d3c7 100644 --- a/src/com/projectkorra/ProjectKorra/airbending/Tornado.java +++ b/src/com/projectkorra/ProjectKorra/airbending/Tornado.java @@ -157,7 +157,7 @@ public class Tornado { velocity.setZ(vz); velocity.setY(vy); velocity.multiply(timefactor); - entity.setVelocity(velocity); + Methods.setVelocity(entity, velocity); entity.setFallDistance(0); Methods.breakBreathbendingHold(entity); diff --git a/src/com/projectkorra/ProjectKorra/firebending/FireBlast.java b/src/com/projectkorra/ProjectKorra/firebending/FireBlast.java index d684c105..084255cb 100644 --- a/src/com/projectkorra/ProjectKorra/firebending/FireBlast.java +++ b/src/com/projectkorra/ProjectKorra/firebending/FireBlast.java @@ -195,9 +195,9 @@ public class FireBlast { private void affect(Entity entity) { if (entity.getEntityId() != player.getEntityId()) { if (AvatarState.isAvatarState(player)) { - entity.setVelocity(direction.clone().multiply(AvatarState.getValue(pushfactor))); + Methods.setVelocity(entity, direction.clone().multiply(AvatarState.getValue(pushfactor))); } else { - entity.setVelocity(direction.clone().multiply(pushfactor)); + Methods.setVelocity(entity, direction.clone().multiply(pushfactor)); } if (entity instanceof LivingEntity) { entity.setFireTicks(50); diff --git a/src/com/projectkorra/ProjectKorra/firebending/WallOfFire.java b/src/com/projectkorra/ProjectKorra/firebending/WallOfFire.java index 59555762..8f88b049 100644 --- a/src/com/projectkorra/ProjectKorra/firebending/WallOfFire.java +++ b/src/com/projectkorra/ProjectKorra/firebending/WallOfFire.java @@ -175,7 +175,7 @@ public class WallOfFire { private void affect(Entity entity) { entity.setFireTicks(50); - entity.setVelocity(new Vector(0, 0, 0)); + Methods.setVelocity(entity, new Vector(0, 0, 0)); if (entity instanceof LivingEntity) { Methods.damageEntity(player, entity, damage); new Enflamed(entity, player); diff --git a/src/com/projectkorra/ProjectKorra/waterbending/Torrent.java b/src/com/projectkorra/ProjectKorra/waterbending/Torrent.java index b1f2c79b..7cffb7e3 100644 --- a/src/com/projectkorra/ProjectKorra/waterbending/Torrent.java +++ b/src/com/projectkorra/ProjectKorra/waterbending/Torrent.java @@ -498,7 +498,7 @@ public class Torrent { velocity.setZ(vec.getY()); } - entity.setVelocity(velocity); + Methods.setVelocity(entity, velocity); entity.setFallDistance(0); if (entity instanceof LivingEntity) { World world = player.getWorld(); diff --git a/src/com/projectkorra/ProjectKorra/waterbending/Wave.java b/src/com/projectkorra/ProjectKorra/waterbending/Wave.java index 3a388cf6..a0839910 100644 --- a/src/com/projectkorra/ProjectKorra/waterbending/Wave.java +++ b/src/com/projectkorra/ProjectKorra/waterbending/Wave.java @@ -295,7 +295,7 @@ public class Wave { if (knockback) { Vector dir = direction.clone(); dir.setY(dir.getY() * upfactor); - entity.setVelocity(entity.getVelocity().clone() + Methods.setVelocity(entity, entity.getVelocity().clone() .add(dir.clone().multiply(Methods.waterbendingNightAugment(factor, player.getWorld())))); entity.setFallDistance(0); if (entity.getFireTicks() > 0)