Shift Click Dismount Disabling

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

Thread Status:
Not open for further replies.
  1. 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. You could try listening to the PlayerToggleSneakEvent and putting the player back on the mob in question...not sure if that'd work.
  3. We already tried that, doesn't fire the event when the player is on the mob. -.-

    But thanks for the answer. :)

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

    Code (Text):
    1. All Known Subinterfaces:
    2. 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...
    LucasEmanuel, Garris0n and Phiwa like this.
  5. 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?
    1. //since I wasted your time, here's code! :)
    2. //on command method
    3. Player player = (Player) sender;
    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. 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.

    The new "feature" works perfectly even though the dragon is not a vehicle, but the event isn't fired because it is no vehicle... -.-
  7. You really need to read the OP before you post...
    x2nec and Phiwa like this.
  8. You could always have a Runnable running every 5 Ticks or so checking if the player is riding it, If now remount it.
  9. May as well just check on a player move.
  10. 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. ;)
  11. Bukkit will probably add an event soon.
  12. 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. Try listening to PlayerInteractEntityEvent and check if event.getPlayer().isSneaking() ?
  14. 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 Retired Staff

    Cleaned offtopic posts.
  16. 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. 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. :)
Thread Status:
Not open for further replies.

Share This Page