use of com.skelril.skree.service.internal.pvp.PvPState in project Skree by Skelril.
the class PvPCommand method execute.
@Override
public CommandResult execute(CommandSource src, CommandContext args) throws CommandException {
if (!(src instanceof Player)) {
src.sendMessage(Text.of("You must be a player to use this command!"));
return CommandResult.empty();
}
Optional<PvPService> optService = Sponge.getServiceManager().provide(PvPService.class);
if (!optService.isPresent()) {
src.sendMessage(Text.of(TextColors.DARK_RED, "The PvP service is not currently running."));
return CommandResult.empty();
}
PvPService service = optService.get();
Player player = (Player) src;
Optional<PvPState> stateArg = args.getOne("status");
PvPState state = stateArg.orElse(service.getPvPState(player));
service.setPvPState(player, state);
player.sendMessage(Text.of(TextColors.BLUE, "Your Opt-in PvP Settings", (stateArg.isPresent() ? " Changed!" : "")));
player.sendMessage(Text.of(TextColors.YELLOW, " Currently: ", getColor(state), state.toString()));
PvPState defaultState = service.getDefaultState(player);
player.sendMessage(Text.of(TextColors.YELLOW, " Upon disconnect: ", getColor(defaultState), defaultState.toString()));
return CommandResult.success();
}
Aggregations