#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.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));

View file

@ -9,6 +9,7 @@ public class CannonBowSettings extends ModCommand {
@Override
public boolean OnCommand(Player player, String alias, String[] args) {
if (args.length > 1){
switch(args[0].toLowerCase()){
case "speedmultiplier":
double speedMultiplier = NumberUtils.toDouble(args[1], CannonBowListener.SpeedMultiplier);
@ -22,11 +23,22 @@ public class CannonBowSettings extends ModCommand {
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;
}