Search in sources :

Example 81 with PartyPlayerEntity

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

the class CommandSetHome method onCommand.

@Override
public void onCommand(CommandData commandData) {
    PartyPlayerEntity pp = commandData.getPartyPlayer();
    PartyEntity party = commandData.getParty();
    /*
		 * Command handling
		 */
    boolean isRemove = false;
    Location home = null;
    if (commandData.getArgs().length > 1 && commandData.getArgs()[1].equalsIgnoreCase(ConfigMain.COMMANDS_SUB_REMOVE)) {
        // Remove command
        isRemove = true;
    } else {
        // Normal command
        if (VaultHandler.payCommand(VaultHandler.VaultCommand.SETHOME, pp, commandData.getCommandLabel(), commandData.getArgs()))
            return;
        home = commandData.getPlayer().getLocation();
    }
    /*
		 * Command starts
		 */
    party.setHome(home);
    party.updateParty();
    if (isRemove) {
        pp.sendMessage(Messages.ADDCMD_SETHOME_REMOVED);
        LoggerManager.log(LogLevel.MEDIUM, Constants.DEBUG_CMD_SETHOME_REM.replace("{player}", pp.getName()).replace("{party}", party.getName()), true);
    } else {
        pp.sendMessage(Messages.ADDCMD_SETHOME_CHANGED);
        party.sendBroadcast(pp, Messages.ADDCMD_SETHOME_BROADCAST);
        LoggerManager.log(LogLevel.MEDIUM, Constants.DEBUG_CMD_SETHOME.replace("{player}", pp.getName()).replace("{party}", party.getName()), true);
    }
}
Also used : PartyPlayerEntity(com.alessiodp.parties.players.objects.PartyPlayerEntity) PartyEntity(com.alessiodp.parties.parties.objects.PartyEntity) Location(org.bukkit.Location)

Example 82 with PartyPlayerEntity

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

the class CommandSuffix method onCommand.

@Override
public void onCommand(CommandData commandData) {
    PartyPlayerEntity pp = commandData.getPartyPlayer();
    PartyEntity party = commandData.getParty();
    /*
		 * Command handling
		 */
    boolean isRemove = false;
    String prefix = "";
    if (commandData.getArgs()[1].equalsIgnoreCase(ConfigMain.COMMANDS_SUB_REMOVE)) {
        // Remove command
        isRemove = true;
    } else {
        // Normal command
        StringBuilder sb = new StringBuilder();
        for (int word = 1; word < commandData.getArgs().length; word++) {
            if (sb.length() > 0)
                sb.append(" ");
            sb.append(commandData.getArgs()[word]);
        }
        if (!Pattern.compile(ConfigMain.ADDITIONAL_TAG_CUSTOM_ALLOWEDCHARS).matcher(sb.toString()).matches() || (sb.toString().length() > ConfigMain.ADDITIONAL_TAG_CUSTOM_MAXLENGTH) || (sb.toString().length() < ConfigMain.ADDITIONAL_TAG_CUSTOM_MINLENGTH)) {
            pp.sendMessage(Messages.ADDCMD_SUFFIX_INVALID);
            return;
        }
        if (PartiesUtils.checkCensor(sb.toString())) {
            pp.sendMessage(Messages.ADDCMD_SUFFIX_CENSORED);
            return;
        }
        if (VaultHandler.payCommand(VaultHandler.VaultCommand.SUFFIX, pp, commandData.getCommandLabel(), commandData.getArgs()))
            return;
        prefix = sb.toString();
    }
    /*
		 * Command starts
		 */
    party.setSuffix(prefix);
    party.updateParty();
    if (isRemove) {
        pp.sendMessage(Messages.ADDCMD_SUFFIX_REMOVED);
        LoggerManager.log(LogLevel.MEDIUM, Constants.DEBUG_CMD_SUFFIX_REM.replace("{player}", pp.getName()).replace("{party}", party.getName()), true);
    } else {
        pp.sendMessage(Messages.ADDCMD_SUFFIX_CHANGED);
        party.sendBroadcast(pp, Messages.ADDCMD_SUFFIX_BROADCAST);
        LoggerManager.log(LogLevel.MEDIUM, Constants.DEBUG_CMD_SUFFIX.replace("{player}", pp.getName()).replace("{party}", party.getName()), true);
    }
}
Also used : PartyPlayerEntity(com.alessiodp.parties.players.objects.PartyPlayerEntity) PartyEntity(com.alessiodp.parties.parties.objects.PartyEntity)

