use of com.alessiodp.partiesapi.objects.Party in project Parties by AlessioDP.
the class DatabaseManager method getPartySync.
public Party getPartySync(String party) {
DebugUtils.debugLog("Data call: getParty()");
long nsTime = System.nanoTime();
Party futureRet = database.getParty(party);
DebugUtils.debugDataTiming(nsTime);
return futureRet;
}
use of com.alessiodp.partiesapi.objects.Party in project Parties by AlessioDP.
the class FileDispatcher method getParty.
@Override
public Party getParty(String party) {
Party ret = null;
String node = "parties." + party;
if (database.existData(node)) {
ret = database.loadPartyData(party);
}
return ret;
}
use of com.alessiodp.partiesapi.objects.Party in project Parties by AlessioDP.
the class YAMLDao method loadPartyData.
@Override
public Party loadPartyData(String party) {
Party ret = new Party(party);
String node = "parties." + party;
ret.setDescription(data.getString(node + ".desc", ""));
ret.setMotd(data.getString(node + ".motd", ""));
ret.setPrefix(data.getString(node + ".prefix", ""));
ret.setSuffix(data.getString(node + ".suffix", ""));
ret.setColor(plugin.getColorManager().searchColorByName(data.getString(node + ".color", "")));
ret.setKills(data.getInt(node + ".kills", 0));
ret.setPassword(data.getString(node + ".password", ""));
ret.setHome(PartiesUtils.formatHome(data.getString(node + ".home", "")));
String lead = data.getString(node + ".leader", "");
try {
if (!lead.isEmpty()) {
if (lead.equalsIgnoreCase(Constants.FIXED_VALUE_TEXT)) {
ret.setLeader(UUID.fromString(Constants.FIXED_VALUE_UUID));
ret.setFixed(true);
} else
ret.setLeader(UUID.fromString(lead));
}
} catch (Exception ex) {
LoggerManager.printError(LoggerManager.formatErrorCallTrace(Constants.DEBUG_FILE_ERROR, ex));
}
List<UUID> list = new ArrayList<UUID>();
for (String id : data.getStringList(node + ".members")) {
try {
list.add(UUID.fromString(id));
} catch (Exception ex) {
LoggerManager.printError(LoggerManager.formatErrorCallTrace(Constants.DEBUG_FILE_ERROR, ex));
}
}
ret.setMembers(list);
return ret;
}
use of com.alessiodp.partiesapi.objects.Party in project Parties by AlessioDP.
the class SQLDispatcher method getPartyFromResultSet.
private Party getPartyFromResultSet(Connection connection, ResultSet rs) {
Party ret = null;
try {
ret = new Party(rs.getString("name"));
ret.setDescription(rs.getString("description"));
ret.setMotd(rs.getString("motd"));
ret.setPrefix(rs.getString("prefix"));
ret.setSuffix(rs.getString("suffix"));
ret.setColor(plugin.getColorManager().searchColorByName(rs.getString("color")));
ret.setKills(rs.getInt("kills"));
ret.setPassword(rs.getString("password"));
ret.setHome(PartiesUtils.formatHome(rs.getString("home")));
String leader = rs.getString("leader");
if (leader != null) {
if (leader.equalsIgnoreCase(Constants.FIXED_VALUE_TEXT)) {
ret.setLeader(UUID.fromString(Constants.FIXED_VALUE_UUID));
ret.setFixed(true);
} else
ret.setLeader(UUID.fromString(leader));
}
ret.setMembers(getMembersParty(connection, rs.getString("name")));
} catch (Exception ex) {
LoggerManager.printError(LoggerManager.formatErrorCallTrace(Constants.DEBUG_SQL_ERROR, ex));
}
return ret;
}
use of com.alessiodp.partiesapi.objects.Party in project Parties by AlessioDP.
the class SQLDispatcher method saveEntireData.
@Override
public boolean saveEntireData(DatabaseData data) {
boolean ret = false;
try (Connection connection = getConnection()) {
connection.setAutoCommit(false);
// Players
for (Entry<UUID, PartyPlayer> entry : data.getPlayers().entrySet()) updatePlayer(entry.getValue(), connection);
// Parties
for (Entry<String, Party> entry : data.getParties().entrySet()) {
updateParty(entry.getValue(), connection);
}
connection.commit();
ret = true;
} catch (Exception ex) {
LoggerManager.printError(LoggerManager.formatErrorCallTrace(Constants.DEBUG_SQL_ERROR, ex));
}
return ret;
}
Aggregations