Search in sources :

Example 1 with PvPState

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();
}
Also used : Player(org.spongepowered.api.entity.living.player.Player) PvPService(com.skelril.skree.service.PvPService) PvPState(com.skelril.skree.service.internal.pvp.PvPState)

Aggregations

PvPService (com.skelril.skree.service.PvPService)1 PvPState (com.skelril.skree.service.internal.pvp.PvPState)1 Player (org.spongepowered.api.entity.living.player.Player)1