mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-08-26 22:49:51 +02:00
Removed DataCache#getInstance method
This commit is contained in:
parent
abc1bc3bc4
commit
c67f0475a0
|
@ -6,7 +6,6 @@ package com.djrapitops.plan.api;
|
|||
|
||||
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||
import com.djrapitops.plan.data.plugin.PluginData;
|
||||
import com.djrapitops.plan.system.cache.DataCache;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.database.databases.operation.FetchOperations;
|
||||
import com.djrapitops.plan.utilities.uuid.UUIDUtility;
|
||||
|
@ -26,20 +25,17 @@ public class BungeeAPI extends CommonAPI {
|
|||
|
||||
private final HookHandler hookHandler;
|
||||
private final Database database;
|
||||
private final DataCache dataCache;
|
||||
|
||||
@Inject
|
||||
public BungeeAPI(
|
||||
UUIDUtility uuidUtility,
|
||||
Database database,
|
||||
DataCache dataCache,
|
||||
HookHandler hookHandler,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
super(uuidUtility, errorHandler);
|
||||
|
||||
this.database = database;
|
||||
this.dataCache = dataCache;
|
||||
this.hookHandler = hookHandler;
|
||||
}
|
||||
|
||||
|
@ -50,7 +46,7 @@ public class BungeeAPI extends CommonAPI {
|
|||
|
||||
@Override
|
||||
public String getPlayerName(UUID uuid) {
|
||||
return dataCache.getName(uuid);
|
||||
return database.fetch().getPlayerName(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -6,7 +6,6 @@ package com.djrapitops.plan.api;
|
|||
|
||||
import com.djrapitops.plan.data.plugin.HookHandler;
|
||||
import com.djrapitops.plan.data.plugin.PluginData;
|
||||
import com.djrapitops.plan.system.cache.DataCache;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plan.system.database.databases.operation.FetchOperations;
|
||||
import com.djrapitops.plan.utilities.uuid.UUIDUtility;
|
||||
|
@ -25,21 +24,18 @@ import java.util.UUID;
|
|||
public class ServerAPI extends CommonAPI {
|
||||
|
||||
private final HookHandler hookHandler;
|
||||
private final Database activeDatabase;
|
||||
private final DataCache dataCache;
|
||||
private final Database database;
|
||||
|
||||
@Inject
|
||||
public ServerAPI(
|
||||
UUIDUtility uuidUtility,
|
||||
HookHandler hookHandler,
|
||||
Database activeDatabase,
|
||||
DataCache dataCache,
|
||||
Database database,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
super(uuidUtility, errorHandler);
|
||||
this.hookHandler = hookHandler;
|
||||
this.activeDatabase = activeDatabase;
|
||||
this.dataCache = dataCache;
|
||||
this.database = database;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -49,11 +45,11 @@ public class ServerAPI extends CommonAPI {
|
|||
|
||||
@Override
|
||||
public String getPlayerName(UUID uuid) {
|
||||
return dataCache.getName(uuid);
|
||||
return database.fetch().getPlayerName(uuid);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FetchOperations fetchFromPlanDB() {
|
||||
return activeDatabase.fetch();
|
||||
return database.fetch();
|
||||
}
|
||||
}
|
||||
|
|
|
@ -7,11 +7,13 @@ import java.util.UUID;
|
|||
public class PlayerDeath implements DateHolder {
|
||||
|
||||
private final UUID killer;
|
||||
private final String killerName;
|
||||
private final long date;
|
||||
private final String weapon;
|
||||
|
||||
public PlayerDeath(UUID killer, String weapon, long date) {
|
||||
public PlayerDeath(UUID killer, String killerName, String weapon, long date) {
|
||||
this.killer = killer;
|
||||
this.killerName = killerName;
|
||||
this.date = date;
|
||||
this.weapon = weapon;
|
||||
}
|
||||
|
@ -20,6 +22,10 @@ public class PlayerDeath implements DateHolder {
|
|||
return killer;
|
||||
}
|
||||
|
||||
public String getKillerName() {
|
||||
return killerName;
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDate() {
|
||||
return date;
|
||||
|
|
|
@ -2,8 +2,8 @@ package com.djrapitops.plan.data.container;
|
|||
|
||||
import com.djrapitops.plan.data.store.objects.DateHolder;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Objects;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
@ -12,11 +12,13 @@ import java.util.UUID;
|
|||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class PlayerKill implements DateHolder, Serializable {
|
||||
public class PlayerKill implements DateHolder {
|
||||
|
||||
private final UUID victim;
|
||||
private final long date;
|
||||
private final String weapon;
|
||||
private final long date;
|
||||
|
||||
private String victimName;
|
||||
|
||||
/**
|
||||
* Creates a PlayerKill object with given parameters.
|
||||
|
@ -31,6 +33,13 @@ public class PlayerKill implements DateHolder, Serializable {
|
|||
this.date = date;
|
||||
}
|
||||
|
||||
public PlayerKill(UUID victim, String weapon, long date, String victimName) {
|
||||
this.victim = victim;
|
||||
this.date = date;
|
||||
this.weapon = weapon;
|
||||
this.victimName = victimName;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the victim's UUID.
|
||||
*
|
||||
|
@ -40,6 +49,10 @@ public class PlayerKill implements DateHolder, Serializable {
|
|||
return victim;
|
||||
}
|
||||
|
||||
public Optional<String> getVictimName() {
|
||||
return Optional.ofNullable(victimName);
|
||||
}
|
||||
|
||||
@Override
|
||||
public long getDate() {
|
||||
return date;
|
||||
|
|
|
@ -1,131 +0,0 @@
|
|||
package com.djrapitops.plan.data.store.mutators.formatting;
|
||||
|
||||
import com.djrapitops.plan.system.settings.Settings;
|
||||
import org.apache.commons.lang3.StringUtils;
|
||||
|
||||
/**
|
||||
* Formatter for time amount in milliseconds.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class TimeAmountFormatter implements Formatter<Long> {
|
||||
|
||||
// Placeholders for the config settings
|
||||
private static final String ZERO_PH = "%zero%";
|
||||
private static final String SECONDS_PH = "%seconds%";
|
||||
private static final String MINUTES_PH = "%minutes%";
|
||||
private static final String HOURS_PH = "%hours%";
|
||||
private static final String DAYS_PH = "%days%";
|
||||
private static final String MONTHS_PH = "%months%";
|
||||
private static final String YEARS_PH = "%years%";
|
||||
|
||||
@Override
|
||||
public String apply(Long ms) {
|
||||
if (ms <= 0) {
|
||||
return "-";
|
||||
}
|
||||
StringBuilder builder = new StringBuilder();
|
||||
long x = ms / 1000;
|
||||
long seconds = x % 60;
|
||||
x /= 60;
|
||||
long minutes = x % 60;
|
||||
x /= 60;
|
||||
long hours = x % 24;
|
||||
x /= 24;
|
||||
long days = x % 365;
|
||||
long months = (days - days % 30) / 30;
|
||||
days -= months * 30;
|
||||
x /= 365;
|
||||
long years = x;
|
||||
|
||||
appendYears(builder, years);
|
||||
appendMonths(builder, months);
|
||||
appendDays(builder, days);
|
||||
|
||||
String hourFormat = Settings.FORMAT_HOURS.toString();
|
||||
String minuteFormat = Settings.FORMAT_MINUTES.toString();
|
||||
String secondFormat = Settings.FORMAT_SECONDS.toString();
|
||||
|
||||
appendHours(builder, hours, hourFormat);
|
||||
appendMinutes(builder, minutes, hours, hourFormat, minuteFormat);
|
||||
appendSeconds(builder, seconds, minutes, hours, hourFormat, minuteFormat, secondFormat);
|
||||
|
||||
String formattedTime = StringUtils.remove(builder.toString(), ZERO_PH);
|
||||
if (formattedTime.isEmpty()) {
|
||||
return Settings.FORMAT_ZERO_SECONDS.toString();
|
||||
}
|
||||
return formattedTime;
|
||||
}
|
||||
|
||||
private void appendSeconds(StringBuilder builder, long seconds, long minutes, long hours, String fHours, String fMinutes, String fSeconds) {
|
||||
if (seconds != 0) {
|
||||
String s = fSeconds.replace(SECONDS_PH, String.valueOf(seconds));
|
||||
if (minutes == 0 && s.contains(MINUTES_PH)) {
|
||||
if (hours == 0 && fMinutes.contains(HOURS_PH)) {
|
||||
builder.append(fHours.replace(ZERO_PH, "0").replace(HOURS_PH, "0"));
|
||||
}
|
||||
builder.append(fMinutes.replace(HOURS_PH, "").replace(ZERO_PH, "0").replace(MINUTES_PH, "0"));
|
||||
}
|
||||
s = s.replace(MINUTES_PH, "");
|
||||
if (s.contains(ZERO_PH) && String.valueOf(seconds).length() == 1) {
|
||||
builder.append('0');
|
||||
}
|
||||
builder.append(s);
|
||||
}
|
||||
}
|
||||
|
||||
private void appendMinutes(StringBuilder builder, long minutes, long hours, String fHours, String fMinutes) {
|
||||
if (minutes != 0) {
|
||||
String m = fMinutes.replace(MINUTES_PH, String.valueOf(minutes));
|
||||
if (hours == 0 && m.contains(HOURS_PH)) {
|
||||
builder.append(fHours.replace(ZERO_PH, "0").replace(HOURS_PH, "0"));
|
||||
m = m.replace(HOURS_PH, "");
|
||||
}
|
||||
m = m.replace(HOURS_PH, "");
|
||||
if (m.contains(ZERO_PH) && String.valueOf(minutes).length() == 1) {
|
||||
builder.append('0');
|
||||
}
|
||||
builder.append(m);
|
||||
}
|
||||
}
|
||||
|
||||
private void appendHours(StringBuilder builder, long hours, String fHours) {
|
||||
if (hours != 0) {
|
||||
String h = fHours.replace(HOURS_PH, String.valueOf(hours));
|
||||
if (h.contains(ZERO_PH) && String.valueOf(hours).length() == 1) {
|
||||
builder.append('0');
|
||||
}
|
||||
builder.append(h);
|
||||
}
|
||||
}
|
||||
|
||||
private void appendDays(StringBuilder builder, long days) {
|
||||
String singular = Settings.FORMAT_DAY.toString();
|
||||
String plural = Settings.FORMAT_DAYS.toString();
|
||||
appendValue(builder, days, singular, plural, DAYS_PH);
|
||||
}
|
||||
|
||||
private void appendMonths(StringBuilder builder, long months) {
|
||||
String singular = Settings.FORMAT_MONTH.toString();
|
||||
String plural = Settings.FORMAT_MONTHS.toString();
|
||||
|
||||
appendValue(builder, months, singular, plural, MONTHS_PH);
|
||||
}
|
||||
|
||||
private void appendYears(StringBuilder builder, long years) {
|
||||
String singular = Settings.FORMAT_YEAR.toString();
|
||||
String plural = Settings.FORMAT_YEARS.toString();
|
||||
|
||||
appendValue(builder, years, singular, plural, YEARS_PH);
|
||||
}
|
||||
|
||||
private void appendValue(StringBuilder builder, long amount, String singular, String plural, String replace) {
|
||||
if (amount != 0) {
|
||||
if (amount == 1) {
|
||||
builder.append(singular);
|
||||
} else {
|
||||
builder.append(plural.replace(replace, String.valueOf(amount)));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -1,6 +1,7 @@
|
|||
package com.djrapitops.plan.system.cache;
|
||||
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
|
@ -17,8 +18,8 @@ import java.util.UUID;
|
|||
public class BungeeDataCache extends DataCache {
|
||||
|
||||
@Inject
|
||||
public BungeeDataCache(Database database) {
|
||||
super(database);
|
||||
public BungeeDataCache(Database database, ErrorHandler errorHandler) {
|
||||
super(database, errorHandler);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -3,12 +3,15 @@ package com.djrapitops.plan.system.cache;
|
|||
import com.djrapitops.plan.api.exceptions.database.DBOpException;
|
||||
import com.djrapitops.plan.system.SubSystem;
|
||||
import com.djrapitops.plan.system.database.databases.Database;
|
||||
import com.djrapitops.plugin.api.utility.log.Log;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.util.*;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* This Class contains the Cache.
|
||||
|
@ -26,14 +29,20 @@ import java.util.*;
|
|||
@Singleton
|
||||
public class DataCache extends SessionCache implements SubSystem {
|
||||
|
||||
private final ErrorHandler errorHandler;
|
||||
private Database database;
|
||||
|
||||
private final Map<UUID, String> playerNames;
|
||||
private final Map<String, UUID> uuids;
|
||||
private final Map<UUID, String> displayNames;
|
||||
|
||||
@Inject
|
||||
public DataCache(Database database) {
|
||||
public DataCache(
|
||||
Database database,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
super(database);
|
||||
this.errorHandler = errorHandler;
|
||||
playerNames = new HashMap<>();
|
||||
displayNames = new HashMap<>();
|
||||
uuids = new HashMap<>();
|
||||
|
@ -52,13 +61,6 @@ public class DataCache extends SessionCache implements SubSystem {
|
|||
displayNames.clear();
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static DataCache getInstance() {
|
||||
DataCache dataCache = CacheSystem.getInstance().getDataCache();
|
||||
Verify.nullCheck(dataCache, () -> new IllegalStateException("Data Cache was not initialized."));
|
||||
return dataCache;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to update PlayerName and DisplayName caches.
|
||||
*
|
||||
|
@ -94,7 +96,7 @@ public class DataCache extends SessionCache implements SubSystem {
|
|||
name = database.fetch().getPlayerName(uuid);
|
||||
playerNames.put(uuid, name);
|
||||
} catch (DBOpException e) {
|
||||
Log.toLog(this.getClass(), e);
|
||||
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||
name = "Error occurred";
|
||||
}
|
||||
}
|
||||
|
@ -119,16 +121,12 @@ public class DataCache extends SessionCache implements SubSystem {
|
|||
return nicknames.get(nicknames.size() - 1);
|
||||
}
|
||||
} catch (DBOpException e) {
|
||||
Log.toLog(this.getClass(), e);
|
||||
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||
}
|
||||
}
|
||||
return cached;
|
||||
}
|
||||
|
||||
public Set<UUID> getUuids() {
|
||||
return playerNames.keySet();
|
||||
}
|
||||
|
||||
public UUID getUUIDof(String playerName) {
|
||||
return uuids.get(playerName);
|
||||
}
|
||||
|
|
|
@ -90,11 +90,13 @@ public class KillsTable extends UserIDTable {
|
|||
public void addKillsToSessions(UUID uuid, Map<Integer, Session> sessions) {
|
||||
String usersIDColumn = usersTable + "." + UsersTable.Col.ID;
|
||||
String usersUUIDColumn = usersTable + "." + UsersTable.Col.UUID + " as victim_uuid";
|
||||
String usersNameColumn = usersTable + "." + UsersTable.Col.USER_NAME + " as victim_name";
|
||||
String sql = "SELECT " +
|
||||
Col.SESSION_ID + ", " +
|
||||
Col.DATE + ", " +
|
||||
Col.WEAPON + ", " +
|
||||
usersUUIDColumn +
|
||||
usersUUIDColumn + ", " +
|
||||
usersNameColumn +
|
||||
" FROM " + tableName +
|
||||
" INNER JOIN " + usersTable + " on " + usersIDColumn + "=" + Col.VICTIM_ID +
|
||||
" WHERE " + Col.KILLER_ID + "=" + usersTable.statementSelectID;
|
||||
|
@ -113,11 +115,11 @@ public class KillsTable extends UserIDTable {
|
|||
if (session == null) {
|
||||
continue;
|
||||
}
|
||||
String uuidS = set.getString("victim_uuid");
|
||||
UUID victim = UUID.fromString(uuidS);
|
||||
UUID victim = UUID.fromString(set.getString("victim_uuid"));
|
||||
String victimName = set.getString("victim_name");
|
||||
long date = set.getLong(Col.DATE.get());
|
||||
String weapon = set.getString(Col.WEAPON.get());
|
||||
session.getUnsafe(SessionKeys.PLAYER_KILLS).add(new PlayerKill(victim, weapon, date));
|
||||
session.getUnsafe(SessionKeys.PLAYER_KILLS).add(new PlayerKill(victim, weapon, date, victimName));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -127,11 +129,13 @@ public class KillsTable extends UserIDTable {
|
|||
public void addDeathsToSessions(UUID uuid, Map<Integer, Session> sessions) {
|
||||
String usersIDColumn = usersTable + "." + UsersTable.Col.ID;
|
||||
String usersUUIDColumn = usersTable + "." + UsersTable.Col.UUID + " as killer_uuid";
|
||||
String usersNameColumn = usersTable + "." + UsersTable.Col.USER_NAME + " as killer_name";
|
||||
String sql = "SELECT " +
|
||||
Col.SESSION_ID + ", " +
|
||||
Col.DATE + ", " +
|
||||
Col.WEAPON + ", " +
|
||||
usersUUIDColumn +
|
||||
usersUUIDColumn + ", " +
|
||||
usersNameColumn +
|
||||
" FROM " + tableName +
|
||||
" INNER JOIN " + usersTable + " on " + usersIDColumn + "=" + Col.KILLER_ID +
|
||||
" WHERE " + Col.VICTIM_ID + "=" + usersTable.statementSelectID;
|
||||
|
@ -150,11 +154,11 @@ public class KillsTable extends UserIDTable {
|
|||
if (session == null) {
|
||||
continue;
|
||||
}
|
||||
String uuidS = set.getString("killer_uuid");
|
||||
UUID killer = UUID.fromString(uuidS);
|
||||
UUID killer = UUID.fromString(set.getString("killer_uuid"));
|
||||
String name = set.getString("killer_name");
|
||||
long date = set.getLong(Col.DATE.get());
|
||||
String weapon = set.getString(Col.WEAPON.get());
|
||||
session.getUnsafe(SessionKeys.PLAYER_DEATHS).add(new PlayerDeath(killer, weapon, date));
|
||||
session.getUnsafe(SessionKeys.PLAYER_DEATHS).add(new PlayerDeath(killer, name, weapon, date));
|
||||
}
|
||||
return null;
|
||||
}
|
||||
|
@ -193,11 +197,13 @@ public class KillsTable extends UserIDTable {
|
|||
String usersVictimIDColumn = usersTable + "." + UsersTable.Col.ID;
|
||||
String usersKillerIDColumn = "a." + UsersTable.Col.ID;
|
||||
String usersVictimUUIDColumn = usersTable + "." + UsersTable.Col.UUID + " as victim_uuid";
|
||||
String usersVictimNameColumn = usersTable + "." + UsersTable.Col.USER_NAME + " as victim_name";
|
||||
String usersKillerUUIDColumn = "a." + UsersTable.Col.UUID + " as killer_uuid";
|
||||
String sql = "SELECT " +
|
||||
Col.DATE + ", " +
|
||||
Col.WEAPON + ", " +
|
||||
usersVictimUUIDColumn + ", " +
|
||||
usersVictimNameColumn + ", " +
|
||||
usersKillerUUIDColumn +
|
||||
" FROM " + tableName +
|
||||
" INNER JOIN " + usersTable + " on " + usersVictimIDColumn + "=" + Col.VICTIM_ID +
|
||||
|
@ -210,10 +216,12 @@ public class KillsTable extends UserIDTable {
|
|||
while (set.next()) {
|
||||
UUID killer = UUID.fromString(set.getString("killer_uuid"));
|
||||
UUID victim = UUID.fromString(set.getString("victim_uuid"));
|
||||
String victimName = set.getString("victim_name");
|
||||
long date = set.getLong(Col.DATE.get());
|
||||
String weapon = set.getString(Col.WEAPON.get());
|
||||
|
||||
List<PlayerKill> kills = allKills.getOrDefault(killer, new ArrayList<>());
|
||||
kills.add(new PlayerKill(victim, weapon, date));
|
||||
kills.add(new PlayerKill(victim, weapon, date, victimName));
|
||||
allKills.put(killer, kills);
|
||||
}
|
||||
return allKills;
|
||||
|
@ -224,11 +232,13 @@ public class KillsTable extends UserIDTable {
|
|||
public Map<Integer, List<PlayerKill>> getAllPlayerKillsBySessionID() {
|
||||
String usersIDColumn = usersTable + "." + UsersTable.Col.ID;
|
||||
String usersUUIDColumn = usersTable + "." + UsersTable.Col.UUID + " as victim_uuid";
|
||||
String usersNameColumn = usersTable + "." + UsersTable.Col.USER_NAME + " as victim_name";
|
||||
String sql = "SELECT " +
|
||||
Col.SESSION_ID + ", " +
|
||||
Col.DATE + ", " +
|
||||
Col.WEAPON + ", " +
|
||||
usersUUIDColumn +
|
||||
usersUUIDColumn + ", " +
|
||||
usersNameColumn +
|
||||
" FROM " + tableName +
|
||||
" INNER JOIN " + usersTable + " on " + usersIDColumn + "=" + Col.VICTIM_ID;
|
||||
|
||||
|
@ -241,11 +251,11 @@ public class KillsTable extends UserIDTable {
|
|||
|
||||
List<PlayerKill> playerKills = allPlayerKills.getOrDefault(sessionID, new ArrayList<>());
|
||||
|
||||
String uuidS = set.getString("victim_uuid");
|
||||
UUID victim = UUID.fromString(uuidS);
|
||||
UUID victim = UUID.fromString(set.getString("victim_uuid"));
|
||||
String victimName = set.getString("victim_name");
|
||||
long date = set.getLong(Col.DATE.get());
|
||||
String weapon = set.getString(Col.WEAPON.get());
|
||||
playerKills.add(new PlayerKill(victim, weapon, date));
|
||||
playerKills.add(new PlayerKill(victim, weapon, date, victimName));
|
||||
|
||||
allPlayerKills.put(sessionID, playerKills);
|
||||
}
|
||||
|
|
|
@ -3,11 +3,10 @@ package com.djrapitops.plan.utilities.html.tables;
|
|||
import com.djrapitops.plan.api.PlanAPI;
|
||||
import com.djrapitops.plan.data.container.PlayerDeath;
|
||||
import com.djrapitops.plan.data.element.TableContainer;
|
||||
import com.djrapitops.plan.data.store.objects.DateHolder;
|
||||
import com.djrapitops.plan.utilities.comparators.DateHolderRecentComparator;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plan.data.store.objects.DateHolder;
|
||||
import com.djrapitops.plan.system.cache.DataCache;
|
||||
import com.djrapitops.plan.utilities.comparators.DateHolderRecentComparator;
|
||||
import com.djrapitops.plan.utilities.html.Html;
|
||||
import com.djrapitops.plan.utilities.html.icon.Family;
|
||||
import com.djrapitops.plan.utilities.html.icon.Icon;
|
||||
|
@ -35,16 +34,15 @@ public class DeathsTable extends TableContainer {
|
|||
Formatter<DateHolder> timestamp = Formatters.year_Old();
|
||||
|
||||
int i = 0;
|
||||
DataCache dataCache = DataCache.getInstance();
|
||||
for (PlayerDeath death : playerPlayerDeaths) {
|
||||
if (i >= 40) {
|
||||
break;
|
||||
}
|
||||
|
||||
String name = dataCache.getName(death.getKiller());
|
||||
String killerName = death.getKillerName();
|
||||
addRow(
|
||||
timestamp.apply(death),
|
||||
Html.LINK.parse(PlanAPI.getInstance().getPlayerInspectPageLink(name), name),
|
||||
Html.LINK.parse(PlanAPI.getInstance().getPlayerInspectPageLink(killerName), killerName),
|
||||
death.getWeapon()
|
||||
);
|
||||
|
||||
|
|
|
@ -3,11 +3,10 @@ package com.djrapitops.plan.utilities.html.tables;
|
|||
import com.djrapitops.plan.api.PlanAPI;
|
||||
import com.djrapitops.plan.data.container.PlayerKill;
|
||||
import com.djrapitops.plan.data.element.TableContainer;
|
||||
import com.djrapitops.plan.data.store.objects.DateHolder;
|
||||
import com.djrapitops.plan.utilities.comparators.DateHolderRecentComparator;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatter;
|
||||
import com.djrapitops.plan.utilities.formatting.Formatters;
|
||||
import com.djrapitops.plan.data.store.objects.DateHolder;
|
||||
import com.djrapitops.plan.system.cache.DataCache;
|
||||
import com.djrapitops.plan.utilities.comparators.DateHolderRecentComparator;
|
||||
import com.djrapitops.plan.utilities.html.Html;
|
||||
import com.djrapitops.plan.utilities.html.icon.Family;
|
||||
import com.djrapitops.plan.utilities.html.icon.Icon;
|
||||
|
@ -39,16 +38,15 @@ public class KillsTable extends TableContainer {
|
|||
Formatter<DateHolder> timestamp = Formatters.year_Old();
|
||||
|
||||
int i = 0;
|
||||
DataCache dataCache = DataCache.getInstance();
|
||||
for (PlayerKill kill : playerKills) {
|
||||
if (i >= 40) {
|
||||
break;
|
||||
}
|
||||
|
||||
String name = dataCache.getName(kill.getVictim());
|
||||
String victimName = kill.getVictimName().orElse("Unknown");
|
||||
addRow(
|
||||
timestamp.apply(kill),
|
||||
Html.LINK.parse(PlanAPI.getInstance().getPlayerInspectPageLink(name), name),
|
||||
Html.LINK.parse(PlanAPI.getInstance().getPlayerInspectPageLink(victimName), victimName),
|
||||
kill.getWeapon()
|
||||
);
|
||||
|
||||
|
|
Loading…
Reference in New Issue
Block a user