Right click and left click in custom inventory

Discussion in 'Plugin Development' started by Hugo_Meteo, Jun 29, 2015.

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

    Hugo_Meteo

    Hi,
    I would like to know how to detect a right click or a left click on an item in a custom inventory ?

    I only found Action.RIGHT_CLICK_AIR / Block and same for left click.

    Thanks !
     
  2. Offline

    Hugo_Meteo

    Thx !

    Code:
                    if(redstone.getType() == Material.REDSTONE){
                        if(e.getClick() == ClickType.LEFT){
                        Location locaton = new Location(getOverWorld(), -312.5, 53, 1203.5);
                        locaton.setYaw(1);
                        locaton.setPitch(1);
                        p.teleport(locaton);
                    }else{
                       
                        Inventory invgungr = Bukkit.createInventory(null, 9,ChatColor.RED+"GunGR");
                        p.openInventory(invgungr);
                        }
                    }
    Mhh, I would like to open an other custom inventory when right click, so how can I do ? I tried this but it doesn't work:

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 12, 2016
  3. What doesn't work? Are there any errors?
     
    Last edited: Jun 29, 2015
  4. Offline

    Hugo_Meteo

    That's not solved, so. ..
     
  5. Offline

    Ruptur

    @Hugo_Meteo
    Like FisheyLP said, please be more specific about what 'doest work'. It helps narrow them the problem :)

    If you are going to create the same inventory very event then you should define it outside scope.
     
  6. Offline

    Hugo_Meteo

    I'm trying to open another inventory when the player right click on a specific item.

    When I did that, it just didn't do anything.
     
  7. Offline

    Ruptur

    @Hugo_Meteo
    (remember to tahg people - alerts them that you are speaking to them)
    Have you tried sending debug messages to see if it got to that specific point?
     
  8. Offline

    Hugo_Meteo

    @Ruptur
    Mhh nope, I started to make plugins yesterday, so I just begin and I don't know how to turn on the debug. Can u help me for this ? ^^
     
  9. Offline

    timtower Administrator Administrator Moderator

    @Hugo_Meteo Try to start smaller then inventory stuff when you just started yesterday
     
  10. Offline

    Ruptur

    @timtower Agreed.

    @Hugo_Meteo
    By debug messages i meant send a message to yourself (or console) saying that it got to that point
     
  11. Offline

    Hugo_Meteo

    @timtower
    I need to make plugins for my server, but i have one experimented devloper with me (but not here today !).

    @Ruptur I tried with .sendMessage("Test"), and it worked. but still not the new inventory
     
  12. Offline

    timtower Administrator Administrator Moderator

    @Hugo_Meteo Never said that you don't need to code at all, I said that it would be better to expand your knowledge step by step instead of taking a leap of faith.
     
    Ruptur likes this.
  13. Offline

    tytwining

    As much as I do agree with @timtower , I realize that you're checking if the item is redstone, and if it's not then you're opening the inventory. Is this intended?
     
Thread Status:
Not open for further replies.

Share This Page