Added back boom bows, arrow trails, and cannon bows
This commit is contained in:
parent
3ea8bb6539
commit
f51ccc9113
11 changed files with 631 additions and 1 deletions
6
pom.xml
6
pom.xml
|
@ -55,6 +55,12 @@
|
|||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<!-- https://mvnrepository.com/artifact/org.apache.commons/commons-lang3 -->
|
||||
<dependency>
|
||||
<groupId>org.apache.commons</groupId>
|
||||
<artifactId>commons-lang3</artifactId>
|
||||
<version>3.5</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
|
|
|
@ -6,6 +6,7 @@ import org.bukkit.plugin.PluginDescriptionFile;
|
|||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import buttondevteam.presents.dictionary.DictionaryComponent;
|
||||
import buttondevteam.presents.magic.MagicComponent;
|
||||
import buttondevteam.presents.metrics.MetricsComponent;
|
||||
import buttondevteam.presents.rtp.RandomTeleportComponent;
|
||||
import buttondevteam.presents.spawn.SpawnComponent;
|
||||
|
@ -13,7 +14,7 @@ import buttondevteam.presents.test.TestComponent;
|
|||
|
||||
public class Main extends JavaPlugin{
|
||||
public void onEnable(){
|
||||
PluginDescriptionFile pdfFile = getDescription();
|
||||
PluginDescriptionFile pdfFile = getDescription();
|
||||
|
||||
Logger logger = getLogger();
|
||||
logger.info(pdfFile.getName() + " has been started (V." + pdfFile.getVersion()+ ").");
|
||||
|
@ -23,6 +24,7 @@ PluginDescriptionFile pdfFile = getDescription();
|
|||
new MetricsComponent().register(this);
|
||||
new SpawnComponent().register(this);
|
||||
new TestComponent().register(this);
|
||||
new MagicComponent().register(this);
|
||||
|
||||
logger.info(pdfFile.getName() + " has fully registered (V." + pdfFile.getVersion()+ ").");
|
||||
}
|
||||
|
|
|
@ -0,0 +1,22 @@
|
|||
package buttondevteam.presents.magic;
|
||||
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
import buttondevteam.presents.architecture.Component;
|
||||
import buttondevteam.presents.magic.tricks.AliArrowListener;
|
||||
import buttondevteam.presents.magic.tricks.BoomBowDeathListener;
|
||||
import buttondevteam.presents.magic.tricks.BoomBowListener;
|
||||
import buttondevteam.presents.magic.tricks.CannonBowListener;
|
||||
import buttondevteam.presents.magic.tricks.CannonBowSettings;
|
||||
|
||||
public class MagicComponent extends Component{
|
||||
|
||||
@Override
|
||||
public void register(JavaPlugin plugin) {
|
||||
registerCommand(plugin, new CannonBowSettings());
|
||||
registerListener(plugin, new AliArrowListener(plugin));
|
||||
registerListener(plugin, new BoomBowDeathListener());
|
||||
registerListener(plugin, new BoomBowListener(plugin));
|
||||
registerListener(plugin, new CannonBowListener(plugin));
|
||||
}
|
||||
}
|
|
@ -0,0 +1,39 @@
|
|||
package buttondevteam.presents.magic.tricks;
|
||||
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.ProjectileLaunchEvent;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
|
||||
public class AliArrowListener implements Listener {
|
||||
private final JavaPlugin plugin;
|
||||
|
||||
public AliArrowListener(JavaPlugin plugin){
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onProjectileLaunch(ProjectileLaunchEvent event){
|
||||
if(event.getEntity().getType() != EntityType.ARROW){
|
||||
return;
|
||||
}
|
||||
Arrow arrow = (Arrow) event.getEntity();
|
||||
if (!(arrow.isCritical()) || !(arrow.getShooter() instanceof Player)){
|
||||
return;
|
||||
}
|
||||
Player player = (Player) arrow.getShooter();
|
||||
String username = player.getName();
|
||||
|
||||
for (String permittedUsername : AliArrowTask.permittedUsers){
|
||||
if(permittedUsername.equalsIgnoreCase(username)){
|
||||
new AliArrowTask(arrow,username).runTaskTimer(plugin, 2, 1);
|
||||
break;
|
||||
}
|
||||
}
|
||||
return;
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,46 @@
|
|||
package buttondevteam.presents.magic.tricks;
|
||||
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.entity.Arrow;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class AliArrowTask extends BukkitRunnable {
|
||||
static String[] permittedUsers = {"alisolarflare", "Zanthr", "NorbiPeti"};
|
||||
String name;
|
||||
Arrow arrow;
|
||||
int count = 0;
|
||||
|
||||
public AliArrowTask(Arrow arrow, String name) {
|
||||
this.name = name;
|
||||
this.arrow = arrow;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void run() {
|
||||
count++;
|
||||
if (count > 400 ||arrow.isOnGround() || arrow.isDead()) {
|
||||
this.cancel();
|
||||
}
|
||||
|
||||
switch(name.toLowerCase()){
|
||||
case "alisolarflare":
|
||||
arrow.getWorld().spawnParticle(Particle.VILLAGER_HAPPY, arrow.getLocation(), 1);
|
||||
break;
|
||||
|
||||
case "zanthr":
|
||||
arrow.getWorld().spawnParticle(Particle.FIREWORKS_SPARK, arrow.getLocation(), 1);
|
||||
arrow.getWorld().spawnParticle(Particle.FLAME, arrow.getLocation(), 1);
|
||||
break;
|
||||
|
||||
case "norbipeti":
|
||||
arrow.getWorld().spawnParticle(Particle.LAVA, arrow.getLocation(), 1);
|
||||
break;
|
||||
|
||||
case "mayskam1995":
|
||||
arrow.getWorld().spawnParticle(Particle.DRIP_WATER, arrow.getLocation(), 2);
|
||||
break;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,16 @@
|
|||
package buttondevteam.presents.magic.tricks;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.PlayerDeathEvent;
|
||||
|
||||
public class BoomBowDeathListener implements Listener{
|
||||
@EventHandler
|
||||
public void onBoomBowDeath(PlayerDeathEvent event){
|
||||
Player player = event.getEntity();
|
||||
if (player.getLastDamage() > 7.42420 && player.getLastDamage() < 7.42429){
|
||||
event.setDeathMessage(player.getName() + " got trigger happy with the [Boom Bow]");
|
||||
}
|
||||
}
|
||||
}
|
|
@ -0,0 +1,111 @@
|
|||
package buttondevteam.presents.magic.tricks;
|
||||
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Particle;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.enchantments.Enchantment;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.block.Action;
|
||||
import org.bukkit.event.player.PlayerInteractEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.inventory.PlayerInventory;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.potion.PotionEffect;
|
||||
import org.bukkit.potion.PotionEffectType;
|
||||
|
||||
public class BoomBowListener implements Listener {
|
||||
JavaPlugin plugin;
|
||||
public BoomBowListener(JavaPlugin plugin){
|
||||
this.plugin = plugin;
|
||||
}
|
||||
@EventHandler
|
||||
public void ClickEvent(PlayerInteractEvent event){
|
||||
FlyBowBoost(event);
|
||||
|
||||
}
|
||||
public void FlyBowBoost(PlayerInteractEvent event){
|
||||
|
||||
//ACTION SANITATION
|
||||
if(!(event.getAction() == Action.LEFT_CLICK_AIR || event.getAction() == Action.LEFT_CLICK_BLOCK)) return;
|
||||
if(!(event.getPlayer().isGliding())) return;
|
||||
if(!(event.getMaterial() == Material.BOW)) return;
|
||||
|
||||
//BOW SANITATION
|
||||
ItemStack bow = event.getItem();
|
||||
if(!(bow.containsEnchantment(Enchantment.ARROW_KNOCKBACK))) return;
|
||||
if(!(bow.getEnchantmentLevel(Enchantment.ARROW_KNOCKBACK) == 3)) return;
|
||||
if(!(bow.getItemMeta().getDisplayName().contains("BOOM BOW"))) return;
|
||||
|
||||
//PLAYER SANITATION
|
||||
Player player = event.getPlayer();
|
||||
PlayerInventory inventory = player.getInventory();
|
||||
if(player.getGameMode().equals(GameMode.SPECTATOR))return;
|
||||
|
||||
if(bow.containsEnchantment(Enchantment.ARROW_INFINITE)){
|
||||
//HAS INIFINITY
|
||||
Activate(event);
|
||||
|
||||
}else if((inventory.contains(Material.TNT))){
|
||||
//HAS TNT
|
||||
Activate(event);
|
||||
|
||||
//Reduce TNT
|
||||
ItemStack tnt = inventory.getItem(inventory.first(Material.TNT));
|
||||
|
||||
if(tnt.getAmount() > 3){
|
||||
tnt.setAmount(tnt.getAmount()-3);
|
||||
}else{
|
||||
inventory.remove(tnt);
|
||||
}
|
||||
if (bow.getDurability() < 0){
|
||||
inventory.clear(inventory.getHeldItemSlot());
|
||||
}
|
||||
|
||||
}else{
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
public void Activate(PlayerInteractEvent event){
|
||||
//INIT - Player variables
|
||||
Player player = event.getPlayer();
|
||||
Location playerLocation = player.getLocation();
|
||||
ItemStack boomBow = player.getInventory().getItemInMainHand();
|
||||
|
||||
//TODO: NERF - boomDecay
|
||||
//TODO: NERF - endCrystal
|
||||
//TODO: NERF - healthReduction
|
||||
//TODO: NERF - localized
|
||||
|
||||
if(BoomBowRule.boomDecay)
|
||||
new BoomDecayTask(player).runTaskTimer(plugin, 1, 1);
|
||||
if(BoomBowRule.endCrystal){
|
||||
//BoomBowCyrstalSpawn
|
||||
}
|
||||
if(BoomBowRule.healthReduction){
|
||||
player.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, 400, -1));
|
||||
}
|
||||
if(BoomBowRule.localized);
|
||||
|
||||
|
||||
//SET - Player Velocity
|
||||
player.setVelocity(playerLocation.getDirection().normalize().multiply(3.0));
|
||||
|
||||
//CREATE - Explosion + damage
|
||||
player.getWorld().playSound(playerLocation, Sound.ENTITY_GENERIC_EXPLODE, 10, -20);
|
||||
player.getWorld().spawnParticle(Particle.EXPLOSION_HUGE, playerLocation, 2);
|
||||
player.damage(7.42425, player);
|
||||
boomBow.setDurability((short) (boomBow.getDurability() + 3));
|
||||
if(boomBow.getDurability() > 385){
|
||||
player.getInventory().setItemInMainHand(null);
|
||||
player.getWorld().playSound(playerLocation, Sound.ENTITY_ITEM_BREAK, 0, 0);
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -0,0 +1,61 @@
|
|||
package buttondevteam.presents.magic.tricks;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import buttondevteam.presents.architecture.commands.ModCommand;
|
||||
|
||||
//HEHEHHEHEH EAASSSTER EGGS
|
||||
public class BoomBowRule extends ModCommand{
|
||||
public static boolean boomDecay;
|
||||
public static boolean healthReduction;
|
||||
public static boolean endCrystal;
|
||||
public static boolean localized;;
|
||||
@Override
|
||||
public boolean OnCommand(Player player, String label, String[] args) {
|
||||
if (player.getName().equals("alisolarflare") == false){
|
||||
player.sendMessage("You must be alisolarflare to use this command");
|
||||
return false;
|
||||
}
|
||||
if (args.length < 2){
|
||||
player.sendMessage("Rules:");
|
||||
player.sendMessage("boomDecay" + boomDecay);
|
||||
player.sendMessage("healthReduction" + healthReduction);
|
||||
player.sendMessage("endCrystal" + endCrystal);
|
||||
player.sendMessage("localized" + localized);
|
||||
return false;
|
||||
}
|
||||
if(!(args[1].startsWith("t")|| args[1].startsWith("f"))){
|
||||
return false;
|
||||
}
|
||||
boolean gameRule = false;
|
||||
if(args[1].startsWith("t") || args[1].startsWith("T")){
|
||||
gameRule = true;
|
||||
}
|
||||
switch(args[0]){
|
||||
case "boomDecay":
|
||||
boomDecay = gameRule;
|
||||
break;
|
||||
case "healthReduction":
|
||||
healthReduction = gameRule;
|
||||
break;
|
||||
case "endCrystal":
|
||||
endCrystal = gameRule;
|
||||
break;
|
||||
case "localized":
|
||||
localized = gameRule;
|
||||
break;
|
||||
default:
|
||||
player.sendMessage("Error: "+args[0]+" not defined as a rule");
|
||||
return false;
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
@Override
|
||||
public String[] GetHelpText(String alias) {
|
||||
return new String[]{
|
||||
"Usage: /boomBowRule [rulename] [true/false]",
|
||||
"Rule settings: boomDecay, healthReduction, endCrystal, localized"
|
||||
};
|
||||
}
|
||||
}
|
|
@ -0,0 +1,25 @@
|
|||
package buttondevteam.presents.magic.tricks;
|
||||
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
public class BoomDecayTask extends BukkitRunnable{
|
||||
Player player;
|
||||
private int ticksSinceStart = 0;
|
||||
private final int effectLength = 20;
|
||||
public BoomDecayTask(Player player){
|
||||
this.player = player;
|
||||
}
|
||||
//runs every tick
|
||||
@Override
|
||||
public void run() {
|
||||
if (ticksSinceStart > effectLength){
|
||||
this.cancel();
|
||||
}
|
||||
player.sendMessage(player.getVelocity().toString());
|
||||
|
||||
ticksSinceStart++;
|
||||
|
||||
}
|
||||
|
||||
}
|
|
@ -0,0 +1,250 @@
|
|||
package buttondevteam.presents.magic.tricks;
|
||||
|
||||
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;
|
||||
import org.bukkit.entity.EntityType;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.TNTPrimed;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityExplodeEvent;
|
||||
import org.bukkit.event.entity.EntityShootBowEvent;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
public class CannonBowListener implements Listener {
|
||||
private static String savePath = "magic.cannonbow";
|
||||
|
||||
private static double maxSpeedMultiplier = 4;
|
||||
private static double minSpeedMultiplier = 0;
|
||||
private static double defaultSpeedMultiplier = 1;
|
||||
private static String speedMultiplierPath = savePath + ".speedmultiplier";
|
||||
|
||||
private static int maxFuseTicks = 400;
|
||||
private static int minFuseTicks = 0;
|
||||
private static int defaultFuseTicks = 30;
|
||||
private static String fuseTicksPath = savePath + ".fuseticks";
|
||||
|
||||
private static double maxMinForce = 1;
|
||||
private static double minMinForce = 0;
|
||||
private static double defaultMinForce = 0.2;
|
||||
private static String minForcePath = savePath + ".minforce";
|
||||
|
||||
private static double maxRecoil = 20;
|
||||
private static double minRecoil = -5;
|
||||
private static double defaultRecoil = 1;
|
||||
private static String recoilPath = savePath + ".recoil";
|
||||
|
||||
private static boolean defaultIsDestructive = false;
|
||||
private static String isDestructivePath = savePath + ".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){
|
||||
config = plugin.getConfig();
|
||||
|
||||
if (config.isDouble(speedMultiplierPath))
|
||||
setSpeedMultiplier(config.getDouble(speedMultiplierPath));
|
||||
|
||||
if (config.isDouble(minForcePath))
|
||||
setMinforce(config.getDouble(minForcePath));
|
||||
|
||||
if (config.isInt(fuseTicksPath))
|
||||
setFuseticks(config.getInt(fuseTicksPath));
|
||||
|
||||
if (config.isDouble(recoilPath))
|
||||
setRecoil(config.getDouble(recoilPath));
|
||||
|
||||
if (config.isBoolean(isDestructivePath))
|
||||
setIsDestructive(config.getBoolean(isDestructivePath));
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onProjectileLaunch(EntityShootBowEvent event){
|
||||
//Entity Sanitation
|
||||
if(event.getProjectile().getType() != EntityType.ARROW)return;
|
||||
|
||||
//Arrow Sanitation
|
||||
Arrow arrow = (Arrow) event.getProjectile();
|
||||
if (!(arrow.getShooter() instanceof Player))return;
|
||||
|
||||
//Player Sanitation
|
||||
Player player = (Player) arrow.getShooter();
|
||||
if (!player.getInventory().contains(Material.TNT))return;
|
||||
|
||||
//Bow Sanitation
|
||||
ItemStack bow;
|
||||
if (!((bow = player.getInventory().getItemInMainHand()).getType() == Material.BOW))return;
|
||||
if (!(bow.containsEnchantment(Enchantment.PROTECTION_EXPLOSIONS)))return;
|
||||
if (!(bow.getEnchantmentLevel(Enchantment.PROTECTION_EXPLOSIONS) == 10))return;
|
||||
if (!(bow.getItemMeta().getDisplayName().toUpperCase().contains("CANNON BOW")))return;
|
||||
|
||||
//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, playerLocation, 30);
|
||||
arrow.getWorld().playSound(playerLocation, Sound.BLOCK_LADDER_BREAK, 1.0F, -7);
|
||||
|
||||
}else{
|
||||
//Spawn TNT
|
||||
TNTPrimed tnt = (TNTPrimed) arrow.getWorld().spawnEntity(arrow.getLocation(), EntityType.PRIMED_TNT);
|
||||
/*
|
||||
// Change via NMS the source of the TNT by the player
|
||||
EntityLiving nmsPlayer = (EntityLiving) (((CraftLivingEntity) player).getHandle());
|
||||
EntityTNTPrimed nmsTNT = (EntityTNTPrimed) (((CraftTNTPrimed) tnt).getHandle());
|
||||
try {
|
||||
Field sourceField = EntityTNTPrimed.class.getDeclaredField("source");
|
||||
sourceField.setAccessible(true);
|
||||
sourceField.set(nmsTNT, nmsPlayer);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}*/
|
||||
|
||||
//
|
||||
tnt.setVelocity(playerVector.multiply(getSpeedMultiplier()).multiply(event.getForce()));
|
||||
tnt.setCustomName(launchedTNTName);
|
||||
tnt.setFuseTicks(getFuseticks());
|
||||
|
||||
//Player Recoil
|
||||
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();
|
||||
|
||||
|
||||
return;
|
||||
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onTnTExplode(EntityExplodeEvent event) {
|
||||
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;
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
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 int getFuseticks() {
|
||||
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 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 > 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);
|
||||
}
|
||||
}
|
|
@ -0,0 +1,52 @@
|
|||
package buttondevteam.presents.magic.tricks;
|
||||
|
||||
import org.apache.commons.lang3.math.NumberUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import buttondevteam.lib.chat.CommandClass;
|
||||
import buttondevteam.presents.architecture.commands.ModCommand;
|
||||
|
||||
@CommandClass(path="magic cannonbow settings")
|
||||
public class CannonBowSettings extends ModCommand {
|
||||
|
||||
@Override
|
||||
public boolean OnCommand(Player player, String alias, String[] args) {
|
||||
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!");
|
||||
player.sendMessage("Valid Settings are: speedmultiplier, minforce, fuseticks, recoil");
|
||||
player.sendMessage("Use argument 'display' to disply current settings");
|
||||
return false;
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
}
|
Loading…
Reference in a new issue