@EventHandler public void onPlayerInteract(PlayerInteractEvent event) { // We don't care about players other than the owner if (!event.getPlayer().equals(owner)) return; // We don't care about non-chest objects if (!(event.getClickedBlock().getState() instanceof Chest)) return; Player player = event.getPlayer(); Chest chest = (Chest) event.getClickedBlock().getState(); // DoubleChests are very broken right now if (!(chest.getInventory().getHolder() instanceof Chest)) { plugin.sendPlayerMessage( owner, ChatColor.DARK_BLUE + "Warning: " + ChatColor.WHITE + "Double chests cannot be used currently."); return; } // If we are not removing, it cannot already be a store if (plugin.isStore(chest) && !remove) { plugin.sendPlayerMessage( player, ChatColor.RED + "Error: " + ChatColor.WHITE + "That is already a store!"); return; } // If we are not removing, it cannot be a coffer if (plugin.isCoffer(chest) && !remove) { plugin.sendPlayerMessage( player, ChatColor.RED + "Error: " + ChatColor.WHITE + "That is a coffer and cannot be a store!"); return; } // If we are removing, it cannot be a coffer if (plugin.isCoffer(chest) && remove) { plugin.sendPlayerMessage( player, ChatColor.RED + "Error: " + ChatColor.WHITE + "That is a coffer not a store!"); return; } // If we are removing it must be a store if ((!plugin.isStore(chest) && remove) || (!plugin.isStore(chest) && admin)) { plugin.sendPlayerMessage( player, ChatColor.RED + "Error: " + ChatColor.WHITE + "That is not a store!"); return; } // If we are removing we must be the owner of the store if (plugin.isStore(chest) && remove && !plugin.getStoreOwner(chest).equals(owner)) { plugin.sendPlayerMessage( player, ChatColor.RED + "Error: " + ChatColor.WHITE + "That is not your store!"); return; } /** Chest Removal */ if (remove && !admin) { if (plugin.removeStore(chest)) plugin.sendPlayerMessage( owner, ChatColor.GREEN + "Your store has been removed from the chest."); else plugin.sendPlayerMessage( owner, ChatColor.DARK_RED + "Error: " + ChatColor.WHITE + "Unable to remove store. Try again."); plugin.removeSetting(owner); unregister(); return; } /** Chest Admin Create */ if (admin && !remove) { plugin.getStore(chest).setType(StoreType.ADMIN); plugin.sendPlayerMessage( owner, ChatColor.GREEN + "The store has been set as an Admin store."); plugin.removeSetting(owner); unregister(); return; } /** Chest Admin remove */ if (admin && remove) { plugin.getStore(chest).setType(StoreType.NORMAL); plugin.sendPlayerMessage( owner, ChatColor.GREEN + "The store has been removed as an Admin store."); plugin.removeSetting(owner); unregister(); return; } /** Chest Adding */ if (plugin.addStore(player, chest)) plugin.sendPlayerMessage( player, ChatColor.GREEN + "The chest has been setup as a store. Use " + ChatColor.WHITE + "'/rs help price'" + ChatColor.GREEN + " for help setting prices."); else plugin.sendPlayerMessage( owner, ChatColor.DARK_RED + "Error: " + ChatColor.WHITE + "Unable to add the store. Try again."); plugin.removeSetting(owner); unregister(); }