Transform values into constants

(cherry picked from commit 20d83e5 et al.)
This commit is contained in:
Maxetto 2017-02-27 19:50:30 +01:00 committed by ljacqu
parent bf3d6b0e7c
commit 41b6c34b6b
4 changed files with 9 additions and 6 deletions

View File

@ -80,10 +80,10 @@ public class LimboCache {
float flySpeed = data.getFlySpeed();
// Reset the speed value if it was 0
if (walkSpeed < 0.01f) {
walkSpeed = 0.2f;
walkSpeed = LimboPlayer.DEFAULT_WALK_SPEED;
}
if (flySpeed < 0.01f) {
flySpeed = 0.2f;
flySpeed = LimboPlayer.DEFAULT_FLY_SPEED;
}
player.setWalkSpeed(walkSpeed);
player.setFlySpeed(flySpeed);

View File

@ -10,6 +10,9 @@ import org.bukkit.scheduler.BukkitTask;
*/
public class LimboPlayer {
public static final float DEFAULT_WALK_SPEED = 0.2f;
public static final float DEFAULT_FLY_SPEED = 0.1f;
private final boolean canFly;
private final boolean operator;
private final String group;

View File

@ -148,8 +148,8 @@ public class LimboPlayerStorage {
String group = "";
boolean operator = false;
boolean canFly = false;
float walkSpeed = 0.2f;
float flySpeed = 0.2f;
float walkSpeed = LimboPlayer.DEFAULT_WALK_SPEED;
float flySpeed = LimboPlayer.DEFAULT_FLY_SPEED;
JsonElement e;
if ((e = jsonObject.getAsJsonObject("location")) != null) {

View File

@ -143,8 +143,8 @@ public class LimboCacheTest {
limboCache.restoreData(player);
// then
verify(player).setWalkSpeed(0.2f);
verify(player).setFlySpeed(0.2f);
verify(player).setWalkSpeed(LimboPlayer.DEFAULT_WALK_SPEED);
verify(player).setFlySpeed(LimboPlayer.DEFAULT_FLY_SPEED);
}
@Test