Example 83 with PartyPlayerEntity

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

the class CommandClaim 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.CLAIM.toString())) {
        pp.sendNoPermission(PartiesPermission.CLAIM);
        ;
        return false;
    }
    PartyEntity party = pp.getPartyName().isEmpty() ? null : plugin.getPartyManager().getParty(pp.getPartyName());
    if (party == null) {
        pp.sendMessage(Messages.PARTIES_COMMON_NOTINPARTY);
        return false;
    }
    if (!PartiesUtils.checkPlayerRankAlerter(pp, PartiesPermission.PRIVATE_CLAIM))
        return false;
    commandData.setPlayer(player);
    commandData.setPartyPlayer(pp);
    commandData.setParty(party);
    return true;
}
Also used : Player(org.bukkit.entity.Player) PartyPlayerEntity(com.alessiodp.parties.players.objects.PartyPlayerEntity) PartyEntity(com.alessiodp.parties.parties.objects.PartyEntity)

Example 84 with PartyPlayerEntity

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

the class CommandColor 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.COLOR.toString())) {
        pp.sendNoPermission(PartiesPermission.COLOR);
        return false;
    }
    PartyEntity party = pp.getPartyName().isEmpty() ? null : plugin.getPartyManager().getParty(pp.getPartyName());
    if (party == null) {
        pp.sendMessage(Messages.PARTIES_COMMON_NOTINPARTY);
        return false;
    }
    if (!PartiesUtils.checkPlayerRankAlerter(pp, PartiesPermission.PRIVATE_EDIT_COLOR))
        return false;
    if (commandData.getArgs().length > 2) {
        pp.sendMessage(Messages.ADDCMD_COLOR_WRONGCMD);
        return false;
    }
    commandData.setPlayer(player);
    commandData.setPartyPlayer(pp);
    commandData.setParty(party);
    return true;
}
Also used : Player(org.bukkit.entity.Player) PartyPlayerEntity(com.alessiodp.parties.players.objects.PartyPlayerEntity) PartyEntity(com.alessiodp.parties.parties.objects.PartyEntity)

Example 85 with PartyPlayerEntity

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

the class CommandColor method onCommand.

@Override
public void onCommand(CommandData commandData) {
    PartyPlayerEntity pp = commandData.getPartyPlayer();
    PartyEntity party = commandData.getParty();
    /*
		 * Command handling
		 */
    if (commandData.getArgs().length == 1) {
        // Automatically pp.sendMessage put color placeholders
        if (party.getColor() != null)
            pp.sendMessage(Messages.ADDCMD_COLOR_INFO);
        else
            pp.sendMessage(Messages.ADDCMD_COLOR_EMPTY);
        return;
    }
    boolean isRemove = false;
    Color color = null;
    if (commandData.getArgs()[1].equalsIgnoreCase(ConfigMain.COMMANDS_SUB_REMOVE)) {
        // Remove command
        isRemove = true;
    } else {
        // Normal command
        color = plugin.getColorManager().searchColorByCommand(commandData.getArgs()[1]);
        if (color == null) {
            // Color doesn't exist
            pp.sendMessage(Messages.ADDCMD_COLOR_WRONGCOLOR);
            return;
        }
        if (VaultHandler.payCommand(VaultHandler.VaultCommand.COLOR, pp, commandData.getCommandLabel(), commandData.getArgs()))
            return;
    }
    /*
		 * Command starts
		 */
    party.setColor(color);
    party.updateParty();
    party.callChange();
    if (isRemove) {
        pp.sendMessage(Messages.ADDCMD_COLOR_REMOVED);
        LoggerManager.log(LogLevel.MEDIUM, Constants.DEBUG_CMD_COLOR_REM.replace("{player}", pp.getName()).replace("{party}", party.getName()), true);
    } else {
        pp.sendMessage(Messages.ADDCMD_COLOR_CHANGED, party);
        party.sendBroadcast(pp, Messages.ADDCMD_COLOR_BROADCAST);
        LoggerManager.log(LogLevel.MEDIUM, Constants.DEBUG_CMD_COLOR.replace("{player}", pp.getName()).replace("{party}", party.getName()).replace("{value}", color.getName()), true);
    }
}
Also used : PartyPlayerEntity(com.alessiodp.parties.players.objects.PartyPlayerEntity) Color(com.alessiodp.partiesapi.interfaces.Color) PartyEntity(com.alessiodp.parties.parties.objects.PartyEntity)

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