Double jump glitch error

Discussion in 'Plugin Development' started by CaptainUniverse, Aug 22, 2014.

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

    CaptainUniverse

    Hi guys I'm making a double jump plugin my code here
    HTML:
    package me.Nicolas.AstroHub;
     
    import org.bukkit.GameMode;
    import org.bukkit.Material;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.event.player.PlayerMoveEvent;
    import org.bukkit.event.player.PlayerToggleFlightEvent;
     
    public class HubJumpAndStacker implements Listener{
        @EventHandler
        public void onPlayerJoin(PlayerJoinEvent event) {
            Player player = event.getPlayer();
            player.setGameMode(GameMode.SURVIVAL);
     
        }
     
        @EventHandler
        public void onPlayerToggleFlight(PlayerToggleFlightEvent event) {
            Player player = event.getPlayer();
            if (player.getGameMode() != GameMode.CREATIVE) {
                player.setAllowFlight(false);
                event.setCancelled(true);
                player.setFlying(false);
                player.setVelocity(player.getLocation().getDirection().multiply(1.5).setY(1));
            }
        }
        @EventHandler
        public void onMove (PlayerMoveEvent e) {
            Player player = e.getPlayer();
            if (player.getGameMode() != GameMode.CREATIVE && player.getLocation().subtract(0,1,0).getBlock().getType() != Material.AIR && ! player.isFlying()) {
                player.setAllowFlight(true);       
            }
        }
    }
    It works fine and all but sometimes if you press the jump bar too fast it will glitch and allow the user to triple jump can anyone give me any ideas on how to fix this?
     
  2. Offline

    JordyPwner

  3. Offline

    fireblast709

    CaptainUniverse instead of subtracting 1, try subtracting 0.1... or 0.0001
     
  4. Offline

    CaptainUniverse

    JordyPwner by cooldowns you mean repeatable tasks with the bukkit scheduler right? well that might lag out big servers because this plugin is actually for a friend of mine who has hundreds of people on all the time. and fireblast709 I trried 0.1 and lower and they all didn't work got any other ideas?
     
  5. Offline

    fireblast709

    CaptainUniverse debug why it doesn't work. That should give you an idea how to make it work.
     
  6. Offline

    CaptainUniverse

    I'm not actually sure why itsnot working fireblast709 thats why I'm talking in a forum :3
     
  7. Offline

    Anonymous350

  8. Offline

    CaptainUniverse

    Anonymous350 like I said earlier Bukkit runnables a.k.a repeatable tasks cause lag to a server
     
  9. Offline

    Necrodoom

     
Thread Status:
Not open for further replies.

Share This Page