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);
}
}
}
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;
}
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;
}
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;
}
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;
}
Aggregations