Shift Click Dismount Disabling

Discussion in 'Plugin Development' started by x2nec, Jul 10, 2013.

  1. Offline

    x2nec

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Hey, does anyone know any "hacks" or methods for cancelling the shift-click dismount feature? Preferably in the form of an event? We can't use the VehicleExitEvent because the mob in question is not actually a vehicle entity - the Bukkit API has nothing for what we need, as far as I can see. Any solutions?
    Phiwa likes this.
  2. Offline

    Garris0n

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    You could try listening to the PlayerToggleSneakEvent and putting the player back on the mob in question...not sure if that'd work.
  3. Offline

    Phiwa

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    We already tried that, doesn't fire the event when the player is on the mob. -.-

    But thanks for the answer. :)

    This post has been edited 1 time. It was last edited by Phiwa Jul 10, 2013.
  4. Offline

    x2nec

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME

    Let's play a game of "Spot the bit where it says EnderDragon:

    Code:
    All Known Subinterfaces:
    Boat, ExplosiveMinecart, HopperMinecart, Horse, Minecart, Pig, PoweredMinecart, PoweredMinecart, RideableMinecart, SpawnerMinecart, StorageMinecart, StorageMinecart
    As I said before, the events for vehicular entities DO NOT work for other mobs. I know perfectly well how to use JavaDocs and if the solution was clear in there I wouldn't be here now...

    This post has been edited 1 time. It was last edited by x2nec Jul 10, 2013.
    LucasEmanuel, Garris0n and Phiwa like this.
  5. Offline

    xTrollxDudex

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    @x2nec
    OOOOOH! I get it now xD. You need to save the dragon as an entity and have player.setPassenger(<name of saved dragon in the field>);
    It's known to kick people off if the ridden entity is not a vehicle so do Thread.sleep(1000); or something. NOTE: DO NOT do this in the main thread. NEVER NEVER do it in the main thread. Go it?
    Code:java
    1. //since I wasted your time, here's code! :)
    2. //on command method
    3. Player player = (Player) sender;
    4.  
    5. //find the EnderDragon in the world (NOT SURE IF GET ENTITIES WORK. Looking into javadocs)
    6. for(LivingEntity ent : player.getWorld().getEntities()){
    7. if(ent instanceof EnderDragon){
    8. player.teleport(ent.getLocation());
    9. ent.setPassenger(player)
    10. //ONLY if this is not in the main thread try without first
    11. Thread.sleep(1000);
    12. }
    13. }
  6. Offline

    Phiwa

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    But as x2nec stated in the very first post, our problem is not to mount the player (DragonTravel, the plugin we encountered the problem in, works since November 2009...), the problem is to avoid the new "SHIFT-click to dismount"-feature which also works for our dragon, but we do not want that and therefore need to cancel the Eject-Event.

    Problem:
    The new "feature" works perfectly even though the dragon is not a vehicle, but the event isn't fired because it is no vehicle... -.-

    This post has been edited 1 time. It was last edited by Phiwa Jul 10, 2013.
  7. Offline

    Garris0n

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    You really need to read the OP before you post...
    x2nec and Phiwa like this.
  8. Offline

    MylesIsCool

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    You could always have a Runnable running every 5 Ticks or so checking if the player is riding it, If now remount it.
  9. Offline

    Garris0n

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    May as well just check on a player move.
  10. Offline

    Phiwa

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    @MylesIsCool @Garris0n
    Yeah, we got a Hashmap <Player, Dragon>, so I thought we could iterate through it every tick/second/whatever, but we had hoped that someone has an idea which is less wasteful concerning resources by somehow directly cancelling the dismount-event. ;)

    This post has been edited 3 times. It was last edited by Phiwa Jul 11, 2013.
  11. Offline

    Garris0n

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Bukkit will probably add an event soon.
  12. Offline

    Phiwa

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    I'm not sure about that because the EnderDragon is no vehicle and not meant to become one, so adding an event just for us to have it easier won't make sense for the Bukkit-team... :)
  13. Offline

    Eats_Rainbows

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Try listening to PlayerInteractEntityEvent and check if event.getPlayer().isSneaking() ?
  14. Offline

    Garris0n

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    That rule applies to any array, list, hashmap, etc...not just hashmaps.
    I don't really think you should be criticizing people for not reading the thread...
    xTrollxDudex likes this.
  15. Offline

    TnT Trinitrotoluene Maximus Administrator Bukkit Help

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Cleaned offtopic posts.
  16. Offline

    xTrollxDudex

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Thank you tnt

    @x2nec make a scheduler that checks if the EnderDragon's getPassenger() returns a Player or if Player's getVehicle() returns the EnderDragon... This may not work depending on the method used to ride the EnderDragon
  17. Offline

    Phiwa

    dev.bukkit.org profile:
    CFUSERNAME
    My Plugins (CFCOUNT)
    Minecraft account:
    MCUSERNAME
    Thanks TnT :)


    I already implemented that (using the "EntityMoveEvent" instead of a scheduler) some days ago, but I didn't have the time to test it properly, but we had hoped there was a better solution to somehow do not deal with the result of the dismount and remount the player, but to prevent the player from dismounting. :)

    This post has been edited 1 time. It was last edited by Phiwa Jul 16, 2013.

Share This Page