Search in sources :

Example 1 with FlyUserDataModule

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();
}
Also used : FlyUserDataModule(io.github.nucleuspowered.nucleus.modules.fly.datamodules.FlyUserDataModule)

Aggregations

FlyUserDataModule (io.github.nucleuspowered.nucleus.modules.fly.datamodules.FlyUserDataModule)1