Check for items in inventory

Discussion in 'Plugin Development' started by metincasper, Mar 15, 2015.

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

    metincasper

    Hi

    So i got this plugin that have a inventory menu.
    When i have the custom inventory open and click on a diamond sword it gives me a diamondsword. But it also gives me a diamondsword when i click on diamondsword in my own inventory, when i still have the custom inventory open...

    I tried to check if it was i right diamondsword in this way:

    Code:
    if (e.getCurrentItem().getType() == Material.DIAMOND_SWORD) {
                    if (!(e.getCurrentItem().getItemMeta().getDisplayName().equalsIgnoreCase("Awesome Sværd"))) return;
                    if (pi.contains(Material.OBSIDIAN, 2)) {
                        pi.removeItem(new ItemStack[] {
                                   new ItemStack(Material.OBSIDIAN, 2) });
                   
                            ItemStack asword = new ItemStack(Material.DIAMOND_SWORD);
                            asword.addEnchantment(Enchantment.DAMAGE_ALL, 3);
                            pi.addItem(asword);
                        return;
                    }else {
                        p.sendMessage(ChatColor.RED + "Du har ikke nok obsidian");
                        return;
                    }
                }
    But even if it has the display name "Awesome Sværd" it wont work at all...

    I hope someone know how to fix it.
    Thanks in advance :)
     
  2. Offline

    hopstar

    Uhmm check for slotnumber? so only items from your custom inventory get checked?
     
  3. Offline

    metincasper

    Ohh.. i havent think about that :D Thanks :)
     
  4. Offline

    Ruptur

    @metincasper
    You need to check for the clicked inventory

    Code:
    if (!event.getClickInventory.getName().contains("Inventoryname")) return;
    
     
  5. Offline

    metincasper

    @Ruptur there is not a method called getClickInventory
     
  6. Offline

    Ruptur

    @metincasper
    Sorry wrote it off the top of my head.
    Its not getClickInventory, its getClickedInventory
     
  7. Offline

    metincasper

    @hopstar i found a issue with checking the slot. If i have the dia sword in my custom inventory at slot 0 and i have another dia sword in my toolbar in slot 0 it think that it is in the custom inventory

    @Ruptur wich event do u find that method in? I use InventoryClickEvent and there is not a method like that
     
    Last edited by a moderator: Mar 15, 2015
  8. Offline

    Ruptur

  9. Offline

    metincasper

    I tried do this:
    Code:
            if (!(e.getInventory().getName().contains("Din handel")
                    || (e.getInventory().getName().contains("Noob Stuff"))
                    || (e.getInventory().getName().contains("Okay Stuff"))
                    || (e.getInventory().getName().contains("Godt Stuff"))
                    || (e.getInventory().getName().contains("Awesome Stuff")))) return;
    It still dosnst work
     
  10. Offline

    Ruptur

    @metincasper
    Doesnt work as in how?
    Remember to tahg who you want to speak to so they receive an alert :)
     
Thread Status:
Not open for further replies.

Share This Page