Search in sources :

Example 21 with PartyPlayerEntity

use of com.alessiodp.parties.players.objects.PartyPlayerEntity 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)

Example 22 with PartyPlayerEntity

use of com.alessiodp.parties.players.objects.PartyPlayerEntity in project Parties by AlessioDP.

the class CommandChat method preRequisites.

@Override
public boolean preRequisites(CommandData commandData) {
    Player player = (Player) commandData.getSender();
    PartyPlayerEntity pp = plugin.getPlayerManager().getPlayer(player.getUniqueId());
    /*
		 * Checks for command prerequisites
		 */
    if (!player.hasPermission(PartiesPermission.CHAT.toString())) {
        pp.sendNoPermission(PartiesPermission.CHAT);
        return false;
    }
    if (pp.getPartyName().isEmpty()) {
        pp.sendMessage(Messages.PARTIES_COMMON_NOTINPARTY);
        return false;
    }
    commandData.setPlayer(player);
    commandData.setPartyPlayer(pp);
    return true;
}
Also used : Player(org.bukkit.entity.Player) PartyPlayerEntity(com.alessiodp.parties.players.objects.PartyPlayerEntity)

Example 23 with PartyPlayerEntity

use of com.alessiodp.parties.players.objects.PartyPlayerEntity in project Parties by AlessioDP.

the class CommandChat method onCommand.

@Override
public void onCommand(CommandData commandData) {
    PartyPlayerEntity pp = commandData.getPartyPlayer();
    /*
		 * Command handling
		 */
    Boolean chat = pp.isChatParty();
    if (commandData.getArgs().length > 1) {
        if (commandData.getArgs()[1].equalsIgnoreCase(ConfigMain.COMMANDS_SUB_ON))
            chat = true;
        else if (commandData.getArgs()[1].equalsIgnoreCase(ConfigMain.COMMANDS_SUB_OFF))
            chat = false;
        else
            chat = null;
    } else {
        chat = !chat;
    }
    if (chat == null) {
        pp.sendMessage(Messages.MAINCMD_CHAT_WRONGCMD);
        return;
    }
    /*
		 * Command starts
		 */
    if (chat)
        pp.sendMessage(Messages.MAINCMD_CHAT_ENABLED);
    else
        pp.sendMessage(Messages.MAINCMD_CHAT_DISABLED);
    pp.setChatParty(chat);
    LoggerManager.log(LogLevel.MEDIUM, Constants.DEBUG_CMD_CHAT.replace("{player}", pp.getName()).replace("{value}", chat.toString()), true);
}
Also used : PartyPlayerEntity(com.alessiodp.parties.players.objects.PartyPlayerEntity)

Example 24 with PartyPlayerEntity

use of com.alessiodp.parties.players.objects.PartyPlayerEntity in project Parties by AlessioDP.

the class CommandCreate method preRequisites.

@Override
public boolean preRequisites(CommandData commandData) {
    Player player = (Player) commandData.getSender();
    PartyPlayerEntity pp = plugin.getPlayerManager().getPlayer(player.getUniqueId());
    /*
		 * Checks for command prerequisites
		 */
    if (!player.hasPermission(PartiesPermission.CREATE.toString())) {
        pp.sendNoPermission(PartiesPermission.CREATE);
        return false;
    }
    if (!pp.getPartyName().isEmpty()) {
        pp.sendMessage(Messages.MAINCMD_CREATE_ALREADYINPARTY);
        return false;
    }
    if (commandData.getArgs().length < 2) {
        pp.sendMessage(Messages.MAINCMD_CREATE_WRONGCMD);
        return false;
    }
    commandData.setPlayer(player);
    commandData.setPartyPlayer(pp);
    commandData.addPermission(PartiesPermission.ADMIN_CREATE_FIXED);
    return true;
}
Also used : Player(org.bukkit.entity.Player) PartyPlayerEntity(com.alessiodp.parties.players.objects.PartyPlayerEntity)

Example 25 with PartyPlayerEntity

use of com.alessiodp.parties.players.objects.PartyPlayerEntity in project Parties by AlessioDP.

the class CommandDelete method preRequisites.

@Override
public boolean preRequisites(CommandData commandData) {
    Player player = (Player) commandData.getSender();
    PartyPlayerEntity pp = plugin.getPlayerManager().getPlayer(player.getUniqueId());
    /*
		 * Checks for command prerequisites
		 */
    if (!player.hasPermission(PartiesPermission.ADMIN_DELETE.toString())) {
        pp.sendNoPermission(PartiesPermission.ADMIN_DELETE);
        return false;
    }
    if (commandData.getArgs().length < 2 || commandData.getArgs().length > 3) {
        pp.sendMessage(Messages.MAINCMD_DELETE_WRONGCMD);
        return false;
    }
    commandData.setPlayer(player);
    commandData.setPartyPlayer(pp);
    commandData.addPermission(PartiesPermission.ADMIN_DELETE_SILENT);
    return true;
}
Also used : Player(org.bukkit.entity.Player) PartyPlayerEntity(com.alessiodp.parties.players.objects.PartyPlayerEntity)

Aggregations

PartyPlayerEntity (com.alessiodp.parties.players.objects.PartyPlayerEntity)92 PartyEntity (com.alessiodp.parties.parties.objects.PartyEntity)56 Player (org.bukkit.entity.Player)53 EventHandler (org.bukkit.event.EventHandler)13 PartyPlayer (com.alessiodp.partiesapi.objects.PartyPlayer)9 UUID (java.util.UUID)8 ArrayList (java.util.ArrayList)6 PartiesPartyPostDeleteEvent (com.alessiodp.partiesapi.events.PartiesPartyPostDeleteEvent)4 PartiesPartyPreDeleteEvent (com.alessiodp.partiesapi.events.PartiesPartyPreDeleteEvent)4 OfflinePlayer (org.bukkit.OfflinePlayer)4 Status (com.alessiodp.partiesapi.enums.Status)3 PartiesPlayerLeaveEvent (com.alessiodp.partiesapi.events.PartiesPlayerLeaveEvent)3 PartiesPlaceholder (com.alessiodp.parties.addons.internal.PartiesPlaceholder)2 ChatTask (com.alessiodp.parties.tasks.ChatTask)2 PartiesChatEvent (com.alessiodp.partiesapi.events.PartiesChatEvent)2 PartiesFriendlyFireBlockedEvent (com.alessiodp.partiesapi.events.PartiesFriendlyFireBlockedEvent)2 PartiesPlayerJoinEvent (com.alessiodp.partiesapi.events.PartiesPlayerJoinEvent)2 Rank (com.alessiodp.partiesapi.interfaces.Rank)2 Matcher (java.util.regex.Matcher)2 Result (com.alessiodp.parties.addons.external.GriefPreventionHandler.Result)1