Search in sources :

Example 1 with Result

use of com.alessiodp.parties.addons.external.GriefPreventionHandler.Result in project Parties by AlessioDP.

the class CommandClaim method onCommand.

@Override
public void onCommand(CommandData commandData) {
    PartyPlayerEntity pp = commandData.getPartyPlayer();
    PartyEntity party = commandData.getParty();
    /*
		 * Command handling
		 */
    if (commandData.getArgs().length != 2) {
        pp.sendMessage(Messages.ADDCMD_CLAIM_WRONGCMD);
        return;
    }
    Selection selection = Selection.FAILED_GENERAL;
    if (commandData.getArgs()[1].equalsIgnoreCase(ConfigMain.ADDONS_GRIEFPREVENTION_CMD_TRUST))
        selection = Selection.TRUST;
    else if (commandData.getArgs()[1].equalsIgnoreCase(ConfigMain.ADDONS_GRIEFPREVENTION_CMD_CONTAINER))
        selection = Selection.CONTAINER;
    else if (commandData.getArgs()[1].equalsIgnoreCase(ConfigMain.ADDONS_GRIEFPREVENTION_CMD_ACCESS))
        selection = Selection.ACCESS;
    else if (commandData.getArgs()[1].equalsIgnoreCase(ConfigMain.ADDONS_GRIEFPREVENTION_CMD_REMOVE))
        selection = Selection.REMOVE;
    if (!selection.equals(Selection.FAILED_GENERAL)) {
        Result res = GriefPreventionHandler.isManager(commandData.getPlayer());
        switch(res) {
            case NOEXIST:
                selection = Selection.FAILED_NOEXIST;
                break;
            case NOMANAGER:
                selection = Selection.FAILED_NOMANAGER;
                break;
            default:
                // Success, selection it's okay
                break;
        }
    }
    if (VaultHandler.payCommand(VaultHandler.VaultCommand.CLAIM, pp, commandData.getCommandLabel(), commandData.getArgs()))
        return;
    /*
		 * Command starts
		 */
    switch(selection) {
        case FAILED_NOEXIST:
            // Return: No exist claim
            pp.sendMessage(Messages.ADDCMD_CLAIM_CLAIMNOEXISTS);
            break;
        case FAILED_NOMANAGER:
            // Return: No manager
            pp.sendMessage(Messages.ADDCMD_CLAIM_NOMANAGER);
            break;
        case FAILED_GENERAL:
            // Return: Wrong command
            pp.sendMessage(Messages.ADDCMD_CLAIM_WRONGCMD);
            break;
        default:
            GriefPreventionHandler.addPartyPermission(commandData.getPlayer(), party, selection.getGPPermission());
            pp.sendMessage(Messages.ADDCMD_CLAIM_CLAIMED);
            LoggerManager.log(LogLevel.MEDIUM, Constants.DEBUG_CMD_CLAIM.replace("{player}", pp.getName()).replace("{value}", commandData.getArgs()[1].toLowerCase()), true);
    }
}
Also used : PartyPlayerEntity(com.alessiodp.parties.players.objects.PartyPlayerEntity) PartyEntity(com.alessiodp.parties.parties.objects.PartyEntity) Result(com.alessiodp.parties.addons.external.GriefPreventionHandler.Result)

Aggregations

Result (com.alessiodp.parties.addons.external.GriefPreventionHandler.Result)1 PartyEntity (com.alessiodp.parties.parties.objects.PartyEntity)1 PartyPlayerEntity (com.alessiodp.parties.players.objects.PartyPlayerEntity)1