use of org.lanternpowered.server.world.difficulty.LanternDifficulty in project LanternServer by LanternPowered.
the class LanternWorldProperties method setDifficulty.
@Override
public void setDifficulty(Difficulty difficulty) {
checkNotNull(difficulty, "difficulty");
if (this.getDifficulty() != difficulty && this.world != null) {
this.world.broadcast(() -> new MessagePlayOutSetDifficulty((LanternDifficulty) difficulty));
}
this.worldConfig.setDifficulty(difficulty);
}
use of org.lanternpowered.server.world.difficulty.LanternDifficulty in project LanternServer by LanternPowered.
the class DifficultyRegistryModule method registerDefaults.
@Override
public void registerDefaults() {
register(new LanternDifficulty("minecraft", "peaceful", 0));
register(new LanternDifficulty("minecraft", "easy", 1));
register(new LanternDifficulty("minecraft", "normal", 2));
register(new LanternDifficulty("minecraft", "hard", 3));
}
use of org.lanternpowered.server.world.difficulty.LanternDifficulty in project LanternServer by LanternPowered.
the class CommandDifficulty method completeSpec.
@Override
public void completeSpec(PluginContainer pluginContainer, CommandSpec.Builder specBuilder) {
final ImmutableMap.Builder<String, Object> baseBuilder = ImmutableMap.builder();
final ImmutableMap.Builder<String, Object> aliasesBuilder = ImmutableMap.builder();
for (Difficulty difficulty : Sponge.getRegistry().getAllOf(Difficulty.class)) {
baseBuilder.put(difficulty.getName(), difficulty);
aliasesBuilder.put(difficulty.getName().substring(0, 1), difficulty);
aliasesBuilder.put(((LanternDifficulty) difficulty).getInternalId() + "", difficulty);
}
specBuilder.arguments(GenericArguments.flags().valueFlag(GenericArguments.world(CommandHelper.WORLD_KEY), "-world", "w").buildWith(GenericArguments.none()), ChoicesElement.of(Text.of("difficulty"), baseBuilder.build(), aliasesBuilder.build(), false, true)).executor((src, args) -> {
WorldProperties world = CommandHelper.getWorldProperties(src, args);
Difficulty difficulty = args.<Difficulty>getOne("difficulty").get();
world.setDifficulty(difficulty);
src.sendMessage(t("commands.difficulty.success", difficulty.getName()));
return CommandResult.success();
});
}
Aggregations