Skip to content

Commit

Permalink
Testing Fall damage
Browse files Browse the repository at this point in the history
  • Loading branch information
ItzJustSamu committed Dec 5, 2023
1 parent 2ea4cbc commit a124e45
Showing 1 changed file with 14 additions and 1 deletion.
Original file line number Diff line number Diff line change
Expand Up @@ -20,6 +20,7 @@
import org.bukkit.event.player.PlayerMoveEvent;
import org.bukkit.event.player.PlayerToggleFlightEvent;
import org.bukkit.event.player.PlayerToggleSneakEvent;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;

import java.util.List;
Expand Down Expand Up @@ -115,10 +116,22 @@ public void onPlayerToggleFlight(PlayerToggleFlightEvent event) {
player.setVelocity(direction.multiply(jumpHeight));
player.setAllowFlight(false);

// Set the flag indicating that the player has double-jumped
HasDoubleJumped.put(player, true);

new BukkitRunnable() {
@Override
public void run() {
if (player.isOnGround()) {
player.sendMessage("Floor!");
player.setAllowFlight(true);
HasDoubleJumped.put(player, false);
cancel();
}
}
}.runTaskTimer(getPlugin(), 0, 1); // Change 'plugin' to your actual plugin instance
}


@EventHandler
public void onSneak(final PlayerToggleSneakEvent event) {
Player player = event.getPlayer();
Expand Down

0 comments on commit a124e45

Please sign in to comment.