Advertisement
Guest User

Untitled

a guest
Feb 21st, 2020
138
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 3.83 KB | None | 0 0
  1. package me.TheCamZone.JobRunCommand;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.Material;
  5. import org.bukkit.command.ConsoleCommandSender;
  6. import org.bukkit.entity.Player;
  7. import org.bukkit.event.EventHandler;
  8. import org.bukkit.event.Listener;
  9. import org.bukkit.event.inventory.InventoryClickEvent;
  10. import org.bukkit.event.player.PlayerItemHeldEvent;
  11. import org.bukkit.inventory.ItemStack;
  12. import org.bukkit.potion.PotionEffect;
  13. import org.bukkit.potion.PotionEffectType;
  14.  
  15. import com.gamingmesh.jobs.api.JobsJoinEvent;
  16. import com.gamingmesh.jobs.api.JobsLeaveEvent;
  17. import com.gamingmesh.jobs.stuff.ChatColor;
  18.  
  19. public class APIListener implements Listener {
  20.  
  21.     @EventHandler
  22.     public void onJobJoinEvent(JobsJoinEvent e)
  23.     {
  24.         ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
  25.        
  26.             Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + e.getPlayer().getName() + " add crafting." + e.getJob().getName());
  27.             console.sendMessage(ChatColor.GREEN + "Added Permission to " + e.getPlayer().getName());
  28.     }
  29.    
  30.     @EventHandler
  31.     public void onJobLeaveEvent(JobsLeaveEvent e)
  32.     {
  33.         ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
  34.  
  35.             Bukkit.dispatchCommand(Bukkit.getConsoleSender(), "pex user " + e.getPlayer().getName() + " remove crafting." + e.getJob().getName());
  36.             console.sendMessage(ChatColor.GREEN + "Added Permission to " + e.getPlayer().getName());
  37.     }
  38.    
  39.     @EventHandler
  40.     public void onPlayerItemHeld(PlayerItemHeldEvent e) {
  41.         Player p = e.getPlayer();
  42.         int i = e.getNewSlot();
  43.         ItemStack item = e.getPlayer().getInventory().getItem(i);
  44.         if (item != null && item.getItemMeta().getLore() != null) {
  45.             if (item.getType() == Material.DIAMOND_SWORD) {
  46.                 if (item.getItemMeta().getLore().contains("§cBuilt by Weaponsmith")) {
  47.                     PotionEffect hasteII = new PotionEffect(PotionEffectType.FAST_DIGGING, 9999*20, 1, false);
  48.                     p.addPotionEffect(hasteII);
  49.                 }
  50.                
  51.             } else if (item.getType() == Material.DIAMOND_PICKAXE) {
  52.                 if (item.getItemMeta().getLore().contains("§cBuilt by Weaponsmith"))
  53.                 {
  54.                     PotionEffect hasteII = new PotionEffect(PotionEffectType.FAST_DIGGING, 9999*20, 1, false);
  55.                     p.addPotionEffect(hasteII);
  56.                 }
  57.            
  58.             } else if (item.getType() == Material.DIAMOND_SHOVEL) {
  59.                 if (item.getItemMeta().getLore().contains("§cBuilt by Weaponsmith"))
  60.                 {
  61.                     PotionEffect hasteII = new PotionEffect(PotionEffectType.FAST_DIGGING, 9999*20, 1, false);
  62.                     p.addPotionEffect(hasteII);
  63.                 }
  64.                
  65.             } else if (item.getType() == Material.DIAMOND_AXE) {
  66.                 if (item.getItemMeta().getLore().contains("§cBuilt by Weaponsmith"))
  67.                 {
  68.                     PotionEffect hasteII = new PotionEffect(PotionEffectType.FAST_DIGGING, 9999*20, 1, false);
  69.                     p.addPotionEffect(hasteII);
  70.                 }
  71.                
  72.             } else if (item.getType() == Material.DIAMOND_HOE) {
  73.                 if (item.getItemMeta().getLore().contains("§cBuilt by Weaponsmith"))
  74.                 {
  75.                     PotionEffect hasteII = new PotionEffect(PotionEffectType.FAST_DIGGING, 9999*20, 1, false);
  76.                     p.addPotionEffect(hasteII);
  77.                 }
  78.                
  79.             }
  80.         }
  81.        
  82.         if (item == null || item.getItemMeta().getLore() == null) {
  83.             p.removePotionEffect(PotionEffectType.FAST_DIGGING);
  84.         }
  85.        
  86.     }
  87.    
  88.     @EventHandler
  89.     public void onPlayerItemMove(InventoryClickEvent e) {
  90.             e.getWhoClicked().removePotionEffect(PotionEffectType.FAST_DIGGING);
  91.     }
  92.    
  93. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement