#37 finished cannon bow adjustments

This commit is contained in:
alisolarflare 2016-12-21 21:14:38 -05:00
parent bde2256262
commit 52bb465803
2 changed files with 44 additions and 22 deletions

View file

@ -6,6 +6,7 @@ import org.bukkit.Location;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.Particle; import org.bukkit.Particle;
import org.bukkit.Sound; 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.CraftLivingEntity;
import org.bukkit.craftbukkit.v1_11_R1.entity.CraftTNTPrimed; import org.bukkit.craftbukkit.v1_11_R1.entity.CraftTNTPrimed;
import org.bukkit.enchantments.Enchantment; import org.bukkit.enchantments.Enchantment;
@ -27,10 +28,19 @@ import net.minecraft.server.v1_11_R1.EntityTNTPrimed;
public class CannonBowListener implements Listener { public class CannonBowListener implements Listener {
public static double SpeedMultiplier = 1.5; public static double SpeedMultiplier = 1.5;
public static double minforce = 0.2; public static double minforce = 0.2;
public static int fuseticks = 40;
public final static String launchedTNTName = "CANNON BOW TNT:42170"; public final static String launchedTNTName = "CANNON BOW TNT:42170";
public CannonBowListener(JavaPlugin plugin){ public CannonBowListener(JavaPlugin plugin){
SpeedMultiplier = plugin.getConfig().getDouble("magic.cannonbow.speedmultiplier"); FileConfiguration config = plugin.getConfig();
minforce = plugin.getConfig().getDouble("magic.cannonbow.minforce");
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 @EventHandler
@ -78,7 +88,7 @@ public class CannonBowListener implements Listener {
tnt.setVelocity(playerVector.multiply(SpeedMultiplier).multiply(event.getForce())); tnt.setVelocity(playerVector.multiply(SpeedMultiplier).multiply(event.getForce()));
tnt.setCustomName(launchedTNTName); tnt.setCustomName(launchedTNTName);
tnt.setFuseTicks(40); tnt.setFuseTicks(fuseticks);
//Player Recoil //Player Recoil
player.setVelocity(player.getEyeLocation().getDirection().normalize().multiply(-1)); player.setVelocity(player.getEyeLocation().getDirection().normalize().multiply(-1));

View file

@ -9,30 +9,42 @@ public class CannonBowSettings extends ModCommand {
@Override @Override
public boolean OnCommand(Player player, String alias, String[] args) { public boolean OnCommand(Player player, String alias, String[] args) {
switch(args[0].toLowerCase()){ if (args.length > 1){
case "speedmultiplier": switch(args[0].toLowerCase()){
double speedMultiplier = NumberUtils.toDouble(args[1], CannonBowListener.SpeedMultiplier); case "speedmultiplier":
CannonBowListener.SpeedMultiplier = speedMultiplier; double speedMultiplier = NumberUtils.toDouble(args[1], CannonBowListener.SpeedMultiplier);
this.getPlugin().getConfig().set("magic.cannonbow.speedmultiplier", speedMultiplier); CannonBowListener.SpeedMultiplier = speedMultiplier;
this.getPlugin().saveConfig(); this.getPlugin().getConfig().set("magic.cannonbow.speedmultiplier", speedMultiplier);
break; this.getPlugin().saveConfig();
case "minforce": break;
double minforce = NumberUtils.toDouble(args[1], CannonBowListener.minforce); case "minforce":
CannonBowListener.minforce = minforce; double minforce = NumberUtils.toDouble(args[1], CannonBowListener.minforce);
this.getPlugin().getConfig().set("magic.cannonbow.minforce", minforce); CannonBowListener.minforce = minforce;
this.getPlugin().saveConfig(); this.getPlugin().getConfig().set("magic.cannonbow.minforce", minforce);
break; this.getPlugin().saveConfig();
default: break;
player.sendMessage("That isn't a valid setting!"); case "fuseticks":
player.sendMessage("Valid Settings are: "); int fuseticks = NumberUtils.toInt(args[1], CannonBowListener.fuseticks);
return false; 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; return true;
} }
@Override @Override
public String GetCommandPath(){ public String GetCommandPath(){
return "magic cannonbow"; return "magic cannonbow";
} }
} }