use of io.github.nucleuspowered.nucleus.modules.powertool.datamodules.PowertoolUserDataModule in project Nucleus by NucleusPowered.
the class TogglePowertoolCommand method executeCommand.
@Override
public CommandResult executeCommand(Player src, CommandContext args) throws Exception {
PowertoolUserDataModule user = Nucleus.getNucleus().getUserDataManager().getUnchecked(src).get(PowertoolUserDataModule.class);
// If specified - get the key. Else, the inverse of what we have now.
boolean toggle = args.<Boolean>getOne(toggleKey).orElse(!user.isPowertoolToggled());
user.setPowertoolToggle(toggle);
MessageProvider mp = plugin.getMessageProvider();
src.sendMessage(mp.getTextMessageWithFormat("command.powertool.toggle", mp.getMessageWithFormat(toggle ? "standard.enabled" : "standard.disabled")));
return CommandResult.success();
}
Aggregations