Advertisement
Guest User

Untitled

a guest
Jan 25th, 2018
135
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.98 KB | None | 0 0
  1. @SuppressWarnings("deprecation")
  2. @EventHandler
  3. public void onInventoryClick(InventoryClickEvent e) {
  4. if(e.getClickedInventory().getName().contains(ChatColor.GREEN + "Unique Space Chest")) {
  5. e.setCancelled(true);
  6. Player p = (Player) e.getWhoClicked();
  7. if (e.isShiftClick()) {
  8. Messages.IS_SHIFT_CLICK(p);
  9. return;
  10. }
  11. if(e.getCurrentItem().getType() == Material.STAINED_GLASS) {
  12. if (e.getClickedInventory().contains(Material.CHEST, 5)) {
  13. return;
  14. }
  15. p.playSound(p.getLocation(), Sound.ORB_PICKUP, 100, 40);
  16. ItemStack chest = new ItemStack(Material.CHEST);
  17. ItemMeta chestMeta = chest.getItemMeta();
  18.  
  19. String[] name = e.getClickedInventory().getItem(e.getSlot()).getItemMeta().getDisplayName().toString().split("#");
  20.  
  21. chestMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&a&lMystisk Item &n#" + name[1]));
  22. ArrayList<String> lore = new ArrayList<String>();
  23. lore.add(ChatColor.GRAY + "Du har udvalgt dette mystiske item.");
  24. chestMeta.setLore(lore);
  25. chest.setItemMeta(chestMeta);
  26.  
  27. Inventory inv = (Inventory) e.getClickedInventory();
  28.  
  29. inv.setItem(e.getRawSlot(), chest);
  30. //e.getCurrentItem().setItemMeta();
  31.  
  32. if (e.getClickedInventory().contains(Material.CHEST, 5)) {
  33.  
  34. BukkitRunnable runnable = new BukkitRunnable() {
  35. @Override
  36. public void run() {
  37. for(int i = 0; i < inv.getContents().length; i++) {
  38. ItemStack is = inv.getItem(i);
  39. if(is.getType() == Material.STAINED_GLASS) {
  40. inv.setItem(i, new ItemStack(Material.STAINED_GLASS_PANE, 1, (byte) (new Random().nextInt(6)+1)));
  41. }
  42. }
  43. }
  44. };
  45.  
  46. Bukkit.getScheduler().scheduleSyncRepeatingTask(this, runnable, 0l, 10l); //every 1/2 second change.
  47.  
  48.  
  49.  
  50.  
  51.  
  52.  
  53. return;
  54. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement