Search in sources :

Example 26 with PartyEntity

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

the class CommandSetHome 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.SETHOME.toString())) {
        pp.sendNoPermission(PartiesPermission.SETHOME);
        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_HOME))
        return false;
    if (commandData.getArgs().length > 1 && !commandData.getArgs()[1].equalsIgnoreCase(ConfigMain.COMMANDS_SUB_REMOVE)) {
        pp.sendMessage(Messages.ADDCMD_SETHOME_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 27 with PartyEntity

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

the class CommandSuffix 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.SUFFIX.toString())) {
        pp.sendNoPermission(PartiesPermission.SUFFIX);
        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_SUFFIX))
        return false;
    if (commandData.getArgs().length < 2) {
        pp.sendMessage(Messages.ADDCMD_SUFFIX_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 28 with PartyEntity

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

the class PartyManager method reload.

public void reload() {
    listParties = new HashMap<String, PartyEntity>();
    listPartiesToDelete = new HashMap<String, Integer>();
    if (ConfigParties.FIXED_ENABLE) {
        List<Party> lst = plugin.getDatabaseManager().getAllFixed().join();
        for (Party party : lst) {
            LoggerManager.log(LogLevel.DEBUG, Constants.DEBUG_PARTY_FIXED_LOAD.replace("{party}", party.getName()), true);
            loadParty(party.getName());
        }
    }
}
Also used : Party(com.alessiodp.partiesapi.objects.Party) PartyEntity(com.alessiodp.parties.parties.objects.PartyEntity)

Example 29 with PartyEntity

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

the class PartyManager method getParty.

public PartyEntity getParty(String name) {
    // Just get the party without save it into the party list
    PartyEntity ret = null;
    if (name != null && !name.isEmpty()) {
        ret = getListParties().get(name.toLowerCase());
        if (ret == null) {
            Party p = plugin.getDatabaseManager().getParty(name).join();
            if (p != null) {
                ret = new PartyEntity(p, plugin);
                LoggerManager.log(LogLevel.DEBUG, Constants.DEBUG_PARTY_GET_DATABASE.replace("{party}", ret.getName()), true);
            }
        } else
            LoggerManager.log(LogLevel.DEBUG, Constants.DEBUG_PARTY_GET_LIST.replace("{party}", ret.getName()), true);
    }
    if (ret != null) {
        plugin.getColorManager().loadDynamicColor(ret);
        ret.refreshPlayers();
    }
    return ret;
}
Also used : Party(com.alessiodp.partiesapi.objects.Party) PartyEntity(com.alessiodp.parties.parties.objects.PartyEntity)

Example 30 with PartyEntity

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

the class EssentialsChatHandler method onChatPlayer.

@EventHandler
public void onChatPlayer(AsyncPlayerChatEvent event) {
    String old = event.getFormat();
    if (old.toLowerCase().contains("{parties_")) {
        // Bypass useless checks if parties doesn't exist
        boolean somethingChanged = false;
        PartyPlayerEntity pp = plugin.getPlayerManager().getPlayer(event.getPlayer().getUniqueId());
        PartyEntity party = plugin.getPartyManager().getParty(pp.getPartyName());
        Pattern pat = Pattern.compile("\\{parties_([a-z\\_]+)\\}", Pattern.CASE_INSENSITIVE);
        Matcher mat = pat.matcher(old);
        while (mat.find()) {
            String base = mat.group(0);
            String identifier = mat.group(1);
            if (identifier != null) {
                PartiesPlaceholder ph = PartiesPlaceholder.getPlaceholder(identifier);
                if (ph != null) {
                    old = old.replace(base, ph.formatPlaceholder(pp, party));
                    somethingChanged = true;
                }
            }
        }
        if (somethingChanged)
            event.setFormat(old);
    }
}
Also used : Pattern(java.util.regex.Pattern) PartyPlayerEntity(com.alessiodp.parties.players.objects.PartyPlayerEntity) PartiesPlaceholder(com.alessiodp.parties.addons.internal.PartiesPlaceholder) Matcher(java.util.regex.Matcher) PartyEntity(com.alessiodp.parties.parties.objects.PartyEntity) EventHandler(org.bukkit.event.EventHandler)

Aggregations

PartyEntity (com.alessiodp.parties.parties.objects.PartyEntity)67 PartyPlayerEntity (com.alessiodp.parties.players.objects.PartyPlayerEntity)56 Player (org.bukkit.entity.Player)31 EventHandler (org.bukkit.event.EventHandler)11 PartyPlayer (com.alessiodp.partiesapi.objects.PartyPlayer)6 Status (com.alessiodp.partiesapi.enums.Status)5 PartiesPartyPostDeleteEvent (com.alessiodp.partiesapi.events.PartiesPartyPostDeleteEvent)5 PartiesPartyPreDeleteEvent (com.alessiodp.partiesapi.events.PartiesPartyPreDeleteEvent)5 UUID (java.util.UUID)5 PartiesPlayerLeaveEvent (com.alessiodp.partiesapi.events.PartiesPlayerLeaveEvent)3 Party (com.alessiodp.partiesapi.objects.Party)3 ArrayList (java.util.ArrayList)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 Rank (com.alessiodp.partiesapi.interfaces.Rank)2 Matcher (java.util.regex.Matcher)2 OfflinePlayer (org.bukkit.OfflinePlayer)2 Result (com.alessiodp.parties.addons.external.GriefPreventionHandler.Result)1