Guest User

Untitled

a guest
May 9th, 2017
52
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. package me.yhl;
  2.  
  3. import org.bukkit.Bukkit;
  4. import org.bukkit.ChatColor;
  5. import org.bukkit.Material;
  6. import org.bukkit.entity.HumanEntity;
  7. import org.bukkit.entity.Player;
  8. import org.bukkit.event.EventHandler;
  9. import org.bukkit.event.Listener;
  10. import org.bukkit.event.inventory.InventoryClickEvent;
  11. import org.bukkit.event.inventory.InventoryCloseEvent;
  12. import org.bukkit.inventory.Inventory;
  13. import org.bukkit.inventory.ItemStack;
  14. import org.bukkit.inventory.meta.ItemMeta;
  15.  
  16. public class ListenerClass implements Listener {
  17. AnimationTimer at = new AnimationTimer(Miner.getInstance());
  18.  
  19. public void setItem(Material item, String itemname,Inventory inv2, int slot){
  20. ItemStack itemm = new ItemStack(item);
  21. ItemMeta tmeta = itemm.getItemMeta();
  22. tmeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', itemname));
  23. itemm.setItemMeta(tmeta);
  24. inv2.setItem(slot, itemm);
  25. }
  26.  
  27. @EventHandler
  28. public void onClose(InventoryCloseEvent e) {
  29. Player p = (Player) e.getPlayer();
  30. }
  31.  
  32. @SuppressWarnings("static-access")
  33. @EventHandler
  34. public void onInventoryInteract(InventoryClickEvent e){
  35. Player p = (Player) e.getWhoClicked();
  36. Inventory cpanel = Bukkit.createInventory(p, 45, ChatColor.GOLD + "" + ChatColor.BOLD + p.getName() + "'s Miner (Control Panel)");
  37.  
  38.  
  39.  
  40.  
  41. if(e.getInventory().getTitle().equals(ChatColor.GOLD + "" + ChatColor.BOLD + p.getName() + "'s Miner")){
  42.  
  43. // if(e.getSlot() == 29){
  44. //
  45. //
  46. // if(p.hasPermission("Miner.use")){
  47. // if(!at.t.get(p)){
  48. // p.sendMessage(": " + at.t.get(p));
  49. // e.setCancelled(true);
  50. // at.toggleAnimation(p, inv);
  51. // p.sendMessage(": " + at.t.get(p));
  52. // } else if(at.t.get(p)){
  53. // e.setCancelled(true);
  54. // p.sendMessage(": " + at.t.get(p));
  55. // at.toggleAnimation(p, inv);
  56. // p.sendMessage(": " + at.t.get(p));
  57. // }
  58. // } else{
  59. // p.sendMessage(ChatColor.DARK_RED + "You do not have permission to do this.");
  60. // e.setCancelled(true);
  61. // return;
  62. // }
  63. // }
  64.  
  65. if(e.getSlot() == 31){
  66.  
  67.  
  68.  
  69. if(e.getCurrentItem().getType() == Material.COAL){
  70.  
  71. setItem(Material.IRON_INGOT, "&7Iron", e.getInventory(), 31);
  72. p.updateInventory();
  73. } else if(e.getCurrentItem().getType() == Material.IRON_INGOT){
  74.  
  75. setItem(Material.GOLD_INGOT, "&6Gold", e.getInventory(), 31);
  76. } else if(e.getCurrentItem().getType() == Material.GOLD_INGOT){
  77.  
  78. setItem(Material.DIAMOND, "&3Diamond", e.getInventory(), 31);
  79. } else if(e.getCurrentItem().getType() == Material.DIAMOND){
  80.  
  81. setItem(Material.COAL, "&4Coal", e.getInventory(), 31);
  82. }
  83. }
  84.  
  85. if(e.getSlot() == 29){
  86. p.closeInventory();
  87. p.openInventory(cpanel);
  88. setItem(Material.GOLD_BARDING, "&3&lAnimation", cpanel, 13);
  89. setItem(Material.BARRIER, "&c&lBack", cpanel, 44);
  90. }
  91.  
  92.  
  93. e.setCancelled(true);
  94. }if(e.getInventory().getTitle().equals(ChatColor.GOLD + "" + ChatColor.BOLD + p.getName() + "'s Miner (Control Panel)")){
  95.  
  96. if(e.getSlot() == 13){
  97. e.setCancelled(true);
  98. if(at.Animation){
  99. at.Animation = false;
  100. p.sendMessage("" + at.Animation);
  101. } else{
  102. at.Animation = true;
  103. p.sendMessage("" + at.Animation);
  104. }{
  105.  
  106. }
  107. } else if(e.getSlot() == 44) {
  108. e.setCancelled(true);
  109. p.closeInventory();
  110. Inventory miner = at.getMiner(p);
  111. p.openInventory(miner);
  112. }
  113. }
  114.  
  115. }
  116.  
  117. }
RAW Paste Data