Double-Jump Problem

Discussion in 'Plugin Development' started by nekojin325, Jan 25, 2014.

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

    nekojin325

    I'm trying to code a kit that basically can double-jump. I was able to do it quite easily, but there's one problem: I have no idea why, but i'm taking no fall damage. Only occasionally, randomly. Can someone help me? Thanks.

    Code:
    Code:java
    1. public class BunnyAbility implements Listener {
    2.  
    3. @EventHandler
    4. public void onPlayerMove(PlayerMoveEvent e) {
    5. final Player p = e.getPlayer();
    6. if(!kPvP.kit.containsKey(p.getName())) {
    7. if(p.getGameMode() != GameMode.CREATIVE) {
    8. p.setAllowFlight(false);
    9. p.setFlying(false);
    10. }
    11. return;
    12. }
    13. if(kPvP.kit.get(p.getName()).equals("Bunny")) {
    14. if(p.getGameMode() != GameMode.CREATIVE && (p.getLocation().getBlock().getRelative(BlockFace.DOWN).getType() != Material.AIR)) {
    15. Bukkit.getScheduler().scheduleSyncDelayedTask(kPvP.getInstance(), new Runnable() {
    16. public void run() {
    17. p.setAllowFlight(true);
    18. }
    19. }, 2 * 20);
    20. }
    21. }
    22. }
    23.  
    24. @EventHandler
    25. public void onPlayerToggleFlight(final PlayerToggleFlightEvent event) {
    26. if(!event.getPlayer().hasPermission("doublejump.use")) return;
    27. Player player = event.getPlayer();
    28. if(event.isFlying()) {
    29. event.getPlayer().setAllowFlight(false);
    30. event.setCancelled(true);
    31. event.getPlayer().setVelocity(player.getLocation().getDirection().multiply(0.5).setY(1));
    32. player.getWorld().playSound(player.getLocation(), Sound.BAT_TAKEOFF, 1f, -5f);
    33. }
    34. }
    35.  
    36. @EventHandler
    37. public void onEntityDamage(EntityDamageEvent e) {
    38. if(e.getEntity() instanceof Player) {
    39. Player p = (Player) e.getEntity();
    40. if(!kPvP.kit.containsKey(p.getName())) return;
    41. if(e.getCause() != DamageCause.FALL) return;
    42. if(kPvP.kit.get(p.getName()).equals("Bunny")) {
    43.  
    44. }
    45. }
    46. }
    47. }
     
  2. Offline

    xDGaming

    give them jumpboost just before they fall
     
  3. Offline

    nekojin325

    I tried that, i think it's a problem with setAllowFlight
     
  4. Offline

    xDGaming

    that may be it, try to disable it after they land
     
  5. Offline

    johngianni

    Hey I don't know if this could help but I think there is a Potion effect that can allow higher jumping. Something like this

    Code:java
    1. PotionEffectType doubleJump = new PotionEffectType(int duration,int amplifier);


    I don't know what is considered double jumping if you amplified it (probably 2). Also for the time, you can probably make some ridiculous time or something to keep the potion going. Tell me what you think about this but I am not sure if you already knew about this or not.
     
  6. Offline

    Garris0n

    If they're in flymode when they hit the ground I don't believe they'll take fall damage.
     
    bennie3211 likes this.
  7. Offline

    xDGaming

    well double jump would be enabling fly then disabling it
     
Thread Status:
Not open for further replies.

Share This Page