From 07d6a32e982dd1479f23286c132615d42cef5302 Mon Sep 17 00:00:00 2001 From: alisolarflare Date: Thu, 3 Nov 2016 02:56:51 -0400 Subject: [PATCH] Moved BoomBow to AliPresents --- .../modules/magictrick/MagicModule.java | 22 ++++ .../magictrick/boombow/BoomBowListener.java | 105 ++++++++++++++++++ .../magictrick/boombow/BoomBowRule.java | 80 +++++++++++++ 3 files changed, 207 insertions(+) create mode 100644 src/alisolarflare/modules/magictrick/MagicModule.java create mode 100644 src/alisolarflare/modules/magictrick/boombow/BoomBowListener.java create mode 100644 src/alisolarflare/modules/magictrick/boombow/BoomBowRule.java diff --git a/src/alisolarflare/modules/magictrick/MagicModule.java b/src/alisolarflare/modules/magictrick/MagicModule.java new file mode 100644 index 0000000..b29179e --- /dev/null +++ b/src/alisolarflare/modules/magictrick/MagicModule.java @@ -0,0 +1,22 @@ +package alisolarflare.modules.magictrick; + +import org.bukkit.plugin.java.JavaPlugin; + +import alisolarflare.modules.Module; +import alisolarflare.modules.events.uhc.commands.AddToUHC; +import alisolarflare.modules.magictrick.aliarrow.AliArrowListener; +import alisolarflare.modules.magictrick.boombow.BoomBowListener; +import buttondevteam.lib.TBMCCoreAPI; +import buttondevteam.lib.chat.TBMCChatAPI; + +public class MagicModule extends Module{ + + @Override + public void register(JavaPlugin plugin) { + TBMCCoreAPI.RegisterEventsForExceptions(new AliArrowListener(plugin), plugin); + TBMCCoreAPI.RegisterEventsForExceptions(new BoomBowListener(), plugin); + TBMCChatAPI.AddCommands(plugin, AddToUHC.class); + + } + +} diff --git a/src/alisolarflare/modules/magictrick/boombow/BoomBowListener.java b/src/alisolarflare/modules/magictrick/boombow/BoomBowListener.java new file mode 100644 index 0000000..3c05bff --- /dev/null +++ b/src/alisolarflare/modules/magictrick/boombow/BoomBowListener.java @@ -0,0 +1,105 @@ +package alisolarflare.modules.magictrick.boombow; + +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.entity.PlayerDeathEvent; +import org.bukkit.event.player.PlayerInteractEvent; +import org.bukkit.inventory.ItemStack; +import org.bukkit.potion.PotionEffect; +import org.bukkit.potion.PotionEffectType; + +public class BoomBowListener implements Listener { + + @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(); + if(player.getGameMode().equals(GameMode.CREATIVE))return; + + if(bow.containsEnchantment(Enchantment.ARROW_INFINITE)){ + //HAS INIFINITY + Activate(event); + + }else if((player.getInventory().contains(Material.TNT))){ + //HAS TNT + Activate(event); + + //Reduce tnt by 1 + int tntSlot = player.getInventory().first(Material.TNT); + ItemStack tntStack = player.getInventory().getItem(tntSlot); + if(tntStack.getAmount() > 3){ + tntStack.setAmount(tntStack.getAmount()-3); + }else{ + tntStack.setAmount(0);; + } + + }else{ + return; + } + } + + + + @SuppressWarnings("deprecation") + public void Activate(PlayerInteractEvent event){ + //INIT - Player variables + Player player = event.getPlayer(); + Location playerLocation = player.getLocation(); + + //TODO: NERF - boomDecay + //TODO: NERF - endCrystal + //TODO: NERF - healthReduction + //TODO: NERF - localized + + if(BoomBowRule.boomDecay); + if(BoomBowRule.endCrystal){ + } + if(BoomBowRule.healthReduction){ + player.addPotionEffect(new PotionEffect(PotionEffectType.HEALTH_BOOST, 400, -1)); + } + if(BoomBowRule.localized); + + + //SET - Player Velocity + player.setVelocity(event.getPlayer().getLocation().getDirection().normalize().multiply(2.5)); + player.sendMessage("" + event.getPlayer().getVelocity().length()); + + //CREATE - Explosion + damage + player.getWorld().playSound(playerLocation, Sound.ENTITY_GENERIC_EXPLODE, 10, -20); + event.getPlayer().getWorld().spawnParticle(Particle.EXPLOSION_HUGE, playerLocation, 2); + player.damage(9.0, player); + player.getItemInHand().setDurability((short) (player.getItemInHand().getDurability() - 3)); + + + + + } + public void FlyBowBoostDeath(PlayerDeathEvent event){ + event.getEntity().getServer().broadcastMessage("[boombow debug]: "+event.getEntity().getLastDamageCause().getCause().toString()); + + } +} diff --git a/src/alisolarflare/modules/magictrick/boombow/BoomBowRule.java b/src/alisolarflare/modules/magictrick/boombow/BoomBowRule.java new file mode 100644 index 0000000..06f5ea0 --- /dev/null +++ b/src/alisolarflare/modules/magictrick/boombow/BoomBowRule.java @@ -0,0 +1,80 @@ +package alisolarflare.modules.magictrick.boombow; + +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import buttondevteam.lib.chat.TBMCCommandBase; +//HEHEHHEHEH EAASSSTER EGGS +public class BoomBowRule extends TBMCCommandBase{ + public static boolean boomDecay; + public static boolean healthReduction; + public static boolean endCrystal; + public static boolean localized;; + @Override + public boolean OnCommand(CommandSender sender, String label, String[] args) { + if (sender instanceof Player == false){ + sender.sendMessage("You must be a player to use this command"); + return false; + } + Player player = (Player) sender; + if (player.getName().equals("alisolarflare") == false){ + player.sendMessage("You must be alisolarflare to use this command"); + return false; + } + if (args.length < 2){ + player.sendMessage("Usage: /boomBowRule [rulename] [true/false]"); + player.sendMessage("Rule settings: boomDecay, healthReduction, endCrystal, localized"); + return false; + } + if(!(args[1].startsWith("t")|| args[1].startsWith("f"))){ + player.sendMessage("Usage: /boomBowRule [rulename] [true/false]"); + 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"); + player.sendMessage("Usage: /boomBowRule [rulename] [true/false]"); + player.sendMessage("Rule settings: boomDecay, healthReduction, endCrystal, localized"); + break; + } + + return false; + } + @Override + public String GetCommandPath() { + // TODO Auto-generated method stub + return null; + } + @Override + public String[] GetHelpText(String arg0) { + // TODO Auto-generated method stub + return null; + } + @Override + public boolean GetModOnly() { + // TODO Auto-generated method stub + return false; + } + @Override + public boolean GetPlayerOnly() { + // TODO Auto-generated method stub + return false; + } + +}