use of io.github.nucleuspowered.nucleus.modules.fly.datamodules.FlyUserDataModule in project Nucleus by NucleusPowered.
the class FlyCommand method executeWithPlayer.
@Override
protected CommandResult executeWithPlayer(CommandSource src, Player pl, CommandContext args, boolean isSelf) throws Exception {
FlyUserDataModule uc = Nucleus.getNucleus().getUserDataManager().getUnchecked(pl).get(FlyUserDataModule.class);
boolean fly = args.<Boolean>getOne(toggle).orElse(!pl.get(Keys.CAN_FLY).orElse(false));
if (!setFlying(pl, fly)) {
src.sendMessages(plugin.getMessageProvider().getTextMessageWithFormat("command.fly.error"));
return CommandResult.empty();
}
uc.setFlying(fly);
if (pl != src) {
src.sendMessages(plugin.getMessageProvider().getTextMessageWithFormat(fly ? "command.fly.player.on" : "command.fly.player.off", pl.getName()));
}
pl.sendMessage(plugin.getMessageProvider().getTextMessageWithFormat(fly ? "command.fly.on" : "command.fly.off"));
return CommandResult.success();
}
Aggregations