From a925a7117f2c4655fa886dcb367d9b8c5faba23e Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Sat, 5 Nov 2016 05:50:39 -0400 Subject: [PATCH] Started on Boom Bow Rule: Boom Decay --- src/alisolarflare/magic/MagicModule.java | 2 +- .../magic/tricks/BoomBowDeathListener.java | 4 ++- .../magic/tricks/BoomBowListener.java | 9 +++++-- .../magic/tricks/BoomBowRule.java | 6 ++++- .../magic/tricks/BoomDecayTask.java | 25 +++++++++++++++++++ 5 files changed, 41 insertions(+), 5 deletions(-) create mode 100644 src/alisolarflare/magic/tricks/BoomDecayTask.java diff --git a/src/alisolarflare/magic/MagicModule.java b/src/alisolarflare/magic/MagicModule.java index 82e3802..616b179 100644 --- a/src/alisolarflare/magic/MagicModule.java +++ b/src/alisolarflare/magic/MagicModule.java @@ -13,6 +13,6 @@ public class MagicModule extends Module{ public void register(JavaPlugin plugin) { registerListener(plugin, new AliArrowListener(plugin)); registerListener(plugin, new BoomBowDeathListener()); - registerListener(plugin, new BoomBowListener()); + registerListener(plugin, new BoomBowListener(plugin)); } } diff --git a/src/alisolarflare/magic/tricks/BoomBowDeathListener.java b/src/alisolarflare/magic/tricks/BoomBowDeathListener.java index d62986d..b742f16 100644 --- a/src/alisolarflare/magic/tricks/BoomBowDeathListener.java +++ b/src/alisolarflare/magic/tricks/BoomBowDeathListener.java @@ -10,9 +10,11 @@ public class BoomBowDeathListener implements Listener{ public void onBoomBowDeath(PlayerDeathEvent event){ Player player = event.getEntity(); if (player.getLastDamage() == 7.000042) - event.setDeathMessage(player.getCustomName() + player.getDisplayName() + player.getPlayerListName() + player.getName() + "got trigger happy with the Boom Bow"); + player.sendMessage("42!"); + event.setDeathMessage(player.getName() + "got trigger happy with the Boom Bow"); if (player.getLastDamage() < 7.000041 || player.getLastDamage() > 7.000043) player.sendMessage("meaning of lyyyyyyfffe"); + player.sendMessage(player.getCustomName() + player.getDisplayName() + player.getPlayerListName() + player.getName()); } } diff --git a/src/alisolarflare/magic/tricks/BoomBowListener.java b/src/alisolarflare/magic/tricks/BoomBowListener.java index a5fb608..caad9d1 100644 --- a/src/alisolarflare/magic/tricks/BoomBowListener.java +++ b/src/alisolarflare/magic/tricks/BoomBowListener.java @@ -12,11 +12,15 @@ 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.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); @@ -74,7 +78,8 @@ public class BoomBowListener implements Listener { //TODO: NERF - healthReduction //TODO: NERF - localized - if(BoomBowRule.boomDecay); + if(BoomBowRule.boomDecay) + new BoomDecayTask(player).runTaskTimer(plugin, 1, 1); if(BoomBowRule.endCrystal){ } if(BoomBowRule.healthReduction){ diff --git a/src/alisolarflare/magic/tricks/BoomBowRule.java b/src/alisolarflare/magic/tricks/BoomBowRule.java index b1131c6..bbfbf8f 100644 --- a/src/alisolarflare/magic/tricks/BoomBowRule.java +++ b/src/alisolarflare/magic/tricks/BoomBowRule.java @@ -23,7 +23,11 @@ public class BoomBowRule extends TBMCCommandBase{ } if (args.length < 2){ player.sendMessage("Usage: /boomBowRule [rulename] [true/false]"); - player.sendMessage("Rule settings: boomDecay, healthReduction, endCrystal, localized"); + 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"))){ diff --git a/src/alisolarflare/magic/tricks/BoomDecayTask.java b/src/alisolarflare/magic/tricks/BoomDecayTask.java new file mode 100644 index 0000000..5f1875c --- /dev/null +++ b/src/alisolarflare/magic/tricks/BoomDecayTask.java @@ -0,0 +1,25 @@ +package alisolarflare.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++; + + } + +}