Advertisement
Guest User

ListenerClass

a guest
Apr 30th, 2017
82
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package me.yhl;
  2.  
  3. import org.bukkit.ChatColor;
  4. import org.bukkit.Material;
  5. import org.bukkit.entity.Player;
  6. import org.bukkit.event.EventHandler;
  7. import org.bukkit.event.Listener;
  8. import org.bukkit.event.inventory.InventoryClickEvent;
  9.  
  10. public class ListenerClass implements Listener {
  11. AnimationTimer at = new AnimationTimer(Miner.getInstance());
  12.  
  13.  
  14.  
  15.  
  16. @SuppressWarnings("static-access")
  17. @EventHandler
  18. public void onInventoryInteract(InventoryClickEvent e){
  19. Player p = (Player) e.getWhoClicked();
  20. at.t.put(p, false);
  21.  
  22.  
  23. if(e.getInventory().getTitle().equals(ChatColor.GOLD + "" + ChatColor.BOLD + p.getName() + "'s Miner")){
  24.  
  25. if(e.getSlot() == 29){
  26.  
  27.  
  28. if(p.hasPermission("Miner.use")){
  29. if(at.t.get(p) == false){
  30. p.sendMessage(": " + at.t.get(p));
  31. at.getItem(Material.DIAMOND_BLOCK, "&3&lON", e.getInventory(), 29);
  32. at.t.put(p, true);
  33. p.sendMessage(": " + at.t.get(p));
  34. } else if(at.t.get(p) == true){
  35. at.getItem(Material.REDSTONE_BLOCK, "&c&lOFF", e.getInventory(), 29);
  36. p.sendMessage(": " + at.t.get(p));
  37. at.t.put(p, false);
  38. p.sendMessage(": " + at.t.get(p));
  39. }
  40. } else{
  41. p.sendMessage(ChatColor.DARK_RED + "You do not have permission to do this.");
  42. e.setCancelled(true);
  43. return;
  44. }
  45. }
  46.  
  47. if(e.getSlot() == 31){
  48.  
  49.  
  50.  
  51. if(e.getCurrentItem().getType() == Material.COAL){
  52.  
  53. at.getItem(Material.IRON_INGOT, "&7&lIRON", e.getInventory(), 31);
  54. p.updateInventory();
  55. } else if(e.getCurrentItem().getType() == Material.IRON_INGOT){
  56.  
  57. at.getItem(Material.GOLD_INGOT, "&6&lGOLD", e.getInventory(), 31);
  58. } else if(e.getCurrentItem().getType() == Material.GOLD_INGOT){
  59.  
  60. at.getItem(Material.DIAMOND, "&3&lDIAMOND", e.getInventory(), 31);
  61. } else if(e.getCurrentItem().getType() == Material.DIAMOND){
  62.  
  63. at.getItem(Material.COAL, "&4&lCOAL", e.getInventory(), 31);
  64. }
  65. }
  66.  
  67. e.setCancelled(true);
  68. }
  69.  
  70. }
  71.  
  72. }
Advertisement
RAW Paste Data Copied
Advertisement