Discussion in 'Plugin Development' started by TerroDoor, Aug 8, 2019.

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


    I'm creating a bunch of different kits and I've decided to list each different kit as an ArrayList<String> kitname; and I'm using a inventory GUI to select them, which works and adds them but I'm wondering if there's another way to do this?

    I want to be able to list all the kits that the player does have in green and have the kits the player doesn't in red displayed in the GUI.

    I have a few ideas but need some professional help, thanks!
  2. Offline


    Is this already solved?
  3. Offline


    My phone auto marked it as solved it won't let me unsolve it, I'm still puzzled!

    Sent from my ZTE BLADE A602 using Tapatalk
  4. Offline


    Your method with the ArrayList is the same I would use. Just check if the Kit ArrayList contains the player and display it with green, and if it doesnt contain the player display it in red.
  5. Offline


    That works for when they select a certain kit, they get added and once added they have special abilities. Once they die and respawn they don't contain any of the Arrays so how would I display what they have if the aren't in any arrays?

    I have a config that holds player balances so I'm thinking maybe I need to use permissions and loop thru the perms?

    Thanks for your respond!

    Sent from my ZTE BLADE A602 using Tapatalk
  6. Offline


    Wait a second, do you want to check what kits the player has in his inventory or do you want to check which of the kits he owns?
  7. Offline


    Yes sorry if I have made it confusing as I'm just trying to find out myself how to do this.

    When the player opens the GUI( kit selector inv ) I want the players kits that he does own listed as 'owned' at the start of the inventory and the ones that the player hasn't purchased yet listed as 'Un-owned'

    I've decided to just use the arrays for when the player selects a certain kit, they get added and contain special abilities

    Sent from my ZTE BLADE A602 using Tapatalk
  8. Offline


    Okay, so, it doesnt work for you if you just add the player to an ArrayList when he buys the kit?
  9. Offline


    I haven't set that part up yet, if I add them to an array when they buy the kit then it'll only be temporary, it would be better to add them to a permission when they buy a kit.

    I'm stuck with displaying the kits in the inventory.

    I'm using arrays to add the player once he selects the kit(for the special abilities), so it is removed when he dies, which works fine.

    Thanks for your time!

    Sent from my ZTE BLADE A602 using Tapatalk
  10. Offline


    I think you mean ArrayLists, not arrays, right?

    Anyway, could you show me your code? Would be way easier.
  11. Offline


    public class Kits implements Listener {
        private Main plugin;
        public Kits(Main instance) {
            plugin = instance;
        public void onSelectKit(InventoryClickEvent e) {
            Player p = (Player)e.getWhoClicked();
            if (e.getCurrentItem().getType() == Material.DIAMOND_SWORD) {
                p.getInventory().addItem(new ItemStack(Material.DIAMOND_SWORD, 1));
                p.sendMessage("soldier selected");
        public void onOpenInv(PlayerInteractEvent e) {
            Player p = (Player)e.getPlayer();
            if (p.getInventory().getItemInMainHand().getType().equals(Material.FEATHER)) {
                if (e.getAction() == Action.RIGHT_CLICK_AIR || e.getAction() == Action.RIGHT_CLICK_BLOCK) {
                    plugin.kitinv.setItem(0, soldier);
                    plugin.kitinv.setItem(1, archer);
                    plugin.kitinv.setItem(2, minion);
                    plugin.kitinv.setItem(3, pyro);
                    plugin.kitinv.setItem(4, flash);
                    plugin.kitinv.setItem(5, mage);
                    plugin.kitinv.setItem(6, fisherman);
                    plugin.kitinv.setItem(7, healer);
                    plugin.kitinv.setItem(8, frost);
            } else {
  12. Offline


    add this to your code:

    public ArrayList<Player> soldier = new ArrayList<Player>();
    And, when selects the kit add this:


    Gesendet von iPhone mit Tapatalk
  13. Offline


    @maxwell71, yes ive done that and it works, now when im at spawn without any kits and i open my selector i want it showing as Owned Kits: and Unowned Kits:
  14. Offline


    Okay, so now you can do this:

     //your code
    im writing this on my phone right now, so i cant check if this works fine, but i think it should

    So now you have to create an ItemMeta which is the item you want to be the soldier item (of course you also need 2 different itemstacks for every kit), then call it maybe „§4 Soldier: Unowned“

    then create a second itemmeta and name the displayname: „§3Soldier: owned“

    that should be it
  15. Offline


    As @TerroDoor mentioned earlier, You could give the player a special permission if he owns the kit. If he does own the kit, change the name of the itemStack in the inventory instead of making a whole new itemStack.

    For exmaple;
    String name = p.hasPermission("special.permission.soldier") ? "Owned" : "Unowned"
    If the code above confuse you, let me explain:
    p.hasPermission("special.permission.soldier") <-- Condition
    ? <-- It's just there to make the expression work, info on it can be researched.
    "Owned" <-- Will become name if the condition returns true.
    "Unowned" <-- Will become name if the condition returns false.
    TerroDoor likes this.
Thread Status:
Not open for further replies.

Share This Page