diff --git a/Plan/src/main/java/com/djrapitops/plan/Plan.java b/Plan/src/main/java/com/djrapitops/plan/Plan.java index cc04e5bda..6cf181faf 100644 --- a/Plan/src/main/java/com/djrapitops/plan/Plan.java +++ b/Plan/src/main/java/com/djrapitops/plan/Plan.java @@ -29,9 +29,7 @@ import main.java.com.djrapitops.plan.api.API; import main.java.com.djrapitops.plan.command.PlanCommand; import main.java.com.djrapitops.plan.command.commands.RegisterCommandFilter; import main.java.com.djrapitops.plan.data.additional.HookHandler; -import main.java.com.djrapitops.plan.data.cache.AnalysisCacheHandler; import main.java.com.djrapitops.plan.data.cache.DataCache; -import main.java.com.djrapitops.plan.data.cache.InspectCacheHandler; import main.java.com.djrapitops.plan.data.cache.PageCacheHandler; import main.java.com.djrapitops.plan.data.listeners.*; import main.java.com.djrapitops.plan.data.server.ServerInfoManager; @@ -46,7 +44,6 @@ import main.java.com.djrapitops.plan.ui.webserver.WebServer; import main.java.com.djrapitops.plan.ui.webserver.api.bukkit.*; import main.java.com.djrapitops.plan.utilities.Benchmark; import main.java.com.djrapitops.plan.utilities.Check; -import main.java.com.djrapitops.plan.utilities.MiscUtils; import main.java.com.djrapitops.plan.utilities.webserver.api.WebAPIManager; import org.apache.logging.log4j.LogManager; import org.bukkit.ChatColor; @@ -70,8 +67,6 @@ public class Plan extends BukkitPlugin { private ProcessingQueue processingQueue; private DataCache dataCache; - private InspectCacheHandler inspectCache; - private AnalysisCacheHandler analysisCache; private HookHandler hookHandler; // Manages 3rd party data sources private Database db; @@ -158,8 +153,6 @@ public class Plan extends BukkitPlugin { Benchmark.start("Init DataCache"); this.dataCache = new DataCache(this); - this.inspectCache = new InspectCacheHandler(this); - this.analysisCache = new AnalysisCacheHandler(this); Benchmark.stop("Enable", "Init DataCache"); tpsCountTimer = new TPSCountTimer(this); @@ -331,8 +324,9 @@ public class Plan extends BukkitPlugin { @Override public void run() { Log.debug("Running PeriodicalAnalysisTask"); - if (!analysisCache.isCached() || MiscUtils.getTime() - analysisCache.getData().getRefreshDate() > TimeAmount.MINUTE.ms()) { - analysisCache.updateCache(); + // TODO DataCacheMethod for checking analysis refresh date. + if (true) { +// TODO analysisCache.updateCache(); } } }).runTaskTimerAsynchronously(everyXMinutes * TimeAmount.MINUTE.ticks(), everyXMinutes * TimeAmount.MINUTE.ticks()); @@ -352,7 +346,7 @@ public class Plan extends BukkitPlugin { Log.debug("Running BootAnalysisTask"); Log.info(bootAnalysisRunMsg); - analysisCache.updateCache(); + //TODO analysisCache.updateCache(); this.cancel(); } }).runTaskLaterAsynchronously(30 * TimeAmount.SECOND.ticks()); @@ -368,24 +362,6 @@ public class Plan extends BukkitPlugin { logger.addFilter(new RegisterCommandFilter()); } - /** - * Used to access AnalysisCache. - * - * @return Current instance of the AnalysisCacheHandler - */ - public AnalysisCacheHandler getAnalysisCache() { - return analysisCache; - } - - /** - * Used to access InspectCache. - * - * @return Current instance of the InspectCacheHandler - */ - public InspectCacheHandler getInspectCache() { - return inspectCache; - } - /** * Used to access Cache. * diff --git a/Plan/src/main/java/com/djrapitops/plan/api/API.java b/Plan/src/main/java/com/djrapitops/plan/api/API.java index 54abd2c05..3c35ef3a3 100644 --- a/Plan/src/main/java/com/djrapitops/plan/api/API.java +++ b/Plan/src/main/java/com/djrapitops/plan/api/API.java @@ -5,10 +5,8 @@ import com.djrapitops.plugin.utilities.player.Fetch; import com.djrapitops.plugin.utilities.player.IOfflinePlayer; import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.data.AnalysisData; -import main.java.com.djrapitops.plan.data.UserData; import main.java.com.djrapitops.plan.data.additional.AnalysisType; import main.java.com.djrapitops.plan.data.additional.PluginData; -import main.java.com.djrapitops.plan.data.cache.DBCallableProcessor; import main.java.com.djrapitops.plan.ui.html.DataRequestHandler; import main.java.com.djrapitops.plan.ui.webserver.WebServer; import main.java.com.djrapitops.plan.utilities.HtmlUtils; @@ -16,11 +14,7 @@ import main.java.com.djrapitops.plan.utilities.uuid.UUIDUtility; import java.sql.SQLException; import java.util.Collection; -import java.util.List; -import java.util.Map; import java.util.UUID; -import java.util.function.Function; -import java.util.stream.Collectors; /** * This class contains the API methods. @@ -35,7 +29,6 @@ import java.util.stream.Collectors; * @author Rsl1122 * @see PluginData * @see AnalysisType - * @see DBCallableProcessor * @since 2.0.0 */ public class API { @@ -94,18 +87,19 @@ public class API { } /** - * Check if the UserData is cached to the InspectCache. + * Check if the UserInfo is cached to the InspectCache. * * @param uuid UUID of the player. * @return true/false */ @Deprecated public boolean isPlayersDataInspectCached(UUID uuid) { - return plugin.getInspectCache().isCached(uuid); + // TODO Check PageCache + return false; } /** - * Cache the UserData to InspectCache. + * Cache the UserInfo to InspectCache. *

* Uses cache if data is cached or database if not. Call from an Asynchronous * thread. @@ -114,7 +108,7 @@ public class API { */ @Deprecated public void cacheUserDataToInspectCache(UUID uuid) { - plugin.getInspectCache().cache(uuid); + // TODO Run Inspect parse } /** @@ -140,7 +134,8 @@ public class API { * @return true/false */ public boolean isAnalysisCached() { - return plugin.getAnalysisCache().isCached(); + // TODO Check PageCache + return false; } /** @@ -150,7 +145,7 @@ public class API { * Starts a new Asynchronous task to run the analysis. */ public void updateAnalysisCache() { - plugin.getAnalysisCache().updateCache(); + // TODO Run analysis } /** @@ -178,7 +173,8 @@ public class API { * @see AnalysisData */ public AnalysisData getAnalysisDataFromCache() { - return plugin.getAnalysisCache().getData(); + // TODO Fix + return null; } /** @@ -239,49 +235,4 @@ public class API { public Collection getSavedUUIDs() throws SQLException { return plugin.getDB().getSavedUUIDs(); } - - /** - * Get the saved UserData in the database for a collection of UUIDs. - *

- * Will not contain data for UUIDs not found in the database. - *

- * Should be called from async thread. - * - * @param uuids Collection of UUIDs that can be found in the database. - * @return List of all Data in the database. - * @throws SQLException If database error occurs. - * @since 3.4.2 - */ - public List getUserDataOfUsers(Collection uuids) throws SQLException { - return plugin.getDB().getUserDataForUUIDS(uuids); - } - - /** - * Get the cached UserData objects in the InspectCache. - *

- * This can be used with PluginData objects safely to get the data for all - * users in Plan database, because all data is InspectCached before analysis - * begins. - * - * @return List of all Data in the InspectCache. - * @since 3.5.0 - */ - public List getInspectCachedUserData() { - return plugin.getInspectCache().getCachedUserData(); - } - - /** - * Get the cached UserData objects in the InspectCache in a Map form. - *

- * This can be used with PluginData objects safely to get the data for all - * users in Plan database, because all data is InspectCached before analysis - * begins. - * - * @return Map of all Data in the InspectCache with UUID of the player as - * the key. - * @since 3.5.0 - */ - public Map getInspectCachedUserDataMap() { - return getInspectCachedUserData().stream().collect(Collectors.toMap(UserData::getUuid, Function.identity())); - } } diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java index 7c1df6d7a..35f58dd84 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/AnalyzeCommand.java @@ -1,6 +1,5 @@ package main.java.com.djrapitops.plan.command.commands; -import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.command.CommandType; import com.djrapitops.plugin.command.CommandUtils; import com.djrapitops.plugin.command.ISender; @@ -10,11 +9,9 @@ import main.java.com.djrapitops.plan.Log; import main.java.com.djrapitops.plan.Permissions; import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.command.ConditionUtils; -import main.java.com.djrapitops.plan.data.cache.AnalysisCacheHandler; import main.java.com.djrapitops.plan.locale.Locale; import main.java.com.djrapitops.plan.locale.Msg; import main.java.com.djrapitops.plan.utilities.Check; -import main.java.com.djrapitops.plan.utilities.MiscUtils; import org.bukkit.ChatColor; /** @@ -26,7 +23,6 @@ import org.bukkit.ChatColor; public class AnalyzeCommand extends SubCommand { private final Plan plugin; - private final AnalysisCacheHandler analysisCache; /** * Subcommand Constructor. @@ -39,7 +35,6 @@ public class AnalyzeCommand extends SubCommand { Permissions.ANALYZE.getPermission(), Locale.get(Msg.CMD_USG_ANALYZE).parse()); this.plugin = plugin; - analysisCache = plugin.getAnalysisCache(); } @Override @@ -53,10 +48,11 @@ public class AnalyzeCommand extends SubCommand { return true; } - if (!Check.isTrue(analysisCache.isAnalysisEnabled(), Locale.get(Msg.CMD_INFO_ANALYSIS_TEMP_DISABLE).toString(), sender) - && !analysisCache.isCached()) { - return true; - } + // TODO Check if analysis is enabled. +// if (!Check.isTrue(analysisCache.isAnalysisEnabled(), Locale.get(Msg.CMD_INFO_ANALYSIS_TEMP_DISABLE).toString(), sender) +// && !analysisCache.isCached()) { +// return true; +// } sender.sendMessage(Locale.get(Msg.CMD_INFO_FETCH_DATA).toString()); if (plugin.getUiServer().isAuthRequired() && CommandUtils.isPlayer(sender)) { @@ -81,15 +77,16 @@ public class AnalyzeCommand extends SubCommand { } private void updateCache(ISender sender) { - if (!analysisCache.isCached() || MiscUtils.getTime() - analysisCache.getData().getRefreshDate() > TimeAmount.MINUTE.ms()) { - int bootAnID = plugin.getBootAnalysisTaskID(); - if (bootAnID != -1) { - plugin.getServer().getScheduler().cancelTask(bootAnID); - } - analysisCache.addNotification(sender); - analysisCache.updateCache(); - } else { - analysisCache.sendAnalysisMessage(sender); - } + // TODO +// if (!analysisCache.isCached() || MiscUtils.getTime() - analysisCache.getData().getRefreshDate() > TimeAmount.MINUTE.ms()) { +// int bootAnID = plugin.getBootAnalysisTaskID(); +// if (bootAnID != -1) { +// plugin.getServer().getScheduler().cancelTask(bootAnID); +// } +// analysisCache.addNotification(sender); +// analysisCache.updateCache(); +// } else { +// analysisCache.sendAnalysisMessage(sender); +// } } } diff --git a/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java b/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java index e0eb76cd5..00bafd1df 100644 --- a/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java +++ b/Plan/src/main/java/com/djrapitops/plan/command/commands/InspectCommand.java @@ -11,7 +11,6 @@ import main.java.com.djrapitops.plan.Log; import main.java.com.djrapitops.plan.Permissions; import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.command.ConditionUtils; -import main.java.com.djrapitops.plan.data.cache.InspectCacheHandler; import main.java.com.djrapitops.plan.locale.Locale; import main.java.com.djrapitops.plan.locale.Msg; import main.java.com.djrapitops.plan.utilities.Check; @@ -24,7 +23,7 @@ import java.sql.SQLException; import java.util.UUID; /** - * This command is used to cache UserData to InspectCache and display the link. + * This command is used to cache UserInfo to InspectCache and display the link. * * @author Rsl1122 * @since 1.0.0 @@ -32,7 +31,6 @@ import java.util.UUID; public class InspectCommand extends SubCommand { private final Plan plugin; - private final InspectCacheHandler inspectCache; /** * Class Constructor. @@ -47,7 +45,6 @@ public class InspectCommand extends SubCommand { ""); this.plugin = plugin; - inspectCache = plugin.getInspectCache(); } @@ -90,7 +87,7 @@ public class InspectCommand extends SubCommand { sender.sendMessage(ChatColor.YELLOW + "[Plan] You might not have a web user, use /plan register "); } } - inspectCache.cache(uuid); + //TODO Inspect Request. runMessageSenderTask(uuid, sender, playerName); } catch (SQLException ex) { Log.toLog(this.getClass().getName(), ex); @@ -108,11 +105,7 @@ public class InspectCommand extends SubCommand { @Override public void run() { timesrun++; - if (inspectCache.isCached(uuid)) { - sendInspectMsg(sender, playerName, uuid); - this.cancel(); - return; - } + // TODO better message sending. if (timesrun > 10) { Log.debug("Command Timeout Message, Inspect."); sender.sendMessage(Locale.get(Msg.CMD_FAIL_TIMEOUT).parse("Inspect")); diff --git a/Plan/src/main/java/com/djrapitops/plan/data/KillData.java b/Plan/src/main/java/com/djrapitops/plan/data/KillData.java index 59e3527ab..ffe0e7547 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/KillData.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/KillData.java @@ -6,7 +6,7 @@ import java.util.Objects; import java.util.UUID; /** - * This class is used to store data about a player kill inside the UserData + * This class is used to store data about a player kill inside the UserInfo * object. * * @author Rsl1122 diff --git a/Plan/src/main/java/com/djrapitops/plan/data/UserData.java b/Plan/src/main/java/com/djrapitops/plan/data/UserData.java deleted file mode 100644 index 0803ef5c4..000000000 --- a/Plan/src/main/java/com/djrapitops/plan/data/UserData.java +++ /dev/null @@ -1,217 +0,0 @@ -package main.java.com.djrapitops.plan.data; - -import java.net.InetAddress; -import java.util.*; - -/** - * This class is used for storing information about a player during runtime. - * - * @author Rsl1122 - */ -// TODO Change to be only used for DB User Get Query responses. -public class UserData { - - private final List sessions; - private int accessing; - private boolean clearAfterSave; - private UUID uuid; - private String name; //TODO DB Update code to JoinListener - @Deprecated - private Set nicknames; //TODO DB Update code to ChatListener - @Deprecated - private String lastNick; //TODO DB Update code to ChatListener - @Deprecated - private String geolocation; //TODO DB Update code to JoinListener - @Deprecated - private Set ips; //TODO DB Update code to JoinListener - @Deprecated - private int timesKicked; //TODO DB Update code to KickListener - @Deprecated - private boolean isOp; //TODO DB Update code to JoinListener - @Deprecated - private boolean isBanned; //TODO DB Update code to JoinListener - @Deprecated - private long registered; //TODO DB Update code to JoinListener (When registering) - @Deprecated - private long lastPlayed; //TODO DB Update code to Join, Refresh, QuitListener - - /** - * Creates a new UserData object with given values and default values. - *

- * Some variables are left uninitialized: isBanned, lastPlayed, playTime, - * loginTimes, timesKicked, lastGmSwapTime, mobKills, deaths, lastWorldSwapTime, lastWorld - *

- * These variables need to be set with setters. - *

- * All Collections are left empty: locations, nicknames, ips, sessions, - * playerKills. Because nicknames is empty, lastNick is an empty string. - *

- * gmTimes Map will contain 4 '0L' values: SURVIVAL, CREATIVE, - * ADVENTURE, SPECTATOR - * worldTimes Map is left empty. - * - * @param uuid UUID of the player - * @param name Name of the player. - */ - public UserData(UUID uuid, String name) { - this.uuid = uuid; - this.name = name; - sessions = new ArrayList<>(); - } - - /** - * Creates a new UserData object with copied values. - * - * @param data UserData to copy into the new object. - */ - public UserData(UserData data) { - this.uuid = data.getUuid(); - this.name = data.getName(); - this.sessions = new ArrayList<>(); - sessions.addAll(data.getSessions()); - } - - /** - * Used to get the UUID of the player. - * - * @return UUID. - */ - public UUID getUuid() { - return uuid; - } - - /** - * Get the InetAddress Set. - * - * @return a HashSet of ips. - */ - public Set getIps() { - return ips; - } - - /** - * Get the nickname String Set. - * - * @return a HashSet of Strings. - */ - public Set getNicknames() { - return nicknames; - } - - /** - * Get the Epoch millisecond the player registered. - * - * @return long in ms. - */ - public long getRegistered() { - return registered; - } - - /** - * Get the Epoch millisecond the player was last seen. - *

- * NOT INITIALIZED BY CONSTRUCTORS. Value is updated periodically by cache - * if the player is online. - * - * @return long in ms. - */ - public long getLastPlayed() { - return lastPlayed; - } - - /** - * Get how many times the player has logged in. - *

- * NOT INITIALIZED BY CONSTRUCTORS. - * - * @return 0 to Integer.MAX - */ - public int getLoginTimes() { - return sessions.size(); - } - - /** - * Get how many times the player has been kicked. - *

- * NOT INITIALIZED BY CONSTRUCTORS. - * - * @return 0 to Integer.MAX - */ - public int getTimesKicked() { - return timesKicked; - } - - /** - * Is the user Operator? - * - * @return opped? - */ - public boolean isOp() { - return isOp; - } - - /** - * Is the user Banned? - * - * @return banned? - */ - public boolean isBanned() { - return isBanned; - } - - /** - * Get the username of the player. - * - * @return username. - */ - public String getName() { - return name; - } - - /** - * Get the sessions of a player. - * - * @return a list of Session. - */ - public List getSessions() { - return sessions; - } - - @Override - public int hashCode() { - int result = sessions.hashCode(); - result = 31 * result + accessing; - result = 31 * result + (clearAfterSave ? 1 : 0); - result = 31 * result + uuid.hashCode(); - result = 31 * result + name.hashCode(); - return result; - } - - @Override - public boolean equals(Object obj) { - if (this == obj) { - return true; - } - if (obj == null) { - return false; - } - if (getClass() != obj.getClass()) { - return false; - } - - final UserData other = (UserData) obj; - - return Objects.equals(this.name, other.name) - && Objects.equals(this.uuid, other.uuid) - && Objects.equals(this.sessions, other.sessions); - } - - public long getPlayTime() { - return 0; //TODO Use Sessions - } - - public List getGeolocations() { - // TODO - return null; - } -} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/data/UserInfo.java b/Plan/src/main/java/com/djrapitops/plan/data/UserInfo.java new file mode 100644 index 000000000..29dd30154 --- /dev/null +++ b/Plan/src/main/java/com/djrapitops/plan/data/UserInfo.java @@ -0,0 +1,70 @@ +package main.java.com.djrapitops.plan.data; + +import java.util.UUID; + +/** + * Used for storing information of players after it has been fetched. + * + * @author Rsl1122 + */ +public class UserInfo { + + private final UUID uuid; + private String name; + private long registered; + private long lastSeen; + private boolean banned; + private boolean opped; + + public UserInfo(UUID uuid) { + this.uuid = uuid; + } + + public UserInfo(UUID uuid, String name, long registered, boolean opped, boolean banned) { + this.uuid = uuid; + this.name = name; + this.registered = registered; + this.opped = opped; + this.banned = banned; + } + + public UUID getUuid() { + return uuid; + } + + public String getName() { + return name; + } + + public void setName(String name) { + this.name = name; + } + + public long getRegistered() { + return registered; + } + + public void setRegistered(long registered) { + this.registered = registered; + } + + public long getLastSeen() { + return lastSeen; + } + + public void setLastSeen(long lastSeen) { + this.lastSeen = lastSeen; + } + + public void setBanned(boolean banned) { + this.banned = banned; + } + + public boolean isBanned() { + return banned; + } + + public boolean isOpped() { + return opped; + } +} \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/data/cache/DBCallableProcessor.java b/Plan/src/main/java/com/djrapitops/plan/data/cache/DBCallableProcessor.java index 07d0883aa..9ceb1cf73 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/cache/DBCallableProcessor.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/cache/DBCallableProcessor.java @@ -1,12 +1,12 @@ package main.java.com.djrapitops.plan.data.cache; -import main.java.com.djrapitops.plan.data.UserData; +import main.java.com.djrapitops.plan.data.UserInfo; /** * This interface can be extended with anything as the process method and * given to the Database. *

- * The process method will be called with the UserData object fetched from the + * The process method will be called with the UserInfo object fetched from the * database. * * @author Rsl1122 @@ -16,11 +16,11 @@ import main.java.com.djrapitops.plan.data.UserData; public interface DBCallableProcessor { /** - * Method used to do multiple things to UserData objects such as Caching, + * Method used to do multiple things to UserInfo objects such as Caching, * changing properties etc. * - * @param data UserData object given to the DBCallableProcessor by the + * @param data UserInfo object given to the DBCallableProcessor by the * method it was given as parameter to. */ - void process(UserData data); + void process(UserInfo data); } diff --git a/Plan/src/main/java/com/djrapitops/plan/data/cache/InspectCacheHandler.java b/Plan/src/main/java/com/djrapitops/plan/data/cache/InspectCacheHandler.java deleted file mode 100644 index a7c87f4aa..000000000 --- a/Plan/src/main/java/com/djrapitops/plan/data/cache/InspectCacheHandler.java +++ /dev/null @@ -1,123 +0,0 @@ -package main.java.com.djrapitops.plan.data.cache; - -import main.java.com.djrapitops.plan.Log; -import main.java.com.djrapitops.plan.Plan; -import main.java.com.djrapitops.plan.data.UserData; -import main.java.com.djrapitops.plan.database.Database; -import main.java.com.djrapitops.plan.ui.webserver.response.InspectPageResponse; -import main.java.com.djrapitops.plan.ui.webserver.response.api.JsonResponse; -import main.java.com.djrapitops.plan.utilities.HtmlUtils; -import main.java.com.djrapitops.plan.utilities.MiscUtils; -import main.java.com.djrapitops.plan.utilities.analysis.ExportUtility; - -import java.io.FileNotFoundException; -import java.sql.SQLException; -import java.util.*; - -/** - * This class stores UserData objects used for displaying the Html pages. - * - * @author Rsl1122 - * @since 2.0.0 - */ -@Deprecated -public class InspectCacheHandler { - - private final DataCache dataCache; - private final Map cache; - private final Map cacheTimes; - - /** - * Class constructor. - * - * @param plugin Current instance of Plan.class - */ - public InspectCacheHandler(Plan plugin) { - this.dataCache = plugin.getDataCache(); - this.cache = new HashMap<>(); - cacheTimes = new HashMap<>(); - } - - /** - * Caches the UserData object to InspectCache. - *

- * If the Userdata is cached in DataCache it will be used. Otherwise the Get - * Queue will handle the DBCallableProcessor. - * - * @param uuid UUID of the player. - */ - @Deprecated // Does not cache anything anymore // TODO Remove - public void cache(UUID uuid) { - DBCallableProcessor cacher = data -> { - UserData userData = new UserData(data); - - cache.put(uuid, userData); - cacheTimes.put(uuid, MiscUtils.getTime()); - - PageCacheHandler.cachePage("inspectPage: " + uuid, () -> new InspectPageResponse(Plan.getInstance().getUiServer().getDataReqHandler(), uuid)); - PageCacheHandler.cachePage("inspectionJson: " + uuid, () -> new JsonResponse(userData)); - - try { - ExportUtility.writeInspectHtml(data, ExportUtility.getPlayersFolder(ExportUtility.getFolder()), HtmlUtils.getStringFromResource("player.html")); - } catch (FileNotFoundException e) { - Log.toLog(this.getClass().getName(), e); - } - }; - } - - /** - * Used to cache all UserData to the InspectCache from the cache and - * provided database. - * - * @param db Database to cache from if data is not in the cache. - * @throws SQLException If Database is not properly enabled - */ - public void cacheAllUserData(Database db) throws SQLException { - List userDataForUUIDS = db.getUserDataForUUIDS(db.getUsersTable().getSavedUUIDs()); - long time = MiscUtils.getTime(); - for (UserData uData : userDataForUUIDS) { - UUID uuid = uData.getUuid(); - cache.put(uuid, new UserData(uData)); - cacheTimes.put(uuid, time); - } - } - - /** - * Checks the cache for UserData matching UUID. - * - * @param uuid UUID of the Player - * @return UserData that matches the player, null if not cached. - */ - public UserData getFromCache(UUID uuid) { - return cache.get(uuid); - } - - /** - * Returns the Epoch millisecond the data was cached to the inspect cache. - * - * @param uuid UUID of the player. - * @return -1 when not cached or Epoch millisecond. - */ - public long getCacheTime(UUID uuid) { - return cacheTimes.getOrDefault(uuid, -1L); - } - - /** - * Check if the data of a player is in the inspect cache. - * - * @param uuid UUID of player. - * @return true if cached. - */ - public boolean isCached(UUID uuid) { - return cache.containsKey(uuid); - } - - /** - * Used to get all cached userdata objects. - * - * @return List of cached userdata objects. - */ - public List getCachedUserData() { - return new ArrayList<>(cache.values()); - } -} diff --git a/Plan/src/main/java/com/djrapitops/plan/data/listeners/PlanPlayerListener.java b/Plan/src/main/java/com/djrapitops/plan/data/listeners/PlanPlayerListener.java index ce57b68c9..b996080b7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/listeners/PlanPlayerListener.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/listeners/PlanPlayerListener.java @@ -100,7 +100,7 @@ public class PlanPlayerListener implements Listener { cache.cacheSession(uuid, Session.start(time, world, gm)); plugin.addToProcessQueue( - new RegisterProcessor(this, uuid, time, playerName, playersOnline), + new RegisterProcessor(this, uuid, player.getFirstPlayed(), playerName, playersOnline), new IPUpdateProcessor(uuid, ip), new NameProcessor(uuid, playerName, displayName), // TODO NameCache to DataCache new DBCommitProcessor(plugin.getDB()) diff --git a/Plan/src/main/java/com/djrapitops/plan/database/Database.java b/Plan/src/main/java/com/djrapitops/plan/database/Database.java index 6a5c20258..3933c3a79 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/Database.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/Database.java @@ -1,7 +1,7 @@ package main.java.com.djrapitops.plan.database; import main.java.com.djrapitops.plan.Plan; -import main.java.com.djrapitops.plan.data.UserData; +import main.java.com.djrapitops.plan.data.UserInfo; import main.java.com.djrapitops.plan.database.tables.*; import java.sql.SQLException; @@ -27,6 +27,11 @@ public abstract class Database { */ protected UsersTable usersTable; + /** + * Table representing plan_user_info in the database. + */ + protected UserInfoTable userInfoTable; + /** * Table representing plan_actions in the database. */ @@ -116,7 +121,7 @@ public abstract class Database { } /** - * Used to get all UserData for multiple UUIDs. + * Used to get all UserInfo for multiple UUIDs. *

* Should only be called from async thread. * @@ -124,7 +129,7 @@ public abstract class Database { * @return Data for matching UUIDs. * @throws SQLException If database error occurs. */ - public abstract List getUserDataForUUIDS(Collection uuids) throws SQLException; + public abstract List getUserDataForUUIDS(Collection uuids) throws SQLException; /** * Check if the user is saved in the database. diff --git a/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java b/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java index ff9852e7c..e5f2116ad 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/databases/SQLDB.java @@ -3,7 +3,7 @@ package main.java.com.djrapitops.plan.database.databases; import com.djrapitops.plugin.task.AbsRunnable; import main.java.com.djrapitops.plan.Log; import main.java.com.djrapitops.plan.Plan; -import main.java.com.djrapitops.plan.data.UserData; +import main.java.com.djrapitops.plan.data.UserInfo; import main.java.com.djrapitops.plan.database.Database; import main.java.com.djrapitops.plan.database.tables.*; import main.java.com.djrapitops.plan.utilities.Benchmark; @@ -44,6 +44,7 @@ public abstract class SQLDB extends Database { tpsTable = new TPSTable(this, usingMySQL); usersTable = new UsersTable(this, usingMySQL); + userInfoTable = new UserInfoTable(this, usingMySQL); actionsTable = new ActionsTable(this, usingMySQL); ipsTable = new IPsTable(this, usingMySQL); nicknamesTable = new NicknamesTable(this, usingMySQL); @@ -185,7 +186,7 @@ public abstract class SQLDB extends Database { */ public Table[] getAllTables() { return new Table[]{ - serverTable, usersTable, ipsTable, + serverTable, usersTable, userInfoTable, ipsTable, nicknamesTable, sessionsTable, killsTable, commandUseTable, actionsTable, tpsTable, worldTable, worldTimesTable, securityTable @@ -201,8 +202,8 @@ public abstract class SQLDB extends Database { return new Table[]{ ipsTable, nicknamesTable, killsTable, worldTimesTable, sessionsTable, actionsTable, - worldTable, usersTable, commandUseTable, - tpsTable, serverTable + worldTable, userInfoTable, usersTable, + commandUseTable, tpsTable, serverTable }; } @@ -336,7 +337,7 @@ public abstract class SQLDB extends Database { } @Override - public List getUserDataForUUIDS(Collection uuidsCol) throws SQLException { + public List getUserDataForUUIDS(Collection uuidsCol) throws SQLException { if (uuidsCol == null || uuidsCol.isEmpty()) { return new ArrayList<>(); } diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/UserInfoTable.java b/Plan/src/main/java/com/djrapitops/plan/database/tables/UserInfoTable.java index 9dbe3b808..319f87110 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/UserInfoTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/tables/UserInfoTable.java @@ -4,9 +4,20 @@ */ package main.java.com.djrapitops.plan.database.tables; +import main.java.com.djrapitops.plan.Plan; +import main.java.com.djrapitops.plan.data.UserInfo; import main.java.com.djrapitops.plan.database.databases.SQLDB; +import main.java.com.djrapitops.plan.database.sql.Select; import main.java.com.djrapitops.plan.database.sql.Sql; import main.java.com.djrapitops.plan.database.sql.TableSqlParser; +import main.java.com.djrapitops.plan.database.sql.Update; + +import java.sql.PreparedStatement; +import java.sql.ResultSet; +import java.sql.SQLException; +import java.util.ArrayList; +import java.util.List; +import java.util.UUID; /** * //TODO Class Javadoc Comment @@ -16,7 +27,6 @@ import main.java.com.djrapitops.plan.database.sql.TableSqlParser; public class UserInfoTable extends UserIDTable { //TODO Server Specific Table - private final String columnUserID = "user_ id"; private final String columnRegistered = "registered"; private final String columnOP = "opped"; private final String columnBanned = "banned"; @@ -41,4 +51,138 @@ public class UserInfoTable extends UserIDTable { .foreignKey(columnServerID, serverTable.getTableName(), serverTable.getColumnID()) .toString()); } + + public void registerUserInfo(UUID uuid, long registered) throws SQLException { + if (!usersTable.isRegistered(uuid)) { + usersTable.registerUser(uuid, registered, "Waiting for Update.."); + } + + PreparedStatement statement = null; + try { + statement = prepareStatement("INSERT INTO " + tableName + " (" + + columnUserID + ", " + + columnRegistered + ", " + + columnServerID + + ") VALUES (" + + usersTable.statementSelectID + ", " + + "?, " + + serverTable.statementSelectServerID + ")"); + statement.setString(1, uuid.toString()); + statement.setLong(2, registered); + statement.setString(3, Plan.getServerUUID().toString()); + statement.execute(); + } finally { + close(statement); + } + } + + public boolean isRegistered(UUID uuid) throws SQLException { + PreparedStatement statement = null; + ResultSet set = null; + try { + statement = prepareStatement(Select.from(tableName, columnUserID) + .where(columnUserID + "=" + usersTable.statementSelectID) + .toString()); + statement.setString(1, uuid.toString()); + set = statement.executeQuery(); + return set.next(); + } finally { + close(set, statement); + } + } + + public void updateOpAndBanStatus(UUID uuid, boolean opped, boolean banned) throws SQLException { + PreparedStatement statement = null; + try { + statement = prepareStatement(Update.values(tableName, columnOP, columnBanned) + .where(columnUserID + "=" + usersTable.statementSelectID) + .toString()); + statement.setBoolean(1, opped); + statement.setBoolean(2, banned); + statement.setString(3, uuid.toString()); + statement.execute(); + } finally { + close(statement); + } + } + + public UserInfo getUserInfo(UUID uuid) throws SQLException { + return getUserInfo(uuid, Plan.getServerUUID()); + } + + public UserInfo getUserInfo(UUID uuid, UUID serverUUID) throws SQLException { + PreparedStatement statement = null; + ResultSet set = null; + try { + String usersIDColumn = usersTable + "." + usersTable.getColumnID(); + String usersNameColumn = usersTable + "." + usersTable.getColumnName() + " as name"; + statement = prepareStatement("SELECT " + + columnRegistered + ", " + + columnOP + ", " + + columnBanned + ", " + + usersNameColumn + + " FROM " + tableName + + " WHERE " + columnUserID + "=" + usersTable.statementSelectID + + " AND " + columnServerID + "=" + serverTable.statementSelectServerID + + " JOIN " + usersTable + " on " + usersIDColumn + "=" + columnUserID + ); + statement.setString(1, uuid.toString()); + statement.setString(2, serverUUID.toString()); + set = statement.executeQuery(); + if (set.next()) { + long registered = set.getLong(columnRegistered); + boolean opped = set.getBoolean(columnOP); + boolean banned = set.getBoolean(columnBanned); + String name = set.getString("name"); + return new UserInfo(uuid, name, registered, opped, banned); + } + return null; + } finally { + close(set, statement); + } + } + + /** + * Used for getting info of all users on THIS server. + * + * @return List of UserInfo objects. + */ + public List getAllUserInfo() throws SQLException { + return getAllUserInfo(Plan.getServerUUID()); + } + + public List getAllUserInfo(UUID serverUUID) throws SQLException { + PreparedStatement statement = null; + ResultSet set = null; + try { + List userInfo = new ArrayList<>(); + String usersIDColumn = usersTable + "." + usersTable.getColumnID(); + String usersUUIDColumn = usersTable + "." + usersTable.getColumnUUID() + " as uuid"; + String usersNameColumn = usersTable + "." + usersTable.getColumnName() + " as name"; + statement = prepareStatement("SELECT " + + columnRegistered + ", " + + columnOP + ", " + + columnBanned + ", " + + usersNameColumn + ", " + + usersUUIDColumn + + " FROM " + tableName + + " WHERE " + columnServerID + "=" + serverTable.statementSelectServerID + + " JOIN " + usersTable + " on " + usersIDColumn + "=" + columnUserID + ); + statement.setFetchSize(2000); + statement.setString(1, serverUUID.toString()); + set = statement.executeQuery(); + while (set.next()) { + long registered = set.getLong(columnRegistered); + boolean opped = set.getBoolean(columnOP); + boolean banned = set.getBoolean(columnBanned); + String name = set.getString("name"); + UUID uuid = UUID.fromString(set.getString("uuid")); + userInfo.add(new UserInfo(uuid, name, registered, opped, banned)); + } + return userInfo; + } finally { + close(set, statement); + } + } } \ No newline at end of file diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/UsersTable.java b/Plan/src/main/java/com/djrapitops/plan/database/tables/UsersTable.java index 3d94ed732..f1ad3e7b9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/UsersTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/tables/UsersTable.java @@ -224,4 +224,8 @@ public class UsersTable extends UserIDTable { close(statement); } } + + public String getColumnName() { + return columnName; + } } diff --git a/Plan/src/main/java/com/djrapitops/plan/ui/html/DataRequestHandler.java b/Plan/src/main/java/com/djrapitops/plan/ui/html/DataRequestHandler.java index 89a538d9f..85d94d447 100644 --- a/Plan/src/main/java/com/djrapitops/plan/ui/html/DataRequestHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/ui/html/DataRequestHandler.java @@ -1,13 +1,7 @@ package main.java.com.djrapitops.plan.ui.html; import main.java.com.djrapitops.plan.Plan; -import main.java.com.djrapitops.plan.data.UserData; -import main.java.com.djrapitops.plan.data.cache.AnalysisCacheHandler; -import main.java.com.djrapitops.plan.data.cache.InspectCacheHandler; -import main.java.com.djrapitops.plan.utilities.HtmlUtils; -import main.java.com.djrapitops.plan.utilities.PlaceholderUtils; -import java.io.FileNotFoundException; import java.util.UUID; /** @@ -16,17 +10,13 @@ import java.util.UUID; @Deprecated //TODO Make an utility class for parsing files to give to the page cache. public class DataRequestHandler { - private final InspectCacheHandler inspectCache; - private final AnalysisCacheHandler analysisCache; - /** * Class Constructor. * * @param plugin Current instance of Plan */ + @Deprecated public DataRequestHandler(Plan plugin) { - this.inspectCache = plugin.getInspectCache(); - this.analysisCache = plugin.getAnalysisCache(); } /** @@ -35,31 +25,23 @@ public class DataRequestHandler { * @param uuid UUID of Player * @return true if cached. */ + @Deprecated public boolean checkIfCached(UUID uuid) { - return inspectCache.isCached(uuid); + // TODO Check from PageCache + return false; } /** * Returns the player.html as string with replaced placeholders. * - * @param uuid UUID of player, whose UserData is used to replace + * @param uuid UUID of player, whose UserInfo is used to replace * placeholders with * @return The html */ + @Deprecated public String getInspectHtml(UUID uuid) { - try { - UserData data = inspectCache.getFromCache(uuid); - if (data == null) { - return "

404 Data was not found in cache

"; - } - - return HtmlUtils.replacePlaceholders( - HtmlUtils.getStringFromResource("player.html"), - PlaceholderUtils.getInspectReplaceRules(data) - ); - } catch (FileNotFoundException ex) { - return "

404 player.html was not found.

"; - } + // TODO Get from PageCache + return ""; } /** @@ -67,17 +49,10 @@ public class DataRequestHandler { * * @return the html */ + @Deprecated public String getServerHtml() { - try { - if (!analysisCache.isCached()) { - return "

404 Data was not found in cache

"; - } - return HtmlUtils.replacePlaceholders( - HtmlUtils.getStringFromResource("server.html"), - PlaceholderUtils.getAnalysisReplaceRules(analysisCache.getData())); - } catch (FileNotFoundException ex) { - return "

404 server.html was not found

"; - } + // TODO Get from PageCache + return ""; } /** @@ -85,7 +60,9 @@ public class DataRequestHandler { * * @return true if cached. */ + @Deprecated public boolean checkIfAnalysisIsCached() { - return analysisCache.isCached(); + // TODO Check from PageCache + return false; } } diff --git a/Plan/src/main/java/com/djrapitops/plan/ui/html/tables/PlayersTableCreator.java b/Plan/src/main/java/com/djrapitops/plan/ui/html/tables/PlayersTableCreator.java index b240fd856..96fb43eca 100644 --- a/Plan/src/main/java/com/djrapitops/plan/ui/html/tables/PlayersTableCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/ui/html/tables/PlayersTableCreator.java @@ -1,17 +1,14 @@ package main.java.com.djrapitops.plan.ui.html.tables; -import main.java.com.djrapitops.plan.data.UserData; -import main.java.com.djrapitops.plan.ui.html.Html; -import main.java.com.djrapitops.plan.utilities.FormatUtils; -import main.java.com.djrapitops.plan.utilities.HtmlUtils; +import main.java.com.djrapitops.plan.data.UserInfo; import main.java.com.djrapitops.plan.utilities.MiscUtils; -import main.java.com.djrapitops.plan.utilities.analysis.AnalysisUtils; import java.util.List; /** * @author Rsl1122 */ +// TODO Rewrite! public class PlayersTableCreator { /** @@ -22,36 +19,36 @@ public class PlayersTableCreator { } /** - * @param data The list of the {@link UserData} Objects from which the players table should be created + * @param data The list of the {@link UserInfo} Objects from which the players table should be created * @return The created players table */ - public static String createSortablePlayersTable(List data) { + public static String createSortablePlayersTable(List data) { StringBuilder html = new StringBuilder(); long now = MiscUtils.getTime(); int i = 0; - for (UserData uData : data) { + for (UserInfo uData : data) { if (i >= 750) { break; } try { - boolean isBanned = uData.isBanned(); - boolean isUnknown = uData.getLoginTimes() == 1; - boolean isActive = AnalysisUtils.isActive(now, uData.getLastPlayed(), uData.getPlayTime(), uData.getLoginTimes()); - - String activityString = getActivityString(isBanned, isUnknown, isActive); - - html.append(Html.TABLELINE_PLAYERS.parse( - Html.LINK.parse(HtmlUtils.getRelativeInspectUrl(uData.getName()), uData.getName()), - activityString, - String.valueOf(uData.getPlayTime()), FormatUtils.formatTimeAmount(uData.getPlayTime()), - String.valueOf(uData.getLoginTimes()), - String.valueOf(uData.getRegistered()), FormatUtils.formatTimeStampYear(uData.getRegistered()), - String.valueOf(uData.getLastPlayed()), FormatUtils.formatTimeStamp(uData.getLastPlayed()), - String.valueOf(uData.getGeolocations()) //TODO get last Geoloc - )); +// boolean isBanned = uData.isBanned(); +// boolean isUnknown = uData.getLoginTimes() == 1; +// boolean isActive = AnalysisUtils.isActive(now, uData.getLastPlayed(), uData.getPlayTime(), uData.getLoginTimes()); +// +// String activityString = getActivityString(isBanned, isUnknown, isActive); +// +// html.append(Html.TABLELINE_PLAYERS.parse( +// Html.LINK.parse(HtmlUtils.getRelativeInspectUrl(uData.getName()), uData.getName()), +// activityString, +// String.valueOf(uData.getPlayTime()), FormatUtils.formatTimeAmount(uData.getPlayTime()), +// String.valueOf(uData.getLoginTimes()), +// String.valueOf(uData.getRegistered()), FormatUtils.formatTimeStampYear(uData.getRegistered()), +// String.valueOf(uData.getLastPlayed()), FormatUtils.formatTimeStamp(uData.getLastPlayed()), +// String.valueOf(uData.getGeolocations()) //TODO get last Geoloc +// )); } catch (NullPointerException ignored) { } diff --git a/Plan/src/main/java/com/djrapitops/plan/ui/webserver/api/bukkit/AnalyzeWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/ui/webserver/api/bukkit/AnalyzeWebAPI.java index 37d1838d3..d1e978456 100644 --- a/Plan/src/main/java/com/djrapitops/plan/ui/webserver/api/bukkit/AnalyzeWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/ui/webserver/api/bukkit/AnalyzeWebAPI.java @@ -18,7 +18,7 @@ import java.util.Map; public class AnalyzeWebAPI implements WebAPI { @Override public Response onResponse(Plan plan, Map variables) { - plan.getAnalysisCache().updateCache(); + // TODO plan.getAnalysisCache().updateCache(); return PageCacheHandler.loadPage("success", SuccessResponse::new); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/ui/webserver/api/bukkit/InspectWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/ui/webserver/api/bukkit/InspectWebAPI.java index c64e10694..b1cd723a4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/ui/webserver/api/bukkit/InspectWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/ui/webserver/api/bukkit/InspectWebAPI.java @@ -35,7 +35,7 @@ public class InspectWebAPI implements WebAPI { return PageCacheHandler.loadPage(error, () -> new BadRequestResponse(error)); } - plan.getInspectCache().cache(uuid); + // TODO plan.getInspectCache().cache(uuid); return PageCacheHandler.loadPage("success", SuccessResponse::new); } diff --git a/Plan/src/main/java/com/djrapitops/plan/ui/webserver/api/bukkit/InspectionWebAPI.java b/Plan/src/main/java/com/djrapitops/plan/ui/webserver/api/bukkit/InspectionWebAPI.java index 95c975f7d..de80b5670 100644 --- a/Plan/src/main/java/com/djrapitops/plan/ui/webserver/api/bukkit/InspectionWebAPI.java +++ b/Plan/src/main/java/com/djrapitops/plan/ui/webserver/api/bukkit/InspectionWebAPI.java @@ -5,44 +5,41 @@ package main.java.com.djrapitops.plan.ui.webserver.api.bukkit; import main.java.com.djrapitops.plan.Plan; -import main.java.com.djrapitops.plan.data.UserData; -import main.java.com.djrapitops.plan.data.cache.PageCacheHandler; import main.java.com.djrapitops.plan.ui.webserver.response.Response; import main.java.com.djrapitops.plan.ui.webserver.response.api.BadRequestResponse; -import main.java.com.djrapitops.plan.ui.webserver.response.api.JsonResponse; -import main.java.com.djrapitops.plan.utilities.uuid.UUIDUtility; import main.java.com.djrapitops.plan.utilities.webserver.api.WebAPI; import java.util.Map; -import java.util.UUID; /** * @author Fuzzlemann */ +@Deprecated // UserData objects should not be sent between servers. public class InspectionWebAPI implements WebAPI { @Override public Response onResponse(Plan plan, Map variables) { - String playerString = variables.get("player"); - - if (playerString == null) { - String error = "Player String not included"; - return PageCacheHandler.loadPage(error, () -> new BadRequestResponse(error)); - } - - UUID uuid = UUIDUtility.getUUIDOf(playerString); - - if (uuid == null) { - String error = "UUID not found"; - return PageCacheHandler.loadPage(error, () -> new BadRequestResponse(error)); - } - - UserData userData = plan.getInspectCache().getFromCache(uuid); - - if (userData == null) { - String error = "User not cached"; - return PageCacheHandler.loadPage(error, () -> new BadRequestResponse(error)); - } - - return PageCacheHandler.loadPage("inspectionJson: " + uuid, () -> new JsonResponse(plan.getInspectCache().getFromCache(uuid))); +// String playerString = variables.get("player"); +// +// if (playerString == null) { +// String error = "Player String not included"; +// return PageCacheHandler.loadPage(error, () -> new BadRequestResponse(error)); +// } +// +// UUID uuid = UUIDUtility.getUUIDOf(playerString); +// +// if (uuid == null) { +// String error = "UUID not found"; +// return PageCacheHandler.loadPage(error, () -> new BadRequestResponse(error)); +// } +// +// UserInfo userInfo = plan.getInspectCache().getFromCache(uuid); +// +// if (userInfo == null) { +// String error = "User not cached"; +// return PageCacheHandler.loadPage(error, () -> new BadRequestResponse(error)); +// } +// +// return PageCacheHandler.loadPage("inspectionJson: " + uuid, () -> new JsonResponse(plan.getInspectCache().getFromCache(uuid))); + return new BadRequestResponse("Not implemented"); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/ui/webserver/response/PlayersPageResponse.java b/Plan/src/main/java/com/djrapitops/plan/ui/webserver/response/PlayersPageResponse.java index 83ed21ccb..170304d15 100644 --- a/Plan/src/main/java/com/djrapitops/plan/ui/webserver/response/PlayersPageResponse.java +++ b/Plan/src/main/java/com/djrapitops/plan/ui/webserver/response/PlayersPageResponse.java @@ -1,7 +1,7 @@ package main.java.com.djrapitops.plan.ui.webserver.response; import main.java.com.djrapitops.plan.Plan; -import main.java.com.djrapitops.plan.data.UserData; +import main.java.com.djrapitops.plan.data.UserInfo; import main.java.com.djrapitops.plan.ui.html.Html; import main.java.com.djrapitops.plan.utilities.HtmlUtils; import main.java.com.djrapitops.plan.utilities.comparators.UserDataNameComparator; @@ -16,10 +16,10 @@ public class PlayersPageResponse extends Response { public PlayersPageResponse(Plan plugin) { super.setHeader("HTTP/1.1 200 OK"); - super.setContent(buildContent(plugin.getInspectCache().getCachedUserData())); +// super.setContent(buildContent(plugin.getInspectCache().getCachedUserData())); } - public static String buildContent(List cached) { + public static String buildContent(List cached) { StringBuilder html = new StringBuilder("

Cached Players

"); int size = cached.size(); @@ -29,8 +29,8 @@ public class PlayersPageResponse extends Response { cached.sort(new UserDataNameComparator()); int i = 1; - for (UserData userData : cached) { - String name = userData.getName(); + for (UserInfo userInfo : cached) { + String name = userInfo.getName(); String link = Html.LINK.parse(HtmlUtils.getRelativeInspectUrl(name), name); html.append("").append(link).append(""); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/ManageUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/ManageUtils.java index 57e3196e2..d63d73a0f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/ManageUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/ManageUtils.java @@ -68,7 +68,7 @@ public class ManageUtils { public static boolean clearAndCopy(Database clearAndCopyToDB, Database copyFromDB) { try { clearAndCopyToDB.removeAllData(); - //TODO List allUserData = copyFromDB.getUserDataForUUIDS(copyFromDB.getSavedUUIDs()); + //TODO List allUserData = copyFromDB.getUserDataForUUIDS(copyFromDB.getSavedUUIDs()); // clearAndCopyToDB.saveMultipleUserData(allUserData); clearAndCopyToDB.getCommandUseTable().saveCommandUse(copyFromDB.getCommandUseTable().getCommandUse()); clearAndCopyToDB.getTpsTable().saveTPSData(copyFromDB.getTpsTable().getTPSData()); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/MiscUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/MiscUtils.java index 9b295ab54..d834d9eb9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/MiscUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/MiscUtils.java @@ -3,17 +3,14 @@ package main.java.com.djrapitops.plan.utilities; import com.djrapitops.plugin.api.TimeAmount; import com.djrapitops.plugin.command.CommandUtils; import com.djrapitops.plugin.command.ISender; -import main.java.com.djrapitops.plan.Log; import main.java.com.djrapitops.plan.Permissions; import main.java.com.djrapitops.plan.Plan; -import main.java.com.djrapitops.plan.data.UserData; import main.java.com.djrapitops.plan.database.Database; import main.java.com.djrapitops.plan.locale.Locale; import main.java.com.djrapitops.plan.locale.Msg; import java.io.Closeable; import java.io.IOException; -import java.sql.SQLException; import java.util.*; import java.util.stream.Collectors; @@ -91,15 +88,11 @@ public class MiscUtils { final String searchFor = search.toLowerCase(); Database db = Plan.getInstance().getDB(); List matches = new ArrayList<>(); - try { - List data = db.getUserDataForUUIDS(db.getSavedUUIDs()); - matches = data.stream() - .map(UserData::getName) - .filter(name -> name.toLowerCase().contains(searchFor)) - .collect(Collectors.toList()); - } catch (SQLException e) { - Log.toLog("MiscUtils.getMatchingPlayerNames", e); - } +// try { + // TODO GetMatchingPlayerNamesFromDB +// } catch (SQLException e) { +// Log.toLog("MiscUtils.getMatchingPlayerNames", e); +// } Collections.sort(matches); return matches; } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/NewPlayerCreator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/NewPlayerCreator.java index c0e7f9aba..03d8a991b 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/NewPlayerCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/NewPlayerCreator.java @@ -3,7 +3,7 @@ package main.java.com.djrapitops.plan.utilities; import com.djrapitops.plugin.utilities.player.Gamemode; import com.djrapitops.plugin.utilities.player.IOfflinePlayer; import com.djrapitops.plugin.utilities.player.IPlayer; -import main.java.com.djrapitops.plan.data.UserData; +import main.java.com.djrapitops.plan.data.UserInfo; /** * @author Rsl1122 @@ -19,33 +19,33 @@ public class NewPlayerCreator { } /** - * Creates a new instance of UserData with default values. + * Creates a new instance of UserInfo with default values. * - * @param player Player the UserData is created for. - * @return a new UserData object + * @param player Player the UserInfo is created for. + * @return a new UserInfo object */ - public static UserData createNewPlayer(IPlayer player) { + public static UserInfo createNewPlayer(IPlayer player) { return createNewPlayer(player, player.getGamemode()); } /** - * Creates a new instance of UserData with default values. + * Creates a new instance of UserInfo with default values. * - * @param player OfflinePlayer the UserData is created for. - * @return a new UserData object + * @param player OfflinePlayer the UserInfo is created for. + * @return a new UserInfo object */ - public static UserData createNewOfflinePlayer(IOfflinePlayer player) { + public static UserInfo createNewOfflinePlayer(IOfflinePlayer player) { return createNewPlayer(player, Gamemode.SURVIVAL); } /** - * Creates a new instance of UserData with default values. + * Creates a new instance of UserInfo with default values. * - * @param player Player the UserData is created for. + * @param player Player the UserInfo is created for. * @param gm Gamemode set as the starting Gamemode - * @return a new UserData object + * @return a new UserInfo object */ - public static UserData createNewPlayer(IOfflinePlayer player, Gamemode gm) { + public static UserInfo createNewPlayer(IOfflinePlayer player, Gamemode gm) { return null; } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/PlaceholderUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/PlaceholderUtils.java index 505b4f7c7..03b441b5e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/PlaceholderUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/PlaceholderUtils.java @@ -3,12 +3,12 @@ package main.java.com.djrapitops.plan.utilities; import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Settings; import main.java.com.djrapitops.plan.data.AnalysisData; -import main.java.com.djrapitops.plan.data.Session; -import main.java.com.djrapitops.plan.data.UserData; -import main.java.com.djrapitops.plan.ui.html.graphs.PunchCardGraphCreator; +import main.java.com.djrapitops.plan.data.UserInfo; import java.io.Serializable; -import java.util.*; +import java.util.HashMap; +import java.util.Map; +import java.util.UUID; /** * @author Rsl1122 @@ -47,10 +47,10 @@ public class PlaceholderUtils { /** * Gets the Map that is used to replace placeholders. * - * @param data UserData used to replace the placeholders with + * @param data UserInfo used to replace the placeholders with * @return HashMap that contains string for each placeholder. */ - public static Map getInspectReplaceRules(UserData data) { + public static Map getInspectReplaceRules(UserInfo data) { HashMap replaceMap = new HashMap<>(); UUID uuid = data.getUuid(); @@ -64,18 +64,18 @@ public class PlaceholderUtils { replaceMap.put("geolocations", "TODO"); //TODO Geolocation list creator • name
replaceMap.put("registered", FormatUtils.formatTimeStampYear(data.getRegistered())); - replaceMap.put("lastSeen", FormatUtils.formatTimeStampYear(data.getLastPlayed())); +// replaceMap.put("lastSeen", FormatUtils.formatTimeStampYear(data.getLastPlayed())); - replaceMap.put("sessionCount", data.getSessions().size()); +// replaceMap.put("sessionCount", data.getSessions().size()); //TODO replaceMap.put("playtimeTotal", FormatUtils.formatTimeAmount(data.getPlayTime())); - replaceMap.put("kickCount", data.getTimesKicked()); +// replaceMap.put("kickCount", data.getTimesKicked()); // replaceMap.put("playerKillCount", data.getPlayerKills().size()); //TODO // replaceMap.put("mobKillCount", data.getMobKills()); // replaceMap.put("deathCount", data.getDeaths()); - Set sessions = new HashSet<>(data.getSessions()); - replaceMap.put("punchCardSeries", PunchCardGraphCreator.createDataSeries(sessions)); +// Set sessions = new HashSet<>(data.getSessions()); +// replaceMap.put("punchCardSeries", PunchCardGraphCreator.createDataSeries(sessions)); //TODO WorldTimes worldTimes = data.getWorldTimes(); // TODO replaceMap.put("worldSeries", WorldPieCreator.createSeriesData(worldTimes.getTimes())); // replaceMap.put("worldTotal", FormatUtils.formatTimeAmount(worldTimes.getTotal())); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java index 3dac3b572..514d98d9a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/Analysis.java @@ -5,28 +5,23 @@ import com.djrapitops.plugin.utilities.Verify; import main.java.com.djrapitops.plan.Log; import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.data.AnalysisData; -import main.java.com.djrapitops.plan.data.Session; import main.java.com.djrapitops.plan.data.TPS; -import main.java.com.djrapitops.plan.data.UserData; import main.java.com.djrapitops.plan.data.additional.AnalysisType; import main.java.com.djrapitops.plan.data.additional.HookHandler; import main.java.com.djrapitops.plan.data.additional.PluginData; import main.java.com.djrapitops.plan.data.analysis.*; import main.java.com.djrapitops.plan.data.cache.AnalysisCacheHandler; import main.java.com.djrapitops.plan.data.cache.DataCache; -import main.java.com.djrapitops.plan.data.cache.InspectCacheHandler; import main.java.com.djrapitops.plan.data.cache.PageCacheHandler; import main.java.com.djrapitops.plan.database.Database; import main.java.com.djrapitops.plan.locale.Locale; import main.java.com.djrapitops.plan.locale.Msg; -import main.java.com.djrapitops.plan.ui.html.tables.PlayersTableCreator; import main.java.com.djrapitops.plan.ui.webserver.response.AnalysisPageResponse; import main.java.com.djrapitops.plan.ui.webserver.response.PlayersPageResponse; import main.java.com.djrapitops.plan.ui.webserver.response.api.JsonResponse; import main.java.com.djrapitops.plan.utilities.Benchmark; import main.java.com.djrapitops.plan.utilities.HtmlUtils; import main.java.com.djrapitops.plan.utilities.MiscUtils; -import main.java.com.djrapitops.plan.utilities.comparators.UserDataLastPlayedComparator; import java.io.Serializable; import java.util.*; @@ -38,7 +33,6 @@ import java.util.stream.Collectors; public class Analysis { private final Plan plugin; - private final InspectCacheHandler inspectCache; private int taskId = -1; /** @@ -48,7 +42,6 @@ public class Analysis { */ public Analysis(Plan plugin) { this.plugin = plugin; - this.inspectCache = plugin.getInspectCache(); } /** @@ -56,7 +49,7 @@ public class Analysis { *

* First retrieves all offline players and checks those that are in the * database. Then runs a new Analysis Task asynchronously. Saves AnalysisData - * to the provided Cache. Saves all UserData to InspectCache for 15 minutes. + * to the provided Cache. Saves all UserInfo to InspectCache for 15 minutes. * * @param analysisCache Cache that the data is saved to. */ @@ -92,42 +85,28 @@ public class Analysis { Benchmark.start("Fetch Phase"); Log.debug("Database", "Analysis Fetch"); Log.debug("Analysis", "Analysis Fetch Phase"); - try { - inspectCache.cacheAllUserData(db); - } catch (Exception ex) { - Log.toLog(this.getClass().getName(), ex); - Log.error(Locale.get(Msg.ANALYSIS_FAIL_FETCH_EXCEPTION).toString()); - } - - List rawData = inspectCache.getCachedUserData(); - if (rawData.isEmpty()) { - Log.info(Locale.get(Msg.ANALYSIS_FAIL_NO_DATA).toString()); - return false; - } - + //TODO Rewrite FETCH List tpsData = new ArrayList<>(); try { tpsData = db.getTpsTable().getTPSData(); - Log.debug("Analysis", "Raw Data Size: " + rawData.size()); Log.debug("Analysis", "TPS Data Size: " + tpsData.size()); } catch (Exception ex) { Log.toLog(this.getClass().getName(), ex); } - return analyzeData(rawData, tpsData, analysisCache); + return analyzeData(tpsData, analysisCache); } /** - * @param rawData * @param tpsData * @param analysisCache * @return */ - public boolean analyzeData(List rawData, List tpsData, AnalysisCacheHandler analysisCache) { + public boolean analyzeData(List tpsData, AnalysisCacheHandler analysisCache) { try { - rawData.sort(new UserDataLastPlayedComparator()); - List uuids = rawData.stream().map(UserData::getUuid).collect(Collectors.toList()); +// rawData.sort(new UserDataLastPlayedComparator()); +// List uuids = rawData.stream().map(UserInfo::getUuid).collect(Collectors.toList()); Benchmark.start("Create Empty dataset"); DataCache dataCache = plugin.getDataCache(); Map commandUse = dataCache.getCommandUse(); @@ -136,28 +115,33 @@ public class Analysis { analysisData.setPluginsTabLayout(plugin.getHookHandler().getPluginsTabLayoutForAnalysis()); analysisData.setPlanVersion(plugin.getVersion()); ActivityPart activityPart = analysisData.getActivityPart(); - activityPart.setRecentPlayersUUIDs(uuids); - analysisData.getPlayerCountPart().addPlayers(uuids); - activityPart.setRecentPlayers(rawData.stream().map(UserData::getName).collect(Collectors.toList())); + // TODO GetRecentPlayers +// activityPart.setRecentPlayersUUIDs(uuids); +// analysisData.getPlayerCountPart().addPlayers(uuids); + +// activityPart.setRecentPlayers(rawData.stream().map(UserInfo::getName).collect(Collectors.toList())); Benchmark.stop("Analysis", "Create Empty dataset"); long fetchPhaseLength = Benchmark.stop("Analysis", "Fetch Phase"); Benchmark.start("Analysis Phase"); Log.debug("Analysis", "Analysis Phase"); - log(Locale.get(Msg.ANALYSIS_PHASE_START).parse(rawData.size(), fetchPhaseLength)); - String playersTable = PlayersTableCreator.createSortablePlayersTable(rawData); - analysisData.setPlayersTable(playersTable); + //TODO Fetch Size + log(Locale.get(Msg.ANALYSIS_PHASE_START).parse(0, fetchPhaseLength)); - fillDataset(analysisData, rawData); + // TODO Create playersTable +// String playersTable = PlayersTableCreator.createSortablePlayersTable(rawData); +// analysisData.setPlayersTable(playersTable); + + fillDataset(analysisData); // Analyze analysisData.analyseData(); Benchmark.stop("Analysis", "Analysis Phase"); log(Locale.get(Msg.ANALYSIS_3RD_PARTY).toString()); Log.debug("Analysis", "Analyzing additional data sources (3rd party)"); - analysisData.setAdditionalDataReplaceMap(analyzeAdditionalPluginData(uuids)); +// TODO analysisData.setAdditionalDataReplaceMap(analyzeAdditionalPluginData(uuids)); analysisCache.cache(analysisData); long time = Benchmark.stop("Analysis", "Analysis"); @@ -171,7 +155,8 @@ public class Analysis { PageCacheHandler.cachePage("analysisJson", () -> new JsonResponse(analysisData)); PageCacheHandler.cachePage("players", () -> new PlayersPageResponse(plugin)); - ExportUtility.export(analysisData, rawData); + // TODO Export +// ExportUtility.export(analysisData, rawData); } catch (Exception e) { Log.toLog(this.getClass().getName(), e); Log.debug("Analysis", "Error: " + e); @@ -187,6 +172,7 @@ public class Analysis { } private Map analyzeAdditionalPluginData(List uuids) { + // TODO Rewrite Benchmark.start("3rd party"); final Map replaceMap = new HashMap<>(); final HookHandler hookHandler = plugin.getHookHandler(); @@ -253,7 +239,7 @@ public class Analysis { taskId = id; } - private void fillDataset(AnalysisData analysisData, List rawData) { + private void fillDataset(AnalysisData analysisData) { ActivityPart activity = analysisData.getActivityPart(); GamemodePart gmPart = analysisData.getGamemodePart(); GeolocationPart geolocPart = analysisData.getGeolocationPart(); @@ -268,46 +254,46 @@ public class Analysis { Benchmark.start("Fill Dataset"); List banSources = plugin.getHookHandler().getAdditionalDataSources() .stream().filter(PluginData::isBanData).collect(Collectors.toList()); - rawData.forEach(uData -> { +// rawData.forEach(uData -> { // TODO Map worldTimes = uData.getWorldTimes().getTimes(); - // TODO playtime.addToPlaytime(playTime); - joinInfo.addToLoginTimes(uData.getLoginTimes()); - joinInfo.addRegistered(uData.getRegistered()); + // TODO playtime.addToPlaytime(playTime); +// joinInfo.addToLoginTimes(uData.getLoginTimes()); +// joinInfo.addRegistered(uData.getRegistered()); - //TODO geolocPart.addGeolocation(uData.getGeolocation()); + //TODO geolocPart.addGeolocation(uData.getGeolocation()); - final UUID uuid = uData.getUuid(); - if (uData.isOp()) { - playerCount.addOP(uuid); - } +// final UUID uuid = uData.getUuid(); +// if (uData.isOp()) { +// playerCount.addOP(uuid); +// } - boolean banned = uData.isBanned(); - if (!banned) { - banned = banSources.stream() - .anyMatch(banData -> { - Serializable value = banData.getValue(uuid); - if (value instanceof Boolean) { - return (Boolean) value; - } - return false; - }); - } - - if (banned) { - activity.addBan(uuid); - } else if (uData.getLoginTimes() == 1) { - activity.addJoinedOnce(uuid); +// boolean banned = uData.isBanned(); +// if (!banned) { +// banned = banSources.stream() +// .anyMatch(banData -> { +// Serializable value = banData.getValue(uuid); +// if (value instanceof Boolean) { +// return (Boolean) value; +// } +// return false; +// }); +// } +// +// if (banned) { +// activity.addBan(uuid); +// } else if (uData.getLoginTimes() == 1) { +// activity.addJoinedOnce(uuid); // TODO } else if (AnalysisUtils.isActive(now, uData.getLastPlayed(), playTime, uData.getSessionCount())) { // activity.addActive(uuid); - } else { - activity.addInActive(uuid); - } +// } else { +// activity.addInActive(uuid); +// } //TODO List playerKills = uData.getPlayerKills(); - List sessions = uData.getSessions(); - joinInfo.addSessions(uuid, sessions); - }); +// List sessions = uData.getSessions(); +// joinInfo.addSessions(uuid, sessions); +// }); Benchmark.stop("Analysis", "Fill Dataset"); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/ExportUtility.java b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/ExportUtility.java index 0881f798c..c60d42ab0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/ExportUtility.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/analysis/ExportUtility.java @@ -4,7 +4,7 @@ import main.java.com.djrapitops.plan.Log; import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Settings; import main.java.com.djrapitops.plan.data.AnalysisData; -import main.java.com.djrapitops.plan.data.UserData; +import main.java.com.djrapitops.plan.data.UserInfo; import main.java.com.djrapitops.plan.ui.webserver.response.PlayersPageResponse; import main.java.com.djrapitops.plan.utilities.Benchmark; import main.java.com.djrapitops.plan.utilities.HtmlUtils; @@ -57,7 +57,7 @@ public class ExportUtility { * @param analysisData * @param rawData */ - public static void export(AnalysisData analysisData, List rawData) { + public static void export(AnalysisData analysisData, List rawData) { if (!Settings.ANALYSIS_EXPORT.isTrue()) { return; } @@ -98,15 +98,15 @@ public class ExportUtility { } /** - * @param userData + * @param userInfo * @param playersFolder */ - public static void writeInspectHtml(UserData userData, File playersFolder, String playerHtml) { + public static void writeInspectHtml(UserInfo userInfo, File playersFolder, String playerHtml) { if (!Settings.ANALYSIS_EXPORT.isTrue()) { return; } - String name = userData.getName(); + String name = userInfo.getName(); if (name.endsWith(".")) { name = name.replace(".", "%2E"); @@ -118,7 +118,7 @@ public class ExportUtility { try { String inspectHtml = HtmlUtils.replacePlaceholders(playerHtml, - PlaceholderUtils.getInspectReplaceRules(userData)); + PlaceholderUtils.getInspectReplaceRules(userInfo)); File playerFolder = new File(playersFolder, name); playerFolder.mkdirs(); @@ -149,7 +149,7 @@ public class ExportUtility { Files.write(analysisHtmlFile.toPath(), Collections.singletonList(analysisHtml)); } - private static void writePlayersPageHtml(List rawData, File playersFolder) throws IOException { + private static void writePlayersPageHtml(List rawData, File playersFolder) throws IOException { String playersHtml = PlayersPageResponse.buildContent(rawData); playersFolder.mkdirs(); File playersHtmlFile = new File(playersFolder, "index.html"); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/UserDataLastPlayedComparator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/UserDataLastPlayedComparator.java index 51e6b38df..fc8693ccf 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/UserDataLastPlayedComparator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/UserDataLastPlayedComparator.java @@ -5,17 +5,17 @@ */ package main.java.com.djrapitops.plan.utilities.comparators; -import main.java.com.djrapitops.plan.data.UserData; +import main.java.com.djrapitops.plan.data.UserInfo; import java.util.Comparator; /** * @author Risto */ -public class UserDataLastPlayedComparator implements Comparator { +public class UserDataLastPlayedComparator implements Comparator { @Override - public int compare(UserData u1, UserData u2) { - return Long.compare(u2.getLastPlayed(), u1.getLastPlayed()); + public int compare(UserInfo u1, UserInfo u2) { + return Long.compare(u2.getLastSeen(), u1.getLastSeen()); } } diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/UserDataNameComparator.java b/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/UserDataNameComparator.java index 90e9ecdac..4a5798b64 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/UserDataNameComparator.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/comparators/UserDataNameComparator.java @@ -5,17 +5,17 @@ */ package main.java.com.djrapitops.plan.utilities.comparators; -import main.java.com.djrapitops.plan.data.UserData; +import main.java.com.djrapitops.plan.data.UserInfo; import java.util.Comparator; /** * @author Risto */ -public class UserDataNameComparator implements Comparator { +public class UserDataNameComparator implements Comparator { @Override - public int compare(UserData u1, UserData u2) { + public int compare(UserInfo u1, UserInfo u2) { return u1.getName().compareTo(u2.getName()); } } diff --git a/Plan/test/test/java/main/java/com/djrapitops/plan/data/UserDataTest.java b/Plan/test/test/java/main/java/com/djrapitops/plan/data/UserInfoTest.java similarity index 83% rename from Plan/test/test/java/main/java/com/djrapitops/plan/data/UserDataTest.java rename to Plan/test/test/java/main/java/com/djrapitops/plan/data/UserInfoTest.java index 49e9a0c1a..2c5520bf0 100644 --- a/Plan/test/test/java/main/java/com/djrapitops/plan/data/UserDataTest.java +++ b/Plan/test/test/java/main/java/com/djrapitops/plan/data/UserInfoTest.java @@ -1,7 +1,7 @@ package test.java.main.java.com.djrapitops.plan.data; import main.java.com.djrapitops.plan.Plan; -import main.java.com.djrapitops.plan.data.UserData; +import main.java.com.djrapitops.plan.data.UserInfo; import org.bukkit.plugin.java.JavaPlugin; import org.junit.Before; import org.junit.Test; @@ -14,16 +14,16 @@ import org.powermock.modules.junit4.PowerMockRunner; */ @RunWith(PowerMockRunner.class) @PrepareForTest(JavaPlugin.class) -public class UserDataTest { +public class UserInfoTest { // TODO Rewrite - private UserData test; + private UserInfo test; private Plan plan; /** * */ - public UserDataTest() { + public UserInfoTest() { } /** diff --git a/Plan/test/test/java/main/java/com/djrapitops/plan/database/DatabaseTest.java b/Plan/test/test/java/main/java/com/djrapitops/plan/database/DatabaseTest.java index 7094fb8f1..a6c9c50a0 100644 --- a/Plan/test/test/java/main/java/com/djrapitops/plan/database/DatabaseTest.java +++ b/Plan/test/test/java/main/java/com/djrapitops/plan/database/DatabaseTest.java @@ -150,7 +150,7 @@ public class DatabaseTest { @Test // TODO Rewrite public void testRemoveAll() throws SQLException { db.init(); -// UserData data = MockUtils.mockUser(); +// UserInfo data = MockUtils.mockUser(); // db.saveUserData(data); HashMap c = new HashMap<>(); c.put("/plan", 1); @@ -196,7 +196,7 @@ public class DatabaseTest { @Test // TODO Rewrite public void testRemove() throws SQLException { db.init(); -// UserData data = MockUtils.mockUser(); +// UserInfo data = MockUtils.mockUser(); // db.saveUserData(data); // assertTrue(db.removeAccount(data.getUuid().toString())); // assertTrue("Contains the user", !db.wasSeenBefore(data.getUuid())); diff --git a/Plan/test/test/java/main/java/com/djrapitops/plan/utilities/comparators/ComparatorTest.java b/Plan/test/test/java/main/java/com/djrapitops/plan/utilities/comparators/ComparatorTest.java index 38d9bd9dd..1e6215520 100644 --- a/Plan/test/test/java/main/java/com/djrapitops/plan/utilities/comparators/ComparatorTest.java +++ b/Plan/test/test/java/main/java/com/djrapitops/plan/utilities/comparators/ComparatorTest.java @@ -2,7 +2,7 @@ package test.java.main.java.com.djrapitops.plan.utilities.comparators; import main.java.com.djrapitops.plan.data.Session; import main.java.com.djrapitops.plan.data.TPS; -import main.java.com.djrapitops.plan.data.UserData; +import main.java.com.djrapitops.plan.data.UserInfo; import main.java.com.djrapitops.plan.data.WebUser; import main.java.com.djrapitops.plan.locale.Message; import main.java.com.djrapitops.plan.locale.Msg; @@ -52,23 +52,23 @@ public class ComparatorTest { @Test public void testUserDataLastPlayedComparator() { - List test = RandomData.randomUserData(); - List longValues = test.stream().map(UserData::getLastPlayed).collect(Collectors.toList()); + List test = RandomData.randomUserData(); + List longValues = test.stream().map(UserInfo::getLastSeen).collect(Collectors.toList()); longValues.sort(Long::compare); Collections.reverse(longValues); test.sort(new UserDataLastPlayedComparator()); - List afterSort = test.stream().map(UserData::getLastPlayed).collect(Collectors.toList()); + List afterSort = test.stream().map(UserInfo::getLastSeen).collect(Collectors.toList()); assertEquals(longValues, afterSort); } @Test public void testUserDataNameComparator() { - List test = RandomData.randomUserData(); - List stringValues = test.stream().map(UserData::getName).collect(Collectors.toList()); + List test = RandomData.randomUserData(); + List stringValues = test.stream().map(UserInfo::getName).collect(Collectors.toList()); Collections.sort(stringValues); test.sort(new UserDataNameComparator()); - List afterSort = test.stream().map(UserData::getName).collect(Collectors.toList()); + List afterSort = test.stream().map(UserInfo::getName).collect(Collectors.toList()); assertEquals(stringValues, afterSort); } diff --git a/Plan/test/test/java/utils/RandomData.java b/Plan/test/test/java/utils/RandomData.java index 544fa712f..f67e9bc9d 100644 --- a/Plan/test/test/java/utils/RandomData.java +++ b/Plan/test/test/java/utils/RandomData.java @@ -2,7 +2,7 @@ package test.java.utils; import main.java.com.djrapitops.plan.data.Session; import main.java.com.djrapitops.plan.data.TPS; -import main.java.com.djrapitops.plan.data.UserData; +import main.java.com.djrapitops.plan.data.UserInfo; import main.java.com.djrapitops.plan.data.WebUser; import main.java.com.djrapitops.plan.utilities.PassEncryptUtil; import main.java.com.djrapitops.plan.utilities.analysis.Point; @@ -64,7 +64,7 @@ public class RandomData { return clazz.getEnumConstants()[x]; } - public static List randomUserData() { + public static List randomUserData() { return new ArrayList<>(); // TODO Rewrite }