Get custom inventory slot

Discussion in 'Plugin Development' started by shohouku, Jul 11, 2014.

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

    shohouku

    I'm trying to get a slot from another custom inventory but it is still applied to the players inventory.

    I try to check if the slots are only from the inventory "Gun".

    Code:java
    1. if(e.getInventory().equals(Gun)) {
    2. if (e.getSlot() > 0 && e.getSlot() <= 9) {
    3. e.setCancelled(true);
    4. }
    5. }
     
  2. Offline

    marwzoor

    If it's a custom inventory holder you can just do:

    Code:java
    1.  
    2. if(e.getInventory().getHolder() instanceof CustomInventoryHolderClass)
    3. {
    4. //This will only be applied to your custom inventory
    5. }
    6.  
     
  3. Offline

    shohouku


    This is how I'm creating my inventory:

    Code:java
    1. public static Inventory Gun = Bukkit.createInventory(null, 9, "Gun");
     
  4. Offline

    marwzoor

    Okey, well that means that you have no inventoryholder. The only way I would go about doing it would be to check for the title of the inventory, in this case "Gun".

    Code:java
    1.  
    2. if(e.getInventory().getTitle().equalsIgnoreCase("Gun"))
    3. {
    4. //Do your stuff here
    5. }
    6.  
     
  5. Offline

    shohouku


    Already tried and tried this:

    Code:java
    1. if(e.getInventory().equals(Gun)) {


    The same slots as the custom inventory still connects to the players inventory...
     
  6. Offline

    maved145

    shohouku
    The checking for the inventory name should work. I have done it before.
     
  7. Offline

    shohouku


    Well it's working the same as:

    Code:java
    1. if(e.getInventory().equals(Gun)) {


    And it still connects with the players inventory.
     
Thread Status:
Not open for further replies.

Share This Page