Help custom inventory unique for each player

Discussion in 'Plugin Development' started by fonkfader, Nov 4, 2012.

Thread Status:
Not open for further replies.
  1. Hello, i've made this plugin : The Enchant Box , it use a custom inventory to edit items enchantment, everything work fine but i still have an issue, the custom inventory view is not unique for each players so if 2 player use it at the same time the clicked slots change for all players, so how can fix it to have unique view for each players , this is some part of the code

    Code:
    public class EnchantBoxInventory {
       
        public EnchantBoxInventory (Player p){
     
            String name = "Enchant Box";
           
            Inventory inv = Bukkit.createInventory(p, 54, name);
            p.openInventory(inv);
        }
    }
    Main Class :

    Code:
    static void Enchantbox (Player p){
           
            EnchantBoxInventory inv = new EnchantBoxInventory(p);
           
        }
       
        public boolean onCommand(CommandSender sender, Command command, String cmd,
                String[] args) {
     
            Player p = null;
     
            if ((sender instanceof Player)) {
     
                p = (Player) sender;
                String name = p.getName();
     
                if (cmd.equalsIgnoreCase("ebox")) {
                    if (p.hasPermission("EnchantBox.use") || (p.isOp())) {
                       
                        Enchantbox(p);
                        return true;
                    } else {
                        p.sendMessage(red + "no permissions");
                        return true;
                    }
                }
                return false;
     
            }
            return false;
        }
     
    }
    EnventClass :

    Code:
    @EventHandler
        public void inventoryOpen(InventoryOpenEvent e) {
     
            Player p = (Player) e.getPlayer();
            Inventory inv = e.getInventory();
            String name = "Enchant Box";
           
            if (e.getView().getTitle() == name) {
     
    etc...
    i've try to change the name of the inventory to :

    Code:
    Inventory inv = Bukkit.createInventory(p, 54, player.getName()+"'s Enchant Box");
    but that don't work ( the inventory is created but the event part not). Any suggestion ?
     
Thread Status:
Not open for further replies.

Share This Page