Left-click doesn't work in adventure mode #1214


  • Defect
  • Vanilla
Open
  • _ForgeUser23963900 created this issue Jun 10, 2017

    Plugin Version

    ChestShop version 3.8.13-SNAPSHOT (build #12)

     

    Server Version

    CraftBukkit version git-Spigot-3fb9445-6e3cec8 (MC: 1.11.2)

     

    What other plugins are you running?

    Vault version 1.5.6-b49; Essentials version 2.0.1-b472

     

    What is happening?

    When a player is in adventure mode, left clicking on a shop sign doesn't sell nor buy, while right-click works like a charm.

     

    What did you expect to happen?

    I expected that the left-click would sell or buy, depending on the config option.

     

    Please provide any additional info below

    None.

  • _ForgeUser23963900 added a tag Defect Jun 10, 2017
  • Phoenix616 posted a comment Jun 28, 2017

    Afaik this isn't really fixable as the server does not receive any info from a player in adventure mode that he left clicked as he can't destroy blocks. I would be happy to be proven wrong though.

  • Phoenix616 added a tag Vanilla Jun 28, 2017
  • _ForgeUser23963900 posted a comment Jun 28, 2017

    Well, PlayerInteractEvent doesn't fire indeed, but I think I found a workaround:

        @EventHandler
        public void onPlayerAnimation(PlayerAnimationEvent e) {
    	Player p = e.getPlayer();
    
    	p.sendMessage(p.getGameMode() + ", " + p.getTargetBlock((Set<Material>) null, 5).getType());
        }

     

    Since the only animation for PlayerAnimationEvent is ARM_SWING, and it only fires on LEFT_CLICK, it should be rather reliable at the moment.

    Glad to prove you wrong, though. ;)


    Edited Jun 28, 2017
  • Phoenix616 posted a comment Jul 4, 2017

    While this is definitely an interesting approach we will run into the issue where even clicks not directly onto the sign (e.g. the block behind of a wall sign) will still trigger the selling as the line of sight intercepts with the block that the player is in. This could be really confusing for players and lead to some accidental sales.

     

    I've added my attempt to a new adventuremode-workaround branch if you want to try to get it working yourself.


    Edited Jul 5, 2017
  • Phoenix616 posted a comment Jul 19, 2017

    So I fixed the hitbox issue by adding my own bounding box interception check.

     

    I'm noticing another issue now though: The PlayerAnimationEvent will get fired for right clicks on signs too. As far as I can tell there is no way to differentiate between a left click and a right click with that event so this whole approach isn't really a solution for the problem.

  • Phoenix616 posted a comment Jul 8, 2019

    Related GitHub ticket.


To post a comment, please login or register a new account.