use of io.github.nucleuspowered.nucleus.modules.environment.datamodule.EnvironmentWorldDataModule in project Nucleus by NucleusPowered.
the class LockWeatherCommand method executeCommand.
@Override
public CommandResult executeCommand(CommandSource src, CommandContext args) throws Exception {
Optional<WorldProperties> world = getWorldProperties(src, worldKey, args);
if (!world.isPresent()) {
src.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.specifyworld"));
return CommandResult.empty();
}
WorldProperties wp = world.get();
Optional<ModularWorldService> ws = loader.getWorld(wp.getUniqueId());
if (!ws.isPresent()) {
src.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.noworld", wp.getWorldName()));
return CommandResult.empty();
}
EnvironmentWorldDataModule environmentWorldDataModule = ws.get().get(EnvironmentWorldDataModule.class);
boolean toggle = args.<Boolean>getOne(toggleKey).orElse(!environmentWorldDataModule.isLockWeather());
environmentWorldDataModule.setLockWeather(toggle);
ws.get().set(environmentWorldDataModule);
if (toggle) {
src.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.lockweather.locked", wp.getWorldName()));
} else {
src.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat("command.lockweather.unlocked", wp.getWorldName()));
}
return CommandResult.success();
}
Aggregations