Advertisement
Guest User

Untitled

a guest
Aug 31st, 2015
65
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.92 KB | None | 0 0
  1. package com.YourMCAdmin.LLPogo;
  2.  
  3.  
  4. //import org.bukkit.Bukkit;
  5. //import org.bukkit.Material;
  6. //import org.bukkit.entity.Player;
  7. //import org.bukkit.event.EventHandler;
  8. //import org.bukkit.event.Listener;
  9. //import org.bukkit.event.player.PlayerItemHeldEvent;
  10. //import org.bukkit.inventory.ItemStack;
  11. //import org.bukkit.plugin.java.JavaPlugin;
  12. //import org.bukkit.potion.PotionEffect;
  13. ////import org.bukkit.potion.PotionEffect;
  14. ////import org.bukkit.potion.PotionEffectType;
  15. //import org.bukkit.potion.PotionEffectType;
  16. //
  17. //public class main extends JavaPlugin implements Listener {
  18. //
  19. //      @Override
  20. //    public void onEnable()
  21. //    {
  22. //      getLogger().info("LegitLand Pogo has been enabled.");
  23. //      getConfig().options().copyDefaults(true);
  24. //      saveDefaultConfig();
  25. //      Bukkit.getServer().getPluginManager().registerEvents(this, this);
  26. //    }
  27. //   
  28. //    public void onDisable() {};
  29. //   
  30. //   
  31. ////      @EventHandler
  32. ////      public void onPlayerItemHeld(PlayerItemHeldEvent e)
  33. ////      {
  34. ////          Player player = e.getPlayer();
  35. ////          //ItemStack item = player.getItemInHand();
  36. ////          ItemStack newItem;
  37. ////          newItem = player.getInventory().getItem(e.getNewSlot());
  38. ////          player.sendMessage("Item switched");
  39. ////          getLogger().info("Item switched");
  40. ////          if(newItem != null){
  41. ////              if(newItem.getType() == Material.STICK) {
  42. ////                  player.sendMessage("Stick found");
  43. ////                  getLogger().info("Stick found");
  44. ////              }else if(newItem.getType() != Material.STICK){
  45. ////                  player.sendMessage("Not a stick silly");
  46. ////                  getLogger().info("Not a stick.");
  47. ////              }
  48. ////             
  49. //////            if (player.getInventory().getItemInHand().getItemMeta().getLore().contains("pogo")){
  50. //////                player.addPotionEffect(new PotionEffect(PotionEffectType.JUMP, 72000, 3));
  51. //////                player.sendMessage("Pogo activate");
  52. //////           
  53. //////            } else {
  54. //////                player.removePotionEffect(PotionEffectType.JUMP);
  55. //////            }
  56. ////             
  57. ////          }
  58. ////      }
  59.  
  60. import org.bukkit.Bukkit;
  61. import org.bukkit.Material;
  62. import org.bukkit.plugin.java.JavaPlugin;
  63. import org.bukkit.potion.*;
  64. import org.bukkit.inventory.*;
  65. import org.bukkit.entity.*;
  66. import org.bukkit.event.player.PlayerItemHeldEvent;
  67. import org.bukkit.event.EventHandler;
  68. import org.bukkit.event.Listener;
  69.  
  70. public class main extends JavaPlugin implements Listener {
  71.  
  72.     public void onEnable() {
  73.         Bukkit.getServer().getPluginManager().registerEvents(this, this);
  74.         ;
  75.  
  76.     }
  77.  
  78.     public void onDisable() {
  79.  
  80.     }
  81.  
  82.  
  83.     @EventHandler
  84.     public void onJoin(PlayerItemHeldEvent event) {
  85.         Player p = event.getPlayer();
  86.         ItemStack item = p.getInventory().getItem(event.getNewSlot());
  87.        
  88.         if(item != null) { //  <--- I put it here because if it's null it "doesn't exist".
  89.             if (item.getType() == Material.GOLD_SWORD) {
  90.                 p.addPotionEffect(new PotionEffect(PotionEffectType.INVISIBILITY, 999999, 0));
  91.  
  92.             } else if (item.getType() != Material.GOLD_SWORD) {
  93.                 p.removePotionEffect(PotionEffectType.INVISIBILITY);
  94.             }
  95.  
  96.             if (item.getType() == Material.IRON_SWORD) {
  97.                 p.addPotionEffect(new PotionEffect(PotionEffectType.ABSORPTION, 999999, 0));
  98.  
  99.             } else if (item.getType() != Material.IRON_SWORD) {
  100.                 p.removePotionEffect(PotionEffectType.ABSORPTION);
  101.  
  102.             }
  103.             if (item.getType() == Material.BOW) {
  104.                 p.addPotionEffect(new PotionEffect(PotionEffectType.NIGHT_VISION, 999999, 0));
  105.  
  106.             } else if (item.getType() != Material.BOW) {
  107.                 p.removePotionEffect(PotionEffectType.NIGHT_VISION);
  108.  
  109.             }
  110.         } else {
  111.             p.removePotionEffect(PotionEffectType.ABSORPTION);
  112.             p.removePotionEffect(PotionEffectType.INVISIBILITY);
  113.             p.removePotionEffect(PotionEffectType.NIGHT_VISION);
  114.         }
  115.     }
  116.  
  117. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement