Search in sources :

Example 76 with PartyImpl

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

the class CommonListener method handleBroadcastMessage.

public void handleBroadcastMessage(UUID partyId, UUID playerId, String message) {
    PartyImpl party = plugin.getPartyManager().getParty(partyId);
    if (party != null) {
        try {
            PartyPlayerImpl player = plugin.getPlayerManager().getPlayer(playerId);
            party.broadcastMessage(message, player);
            plugin.getLoggerManager().logDebug(String.format(PartiesConstants.DEBUG_MESSAGING_LISTEN_BROADCAST_MESSAGE, playerId != null ? playerId.toString() : "none", partyId.toString(), message), true);
        } catch (Exception ex) {
            plugin.getLoggerManager().logError(PartiesConstants.DEBUG_MESSAGING_LISTEN_INVITE_PARTY_ERROR, ex);
        }
    }
}
Also used : PartyPlayerImpl(com.alessiodp.parties.common.players.objects.PartyPlayerImpl) PartyImpl(com.alessiodp.parties.common.parties.objects.PartyImpl)

Example 77 with PartyImpl

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

the class PartiesYAMLDispatcher method getListFixed.

@Override
public Set<PartyImpl> getListFixed() {
    Set<PartyImpl> ret = new HashSet<>();
    ConfigurationSection node = database.getYaml().getConfigurationSection("parties");
    for (String key : node.getKeys(false)) {
        if (node.get(key + ".leader") == null) {
            ret.add(getPartyFromNode(node.getConfigurationSection(key)));
        }
    }
    return ret;
}
Also used : PartyImpl(com.alessiodp.parties.common.parties.objects.PartyImpl) HashSet(java.util.HashSet) LinkedHashSet(java.util.LinkedHashSet) ConfigurationSection(com.alessiodp.core.common.addons.external.simpleyaml.configuration.ConfigurationSection)

Example 78 with PartyImpl

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

the class PartiesYAMLDispatcher method getListParties.

@Override
public LinkedHashSet<PartyImpl> getListParties(PartiesDatabaseManager.ListOrder order, int limit, int offset) {
    ConfigurationSection node = database.getYaml().getConfigurationSection("parties");
    LinkedHashSet<PartyImpl> ret = new LinkedHashSet<>();
    List<String> lowerCaseBlacklist = new ArrayList<>();
    for (String b : ConfigParties.ADDITIONAL_LIST_HIDDENPARTIES) lowerCaseBlacklist.add(CommonUtils.toLowerCase(b));
    TreeSet<? extends Pair<String, ?>> entries;
    if (order == PartiesDatabaseManager.ListOrder.NAME)
        entries = listByName(node, lowerCaseBlacklist);
    else if (order == PartiesDatabaseManager.ListOrder.MEMBERS)
        entries = listByMembers(node, lowerCaseBlacklist);
    else if (order == PartiesDatabaseManager.ListOrder.KILLS)
        entries = listByKills(node, lowerCaseBlacklist);
    else if (order == PartiesDatabaseManager.ListOrder.EXPERIENCE)
        entries = listByExperience(node, lowerCaseBlacklist);
    else
        throw new IllegalStateException("Cannot get the list of parties with the order" + order.name());
    // Limit and offset
    Iterator<? extends Pair<String, ?>> iterator = entries.iterator();
    int n = 0;
    for (int c = 0; iterator.hasNext() && n < limit; c++) {
        String uuid = iterator.next().getKey();
        if (c >= offset) {
            ret.add(getParty(UUID.fromString(uuid)));
            n++;
        }
    }
    return ret;
}
Also used : LinkedHashSet(java.util.LinkedHashSet) ArrayList(java.util.ArrayList) ConfigurationSection(com.alessiodp.core.common.addons.external.simpleyaml.configuration.ConfigurationSection) PartyImpl(com.alessiodp.parties.common.parties.objects.PartyImpl)

Example 79 with PartyImpl

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

the class PartiesYAMLDispatcher method getPartyFromNode.

