Java Code Examples for org.bukkit.entity.Player#setWalkSpeed()
The following examples show how to use
org.bukkit.entity.Player#setWalkSpeed() .
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: MatchPlayer.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
public void reset() { final Player bukkit = getBukkit(); bukkit.closeInventory(); clearInventory(); bukkit.setExhaustion(0); bukkit.setFallDistance(0); bukkit.setFireTicks(0); bukkit.setFoodLevel(20); // full bukkit.setMaxHealth(20); bukkit.setHealth(bukkit.getMaxHealth()); bukkit.setAbsorption(0); bukkit.setLevel(0); bukkit.setExp(0); // clear xp bukkit.setSaturation(5); // default bukkit.setFastNaturalRegeneration(false); bukkit.setSlowNaturalRegeneration(true); bukkit.setAllowFlight(false); bukkit.setFlying(false); bukkit.setSneaking(false); bukkit.setSprinting(false); bukkit.setFlySpeed(0.1f); bukkit.setKnockbackReduction(0); bukkit.setWalkSpeed(WalkSpeedKit.BUKKIT_DEFAULT); AttributeUtils.removeAllModifiers(bukkit); resetPotions(); // we only reset bed spawn here so people don't have to see annoying messages when they respawn bukkit.setBedSpawnLocation(null); match.callEvent(new PlayerResetEvent(this)); }
Example 2
Source File: Utils.java From ProjectAres with GNU Affero General Public License v3.0 | 5 votes |
public static void resetPlayer(Player player) { player.getInventory().clear(); player.getInventory().setChestplate(new ItemBuilder().material(Material.ELYTRA).unbreakable(true).get()); player.setGameMode(GameMode.ADVENTURE); player.setAllowFlight(player.hasPermission("lobby.fly")); player.setWalkSpeed(0.2f); player.setFlySpeed(0.1f); player.setPotionParticles(false); player.hideTitle(); player.getWorld().spawnParticle(Particle.CLOUD, player.getLocation(), 15, 0.5, 0.5, 0.5, 0); }
Example 3
Source File: ExprSpeed.java From Skript with GNU General Public License v3.0 | 5 votes |
@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 4
Source File: WalkSpeedFlagHandler.java From WorldGuardExtraFlagsPlugin with MIT License | 5 votes |
private void handleValue(Player player, Double speed) { if (speed != null) { if (speed > 1.0) { speed = 1.0; } else if (speed < -1.0) { speed = -1.0; } if (player.getWalkSpeed() != speed.floatValue()) { if (this.originalWalkSpeed == null) { this.originalWalkSpeed = player.getWalkSpeed(); } player.setWalkSpeed(speed.floatValue()); } } else { if (this.originalWalkSpeed != null) { player.setWalkSpeed(this.originalWalkSpeed); this.originalWalkSpeed = null; } } }
Example 5
Source File: DebugCommand.java From civcraft with GNU General Public License v2.0 | 5 votes |
public void setspeed_cmd() throws CivException { Player player = getPlayer(); if (args.length < 2) { throw new CivException("Enter a speed."); } player.setWalkSpeed(Float.valueOf(args[1])); CivMessage.sendSuccess(player, "speed changed"); }
Example 6
Source File: Players.java From CardinalPGM with MIT License | 5 votes |
public static void resetPlayer(Player player, boolean heal) { if (heal) player.setHealth(player.getMaxHealth()); player.setFoodLevel(20); player.setSaturation(20); player.getInventory().clear(); player.getInventory().setArmorContents(new ItemStack[]{new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR), new ItemStack(Material.AIR)}); for (PotionEffect effect : player.getActivePotionEffects()) { try { player.removePotionEffect(effect.getType()); } catch (NullPointerException ignored) { } } player.setTotalExperience(0); player.setExp(0); player.setLevel(0); player.setPotionParticles(false); player.setWalkSpeed(0.2F); player.setFlySpeed(0.1F); player.setKnockbackReduction(0); player.setArrowsStuck(0); player.hideTitle(); player.setFastNaturalRegeneration(false); for (Attribute attribute : Attribute.values()) { if (player.getAttribute(attribute) == null) continue; for (AttributeModifier modifier : player.getAttribute(attribute).getModifiers()) { player.getAttribute(attribute).removeModifier(modifier); } } player.getAttribute(Attribute.GENERIC_ATTACK_SPEED).addModifier(new AttributeModifier(UUID.randomUUID(), "generic.attackSpeed", 4.001D, AttributeModifier.Operation.ADD_SCALAR)); player.getAttribute(Attribute.ARROW_ACCURACY).addModifier(new AttributeModifier(UUID.randomUUID(), "sportbukkit.arrowAccuracy", -1D, AttributeModifier.Operation.ADD_NUMBER)); player.getAttribute(Attribute.ARROW_VELOCITY_TRANSFER).addModifier(new AttributeModifier(UUID.randomUUID(), "sportbukkit.arrowVelocityTransfer", -1D, AttributeModifier.Operation.ADD_NUMBER)); }
Example 7
Source File: FlagFreeze.java From HeavySpleef with GNU General Public License v3.0 | 5 votes |
private void freezePlayer(SpleefPlayer player) { task.addFrozenPlayer(player); Player bukkitPlayer = player.getBukkitPlayer(); bukkitPlayer.setWalkSpeed(0F); PotionEffect noJumpEffect = new PotionEffect(PotionEffectType.JUMP, Integer.MAX_VALUE, POTION_AMPLIFIER, true); bukkitPlayer.addPotionEffect(noJumpEffect, true); }
Example 8
Source File: FlagFreeze.java From HeavySpleef with GNU General Public License v3.0 | 5 votes |
private void unfreezePlayer(SpleefPlayer player) { task.removeFrozenPlayer(player); Player bukkitPlayer = player.getBukkitPlayer(); bukkitPlayer.setWalkSpeed(DEFAULT_WALK_SPEED); bukkitPlayer.removePotionEffect(PotionEffectType.JUMP); }
Example 9
Source File: LimboServiceHelper.java From AuthMeReloaded with GNU General Public License v3.0 | 5 votes |
/** * Removes the data that is saved in a LimboPlayer from the player. * <p> * Note that teleportation on the player is performed by {@link fr.xephi.authme.service.TeleportationService} and * changing the permission group is handled by {@link fr.xephi.authme.data.limbo.AuthGroupHandler}. * * @param player the player to set defaults to */ void revokeLimboStates(Player player) { player.setOp(false); settings.getProperty(LimboSettings.RESTORE_ALLOW_FLIGHT) .processPlayer(player); if (!settings.getProperty(RestrictionSettings.ALLOW_UNAUTHED_MOVEMENT)) { player.setFlySpeed(0.0f); player.setWalkSpeed(0.0f); } }
Example 10
Source File: MatchPlayerImpl.java From PGM with GNU Affero General Public License v3.0 | 4 votes |
@Override public void reset() { getMatch().callEvent(new PlayerResetEvent(this)); setFrozen(false); Player bukkit = getBukkit(); bukkit.closeInventory(); resetInventory(); bukkit.setArrowsStuck(0); bukkit.setExhaustion(0); bukkit.setFallDistance(0); bukkit.setFireTicks(0); bukkit.setFoodLevel(20); // full bukkit.setHealth(bukkit.getMaxHealth()); bukkit.setLevel(0); bukkit.setExp(0); // clear xp bukkit.setSaturation(5); // default bukkit.setAllowFlight(false); bukkit.setFlying(false); bukkit.setSneaking(false); bukkit.setSprinting(false); bukkit.setFlySpeed(0.1f); bukkit.setKnockbackReduction(0); bukkit.setWalkSpeed(WalkSpeedKit.BUKKIT_DEFAULT); for (PotionEffect effect : bukkit.getActivePotionEffects()) { if (effect.getType() != null) { bukkit.removePotionEffect(effect.getType()); } } for (Attribute attribute : ATTRIBUTES) { AttributeInstance attributes = bukkit.getAttribute(attribute); if (attributes == null) continue; for (AttributeModifier modifier : attributes.getModifiers()) { attributes.removeModifier(modifier); } } NMSHacks.setAbsorption(bukkit, 0); // we only reset bed spawn here so people don't have to see annoying messages when they respawn bukkit.setBedSpawnLocation(null); }
Example 11
Source File: Players.java From helper with MIT License | 4 votes |
public static void resetWalkSpeed(Player player) { player.setWalkSpeed(0.2f); }
Example 12
Source File: PlayerListener.java From civcraft with GNU General Public License v2.0 | 4 votes |
private void setModifiedMovementSpeed(Player player) { /* Change move speed based on armor. */ double speed = CivSettings.normal_speed; /* Set speed from armor. */ if (Unit.isWearingFullComposite(player)) { speed *= CivSettings.T4_leather_speed; } if (Unit.isWearingFullHardened(player)) { speed *= CivSettings.T3_leather_speed; } if (Unit.isWearingFullRefined(player)) { speed *= CivSettings.T2_leather_speed; } if (Unit.isWearingFullBasicLeather(player)) { speed *= CivSettings.T1_leather_speed; } if (Unit.isWearingAnyIron(player)) { speed *= CivSettings.T1_metal_speed; } if (Unit.isWearingAnyChain(player)) { speed *= CivSettings.T2_metal_speed; } if (Unit.isWearingAnyGold(player)) { speed *= CivSettings.T3_metal_speed; } if (Unit.isWearingAnyDiamond(player)) { speed *= CivSettings.T4_metal_speed; } Resident resident = CivGlobal.getResident(player); if (resident != null && resident.isOnRoad()) { if (player.getVehicle() != null && player.getVehicle().getType().equals(EntityType.HORSE)) { Vector vec = player.getVehicle().getVelocity(); double yComp = vec.getY(); vec.multiply(Road.ROAD_HORSE_SPEED); vec.setY(yComp); /* Do not multiply y velocity. */ player.getVehicle().setVelocity(vec); } else { speed *= Road.ROAD_PLAYER_SPEED; } } player.setWalkSpeed((float) Math.min(1.0f, speed)); }
Example 13
Source File: WalkSpeedKit.java From CardinalPGM with MIT License | 4 votes |
@Override public void apply(Player player, Boolean force) { player.setWalkSpeed(walkSpeed); }
Example 14
Source File: WalkSpeedKit.java From CardinalPGM with MIT License | 4 votes |
@Override public void remove(Player player) { player.setWalkSpeed(0.2f); }