Plugin Help Help with inventories?

Discussion in 'Plugin Help/Development/Requests' started by LeviiSnyderr, Oct 23, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    LeviiSnyderr

    So, in my private server, I want to add a backpack for players, and while I know how to make the inventory, I can't figure out how to make it player specific, currently it opens as a community chest.

    heres my code:
    Code:
        Server server = getServer();
        Inventory backpack = server.createInventory(null, InventoryType.CHEST);
        String[] extraCommands = {"backpack"};
       
        @Override
        public boolean onCommand(...) {
    
            if(command.getLabel().equalsIgnoreCase(extraCommands[0])){
                ((Player)sender).openInventory(backpack);
                return true;
            }
            return false;
        }
     
  2. @LeviiSnyderr You have no arguments? why do you have a String[] called extraCommands? Use command.getName not getLabel. Check before casting and please learn Java before doing Bukkit. Also who did you learn this off?
     
    mine-care likes this.
  3. Offline

    LeviiSnyderr

    I asked on here so I can learn, I thought the idea of the forums were to learn from one another?
    I learned where to start on a few YouTube videos. I know some Java, otherwise I wouldn't have gotten this far. A lot of this I setup on my own. I knew I needed an argument, but I'm not sure what. Googling didn't help, and you're being awful standoffish.. so, will you help me, or not?
     
  4. Online

    timtower Administrator Administrator Moderator

  5. Offline

    LeviiSnyderr

    @timtower thank you, and @bwfcwalshy I have a String[] because I can set it up like:

    Code:
    if(command.getName().equalsIgnoreCase(extraCommands[0[)){...}
    if(command.getName().equalsIgnoreCase(extraCommands[1[)){...}
    if(command.getName().equalsIgnoreCase(extraCommands[2[)){...}
     
  6. @LeviiSnyderr Why? Why not just use equalsIgnoreCase("command1")
     
  7. Offline

    LeviiSnyderr

    @bwfcwalshy because for me, it makes it easier to keep up with the commands, and what I put where.
     
  8. Online

    timtower Administrator Administrator Moderator

    @LeviiSnyderr Enum also works for that, or having separate command executors.
     
Thread Status:
Not open for further replies.

Share This Page