From 81b830e8055882f58fb59e87fc630732d7785373 Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Wed, 21 Dec 2016 23:12:04 -0500 Subject: [PATCH] Added Maximum and minimum settings (Also gave kayla an arrow trail :D) --- .../components/magic/tricks/AliArrowTask.java | 4 ++ .../magic/tricks/CannonBowListener.java | 71 +++++++++++++++---- .../magic/tricks/CannonBowSettings.java | 26 +++---- 3 files changed, 73 insertions(+), 28 deletions(-) diff --git a/src/buttondevteam/alipresents/components/magic/tricks/AliArrowTask.java b/src/buttondevteam/alipresents/components/magic/tricks/AliArrowTask.java index f607210..05c5611 100644 --- a/src/buttondevteam/alipresents/components/magic/tricks/AliArrowTask.java +++ b/src/buttondevteam/alipresents/components/magic/tricks/AliArrowTask.java @@ -35,6 +35,10 @@ public class AliArrowTask extends BukkitRunnable { case "norbipeti": arrow.getWorld().spawnParticle(Particle.LAVA, arrow.getLocation(), 1); break; + + case "mayskam1995": + arrow.getWorld().spawnParticle(Particle.DRIP_WATER, arrow.getLocation(), 2); + break; } } diff --git a/src/buttondevteam/alipresents/components/magic/tricks/CannonBowListener.java b/src/buttondevteam/alipresents/components/magic/tricks/CannonBowListener.java index 6c04546..1dc1017 100644 --- a/src/buttondevteam/alipresents/components/magic/tricks/CannonBowListener.java +++ b/src/buttondevteam/alipresents/components/magic/tricks/CannonBowListener.java @@ -26,21 +26,25 @@ import net.minecraft.server.v1_11_R1.EntityLiving; import net.minecraft.server.v1_11_R1.EntityTNTPrimed; public class CannonBowListener implements Listener { - public static double SpeedMultiplier = 1.5; - public static double minforce = 0.2; - public static int fuseticks = 40; + private static double SpeedMultiplier = 1.5; + private static double minforce = 0.2; + private static int fuseticks = 40; + private static double recoil = 1; public final static String launchedTNTName = "CANNON BOW TNT:42170"; public CannonBowListener(JavaPlugin plugin){ FileConfiguration config = plugin.getConfig(); if (config.isDouble("magic.cannonbow.speedmultiplier")) - SpeedMultiplier = config.getDouble("magic.cannonbow.speedmultiplier"); + setSpeedMultiplier(config.getDouble("magic.cannonbow.speedmultiplier")); if (config.isDouble("magic.cannonbow.minforce")) - minforce = config.getDouble("magic.cannonbow.minforce"); + setMinforce(config.getDouble("magic.cannonbow.minforce")); if (config.isInt("magic.cannonbow.fuseticks")) - fuseticks = config.getInt("magic.cannonbow.fuseticks"); + setFuseticks(config.getInt("magic.cannonbow.fuseticks")); + + if (config.isDouble("magic.cannonbow.recoil")) + setRecoil(config.getDouble("magic.cannonbow.recoil")); } @EventHandler @@ -64,14 +68,15 @@ public class CannonBowListener implements Listener { if (!(bow.getItemMeta().getDisplayName().toUpperCase().contains("CANNON BOW")))return; //TNT Spawning - Vector playerVector = player.getEyeLocation().getDirection().normalize(); - if (event.getForce() < minforce){ + if (event.getForce() < getMinforce()){ + //Smoke cloud if draw is too low arrow.getWorld().spawnParticle(Particle.SMOKE_NORMAL, player.getLocation(), 30); - arrow.getWorld().playSound(player.getLocation(), Sound.BLOCK_LADDER_BREAK, 1.0F, -14); + arrow.getWorld().playSound(player.getLocation(), Sound.BLOCK_LADDER_BREAK, 1.0F, -7); }else{ + //Spawn TNT TNTPrimed tnt = (TNTPrimed) arrow.getWorld().spawnEntity(arrow.getLocation(), EntityType.PRIMED_TNT); // Change via NMS the source of the TNT by the player @@ -85,13 +90,13 @@ public class CannonBowListener implements Listener { ex.printStackTrace(); } - - tnt.setVelocity(playerVector.multiply(SpeedMultiplier).multiply(event.getForce())); + // + tnt.setVelocity(playerVector.multiply(getSpeedMultiplier()).multiply(event.getForce())); tnt.setCustomName(launchedTNTName); - tnt.setFuseTicks(fuseticks); + tnt.setFuseTicks(getFuseticks()); //Player Recoil - player.setVelocity(player.getEyeLocation().getDirection().normalize().multiply(-1)); + player.setVelocity(player.getEyeLocation().getDirection().normalize().multiply(-1).multiply(getRecoil())); player.getWorld().playSound(player.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1.0F, 0); player.getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, player.getLocation(), 2); @@ -114,4 +119,44 @@ public class CannonBowListener implements Listener { } + + public static double getSpeedMultiplier() { + return SpeedMultiplier; + } + + public static void setSpeedMultiplier(double speedMultiplier) { + if (speedMultiplier > 4) speedMultiplier = 4; + if (speedMultiplier < 0) speedMultiplier = 0; + SpeedMultiplier = speedMultiplier; + } + + public static double getMinforce() { + return minforce; + } + + public static void setMinforce(double minforce) { + if (minforce > 1) minforce = 1; + if (minforce < 0) minforce = 0; + CannonBowListener.minforce = minforce; + } + + public static int getFuseticks() { + return fuseticks; + } + + public static void setFuseticks(int fuseticks) { + if (fuseticks > 400) fuseticks = 400; + if (fuseticks < 0) fuseticks = 0; + CannonBowListener.fuseticks = fuseticks; + } + + public static double getRecoil() { + return recoil; + } + + public static void setRecoil(double recoil) { + if (recoil > 20) recoil = 20; + if (recoil < 0) recoil = 0; + CannonBowListener.recoil = recoil; + } } \ No newline at end of file diff --git a/src/buttondevteam/alipresents/components/magic/tricks/CannonBowSettings.java b/src/buttondevteam/alipresents/components/magic/tricks/CannonBowSettings.java index c34641d..d781203 100644 --- a/src/buttondevteam/alipresents/components/magic/tricks/CannonBowSettings.java +++ b/src/buttondevteam/alipresents/components/magic/tricks/CannonBowSettings.java @@ -12,26 +12,22 @@ public class CannonBowSettings extends ModCommand { if (args.length > 1){ switch(args[0].toLowerCase()){ case "speedmultiplier": - double speedMultiplier = NumberUtils.toDouble(args[1], CannonBowListener.SpeedMultiplier); - CannonBowListener.SpeedMultiplier = speedMultiplier; - this.getPlugin().getConfig().set("magic.cannonbow.speedmultiplier", speedMultiplier); - this.getPlugin().saveConfig(); + CannonBowListener.setSpeedMultiplier(NumberUtils.toDouble(args[1], CannonBowListener.getSpeedMultiplier())); break; case "minforce": - double minforce = NumberUtils.toDouble(args[1], CannonBowListener.minforce); - CannonBowListener.minforce = minforce; - this.getPlugin().getConfig().set("magic.cannonbow.minforce", minforce); - this.getPlugin().saveConfig(); + CannonBowListener.setMinforce(NumberUtils.toDouble(args[1], CannonBowListener.getMinforce())); break; case "fuseticks": - int fuseticks = NumberUtils.toInt(args[1], CannonBowListener.fuseticks); - CannonBowListener.fuseticks = fuseticks; - this.getPlugin().getConfig().set("magic.cannonbow.fuseticks", fuseticks); - this.getPlugin().saveConfig(); + CannonBowListener.setFuseticks(NumberUtils.toInt(args[1], CannonBowListener.getFuseticks())); + break; + case "recoil": + CannonBowListener.setRecoil(NumberUtils.toDouble((args[1]), CannonBowListener.getRecoil())); break; case "display": - player.sendMessage("Speed Multiplier: "+CannonBowListener.SpeedMultiplier); - player.sendMessage("Minimum Force : "+CannonBowListener.minforce); + player.sendMessage("Speed Multiplier: "+CannonBowListener.getSpeedMultiplier()); + player.sendMessage("Minimum Force: "+CannonBowListener.getMinforce()); + player.sendMessage("Fuseticks: " + CannonBowListener.getFuseticks()); + player.sendMessage("Recoil: " + CannonBowListener.getRecoil()); break; default: player.sendMessage("That isn't a valid setting!"); @@ -44,7 +40,7 @@ public class CannonBowSettings extends ModCommand { @Override public String GetCommandPath(){ - return "magic cannonbow"; + return "magic cannonbow settings"; } }