Started Work on Dungeons #43

Merged
alisolarflare merged 7 commits from Dungeons into master 2016-12-24 07:39:43 +00:00
2 changed files with 164 additions and 61 deletions
Showing only changes of commit 7d012bb9ec - Show all commits

View file

@ -4,6 +4,7 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Particle;
import org.bukkit.Sound;
import org.bukkit.command.CommandSender;
import org.bukkit.configuration.file.FileConfiguration;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.Arrow;
@ -19,25 +20,56 @@ import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.util.Vector;
public class CannonBowListener implements Listener {
private static double SpeedMultiplier = 1.5;
private static double minforce = 0.2;
private static int fuseticks = 40;
private static double recoil = 1;
private static double maxSpeedMultiplier = 4;
private static double minSpeedMultiplier = 0;
private static double defaultSpeedMultiplier = 1;
private static String speedMultiplierPath = "magic.cannonbow.speedmultiplier";
private static int maxFuseTicks = 400;
private static int minFuseTicks = 0;
private static int defaultFuseTicks = 30;
private static String fuseTicksPath = "magic.cannonbow.fuseticks";
private static double maxMinForce = 1;
private static double minMinForce = 0;
private static double defaultMinForce = 0.2;
private static String minForcePath = "magic.cannonbow.minforce";
private static double maxRecoil = 20;
private static double minRecoil = -5;
private static double defaultRecoil = 1;
private static String recoilPath = "magic.cannonbow.recoil";
private static boolean defaultIsDestructive = false;
private static String isDestructivePath = "magic.cannonbow.isdestructive";
private static double speedMultiplier = defaultSpeedMultiplier;
private static double minForce = defaultMinForce;
private static int fuseTicks = defaultFuseTicks;
private static double recoil = defaultRecoil;
private static boolean isDestructive = defaultIsDestructive;
public final static String launchedTNTName = "CANNON BOW TNT:42170";
static FileConfiguration config;
public CannonBowListener(JavaPlugin plugin){
FileConfiguration config = plugin.getConfig();
config = plugin.getConfig();
if (config.isDouble("magic.cannonbow.speedmultiplier"))
setSpeedMultiplier(config.getDouble("magic.cannonbow.speedmultiplier"));
if (config.isDouble(speedMultiplierPath))
setSpeedMultiplier(config.getDouble(speedMultiplierPath));
if (config.isDouble("magic.cannonbow.minforce"))
setMinforce(config.getDouble("magic.cannonbow.minforce"));
if (config.isDouble(minForcePath))
setMinforce(config.getDouble(minForcePath));
if (config.isInt("magic.cannonbow.fuseticks"))
setFuseticks(config.getInt("magic.cannonbow.fuseticks"));
if (config.isInt(fuseTicksPath))
setFuseticks(config.getInt(fuseTicksPath));
if (config.isDouble("magic.cannonbow.recoil"))
setRecoil(config.getDouble("magic.cannonbow.recoil"));
if (config.isDouble(recoilPath))
setRecoil(config.getDouble(recoilPath));
if (config.isBoolean(isDestructivePath))
setIsDestructive(config.getBoolean(isDestructivePath));
}
@EventHandler
@ -62,11 +94,12 @@ public class CannonBowListener implements Listener {
//TNT Spawning
Vector playerVector = player.getEyeLocation().getDirection().normalize();
Location playerLocation = player.getLocation();
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, -7);
arrow.getWorld().spawnParticle(Particle.SMOKE_NORMAL, playerLocation, 30);
arrow.getWorld().playSound(playerLocation, Sound.BLOCK_LADDER_BREAK, 1.0F, -7);
}else{
//Spawn TNT
@ -89,9 +122,9 @@ public class CannonBowListener implements Listener {
tnt.setFuseTicks(getFuseticks());
//Player Recoil
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);
player.setVelocity(playerVector.multiply(-1).multiply(getRecoil()));
player.getWorld().playSound(playerLocation, Sound.ENTITY_GENERIC_EXPLODE, 1.0F, 0);
player.getWorld().spawnParticle(Particle.EXPLOSION_NORMAL, playerLocation, 2);
}
arrow.remove();
@ -106,50 +139,111 @@ public class CannonBowListener implements Listener {
if (event.getEntityType() != EntityType.PRIMED_TNT) return;
if (event.getEntity().getCustomName() != "CANNON BOW TNT:42170") return;
if (isDestructive == true){
Location loc = event.getEntity().getLocation();
event.getEntity().getWorld().createExplosion(loc.getX(), loc.getY(), loc.getZ(), 3, false, false);
event.setCancelled(true);
}
}
public static double getSpeedMultiplier() {
return SpeedMultiplier;
return speedMultiplier;
}
public static void setSpeedMultiplier(double speedMultiplier) {
if (speedMultiplier > 4) speedMultiplier = 4;
if (speedMultiplier < 0) speedMultiplier = 0;
SpeedMultiplier = speedMultiplier;
public static void setSpeedMultiplier(double multiplier, CommandSender sender){
if (multiplier > maxSpeedMultiplier) sender.sendMessage("SpeedMultiplier is too Large! Setting multiplier to "+ maxSpeedMultiplier);
if (multiplier < maxSpeedMultiplier) sender.sendMessage("SpeedMultiplier is too Small! Setting multiplier to "+ minSpeedMultiplier);
setSpeedMultiplier(multiplier, sender);
sender.sendMessage("SpeedMultiplier set to " + getSpeedMultiplier());
}
public static void setSpeedMultiplier(double multiplier) {
if (multiplier > maxSpeedMultiplier) multiplier = maxSpeedMultiplier;
if (multiplier < minSpeedMultiplier) multiplier = minSpeedMultiplier;
config.set(speedMultiplierPath, multiplier);
speedMultiplier = multiplier;
}
public static double getMinforce() {
return minforce;
return minForce;
}
public static void setMinForce(double minforce, CommandSender sender){
if (minforce > maxMinForce) sender.sendMessage("MinForce is too large! Setting it to " + maxMinForce);
if (minforce < minMinForce) sender.sendMessage("MinForce is too small! Setting it to " + minMinForce);
setMinforce(minforce);
sender.sendMessage("MinForce set to " + getMinforce());
}
public static void setMinforce(double minforce) {
if (minforce > maxMinForce) minforce = maxMinForce;
if (minforce < minMinForce) minforce = minMinForce;
config.set(minForcePath, minforce);
CannonBowListener.minForce = 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;
return fuseTicks;
}
public static void setFuseticks(int fuseticks, CommandSender sender){
if (fuseticks > maxFuseTicks) sender.sendMessage("Fuseticks is too large! Setting it to " + maxFuseTicks);
if (fuseticks < minFuseTicks) sender.sendMessage("Fuseticks is too small! Setting it to " + minFuseTicks);
setFuseticks(fuseticks);
sender.sendMessage("FuseTicks set to " + getFuseticks());
}
public static void setFuseticks(int fuseticks) {
if (fuseticks > maxFuseTicks) fuseticks = maxFuseTicks;
if (fuseticks < minFuseTicks) fuseticks = minFuseTicks;
config.set(fuseTicksPath, fuseticks);
CannonBowListener.fuseTicks = 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, CommandSender sender){
if (recoil > maxRecoil) sender.sendMessage("Recoil is too large! Setting it to " + maxRecoil);
if (recoil < maxRecoil) sender.sendMessage("Recoil is too small! Setting it to " + minRecoil);
setRecoil(recoil);
sender.sendMessage("Recoil set to " + getRecoil());
}
public static void setRecoil(double recoil) {
if (recoil > 20) recoil = 20;
if (recoil < 0) recoil = 0;
if (recoil > maxRecoil) recoil = maxRecoil;
if (recoil < minRecoil) recoil = minRecoil;
config.set(recoilPath, recoil);
CannonBowListener.recoil = recoil;
}
public static boolean getIsDestructive(){
return isDestructive;
}
public static void setIsDestructive(String input){
if(input.startsWith("T") || input.startsWith("t")) setIsDestructive(true);
if(input.startsWith("F") || input.startsWith("f")) setIsDestructive(false);
}
public static void setIsDestructive(boolean isDestructive){
CannonBowListener.isDestructive = isDestructive;
config.set(speedMultiplierPath, isDestructive);
}
}

