Search
 
SCRIPT & CODE EXAMPLE
 

JAVA

java bukkit double jump

import java.util.ArrayList;
import java.util.List;

import org.bukkit.GameMode;
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.PlayerQuitEvent;
import org.bukkit.event.player.PlayerToggleFlightEvent;

public class DoubleJump implements Listener {

	private List<Player> doubleJump;
	
	public DoubleJump() {
		doubleJump = new ArrayList<>();
	}

	@EventHandler
	public void onJoin(PlayerJoinEvent event) {
		event.getPlayer().setAllowFlight(true);
	}

	@EventHandler
	public void onQuit(PlayerQuitEvent event) {
		doubleJump.remove(event.getPlayer());
	}

	@EventHandler
	public void onToggleFlight(PlayerToggleFlightEvent event) {
		Player player = event.getPlayer();
		GameMode gameMode = player.getGameMode();
		
		if(gameMode == GameMode.CREATIVE || gameMode == GameMode.SPECTATOR || player.isFlying()) {
			return;
		}

		event.setCancelled(true);
		doubleJump.add(player);

		player.setAllowFlight(false);
		player.setFlying(false);
		player.setVelocity(player.getLocation().getDirection().multiply(1.5).setY(1));
	}

	@EventHandler
	public void onHitGround(PlayerMoveEvent event) {
		Player player = event.getPlayer();

		if ((player.isOnGround() || event.getTo().getBlock().isLiquid()) && doubleJump.remove(player)) {
			player.setAllowFlight(true);
		}
	}
}
Comment

PREVIOUS NEXT
Code Example
Java :: entity cannot be resolved to a type in spring boot eclipse 
Java :: factorial program in java 
Java :: android studio constraint layout proportional height 
Java :: upload byte array to oss 
Java :: java summe array 
Java :: how to change color of progress bar in android 
Java :: how to summon lightning in minecraft 
Java :: Validation failed for query for method public abstract java.util.List 
Java :: retrofit implementation 
Java :: android get list element by index 
Java :: instantiate optinal java 8 
Java :: java list distinct by attribute 
Java :: how to get input form combobox java 
Java :: multiple type array java 
Java :: convert arraylist to csv file java 
Java :: root to leaf sum leetcode 
Java :: fibonacci number in java 
Java :: get random number from enum in java 
Java :: get request in java 
Java :: java get random 
Java :: uuid from any string java 
Java :: java sleep 1 second 
Java :: How to efficiently convert a sorted array into a min height binary search tree, in Java? 
Java :: arraylist to int array conversion in java 
Java :: retrofit android 
Java :: android java listview clean 
Java :: get length of a string java 
Java :: java sum of array elements 
Java :: bean factory vs application context 
Java :: arraylist input from user java 
ADD CONTENT
Topic
Content
Source link
Name
7+2 =