Advertisement
Guest User

Untitled

a guest
Feb 7th, 2016
62
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.65 KB | None | 0 0
  1.  
  2. public class Events
  3. implements Listener
  4. {
  5. private AutoLapis plugin;
  6. private ItemStack lapis;
  7.  
  8. public Events(AutoLapis plugin)
  9. {
  10. this.plugin = plugin;
  11.  
  12. Dye d = new Dye();
  13. d.setColor(DyeColor.BLUE);
  14. this.lapis = d.toItemStack();
  15. this.lapis.setAmount(3);
  16. }
  17.  
  18. @EventHandler
  19. public void openInventoryEvent(InventoryOpenEvent e)
  20. {
  21. if (((e.getInventory() instanceof EnchantingInventory)) && (
  22. (e.getPlayer().hasPermission("autolapis.autofill")) ||
  23. (e.getPlayer().isOp()) || (e.getPlayer().hasPermission("*"))))
  24. {
  25. e.getInventory().setItem(1, this.lapis);
  26. this.plugin.inventories.add(
  27. (EnchantingInventory)e.getInventory());
  28. }
  29. }
  30.  
  31. @EventHandler
  32. public void closeInventoryEvent(InventoryCloseEvent e)
  33. {
  34. if ((e.getInventory() instanceof EnchantingInventory)) {
  35. if (this.plugin.inventories.contains((EnchantingInventory)e.getInventory()))
  36. {
  37. e.getInventory().setItem(1, null);
  38. this.plugin.inventories.remove(
  39. (EnchantingInventory)e.getInventory());
  40. }
  41. }
  42. }
  43.  
  44. @EventHandler
  45. public void inventoryClickEvent(InventoryClickEvent e)
  46. {
  47. if ((e.getClickedInventory() instanceof EnchantingInventory)) {
  48. if ((this.plugin.inventories.contains((EnchantingInventory)e.getInventory())) &&
  49. (e.getSlot() == 1)) {
  50. e.setCancelled(true);
  51. }
  52. }
  53. }
  54.  
  55. @EventHandler
  56. public void enchantItemEvent(EnchantItemEvent e)
  57. {
  58. if (this.plugin.inventories.contains((EnchantingInventory)e.getInventory())) {
  59. e.getInventory().setItem(1, this.lapis);
  60. }
  61. }
  62. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement