Java Code Examples for org.bukkit.entity.Player#getFlySpeed()

The following examples show how to use org.bukkit.entity.Player#getFlySpeed() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: ExprSpeed.java    From Skript with GNU General Public License v3.0 5 votes vote down vote up
@Override
public void change(final Event e, final @Nullable Object[] delta, final ChangeMode mode) throws UnsupportedOperationException {
	float input = delta == null ? 0 : ((Number) delta[0]).floatValue();
	
	for (final Player p : getExpr().getArray(e)) {
		float oldSpeed = walk ? p.getWalkSpeed() : p.getFlySpeed();
		
		float newSpeed;
		switch (mode) {
			case SET:
				newSpeed = input;
				break;
			case ADD:
				newSpeed = oldSpeed + input;
				break;
			case REMOVE:
				newSpeed = oldSpeed - input;
				break;
				//$CASES-OMITTED$
			default:
				newSpeed = walk ? 0.2f : 0.1f;
				break;
		}
		
		final float d = Math2.fit(-1, newSpeed, 1);
		
		if (walk)
			p.setWalkSpeed(d);
		else
			p.setFlySpeed(d);
	}
}
 
Example 2
Source File: LimboServiceHelper.java    From AuthMeReloaded with GNU General Public License v3.0 5 votes vote down vote up
/**
 * Creates a LimboPlayer with the given player's details.
 *
 * @param player the player to process
 * @param isRegistered whether the player is registered
 * @param location the player location
 * @return limbo player with the player's data
 */
LimboPlayer createLimboPlayer(Player player, boolean isRegistered, Location location) {
    // For safety reasons an unregistered player should not have OP status after registration
    boolean isOperator = isRegistered && player.isOp();
    boolean flyEnabled = player.getAllowFlight();
    float walkSpeed = player.getWalkSpeed();
    float flySpeed = player.getFlySpeed();
    Collection<String> playerGroups = permissionsManager.hasGroupSupport()
        ? permissionsManager.getGroups(player) : Collections.emptyList();
    logger.debug("Player `{0}` has groups `{1}`", player.getName(), String.join(", ", playerGroups));

    return new LimboPlayer(location, isOperator, playerGroups, flyEnabled, walkSpeed, flySpeed);
}
 
Example 3
Source File: ExprSpeed.java    From Skript with GNU General Public License v3.0 4 votes vote down vote up
@SuppressWarnings("null")
@Override
public Float convert(final Player p) {
	return walk ? p.getWalkSpeed() : p.getFlySpeed();
}
 
Example 4
Source File: LimboServiceTest.java    From AuthMeReloaded with GNU General Public License v3.0 4 votes vote down vote up
private static LimboPlayer convertToLimboPlayer(Player player, Location location, Collection<String> groups) {
    return new LimboPlayer(location, player.isOp(), groups, player.getAllowFlight(),
        player.getWalkSpeed(), player.getFlySpeed());
}