mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-01-02 22:47:37 +01:00
Fixed a bunch of IntelliJ inspections
- Fixed possible null issues with NicknameCache - Removed bunch of unused code, such as: - Point reduction algorithm implementations - HighCharts data String parsing methods - Unused Mutators - Unused AnalysisKeys - Leftovers from ConnectionSystem (Response codes) - Unused queries (Leftovers from Server box and Players table queries) - rendering.html.icon.Icons - Made bunch of fields final Note that old deprecated API classes do not have signature changes.
This commit is contained in:
parent
2970b6590e
commit
1511162f5b
@ -19,7 +19,7 @@ package com.djrapitops.plan.addons.placeholderapi.placeholders;
|
||||
import com.djrapitops.plan.delivery.domain.container.PlayerContainer;
|
||||
import com.djrapitops.plan.delivery.domain.keys.PlayerKeys;
|
||||
import com.djrapitops.plan.delivery.domain.mutators.PingMutator;
|
||||
import com.djrapitops.plan.delivery.domain.mutators.PvpInfoMutator;
|
||||
import com.djrapitops.plan.delivery.domain.mutators.PlayerVersusMutator;
|
||||
import com.djrapitops.plan.delivery.domain.mutators.SessionsMutator;
|
||||
import com.djrapitops.plan.delivery.formatting.Formatter;
|
||||
import com.djrapitops.plan.delivery.formatting.Formatters;
|
||||
@ -86,7 +86,7 @@ public class PlayerPlaceHolder extends AbstractPlanPlaceHolder {
|
||||
case "player_player_kill_count":
|
||||
return player.getValue(PlayerKeys.PLAYER_KILL_COUNT).orElse(0);
|
||||
case "player_kill_death_ratio":
|
||||
return PvpInfoMutator.forContainer(player).killDeathRatio();
|
||||
return PlayerVersusMutator.forContainer(player).toKillDeathRatio();
|
||||
|
||||
case "player_ping_average_day":
|
||||
return PingMutator.forContainer(player).filterBy(Predicates.within(dayAgo(), now())).average();
|
||||
|
@ -78,7 +78,7 @@ public class ChatListener implements Listener {
|
||||
|
||||
dbSystem.getDatabase().executeTransaction(new NicknameStoreTransaction(
|
||||
uuid, new Nickname(displayName, time, serverInfo.getServerUUID()),
|
||||
(playerUUID, name) -> name.equals(nicknameCache.getDisplayName(playerUUID))
|
||||
(playerUUID, name) -> nicknameCache.getDisplayName(playerUUID).map(name::equals).orElse(false)
|
||||
));
|
||||
}
|
||||
}
|
||||
|
@ -183,7 +183,7 @@ public class PlayerOnlineListener implements Listener {
|
||||
|
||||
database.executeTransaction(new NicknameStoreTransaction(
|
||||
playerUUID, new Nickname(displayName, time, serverUUID),
|
||||
(uuid, name) -> name.equals(nicknameCache.getDisplayName(uuid))
|
||||
(uuid, name) -> nicknameCache.getDisplayName(playerUUID).map(name::equals).orElse(false)
|
||||
));
|
||||
|
||||
processing.submitNonCritical(() -> extensionService.updatePlayerValues(playerUUID, playerName, CallEvents.PLAYER_JOIN));
|
||||
|
@ -48,7 +48,7 @@ public class BukkitDBSystem extends DBSystem {
|
||||
Timings timings,
|
||||
ErrorHandler errorHandler
|
||||
) {
|
||||
super(locale, sqLiteDB, h2DB, logger, timings, errorHandler);
|
||||
super(locale, sqLiteDB, h2DB, logger);
|
||||
this.config = config;
|
||||
|
||||
databases.add(mySQLDB);
|
||||
|
@ -29,7 +29,7 @@ import java.util.function.Consumer;
|
||||
*/
|
||||
public class CapabilityServiceImplementation implements CapabilityService {
|
||||
|
||||
private List<Consumer<Boolean>> enableListeners;
|
||||
private final List<Consumer<Boolean>> enableListeners;
|
||||
|
||||
private CapabilityServiceImplementation() {
|
||||
/* Inject required for dagger */
|
||||
|
@ -43,7 +43,7 @@ import java.util.UUID;
|
||||
@Deprecated
|
||||
public final class AnalysisContainer extends InspectContainer {
|
||||
|
||||
private Map<String, Map<UUID, ? extends Serializable>> playerTableValues;
|
||||
private final Map<String, Map<UUID, ? extends Serializable>> playerTableValues;
|
||||
|
||||
public AnalysisContainer() {
|
||||
playerTableValues = new TreeMap<>();
|
||||
|
@ -40,9 +40,9 @@ import java.util.TreeMap;
|
||||
@Deprecated
|
||||
public class InspectContainer {
|
||||
|
||||
protected List<String> values;
|
||||
protected TreeMap<String, String> html;
|
||||
protected TreeMap<String, TableContainer> tables;
|
||||
protected final List<String> values;
|
||||
protected final TreeMap<String, String> html;
|
||||
protected final TreeMap<String, TableContainer> tables;
|
||||
|
||||
public InspectContainer() {
|
||||
values = new ArrayList<>();
|
||||
|
@ -35,7 +35,7 @@ public class TableContainer {
|
||||
|
||||
protected final String[] header;
|
||||
protected final Formatter[] formatters;
|
||||
private List<Serializable[]> values;
|
||||
private final List<Serializable[]> values;
|
||||
|
||||
private String jqueryDatatable;
|
||||
|
||||
|
@ -1,36 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.delivery.domain;
|
||||
|
||||
import java.util.TreeSet;
|
||||
|
||||
/**
|
||||
* Basic TreeSet with Epoch ms as values.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class DateSet extends TreeSet<Long> {
|
||||
|
||||
public boolean hasValuesBetween(long after, long before) {
|
||||
return countBetween(after, before) > 0;
|
||||
}
|
||||
|
||||
public int countBetween(long after, long before) {
|
||||
return subSet(after, before).size();
|
||||
}
|
||||
|
||||
}
|
@ -105,10 +105,10 @@ public class TablePlayer implements Comparable<TablePlayer> {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof TablePlayer)) return false;
|
||||
TablePlayer that = (TablePlayer) o;
|
||||
return playtime == that.playtime &&
|
||||
sessionCount == that.sessionCount &&
|
||||
registered == that.registered &&
|
||||
lastSeen == that.lastSeen &&
|
||||
return playtime.equals(that.playtime) &&
|
||||
sessionCount.equals(that.sessionCount) &&
|
||||
registered.equals(that.registered) &&
|
||||
lastSeen.equals(that.lastSeen) &&
|
||||
name.equals(that.name) &&
|
||||
activityIndex.equals(that.activityIndex) &&
|
||||
geolocation.equals(that.geolocation);
|
||||
|
@ -31,7 +31,7 @@ public class CachingSupplier<T> implements Supplier<T> {
|
||||
private final Supplier<T> original;
|
||||
private T cachedValue;
|
||||
private long cacheTime;
|
||||
private long timeToLive;
|
||||
private final long timeToLive;
|
||||
|
||||
public CachingSupplier(Supplier<T> original) {
|
||||
this(original, TimeUnit.SECONDS.toMillis(30L));
|
||||
@ -53,11 +53,4 @@ public class CachingSupplier<T> implements Supplier<T> {
|
||||
return cachedValue;
|
||||
}
|
||||
|
||||
public boolean isCached() {
|
||||
return cachedValue != null;
|
||||
}
|
||||
|
||||
public long getCacheTime() {
|
||||
return cacheTime;
|
||||
}
|
||||
}
|
@ -37,11 +37,6 @@ public class DynamicDataContainer implements DataContainer {
|
||||
rawDataContainer = new RawDataContainer();
|
||||
}
|
||||
|
||||
public DynamicDataContainer(long timeToLive) {
|
||||
supplierDataContainer = new SupplierDataContainer(timeToLive);
|
||||
rawDataContainer = new RawDataContainer();
|
||||
}
|
||||
|
||||
@Override
|
||||
public <T> void putRawData(Key<T> key, T obj) {
|
||||
rawDataContainer.putRawData(key, obj);
|
||||
|
@ -32,7 +32,7 @@ import java.util.Map;
|
||||
*/
|
||||
public class PlayerContainer extends DynamicDataContainer {
|
||||
|
||||
private Map<Long, ActivityIndex> activityIndexCache;
|
||||
private final Map<Long, ActivityIndex> activityIndexCache;
|
||||
|
||||
public PlayerContainer() {
|
||||
activityIndexCache = new HashMap<>();
|
||||
|
@ -32,7 +32,7 @@ import java.util.function.Supplier;
|
||||
public class SupplierDataContainer implements DataContainer {
|
||||
|
||||
private final Map<Key, Supplier> map;
|
||||
private long timeToLive;
|
||||
private final long timeToLive;
|
||||
|
||||
/**
|
||||
* Create a SupplierDataContainer with a default TTL of 30 seconds.
|
||||
|
@ -16,16 +16,6 @@
|
||||
*/
|
||||
package com.djrapitops.plan.delivery.domain.keys;
|
||||
|
||||
import com.djrapitops.plan.delivery.domain.mutators.PlayersMutator;
|
||||
import com.djrapitops.plan.delivery.domain.mutators.PlayersOnlineResolver;
|
||||
import com.djrapitops.plan.delivery.domain.mutators.SessionsMutator;
|
||||
import com.djrapitops.plan.delivery.domain.mutators.TPSMutator;
|
||||
|
||||
import java.util.Map;
|
||||
import java.util.Set;
|
||||
import java.util.TreeMap;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Key objects used for Analysis.
|
||||
* <p>
|
||||
@ -38,9 +28,6 @@ import java.util.UUID;
|
||||
@Deprecated
|
||||
public class AnalysisKeys {
|
||||
|
||||
// Constants (Affected only by config settings)
|
||||
public static final PlaceholderKey<String> VERSION = CommonPlaceholderKeys.VERSION;
|
||||
public static final PlaceholderKey<String> SERVER_NAME = new PlaceholderKey<>(String.class, "serverName");
|
||||
public static final PlaceholderKey<Integer> TIME_ZONE = CommonPlaceholderKeys.TIME_ZONE;
|
||||
public static final PlaceholderKey<Integer> FIRST_DAY = new PlaceholderKey<>(Integer.class, "firstDay");
|
||||
public static final PlaceholderKey<Integer> TPS_MEDIUM = new PlaceholderKey<>(Integer.class, "tpsMedium");
|
||||
@ -64,127 +51,6 @@ public class AnalysisKeys {
|
||||
public static final PlaceholderKey<String> WORLD_MAP_HIGH_COLOR = CommonPlaceholderKeys.WORLD_MAP_HIGH_COLOR;
|
||||
public static final PlaceholderKey<String> WORLD_MAP_LOW_COLOR = CommonPlaceholderKeys.WORLD_MAP_LOW_COLOR;
|
||||
|
||||
// Tables & other structures
|
||||
public static final PlaceholderKey<String> PLAYERS_TABLE = new PlaceholderKey<>(String.class, "tablePlayerlist");
|
||||
public static final PlaceholderKey<String> SESSION_ACCORDION_HTML = new PlaceholderKey<>(String.class, "accordionSessions");
|
||||
public static final PlaceholderKey<String> SESSION_ACCORDION_FUNCTIONS = new PlaceholderKey<>(String.class, "sessionTabGraphViewFunctions");
|
||||
public static final PlaceholderKey<String> SESSION_TABLE = new PlaceholderKey<>(String.class, "tableBodySessions");
|
||||
public static final PlaceholderKey<String> PING_TABLE = new PlaceholderKey<>(String.class, "tablePing");
|
||||
public static final PlaceholderKey<String> RECENT_LOGINS = new PlaceholderKey<>(String.class, "listRecentLogins");
|
||||
public static final PlaceholderKey<String> COMMAND_USAGE_TABLE = new PlaceholderKey<>(String.class, "tableCommandUsage");
|
||||
public static final PlaceholderKey<String> HEALTH_NOTES = CommonPlaceholderKeys.HEALTH_NOTES;
|
||||
public static final PlaceholderKey<String> PLUGINS_TAB = new PlaceholderKey<>(String.class, "tabsPlugins");
|
||||
public static final PlaceholderKey<String> PLUGINS_TAB_NAV = new PlaceholderKey<>(String.class, "navPluginsTabs");
|
||||
// Formatted time values
|
||||
public static final PlaceholderKey<String> REFRESH_TIME_F = CommonPlaceholderKeys.REFRESH_TIME_F;
|
||||
public static final PlaceholderKey<String> REFRESH_TIME_FULL_F = CommonPlaceholderKeys.REFRESH_TIME_FULL_F;
|
||||
public static final PlaceholderKey<String> LAST_PEAK_TIME_F = CommonPlaceholderKeys.LAST_PEAK_TIME_F;
|
||||
public static final PlaceholderKey<String> ALL_TIME_PEAK_TIME_F = CommonPlaceholderKeys.ALL_TIME_PEAK_TIME_F;
|
||||
public static final PlaceholderKey<String> AVERAGE_SESSION_LENGTH_F = new PlaceholderKey<>(String.class, "sessionAverage");
|
||||
public static final PlaceholderKey<String> AVERAGE_PLAYTIME_F = new PlaceholderKey<>(String.class, "playtimeAverage");
|
||||
public static final PlaceholderKey<String> PLAYTIME_F = new PlaceholderKey<>(String.class, "playtimeTotal");
|
||||
// Direct values, possibly formatted
|
||||
public static final PlaceholderKey<String> PLAYERS_LAST_PEAK = CommonPlaceholderKeys.PLAYERS_LAST_PEAK;
|
||||
public static final PlaceholderKey<String> PLAYERS_ALL_TIME_PEAK = CommonPlaceholderKeys.PLAYERS_ALL_TIME_PEAK;
|
||||
public static final PlaceholderKey<Integer> OPERATORS = new PlaceholderKey<>(Integer.class, "ops");
|
||||
public static final PlaceholderKey<Integer> PLAYERS_REGULAR = new PlaceholderKey<>(Integer.class, "playersRegular");
|
||||
public static final PlaceholderKey<Integer> SESSION_COUNT = new PlaceholderKey<>(Integer.class, "sessionCount");
|
||||
public static final PlaceholderKey<Integer> DEATHS = new PlaceholderKey<>(Integer.class, "deaths");
|
||||
public static final PlaceholderKey<Integer> MOB_KILL_COUNT = new PlaceholderKey<>(Integer.class, "mobKillCount");
|
||||
public static final PlaceholderKey<Integer> PLAYER_KILL_COUNT = new PlaceholderKey<>(Integer.class, "killCount");
|
||||
public static final PlaceholderKey<Double> HEALTH_INDEX = CommonPlaceholderKeys.HEALTH_INDEX;
|
||||
public static final PlaceholderKey<Integer> COMMAND_COUNT = new PlaceholderKey<>(Integer.class, "commandCount");
|
||||
public static final PlaceholderKey<Integer> COMMAND_COUNT_UNIQUE = new PlaceholderKey<>(Integer.class, "commandUniqueCount");
|
||||
//
|
||||
public static final PlaceholderKey<Integer> PLAYERS_DAY = CommonPlaceholderKeys.PLAYERS_DAY;
|
||||
public static final PlaceholderKey<Integer> PLAYERS_WEEK = CommonPlaceholderKeys.PLAYERS_WEEK;
|
||||
public static final PlaceholderKey<Integer> PLAYERS_MONTH = CommonPlaceholderKeys.PLAYERS_MONTH;
|
||||
public static final PlaceholderKey<Integer> PLAYERS_NEW_DAY = CommonPlaceholderKeys.PLAYERS_NEW_DAY;
|
||||
public static final PlaceholderKey<Integer> PLAYERS_NEW_WEEK = CommonPlaceholderKeys.PLAYERS_NEW_WEEK;
|
||||
public static final PlaceholderKey<Integer> PLAYERS_NEW_MONTH = CommonPlaceholderKeys.PLAYERS_NEW_MONTH;
|
||||
public static final PlaceholderKey<Integer> AVG_PLAYERS = new PlaceholderKey<>(Integer.class, "playersAverage");
|
||||
public static final PlaceholderKey<Integer> AVG_PLAYERS_DAY = new PlaceholderKey<>(Integer.class, "playersAverageDay");
|
||||
public static final PlaceholderKey<Integer> AVG_PLAYERS_WEEK = new PlaceholderKey<>(Integer.class, "playersAverageWeek");
|
||||
public static final PlaceholderKey<Integer> AVG_PLAYERS_MONTH = new PlaceholderKey<>(Integer.class, "playersAverageMonth");
|
||||
public static final PlaceholderKey<Integer> AVG_PLAYERS_NEW = new PlaceholderKey<>(Integer.class, "playersNewAverage");
|
||||
public static final PlaceholderKey<Integer> AVG_PLAYERS_NEW_DAY = new PlaceholderKey<>(Integer.class, "playersNewAverageDay");
|
||||
public static final PlaceholderKey<Integer> AVG_PLAYERS_NEW_WEEK = new PlaceholderKey<>(Integer.class, "playersNewAverageWeek");
|
||||
public static final PlaceholderKey<Integer> AVG_PLAYERS_NEW_MONTH = new PlaceholderKey<>(Integer.class, "playersNewAverageMonth");
|
||||
public static final PlaceholderKey<Integer> PLAYERS_RETAINED_DAY = new PlaceholderKey<>(Integer.class, "playersStuckDay");
|
||||
public static final PlaceholderKey<String> PLAYERS_RETAINED_DAY_PERC = new PlaceholderKey<>(String.class, "playersStuckPercDay");
|
||||
public static final PlaceholderKey<Integer> PLAYERS_RETAINED_WEEK = new PlaceholderKey<>(Integer.class, "playersStuckWeek");
|
||||
public static final PlaceholderKey<String> PLAYERS_RETAINED_WEEK_PERC = new PlaceholderKey<>(String.class, "playersStuckPercWeek");
|
||||
public static final PlaceholderKey<Integer> PLAYERS_RETAINED_MONTH = new PlaceholderKey<>(Integer.class, "playersStuckMonth");
|
||||
public static final PlaceholderKey<String> PLAYERS_RETAINED_MONTH_PERC = new PlaceholderKey<>(String.class, "playersStuckPercMonth");
|
||||
//
|
||||
public static final PlaceholderKey<Integer> TPS_SPIKE_MONTH = new PlaceholderKey<>(Integer.class, "tpsSpikeMonth");
|
||||
public static final PlaceholderKey<Integer> TPS_SPIKE_WEEK = new PlaceholderKey<>(Integer.class, "tpsSpikeWeek");
|
||||
public static final PlaceholderKey<Integer> TPS_SPIKE_DAY = new PlaceholderKey<>(Integer.class, "tpsSpikeDay");
|
||||
public static final PlaceholderKey<Double> AVG_TPS_MONTH = new PlaceholderKey<>(Double.class, "tpsAverageMonth");
|
||||
public static final PlaceholderKey<Double> AVG_TPS_WEEK = new PlaceholderKey<>(Double.class, "tpsAverageWeek");
|
||||
public static final PlaceholderKey<Double> AVG_TPS_DAY = new PlaceholderKey<>(Double.class, "tpsAverageDay");
|
||||
public static final PlaceholderKey<Double> AVG_CPU_MONTH = new PlaceholderKey<>(Double.class, "cpuAverageMonth");
|
||||
public static final PlaceholderKey<Double> AVG_CPU_WEEK = new PlaceholderKey<>(Double.class, "cpuAverageWeek");
|
||||
public static final PlaceholderKey<Double> AVG_CPU_DAY = new PlaceholderKey<>(Double.class, "cpuAverageDay");
|
||||
public static final PlaceholderKey<Double> AVG_RAM_MONTH = new PlaceholderKey<>(Double.class, "ramAverageMonth");
|
||||
public static final PlaceholderKey<Double> AVG_RAM_WEEK = new PlaceholderKey<>(Double.class, "ramAverageWeek");
|
||||
public static final PlaceholderKey<Double> AVG_RAM_DAY = new PlaceholderKey<>(Double.class, "ramAverageDay");
|
||||
public static final PlaceholderKey<Double> AVG_ENTITY_MONTH = new PlaceholderKey<>(Double.class, "entityAverageMonth");
|
||||
public static final PlaceholderKey<Double> AVG_ENTITY_WEEK = new PlaceholderKey<>(Double.class, "entityAverageWeek");
|
||||
public static final PlaceholderKey<Double> AVG_ENTITY_DAY = new PlaceholderKey<>(Double.class, "entityAverageDay");
|
||||
public static final PlaceholderKey<Double> AVG_CHUNK_MONTH = new PlaceholderKey<>(Double.class, "chunkAverageMonth");
|
||||
public static final PlaceholderKey<Double> AVG_CHUNK_WEEK = new PlaceholderKey<>(Double.class, "chunkAverageWeek");
|
||||
public static final PlaceholderKey<Double> AVG_CHUNK_DAY = new PlaceholderKey<>(Double.class, "chunkAverageDay");
|
||||
public static final PlaceholderKey<Double> AVG_FREE_DISK_MONTH = new PlaceholderKey<>(Double.class, "freeDiskAverageMonth");
|
||||
public static final PlaceholderKey<Double> AVG_FREE_DISK_WEEK = new PlaceholderKey<>(Double.class, "freeDiskAverageWeek");
|
||||
public static final PlaceholderKey<Double> AVG_FREE_DISK_DAY = new PlaceholderKey<>(Double.class, "freeDiskAverageDay");
|
||||
public static final PlaceholderKey<Long> MAX_FREE_DISK_MONTH = new PlaceholderKey<>(Long.class, "freeDiskMaximumMonth");
|
||||
public static final PlaceholderKey<Long> MAX_FREE_DISK_WEEK = new PlaceholderKey<>(Long.class, "freeDiskMaximumWeek");
|
||||
public static final PlaceholderKey<Long> MAX_FREE_DISK_DAY = new PlaceholderKey<>(Long.class, "freeDiskMaximumDay");
|
||||
public static final PlaceholderKey<Long> MIN_FREE_DISK_MONTH = new PlaceholderKey<>(Long.class, "freeDiskMinimumMonth");
|
||||
public static final PlaceholderKey<Long> MIN_FREE_DISK_WEEK = new PlaceholderKey<>(Long.class, "freeDiskMinimumWeek");
|
||||
public static final PlaceholderKey<Long> MIN_FREE_DISK_DAY = new PlaceholderKey<>(Long.class, "freeDiskMinimumDay");
|
||||
// Data for Charts
|
||||
public static final PlaceholderKey<String> WORLD_PIE_SERIES = new PlaceholderKey<>(String.class, "worldSeries");
|
||||
public static final PlaceholderKey<String> GM_PIE_SERIES = new PlaceholderKey<>(String.class, "gmSeries");
|
||||
public static final PlaceholderKey<String> PLAYERS_ONLINE_SERIES = CommonPlaceholderKeys.PLAYERS_ONLINE_SERIES;
|
||||
public static final PlaceholderKey<String> TPS_SERIES = new PlaceholderKey<>(String.class, "tpsSeries");
|
||||
public static final PlaceholderKey<String> CPU_SERIES = new PlaceholderKey<>(String.class, "cpuSeries");
|
||||
public static final PlaceholderKey<String> RAM_SERIES = new PlaceholderKey<>(String.class, "ramSeries");
|
||||
public static final PlaceholderKey<String> ENTITY_SERIES = new PlaceholderKey<>(String.class, "entitySeries");
|
||||
public static final PlaceholderKey<String> CHUNK_SERIES = new PlaceholderKey<>(String.class, "chunkSeries");
|
||||
public static final PlaceholderKey<String> DISK_SERIES = new PlaceholderKey<>(String.class, "diskSeries");
|
||||
public static final PlaceholderKey<String> PUNCHCARD_SERIES = new PlaceholderKey<>(String.class, "punchCardSeries");
|
||||
public static final PlaceholderKey<String> WORLD_MAP_SERIES = CommonPlaceholderKeys.WORLD_MAP_SERIES;
|
||||
public static final PlaceholderKey<String> ACTIVITY_STACK_SERIES = CommonPlaceholderKeys.ACTIVITY_STACK_SERIES;
|
||||
public static final PlaceholderKey<String> ACTIVITY_STACK_CATEGORIES = CommonPlaceholderKeys.ACTIVITY_STACK_CATEGORIES;
|
||||
public static final PlaceholderKey<String> ACTIVITY_PIE_SERIES = CommonPlaceholderKeys.ACTIVITY_PIE_SERIES;
|
||||
public static final PlaceholderKey<String> CALENDAR_SERIES = new PlaceholderKey<>(String.class, "calendarSeries");
|
||||
public static final PlaceholderKey<String> UNIQUE_PLAYERS_SERIES = new PlaceholderKey<>(String.class, "uniquePlayersSeries");
|
||||
public static final PlaceholderKey<String> NEW_PLAYERS_SERIES = new PlaceholderKey<>(String.class, "newPlayersSeries");
|
||||
public static final PlaceholderKey<String> AVG_PING_SERIES = new PlaceholderKey<>(String.class, "avgPingSeries");
|
||||
public static final PlaceholderKey<String> MAX_PING_SERIES = new PlaceholderKey<>(String.class, "maxPingSeries");
|
||||
public static final PlaceholderKey<String> MIN_PING_SERIES = new PlaceholderKey<>(String.class, "minPingSeries");
|
||||
public static final PlaceholderKey<String> COUNTRY_CATEGORIES = CommonPlaceholderKeys.COUNTRY_CATEGORIES;
|
||||
public static final PlaceholderKey<String> COUNTRY_SERIES = CommonPlaceholderKeys.COUNTRY_SERIES;
|
||||
// Variables used only during analysis
|
||||
public static final Key<SessionsMutator> SESSIONS_MUTATOR = CommonKeys.SESSIONS_MUTATOR;
|
||||
public static final Key<TPSMutator> TPS_MUTATOR = CommonKeys.TPS_MUTATOR;
|
||||
public static final Key<PlayersMutator> PLAYERS_MUTATOR = CommonKeys.PLAYERS_MUTATOR;
|
||||
public static final Key<PlayersOnlineResolver> PLAYERS_ONLINE_RESOLVER = new Key<>(PlayersOnlineResolver.class, "PLAYERS_ONLINE_RESOLVER");
|
||||
public static final Key<Long> PLAYTIME_TOTAL = new Key<>(Long.class, "PLAYTIME_TOTAL");
|
||||
public static final Key<Long> ANALYSIS_TIME = new Key<>(Long.class, "ANALYSIS_TIME");
|
||||
public static final Key<Long> ANALYSIS_TIME_DAY_AGO = new Key<>(Long.class, "ANALYSIS_TIME_DAY_AGO");
|
||||
public static final Key<Long> ANALYSIS_TIME_WEEK_AGO = new Key<>(Long.class, "ANALYSIS_TIME_WEEK_AGO");
|
||||
public static final Key<Long> ANALYSIS_TIME_MONTH_AGO = new Key<>(Long.class, "ANALYSIS_TIME_MONTH_AGO");
|
||||
public static final Key<Map<UUID, String>> PLAYER_NAMES = new Key<>(new Type<Map<UUID, String>>() {
|
||||
}, "PLAYER_NAMES");
|
||||
public static final Key<TreeMap<Long, Map<String, Set<UUID>>>> ACTIVITY_DATA = CommonKeys.ACTIVITY_DATA;
|
||||
public static final Key<TreeMap<Long, Integer>> UNIQUE_PLAYERS_PER_DAY = new Key<>(new Type<TreeMap<Long, Integer>>() {
|
||||
}, "UNIQUE_PLAYERS_PER_DAY");
|
||||
public static final Key<TreeMap<Long, Integer>> NEW_PLAYERS_PER_DAY = new Key<>(new Type<TreeMap<Long, Integer>>() {
|
||||
}, "NEW_PLAYERS_PER_DAY");
|
||||
|
||||
private AnalysisKeys() {
|
||||
/* Static variable class */
|
||||
}
|
||||
|
@ -24,7 +24,6 @@ package com.djrapitops.plan.delivery.domain.keys;
|
||||
*/
|
||||
class CommonPlaceholderKeys {
|
||||
|
||||
static final PlaceholderKey<String> VERSION = new PlaceholderKey<>(String.class, "version");
|
||||
static final PlaceholderKey<Integer> TIME_ZONE = new PlaceholderKey<>(Integer.class, "timeZone");
|
||||
static final PlaceholderKey<String> PLAYERS_GRAPH_COLOR = new PlaceholderKey<>(String.class, "playersGraphColor");
|
||||
static final PlaceholderKey<String> PLAYERS_ONLINE_SERIES = new PlaceholderKey<>(String.class, "playersOnlineSeries");
|
||||
|
@ -30,11 +30,6 @@ public class PlaceholderKey<T> extends Key<T> {
|
||||
this.placeholder = placeholder;
|
||||
}
|
||||
|
||||
public PlaceholderKey(Type<T> type, String placeholder) {
|
||||
super(type, placeholder);
|
||||
this.placeholder = placeholder;
|
||||
}
|
||||
|
||||
public String getPlaceholder() {
|
||||
return placeholder;
|
||||
}
|
||||
|
@ -165,29 +165,15 @@ public class ActivityIndex {
|
||||
|
||||
public String getGroup() {
|
||||
if (value >= VERY_ACTIVE) {
|
||||
return "Very Active";
|
||||
return HtmlLang.INDEX_VERY_ACTIVE.getDefault();
|
||||
} else if (value >= ACTIVE) {
|
||||
return "Active";
|
||||
return HtmlLang.INDEX_ACTIVE.getDefault();
|
||||
} else if (value >= REGULAR) {
|
||||
return "Regular";
|
||||
return HtmlLang.INDEX_REGULAR.getDefault();
|
||||
} else if (value >= IRREGULAR) {
|
||||
return "Irregular";
|
||||
return HtmlLang.INDEX_IRREGULAR.getDefault();
|
||||
} else {
|
||||
return "Inactive";
|
||||
}
|
||||
}
|
||||
|
||||
public String getColor() {
|
||||
if (value >= VERY_ACTIVE) {
|
||||
return "green";
|
||||
} else if (value >= ACTIVE) {
|
||||
return "green";
|
||||
} else if (value >= REGULAR) {
|
||||
return "lime";
|
||||
} else if (value >= IRREGULAR) {
|
||||
return "amber";
|
||||
} else {
|
||||
return "blue-gray";
|
||||
return HtmlLang.INDEX_INACTIVE.getDefault();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -30,12 +30,6 @@ public class MutatorFunctions {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static List<Point> toPointsWithRemovedOffset(NavigableMap<Long, Integer> map, TimeZone timeZone) {
|
||||
return map.entrySet().stream()
|
||||
.map(entry -> new Point(entry.getKey() - timeZone.getOffset(entry.getKey()), entry.getValue()))
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static NavigableMap<Long, Integer> addMissing(NavigableMap<Long, Integer> points, long accuracy, Integer replacement) {
|
||||
if (Verify.isEmpty(points)) return points;
|
||||
|
||||
|
@ -1,64 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.delivery.domain.mutators;
|
||||
|
||||
import com.djrapitops.plan.delivery.domain.container.DataContainer;
|
||||
import com.djrapitops.plan.delivery.domain.container.PerServerContainer;
|
||||
import com.djrapitops.plan.delivery.domain.container.PlayerContainer;
|
||||
import com.djrapitops.plan.delivery.domain.keys.CommonKeys;
|
||||
import com.djrapitops.plan.delivery.domain.keys.PlayerKeys;
|
||||
|
||||
import java.util.*;
|
||||
|
||||
public class NetworkPerServerMutator {
|
||||
|
||||
private final Map<UUID, List<DataContainer>> perServerContainers;
|
||||
|
||||
public NetworkPerServerMutator(PlayersMutator playersMutator) {
|
||||
this.perServerContainers = perServerContainers(playersMutator);
|
||||
}
|
||||
|
||||
public static NetworkPerServerMutator forContainer(DataContainer container) {
|
||||
return new NetworkPerServerMutator(
|
||||
container.getValue(CommonKeys.PLAYERS_MUTATOR)
|
||||
.orElse(PlayersMutator.forContainer(container))
|
||||
);
|
||||
}
|
||||
|
||||
public Map<UUID, List<DataContainer>> getPerServerContainers() {
|
||||
return perServerContainers;
|
||||
}
|
||||
|
||||
private Map<UUID, List<DataContainer>> perServerContainers(PlayersMutator playersMutator) {
|
||||
Map<UUID, List<DataContainer>> dataContainerMap = new HashMap<>();
|
||||
|
||||
for (PlayerContainer playerContainer : playersMutator.all()) {
|
||||
UUID uuid = playerContainer.getUnsafe(PlayerKeys.UUID);
|
||||
PerServerContainer perServerContainer = playerContainer.getValue(PlayerKeys.PER_SERVER).orElse(new PerServerContainer());
|
||||
for (Map.Entry<UUID, DataContainer> entry : perServerContainer.entrySet()) {
|
||||
UUID serverUUID = entry.getKey();
|
||||
DataContainer container = entry.getValue();
|
||||
container.putRawData(PlayerKeys.UUID, uuid);
|
||||
List<DataContainer> dataContainers = dataContainerMap.getOrDefault(serverUUID, new ArrayList<>());
|
||||
dataContainers.add(container);
|
||||
dataContainerMap.put(serverUUID, dataContainers);
|
||||
}
|
||||
}
|
||||
|
||||
return dataContainerMap;
|
||||
}
|
||||
}
|
@ -67,6 +67,16 @@ public class PlayerVersusMutator {
|
||||
return sessionsMutator.toMobKillCount();
|
||||
}
|
||||
|
||||
public double toKillDeathRatio() {
|
||||
int deathCount = toPlayerDeathCount();
|
||||
return toPlayerKillCount() * 1.0 / (deathCount != 0 ? deathCount : 1);
|
||||
}
|
||||
|
||||
public double toMobKillDeathRatio() {
|
||||
int deathCount = toMobDeathCount();
|
||||
return toMobKillCount() * 1.0 / (deathCount != 0 ? deathCount : 1);
|
||||
}
|
||||
|
||||
public int toPlayerDeathCount() {
|
||||
return deaths.size();
|
||||
}
|
||||
|
@ -38,7 +38,7 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
public class PlayersMutator {
|
||||
|
||||
private List<PlayerContainer> players;
|
||||
private final List<PlayerContainer> players;
|
||||
|
||||
public PlayersMutator(List<PlayerContainer> players) {
|
||||
this.players = players;
|
||||
|
@ -1,73 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.delivery.domain.mutators;
|
||||
|
||||
import com.djrapitops.plan.delivery.domain.container.DataContainer;
|
||||
import com.djrapitops.plan.gathering.domain.Session;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class PvpInfoMutator {
|
||||
|
||||
private final SessionsMutator sessionsMutator;
|
||||
|
||||
private PvpInfoMutator(SessionsMutator sessionsMutator) {
|
||||
this.sessionsMutator = sessionsMutator;
|
||||
}
|
||||
|
||||
public PvpInfoMutator(List<Session> sessions) {
|
||||
this(new SessionsMutator(sessions));
|
||||
}
|
||||
|
||||
public static PvpInfoMutator forContainer(DataContainer container) {
|
||||
return new PvpInfoMutator(SessionsMutator.forContainer(container));
|
||||
}
|
||||
|
||||
public static PvpInfoMutator forMutator(SessionsMutator sessionsMutator) {
|
||||
return new PvpInfoMutator(sessionsMutator);
|
||||
}
|
||||
|
||||
public double killDeathRatio() {
|
||||
int deathCount = sessionsMutator.toPlayerDeathCount();
|
||||
return sessionsMutator.toPlayerKillCount() * 1.0 / (deathCount != 0 ? deathCount : 1);
|
||||
}
|
||||
|
||||
public int mobCausedDeaths() {
|
||||
return sessionsMutator.toDeathCount() - sessionsMutator.toPlayerDeathCount();
|
||||
}
|
||||
|
||||
public double mobKillDeathRatio() {
|
||||
int deathCount = mobCausedDeaths();
|
||||
return sessionsMutator.toMobKillCount() * 1.0 / (deathCount != 0 ? deathCount : 1);
|
||||
}
|
||||
|
||||
public int mobKills() {
|
||||
return sessionsMutator.toMobKillCount();
|
||||
}
|
||||
|
||||
public int playerKills() {
|
||||
return sessionsMutator.toPlayerKillCount();
|
||||
}
|
||||
|
||||
public int deaths() {
|
||||
return sessionsMutator.toDeathCount();
|
||||
}
|
||||
|
||||
public int playerCausedDeaths() {
|
||||
return sessionsMutator.toPlayerDeathCount();
|
||||
}
|
||||
}
|
@ -33,7 +33,7 @@ import java.util.concurrent.TimeUnit;
|
||||
*/
|
||||
public class RetentionData {
|
||||
private final double activityIndex;
|
||||
private double onlineOnJoin;
|
||||
private final double onlineOnJoin;
|
||||
|
||||
public static RetentionData average(Collection<RetentionData> stuck) {
|
||||
int size = stuck.size();
|
||||
|
@ -22,7 +22,6 @@ import com.djrapitops.plan.delivery.domain.keys.SessionKeys;
|
||||
import com.djrapitops.plan.delivery.formatting.Formatters;
|
||||
import com.djrapitops.plan.delivery.rendering.json.graphs.Graphs;
|
||||
import com.djrapitops.plan.delivery.rendering.json.graphs.pie.WorldPie;
|
||||
import com.djrapitops.plan.gathering.domain.PlayerDeath;
|
||||
import com.djrapitops.plan.gathering.domain.PlayerKill;
|
||||
import com.djrapitops.plan.gathering.domain.Session;
|
||||
import com.djrapitops.plan.gathering.domain.WorldTimes;
|
||||
@ -43,7 +42,7 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
public class SessionsMutator {
|
||||
|
||||
private List<Session> sessions;
|
||||
private final List<Session> sessions;
|
||||
|
||||
public static SessionsMutator forContainer(DataContainer container) {
|
||||
return new SessionsMutator(container.getValue(CommonKeys.SESSIONS).orElse(new ArrayList<>()));
|
||||
@ -101,14 +100,6 @@ public class SessionsMutator {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
/**
|
||||
* @deprecated Incorrect results.
|
||||
*/
|
||||
@Deprecated
|
||||
public List<PlayerDeath> toPlayerDeathList() {
|
||||
return Collections.emptyList();
|
||||
}
|
||||
|
||||
public int toMobKillCount() {
|
||||
return sessions.stream()
|
||||
.mapToInt(session -> session.getValue(SessionKeys.MOB_KILL_COUNT).orElse(0))
|
||||
@ -170,25 +161,6 @@ public class SessionsMutator {
|
||||
return (long) Median.forList(sessionLengths).calculate();
|
||||
}
|
||||
|
||||
public int toAverageUniqueJoinsPerDay(TimeZone timeZone) {
|
||||
return MutatorFunctions.average(uniqueJoinsPerDay(timeZone));
|
||||
}
|
||||
|
||||
public TreeMap<Long, Integer> uniqueJoinsPerDay(TimeZone timeZone) {
|
||||
// Adds Timezone offset
|
||||
SortedMap<Long, List<Session>> byStartOfDay = toDateHoldersMutator().groupByStartOfDay(timeZone);
|
||||
|
||||
TreeMap<Long, Integer> uniqueJoins = new TreeMap<>();
|
||||
for (Map.Entry<Long, List<Session>> entry : byStartOfDay.entrySet()) {
|
||||
uniqueJoins.put(
|
||||
entry.getKey(),
|
||||
new SessionsMutator(entry.getValue()).toUniquePlayers()
|
||||
);
|
||||
}
|
||||
|
||||
return uniqueJoins;
|
||||
}
|
||||
|
||||
public int toUniquePlayers() {
|
||||
return (int) sessions.stream()
|
||||
.map(session -> session.getUnsafe(SessionKeys.UUID))
|
||||
|
@ -38,7 +38,7 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
public class TPSMutator {
|
||||
|
||||
private List<TPS> tpsData;
|
||||
private final List<TPS> tpsData;
|
||||
|
||||
public TPSMutator(List<TPS> tpsData) {
|
||||
this.tpsData = tpsData;
|
||||
|
@ -28,8 +28,8 @@ import java.util.List;
|
||||
*/
|
||||
public class ExportPaths {
|
||||
|
||||
private List<String> replace;
|
||||
private List<String> with;
|
||||
private final List<String> replace;
|
||||
private final List<String> with;
|
||||
|
||||
public ExportPaths() {
|
||||
replace = new ArrayList<>();
|
||||
|
@ -41,19 +41,6 @@ public class PlaceholderReplacer extends HashMap<String, Serializable> implement
|
||||
}
|
||||
}
|
||||
|
||||
public <T> void addPlaceholderFrom(DataContainer container, Formatter<T> formatter, PlaceholderKey<T> key) {
|
||||
if (!container.supports(key)) {
|
||||
return;
|
||||
}
|
||||
put(key.getPlaceholder(), container.getFormattedUnsafe(key, formatter));
|
||||
}
|
||||
|
||||
public <T> void addAllPlaceholdersFrom(DataContainer container, Formatter<T> formatter, PlaceholderKey<T>... keys) {
|
||||
for (PlaceholderKey<T> key : keys) {
|
||||
addPlaceholderFrom(container, formatter, key);
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public String apply(String string) {
|
||||
StringSubstitutor sub = new StringSubstitutor(this);
|
||||
|
@ -47,16 +47,6 @@ public enum Color {
|
||||
this.htmlClass = htmlClass;
|
||||
}
|
||||
|
||||
public static Color matchString(String name) {
|
||||
String lowerCaseName = name.toLowerCase();
|
||||
for (Color color : values()) {
|
||||
if (color.htmlClass.contains(lowerCaseName)) {
|
||||
return color;
|
||||
}
|
||||
}
|
||||
return Color.BLACK;
|
||||
}
|
||||
|
||||
public static Optional<Color> getByName(String name) {
|
||||
if (name == null) {
|
||||
return Optional.empty();
|
||||
|
@ -1,49 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.delivery.rendering.html.icon;
|
||||
|
||||
/**
|
||||
* Class that contains commonly used {@link Icon}s.
|
||||
*
|
||||
* @see Icon
|
||||
*/
|
||||
public class Icons {
|
||||
|
||||
public static final Icon PLAYTIME = Icon.called("clock").of(Color.GREEN).of(Family.REGULAR).build();
|
||||
public static final Icon SESSION_LENGTH = Icon.called("clock").of(Color.TEAL).of(Family.REGULAR).build();
|
||||
public static final Icon AFK_LENGTH = Icon.called("clock").of(Color.GREY).of(Family.REGULAR).build();
|
||||
public static final Icon PLAYER_KILLS = Icon.called("crosshairs").of(Color.RED).build();
|
||||
public static final Icon MOB_KILLS = Icon.called("crosshairs").of(Color.GREEN).build();
|
||||
public static final Icon DEATHS = Icon.called("skull").build();
|
||||
public static final Icon SESSION_COUNT = Icon.called("calendar-check").of(Color.TEAL).of(Family.REGULAR).build();
|
||||
public static final Icon OPERATOR = Icon.called("superpowers").of(Color.BLUE).of(Family.BRAND).build();
|
||||
public static final Icon BANNED = Icon.called("gavel").of(Color.RED).build();
|
||||
public static final Icon SERVER = Icon.called("server").of(Color.GREEN).build();
|
||||
public static final Icon SIGNAL = Icon.called("signal").build();
|
||||
|
||||
public static final Icon GREEN_THUMB = Icon.called("thumbs-up").of(Color.GREEN).build();
|
||||
public static final Icon YELLOW_FLAG = Icon.called("flag").of(Color.AMBER).build();
|
||||
public static final Icon RED_WARN = Icon.called("exclamation-circle").of(Color.RED).build();
|
||||
public static final Icon GREEN_PLUS = Icon.called("plus").of(Color.GREEN).build();
|
||||
public static final Icon RED_MINUS = Icon.called("minus").of(Color.RED).build();
|
||||
public static final Icon HELP_RING = Icon.called("life-ring").of(Color.RED).of(Family.REGULAR).build();
|
||||
|
||||
private Icons() {
|
||||
/* Static variable class */
|
||||
}
|
||||
|
||||
}
|
@ -48,12 +48,12 @@ import java.util.concurrent.TimeUnit;
|
||||
@Singleton
|
||||
public class OnlineActivityOverviewJSONParser implements ServerTabJSONParser<Map<String, Object>> {
|
||||
|
||||
private PlanConfig config;
|
||||
private DBSystem dbSystem;
|
||||
private final PlanConfig config;
|
||||
private final DBSystem dbSystem;
|
||||
|
||||
private Formatter<Long> timeAmountFormatter;
|
||||
private Formatter<Double> decimalFormatter;
|
||||
private Formatter<Double> percentageFormatter;
|
||||
private final Formatter<Long> timeAmountFormatter;
|
||||
private final Formatter<Double> decimalFormatter;
|
||||
private final Formatter<Double> percentageFormatter;
|
||||
private final TimeZone timeZone;
|
||||
|
||||
@Inject
|
||||
|
@ -41,11 +41,11 @@ import java.util.concurrent.TimeUnit;
|
||||
@Singleton
|
||||
public class PlayerBaseOverviewJSONParser implements ServerTabJSONParser<Map<String, Object>> {
|
||||
|
||||
private PlanConfig config;
|
||||
private DBSystem dbSystem;
|
||||
private final PlanConfig config;
|
||||
private final DBSystem dbSystem;
|
||||
|
||||
private Formatter<Long> timeAmount;
|
||||
private Formatter<Double> percentage;
|
||||
private final Formatter<Long> timeAmount;
|
||||
private final Formatter<Double> percentage;
|
||||
|
||||
@Inject
|
||||
public PlayerBaseOverviewJSONParser(
|
||||
|
@ -264,9 +264,9 @@ public class PlayerJSONParser {
|
||||
}
|
||||
|
||||
public static class Nickname {
|
||||
private String nickname;
|
||||
private String server;
|
||||
private String date;
|
||||
private final String nickname;
|
||||
private final String server;
|
||||
private final String date;
|
||||
|
||||
public Nickname(String nickname, String server, String date) {
|
||||
this.nickname = nickname;
|
||||
@ -293,8 +293,8 @@ public class PlayerJSONParser {
|
||||
}
|
||||
|
||||
public static class ConnectionInfo {
|
||||
private String geolocation;
|
||||
private String date;
|
||||
private final String geolocation;
|
||||
private final String date;
|
||||
|
||||
public ConnectionInfo(String geolocation, String date) {
|
||||
this.geolocation = geolocation;
|
||||
|
@ -49,9 +49,9 @@ public class PlayersTableJSONParser {
|
||||
|
||||
private final boolean openPlayerPageInNewTab;
|
||||
|
||||
private Map<FormatType, Formatter<Long>> numberFormatters;
|
||||
private final Map<FormatType, Formatter<Long>> numberFormatters;
|
||||
|
||||
private Formatter<Double> decimalFormatter;
|
||||
private final Formatter<Double> decimalFormatter;
|
||||
|
||||
public PlayersTableJSONParser(
|
||||
List<TablePlayer> players,
|
||||
@ -116,7 +116,7 @@ public class PlayersTableJSONParser {
|
||||
dataJSON.append('{'); // Start new item
|
||||
|
||||
appendPlayerData(dataJSON, player);
|
||||
appendExtensionData(dataJSON, extensionData.getOrDefault(playerUUID, new ExtensionTabData.Factory(null).build()));
|
||||
appendExtensionData(dataJSON, extensionData.getOrDefault(playerUUID, new ExtensionTabData.Builder(null).build()));
|
||||
|
||||
dataJSON.append('}'); // Close new item
|
||||
|
||||
|
@ -35,9 +35,9 @@ import java.util.concurrent.TimeUnit;
|
||||
@Singleton
|
||||
public class PvPPvEJSONParser implements ServerTabJSONParser<Map<String, Object>> {
|
||||
|
||||
private DBSystem dbSystem;
|
||||
private final DBSystem dbSystem;
|
||||
|
||||
private Formatter<Double> decimals;
|
||||
private final Formatter<Double> decimals;
|
||||
|
||||
@Inject
|
||||
public PvPPvEJSONParser(
|
||||
|
@ -41,10 +41,10 @@ import java.util.concurrent.TimeUnit;
|
||||
@Singleton
|
||||
public class SessionsOverviewJSONParser implements ServerTabJSONParser<Map<String, Object>> {
|
||||
|
||||
private DBSystem dbSystem;
|
||||
private final DBSystem dbSystem;
|
||||
|
||||
private Formatter<Long> timeAmount;
|
||||
private Formatter<Double> percentage;
|
||||
private final Formatter<Long> timeAmount;
|
||||
private final Formatter<Double> percentage;
|
||||
|
||||
@Inject
|
||||
public SessionsOverviewJSONParser(
|
||||
|
@ -30,9 +30,9 @@ public class Trend {
|
||||
*/
|
||||
public static final boolean REVERSED = true;
|
||||
|
||||
private String text;
|
||||
private String direction;
|
||||
private boolean reversed;
|
||||
private final String text;
|
||||
private final String direction;
|
||||
private final boolean reversed;
|
||||
|
||||
public Trend(long before, long after, boolean reversed) {
|
||||
long difference = Math.abs(before - after);
|
||||
|
@ -1,58 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.delivery.rendering.json.graphs;
|
||||
|
||||
import com.djrapitops.plan.delivery.formatting.Formatter;
|
||||
|
||||
/**
|
||||
* Utility for creating Progress bars.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class ProgressBar {
|
||||
|
||||
private final int obtained;
|
||||
private final int max;
|
||||
|
||||
private final Formatter<Double> percentageFormatter;
|
||||
|
||||
private final String color;
|
||||
|
||||
public ProgressBar(int obtained, int max, Formatter<Double> percentageFormatter) {
|
||||
this(obtained, max, "teal", percentageFormatter);
|
||||
}
|
||||
|
||||
public ProgressBar(int obtained, int max, String color, Formatter<Double> percentageFormatter) {
|
||||
this.obtained = obtained;
|
||||
this.max = max;
|
||||
this.color = color;
|
||||
this.percentageFormatter = percentageFormatter;
|
||||
}
|
||||
|
||||
public String toHtml() {
|
||||
double percentage = obtained * 1.0 / max;
|
||||
int percentageRounded = (int) percentage;
|
||||
|
||||
return "<div class=\"progress\"><div class=\"progress-bar bg-" + color + "\" role=\"progressbar\"" +
|
||||
" aria-valuenow=\"" + obtained + "\"" +
|
||||
" aria-valuemin=\"0\" aria-valuemax=\"" + max + "\"" +
|
||||
" style=\"width: " + percentageRounded + "%;\">" +
|
||||
obtained + " / " + max + " (" + percentageFormatter.apply(percentage) + ")" +
|
||||
"</div></div>";
|
||||
}
|
||||
|
||||
}
|
@ -16,12 +16,9 @@
|
||||
*/
|
||||
package com.djrapitops.plan.delivery.rendering.json.graphs.bar;
|
||||
|
||||
import com.djrapitops.plan.delivery.rendering.json.graphs.HighChart;
|
||||
import org.apache.commons.text.TextStringBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
public class BarGraph implements HighChart {
|
||||
public class BarGraph {
|
||||
|
||||
private final List<Bar> bars;
|
||||
|
||||
@ -33,16 +30,4 @@ public class BarGraph implements HighChart {
|
||||
return bars;
|
||||
}
|
||||
|
||||
public String toHighChartsCategories() {
|
||||
TextStringBuilder categories = new TextStringBuilder("[");
|
||||
categories.appendWithSeparators(bars.stream().map(bar -> "'" + bar.getLabel() + "'").iterator(), ",");
|
||||
return categories.append("]").toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toHighChartsSeries() {
|
||||
TextStringBuilder series = new TextStringBuilder("[");
|
||||
series.appendWithSeparators(bars.stream().map(Bar::getValue).iterator(), ",");
|
||||
return series.append("]").toString();
|
||||
}
|
||||
}
|
||||
|
@ -16,8 +16,6 @@
|
||||
*/
|
||||
package com.djrapitops.plan.delivery.rendering.json.graphs.bar;
|
||||
|
||||
import com.djrapitops.plan.delivery.domain.mutators.PlayersMutator;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
import java.util.Map;
|
||||
@ -34,10 +32,6 @@ public class BarGraphFactory {
|
||||
// Inject Constructor.
|
||||
}
|
||||
|
||||
public BarGraph geolocationBarGraph(PlayersMutator playersMutator) {
|
||||
return new GeolocationBarGraph(playersMutator);
|
||||
}
|
||||
|
||||
public BarGraph geolocationBarGraph(Map<String, Integer> geolocationCounts) {
|
||||
return new GeolocationBarGraph(geolocationCounts);
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ import java.io.Serializable;
|
||||
import java.util.Optional;
|
||||
|
||||
/**
|
||||
* Represents an entry for calendar.
|
||||
* Represents an entry for FullCalendar json calendar.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
|
@ -119,10 +119,6 @@ public class PlayerCalendar {
|
||||
return entries;
|
||||
}
|
||||
|
||||
public String toCalendarSeries() {
|
||||
return getEntries().toString();
|
||||
}
|
||||
|
||||
private Map<String, List<Session>> getSessionsByDay() {
|
||||
Map<String, List<Session>> sessionsByDay = new HashMap<>();
|
||||
for (Session session : allSessions) {
|
||||
|
@ -1,77 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.delivery.rendering.json.graphs.line;
|
||||
|
||||
/**
|
||||
* This math object is used in Ramer–Douglas–Peucker algorithm.
|
||||
*
|
||||
* https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class Line {
|
||||
|
||||
private final Point start;
|
||||
private final Point end;
|
||||
private final double slope;
|
||||
private final double c;
|
||||
private final double crossPoint;
|
||||
|
||||
public Line(Point one, Point two) {
|
||||
start = one;
|
||||
end = two;
|
||||
double x1 = one.getX();
|
||||
double x2 = two.getX();
|
||||
double y1 = one.getY();
|
||||
double y2 = two.getY();
|
||||
|
||||
slope = (y2 - y1) / (x2 - x1);
|
||||
c = y1 - slope * x1;
|
||||
crossPoint = c / slope;
|
||||
}
|
||||
|
||||
public double getA() {
|
||||
return getSlope();
|
||||
}
|
||||
|
||||
public double getSlope() {
|
||||
return slope;
|
||||
}
|
||||
|
||||
public double getC() {
|
||||
return c;
|
||||
}
|
||||
|
||||
public double getCrossPoint() {
|
||||
return crossPoint;
|
||||
}
|
||||
|
||||
public double getLength() {
|
||||
double x1 = start.getX();
|
||||
double x2 = end.getX();
|
||||
double y1 = start.getY();
|
||||
double y2 = end.getY();
|
||||
return Math.sqrt(Math.pow(x2 - x1, 2) + (Math.pow(y2 - y1, 2)));
|
||||
}
|
||||
|
||||
public double getPerpendicularDistance(Point from) {
|
||||
double a = getA();
|
||||
double x = from.getX();
|
||||
double y = from.getY();
|
||||
return Math.abs(a * x - y + c) / Math.sqrt(Math.pow(a, 2) + 1);
|
||||
}
|
||||
}
|
@ -30,7 +30,7 @@ import java.util.concurrent.TimeUnit;
|
||||
public class LineGraph implements HighChart {
|
||||
|
||||
private final boolean displayGaps;
|
||||
private List<Point> points;
|
||||
private final List<Point> points;
|
||||
|
||||
public LineGraph(List<Point> points, boolean displayGaps) {
|
||||
this.points = points;
|
||||
|
@ -52,18 +52,6 @@ public class PingGraph {
|
||||
avgGraph = new LineGraph(avg, displayGaps);
|
||||
}
|
||||
|
||||
public String toMaxSeries() {
|
||||
return maxGraph.toHighChartsSeries();
|
||||
}
|
||||
|
||||
public String toMinSeries() {
|
||||
return minGraph.toHighChartsSeries();
|
||||
}
|
||||
|
||||
public String toAvgSeries() {
|
||||
return avgGraph.toHighChartsSeries();
|
||||
}
|
||||
|
||||
public LineGraph getMaxGraph() {
|
||||
return maxGraph;
|
||||
}
|
||||
|
@ -1,84 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.delivery.rendering.json.graphs.line.alg;
|
||||
|
||||
import com.djrapitops.plan.delivery.rendering.json.graphs.line.Line;
|
||||
import com.djrapitops.plan.delivery.rendering.json.graphs.line.Point;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Ramer-Douglas-Peucker Point Reduction Algorithm Implementation for reducing points from graphs.
|
||||
*
|
||||
* https://en.wikipedia.org/wiki/Ramer%E2%80%93Douglas%E2%80%93Peucker_algorithm
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class DouglasPeuckerAlgorithm {
|
||||
|
||||
/**
|
||||
* Constructor used to hide the public constructor
|
||||
*/
|
||||
private DouglasPeuckerAlgorithm() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
public static List<Point> reducePoints(List<Point> points, double epsilon) {
|
||||
if (points.isEmpty()) {
|
||||
return points;
|
||||
}
|
||||
|
||||
if (Double.compare(epsilon, -1) == 0) {
|
||||
epsilon = 0.002;
|
||||
}
|
||||
|
||||
int size = points.size();
|
||||
final int lastIndex = size - 1;
|
||||
final Point start = points.get(0);
|
||||
final Point end = points.get(lastIndex);
|
||||
|
||||
// Max distance and it's index.
|
||||
double dMax = 0;
|
||||
int index = 0;
|
||||
for (int i = 1; i < size; i++) {
|
||||
double d = perpendicularDistance(points.get(i), new Line(start, end));
|
||||
if (d > dMax) {
|
||||
dMax = d;
|
||||
index = i;
|
||||
}
|
||||
}
|
||||
|
||||
List<Point> results;
|
||||
if (dMax > epsilon) {
|
||||
List<Point> results1 = reducePoints(points.subList(0, index), epsilon);
|
||||
List<Point> results2 = reducePoints(points.subList(index, lastIndex), epsilon);
|
||||
|
||||
results = new ArrayList<>();
|
||||
results.addAll(results1.subList(0, results1.size() - 1));
|
||||
results.addAll(results2);
|
||||
} else {
|
||||
return Arrays.asList(points.get(0), points.get(lastIndex));
|
||||
}
|
||||
return results;
|
||||
}
|
||||
|
||||
private static double perpendicularDistance(Point point, Line line) {
|
||||
return line.getPerpendicularDistance(point);
|
||||
}
|
||||
}
|
@ -1,74 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.delivery.rendering.json.graphs.line.alg;
|
||||
|
||||
import com.djrapitops.plan.delivery.rendering.json.graphs.line.Point;
|
||||
import com.djrapitops.plan.utilities.comparators.PointComparator;
|
||||
import com.djrapitops.plugin.utilities.Verify;
|
||||
|
||||
import java.util.HashSet;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
/**
|
||||
* Utility for reducing Points in LineGraphs.
|
||||
*
|
||||
* @author Rsl1122 (Refactored into this class by Fuzzlemann)
|
||||
*/
|
||||
public class ReduceGapTriangles {
|
||||
|
||||
/**
|
||||
* Constructor used to hide the public constructor
|
||||
*/
|
||||
private ReduceGapTriangles() {
|
||||
throw new IllegalStateException("Utility class");
|
||||
}
|
||||
|
||||
public static List<Point> reduce(List<Point> points) {
|
||||
Point lastPoint = null;
|
||||
|
||||
Set<Point> toAdd = new HashSet<>();
|
||||
for (Point point : points) {
|
||||
if (!Verify.notNull(point, lastPoint)) {
|
||||
lastPoint = point;
|
||||
continue;
|
||||
}
|
||||
|
||||
assert lastPoint != null;
|
||||
|
||||
long date = (long) point.getX();
|
||||
long lastDate = (long) lastPoint.getX();
|
||||
double y = point.getY();
|
||||
double lastY = lastPoint.getY();
|
||||
|
||||
if (Double.compare(y, lastY) != 0
|
||||
&& Math.abs(lastY - y) > 0.5
|
||||
&& lastDate < date - TimeUnit.MINUTES.toMillis(10L)) {
|
||||
toAdd.add(new Point(lastDate + 1, lastY));
|
||||
toAdd.add(new Point(date - 1, lastY));
|
||||
}
|
||||
|
||||
lastPoint = point;
|
||||
}
|
||||
|
||||
points.addAll(toAdd);
|
||||
points.sort(new PointComparator());
|
||||
|
||||
return points;
|
||||
}
|
||||
}
|
@ -16,9 +16,6 @@
|
||||
*/
|
||||
package com.djrapitops.plan.delivery.rendering.json.graphs.pie;
|
||||
|
||||
import com.djrapitops.plan.delivery.rendering.json.graphs.HighChart;
|
||||
import org.apache.commons.text.TextStringBuilder;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
@ -26,7 +23,7 @@ import java.util.List;
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class Pie implements HighChart {
|
||||
public class Pie {
|
||||
|
||||
protected final List<PieSlice> slices;
|
||||
|
||||
@ -34,13 +31,6 @@ public class Pie implements HighChart {
|
||||
this.slices = slices;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toHighChartsSeries() {
|
||||
TextStringBuilder series = new TextStringBuilder("[");
|
||||
series.appendWithSeparators(slices, ",");
|
||||
return series.append("]").toString();
|
||||
}
|
||||
|
||||
public List<PieSlice> getSlices() {
|
||||
return slices;
|
||||
}
|
||||
|
@ -29,6 +29,4 @@ public abstract class PieWithDrilldown extends Pie {
|
||||
super(slices);
|
||||
}
|
||||
|
||||
public abstract String toHighChartsDrilldown();
|
||||
|
||||
}
|
||||
|
@ -80,34 +80,6 @@ public class WorldPie extends PieWithDrilldown {
|
||||
return data;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toHighChartsDrilldown() {
|
||||
StringBuilder drilldownBuilder = new StringBuilder();
|
||||
int i = 0;
|
||||
|
||||
if (gmTimesAliasMap.isEmpty()) {
|
||||
return "[]";
|
||||
}
|
||||
int size = gmTimesAliasMap.size();
|
||||
|
||||
drilldownBuilder.append("[");
|
||||
for (Map.Entry<String, GMTimes> worldAlias : gmTimesAliasMap.entrySet()) {
|
||||
drilldownBuilder.append("{name:'").append(worldAlias.getKey())
|
||||
.append("', id:'").append(worldAlias.getKey())
|
||||
.append("',colors: gmPieColors,");
|
||||
drilldownBuilder.append("data: [");
|
||||
|
||||
appendGMTimesForWorld(drilldownBuilder, worldAlias);
|
||||
|
||||
if (i < size - 1) {
|
||||
drilldownBuilder.append(",");
|
||||
}
|
||||
i++;
|
||||
}
|
||||
drilldownBuilder.append("]");
|
||||
return drilldownBuilder.toString();
|
||||
}
|
||||
|
||||
private void appendGMTimesForWorld(StringBuilder drilldownBuilder, Map.Entry<String, GMTimes> world) {
|
||||
Map<String, Long> gmTimes = world.getValue().getTimes();
|
||||
int smallSize = gmTimes.size();
|
||||
|
@ -17,7 +17,6 @@
|
||||
package com.djrapitops.plan.delivery.rendering.json.graphs.special;
|
||||
|
||||
import com.djrapitops.plan.delivery.domain.mutators.SessionsMutator;
|
||||
import com.djrapitops.plan.delivery.rendering.json.graphs.HighChart;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Calendar;
|
||||
@ -29,7 +28,7 @@ import java.util.List;
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class PunchCard implements HighChart {
|
||||
public class PunchCard {
|
||||
|
||||
private final SessionsMutator sessions;
|
||||
|
||||
@ -52,10 +51,6 @@ public class PunchCard implements HighChart {
|
||||
day.setTimeInMillis(start);
|
||||
int hourOfDay = day.get(Calendar.HOUR_OF_DAY); // 0 AM is 0
|
||||
int dayOfWeek = day.get(Calendar.DAY_OF_WEEK) - 2; // Monday is 0, Sunday is -1
|
||||
if (hourOfDay == 24) { // If hour is 24 (Should be impossible but.)
|
||||
hourOfDay = 0;
|
||||
dayOfWeek += 1;
|
||||
}
|
||||
if (dayOfWeek > 6) { // If Hour added a day on Sunday, move to Monday
|
||||
dayOfWeek = 0;
|
||||
}
|
||||
@ -77,11 +72,6 @@ public class PunchCard implements HighChart {
|
||||
return matrix;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toHighChartsSeries() {
|
||||
return getDots().toString();
|
||||
}
|
||||
|
||||
public List<Dot> getDots() {
|
||||
List<Dot> dots = new ArrayList<>();
|
||||
|
||||
@ -142,10 +132,10 @@ public class PunchCard implements HighChart {
|
||||
}
|
||||
|
||||
public static class Dot {
|
||||
int x;
|
||||
int y;
|
||||
int z;
|
||||
Marker marker;
|
||||
final int x;
|
||||
final int y;
|
||||
final int z;
|
||||
final Marker marker;
|
||||
|
||||
public Dot(int x, int y, int z, int radius) {
|
||||
this.x = x;
|
||||
@ -165,7 +155,7 @@ public class PunchCard implements HighChart {
|
||||
}
|
||||
|
||||
public static class Marker {
|
||||
int radius;
|
||||
final int radius;
|
||||
|
||||
Marker(int radius) {
|
||||
this.radius = radius;
|
||||
|
@ -16,9 +16,7 @@
|
||||
*/
|
||||
package com.djrapitops.plan.delivery.rendering.json.graphs.special;
|
||||
|
||||
import com.djrapitops.plan.delivery.domain.mutators.PlayersMutator;
|
||||
import com.djrapitops.plan.delivery.domain.mutators.SessionsMutator;
|
||||
import com.djrapitops.plan.delivery.rendering.json.graphs.HighChart;
|
||||
import com.djrapitops.plan.gathering.domain.Session;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@ -51,7 +49,4 @@ public class SpecialGraphFactory {
|
||||
return new WorldMap(geolocationCounts);
|
||||
}
|
||||
|
||||
public HighChart worldMap(PlayersMutator mutator) {
|
||||
return new WorldMap(mutator);
|
||||
}
|
||||
}
|
@ -17,12 +17,11 @@
|
||||
package com.djrapitops.plan.delivery.rendering.json.graphs.special;
|
||||
|
||||
import com.djrapitops.plan.delivery.domain.mutators.PlayersMutator;
|
||||
import com.djrapitops.plan.delivery.rendering.json.graphs.HighChart;
|
||||
import org.apache.commons.text.TextStringBuilder;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.Objects;
|
||||
import java.util.stream.Collectors;
|
||||
|
||||
/**
|
||||
@ -30,7 +29,7 @@ import java.util.stream.Collectors;
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class WorldMap implements HighChart {
|
||||
public class WorldMap {
|
||||
|
||||
private final Map<String, Integer> geoCodeCounts;
|
||||
|
||||
@ -86,21 +85,6 @@ public class WorldMap implements HighChart {
|
||||
return codeCounts;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toHighChartsSeries() {
|
||||
TextStringBuilder dataBuilder = new TextStringBuilder("[");
|
||||
|
||||
dataBuilder.appendWithSeparators(
|
||||
geoCodeCounts.entrySet().stream()
|
||||
.filter(entry -> entry.getValue() != 0)
|
||||
.map(entry -> "{'code':'" + entry.getKey() + "','value':" + entry.getValue() + "}")
|
||||
.iterator(),
|
||||
","
|
||||
);
|
||||
|
||||
return dataBuilder.append("]").toString();
|
||||
}
|
||||
|
||||
public List<Entry> getEntries() {
|
||||
return geoCodeCounts.entrySet().stream()
|
||||
.filter(entry -> entry.getValue() != 0)
|
||||
@ -109,8 +93,8 @@ public class WorldMap implements HighChart {
|
||||
}
|
||||
|
||||
public static class Entry {
|
||||
private String code;
|
||||
private int value;
|
||||
private final String code;
|
||||
private final int value;
|
||||
|
||||
public Entry(String code, int value) {
|
||||
this.code = code;
|
||||
@ -124,5 +108,19 @@ public class WorldMap implements HighChart {
|
||||
public int getValue() {
|
||||
return value;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean equals(Object o) {
|
||||
if (this == o) return true;
|
||||
if (!(o instanceof Entry)) return false;
|
||||
Entry entry = (Entry) o;
|
||||
return value == entry.value &&
|
||||
Objects.equals(code, entry.code);
|
||||
}
|
||||
|
||||
@Override
|
||||
public int hashCode() {
|
||||
return Objects.hash(code, value);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -16,14 +16,12 @@
|
||||
*/
|
||||
package com.djrapitops.plan.delivery.rendering.json.graphs.stack;
|
||||
|
||||
import com.djrapitops.plan.delivery.rendering.json.graphs.HighChart;
|
||||
|
||||
/**
|
||||
* Utility for creating HighCharts Stack graphs.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class StackGraph implements HighChart {
|
||||
public class StackGraph {
|
||||
|
||||
private final StackDataSet[] dataSets;
|
||||
private final String[] labels;
|
||||
@ -37,42 +35,8 @@ public class StackGraph implements HighChart {
|
||||
return labels;
|
||||
}
|
||||
|
||||
public String toHighChartsLabels() {
|
||||
StringBuilder labelBuilder = new StringBuilder("[");
|
||||
|
||||
int length = this.labels.length;
|
||||
int i = 0;
|
||||
for (String label : this.labels) {
|
||||
labelBuilder.append('"').append(label).append('"');
|
||||
|
||||
if (i < length - 1) {
|
||||
labelBuilder.append(",");
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
return labelBuilder.append("]").toString();
|
||||
}
|
||||
|
||||
public StackDataSet[] getDataSets() {
|
||||
return dataSets;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String toHighChartsSeries() {
|
||||
StringBuilder seriesBuilder = new StringBuilder("[");
|
||||
|
||||
int size = dataSets.length;
|
||||
int i = 0;
|
||||
for (StackDataSet dataSet : dataSets) {
|
||||
seriesBuilder.append(dataSet.toSeriesObjectString());
|
||||
|
||||
if (i < size - 1) {
|
||||
seriesBuilder.append(",");
|
||||
}
|
||||
i++;
|
||||
}
|
||||
|
||||
return seriesBuilder.append("]").toString();
|
||||
}
|
||||
}
|
||||
|
@ -48,11 +48,11 @@ import java.util.concurrent.TimeUnit;
|
||||
public class NetworkOverviewJSONParser implements NetworkTabJSONParser<Map<String, Object>> {
|
||||
|
||||
private final Formatter<Long> day;
|
||||
private PlanConfig config;
|
||||
private DBSystem dbSystem;
|
||||
private ServerInfo serverInfo;
|
||||
private Formatter<Long> timeAmount;
|
||||
private Formatter<DateHolder> year;
|
||||
private final PlanConfig config;
|
||||
private final DBSystem dbSystem;
|
||||
private final ServerInfo serverInfo;
|
||||
private final Formatter<Long> timeAmount;
|
||||
private final Formatter<DateHolder> year;
|
||||
|
||||
@Inject
|
||||
public NetworkOverviewJSONParser(
|
||||
|
@ -41,11 +41,11 @@ import java.util.concurrent.TimeUnit;
|
||||
@Singleton
|
||||
public class NetworkPlayerBaseOverviewJSONParser implements NetworkTabJSONParser<Map<String, Object>> {
|
||||
|
||||
private PlanConfig config;
|
||||
private DBSystem dbSystem;
|
||||
private final PlanConfig config;
|
||||
private final DBSystem dbSystem;
|
||||
|
||||
private Formatter<Long> timeAmount;
|
||||
private Formatter<Double> percentage;
|
||||
private final Formatter<Long> timeAmount;
|
||||
private final Formatter<Double> percentage;
|
||||
|
||||
@Inject
|
||||
public NetworkPlayerBaseOverviewJSONParser(
|
||||
|
@ -37,10 +37,10 @@ import java.util.concurrent.TimeUnit;
|
||||
@Singleton
|
||||
public class NetworkSessionsOverviewJSONParser implements NetworkTabJSONParser<Map<String, Object>> {
|
||||
|
||||
private DBSystem dbSystem;
|
||||
private final DBSystem dbSystem;
|
||||
|
||||
private Formatter<Long> timeAmount;
|
||||
private Formatter<Double> percentage;
|
||||
private final Formatter<Long> timeAmount;
|
||||
private final Formatter<Double> percentage;
|
||||
|
||||
@Inject
|
||||
public NetworkSessionsOverviewJSONParser(
|
||||
|
@ -52,13 +52,13 @@ import static com.djrapitops.plan.delivery.domain.keys.AnalysisKeys.*;
|
||||
public class ServerPage implements Page {
|
||||
|
||||
private final Server server;
|
||||
private PlanConfig config;
|
||||
private Theme theme;
|
||||
private final PlanConfig config;
|
||||
private final Theme theme;
|
||||
private final VersionCheckSystem versionCheckSystem;
|
||||
private final PlanFiles files;
|
||||
private final DBSystem dbSystem;
|
||||
private final ServerInfo serverInfo;
|
||||
private Formatters formatters;
|
||||
private final Formatters formatters;
|
||||
|
||||
ServerPage(
|
||||
Server server,
|
||||
@ -90,7 +90,6 @@ public class ServerPage implements Page {
|
||||
placeholders.put("serverDisplayName", server.getName());
|
||||
|
||||
DataContainer constants = new RawDataContainer();
|
||||
constants.putRawData(AnalysisKeys.VERSION, versionCheckSystem.getCurrentVersion());
|
||||
constants.putRawData(AnalysisKeys.TIME_ZONE, config.getTimeZoneOffsetHours());
|
||||
|
||||
// TODO Move these graph settings to the graph requests instead of placeholders
|
||||
@ -113,7 +112,7 @@ public class ServerPage implements Page {
|
||||
constants.putRawData(AnalysisKeys.MIN_PING_COLOR, theme.getValue(ThemeVal.GRAPH_MIN_PING));
|
||||
|
||||
placeholders.addAllPlaceholdersFrom(constants,
|
||||
VERSION, TIME_ZONE,
|
||||
TIME_ZONE,
|
||||
FIRST_DAY, TPS_MEDIUM, TPS_HIGH,
|
||||
DISK_MEDIUM, DISK_HIGH,
|
||||
PLAYERS_MAX, PLAYERS_ONLINE, PLAYERS_TOTAL,
|
||||
|
@ -34,7 +34,7 @@ import java.util.Optional;
|
||||
public class Request {
|
||||
private final String requestMethod;
|
||||
|
||||
private URI requestURI;
|
||||
private final URI requestURI;
|
||||
|
||||
private final HttpExchange exchange;
|
||||
private final String remoteAddress;
|
||||
|
@ -23,7 +23,10 @@ import com.djrapitops.plan.delivery.webserver.response.Response;
|
||||
import com.djrapitops.plan.delivery.webserver.response.ResponseFactory;
|
||||
import com.djrapitops.plan.delivery.webserver.response.errors.BadRequestResponse;
|
||||
import com.djrapitops.plan.exceptions.WebUserAuthException;
|
||||
import com.djrapitops.plan.exceptions.connection.*;
|
||||
import com.djrapitops.plan.exceptions.connection.BadRequestException;
|
||||
import com.djrapitops.plan.exceptions.connection.ForbiddenException;
|
||||
import com.djrapitops.plan.exceptions.connection.NotFoundException;
|
||||
import com.djrapitops.plan.exceptions.connection.WebException;
|
||||
import com.djrapitops.plan.identification.ServerInfo;
|
||||
import com.djrapitops.plugin.logging.L;
|
||||
import com.djrapitops.plugin.logging.error.ErrorHandler;
|
||||
@ -49,7 +52,7 @@ public class ResponseHandler extends TreePageHandler {
|
||||
private final ErrorHandler errorHandler;
|
||||
|
||||
private final ServerInfo serverInfo;
|
||||
private Lazy<WebServer> webServer;
|
||||
private final Lazy<WebServer> webServer;
|
||||
|
||||
@Inject
|
||||
public ResponseHandler(
|
||||
@ -100,12 +103,6 @@ public class ResponseHandler extends TreePageHandler {
|
||||
return responseFactory.forbidden403(e.getMessage());
|
||||
} catch (BadRequestException e) {
|
||||
return new BadRequestResponse(e.getMessage() + " (when requesting '" + request.getTargetString() + "')");
|
||||
} catch (InternalErrorException e) {
|
||||
if (e.getCause() != null) {
|
||||
return responseFactory.internalErrorResponse(e.getCause(), request.getTargetString());
|
||||
} else {
|
||||
return responseFactory.internalErrorResponse(e, request.getTargetString());
|
||||
}
|
||||
} catch (Exception e) {
|
||||
errorHandler.log(L.ERROR, this.getClass(), e);
|
||||
return responseFactory.internalErrorResponse(e, request.getTargetString());
|
||||
|
@ -18,7 +18,6 @@ package com.djrapitops.plan.delivery.webserver;
|
||||
|
||||
import com.djrapitops.plan.SubSystem;
|
||||
import com.djrapitops.plan.delivery.webserver.cache.JSONCache;
|
||||
import com.djrapitops.plan.exceptions.EnableException;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
@ -41,7 +40,7 @@ public class WebServerSystem implements SubSystem {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void enable() throws EnableException {
|
||||
public void enable() {
|
||||
webServer.enable();
|
||||
}
|
||||
|
||||
|
@ -1,59 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.delivery.webserver.cache;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
* Enum class for "magic" ResponseCache identifier values.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public enum PageId {
|
||||
|
||||
SERVER("serverPage:"),
|
||||
PLAYER("playerPage:"),
|
||||
RAW_PLAYER("rawPlayer:"),
|
||||
PLAYERS("playersPage"),
|
||||
|
||||
ERROR("error:"),
|
||||
FORBIDDEN(ERROR.of("Forbidden")),
|
||||
NOT_FOUND(ERROR.of("Not Found")),
|
||||
|
||||
JS("js:"),
|
||||
CSS("css:"),
|
||||
|
||||
FAVICON("Favicon");
|
||||
|
||||
private final String id;
|
||||
|
||||
PageId(String id) {
|
||||
this.id = id;
|
||||
}
|
||||
|
||||
public String of(String additionalInfo) {
|
||||
return id + additionalInfo;
|
||||
}
|
||||
|
||||
public String of(UUID uuid) {
|
||||
return of(uuid.toString());
|
||||
}
|
||||
|
||||
public String id() {
|
||||
return id;
|
||||
}
|
||||
}
|
@ -36,7 +36,7 @@ public abstract class TreePageHandler implements PageHandler {
|
||||
|
||||
protected final ResponseFactory responseFactory;
|
||||
|
||||
private Map<String, PageHandler> pages;
|
||||
private final Map<String, PageHandler> pages;
|
||||
|
||||
public TreePageHandler(ResponseFactory responseFactory) {
|
||||
this.responseFactory = responseFactory;
|
||||
|
@ -26,7 +26,6 @@ import com.djrapitops.plan.delivery.webserver.auth.Authentication;
|
||||
import com.djrapitops.plan.delivery.webserver.cache.DataID;
|
||||
import com.djrapitops.plan.delivery.webserver.pages.TreePageHandler;
|
||||
import com.djrapitops.plan.delivery.webserver.response.ResponseFactory;
|
||||
import com.djrapitops.plan.exceptions.WebUserAuthException;
|
||||
|
||||
import javax.inject.Inject;
|
||||
import javax.inject.Singleton;
|
||||
@ -61,7 +60,7 @@ public class NetworkJSONHandler extends TreePageHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAuthorized(Authentication auth, RequestTarget target) throws WebUserAuthException {
|
||||
public boolean isAuthorized(Authentication auth, RequestTarget target) {
|
||||
return true;
|
||||
}
|
||||
}
|
@ -22,7 +22,6 @@ import com.djrapitops.plan.delivery.webserver.auth.Authentication;
|
||||
import com.djrapitops.plan.delivery.webserver.cache.DataID;
|
||||
import com.djrapitops.plan.delivery.webserver.pages.TreePageHandler;
|
||||
import com.djrapitops.plan.delivery.webserver.response.ResponseFactory;
|
||||
import com.djrapitops.plan.exceptions.WebUserAuthException;
|
||||
import com.djrapitops.plan.identification.Identifiers;
|
||||
|
||||
import javax.inject.Inject;
|
||||
@ -36,7 +35,7 @@ import javax.inject.Singleton;
|
||||
@Singleton
|
||||
public class RootJSONHandler extends TreePageHandler {
|
||||
|
||||
private Identifiers identifiers;
|
||||
private final Identifiers identifiers;
|
||||
|
||||
@Inject
|
||||
public RootJSONHandler(
|
||||
@ -83,7 +82,7 @@ public class RootJSONHandler extends TreePageHandler {
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean isAuthorized(Authentication auth, RequestTarget target) throws WebUserAuthException {
|
||||
public boolean isAuthorized(Authentication auth, RequestTarget target) {
|
||||
return true;
|
||||
}
|
||||
}
|
@ -1,36 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.delivery.webserver.response;
|
||||
|
||||
/**
|
||||
* Enum containing default responses that don't need to be cached because they're always the same.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public enum DefaultResponses {
|
||||
SUCCESS(new TextResponse("Success"));
|
||||
|
||||
private final Response response;
|
||||
|
||||
DefaultResponses(Response response) {
|
||||
this.response = response;
|
||||
}
|
||||
|
||||
public Response get() {
|
||||
return response;
|
||||
}
|
||||
}
|
@ -27,7 +27,7 @@ import java.io.IOException;
|
||||
*/
|
||||
public class RedirectResponse extends Response {
|
||||
|
||||
private String direct;
|
||||
private final String direct;
|
||||
|
||||
public RedirectResponse(String direct) {
|
||||
super.setHeader("HTTP/1.1 302 Found");
|
||||
|
@ -1,45 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.delivery.webserver.response;
|
||||
|
||||
/**
|
||||
* Enum for HTTP response codes.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public enum ResponseCode {
|
||||
NONE(0),
|
||||
CONNECTION_REFUSED(-1),
|
||||
SUCCESS(200),
|
||||
BAD_REQUEST(400),
|
||||
UNAUTHORIZED(401),
|
||||
FORBIDDEN(403),
|
||||
NOT_FOUND(404),
|
||||
PRECONDITION_FAILED(412),
|
||||
INTERNAL_ERROR(500),
|
||||
GATEWAY_ERROR(504);
|
||||
|
||||
private final int code;
|
||||
|
||||
ResponseCode(int code) {
|
||||
this.code = code;
|
||||
}
|
||||
|
||||
public int getCode() {
|
||||
return code;
|
||||
}
|
||||
}
|
@ -160,10 +160,6 @@ public class ResponseFactory {
|
||||
return notFound404(locale.getString(ErrorPageLang.NOT_PLAYED_404));
|
||||
}
|
||||
|
||||
public ErrorResponse serverNotFound404() {
|
||||
return notFound404(locale.getString(ErrorPageLang.NO_SERVERS_404));
|
||||
}
|
||||
|
||||
public ErrorResponse notFound404(String message) {
|
||||
try {
|
||||
return new NotFoundResponse(message, versionCheckSystem, files);
|
||||
|
@ -16,8 +16,6 @@
|
||||
*/
|
||||
package com.djrapitops.plan.exceptions.connection;
|
||||
|
||||
import com.djrapitops.plan.delivery.webserver.response.ResponseCode;
|
||||
|
||||
/**
|
||||
* Thrown when connection is returned 401 Bad Request.
|
||||
*
|
||||
@ -26,6 +24,6 @@ import com.djrapitops.plan.delivery.webserver.response.ResponseCode;
|
||||
public class BadRequestException extends WebException {
|
||||
|
||||
public BadRequestException(String message) {
|
||||
super(message, ResponseCode.BAD_REQUEST);
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
@ -16,8 +16,6 @@
|
||||
*/
|
||||
package com.djrapitops.plan.exceptions.connection;
|
||||
|
||||
import com.djrapitops.plan.delivery.webserver.response.ResponseCode;
|
||||
|
||||
/**
|
||||
* Thrown when Connection gets a 403 response.
|
||||
*
|
||||
@ -25,6 +23,6 @@ import com.djrapitops.plan.delivery.webserver.response.ResponseCode;
|
||||
*/
|
||||
public class ForbiddenException extends WebException {
|
||||
public ForbiddenException(String url) {
|
||||
super("Forbidden: " + url, ResponseCode.FORBIDDEN);
|
||||
super("Forbidden: " + url);
|
||||
}
|
||||
}
|
||||
|
@ -1,34 +0,0 @@
|
||||
/*
|
||||
* This file is part of Player Analytics (Plan).
|
||||
*
|
||||
* Plan is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Lesser General Public License v3 as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* Plan is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Lesser General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Lesser General Public License
|
||||
* along with Plan. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
package com.djrapitops.plan.exceptions.connection;
|
||||
|
||||
import com.djrapitops.plan.delivery.webserver.response.ResponseCode;
|
||||
|
||||
/**
|
||||
* Thrown when Connection returns 500.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class InternalErrorException extends WebException {
|
||||
public InternalErrorException() {
|
||||
super("Internal Error occurred on receiving server", ResponseCode.INTERNAL_ERROR);
|
||||
}
|
||||
|
||||
public InternalErrorException(String message, Throwable cause) {
|
||||
super(message, cause, ResponseCode.INTERNAL_ERROR);
|
||||
}
|
||||
}
|
@ -16,8 +16,6 @@
|
||||
*/
|
||||
package com.djrapitops.plan.exceptions.connection;
|
||||
|
||||
import com.djrapitops.plan.delivery.webserver.response.ResponseCode;
|
||||
|
||||
/**
|
||||
* Thrown when Connection returns 404, when page is not found.
|
||||
*
|
||||
@ -25,6 +23,6 @@ import com.djrapitops.plan.delivery.webserver.response.ResponseCode;
|
||||
*/
|
||||
public class NotFoundException extends WebException {
|
||||
public NotFoundException(String message) {
|
||||
super(message, ResponseCode.NOT_FOUND);
|
||||
super(message);
|
||||
}
|
||||
}
|
||||
|
@ -16,8 +16,6 @@
|
||||
*/
|
||||
package com.djrapitops.plan.exceptions.connection;
|
||||
|
||||
import com.djrapitops.plan.delivery.webserver.response.ResponseCode;
|
||||
|
||||
/**
|
||||
* Thrown when Connection POST-request fails, general Exception.
|
||||
*
|
||||
@ -25,47 +23,18 @@ import com.djrapitops.plan.delivery.webserver.response.ResponseCode;
|
||||
*/
|
||||
public class WebException extends Exception {
|
||||
|
||||
private final ResponseCode responseCode;
|
||||
|
||||
public WebException() {
|
||||
responseCode = ResponseCode.NONE;
|
||||
}
|
||||
|
||||
public WebException(String message) {
|
||||
super(message);
|
||||
responseCode = ResponseCode.NONE;
|
||||
}
|
||||
|
||||
public WebException(String message, Throwable cause) {
|
||||
super(message, cause);
|
||||
responseCode = ResponseCode.NONE;
|
||||
}
|
||||
|
||||
public WebException(Throwable cause) {
|
||||
super(cause);
|
||||
responseCode = ResponseCode.NONE;
|
||||
}
|
||||
|
||||
public WebException(ResponseCode responseCode) {
|
||||
this.responseCode = responseCode;
|
||||
}
|
||||
|
||||
public WebException(String message, ResponseCode responseCode) {
|
||||
super(message);
|
||||
this.responseCode = responseCode;
|
||||
}
|
||||
|
||||
public WebException(String message, Throwable cause, ResponseCode responseCode) {
|
||||
super(message, cause);
|
||||
this.responseCode = responseCode;
|
||||
}
|
||||
|
||||
public WebException(Throwable cause, ResponseCode responseCode) {
|
||||
super(cause);
|
||||
this.responseCode = responseCode;
|
||||
}
|
||||
|
||||
public ResponseCode getResponseCode() {
|
||||
return responseCode;
|
||||
}
|
||||
}
|
||||
|
@ -148,12 +148,9 @@ public class ExtensionServiceImplementation implements ExtensionService {
|
||||
}
|
||||
|
||||
public void updatePlayerValues(ProviderValueGatherer gatherer, UUID playerUUID, String playerName, CallEvents event) {
|
||||
if (!gatherer.canCallEvent(event)) {
|
||||
return;
|
||||
}
|
||||
if (playerUUID == null && playerName == null) {
|
||||
return;
|
||||
}
|
||||
if (!gatherer.canCallEvent(event)) return;
|
||||
if (playerUUID == null && playerName == null) return;
|
||||
|
||||
try {
|
||||
logger.getDebugLogger().logOn(DebugChannels.DATA_EXTENSIONS, "Gathering values for: " + playerName);
|
||||
|
||||
@ -193,9 +190,8 @@ public class ExtensionServiceImplementation implements ExtensionService {
|
||||
}
|
||||
|
||||
public void updateServerValues(ProviderValueGatherer gatherer, CallEvents event) {
|
||||
if (!gatherer.canCallEvent(event)) {
|
||||
return;
|
||||
}
|
||||
if (!gatherer.canCallEvent(event)) return;
|
||||
|
||||
try {
|
||||
logger.getDebugLogger().logOn(DebugChannels.DATA_EXTENSIONS, "Gathering values for server");
|
||||
|
||||
|
@ -42,8 +42,8 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
public class DataProviderExtractor {
|
||||
|
||||
private ExtensionExtractor extensionExtractor;
|
||||
private DataProviders dataProviders;
|
||||
private final ExtensionExtractor extensionExtractor;
|
||||
private final DataProviders dataProviders;
|
||||
|
||||
/**
|
||||
* Create a DataProviderExtractor.
|
||||
|
@ -37,7 +37,7 @@ public class TabInformation {
|
||||
private final String tabName;
|
||||
private final Icon icon; // can be null
|
||||
private ElementOrder[] elementOrder; // can be null / miss values
|
||||
private int tabPriority;
|
||||
private final int tabPriority;
|
||||
|
||||
public TabInformation(String tabName, Icon icon, ElementOrder[] elementOrder, int tabPriority) {
|
||||
this.tabName = tabName;
|
||||
|
@ -28,7 +28,7 @@ import java.util.stream.Collectors;
|
||||
*/
|
||||
public class DataProviders {
|
||||
|
||||
private Map<MethodType, Map<Class, List<DataProvider>>> byMethodType;
|
||||
private final Map<MethodType, Map<Class, List<DataProvider>>> byMethodType;
|
||||
|
||||
public DataProviders() {
|
||||
byMethodType = new EnumMap<>(MethodType.class);
|
||||
|
@ -35,7 +35,7 @@ public class MethodWrapper<T> {
|
||||
|
||||
private final Method method;
|
||||
private final Class<T> resultType;
|
||||
private MethodType methodType;
|
||||
private final MethodType methodType;
|
||||
|
||||
public MethodWrapper(Method method, Class<T> resultType) {
|
||||
this.method = method;
|
||||
|
@ -45,13 +45,13 @@ public class ProviderValueGatherer {
|
||||
private final DBSystem dbSystem;
|
||||
private final ServerInfo serverInfo;
|
||||
|
||||
private DataProviders dataProviders;
|
||||
private BooleanProviderValueGatherer booleanGatherer;
|
||||
private NumberProviderValueGatherer numberGatherer;
|
||||
private DoubleAndPercentageProviderValueGatherer doubleAndPercentageGatherer;
|
||||
private StringProviderValueGatherer stringGatherer;
|
||||
private TableProviderValueGatherer tableGatherer;
|
||||
private GroupProviderValueGatherer groupGatherer;
|
||||
private final DataProviders dataProviders;
|
||||
private final BooleanProviderValueGatherer booleanGatherer;
|
||||
private final NumberProviderValueGatherer numberGatherer;
|
||||
private final DoubleAndPercentageProviderValueGatherer doubleAndPercentageGatherer;
|
||||
private final StringProviderValueGatherer stringGatherer;
|
||||
private final TableProviderValueGatherer tableGatherer;
|
||||
private final GroupProviderValueGatherer groupGatherer;
|
||||
|
||||
|
||||
public ProviderValueGatherer(
|
||||
|
@ -23,8 +23,8 @@ package com.djrapitops.plan.extension.implementation.results;
|
||||
*/
|
||||
public class ExtensionBooleanData implements DescribedExtensionData {
|
||||
|
||||
private ExtensionDescriptive descriptive;
|
||||
private boolean value;
|
||||
private final ExtensionDescriptive descriptive;
|
||||
private final boolean value;
|
||||
|
||||
public ExtensionBooleanData(ExtensionDescriptive descriptive, boolean value) {
|
||||
this.descriptive = descriptive;
|
||||
|
@ -29,7 +29,7 @@ public class ExtensionData implements Comparable<ExtensionData> {
|
||||
|
||||
private ExtensionInformation extensionInformation;
|
||||
|
||||
private Map<String, ExtensionTabData> tabs;
|
||||
private final Map<String, ExtensionTabData> tabs;
|
||||
|
||||
private ExtensionData(int pluginID) {
|
||||
this.pluginID = pluginID;
|
||||
@ -84,15 +84,15 @@ public class ExtensionData implements Comparable<ExtensionData> {
|
||||
return Objects.hash(pluginID, extensionInformation, tabs);
|
||||
}
|
||||
|
||||
public static class Factory {
|
||||
public static class Builder {
|
||||
|
||||
private final ExtensionData data;
|
||||
|
||||
public Factory(int pluginId) {
|
||||
public Builder(int pluginId) {
|
||||
data = new ExtensionData(pluginId);
|
||||
}
|
||||
|
||||
public Factory combine(Factory with) {
|
||||
public Builder combine(Builder with) {
|
||||
if (with != null) {
|
||||
for (ExtensionTabData tab : with.build().getTabs()) {
|
||||
Optional<ExtensionTabData> found = getTab(tab.getTabInformation().getTabName());
|
||||
@ -106,7 +106,7 @@ public class ExtensionData implements Comparable<ExtensionData> {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Factory setInformation(ExtensionInformation information) {
|
||||
public Builder setInformation(ExtensionInformation information) {
|
||||
if (information.getId() != data.pluginID) {
|
||||
throw new IllegalArgumentException("ID mismatch, wanted id: " + data.pluginID + " but got " + information);
|
||||
}
|
||||
@ -114,7 +114,7 @@ public class ExtensionData implements Comparable<ExtensionData> {
|
||||
return this;
|
||||
}
|
||||
|
||||
public Factory addTab(ExtensionTabData tab) {
|
||||
public Builder addTab(ExtensionTabData tab) {
|
||||
data.tabs.put(tab.getTabInformation().getTabName(), tab);
|
||||
return this;
|
||||
}
|
||||
|
@ -25,8 +25,8 @@ import com.djrapitops.plan.delivery.formatting.Formatter;
|
||||
*/
|
||||
public class ExtensionDoubleData implements DescribedExtensionData {
|
||||
|
||||
private ExtensionDescriptive descriptive;
|
||||
private double value;
|
||||
private final ExtensionDescriptive descriptive;
|
||||
private final double value;
|
||||
|
||||
public ExtensionDoubleData(ExtensionDescriptive descriptive, double value) {
|
||||
this.descriptive = descriptive;
|
||||
|
@ -37,9 +37,9 @@ public class ExtensionTabData implements Comparable<ExtensionTabData> {
|
||||
private final Map<String, ExtensionStringData> stringData;
|
||||
|
||||
private final List<ExtensionTableData> tableData;
|
||||
private final List<ExtensionDescriptive> descriptives;
|
||||
|
||||
private List<String> order;
|
||||
private List<ExtensionDescriptive> descriptives;
|
||||
|
||||
// Table and Graph data will be added later.
|
||||
|
||||
@ -143,47 +143,47 @@ public class ExtensionTabData implements Comparable<ExtensionTabData> {
|
||||
.collect(Collectors.toList());
|
||||
}
|
||||
|
||||
public static class Factory {
|
||||
public static class Builder {
|
||||
|
||||
private final ExtensionTabData data;
|
||||
|
||||
public Factory(TabInformation tabInformation) {
|
||||
public Builder(TabInformation tabInformation) {
|
||||
data = new ExtensionTabData(tabInformation);
|
||||
}
|
||||
|
||||
public Factory putBooleanData(ExtensionBooleanData extensionBooleanData) {
|
||||
public Builder putBooleanData(ExtensionBooleanData extensionBooleanData) {
|
||||
data.booleanData.put(extensionBooleanData.getDescriptive().getName(), extensionBooleanData);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Factory putDoubleData(ExtensionDoubleData extensionDoubleData) {
|
||||
public Builder putDoubleData(ExtensionDoubleData extensionDoubleData) {
|
||||
data.doubleData.put(extensionDoubleData.getDescriptive().getName(), extensionDoubleData);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Factory putPercentageData(ExtensionDoubleData extensionDoubleData) {
|
||||
public Builder putPercentageData(ExtensionDoubleData extensionDoubleData) {
|
||||
data.percentageData.put(extensionDoubleData.getDescriptive().getName(), extensionDoubleData);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Factory putNumberData(ExtensionNumberData extensionNumberData) {
|
||||
public Builder putNumberData(ExtensionNumberData extensionNumberData) {
|
||||
data.numberData.put(extensionNumberData.getDescriptive().getName(), extensionNumberData);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Factory putStringData(ExtensionStringData extensionStringData) {
|
||||
public Builder putStringData(ExtensionStringData extensionStringData) {
|
||||
data.stringData.put(extensionStringData.getDescriptive().getName(), extensionStringData);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Factory putGroupData(ExtensionStringData extensionStringData) {
|
||||
public Builder putGroupData(ExtensionStringData extensionStringData) {
|
||||
String name = extensionStringData.getDescriptive().getName();
|
||||
ExtensionStringData previous = data.stringData.get(name);
|
||||
data.stringData.put(name, previous != null ? previous.concatenate(extensionStringData) : extensionStringData);
|
||||
return this;
|
||||
}
|
||||
|
||||
public Factory putTableData(ExtensionTableData extensionTableData) {
|
||||
public Builder putTableData(ExtensionTableData extensionTableData) {
|
||||
data.tableData.add(extensionTableData);
|
||||
return this;
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ import static com.djrapitops.plan.storage.database.sql.parsing.Sql.*;
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class ExtensionAggregateBooleansQuery implements Query<Map<Integer, ExtensionData.Factory>> {
|
||||
public class ExtensionAggregateBooleansQuery implements Query<Map<Integer, ExtensionData.Builder>> {
|
||||
|
||||
private final UUID serverUUID;
|
||||
|
||||
@ -63,7 +63,7 @@ public class ExtensionAggregateBooleansQuery implements Query<Map<Integer, Exten
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ExtensionData.Factory> executeQuery(SQLDB db) {
|
||||
public Map<Integer, ExtensionData.Builder> executeQuery(SQLDB db) {
|
||||
String selectTrueBooleans = SELECT +
|
||||
ExtensionPlayerValueTable.PROVIDER_ID +
|
||||
",COUNT(1) as positive" +
|
||||
@ -106,7 +106,7 @@ public class ExtensionAggregateBooleansQuery implements Query<Map<Integer, Exten
|
||||
WHERE + ExtensionPluginTable.SERVER_UUID + "=?" +
|
||||
AND + "p1." + ExtensionProviderTable.HIDDEN + "=?";
|
||||
|
||||
return db.query(new QueryStatement<Map<Integer, ExtensionData.Factory>>(sql, 1000) {
|
||||
return db.query(new QueryStatement<Map<Integer, ExtensionData.Builder>>(sql, 1000) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setBoolean(1, true); // selectTrueBooleans parameter
|
||||
@ -115,7 +115,7 @@ public class ExtensionAggregateBooleansQuery implements Query<Map<Integer, Exten
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ExtensionData.Factory> processResults(ResultSet set) throws SQLException {
|
||||
public Map<Integer, ExtensionData.Builder> processResults(ResultSet set) throws SQLException {
|
||||
return extractTabDataByPluginID(set).toExtensionDataByPluginID();
|
||||
}
|
||||
});
|
||||
@ -127,7 +127,7 @@ public class ExtensionAggregateBooleansQuery implements Query<Map<Integer, Exten
|
||||
while (set.next()) {
|
||||
int pluginID = set.getInt("plugin_id");
|
||||
String tabName = Optional.ofNullable(set.getString("tab_name")).orElse("");
|
||||
ExtensionTabData.Factory extensionTab = tabData.getTab(pluginID, tabName, () -> extractTabInformation(tabName, set));
|
||||
ExtensionTabData.Builder extensionTab = tabData.getTab(pluginID, tabName, () -> extractTabInformation(tabName, set));
|
||||
|
||||
ExtensionDescriptive extensionDescriptive = extractDescriptive(set);
|
||||
extractAndPutDataTo(extensionTab, extensionDescriptive, set);
|
||||
@ -152,7 +152,7 @@ public class ExtensionAggregateBooleansQuery implements Query<Map<Integer, Exten
|
||||
);
|
||||
}
|
||||
|
||||
private void extractAndPutDataTo(ExtensionTabData.Factory extensionTab, ExtensionDescriptive descriptive, ResultSet set) throws SQLException {
|
||||
private void extractAndPutDataTo(ExtensionTabData.Builder extensionTab, ExtensionDescriptive descriptive, ResultSet set) throws SQLException {
|
||||
double percentageValue = percentage(set.getInt("positive"), set.getInt("total"));
|
||||
extensionTab.putPercentageData(new ExtensionDoubleData(descriptive, percentageValue));
|
||||
}
|
||||
|
@ -54,7 +54,7 @@ import static com.djrapitops.plan.storage.database.sql.parsing.Sql.*;
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class ExtensionAggregateDoublesQuery implements Query<Map<Integer, ExtensionData.Factory>> {
|
||||
public class ExtensionAggregateDoublesQuery implements Query<Map<Integer, ExtensionData.Builder>> {
|
||||
|
||||
private final UUID serverUUID;
|
||||
|
||||
@ -63,7 +63,7 @@ public class ExtensionAggregateDoublesQuery implements Query<Map<Integer, Extens
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ExtensionData.Factory> executeQuery(SQLDB db) {
|
||||
public Map<Integer, ExtensionData.Builder> executeQuery(SQLDB db) {
|
||||
String selectDoubleAverage = SELECT +
|
||||
ExtensionPlayerValueTable.PROVIDER_ID +
|
||||
",AVG(" + ExtensionPlayerValueTable.DOUBLE_VALUE + ") as average" +
|
||||
@ -106,7 +106,7 @@ public class ExtensionAggregateDoublesQuery implements Query<Map<Integer, Extens
|
||||
WHERE + ExtensionPluginTable.SERVER_UUID + "=?" +
|
||||
AND + "p1." + ExtensionProviderTable.HIDDEN + "=?";
|
||||
|
||||
return db.query(new QueryStatement<Map<Integer, ExtensionData.Factory>>(sql, 1000) {
|
||||
return db.query(new QueryStatement<Map<Integer, ExtensionData.Builder>>(sql, 1000) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, serverUUID.toString());
|
||||
@ -114,7 +114,7 @@ public class ExtensionAggregateDoublesQuery implements Query<Map<Integer, Extens
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ExtensionData.Factory> processResults(ResultSet set) throws SQLException {
|
||||
public Map<Integer, ExtensionData.Builder> processResults(ResultSet set) throws SQLException {
|
||||
return extractTabDataByPluginID(set).toExtensionDataByPluginID();
|
||||
}
|
||||
});
|
||||
@ -126,7 +126,7 @@ public class ExtensionAggregateDoublesQuery implements Query<Map<Integer, Extens
|
||||
while (set.next()) {
|
||||
int pluginID = set.getInt("plugin_id");
|
||||
String tabName = Optional.ofNullable(set.getString("tab_name")).orElse("");
|
||||
ExtensionTabData.Factory extensionTab = tabData.getTab(pluginID, tabName, () -> extractTabInformation(tabName, set));
|
||||
ExtensionTabData.Builder extensionTab = tabData.getTab(pluginID, tabName, () -> extractTabInformation(tabName, set));
|
||||
|
||||
ExtensionDescriptive extensionDescriptive = extractDescriptive(set);
|
||||
extractAndPutDataTo(extensionTab, extensionDescriptive, set);
|
||||
@ -151,7 +151,7 @@ public class ExtensionAggregateDoublesQuery implements Query<Map<Integer, Extens
|
||||
);
|
||||
}
|
||||
|
||||
private void extractAndPutDataTo(ExtensionTabData.Factory extensionTab, ExtensionDescriptive descriptive, ResultSet set) throws SQLException {
|
||||
private void extractAndPutDataTo(ExtensionTabData.Builder extensionTab, ExtensionDescriptive descriptive, ResultSet set) throws SQLException {
|
||||
extensionTab.putDoubleData(new ExtensionDoubleData(modifiedDescriptive(descriptive, "_avg", "Average "), set.getDouble("average")));
|
||||
extensionTab.putDoubleData(new ExtensionDoubleData(modifiedDescriptive(descriptive, "_total", "Total "), set.getDouble("total")));
|
||||
}
|
||||
|
@ -44,7 +44,7 @@ import static com.djrapitops.plan.storage.database.sql.parsing.Sql.*;
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class ExtensionAggregateGroupsQuery implements Query<Map<Integer, ExtensionData.Factory>> {
|
||||
public class ExtensionAggregateGroupsQuery implements Query<Map<Integer, ExtensionData.Builder>> {
|
||||
|
||||
private final UUID serverUUID;
|
||||
|
||||
@ -53,7 +53,7 @@ public class ExtensionAggregateGroupsQuery implements Query<Map<Integer, Extensi
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ExtensionData.Factory> executeQuery(SQLDB db) {
|
||||
public Map<Integer, ExtensionData.Builder> executeQuery(SQLDB db) {
|
||||
String selectGroupCounts = SELECT +
|
||||
ExtensionGroupsTable.PROVIDER_ID + ',' +
|
||||
ExtensionGroupsTable.GROUP_NAME + ',' +
|
||||
@ -87,7 +87,7 @@ public class ExtensionAggregateGroupsQuery implements Query<Map<Integer, Extensi
|
||||
AND + "p1." + ExtensionProviderTable.HIDDEN + "=?" +
|
||||
ORDER_BY + "table_id ASC, group_name ASC";
|
||||
|
||||
return db.query(new QueryStatement<Map<Integer, ExtensionData.Factory>>(sql, 1000) {
|
||||
return db.query(new QueryStatement<Map<Integer, ExtensionData.Builder>>(sql, 1000) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, serverUUID.toString());
|
||||
@ -95,7 +95,7 @@ public class ExtensionAggregateGroupsQuery implements Query<Map<Integer, Extensi
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ExtensionData.Factory> processResults(ResultSet set) throws SQLException {
|
||||
public Map<Integer, ExtensionData.Builder> processResults(ResultSet set) throws SQLException {
|
||||
return extractTables(set).toQueriedTabs().toExtensionDataByPluginID();
|
||||
}
|
||||
});
|
||||
|
@ -55,7 +55,7 @@ import static com.djrapitops.plan.storage.database.sql.parsing.Sql.*;
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class ExtensionAggregateNumbersQuery implements Query<Map<Integer, ExtensionData.Factory>> {
|
||||
public class ExtensionAggregateNumbersQuery implements Query<Map<Integer, ExtensionData.Builder>> {
|
||||
|
||||
private final UUID serverUUID;
|
||||
|
||||
@ -64,7 +64,7 @@ public class ExtensionAggregateNumbersQuery implements Query<Map<Integer, Extens
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ExtensionData.Factory> executeQuery(SQLDB db) {
|
||||
public Map<Integer, ExtensionData.Builder> executeQuery(SQLDB db) {
|
||||
String selectNumberAverage = SELECT +
|
||||
ExtensionPlayerValueTable.PROVIDER_ID +
|
||||
",AVG(" + ExtensionPlayerValueTable.LONG_VALUE + ") as average" +
|
||||
@ -110,7 +110,7 @@ public class ExtensionAggregateNumbersQuery implements Query<Map<Integer, Extens
|
||||
AND + "p1." + ExtensionProviderTable.FORMAT_TYPE + "!=?" +
|
||||
AND + "p1." + ExtensionProviderTable.FORMAT_TYPE + "!=?";
|
||||
|
||||
return db.query(new QueryStatement<Map<Integer, ExtensionData.Factory>>(sql, 1000) {
|
||||
return db.query(new QueryStatement<Map<Integer, ExtensionData.Builder>>(sql, 1000) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, serverUUID.toString());
|
||||
@ -120,7 +120,7 @@ public class ExtensionAggregateNumbersQuery implements Query<Map<Integer, Extens
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ExtensionData.Factory> processResults(ResultSet set) throws SQLException {
|
||||
public Map<Integer, ExtensionData.Builder> processResults(ResultSet set) throws SQLException {
|
||||
return extractTabDataByPluginID(set).toExtensionDataByPluginID();
|
||||
}
|
||||
});
|
||||
@ -132,7 +132,7 @@ public class ExtensionAggregateNumbersQuery implements Query<Map<Integer, Extens
|
||||
while (set.next()) {
|
||||
int pluginID = set.getInt("plugin_id");
|
||||
String tabName = Optional.ofNullable(set.getString("tab_name")).orElse("");
|
||||
ExtensionTabData.Factory extensionTab = tabData.getTab(pluginID, tabName, () -> extractTabInformation(tabName, set));
|
||||
ExtensionTabData.Builder extensionTab = tabData.getTab(pluginID, tabName, () -> extractTabInformation(tabName, set));
|
||||
|
||||
ExtensionDescriptive extensionDescriptive = extractDescriptive(set);
|
||||
extractAndPutDataTo(extensionTab, extensionDescriptive, set);
|
||||
@ -157,7 +157,7 @@ public class ExtensionAggregateNumbersQuery implements Query<Map<Integer, Extens
|
||||
);
|
||||
}
|
||||
|
||||
private void extractAndPutDataTo(ExtensionTabData.Factory extensionTab, ExtensionDescriptive descriptive, ResultSet set) throws SQLException {
|
||||
private void extractAndPutDataTo(ExtensionTabData.Builder extensionTab, ExtensionDescriptive descriptive, ResultSet set) throws SQLException {
|
||||
FormatType formatType = FormatType.getByName(set.getString(ExtensionProviderTable.FORMAT_TYPE)).orElse(FormatType.NONE);
|
||||
extensionTab.putNumberData(new ExtensionNumberData(modifiedDescriptive(descriptive, "_avg", "Average "), formatType, (long) set.getDouble("average")));
|
||||
extensionTab.putNumberData(new ExtensionNumberData(modifiedDescriptive(descriptive, "_total", "Total "), formatType, (long) set.getDouble("total")));
|
||||
|
@ -54,7 +54,7 @@ import static com.djrapitops.plan.storage.database.sql.parsing.Sql.*;
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class ExtensionAggregatePercentagesQuery implements Query<Map<Integer, ExtensionData.Factory>> {
|
||||
public class ExtensionAggregatePercentagesQuery implements Query<Map<Integer, ExtensionData.Builder>> {
|
||||
|
||||
private final UUID serverUUID;
|
||||
|
||||
@ -63,7 +63,7 @@ public class ExtensionAggregatePercentagesQuery implements Query<Map<Integer, Ex
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ExtensionData.Factory> executeQuery(SQLDB db) {
|
||||
public Map<Integer, ExtensionData.Builder> executeQuery(SQLDB db) {
|
||||
String selectPercentageAverage = SELECT +
|
||||
ExtensionPlayerValueTable.PROVIDER_ID +
|
||||
",AVG(" + ExtensionPlayerValueTable.PERCENTAGE_VALUE + ") as average" +
|
||||
@ -97,7 +97,7 @@ public class ExtensionAggregatePercentagesQuery implements Query<Map<Integer, Ex
|
||||
WHERE + ExtensionPluginTable.SERVER_UUID + "=?" +
|
||||
AND + "p1." + ExtensionProviderTable.HIDDEN + "=?";
|
||||
|
||||
return db.query(new QueryStatement<Map<Integer, ExtensionData.Factory>>(sql, 1000) {
|
||||
return db.query(new QueryStatement<Map<Integer, ExtensionData.Builder>>(sql, 1000) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, serverUUID.toString());
|
||||
@ -105,7 +105,7 @@ public class ExtensionAggregatePercentagesQuery implements Query<Map<Integer, Ex
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ExtensionData.Factory> processResults(ResultSet set) throws SQLException {
|
||||
public Map<Integer, ExtensionData.Builder> processResults(ResultSet set) throws SQLException {
|
||||
return extractTabDataByPluginID(set).toExtensionDataByPluginID();
|
||||
}
|
||||
});
|
||||
@ -117,7 +117,7 @@ public class ExtensionAggregatePercentagesQuery implements Query<Map<Integer, Ex
|
||||
while (set.next()) {
|
||||
int pluginID = set.getInt("plugin_id");
|
||||
String tabName = Optional.ofNullable(set.getString("tab_name")).orElse("");
|
||||
ExtensionTabData.Factory extensionTab = tabData.getTab(pluginID, tabName, () -> extractTabInformation(tabName, set));
|
||||
ExtensionTabData.Builder extensionTab = tabData.getTab(pluginID, tabName, () -> extractTabInformation(tabName, set));
|
||||
|
||||
ExtensionDescriptive extensionDescriptive = extractDescriptive(set);
|
||||
extractAndPutDataTo(extensionTab, extensionDescriptive, set);
|
||||
@ -142,7 +142,7 @@ public class ExtensionAggregatePercentagesQuery implements Query<Map<Integer, Ex
|
||||
);
|
||||
}
|
||||
|
||||
private void extractAndPutDataTo(ExtensionTabData.Factory extensionTab, ExtensionDescriptive descriptive, ResultSet set) throws SQLException {
|
||||
private void extractAndPutDataTo(ExtensionTabData.Builder extensionTab, ExtensionDescriptive descriptive, ResultSet set) throws SQLException {
|
||||
extensionTab.putPercentageData(new ExtensionDoubleData(modifiedDescriptive(descriptive, "_avg", "Average "), set.getDouble("average")));
|
||||
}
|
||||
|
||||
|
@ -65,7 +65,7 @@ public class ExtensionPlayerDataQuery implements Query<Map<UUID, List<ExtensionD
|
||||
@Override
|
||||
public Map<UUID, List<ExtensionData>> executeQuery(SQLDB db) {
|
||||
Map<UUID, List<ExtensionInformation>> extensionsByServerUUID = db.query(ExtensionInformationQueries.allExtensions());
|
||||
Map<Integer, ExtensionData.Factory> extensionDataByPluginID = db.query(fetchIncompletePlayerDataByPluginID());
|
||||
Map<Integer, ExtensionData.Builder> extensionDataByPluginID = db.query(fetchIncompletePlayerDataByPluginID());
|
||||
|
||||
combine(extensionDataByPluginID, db.query(new ExtensionPlayerTablesQuery(playerUUID)));
|
||||
combine(extensionDataByPluginID, db.query(new ExtensionPlayerGroupsQuery(playerUUID)));
|
||||
@ -74,14 +74,14 @@ public class ExtensionPlayerDataQuery implements Query<Map<UUID, List<ExtensionD
|
||||
}
|
||||
|
||||
private void combine(
|
||||
Map<Integer, ExtensionData.Factory> extensionDataByPluginID,
|
||||
Map<Integer, ExtensionData.Factory> aggregates
|
||||
Map<Integer, ExtensionData.Builder> extensionDataByPluginID,
|
||||
Map<Integer, ExtensionData.Builder> aggregates
|
||||
) {
|
||||
for (Map.Entry<Integer, ExtensionData.Factory> entry : aggregates.entrySet()) {
|
||||
for (Map.Entry<Integer, ExtensionData.Builder> entry : aggregates.entrySet()) {
|
||||
Integer pluginID = entry.getKey();
|
||||
ExtensionData.Factory data = entry.getValue();
|
||||
ExtensionData.Builder data = entry.getValue();
|
||||
|
||||
ExtensionData.Factory found = extensionDataByPluginID.get(pluginID);
|
||||
ExtensionData.Builder found = extensionDataByPluginID.get(pluginID);
|
||||
if (found == null) {
|
||||
extensionDataByPluginID.put(pluginID, data);
|
||||
} else {
|
||||
@ -90,13 +90,13 @@ public class ExtensionPlayerDataQuery implements Query<Map<UUID, List<ExtensionD
|
||||
}
|
||||
}
|
||||
|
||||
private Map<UUID, List<ExtensionData>> flatMapByServerUUID(Map<UUID, List<ExtensionInformation>> extensionsByServerUUID, Map<Integer, ExtensionData.Factory> extensionDataByPluginID) {
|
||||
private Map<UUID, List<ExtensionData>> flatMapByServerUUID(Map<UUID, List<ExtensionInformation>> extensionsByServerUUID, Map<Integer, ExtensionData.Builder> extensionDataByPluginID) {
|
||||
Map<UUID, List<ExtensionData>> extensionDataByServerUUID = new HashMap<>();
|
||||
|
||||
for (Map.Entry<UUID, List<ExtensionInformation>> entry : extensionsByServerUUID.entrySet()) {
|
||||
UUID serverUUID = entry.getKey();
|
||||
for (ExtensionInformation extensionInformation : entry.getValue()) {
|
||||
ExtensionData.Factory data = extensionDataByPluginID.get(extensionInformation.getId());
|
||||
ExtensionData.Builder data = extensionDataByPluginID.get(extensionInformation.getId());
|
||||
if (data == null) {
|
||||
continue;
|
||||
}
|
||||
@ -108,7 +108,7 @@ public class ExtensionPlayerDataQuery implements Query<Map<UUID, List<ExtensionD
|
||||
return extensionDataByServerUUID;
|
||||
}
|
||||
|
||||
private Query<Map<Integer, ExtensionData.Factory>> fetchIncompletePlayerDataByPluginID() {
|
||||
private Query<Map<Integer, ExtensionData.Builder>> fetchIncompletePlayerDataByPluginID() {
|
||||
String sql = SELECT +
|
||||
"v1." + ExtensionPlayerValueTable.BOOLEAN_VALUE + " as boolean_value," +
|
||||
"v1." + ExtensionPlayerValueTable.DOUBLE_VALUE + " as double_value," +
|
||||
@ -139,7 +139,7 @@ public class ExtensionPlayerDataQuery implements Query<Map<UUID, List<ExtensionD
|
||||
WHERE + ExtensionPlayerValueTable.USER_UUID + "=?" +
|
||||
AND + "p1." + ExtensionProviderTable.HIDDEN + "=?";
|
||||
|
||||
return new QueryStatement<Map<Integer, ExtensionData.Factory>>(sql, 1000) {
|
||||
return new QueryStatement<Map<Integer, ExtensionData.Builder>>(sql, 1000) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, playerUUID.toString());
|
||||
@ -147,7 +147,7 @@ public class ExtensionPlayerDataQuery implements Query<Map<UUID, List<ExtensionD
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ExtensionData.Factory> processResults(ResultSet set) throws SQLException {
|
||||
public Map<Integer, ExtensionData.Builder> processResults(ResultSet set) throws SQLException {
|
||||
return extractTabDataByPluginID(set).toExtensionDataByPluginID();
|
||||
}
|
||||
};
|
||||
@ -159,7 +159,7 @@ public class ExtensionPlayerDataQuery implements Query<Map<UUID, List<ExtensionD
|
||||
while (set.next()) {
|
||||
int pluginID = set.getInt("plugin_id");
|
||||
String tabName = Optional.ofNullable(set.getString("tab_name")).orElse("");
|
||||
ExtensionTabData.Factory extensionTab = tabData.getTab(pluginID, tabName, () -> extractTabInformation(tabName, set));
|
||||
ExtensionTabData.Builder extensionTab = tabData.getTab(pluginID, tabName, () -> extractTabInformation(tabName, set));
|
||||
|
||||
ExtensionDescriptive extensionDescriptive = extractDescriptive(set);
|
||||
extractAndPutDataTo(extensionTab, extensionDescriptive, set);
|
||||
@ -184,7 +184,7 @@ public class ExtensionPlayerDataQuery implements Query<Map<UUID, List<ExtensionD
|
||||
);
|
||||
}
|
||||
|
||||
private void extractAndPutDataTo(ExtensionTabData.Factory extensionTab, ExtensionDescriptive descriptive, ResultSet set) throws SQLException {
|
||||
private void extractAndPutDataTo(ExtensionTabData.Builder extensionTab, ExtensionDescriptive descriptive, ResultSet set) throws SQLException {
|
||||
boolean booleanValue = set.getBoolean(ExtensionPlayerValueTable.BOOLEAN_VALUE);
|
||||
if (!set.wasNull()) {
|
||||
extensionTab.putBooleanData(new ExtensionBooleanData(descriptive, booleanValue));
|
||||
|
@ -49,7 +49,7 @@ import static com.djrapitops.plan.storage.database.sql.parsing.Sql.*;
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class ExtensionPlayerGroupsQuery implements Query<Map<Integer, ExtensionData.Factory>> {
|
||||
public class ExtensionPlayerGroupsQuery implements Query<Map<Integer, ExtensionData.Builder>> {
|
||||
|
||||
private final UUID playerUUID;
|
||||
|
||||
@ -58,11 +58,11 @@ public class ExtensionPlayerGroupsQuery implements Query<Map<Integer, ExtensionD
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ExtensionData.Factory> executeQuery(SQLDB db) {
|
||||
public Map<Integer, ExtensionData.Builder> executeQuery(SQLDB db) {
|
||||
return db.query(fetchGroupsByPluginID());
|
||||
}
|
||||
|
||||
private Query<Map<Integer, ExtensionData.Factory>> fetchGroupsByPluginID() {
|
||||
private Query<Map<Integer, ExtensionData.Builder>> fetchGroupsByPluginID() {
|
||||
String sql = SELECT +
|
||||
"v1." + ExtensionGroupsTable.GROUP_NAME + " as group_name," +
|
||||
"p1." + ExtensionProviderTable.PLUGIN_ID + " as plugin_id," +
|
||||
@ -86,7 +86,7 @@ public class ExtensionPlayerGroupsQuery implements Query<Map<Integer, ExtensionD
|
||||
AND + "p1." + ExtensionProviderTable.HIDDEN + "=?" +
|
||||
ORDER_BY + ExtensionGroupsTable.GROUP_NAME + " ASC";
|
||||
|
||||
return new QueryStatement<Map<Integer, ExtensionData.Factory>>(sql, 1000) {
|
||||
return new QueryStatement<Map<Integer, ExtensionData.Builder>>(sql, 1000) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, playerUUID.toString());
|
||||
@ -94,7 +94,7 @@ public class ExtensionPlayerGroupsQuery implements Query<Map<Integer, ExtensionD
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ExtensionData.Factory> processResults(ResultSet set) throws SQLException {
|
||||
public Map<Integer, ExtensionData.Builder> processResults(ResultSet set) throws SQLException {
|
||||
return extractTabDataByPluginID(set).toExtensionDataByPluginID();
|
||||
}
|
||||
};
|
||||
@ -106,7 +106,7 @@ public class ExtensionPlayerGroupsQuery implements Query<Map<Integer, ExtensionD
|
||||
while (set.next()) {
|
||||
int pluginID = set.getInt("plugin_id");
|
||||
String tabName = Optional.ofNullable(set.getString("tab_name")).orElse("");
|
||||
ExtensionTabData.Factory extensionTab = tabData.getTab(pluginID, tabName, () -> extractTabInformation(tabName, set));
|
||||
ExtensionTabData.Builder extensionTab = tabData.getTab(pluginID, tabName, () -> extractTabInformation(tabName, set));
|
||||
|
||||
ExtensionDescriptive extensionDescriptive = extractDescriptive(set);
|
||||
|
||||
|
@ -54,7 +54,7 @@ import static com.djrapitops.plan.storage.database.sql.parsing.Sql.*;
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class ExtensionPlayerTablesQuery implements Query<Map<Integer, ExtensionData.Factory>> {
|
||||
public class ExtensionPlayerTablesQuery implements Query<Map<Integer, ExtensionData.Builder>> {
|
||||
|
||||
private final UUID playerUUID;
|
||||
|
||||
@ -63,7 +63,7 @@ public class ExtensionPlayerTablesQuery implements Query<Map<Integer, ExtensionD
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ExtensionData.Factory> executeQuery(SQLDB db) {
|
||||
public Map<Integer, ExtensionData.Builder> executeQuery(SQLDB db) {
|
||||
QueriedTables tablesWithValues = db.query(placeValuesToTables(db.query(queryTableProviders())));
|
||||
return tablesWithValues.toQueriedTabs().toExtensionDataByPluginID();
|
||||
}
|
||||
|
@ -63,7 +63,7 @@ public class ExtensionServerDataQuery implements Query<List<ExtensionData>> {
|
||||
@Override
|
||||
public List<ExtensionData> executeQuery(SQLDB db) {
|
||||
List<ExtensionInformation> extensionsOfServer = db.query(ExtensionInformationQueries.extensionsOfServer(serverUUID));
|
||||
Map<Integer, ExtensionData.Factory> extensionDataByPluginID = db.query(fetchIncompleteServerDataByPluginID());
|
||||
Map<Integer, ExtensionData.Builder> extensionDataByPluginID = db.query(fetchIncompleteServerDataByPluginID());
|
||||
|
||||
combine(extensionDataByPluginID, db.query(new ExtensionAggregateBooleansQuery(serverUUID)));
|
||||
combine(extensionDataByPluginID, db.query(new ExtensionAggregateDoublesQuery(serverUUID)));
|
||||
@ -76,14 +76,14 @@ public class ExtensionServerDataQuery implements Query<List<ExtensionData>> {
|
||||
}
|
||||
|
||||
private void combine(
|
||||
Map<Integer, ExtensionData.Factory> extensionDataByPluginID,
|
||||
Map<Integer, ExtensionData.Factory> aggregates
|
||||
Map<Integer, ExtensionData.Builder> extensionDataByPluginID,
|
||||
Map<Integer, ExtensionData.Builder> aggregates
|
||||
) {
|
||||
for (Map.Entry<Integer, ExtensionData.Factory> entry : aggregates.entrySet()) {
|
||||
for (Map.Entry<Integer, ExtensionData.Builder> entry : aggregates.entrySet()) {
|
||||
Integer pluginID = entry.getKey();
|
||||
ExtensionData.Factory data = entry.getValue();
|
||||
ExtensionData.Builder data = entry.getValue();
|
||||
|
||||
ExtensionData.Factory found = extensionDataByPluginID.get(pluginID);
|
||||
ExtensionData.Builder found = extensionDataByPluginID.get(pluginID);
|
||||
if (found == null) {
|
||||
extensionDataByPluginID.put(pluginID, data);
|
||||
} else {
|
||||
@ -94,12 +94,12 @@ public class ExtensionServerDataQuery implements Query<List<ExtensionData>> {
|
||||
|
||||
private List<ExtensionData> combineWithExtensionInfo(
|
||||
List<ExtensionInformation> extensionsOfServer,
|
||||
Map<Integer, ExtensionData.Factory> extensionDataByPluginID
|
||||
Map<Integer, ExtensionData.Builder> extensionDataByPluginID
|
||||
) {
|
||||
List<ExtensionData> extensionData = new ArrayList<>();
|
||||
|
||||
for (ExtensionInformation extensionInformation : extensionsOfServer) {
|
||||
ExtensionData.Factory data = extensionDataByPluginID.get(extensionInformation.getId());
|
||||
ExtensionData.Builder data = extensionDataByPluginID.get(extensionInformation.getId());
|
||||
if (data == null) {
|
||||
continue;
|
||||
}
|
||||
@ -108,7 +108,7 @@ public class ExtensionServerDataQuery implements Query<List<ExtensionData>> {
|
||||
return extensionData;
|
||||
}
|
||||
|
||||
private Query<Map<Integer, ExtensionData.Factory>> fetchIncompleteServerDataByPluginID() {
|
||||
private Query<Map<Integer, ExtensionData.Builder>> fetchIncompleteServerDataByPluginID() {
|
||||
String sql = SELECT +
|
||||
"v1." + ExtensionServerValueTable.BOOLEAN_VALUE + " as boolean_value," +
|
||||
"v1." + ExtensionServerValueTable.DOUBLE_VALUE + " as double_value," +
|
||||
@ -140,7 +140,7 @@ public class ExtensionServerDataQuery implements Query<List<ExtensionData>> {
|
||||
WHERE + ExtensionPluginTable.SERVER_UUID + "=?" +
|
||||
AND + "p1." + ExtensionProviderTable.HIDDEN + "=?";
|
||||
|
||||
return new QueryStatement<Map<Integer, ExtensionData.Factory>>(sql, 1000) {
|
||||
return new QueryStatement<Map<Integer, ExtensionData.Builder>>(sql, 1000) {
|
||||
@Override
|
||||
public void prepare(PreparedStatement statement) throws SQLException {
|
||||
statement.setString(1, serverUUID.toString());
|
||||
@ -148,7 +148,7 @@ public class ExtensionServerDataQuery implements Query<List<ExtensionData>> {
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ExtensionData.Factory> processResults(ResultSet set) throws SQLException {
|
||||
public Map<Integer, ExtensionData.Builder> processResults(ResultSet set) throws SQLException {
|
||||
return extractTabDataByPluginID(set).toExtensionDataByPluginID();
|
||||
}
|
||||
};
|
||||
@ -160,7 +160,7 @@ public class ExtensionServerDataQuery implements Query<List<ExtensionData>> {
|
||||
while (set.next()) {
|
||||
int pluginID = set.getInt("plugin_id");
|
||||
String tabName = Optional.ofNullable(set.getString("tab_name")).orElse("");
|
||||
ExtensionTabData.Factory extensionTab = tabData.getTab(pluginID, tabName, () -> extractTabInformation(tabName, set));
|
||||
ExtensionTabData.Builder extensionTab = tabData.getTab(pluginID, tabName, () -> extractTabInformation(tabName, set));
|
||||
|
||||
ExtensionDescriptive extensionDescriptive = extractDescriptive(set);
|
||||
extractAndPutDataTo(extensionTab, extensionDescriptive, set);
|
||||
@ -185,7 +185,7 @@ public class ExtensionServerDataQuery implements Query<List<ExtensionData>> {
|
||||
);
|
||||
}
|
||||
|
||||
private void extractAndPutDataTo(ExtensionTabData.Factory extensionTab, ExtensionDescriptive descriptive, ResultSet set) throws SQLException {
|
||||
private void extractAndPutDataTo(ExtensionTabData.Builder extensionTab, ExtensionDescriptive descriptive, ResultSet set) throws SQLException {
|
||||
boolean booleanValue = set.getBoolean(ExtensionServerValueTable.BOOLEAN_VALUE);
|
||||
if (!set.wasNull()) {
|
||||
extensionTab.putBooleanData(new ExtensionBooleanData(descriptive, booleanValue));
|
||||
|
@ -157,11 +157,11 @@ public class ExtensionServerPlayerDataTableQuery implements Query<Map<UUID, Exte
|
||||
}
|
||||
|
||||
private Map<UUID, ExtensionTabData> extractDataByPlayer(ResultSet set) throws SQLException {
|
||||
Map<UUID, ExtensionTabData.Factory> dataByPlayer = new HashMap<>();
|
||||
Map<UUID, ExtensionTabData.Builder> dataByPlayer = new HashMap<>();
|
||||
|
||||
while (set.next()) {
|
||||
UUID playerUUID = UUID.fromString(set.getString("uuid"));
|
||||
ExtensionTabData.Factory data = dataByPlayer.getOrDefault(playerUUID, new ExtensionTabData.Factory(null));
|
||||
ExtensionTabData.Builder data = dataByPlayer.getOrDefault(playerUUID, new ExtensionTabData.Builder(null));
|
||||
|
||||
ExtensionDescriptive extensionDescriptive = extractDescriptive(set);
|
||||
extractAndPutDataTo(data, extensionDescriptive, set);
|
||||
@ -171,7 +171,7 @@ public class ExtensionServerPlayerDataTableQuery implements Query<Map<UUID, Exte
|
||||
return dataByPlayer.entrySet().stream().collect(Collectors.toMap(Map.Entry::getKey, entry -> entry.getValue().build()));
|
||||
}
|
||||
|
||||
private void extractAndPutDataTo(ExtensionTabData.Factory extensionTab, ExtensionDescriptive descriptive, ResultSet set) throws SQLException {
|
||||
private void extractAndPutDataTo(ExtensionTabData.Builder extensionTab, ExtensionDescriptive descriptive, ResultSet set) throws SQLException {
|
||||
String groupValue = set.getString("group_value");
|
||||
if (groupValue != null) {
|
||||
extensionTab.putGroupData(new ExtensionStringData(descriptive, false, groupValue));
|
||||
|
@ -51,7 +51,7 @@ import static com.djrapitops.plan.storage.database.sql.parsing.Sql.*;
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class ExtensionServerTablesQuery implements Query<Map<Integer, ExtensionData.Factory>> {
|
||||
public class ExtensionServerTablesQuery implements Query<Map<Integer, ExtensionData.Builder>> {
|
||||
|
||||
private final UUID serverUUID;
|
||||
|
||||
@ -60,7 +60,7 @@ public class ExtensionServerTablesQuery implements Query<Map<Integer, ExtensionD
|
||||
}
|
||||
|
||||
@Override
|
||||
public Map<Integer, ExtensionData.Factory> executeQuery(SQLDB db) {
|
||||
public Map<Integer, ExtensionData.Builder> executeQuery(SQLDB db) {
|
||||
QueriedTables tablesWithValues = db.query(queryTableValues(db.query(queryTableProviders())));
|
||||
return tablesWithValues.toQueriedTabs().toExtensionDataByPluginID();
|
||||
}
|
||||
|
@ -31,18 +31,18 @@ import java.util.Map;
|
||||
*/
|
||||
public class QueriedTabData {
|
||||
|
||||
private final Map<Integer, Map<String, ExtensionTabData.Factory>> byPluginID;
|
||||
private final Map<Integer, Map<String, ExtensionTabData.Builder>> byPluginID;
|
||||
|
||||
public QueriedTabData() {
|
||||
byPluginID = new HashMap<>();
|
||||
}
|
||||
|
||||
public <K extends Throwable> ExtensionTabData.Factory getTab(int pluginID, String tabName, ThrowingSupplier<TabInformation, K> newDefault) throws K {
|
||||
Map<String, ExtensionTabData.Factory> byTabName = byPluginID.getOrDefault(pluginID, new HashMap<>());
|
||||
public <K extends Throwable> ExtensionTabData.Builder getTab(int pluginID, String tabName, ThrowingSupplier<TabInformation, K> newDefault) throws K {
|
||||
Map<String, ExtensionTabData.Builder> byTabName = byPluginID.getOrDefault(pluginID, new HashMap<>());
|
||||
|
||||
ExtensionTabData.Factory tab = byTabName.get(tabName);
|
||||
ExtensionTabData.Builder tab = byTabName.get(tabName);
|
||||
if (tab == null) {
|
||||
tab = new ExtensionTabData.Factory(newDefault.get());
|
||||
tab = new ExtensionTabData.Builder(newDefault.get());
|
||||
}
|
||||
|
||||
byTabName.put(tabName, tab);
|
||||
@ -50,17 +50,17 @@ public class QueriedTabData {
|
||||
return tab;
|
||||
}
|
||||
|
||||
public Map<Integer, ExtensionData.Factory> toExtensionDataByPluginID() {
|
||||
Map<Integer, ExtensionData.Factory> dataByPluginID = new HashMap<>();
|
||||
for (Map.Entry<Integer, Map<String, ExtensionTabData.Factory>> entry : byPluginID.entrySet()) {
|
||||
public Map<Integer, ExtensionData.Builder> toExtensionDataByPluginID() {
|
||||
Map<Integer, ExtensionData.Builder> dataByPluginID = new HashMap<>();
|
||||
for (Map.Entry<Integer, Map<String, ExtensionTabData.Builder>> entry : byPluginID.entrySet()) {
|
||||
Integer pluginID = entry.getKey();
|
||||
|
||||
ExtensionData.Factory data = dataByPluginID.get(pluginID);
|
||||
ExtensionData.Builder data = dataByPluginID.get(pluginID);
|
||||
if (data == null) {
|
||||
data = new ExtensionData.Factory(pluginID);
|
||||
data = new ExtensionData.Builder(pluginID);
|
||||
}
|
||||
|
||||
for (ExtensionTabData.Factory tabData : entry.getValue().values()) {
|
||||
for (ExtensionTabData.Builder tabData : entry.getValue().values()) {
|
||||
data.addTab(tabData.build());
|
||||
}
|
||||
dataByPluginID.put(pluginID, data);
|
||||
|
@ -79,7 +79,7 @@ public class QueriedTables {
|
||||
// Extra tab information
|
||||
String tabName = TableAccessor.getTabName(table);
|
||||
|
||||
ExtensionTabData.Factory tab = tabData.getTab(pluginID, tabName, () -> extractTabInformation(table));
|
||||
ExtensionTabData.Builder tab = tabData.getTab(pluginID, tabName, () -> extractTabInformation(table));
|
||||
tab.putTableData(new ExtensionTableData(
|
||||
tableName, table.build(), tableColor
|
||||
));
|
||||
|
@ -43,7 +43,7 @@ import static com.djrapitops.plan.storage.database.sql.tables.ExtensionProviderT
|
||||
public class StoreGroupProviderTransaction extends ThrowawayTransaction {
|
||||
|
||||
private final UUID serverUUID;
|
||||
private ProviderInformation providerInformation;
|
||||
private final ProviderInformation providerInformation;
|
||||
|
||||
public StoreGroupProviderTransaction(DataProvider<String[]> provider, UUID serverUUID) {
|
||||
this.serverUUID = serverUUID;
|
||||
|
@ -44,7 +44,7 @@ public class StoreStringProviderTransaction extends ThrowawayTransaction {
|
||||
|
||||
private final boolean playerName;
|
||||
private final UUID serverUUID;
|
||||
private ProviderInformation providerInformation;
|
||||
private final ProviderInformation providerInformation;
|
||||
|
||||
public StoreStringProviderTransaction(DataProvider<String> provider, boolean playerName, UUID serverUUID) {
|
||||
this.playerName = playerName;
|
||||
|
@ -115,16 +115,6 @@ public class GeolocationCache implements SubSystem {
|
||||
return cache.get(ipAddress, this::getUnCachedCountry);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the cached country
|
||||
*
|
||||
* @param ipAddress The IP Address which is retrieved out of the cache
|
||||
* @return The cached country, {@code null} if the country is not cached
|
||||
*/
|
||||
private String getCachedCountry(String ipAddress) {
|
||||
return cache.getIfPresent(ipAddress);
|
||||
}
|
||||
|
||||
/**
|
||||
* Retrieves the country in full length (e.g. United States) from the IP Address.
|
||||
* <p>
|
||||
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue
Block a user