Allow user to configure speed as a decimal value
@@ -74,7 +74,7 @@ public class SpeedCommand implements ICommandExecutor, IReloadableService.Reload
GenericArguments.optionalWeak(GenericArguments.onlyOne(GenericArguments.choices(Text.of(this.typeKey), keysMap, true))),
GenericArguments.optional(
GenericArguments.firstParsing(
- GenericArguments.integer(Text.of(this.speedKey)),
+ GenericArguments.doubleNum(Text.of(this.speedKey)),
GenericArguments.literal(Text.of(this.resetKey), this.resetKey)
)
)
@@ -86,9 +86,9 @@ public class SpeedCommand implements ICommandExecutor, IReloadableService.Reload
final Player pl = context.getPlayerFromArgs();
final SpeedType key = context.getOne(this.typeKey, SpeedType.class)
.orElseGet(() -> pl.get(Keys.IS_FLYING).orElse(false) ? SpeedType.FLYING : SpeedType.WALKING);
- final Integer speed = context.getOne(this.speedKey, Integer.class).orElseGet(() -> {
+ final Double speed = context.getOne(this.speedKey, Double.class).orElseGet(() -> {
if (context.hasAny(this.resetKey)) {
- return key == SpeedType.WALKING ? 2 : 1;
+ return key == SpeedType.WALKING ? 2.0d : 1.0d;
}
return null;
@@ -96,10 +96,10 @@ public class SpeedCommand implements ICommandExecutor, IReloadableService.Reload
if (speed == null) {
final TextComponent t = Text.builder().append(context.getMessage("command.speed.walk")).append(Text.of(" "))
- .append(Text.of(TextColors.YELLOW, Math.round(pl.get(Keys.WALKING_SPEED).orElse(0.1d) * 20)))
+ .append(Text.of(TextColors.YELLOW, Math.round(pl.get(Keys.WALKING_SPEED).orElse(0.1d) * SpeedCommand.multiplier)))
.append(Text.builder().append(Text.of(TextColors.GREEN, ", "))
.append(context.getMessage("command.speed.flying")).build())
- .append(Text.of(" ")).append(Text.of(TextColors.YELLOW, Math.round(pl.get(Keys.FLYING_SPEED).orElse(0.05d) * 20)))
+ .append(Text.of(" ")).append(Text.of(TextColors.YELLOW, pl.get(Keys.FLYING_SPEED).orElse(0.05d) * multiplier))
.append(Text.of(TextColors.GREEN, ".")).build();
context.sendMessageText(t);
@@ -116,7 +116,7 @@ public class SpeedCommand implements ICommandExecutor, IReloadableService.Reload
return context.errorResult("command.speed.max", String.valueOf(this.maxSpeed));
}
- final DataTransactionResult dtr = pl.offer(key.speedKey, (double) speed / (double) multiplier);
+ final DataTransactionResult dtr = pl.offer(key.speedKey, speed / (double) multiplier);
if (dtr.isSuccessful()) {
context.sendMessage("command.speed.success.base", key.name, String.valueOf(speed));