private PartyImpl getPartyFromNode(ConfigurationSection node) {
    PartyImpl ret = null;
    if (node != null) {
        ret = ((PartiesPlugin) plugin).getPartyManager().initializeParty(UUID.fromString(node.getName()));
        ret.setAccessible(true);
        ret.setup(node.getString("name"), node.getString("leader"));
        ret.setDescription(node.getString("tag"));
        ret.setDescription(node.getString("description"));
        ret.setMotd(node.getString("motd"));
        ret.setColor(((PartiesPlugin) plugin).getColorManager().searchColorByName(node.getString("color")));
        ret.setKills(node.getInt("kills"));
        ret.setPassword(node.getString("password"));
        ret.getHomes().addAll(PartyHomeImpl.deserializeMultiple(node.getString("home")));
        ret.setProtection(node.getBoolean("protection", false));
        ret.setExperience(node.getDouble("experience"));
        ret.setFollowEnabled(node.getBoolean("follow", true));
        if (node.isSet("isopen"))
            ret.setOpenNullable(node.getBoolean("isopen"));
        ret.setAccessible(false);
        // Members check
        if (node.getStringList("members") != null) {
            for (String id : node.getStringList("members")) {
                try {
                    ret.getMembers().add(UUID.fromString(id));
                } catch (Exception ex) {
                    plugin.getLoggerManager().logError(Constants.DEBUG_DB_FILE_ERROR, ex);
                }
            }
        }
    }
    return ret;
}
Also used : PartiesPlugin(com.alessiodp.parties.common.PartiesPlugin) PartyImpl(com.alessiodp.parties.common.parties.objects.PartyImpl)

Example 80 with PartyImpl

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

the class PartyRowMapper method map.

@Override
public PartyImpl map(ResultSet rs, StatementContext ctx) throws SQLException {
    PartyImpl ret = ((PartiesPlugin) ADPPlugin.getInstance()).getPartyManager().initializeParty(UUID.fromString(rs.getString("id")));
    ret.setAccessible(true);
    ret.setup(rs.getString("name"), rs.getString("leader"));
    ret.setTag(rs.getString("tag"));
    ret.setDescription(rs.getString("description"));
    ret.setMotd(rs.getString("motd"));
    ret.setColor(((PartiesPlugin) ADPPlugin.getInstance()).getColorManager().searchColorByName(rs.getString("color")));
    ret.setKills(rs.getInt("kills"));
    ret.setPassword(rs.getString("password"));
    ret.getHomes().addAll(PartyHomeImpl.deserializeMultiple(rs.getString("home")));
    ret.setProtection(rs.getBoolean("protection"));
    ret.setExperience(rs.getDouble("experience"));
    ret.setFollowEnabled(rs.getBoolean("follow"));
    boolean isopen = rs.getBoolean("isopen");
    if (!rs.wasNull())
        ret.setOpenNullable(isopen);
    ret.setAccessible(false);
    return ret;
}
Also used : PartiesPlugin(com.alessiodp.parties.common.PartiesPlugin) PartyImpl(com.alessiodp.parties.common.parties.objects.PartyImpl)

Aggregations

PartyImpl (com.alessiodp.parties.common.parties.objects.PartyImpl)106 PartyPlayerImpl (com.alessiodp.parties.common.players.objects.PartyPlayerImpl)75 User (com.alessiodp.core.common.user.User)39 PartiesCommandData (com.alessiodp.parties.common.commands.utils.PartiesCommandData)31 ADPPlugin (com.alessiodp.core.common.ADPPlugin)11 UUID (java.util.UUID)11 ConfigMain (com.alessiodp.parties.common.configuration.data.ConfigMain)10 ConfigParties (com.alessiodp.parties.common.configuration.data.ConfigParties)10 PartiesPlugin (com.alessiodp.parties.common.PartiesPlugin)9 PartiesConstants (com.alessiodp.parties.common.configuration.PartiesConstants)9 PartyHomeImpl (com.alessiodp.parties.common.parties.objects.PartyHomeImpl)8 LinkedList (java.util.LinkedList)8 LinkedHashSet (java.util.LinkedHashSet)7 List (java.util.List)7 HashMap (java.util.HashMap)6 ADPMainCommand (com.alessiodp.core.common.commands.utils.ADPMainCommand)5 CommandData (com.alessiodp.core.common.commands.utils.CommandData)5 OfflineUser (com.alessiodp.core.common.user.OfflineUser)5 CommonCommands (com.alessiodp.parties.common.commands.list.CommonCommands)5 PartiesSubCommand (com.alessiodp.parties.common.commands.utils.PartiesSubCommand)5