geforkt von Mirrors/Paper
Implement player speed API. Addresses BUKKIT-2205
Dieser Commit ist enthalten in:
Ursprung
77cda7e715
Commit
342f9c3bd3
@ -7,8 +7,8 @@ public class PlayerAbilities {
|
|||||||
public boolean canFly = false;
|
public boolean canFly = false;
|
||||||
public boolean canInstantlyBuild = false;
|
public boolean canInstantlyBuild = false;
|
||||||
public boolean mayBuild = true;
|
public boolean mayBuild = true;
|
||||||
private float flySpeed = 0.05F;
|
public float flySpeed = 0.05F; // CraftBukkit private -> public
|
||||||
private float walkSpeed = 0.1F;
|
public float walkSpeed = 0.1F; // CraftBukkit private -> public
|
||||||
|
|
||||||
public PlayerAbilities() {}
|
public PlayerAbilities() {}
|
||||||
|
|
||||||
|
@ -864,4 +864,39 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
|
|||||||
return getHandle().noDamageTicks;
|
return getHandle().noDamageTicks;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setFlySpeed(float value) {
|
||||||
|
validateSpeed(value);
|
||||||
|
EntityPlayer player = getHandle();
|
||||||
|
player.abilities.flySpeed = value / 2f;
|
||||||
|
player.updateAbilities();
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setWalkSpeed(float value) {
|
||||||
|
validateSpeed(value);
|
||||||
|
EntityPlayer player = getHandle();
|
||||||
|
player.abilities.walkSpeed = value / 2f;
|
||||||
|
player.updateAbilities();
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getFlySpeed() {
|
||||||
|
return getHandle().abilities.flySpeed * 2f;
|
||||||
|
}
|
||||||
|
|
||||||
|
public float getWalkSpeed() {
|
||||||
|
return getHandle().abilities.walkSpeed * 2f;
|
||||||
|
}
|
||||||
|
|
||||||
|
private void validateSpeed(float value) {
|
||||||
|
if (value < 0) {
|
||||||
|
if (value < -1f) {
|
||||||
|
throw new IllegalArgumentException(value + " is too low");
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (value > 1f) {
|
||||||
|
throw new IllegalArgumentException(value + " is too high");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren