Solved Right clicking on air with a fist

Discussion in 'Plugin Development' started by iPoke111, Dec 8, 2013.

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

    iPoke111

    Hi,
    I was experimenting with my plugin and found out that this is not called when I right click on air with my fist:
    Code:java
    1. if(enabled.contains(player.getName())
    2. && e.getAction() == Action.RIGHT_CLICK_AIR
    3. && player.getItemInHand().getType() == Material.AIR
    4. && !player.isSneaking()) {
    5. //stuff
    6. }

    I know that it's the RIGHT_CLICK_AIR that is the problem because when I tested it with
    Code:java
    1. if(enabled.contains(player.getName())
    2. && e.getAction() == Action.LEFT_CLICK_AIR
    3. && player.getItemInHand().getType() == Material.AIR
    4. && !player.isSneaking()) {
    5. //stuff
    6. }

    it worked fine. Is it just not possible or am I doing something wrong?
    Thanks,
    iPoke111
     
  2. Offline

    Draesia

    It currently doesn't register, it is a known 'bug' in Bukkit, however, if you need to do it, you can use protocollib, and intercept the packets, like this

    Code:
            ProtocolLibrary.getProtocolManager().addPacketListener(new PacketAdapter(cc, ConnectionSide.CLIENT_SIDE, 15) {
                @Override
                public void onPacketReceiving(PacketEvent event) {
                    //Code in here will be called when right clicking.
                }
            });
     
  3. Offline

    iPoke111

    Draesia
    Alright. Thanks! Is this for right clicking on air with a fist only, or any item?
    I'll set it to solved anyways.
     
Thread Status:
Not open for further replies.

Share This Page