View file

@ -9,25 +9,34 @@ public class CannonBowSettings extends ModCommand {
@Override
public boolean OnCommand(Player player, String alias, String[] args) {
if (args.length > 1){
if (args.length > 1 && args[0] == "display"){
switch(args[0].toLowerCase()){
case "force":
case "speedmultiplier":
CannonBowListener.setSpeedMultiplier(NumberUtils.toDouble(args[1], CannonBowListener.getSpeedMultiplier()));
break;
case "minimumforce":
case "minforce":
case "minimumdraw":
case "mindraw":
CannonBowListener.setMinforce(NumberUtils.toDouble(args[1], CannonBowListener.getMinforce()));
break;
case "fuse":
case "fusetick":
case "fuseticks":
CannonBowListener.setFuseticks(NumberUtils.toInt(args[1], CannonBowListener.getFuseticks()));
break;
case "recoil":
CannonBowListener.setRecoil(NumberUtils.toDouble((args[1]), CannonBowListener.getRecoil()));
break;
case "isDestructive":
CannonBowListener.setIsDestructive(args[1]);
case "display":
player.sendMessage("Speed Multiplier: "+CannonBowListener.getSpeedMultiplier());
player.sendMessage("Minimum Force: "+CannonBowListener.getMinforce());
player.sendMessage("Fuseticks: " + CannonBowListener.getFuseticks());
player.sendMessage("Recoil: " + CannonBowListener.getRecoil());
player.sendMessage("isDestructive: " + CannonBowListener.getIsDestructive());
break;
default:
player.sendMessage("That isn't a valid setting!");