Insert an Item running Double Jump

Discussion in 'Plugin Development' started by ToPoEdiTs, Aug 23, 2014.

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


    I have to do to add that when a user use an item run the double jump?

    1. package com.topoedits;
    3. import org.bukkit.GameMode;
    4. import org.bukkit.Material;
    5. import org.bukkit.entity.Player;
    6. import org.bukkit.event.EventHandler;
    7. import org.bukkit.event.EventPriority;
    8. import org.bukkit.event.Listener;
    9. import org.bukkit.event.player.PlayerMoveEvent;
    10. import org.bukkit.event.player.PlayerToggleFlightEvent;
    11. import;
    13. public class Acrobata extends JavaPlugin implements Listener {
    14. public void onEnable(){
    15. getServer().getPluginManager().registerEvents(this, this);
    17. }
    19. @EventHandler
    20. public void onPlayerToggleFlight(PlayerToggleFlightEvent event) {
    21. Player player = event.getPlayer();
    22. if (player.getGameMode() == GameMode.CREATIVE)
    23. return;
    24. event.setCancelled(true);
    25. player.setAllowFlight(false);
    26. player.setFlying(false);
    27. player.setVelocity(player.getLocation().getDirection()
    28. .multiply(1.5).setY(1));
    29. }
    30. @EventHandler
    31. public void onPlayerMove(PlayerMoveEvent event) {
    32. Player player = event.getPlayer();
    33. if ((player.getGameMode() != GameMode.CREATIVE)
    34. && (player.getLocation().subtract(0, 1, 0).getBlock().getType() != Material.AIR)
    35. && (!player.isFlying()))
    36. player.setAllowFlight(true);
    38. }
    40. }
  2. Offline


    ToPoEdiTs, i'm sorry, but your grammer is so far off that I can't understand what you are asking. Anyone else understand this?
    KingFaris11 likes this.
  3. You can't use that point since you spelt "grammar" wrong.

    But getting back the point, yep, I have no idea what you want too.
    ChipDev likes this.
  4. Offline


    From what I got: He wants to know how to make player's be able to double jump when holing a specific item/use a specific item.
  5. Offline


    Tecno_Wizard A bit hypocritical.

    Anyway, I believe he is wondering how to activate double jump when you use an item.
    This can be interpreted 2 ways:

    1. Double jump when you use the Item:
    Listen to the PlayerInteractEvent, and check to see if the item that they click is what you want. If they do, run the Double Jump code.

    2. Enable/Disable double jump when you use the item:
    Same as before, but instead do p.setAllowFlight(boolean); instead of running the double jump code.
    This way, the flyevent can't get called for the player in order to double jump.
    Jozeth likes this.
  6. Offline


    unon1100 Jozeth, I wasn't trying to be rude in any fasion. I'm sorry if it seemed that way. Spelling was never my strong suit.
    By what method would you be creating a double jump, ToPoEdiTs?
Thread Status:
Not open for further replies.

Share This Page