diff --git a/Plan/src/main/java/com/djrapitops/plan/data/AnalysisData.java b/Plan/src/main/java/com/djrapitops/plan/data/AnalysisData.java index c8d36f603..d29c47cc0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/AnalysisData.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/AnalysisData.java @@ -885,26 +885,58 @@ public class AnalysisData { this.genderData = genderData; } + /** + * Get the data for the Session Punchcard + * + * @return Array of x y r coordinates: [{x: 4, y: 5, r: 4}] + */ public String getPunchCardData() { return punchCardData; } + /** + * Set the data for the Session Punchcard + * + * @param punchCardData Array of x y r coordinates: [{x: 4, y: 5, r: 4}] + */ public void setPunchCardData(String punchCardData) { this.punchCardData = punchCardData; } + /** + * Get the data and labels for the session distribution barchart. + * + * @return index 0: [0, 5, 4], 1: ["0-5", "5-10", "10-15"] + */ public String[] getSessionDistributionData() { return sessionDistributionData; } + /** + * Set the data and labels for the session distribution barchart. + * + * @param sessionDistributionData index 0: [0, 5, 4], 1: ["0-5", "5-10", + * "10-15"] + */ public void setSessionDistributionData(String[] sessionDistributionData) { this.sessionDistributionData = sessionDistributionData; } + /** + * Get the data and labels for the playtime distribution barchart. + * + * @return index 0: [0, 5, 4], 1: ["0-5", "5-10", "10-15"] + */ public String[] getPlaytimeDistributionData() { return playtimeDistributionData; } + /** + * Set the data and labels for the playtime distribution barchart. + * + * @param playtimeDistributionData index 0: [0, 5, 4], 1: ["0-5", "5-10", + * "10-15"] + */ public void setPlaytimeDistributionData(String[] playtimeDistributionData) { this.playtimeDistributionData = playtimeDistributionData; } diff --git a/Plan/src/main/java/com/djrapitops/plan/data/UserData.java b/Plan/src/main/java/com/djrapitops/plan/data/UserData.java index bcaddbe8e..1add8a1d7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/UserData.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/UserData.java @@ -944,11 +944,20 @@ public class UserData { this.clearAfterSave = clearAfterSave; } + /** + * Set the banned value. + * + * @param isBanned true/false + */ public void setBanned(boolean isBanned) { this.isBanned = isBanned; } + /** + * Set the online value. + * @param isOnline true/false + */ public void setOnline(boolean isOnline) { this.isOnline = isOnline; } -} \ No newline at end of file +} diff --git a/Plan/src/main/java/com/djrapitops/plan/data/additional/Hook.java b/Plan/src/main/java/com/djrapitops/plan/data/additional/Hook.java index 135237319..8e1f15e36 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/additional/Hook.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/additional/Hook.java @@ -11,6 +11,9 @@ import static org.bukkit.plugin.java.JavaPlugin.getPlugin; */ public abstract class Hook { + /** + * Is the plugin being hooked properly enabled? + */ protected boolean enabled; /** diff --git a/Plan/src/main/java/com/djrapitops/plan/data/additional/jobs/JobsAnalysisJobTable.java b/Plan/src/main/java/com/djrapitops/plan/data/additional/jobs/JobsAnalysisJobTable.java index 690ae6e24..df8b1e2dc 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/additional/jobs/JobsAnalysisJobTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/additional/jobs/JobsAnalysisJobTable.java @@ -2,7 +2,6 @@ package main.java.com.djrapitops.plan.data.additional.jobs; import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.PlayerManager; -import com.gamingmesh.jobs.container.Job; import com.gamingmesh.jobs.container.JobProgression; import java.io.Serializable; import java.util.Arrays; @@ -29,6 +28,9 @@ import static org.bukkit.Bukkit.getOfflinePlayers; */ public class JobsAnalysisJobTable extends PluginData { + /** + * Class Constructor, sets the parameters of the PluginData object. + */ public JobsAnalysisJobTable() { super("Jobs", "analysistable", AnalysisType.HTML); final String job = Html.FONT_AWESOME_ICON.parse("suitcase") + " Job"; diff --git a/Plan/src/main/java/com/djrapitops/plan/data/additional/jobs/JobsInspectJobTable.java b/Plan/src/main/java/com/djrapitops/plan/data/additional/jobs/JobsInspectJobTable.java index 0e2931bdb..ab109a23d 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/additional/jobs/JobsInspectJobTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/additional/jobs/JobsInspectJobTable.java @@ -22,6 +22,9 @@ import main.java.com.djrapitops.plan.ui.Html; */ public class JobsInspectJobTable extends PluginData { + /** + * Class Constructor, sets the parameters of the PluginData object. + */ public JobsInspectJobTable() { super("Jobs", "inspecttable"); super.setAnalysisOnly(false); @@ -33,18 +36,21 @@ public class JobsInspectJobTable extends PluginData { @Override public String getHtmlReplaceValue(String modifierPrefix, UUID uuid) { - PlayerManager pm = Jobs.getPlayerManager(); - PlayerInfo info = pm.getPlayerInfo(uuid); - JobsPlayer player = pm.getJobsPlayerOffline(info); - List progression = player.getJobProgression(); - if (progression.isEmpty()) { - return parseContainer("", Html.TABLELINE_2.parse("No Jobs.", "")); + try { + PlayerManager pm = Jobs.getPlayerManager(); + PlayerInfo info = pm.getPlayerInfo(uuid); + JobsPlayer player = pm.getJobsPlayerOffline(info); + List progression = player.getJobProgression(); + if (!progression.isEmpty()) { + StringBuilder html = new StringBuilder(); + for (JobProgression job : progression) { + html.append(Html.TABLELINE_2.parse(job.getJob().getName(), "" + job.getLevel())); + } + return parseContainer("", html.toString()); + } + } catch (NullPointerException e) { } - StringBuilder html = new StringBuilder(); - for (JobProgression job : progression) { - html.append(Html.TABLELINE_2.parse(job.getJob().getName(), "" + job.getLevel())); - } - return parseContainer("", html.toString()); + return parseContainer("", Html.TABLELINE_2.parse("No Jobs.", "")); } @Override diff --git a/Plan/src/main/java/com/djrapitops/plan/data/additional/mcmmo/McmmoAnalysisSkillTable.java b/Plan/src/main/java/com/djrapitops/plan/data/additional/mcmmo/McmmoAnalysisSkillTable.java index 20899d219..56fe323f7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/additional/mcmmo/McmmoAnalysisSkillTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/additional/mcmmo/McmmoAnalysisSkillTable.java @@ -6,7 +6,6 @@ import com.gmail.nossr50.util.player.UserManager; import java.io.Serializable; import java.util.ArrayList; import java.util.Arrays; -import java.util.Collection; import java.util.List; import java.util.UUID; import java.util.stream.Collectors; @@ -17,7 +16,6 @@ import main.java.com.djrapitops.plan.utilities.FormatUtils; import main.java.com.djrapitops.plan.utilities.MathUtils; import org.apache.commons.lang.StringUtils; import static org.bukkit.Bukkit.getOnlinePlayers; -import org.bukkit.entity.Player; /** * PluginData class for McMMO-plugin. @@ -30,6 +28,9 @@ import org.bukkit.entity.Player; */ public class McmmoAnalysisSkillTable extends PluginData { + /** + * Class Constructor, sets the parameters of the PluginData object. + */ public McmmoAnalysisSkillTable() { super("McMMO", "analysistable", AnalysisType.HTML); final String skill = Html.FONT_AWESOME_ICON.parse("star") + " Skill"; diff --git a/Plan/src/main/java/com/djrapitops/plan/data/additional/mcmmo/McmmoInspectSkillTable.java b/Plan/src/main/java/com/djrapitops/plan/data/additional/mcmmo/McmmoInspectSkillTable.java index 6f4d74210..0cd4d7ea2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/additional/mcmmo/McmmoInspectSkillTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/additional/mcmmo/McmmoInspectSkillTable.java @@ -32,6 +32,9 @@ import static org.bukkit.Bukkit.getOfflinePlayer; */ public class McmmoInspectSkillTable extends PluginData { + /** + * Class Constructor, sets the parameters of the PluginData object. + */ public McmmoInspectSkillTable() { super("McMMO", "inspectskilltable"); super.setAnalysisOnly(false); 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 index f4275be78..1c3844e4f 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/cache/InspectCacheHandler.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/cache/InspectCacheHandler.java @@ -5,12 +5,14 @@ import java.util.ArrayList; import java.util.HashMap; import java.util.HashSet; import java.util.List; +import java.util.Map; import java.util.Set; import java.util.UUID; 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.utilities.MiscUtils; /** * This class stores UserData objects used for displaying the Html pages. @@ -22,7 +24,8 @@ public class InspectCacheHandler { private DataCacheHandler handler; private Plan plugin; - private HashMap cache; + private Map cache; + private Map cacheTimes; /** * Class constructor. @@ -33,6 +36,7 @@ public class InspectCacheHandler { this.handler = plugin.getHandler(); this.plugin = plugin; this.cache = new HashMap<>(); + cacheTimes = new HashMap<>(); } /** @@ -48,11 +52,19 @@ public class InspectCacheHandler { @Override public void process(UserData data) { cache.put(uuid, new UserData(data)); + cacheTimes.put(uuid, MiscUtils.getTime()); } }; handler.getUserDataForProcessing(cacher, uuid, false); } + /** + * 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 { Set cachedUserData = handler.getDataCache().keySet(); for (UUID uuid : cachedUserData) { @@ -66,8 +78,11 @@ public class InspectCacheHandler { } savedUUIDs.removeAll(cachedUserData); List userDataForUUIDS = db.getUserDataForUUIDS(savedUUIDs); + long time = MiscUtils.getTime(); for (UserData uData : userDataForUUIDS) { - cache.put(uData.getUuid(), uData); + UUID uuid = uData.getUuid(); + cache.put(uuid, uData); + cacheTimes.put(uuid, time); } } @@ -81,6 +96,13 @@ public class InspectCacheHandler { return cache.get(uuid); } + public long getCacheTime(UUID uuid) { + if (cacheTimes.containsKey(uuid)) { + return cacheTimes.get(uuid); + } + return -1; + } + /** * Check if the data of a player is in the inspect cache. * @@ -90,7 +112,12 @@ public class InspectCacheHandler { 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/handling/importing/ImportUtils.java b/Plan/src/main/java/com/djrapitops/plan/data/handling/importing/ImportUtils.java index 5abbd37f3..ee0d948e9 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/handling/importing/ImportUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/handling/importing/ImportUtils.java @@ -1,8 +1,3 @@ -/* - * To change this license header, choose License Headers in Project Properties. - * To change this template file, choose Tools | Templates - * and open the template in the editor. - */ package main.java.com.djrapitops.plan.data.handling.importing; import java.util.HashMap; @@ -10,14 +5,28 @@ import java.util.Map; import static org.bukkit.Bukkit.getPluginManager; /** + * This class is responsible for static utility methods used for importing. * * @author Risto + * @since 3.2.0 */ public class ImportUtils { + + /** + * Checks if a plugin is enabled. + * + * @param pluginName Name of the plugin + * @return true/false + */ public static boolean isPluginEnabled(String pluginName) { return getPluginManager().isPluginEnabled(pluginName); } - + + /** + * Used to get all importers for different plugins. + * + * @return Map of importers with pluginname in lowercase as key. + */ public static Map getImporters() { Map importers = new HashMap<>(); importers.put("ontime", new OnTimeImporter()); diff --git a/Plan/src/main/java/com/djrapitops/plan/data/handling/importing/Importer.java b/Plan/src/main/java/com/djrapitops/plan/data/handling/importing/Importer.java index ce3298320..3f2cb20cf 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/handling/importing/Importer.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/handling/importing/Importer.java @@ -6,8 +6,6 @@ import java.util.Collection; import java.util.List; import java.util.Set; import java.util.UUID; -import java.util.logging.Level; -import java.util.logging.Logger; import main.java.com.djrapitops.plan.Log; import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.data.cache.DataCacheHandler; @@ -17,15 +15,28 @@ import static org.bukkit.Bukkit.getOfflinePlayer; import org.bukkit.OfflinePlayer; /** + * Abstract class used for importing data from other plugins. * * @author Rsl1122 + * @since 3.2.0 */ public abstract class Importer { + /** + * Constructor. + */ public Importer() { } + /** + * Method used for the import. + * + * Creates UserData for players that have not been saved to the database. + * + * @param uuids UUIDs to be imported + * @return success + */ public boolean importData(Collection uuids) { Plan plan = Plan.getInstance(); DataCacheHandler handler = plan.getHandler(); @@ -49,5 +60,12 @@ public abstract class Importer { return true; } + /** + * Method used for getting the HandlingInfo object for the import data. + * + * @param uuid UUID of the player + * @return HandlingInfo object that modifies the UserData so that the data + * is imported. + */ public abstract HandlingInfo importData(UUID uuid); } diff --git a/Plan/src/main/java/com/djrapitops/plan/data/handling/importing/OnTimeImporter.java b/Plan/src/main/java/com/djrapitops/plan/data/handling/importing/OnTimeImporter.java index 34250cd2e..8de762860 100644 --- a/Plan/src/main/java/com/djrapitops/plan/data/handling/importing/OnTimeImporter.java +++ b/Plan/src/main/java/com/djrapitops/plan/data/handling/importing/OnTimeImporter.java @@ -1,31 +1,38 @@ package main.java.com.djrapitops.plan.data.handling.importing; -import java.util.HashMap; -import java.util.Set; import java.util.UUID; import main.java.com.djrapitops.plan.data.UserData; import main.java.com.djrapitops.plan.data.handling.info.HandlingInfo; import main.java.com.djrapitops.plan.data.handling.info.InfoType; import me.edge209.OnTime.OnTimeAPI; -import me.edge209.OnTime.OnTimeAPI.data; -import org.bukkit.Bukkit; -import static org.bukkit.Bukkit.getOfflinePlayer; import org.bukkit.GameMode; import org.bukkit.OfflinePlayer; import static org.bukkit.Bukkit.getOfflinePlayer; /** + * Class responsible for importing data from OnTime plugin. + * + * Imports playtime * * @author Rsl1122 + * @since 3.2.0 */ public class OnTimeImporter extends Importer { /** - * + * Constructor. */ public OnTimeImporter() { } + /** + * Imports playtime from Ontime. + * + * Resets Gamemode times to survival because it is playtime dependent. + * + * @param uuid UUID of the player + * @return HandlingInfo object + */ @Override public HandlingInfo importData(UUID uuid) { OfflinePlayer p = getOfflinePlayer(uuid); 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 34a58e74d..21fc0c3a6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/Database.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/Database.java @@ -24,15 +24,54 @@ import org.bukkit.World; */ public abstract class Database { + /** + * Instance of Plan used with this database. + */ protected final Plan plugin; + + /** + * Table representing plan_users in the database. + */ protected UsersTable usersTable; + + /** + * Table representing plan_gamemodetimes in the database. + */ protected GMTimesTable gmTimesTable; + + /** + * Table representing plan_kills in the database. + */ protected KillsTable killsTable; + + /** + * Table representing plan_locations in the database. + */ protected LocationsTable locationsTable; + + /** + * Table representing plan_nicknames in the database. + */ protected NicknamesTable nicknamesTable; + + /** + * Table representing plan_sessions in the database. + */ protected SessionsTable sessionsTable; + + /** + * Table representing plan_ips in the database. + */ protected IPsTable ipsTable; + + /** + * Table representing plan_commandusages in the database. + */ protected CommandUseTable commandUseTable; + + /** + * Table representing plan_version in the database. + */ protected VersionTable versionTable; /** @@ -81,6 +120,15 @@ public abstract class Database { */ public abstract void giveUserDataToProcessors(UUID uuid, Collection processors) throws SQLException; + /** + * Used to get all UserData for multiple UUIDs. + * + * Should only be called from async thread. + * + * @param uuids UUIDs to fetch data for. + * @return Data for matching UUIDs. + * @throws SQLException If database error occurs. + */ public abstract List getUserDataForUUIDS(Collection uuids) throws SQLException; /** @@ -239,6 +287,14 @@ public abstract class Database { return getLocations(Integer.parseInt(userId), worlds); } + /** + * + * @param userId + * @param worlds + * @return + * @throws SQLException + * @deprecated + */ @Deprecated public List getLocations(int userId, HashMap worlds) throws SQLException { return locationsTable.getLocations(userId, worlds); 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 ee4af1f63..31bf5cab2 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 @@ -146,6 +146,9 @@ public abstract class SQLDB extends Database { return true; } + /** + * + */ public void convertBukkitDataToDB() { new BukkitRunnable() { @Override @@ -316,6 +319,12 @@ public abstract class SQLDB extends Database { Benchmark.stop("DB Give userdata to processors"); } + /** + * + * @param uuidsCol + * @return + * @throws SQLException + */ @Override public List getUserDataForUUIDS(Collection uuidsCol) throws SQLException { if (uuidsCol == null || uuidsCol.isEmpty()) { diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/IPsTable.java b/Plan/src/main/java/com/djrapitops/plan/database/tables/IPsTable.java index e3fe9b808..ddc24c9d4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/IPsTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/tables/IPsTable.java @@ -146,6 +146,12 @@ public class IPsTable extends Table { } } + /** + * + * @param ids + * @return + * @throws SQLException + */ public Map> getIPList(Collection ids) throws SQLException { if (ids == null || ids.isEmpty()) { return new HashMap<>(); @@ -178,6 +184,11 @@ public class IPsTable extends Table { } } + /** + * + * @param ips + * @throws SQLException + */ public void saveIPList(Map> ips) throws SQLException { if (ips == null || ips.isEmpty()) { return; diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/KillsTable.java b/Plan/src/main/java/com/djrapitops/plan/database/tables/KillsTable.java index b267a5078..8cfced485 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/KillsTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/tables/KillsTable.java @@ -156,6 +156,13 @@ public class KillsTable extends Table { } } + /** + * + * @param ids + * @param uuids + * @return + * @throws SQLException + */ public Map> getPlayerKills(Collection ids, Map uuids) throws SQLException { if (ids == null || ids.isEmpty()) { return new HashMap<>(); @@ -187,6 +194,12 @@ public class KillsTable extends Table { } } + /** + * + * @param kills + * @param uuids + * @throws SQLException + */ public void savePlayerKills(Map> kills, Map uuids) throws SQLException { if (kills == null || kills.isEmpty()) { return; diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/LocationsTable.java b/Plan/src/main/java/com/djrapitops/plan/database/tables/LocationsTable.java index 54cfafcce..0eca7a883 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/LocationsTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/tables/LocationsTable.java @@ -157,6 +157,11 @@ public class LocationsTable extends Table { } } + /** + * + * @param locations + * @throws SQLException + */ public void saveAdditionalLocationsLists(Map> locations) throws SQLException { if (locations == null || locations.isEmpty()) { return; diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/NicknamesTable.java b/Plan/src/main/java/com/djrapitops/plan/database/tables/NicknamesTable.java index c027261db..65be25315 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/NicknamesTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/tables/NicknamesTable.java @@ -173,6 +173,12 @@ public class NicknamesTable extends Table { } } + /** + * + * @param ids + * @return + * @throws SQLException + */ public Map> getNicknames(Collection ids) throws SQLException { if (ids == null || ids.isEmpty()) { return new HashMap<>(); @@ -218,6 +224,12 @@ public class NicknamesTable extends Table { } } + /** + * + * @param nicknames + * @param lastNicks + * @throws SQLException + */ public void saveNickLists(Map> nicknames, Map lastNicks) throws SQLException { if (nicknames == null || nicknames.isEmpty()) { return; diff --git a/Plan/src/main/java/com/djrapitops/plan/database/tables/SessionsTable.java b/Plan/src/main/java/com/djrapitops/plan/database/tables/SessionsTable.java index 2aee7380f..670f7ead2 100644 --- a/Plan/src/main/java/com/djrapitops/plan/database/tables/SessionsTable.java +++ b/Plan/src/main/java/com/djrapitops/plan/database/tables/SessionsTable.java @@ -151,6 +151,12 @@ public class SessionsTable extends Table { } } + /** + * + * @param ids + * @return + * @throws SQLException + */ public Map> getSessionData(Collection ids) throws SQLException { if (ids == null || ids.isEmpty()) { return new HashMap<>(); @@ -183,6 +189,11 @@ public class SessionsTable extends Table { } } + /** + * + * @param sessions + * @throws SQLException + */ public void saveSessionData(Map> sessions) throws SQLException { if (sessions == null || sessions.isEmpty()) { return; 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 01fa172b1..ff5bd79db 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 @@ -284,6 +284,12 @@ public class UsersTable extends Table { } } + /** + * + * @param uuid + * @return + * @throws SQLException + */ public UserData getUserData(UUID uuid) throws SQLException { Benchmark.start(uuid + " Get UserData"); boolean containsBukkitData = getContainsBukkitData(uuid); @@ -317,6 +323,12 @@ public class UsersTable extends Table { return containsBukkitData; } + /** + * + * @param uuids + * @return + * @throws SQLException + */ public List getUserData(Collection uuids) throws SQLException { Benchmark.start("Get UserData Multiple " + uuids.size()); List containsBukkitData = getContainsBukkitData(uuids); @@ -337,6 +349,12 @@ public class UsersTable extends Table { return datas; } + /** + * + * @param uuids + * @return + * @throws SQLException + */ public List getContainsBukkitData(Collection uuids) throws SQLException { PreparedStatement statement = null; ResultSet set = null; @@ -473,6 +491,11 @@ public class UsersTable extends Table { } } + /** + * + * @param data + * @throws SQLException + */ public void addUserInformationToUserData(List data) throws SQLException { Benchmark.start("addUserInformationToUserData Multiple " + data.size()); PreparedStatement statement = null; @@ -704,6 +727,12 @@ public class UsersTable extends Table { } } + /** + * + * @param uuids + * @return + * @throws SQLException + */ public Map getUserIds(Collection uuids) throws SQLException { Benchmark.start("Get User IDS " + uuids.size()); PreparedStatement statement = null; @@ -728,6 +757,11 @@ public class UsersTable extends Table { } } + /** + * + * @return + * @throws SQLException + */ public Map getAllUserIds() throws SQLException { Benchmark.start("Get User IDS ALL"); PreparedStatement statement = null; diff --git a/Plan/src/main/java/com/djrapitops/plan/ui/graphs/PunchCardGraphCreator.java b/Plan/src/main/java/com/djrapitops/plan/ui/graphs/PunchCardGraphCreator.java index 0f694082d..1ff17c9cc 100644 --- a/Plan/src/main/java/com/djrapitops/plan/ui/graphs/PunchCardGraphCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/ui/graphs/PunchCardGraphCreator.java @@ -19,6 +19,11 @@ import main.java.com.djrapitops.plan.data.SessionData; */ public class PunchCardGraphCreator { + /** + * + * @param data + * @return + */ public static String generateDataArray(Collection data) { // Initialize dataset List sessionStarts = getSessionStarts(data); diff --git a/Plan/src/main/java/com/djrapitops/plan/ui/graphs/SessionLengthDistributionGraphCreator.java b/Plan/src/main/java/com/djrapitops/plan/ui/graphs/SessionLengthDistributionGraphCreator.java index 7fe126a6f..ba2ce9bf0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/ui/graphs/SessionLengthDistributionGraphCreator.java +++ b/Plan/src/main/java/com/djrapitops/plan/ui/graphs/SessionLengthDistributionGraphCreator.java @@ -22,11 +22,21 @@ import main.java.com.djrapitops.plan.utilities.MathUtils; */ public class SessionLengthDistributionGraphCreator { + /** + * + * @param data + * @return + */ public static String[] generateDataArraySessions(Collection data) { List lengths = AnalysisUtils.transformSessionDataToLengths(data); return generateDataArray(lengths); } + /** + * + * @param lengths + * @return + */ public static String[] generateDataArray(Collection lengths) { Map values = getValues(lengths); Map scaled = scale(values); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/Analysis.java b/Plan/src/main/java/com/djrapitops/plan/utilities/Analysis.java index bb102c55f..94443616a 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/Analysis.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/Analysis.java @@ -258,16 +258,9 @@ public class Analysis { Benchmark.stop("Analysis Activity Visualization"); } - // TODO Refactor private void analyzeAverageAge(List ages, AnalysisData data) { - int totalAge = 0; - for (int age : ages) { - totalAge += age; - } - double averageAge; - if (!ages.isEmpty()) { - averageAge = totalAge * 1.0 / ages.size(); - } else { + double averageAge = MathUtils.averageInt(ages.stream()); + if (averageAge == 0) { averageAge = -1; } data.setAverageAge(averageAge); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/AnalysisUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/AnalysisUtils.java index 1cfeb53a0..708054fa6 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/AnalysisUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/AnalysisUtils.java @@ -30,6 +30,14 @@ public class AnalysisUtils { return isActive(MiscUtils.getTime(), lastPlayed, playTime, loginTimes); } + /** + * + * @param now + * @param lastPlayed + * @param playTime + * @param loginTimes + * @return + */ public static boolean isActive(long now, long lastPlayed, long playTime, int loginTimes) { int timeToActive = Settings.ANALYSIS_MINUTES_FOR_ACTIVE.getNumber(); if (timeToActive < 0) { @@ -162,6 +170,13 @@ public class AnalysisUtils { } } + /** + * + * @param analysisType + * @param source + * @param uuids + * @return + */ public static String getBooleanPercentage(AnalysisType analysisType, PluginData source, List uuids) { if (analysisType == AnalysisType.BOOLEAN_PERCENTAGE) { try { @@ -177,6 +192,13 @@ public class AnalysisUtils { return source.parseContainer("Err ", "Wrong Analysistype specified: " + analysisType.name()); } + /** + * + * @param analysisType + * @param source + * @param uuids + * @return + */ public static String getBooleanTotal(AnalysisType analysisType, PluginData source, List uuids) { if (analysisType == AnalysisType.BOOLEAN_TOTAL) { try { diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/Benchmark.java b/Plan/src/main/java/com/djrapitops/plan/utilities/Benchmark.java index 06294a02f..a766efa96 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/Benchmark.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/Benchmark.java @@ -12,11 +12,20 @@ public class Benchmark { private static Map starts = new HashMap<>(); + /** + * + * @param source + */ public static void start(String source) { starts.put(source, System.nanoTime()); Log.debug(source); } + /** + * + * @param source + * @return + */ public static long stop(String source) { Long s = starts.get(source); if (s != null) { diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java index 4f5e792a6..c933ba7d0 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/FormatUtils.java @@ -11,14 +11,30 @@ import org.bukkit.Location; */ public class FormatUtils { + /** + * + * @param ms + * @return + */ public static String formatTimeAmount(long ms) { return formatMilliseconds(ms); } + /** + * + * @param before + * @param after + * @return + */ public static String formatTimeAmountDifference(long before, long after) { return formatMilliseconds(Math.abs(after - before)); } + /** + * + * @param epochMs + * @return + */ public static String formatTimeStamp(long epochMs) { Date sfd = new Date(epochMs); return ("" + sfd).substring(4, 19); diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/HtmlUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/HtmlUtils.java index 545a5926a..2242790e4 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/HtmlUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/HtmlUtils.java @@ -145,6 +145,11 @@ public class HtmlUtils { return html.toString(); } + /** + * + * @param string + * @return + */ public static String swapColorsToSpan(String string) { Html[] replacer = new Html[]{Html.COLOR_0, Html.COLOR_1, Html.COLOR_2, Html.COLOR_3, Html.COLOR_4, Html.COLOR_5, Html.COLOR_6, Html.COLOR_7, Html.COLOR_8, Html.COLOR_9, diff --git a/Plan/src/main/java/com/djrapitops/plan/utilities/MathUtils.java b/Plan/src/main/java/com/djrapitops/plan/utilities/MathUtils.java index 0f545ab9d..3f404766e 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/MathUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/MathUtils.java @@ -11,6 +11,11 @@ import java.util.stream.Stream; */ public class MathUtils { + /** + * + * @param values + * @return + */ public static double averageInt(Stream values) { OptionalDouble average = values.mapToInt(i -> i).average(); if (average.isPresent()) { @@ -20,10 +25,20 @@ public class MathUtils { } } + /** + * + * @param values + * @return + */ public static long averageLong(Collection values) { return averageLong(values.stream()); } + /** + * + * @param values + * @return + */ public static long averageLong(Stream values) { OptionalDouble average = values.mapToLong(i -> i).average(); if (average.isPresent()) { @@ -33,6 +48,11 @@ public class MathUtils { } } + /** + * + * @param values + * @return + */ public static double averageDouble(Stream values) { OptionalDouble average = values.mapToDouble(i -> i).average(); if (average.isPresent()) { @@ -42,32 +62,63 @@ public class MathUtils { } } + /** + * + * @param total + * @param size + * @return + */ public static double average(int total, int size) { return 1.0 * total / size; } + /** + * + * @param values + * @return + */ public static long countTrueBoolean(Stream values) { return values.filter(i -> i).count(); } + /** + * + * @param values + * @return + */ public static int sumInt(Stream values) { return values .mapToInt(value -> (Integer) value) .sum(); } + /** + * + * @param values + * @return + */ public static long sumLong(Stream values) { return values .mapToLong(value -> (Long) value) .sum(); } + /** + * + * @param values + * @return + */ public static double sumDouble(Stream values) { return values .mapToDouble(value -> (Double) value) .sum(); } + /** + * + * @param values + * @return + */ public static int getBiggest(Collection values) { int biggest = 1; for (Integer value : values) { @@ -77,6 +128,12 @@ public class MathUtils { } return biggest; } + + /** + * + * @param values + * @return + */ public static long getBiggestLong(Collection values) { long biggest = 1; for (Long value : values) { 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 9ac9d5e7b..486586fd7 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/MiscUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/MiscUtils.java @@ -4,13 +4,10 @@ import java.io.IOException; import java.net.URL; import java.util.ArrayList; import java.util.Arrays; -import java.util.Date; import java.util.HashSet; import java.util.List; -import java.util.Map; import java.util.Scanner; import java.util.Set; -import java.util.stream.Collectors; import main.java.com.djrapitops.plan.Log; import main.java.com.djrapitops.plan.Permissions; import main.java.com.djrapitops.plan.Phrase; @@ -21,13 +18,20 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; /** - * + * Utility method class containing various static methods. + * * @author Rsl1122 + * @since 2.0.0 */ public class MiscUtils { + /** + * Used to get the current time as milliseconds. + * + * @return Epoch ms. + */ public static long getTime() { - return new Date().getTime(); + return System.currentTimeMillis(); } /** @@ -40,7 +44,11 @@ public class MiscUtils { Plan plugin = Plan.getInstance(); String cVersion = plugin.getDescription().getVersion(); String gitVersion = getGitVersion(); - return checkVersion(cVersion, gitVersion); + if (checkVersion(cVersion, gitVersion)) { + return Phrase.VERSION_NEW_AVAILABLE.parse(gitVersion); + } else { + return Phrase.VERSION_LATEST + ""; + } } catch (IOException | NumberFormatException e) { Log.error(Phrase.VERSION_CHECK_ERROR + ""); } @@ -68,14 +76,10 @@ public class MiscUtils { * @return * @throws NumberFormatException */ - public static String checkVersion(String currentVersion, String gitVersion) throws NumberFormatException { + public static boolean checkVersion(String currentVersion, String gitVersion) throws NumberFormatException { int newestVersionNumber = FormatUtils.parseVersionNumber(gitVersion); int currentVersionNumber = FormatUtils.parseVersionNumber(currentVersion); - if (newestVersionNumber > currentVersionNumber) { - return Phrase.VERSION_NEW_AVAILABLE.parse(gitVersion); - } else { - return Phrase.VERSION_LATEST + ""; - } + return newestVersionNumber > currentVersionNumber; } /** @@ -93,6 +97,7 @@ public class MiscUtils { * * @param args Arguments of a command, must not be empty if console sender. * @param sender Command sender + * @param perm * @return The name of the player (first argument or sender) */ public static String getPlayerName(String[] args, CommandSender sender, Permissions perm) { 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 a36c7b955..b066b9daf 100644 --- a/Plan/src/main/java/com/djrapitops/plan/utilities/PlaceholderUtils.java +++ b/Plan/src/main/java/com/djrapitops/plan/utilities/PlaceholderUtils.java @@ -33,6 +33,7 @@ public class PlaceholderUtils { public static Map getAnalysisReplaceRules(AnalysisData data) { Benchmark.start("Replace Placeholders Anaysis"); HashMap replaceMap = new HashMap<>(); + replaceMap.put("%currenttime%", MiscUtils.getTime()+""); replaceMap.put("%gm0%", (int) (data.getGm0Perc() * 100) + "%"); replaceMap.put("%gm1%", (int) (data.getGm1Perc() * 100) + "%"); replaceMap.put("%gm2%", (int) (data.getGm2Perc() * 100) + "%"); @@ -128,6 +129,7 @@ public class PlaceholderUtils { replaceMap.put("#" + defaultCols[i], "#" + colors[i]); } } + replaceMap.put("%refreshlong%", data.getRefreshDate()+""); replaceMap.put("%servername%", Settings.SERVER_NAME.toString()); Benchmark.stop("Replace Placeholders Anaysis"); return replaceMap; @@ -142,6 +144,7 @@ public class PlaceholderUtils { */ public static Map getInspectReplaceRules(UserData data) throws FileNotFoundException { Benchmark.start("Replace Placeholders Inspect"); + HashMap replaceMap = new HashMap<>(); boolean showIPandUUID = Settings.SECURITY_IP_UUID.isTrue(); UUID uuid = data.getUuid(); @@ -222,6 +225,8 @@ public class PlaceholderUtils { replaceMap.put("#" + defaultCols[i], "#" + colors[i]); } } + replaceMap.put("%refreshlong%", plugin.getInspectCache().getCacheTime(uuid)+""); + replaceMap.put("%currenttime%", MiscUtils.getTime()+""); replaceMap.put("%servername%", Settings.SERVER_NAME.toString()); String pluginsTabHtml = plugin.getHookHandler().getPluginsTabLayoutForInspect(); Map additionalReplaceRules = plugin.getHookHandler().getAdditionalInspectReplaceRules(uuid); diff --git a/Plan/src/main/resources/analysis.html b/Plan/src/main/resources/analysis.html index 57dd5abb7..a87e4853a 100644 --- a/Plan/src/main/resources/analysis.html +++ b/Plan/src/main/resources/analysis.html @@ -279,7 +279,7 @@ header p { } - +
Player Analytics | Analysis @@ -290,7 +290,7 @@ header p {
-

Last Refresh:
%refresh% ago

+

Last Refresh:
%refresh% ago

Information @@ -823,6 +823,7 @@ for (i=0; i < navButtons.length; i++) { } x.style.opacity = "1"; openFunc(slideIndex)(); +countUpTimer(); function openFunc(i) { return function() { @@ -849,6 +850,42 @@ function openFunc(i) { x.style.transform = "translate3d("+value+"%,0px,0)"; }; } +var serverTime = new Date(%currenttime%); +var now = new Date(); +var timediff = serverTime.getTime()-now.getTime(); +function countUpTimer() { + var now = new Date(); + var begin = new Date(%refreshlong%-timediff); + var out = ""; + + var seconds = now.getTime() - begin.getTime(); + seconds = Math.floor(seconds / 1000); + + var dd = Math.floor(seconds / 86400); + seconds -= (dd * 86400); + + var dh = Math.floor(seconds / 3600); + seconds -= (dh * 3600); + + var dm = Math.floor(seconds / 60); + seconds -= (dm * 60); + + seconds = Math.floor(seconds); + + if (dd != 0) { + out += dd.toString() + "d "; + } + if (dh != 0) { + out += dh.toString() + "h "; + } + if (dm != 0) { + out += dm.toString() + "m "; + } + out += seconds.toString() + "s "; + + document.getElementById('divTime').innerHTML = out; + setTimeout('countUpTimer()', 1000); + } diff --git a/Plan/src/main/resources/player.html b/Plan/src/main/resources/player.html index 1b895fafe..6bfdf7ccf 100644 --- a/Plan/src/main/resources/player.html +++ b/Plan/src/main/resources/player.html @@ -325,8 +325,8 @@ table.sortable th:not(.sorttable_sorted):not(.sorttable_sorted_reverse):not(.sor
-
-

Has Connected from ips:
%ips%

+
+

Last Refresh:
%refresh% ago

Information @@ -370,7 +370,8 @@ table.sortable th:not(.sorttable_sorted):not(.sorttable_sorted_reverse):not(.sor
Geolocation: %geoloc%
Age: %age% | Gender: %gender%
- UUID: %uuid%

+ UUID: %uuid%
+ Has Connected from ips: %ips%

@@ -574,6 +575,7 @@ for (i=0; i < navButtons.length; i++) { } x.style.opacity = "1"; openFunc(slideIndex)(); +countUpTimer(); function openFunc(i) { return function() { @@ -600,6 +602,43 @@ function openFunc(i) { x.style.transform = "translate3d("+value+"%,0px,0)"; }; } + +var serverTime = new Date(%currenttime%); +var now = new Date(); +var timediff = serverTime.getTime()-now.getTime(); +function countUpTimer() { + var now = new Date(); + var begin = new Date(%refreshlong%-timediff); + var out = ""; + + var seconds = now.getTime() - begin.getTime(); + seconds = Math.floor(seconds / 1000); + + var dd = Math.floor(seconds / 86400); + seconds -= (dd * 86400); + + var dh = Math.floor(seconds / 3600); + seconds -= (dh * 3600); + + var dm = Math.floor(seconds / 60); + seconds -= (dm * 60); + + seconds = Math.floor(seconds); + + if (dd != 0) { + out += dd.toString() + "d "; + } + if (dh != 0) { + out += dh.toString() + "h "; + } + if (dm != 0) { + out += dm.toString() + "m "; + } + out += seconds.toString() + "s "; + + document.getElementById('divTime').innerHTML = out; + setTimeout('countUpTimer()', 1000); + } diff --git a/Plan/src/test/java/main/java/com/djrapitops/plan/PermissionsTest.java b/Plan/src/test/java/main/java/com/djrapitops/plan/PermissionsTest.java index 6e4eba1a1..3a737a470 100644 --- a/Plan/src/test/java/main/java/com/djrapitops/plan/PermissionsTest.java +++ b/Plan/src/test/java/main/java/com/djrapitops/plan/PermissionsTest.java @@ -18,14 +18,23 @@ import test.java.utils.MockUtils; */ public class PermissionsTest { + /** + * + */ public PermissionsTest() { } + /** + * + */ @Test public void testUserHasThisPermission() { assertTrue(Permissions.INSPECT_OTHER.userHasThisPermission(MockUtils.mockPlayer())); } + /** + * + */ @Test public void testGetPermission() { assertEquals("plan.inspect.other", Permissions.INSPECT_OTHER.getPermission()); diff --git a/Plan/src/test/java/main/java/com/djrapitops/plan/SettingsTest.java b/Plan/src/test/java/main/java/com/djrapitops/plan/SettingsTest.java index d978e9268..507732721 100644 --- a/Plan/src/test/java/main/java/com/djrapitops/plan/SettingsTest.java +++ b/Plan/src/test/java/main/java/com/djrapitops/plan/SettingsTest.java @@ -64,6 +64,9 @@ public class SettingsTest { assertEquals(8804, Settings.WEBSERVER_PORT.getNumber()); } + /** + * + */ @Test public void testGetStringList() { List exp = new ArrayList<>(); diff --git a/Plan/src/test/java/main/java/com/djrapitops/plan/data/additional/AnalysisTypeTest.java b/Plan/src/test/java/main/java/com/djrapitops/plan/data/additional/AnalysisTypeTest.java index f9c458901..621696055 100644 --- a/Plan/src/test/java/main/java/com/djrapitops/plan/data/additional/AnalysisTypeTest.java +++ b/Plan/src/test/java/main/java/com/djrapitops/plan/data/additional/AnalysisTypeTest.java @@ -15,14 +15,23 @@ import static org.junit.Assert.*; */ public class AnalysisTypeTest { + /** + * + */ public AnalysisTypeTest() { } + /** + * + */ @Test public void testGetModifier() { assertEquals("Average ", AnalysisType.INT_AVG.getModifier()); } + /** + * + */ @Test public void testGetPlaceholderModifier() { assertEquals("totalInt_", AnalysisType.INT_TOTAL.getPlaceholderModifier()); diff --git a/Plan/src/test/java/main/java/com/djrapitops/plan/ui/graphs/PlayerActivityGraphCreatorTest.java b/Plan/src/test/java/main/java/com/djrapitops/plan/ui/graphs/PlayerActivityGraphCreatorTest.java index e8383971a..d30eefd5b 100644 --- a/Plan/src/test/java/main/java/com/djrapitops/plan/ui/graphs/PlayerActivityGraphCreatorTest.java +++ b/Plan/src/test/java/main/java/com/djrapitops/plan/ui/graphs/PlayerActivityGraphCreatorTest.java @@ -23,6 +23,9 @@ import test.java.utils.TestInit; @PrepareForTest(JavaPlugin.class) public class PlayerActivityGraphCreatorTest { + /** + * + */ @Before public void setUp() { TestInit t = new TestInit(); diff --git a/Plan/src/test/java/main/java/com/djrapitops/plan/utilities/FormatUtilsTest.java b/Plan/src/test/java/main/java/com/djrapitops/plan/utilities/FormatUtilsTest.java index c3467f010..11c705335 100644 --- a/Plan/src/test/java/main/java/com/djrapitops/plan/utilities/FormatUtilsTest.java +++ b/Plan/src/test/java/main/java/com/djrapitops/plan/utilities/FormatUtilsTest.java @@ -26,6 +26,9 @@ import test.java.utils.*; @PrepareForTest(JavaPlugin.class) public class FormatUtilsTest { + /** + * + */ @Before public void setUp() { TestInit t = new TestInit(); diff --git a/Plan/src/test/java/main/java/com/djrapitops/plan/utilities/MathUtilsTest.java b/Plan/src/test/java/main/java/com/djrapitops/plan/utilities/MathUtilsTest.java index a84c8edf7..68a1dffa6 100644 --- a/Plan/src/test/java/main/java/com/djrapitops/plan/utilities/MathUtilsTest.java +++ b/Plan/src/test/java/main/java/com/djrapitops/plan/utilities/MathUtilsTest.java @@ -19,9 +19,15 @@ import org.junit.Test; */ public class MathUtilsTest { + /** + * + */ public MathUtilsTest() { } + /** + * + */ @Test public void testAverageInt() { List l = new ArrayList<>(); @@ -34,6 +40,9 @@ public class MathUtilsTest { assertTrue(exp == result); } + /** + * + */ @Test public void testAverageIntEmpty() { List l = new ArrayList<>(); @@ -42,6 +51,9 @@ public class MathUtilsTest { assertTrue(result + "/" + exp, exp == result); } + /** + * + */ @Test public void testAverageLong_Collection() { List l = new ArrayList<>(); @@ -54,6 +66,9 @@ public class MathUtilsTest { assertTrue(result + "/" + exp, exp == result); } + /** + * + */ @Test public void testAverageDouble() { List l = new ArrayList<>(); @@ -67,6 +82,9 @@ public class MathUtilsTest { } + /** + * + */ @Test public void testAverage() { double exp = 10; @@ -74,6 +92,9 @@ public class MathUtilsTest { assertTrue(result + "/" + exp, exp == result); } + /** + * + */ @Test public void testCountTrueBoolean() { List l = new ArrayList<>(); @@ -88,6 +109,9 @@ public class MathUtilsTest { assertTrue(result + "/" + exp, exp == result); } + /** + * + */ @Test public void testSumInt() { List l = new ArrayList<>(); @@ -100,6 +124,9 @@ public class MathUtilsTest { assertTrue(result + "/" + exp, exp == result); } + /** + * + */ @Test public void testSumLong() { List l = new ArrayList<>(); @@ -112,6 +139,9 @@ public class MathUtilsTest { assertTrue(result + "/" + exp, exp == result); } + /** + * + */ @Test public void testSumDouble() { List l = new ArrayList<>(); diff --git a/Plan/src/test/java/main/java/com/djrapitops/plan/utilities/MiscUtilsTest.java b/Plan/src/test/java/main/java/com/djrapitops/plan/utilities/MiscUtilsTest.java index 986917e7d..e88d6c4ff 100644 --- a/Plan/src/test/java/main/java/com/djrapitops/plan/utilities/MiscUtilsTest.java +++ b/Plan/src/test/java/main/java/com/djrapitops/plan/utilities/MiscUtilsTest.java @@ -6,7 +6,6 @@ package test.java.main.java.com.djrapitops.plan.utilities; import java.util.Set; -import main.java.com.djrapitops.plan.Phrase; import main.java.com.djrapitops.plan.utilities.MiscUtils; import org.bukkit.Bukkit; import org.bukkit.OfflinePlayer; @@ -59,9 +58,7 @@ public class MiscUtilsTest { @Test public void testCheckVersion() { String versionG = "2.10.9"; - String result = MiscUtils.checkVersion("2.0.0", versionG); - String exp = Phrase.VERSION_NEW_AVAILABLE.parse(versionG); - assertEquals(exp, result); + assertTrue(MiscUtils.checkVersion("2.0.0", versionG)); } /** @@ -69,9 +66,12 @@ public class MiscUtilsTest { */ @Test public void testCheckVersion2() { - String result = MiscUtils.checkVersion("3.0.0", "2.10.9"); - String exp = Phrase.VERSION_LATEST + ""; - assertEquals(exp, result); + assertTrue(!MiscUtils.checkVersion("3.0.0", "2.10.9")); + } + + @Test + public void testCheckVersion5() { + assertTrue(MiscUtils.checkVersion("2.10.9", "3.0.0")); } /** @@ -79,9 +79,7 @@ public class MiscUtilsTest { */ @Test public void testCheckVersion3() { - String result = MiscUtils.checkVersion("2.11.0", "2.10.9"); - String exp = Phrase.VERSION_LATEST + ""; - assertEquals(exp, result); + assertTrue(!MiscUtils.checkVersion("2.11.0", "2.10.9")); } /** @@ -89,9 +87,7 @@ public class MiscUtilsTest { */ @Test public void testCheckVersion4() { - String result = MiscUtils.checkVersion("2.11.0", "2.11.0"); - String exp = Phrase.VERSION_LATEST + ""; - assertEquals(exp, result); + assertTrue(!MiscUtils.checkVersion("2.11.0", "2.11.0")); } /** @@ -181,7 +177,7 @@ public class MiscUtilsTest { boolean equalToExp1 = r.getName().equals(exp1.getName()); boolean equalToExp2 = r.getName().equals(exp2.getName()); if (!(equalToExp1 || equalToExp2)) { - fail("Unknown result!: "+r.getName()); + fail("Unknown result!: " + r.getName()); } } } @@ -197,7 +193,7 @@ public class MiscUtilsTest { assertEquals(1, result.size()); for (OfflinePlayer r : result) { if (!r.getName().equals(exp2.getName())) { - fail("Unknown result!: "+r.getName()); + fail("Unknown result!: " + r.getName()); } } }