Advertisement
Guest User

Listener

a guest
Jan 23rd, 2014
74
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package me.CraftCreeper6.zeartool;
  2.  
  3. import java.util.ArrayList;
  4. import java.util.List;
  5.  
  6. import org.bukkit.ChatColor;
  7. import org.bukkit.Material;
  8. import org.bukkit.entity.Player;
  9. import org.bukkit.event.EventHandler;
  10. import org.bukkit.event.Listener;
  11. import org.bukkit.event.block.Action;
  12. import org.bukkit.event.player.PlayerInteractEvent;
  13. import org.bukkit.inventory.ItemStack;
  14. import org.bukkit.inventory.meta.ItemMeta;
  15. import org.bukkit.potion.PotionEffect;
  16. import org.bukkit.potion.PotionEffectType;
  17. import org.bukkit.util.Vector;
  18.  
  19. public class MainListener implements Listener {
  20.  
  21.         @EventHandler
  22.         public void onClick(PlayerInteractEvent event) {
  23.  
  24.                 Player p = event.getPlayer();
  25.  
  26.                 ItemStack stick = new ItemStack(Material.STICK);
  27.                 ItemMeta smeta = stick.getItemMeta();
  28.                 smeta.setDisplayName("§c§nInvisibilty");
  29.                 List<String> lorename = new ArrayList<String>();
  30.                 lorename
  31.                         .add(ChatColor.DARK_PURPLE
  32.                                 + "Right click to turn invisible for 10 seconds.");
  33.                 smeta.setLore(lorename);
  34.                 stick.setItemMeta(smeta);
  35.                 if (event.getAction() == Action.RIGHT_CLICK_BLOCK
  36.                                 || event.getAction() == Action.RIGHT_CLICK_AIR) {
  37.                     if (event.getItem().getType().equals(stick)) {
  38.                     if (p.hasPotionEffect(PotionEffectType.INVISIBILITY)) {
  39.                                         return;
  40.                                 }                              
  41.  
  42.                                 p.addPotionEffect(new PotionEffect(
  43.                                                 PotionEffectType.INVISIBILITY, 200, 1));
  44.                                 return;
  45.  
  46.                         }ItemStack ironaxe = new ItemStack(Material.IRON_AXE);
  47.                         ItemMeta iameta = ironaxe.getItemMeta();
  48.                         iameta.setDisplayName("§c§nHigh Jump");
  49.                         List<String> lorename1 = new ArrayList<String>();
  50.                         lorename1
  51.                                 .add(ChatColor.DARK_PURPLE
  52.                                         + "Right click to jump high in the sky and deal AOE damage when you hit the ground!");
  53.                         iameta.setLore(lorename1);
  54.                         ironaxe.setItemMeta(iameta);
  55.                         if (event.getAction() == Action.RIGHT_CLICK_BLOCK
  56.                                 || event.getAction() == Action.RIGHT_CLICK_AIR) {
  57.                         if (event.getItem().hasItemMeta()) {
  58.                         if (event.getItem().getItemMeta().getDisplayName().equalsIgnoreCase("§c§nHigh Jump")){ // Check this line, might not be right. If it works, remove the new ItemStack code
  59.                             p.setFlying(false);
  60.                             Vector jump = p.getLocation().getDirection().multiply(0.2).setY(1.1);
  61.                             p.setVelocity(p.getVelocity().add(jump));
  62.                         }
  63.                             if (event.getItem().getType().equals(Material.COOKED_BEEF));
  64.                             p.addPotionEffect(new PotionEffect(
  65.                                     PotionEffectType.SPEED, 100, 1));
  66.                     return;
  67.                        
  68.                 }
  69.                 return;
  70.                         }
  71.                 }
  72.  
  73.         }
  74. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement