Adjusted and created settings for Cannon Bow <@114932850507120641> #40
3 changed files with 73 additions and 28 deletions
|
@ -35,6 +35,10 @@ public class AliArrowTask extends BukkitRunnable {
|
||||||
case "norbipeti":
|
case "norbipeti":
|
||||||
arrow.getWorld().spawnParticle(Particle.LAVA, arrow.getLocation(), 1);
|
arrow.getWorld().spawnParticle(Particle.LAVA, arrow.getLocation(), 1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
|
case "mayskam1995":
|
||||||
|
arrow.getWorld().spawnParticle(Particle.DRIP_WATER, arrow.getLocation(), 2);
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -26,21 +26,25 @@ import net.minecraft.server.v1_11_R1.EntityLiving;
|
||||||
import net.minecraft.server.v1_11_R1.EntityTNTPrimed;
|
import net.minecraft.server.v1_11_R1.EntityTNTPrimed;
|
||||||
|
|
||||||
public class CannonBowListener implements Listener {
|
public class CannonBowListener implements Listener {
|
||||||
public static double SpeedMultiplier = 1.5;
|
private static double SpeedMultiplier = 1.5;
|
||||||
public static double minforce = 0.2;
|
private static double minforce = 0.2;
|
||||||
public static int fuseticks = 40;
|
private static int fuseticks = 40;
|
||||||
|
private static double recoil = 1;
|
||||||
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){
|
||||||
FileConfiguration config = plugin.getConfig();
|
FileConfiguration config = plugin.getConfig();
|
||||||
|
|
||||||
if (config.isDouble("magic.cannonbow.speedmultiplier"))
|
if (config.isDouble("magic.cannonbow.speedmultiplier"))
|
||||||
SpeedMultiplier = config.getDouble("magic.cannonbow.speedmultiplier");
|
setSpeedMultiplier(config.getDouble("magic.cannonbow.speedmultiplier"));
|
||||||
|
|
||||||
if (config.isDouble("magic.cannonbow.minforce"))
|
if (config.isDouble("magic.cannonbow.minforce"))
|
||||||
minforce = config.getDouble("magic.cannonbow.minforce");
|
setMinforce(config.getDouble("magic.cannonbow.minforce"));
|
||||||
|
|
||||||
if (config.isInt("magic.cannonbow.fuseticks"))
|
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
|
@EventHandler
|
||||||
|
@ -64,14 +68,15 @@ public class CannonBowListener implements Listener {
|
||||||
if (!(bow.getItemMeta().getDisplayName().toUpperCase().contains("CANNON BOW")))return;
|
if (!(bow.getItemMeta().getDisplayName().toUpperCase().contains("CANNON BOW")))return;
|
||||||
|
|
||||||
//TNT Spawning
|
//TNT Spawning
|
||||||
|
|
||||||
Vector playerVector = player.getEyeLocation().getDirection().normalize();
|
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().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{
|
}else{
|
||||||
|
//Spawn TNT
|
||||||
TNTPrimed tnt = (TNTPrimed) arrow.getWorld().spawnEntity(arrow.getLocation(), EntityType.PRIMED_TNT);
|
TNTPrimed tnt = (TNTPrimed) arrow.getWorld().spawnEntity(arrow.getLocation(), EntityType.PRIMED_TNT);
|
||||||
|
|
||||||
// Change via NMS the source of the TNT by the player
|
// Change via NMS the source of the TNT by the player
|
||||||
|
@ -85,13 +90,13 @@ public class CannonBowListener implements Listener {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//
|
||||||
tnt.setVelocity(playerVector.multiply(SpeedMultiplier).multiply(event.getForce()));
|
tnt.setVelocity(playerVector.multiply(getSpeedMultiplier()).multiply(event.getForce()));
|
||||||
tnt.setCustomName(launchedTNTName);
|
tnt.setCustomName(launchedTNTName);
|
||||||
tnt.setFuseTicks(fuseticks);
|
tnt.setFuseTicks(getFuseticks());
|
||||||
|
|
||||||
//Player Recoil
|
//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().playSound(player.getLocation(), Sound.ENTITY_GENERIC_EXPLODE, 1.0F, 0);
|
||||||
player.getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, player.getLocation(), 2);
|
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;
|
||||||
|
}
|
||||||
}
|
}
|
|
@ -12,26 +12,22 @@ public class CannonBowSettings extends ModCommand {
|
||||||
if (args.length > 1){
|
if (args.length > 1){
|
||||||
switch(args[0].toLowerCase()){
|
switch(args[0].toLowerCase()){
|
||||||
case "speedmultiplier":
|
case "speedmultiplier":
|
||||||
double speedMultiplier = NumberUtils.toDouble(args[1], CannonBowListener.SpeedMultiplier);
|
CannonBowListener.setSpeedMultiplier(NumberUtils.toDouble(args[1], CannonBowListener.getSpeedMultiplier()));
|
||||||
CannonBowListener.SpeedMultiplier = speedMultiplier;
|
|
||||||
this.getPlugin().getConfig().set("magic.cannonbow.speedmultiplier", speedMultiplier);
|
|
||||||
this.getPlugin().saveConfig();
|
|
||||||
break;
|
break;
|
||||||
case "minforce":
|
case "minforce":
|
||||||
double minforce = NumberUtils.toDouble(args[1], CannonBowListener.minforce);
|
CannonBowListener.setMinforce(NumberUtils.toDouble(args[1], CannonBowListener.getMinforce()));
|
||||||
CannonBowListener.minforce = minforce;
|
|
||||||
this.getPlugin().getConfig().set("magic.cannonbow.minforce", minforce);
|
|
||||||
this.getPlugin().saveConfig();
|
|
||||||
break;
|
break;
|
||||||
case "fuseticks":
|
case "fuseticks":
|
||||||
int fuseticks = NumberUtils.toInt(args[1], CannonBowListener.fuseticks);
|
CannonBowListener.setFuseticks(NumberUtils.toInt(args[1], CannonBowListener.getFuseticks()));
|
||||||
CannonBowListener.fuseticks = fuseticks;
|
break;
|
||||||
this.getPlugin().getConfig().set("magic.cannonbow.fuseticks", fuseticks);
|
case "recoil":
|
||||||
this.getPlugin().saveConfig();
|
CannonBowListener.setRecoil(NumberUtils.toDouble((args[1]), CannonBowListener.getRecoil()));
|
||||||
break;
|
break;
|
||||||
case "display":
|
case "display":
|
||||||
player.sendMessage("Speed Multiplier: "+CannonBowListener.SpeedMultiplier);
|
player.sendMessage("Speed Multiplier: "+CannonBowListener.getSpeedMultiplier());
|
||||||
player.sendMessage("Minimum Force : "+CannonBowListener.minforce);
|
player.sendMessage("Minimum Force: "+CannonBowListener.getMinforce());
|
||||||
|
player.sendMessage("Fuseticks: " + CannonBowListener.getFuseticks());
|
||||||
|
player.sendMessage("Recoil: " + CannonBowListener.getRecoil());
|
||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
player.sendMessage("That isn't a valid setting!");
|
player.sendMessage("That isn't a valid setting!");
|
||||||
|
@ -44,7 +40,7 @@ public class CannonBowSettings extends ModCommand {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String GetCommandPath(){
|
public String GetCommandPath(){
|
||||||
return "magic cannonbow";
|
return "magic cannonbow settings";
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue