Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- @SuppressWarnings("deprecation")
- @EventHandler
- public void onInventoryClick(InventoryClickEvent e) {
- if(e.getClickedInventory().getName().contains(ChatColor.GREEN + "Unique Space Chest")) {
- e.setCancelled(true);
- Player p = (Player) e.getWhoClicked();
- if (e.isShiftClick()) {
- Messages.IS_SHIFT_CLICK(p);
- return;
- }
- if(e.getCurrentItem().getType() == Material.STAINED_GLASS) {
- if (e.getClickedInventory().contains(Material.CHEST, 5)) {
- return;
- }
- p.playSound(p.getLocation(), Sound.ORB_PICKUP, 100, 40);
- ItemStack chest = new ItemStack(Material.CHEST);
- ItemMeta chestMeta = chest.getItemMeta();
- String[] name = e.getClickedInventory().getItem(e.getSlot()).getItemMeta().getDisplayName().toString().split("#");
- chestMeta.setDisplayName(ChatColor.translateAlternateColorCodes('&', "&a&lMystisk Item &n#" + name[1]));
- ArrayList<String> lore = new ArrayList<String>();
- lore.add(ChatColor.GRAY + "Du har udvalgt dette mystiske item.");
- chestMeta.setLore(lore);
- chest.setItemMeta(chestMeta);
- Inventory inv = (Inventory) e.getClickedInventory();
- inv.setItem(e.getRawSlot(), chest);
- //e.getCurrentItem().setItemMeta();
- if (e.getClickedInventory().contains(Material.CHEST, 5)) {
- BukkitRunnable runnable = new BukkitRunnable() {
- @Override
- public void run() {
- for(int i = 0; i < inv.getContents().length; i++) {
- ItemStack is = inv.getItem(i);
- if(is.getType() == Material.STAINED_GLASS) {
- inv.setItem(i, new ItemStack(Material.STAINED_GLASS_PANE, 1, (byte) (new Random().nextInt(6)+1)));
- }
- }
- }
- };
- Bukkit.getScheduler().scheduleSyncRepeatingTask(this, runnable, 0l, 10l); //every 1/2 second change.
- return;
- }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement