From 52bb4658036ec9cb82ca2332f40c7922e85553fd Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Wed, 21 Dec 2016 21:14:38 -0500 Subject: [PATCH] #37 finished cannon bow adjustments --- .../magic/tricks/CannonBowListener.java | 16 ++++-- .../magic/tricks/CannonBowSettings.java | 50 ++++++++++++------- 2 files changed, 44 insertions(+), 22 deletions(-) diff --git a/src/buttondevteam/alipresents/components/magic/tricks/CannonBowListener.java b/src/buttondevteam/alipresents/components/magic/tricks/CannonBowListener.java index a266827..6c04546 100644 --- a/src/buttondevteam/alipresents/components/magic/tricks/CannonBowListener.java +++ b/src/buttondevteam/alipresents/components/magic/tricks/CannonBowListener.java @@ -6,6 +6,7 @@ import org.bukkit.Location; import org.bukkit.Material; import org.bukkit.Particle; import org.bukkit.Sound; +import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.craftbukkit.v1_11_R1.entity.CraftLivingEntity; import org.bukkit.craftbukkit.v1_11_R1.entity.CraftTNTPrimed; import org.bukkit.enchantments.Enchantment; @@ -27,10 +28,19 @@ 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; public final static String launchedTNTName = "CANNON BOW TNT:42170"; public CannonBowListener(JavaPlugin plugin){ - SpeedMultiplier = plugin.getConfig().getDouble("magic.cannonbow.speedmultiplier"); - minforce = plugin.getConfig().getDouble("magic.cannonbow.minforce"); + FileConfiguration config = plugin.getConfig(); + + if (config.isDouble("magic.cannonbow.speedmultiplier")) + SpeedMultiplier = config.getDouble("magic.cannonbow.speedmultiplier"); + + if (config.isDouble("magic.cannonbow.minforce")) + minforce = config.getDouble("magic.cannonbow.minforce"); + + if (config.isInt("magic.cannonbow.fuseticks")) + fuseticks = config.getInt("magic.cannonbow.fuseticks"); } @EventHandler @@ -78,7 +88,7 @@ public class CannonBowListener implements Listener { tnt.setVelocity(playerVector.multiply(SpeedMultiplier).multiply(event.getForce())); tnt.setCustomName(launchedTNTName); - tnt.setFuseTicks(40); + tnt.setFuseTicks(fuseticks); //Player Recoil player.setVelocity(player.getEyeLocation().getDirection().normalize().multiply(-1)); diff --git a/src/buttondevteam/alipresents/components/magic/tricks/CannonBowSettings.java b/src/buttondevteam/alipresents/components/magic/tricks/CannonBowSettings.java index d081bd3..c34641d 100644 --- a/src/buttondevteam/alipresents/components/magic/tricks/CannonBowSettings.java +++ b/src/buttondevteam/alipresents/components/magic/tricks/CannonBowSettings.java @@ -9,30 +9,42 @@ public class CannonBowSettings extends ModCommand { @Override public boolean OnCommand(Player player, String alias, String[] args) { - 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(); - 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(); - break; - default: - player.sendMessage("That isn't a valid setting!"); - player.sendMessage("Valid Settings are: "); - return false; + 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(); + 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(); + 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(); + break; + case "display": + player.sendMessage("Speed Multiplier: "+CannonBowListener.SpeedMultiplier); + player.sendMessage("Minimum Force : "+CannonBowListener.minforce); + break; + default: + player.sendMessage("That isn't a valid setting!"); + player.sendMessage("Valid Settings are: "); + return false; + } } return true; } - + @Override public String GetCommandPath(){ return "magic cannonbow"; } - + }