Moved BoomBow to AliPresents

This commit is contained in:
alisolarflare 2016-11-03 02:56:51 -04:00
parent 28877a9bfa
commit 07d6a32e98
3 changed files with 207 additions and 0 deletions

View file

@ -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);
}
}

View file

@ -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());
}
}

View file

@ -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;
}
}