mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-23 01:27:42 +01:00
Refactoring, Export utility, bugfixes
- Optimized Advanced Achievements PluginData objects with method introduced in AA 5.2.0 - Fixed some plugindata objects displaying as empty - localStorage -> sessionStorage on html pages
This commit is contained in:
parent
a92da9a503
commit
a2af65349a
@ -26,7 +26,7 @@
|
||||
<dependency>
|
||||
<groupId>com.hm</groupId>
|
||||
<artifactId>advanced.achievements</artifactId>
|
||||
<version>5.1</version>
|
||||
<version>5.2</version>
|
||||
<scope>provided</scope>
|
||||
</dependency>
|
||||
<dependency>
|
||||
@ -183,7 +183,6 @@
|
||||
<param>test.java.main.java.com.djrapitops.plan.*</param>
|
||||
</targetTests>
|
||||
<timeoutConstant>1000</timeoutConstant>
|
||||
<verbose>true</verbose>
|
||||
</configuration>
|
||||
</plugin>
|
||||
<plugin>
|
||||
|
@ -385,7 +385,7 @@ public class Plan extends JavaPlugin {
|
||||
}
|
||||
return INSTANCE;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* Used to set the current instance of Plan.
|
||||
*
|
||||
|
@ -16,6 +16,7 @@ public enum Settings {
|
||||
ANALYSIS_REFRESH_ON_ENABLE("Settings.Cache.AnalysisCache.RefreshAnalysisCacheOnEnable"),
|
||||
ANALYSIS_LOG_TO_CONSOLE("Settings.Analysis.LogProgressOnConsole"),
|
||||
ANALYSIS_LOG_FINISHED("Settings.Analysis.NotifyWhenFinished"),
|
||||
ANALYSIS_EXPORT("Settings.Analysis.Export.Enabled"),
|
||||
SHOW_ALTERNATIVE_IP("Settings.WebServer.ShowAlternativeServerIP"),
|
||||
USE_ALTERNATIVE_UI("Settings.UseTextUI"),
|
||||
GATHERLOCATIONS("Settings.Data.GatherLocations"),
|
||||
@ -48,6 +49,7 @@ public enum Settings {
|
||||
LOCALE("Settings.Locale"),
|
||||
WEBSERVER_IP("Settings.WebServer.InternalIP"),
|
||||
SECURITY_CODE("Settings.WebServer.Security.AddressSecurityCode"),
|
||||
ANALYSIS_EXPORT_PATH("Settings.Analysis.Export.DestinationFolder"),
|
||||
//
|
||||
SERVER_NAME("Customization.ServerName"),
|
||||
//
|
||||
@ -124,7 +126,7 @@ public enum Settings {
|
||||
public int getNumber() {
|
||||
return Plan.getInstance().getConfig().getInt(configPath);
|
||||
}
|
||||
|
||||
|
||||
public List<String> getStringList() {
|
||||
return Plan.getInstance().getConfig().getStringList(configPath);
|
||||
}
|
||||
|
@ -1,11 +1,8 @@
|
||||
package main.java.com.djrapitops.plan.command.commands.manage;
|
||||
|
||||
import java.util.Arrays;
|
||||
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 java.util.stream.Collectors;
|
||||
import main.java.com.djrapitops.plan.Permissions;
|
||||
@ -15,10 +12,7 @@ import main.java.com.djrapitops.plan.command.CommandType;
|
||||
import main.java.com.djrapitops.plan.command.SubCommand;
|
||||
import main.java.com.djrapitops.plan.data.handling.importing.ImportUtils;
|
||||
import main.java.com.djrapitops.plan.data.handling.importing.Importer;
|
||||
import main.java.com.djrapitops.plan.utilities.ManageUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import static org.bukkit.Bukkit.getOfflinePlayers;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
@ -55,14 +49,13 @@ public class ManageImportCommand extends SubCommand {
|
||||
}
|
||||
|
||||
String importFromPlugin = args[0].toLowerCase();
|
||||
List<String> supportedImports = Arrays.asList(new String[]{"ontime"});
|
||||
if (!supportedImports.contains(importFromPlugin)) {
|
||||
Map<String, Importer> importPlugins = ImportUtils.getImporters();
|
||||
if (!importPlugins.keySet().contains(importFromPlugin)) {
|
||||
sender.sendMessage(Phrase.MANAGE_ERROR_INCORRECT_PLUGIN + importFromPlugin);
|
||||
return true;
|
||||
}
|
||||
Map<String, Importer> importPlugins = ImportUtils.getImporters();
|
||||
|
||||
if (!importPlugins.keySet().contains(importFromPlugin) || !ImportUtils.isPluginEnabled(importFromPlugin)) {
|
||||
if (!ImportUtils.isPluginEnabled(importFromPlugin)) {
|
||||
sender.sendMessage(Phrase.MANAGE_ERROR_PLUGIN_NOT_ENABLED + importFromPlugin);
|
||||
return true;
|
||||
}
|
||||
@ -73,7 +66,6 @@ public class ManageImportCommand extends SubCommand {
|
||||
}
|
||||
|
||||
final Importer importer = importPlugins.get(importFromPlugin);
|
||||
// Header
|
||||
BukkitTask asyncImportTask = new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
@ -83,7 +75,6 @@ public class ManageImportCommand extends SubCommand {
|
||||
sender.sendMessage(Phrase.MANAGE_SUCCESS + "");
|
||||
} else {
|
||||
sender.sendMessage(Phrase.MANAGE_PROCESS_FAIL + "");
|
||||
|
||||
}
|
||||
this.cancel();
|
||||
}
|
||||
|
@ -9,8 +9,8 @@ import main.java.com.djrapitops.plan.ui.RecentPlayersButtonsCreator;
|
||||
import main.java.com.djrapitops.plan.ui.graphs.PlayerActivityGraphCreator;
|
||||
import main.java.com.djrapitops.plan.ui.tables.SortableCommandUseTableCreator;
|
||||
import main.java.com.djrapitops.plan.ui.tables.SortablePlayersTableCreator;
|
||||
import main.java.com.djrapitops.plan.utilities.Analysis;
|
||||
import main.java.com.djrapitops.plan.utilities.AnalysisUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.Analysis;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.AnalysisUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.PlaceholderUtils;
|
||||
|
||||
/**
|
||||
@ -886,7 +886,7 @@ public class AnalysisData {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the data for the Session Punchcard
|
||||
* Get the data for the Session Punchcard.
|
||||
*
|
||||
* @return Array of x y r coordinates: [{x: 4, y: 5, r: 4}]
|
||||
*/
|
||||
@ -895,7 +895,7 @@ public class AnalysisData {
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the data for the Session Punchcard
|
||||
* Set the data for the Session Punchcard.
|
||||
*
|
||||
* @param punchCardData Array of x y r coordinates: [{x: 4, y: 5, r: 4}]
|
||||
*/
|
||||
|
@ -4,7 +4,7 @@ import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import main.java.com.djrapitops.plan.utilities.Analysis;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.Analysis;
|
||||
|
||||
/**
|
||||
* This class is used for storing combined data of several UserData objects
|
||||
|
@ -2,9 +2,11 @@ package main.java.com.djrapitops.plan.data.additional.advancedachievements;
|
||||
|
||||
import com.hm.achievement.api.AdvancedAchievementsAPI;
|
||||
import java.io.Serializable;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import main.java.com.djrapitops.plan.data.additional.AnalysisType;
|
||||
import main.java.com.djrapitops.plan.data.additional.PluginData;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
|
||||
/**
|
||||
* PluginData class for AdvancedAchievements-plugin.
|
||||
@ -20,6 +22,8 @@ import main.java.com.djrapitops.plan.data.additional.PluginData;
|
||||
public class AdvancedAchievementsAchievements extends PluginData {
|
||||
|
||||
private AdvancedAchievementsAPI aaAPI;
|
||||
private long lastRefresh;
|
||||
private Map<UUID, Integer> totalAchievements;
|
||||
|
||||
/**
|
||||
* Class Constructor, sets the parameters of the PluginData object.
|
||||
@ -32,16 +36,30 @@ public class AdvancedAchievementsAchievements extends PluginData {
|
||||
super.setAnalysisOnly(false);
|
||||
super.setIcon("check-circle-o");
|
||||
super.setPrefix("Achivements: ");
|
||||
totalAchievements = aaAPI.getPlayersTotalAchievements();
|
||||
lastRefresh = MiscUtils.getTime();
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHtmlReplaceValue(String modifierPrefix, UUID uuid) {
|
||||
return parseContainer(modifierPrefix, aaAPI.getPlayerTotalAchievements(uuid) + "");
|
||||
if (MiscUtils.getTime()- lastRefresh > 60000) {
|
||||
totalAchievements = aaAPI.getPlayersTotalAchievements();
|
||||
}
|
||||
if (totalAchievements.containsKey(uuid)) {
|
||||
return parseContainer(modifierPrefix,totalAchievements.get(uuid) + "");
|
||||
}
|
||||
return parseContainer(modifierPrefix, 0+"");
|
||||
}
|
||||
|
||||
@Override
|
||||
public Serializable getValue(UUID uuid) {
|
||||
return aaAPI.getPlayerTotalAchievements(uuid);
|
||||
if (MiscUtils.getTime()- lastRefresh > 60000) {
|
||||
totalAchievements = aaAPI.getPlayersTotalAchievements();
|
||||
}
|
||||
if (totalAchievements.containsKey(uuid)) {
|
||||
return totalAchievements.get(uuid);
|
||||
}
|
||||
return -1;
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -4,8 +4,12 @@ import com.hm.achievement.api.AdvancedAchievementsAPI;
|
||||
import java.io.Serializable;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
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.ui.Html;
|
||||
@ -47,13 +51,24 @@ public class AdvancedAchievementsTable extends PluginData {
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHtmlReplaceValue(String modifierPrefix, UUID uuid) {
|
||||
public String getHtmlReplaceValue(String modifierPrefix, UUID uuidUnused) {
|
||||
StringBuilder html = new StringBuilder();
|
||||
List<OfflinePlayer> offlinePlayers = Arrays.stream(getOfflinePlayers()).filter(p -> p.hasPlayedBefore()).collect(Collectors.toList());
|
||||
Map<UUID, OfflinePlayer> offlinePlayers = Arrays.stream(getOfflinePlayers()).filter(p -> p.hasPlayedBefore()).collect(Collectors.toMap(p -> p.getUniqueId(), Function.identity()));
|
||||
if (offlinePlayers.isEmpty()) {
|
||||
html.append(Html.TABLELINE_2.parse("No Players.", ""));
|
||||
} else if (aaAPI.getAdvancedAchievementsVersionCode() >= 520) {
|
||||
Map<UUID, Integer> achievementsMap = aaAPI.getPlayersTotalAchievements();
|
||||
for (UUID uuid : achievementsMap.keySet()) {
|
||||
OfflinePlayer p = offlinePlayers.get(uuid);
|
||||
if (p == null) {
|
||||
continue;
|
||||
}
|
||||
String inspectUrl = HtmlUtils.getInspectUrl(p.getName());
|
||||
int achievements = achievementsMap.get(uuid);
|
||||
html.append(Html.TABLELINE_2.parse(Html.LINK.parse(inspectUrl, p.getName()), achievements+""));
|
||||
}
|
||||
} else {
|
||||
for (OfflinePlayer p : offlinePlayers) {
|
||||
for (OfflinePlayer p : offlinePlayers.values()) {
|
||||
String inspectUrl = HtmlUtils.getInspectUrl(p.getName());
|
||||
String achievements = aaAPI.getPlayerTotalAchievements(p.getUniqueId()) + "";
|
||||
html.append(Html.TABLELINE_2.parse(Html.LINK.parse(inspectUrl, p.getName()), achievements));
|
||||
|
@ -41,7 +41,7 @@ public class EssentialsJailed extends PluginData {
|
||||
if (user != null) {
|
||||
return parseContainer(modifier, user.isJailed() ? "Yes" : "No");
|
||||
}
|
||||
return "";
|
||||
return parseContainer(modifier, "No");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -41,7 +41,7 @@ public class EssentialsMuted extends PluginData {
|
||||
if (user != null) {
|
||||
return parseContainer("", user.isMuted() ? "Yes" : "No");
|
||||
}
|
||||
return "";
|
||||
return parseContainer(modifier, "No");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -14,7 +14,7 @@ import main.java.com.djrapitops.plan.data.additional.AnalysisType;
|
||||
import main.java.com.djrapitops.plan.data.additional.PluginData;
|
||||
import main.java.com.djrapitops.plan.ui.Html;
|
||||
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.MathUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.MathUtils;
|
||||
import static org.bukkit.Bukkit.getOfflinePlayers;
|
||||
|
||||
/**
|
||||
|
@ -13,7 +13,7 @@ import main.java.com.djrapitops.plan.data.additional.AnalysisType;
|
||||
import main.java.com.djrapitops.plan.data.additional.PluginData;
|
||||
import main.java.com.djrapitops.plan.ui.Html;
|
||||
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.MathUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.MathUtils;
|
||||
import org.apache.commons.lang.StringUtils;
|
||||
import static org.bukkit.Bukkit.getOnlinePlayers;
|
||||
|
||||
|
@ -37,7 +37,7 @@ public class TownyTown extends PluginData {
|
||||
public String getHtmlReplaceValue(String modifierPrefix, UUID uuid) {
|
||||
OfflinePlayer offlinePlayer = getOfflinePlayer(uuid);
|
||||
if (!offlinePlayer.hasPlayedBefore()) {
|
||||
return "";
|
||||
return parseContainer(modifierPrefix, Phrase.NOT_IN_TOWN + "");
|
||||
}
|
||||
String name = offlinePlayer.getName();
|
||||
try {
|
||||
@ -50,7 +50,7 @@ public class TownyTown extends PluginData {
|
||||
}
|
||||
return parseContainer("", town);
|
||||
} catch (NotRegisteredException ex) {
|
||||
return "";
|
||||
return parseContainer(modifierPrefix, Phrase.NOT_IN_TOWN + "");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2,7 +2,7 @@ package main.java.com.djrapitops.plan.data.cache;
|
||||
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.data.AnalysisData;
|
||||
import main.java.com.djrapitops.plan.utilities.Analysis;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.Analysis;
|
||||
|
||||
/**
|
||||
* This class is used to store the most recent AnalysisData object and to run
|
||||
|
@ -96,6 +96,12 @@ public class InspectCacheHandler {
|
||||
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) {
|
||||
if (cacheTimes.containsKey(uuid)) {
|
||||
return cacheTimes.get(uuid);
|
||||
|
@ -34,7 +34,7 @@ public class KillHandling {
|
||||
int victimID;
|
||||
try {
|
||||
UUID victimUUID = deadPlayer.getUniqueId();
|
||||
victimID = plugin.getDB().getUserId(victimUUID + "");
|
||||
victimID = plugin.getDB().getUsersTable().getUserId(victimUUID + "");
|
||||
if (victimID == -1) {
|
||||
return;
|
||||
}
|
||||
|
@ -14,12 +14,13 @@ import main.java.com.djrapitops.plan.database.tables.NicknamesTable;
|
||||
import main.java.com.djrapitops.plan.database.tables.SessionsTable;
|
||||
import main.java.com.djrapitops.plan.database.tables.UsersTable;
|
||||
import main.java.com.djrapitops.plan.database.tables.VersionTable;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.World;
|
||||
|
||||
/**
|
||||
* Abstract class representing a Database.
|
||||
*
|
||||
* All methods should be only called from an asyncronous thread, unless stated
|
||||
* otherwise.
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public abstract class Database {
|
||||
@ -131,21 +132,6 @@ public abstract class Database {
|
||||
*/
|
||||
public abstract List<UserData> getUserDataForUUIDS(Collection<UUID> uuids) throws SQLException;
|
||||
|
||||
/**
|
||||
* Used to save UserData object of a user.
|
||||
*
|
||||
* @param uuid UUID of the player
|
||||
* @param data UserData of the Player.
|
||||
* @throws SQLException If a database error occurs.
|
||||
* @deprecated Separate UUID no longer required.
|
||||
*/
|
||||
@Deprecated
|
||||
public void saveUserData(UUID uuid, UserData data) throws SQLException {
|
||||
if (uuid.equals(data.getUuid())) {
|
||||
saveUserData(data);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to save UserData object of a user.
|
||||
*
|
||||
@ -178,6 +164,8 @@ public abstract class Database {
|
||||
/**
|
||||
* Used to get the name of the database type.
|
||||
*
|
||||
* Thread safe.
|
||||
*
|
||||
* @return SQLite/MySQL
|
||||
*/
|
||||
public abstract String getName();
|
||||
@ -185,6 +173,8 @@ public abstract class Database {
|
||||
/**
|
||||
* Used to get the config name of the database type.
|
||||
*
|
||||
* Thread safe.
|
||||
*
|
||||
* @return sqlite/mysql
|
||||
*/
|
||||
public String getConfigName() {
|
||||
@ -238,127 +228,101 @@ public abstract class Database {
|
||||
/**
|
||||
* Used to save CommandUse map.
|
||||
*
|
||||
* @param data
|
||||
* @param data String command (key), Integer times used
|
||||
* @throws SQLException If a database error occurs.
|
||||
* @throws NullPointerException If the database has not initialized tables.
|
||||
*/
|
||||
@Deprecated
|
||||
public void saveCommandUse(Map<String, Integer> data) throws SQLException, NullPointerException {
|
||||
commandUseTable.saveCommandUse(data);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to fetch the saved UUIDs in the users table.
|
||||
*
|
||||
* @return @throws SQLException If a database error occurs.
|
||||
* @return Set of saved UUIDs
|
||||
* @throws SQLException If a database error occurs.
|
||||
*/
|
||||
public Set<UUID> getSavedUUIDs() throws SQLException {
|
||||
return usersTable.getSavedUUIDs();
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get the Command usage mep.
|
||||
*
|
||||
* @return @throws SQLException If a database error occurs.
|
||||
* @return String command (key), Integer times used
|
||||
* @throws SQLException If a database error occurs.
|
||||
*/
|
||||
@Deprecated
|
||||
public Map<String, Integer> getCommandUse() throws SQLException {
|
||||
return commandUseTable.getCommandUse();
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get the users table.
|
||||
*
|
||||
* @param uuid
|
||||
* @return
|
||||
* @throws SQLException If a database error occurs.
|
||||
*/
|
||||
@Deprecated
|
||||
public int getUserId(String uuid) throws SQLException {
|
||||
return usersTable.getUserId(uuid);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param userId
|
||||
* @param worlds
|
||||
* @return
|
||||
* @throws SQLException If a database error occurs.
|
||||
*/
|
||||
@Deprecated
|
||||
public List<Location> getLocations(String userId, HashMap<String, World> worlds) throws SQLException {
|
||||
return getLocations(Integer.parseInt(userId), worlds);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param userId
|
||||
* @param worlds
|
||||
* @return
|
||||
* @throws SQLException
|
||||
* @deprecated
|
||||
*/
|
||||
@Deprecated
|
||||
public List<Location> getLocations(int userId, HashMap<String, World> worlds) throws SQLException {
|
||||
return locationsTable.getLocations(userId, worlds);
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @return Table representing plan_users
|
||||
*/
|
||||
public UsersTable getUsersTable() {
|
||||
return usersTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get the users table.
|
||||
*
|
||||
* @return
|
||||
* @return Table representing plan_sessions
|
||||
*/
|
||||
public SessionsTable getSessionsTable() {
|
||||
return sessionsTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get the gm times table.
|
||||
*
|
||||
* @return
|
||||
* @return Table representing plan_gamemodetimes
|
||||
*/
|
||||
public GMTimesTable getGmTimesTable() {
|
||||
return gmTimesTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get the kills table.
|
||||
*
|
||||
* @return
|
||||
* @return Table representing plan_kills
|
||||
*/
|
||||
public KillsTable getKillsTable() {
|
||||
return killsTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get the locations table.
|
||||
*
|
||||
* @return
|
||||
* @return Table representing plan_locations
|
||||
*/
|
||||
public LocationsTable getLocationsTable() {
|
||||
return locationsTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get the ips table.
|
||||
*
|
||||
* @return
|
||||
* @return Table representing plan_ips
|
||||
*/
|
||||
public IPsTable getIpsTable() {
|
||||
return ipsTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get the nicknames table.
|
||||
*
|
||||
* @return
|
||||
* @return Table representing plan_nicknames
|
||||
*/
|
||||
public NicknamesTable getNicknamesTable() {
|
||||
return nicknamesTable;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get the command usage table.
|
||||
*
|
||||
* @return
|
||||
* @return Table representing plan_commandusages
|
||||
*/
|
||||
public CommandUseTable getCommandUseTable() {
|
||||
return commandUseTable;
|
||||
|
@ -104,7 +104,7 @@ public class CommandUseTable extends Table {
|
||||
commitRequired = true;
|
||||
}
|
||||
if (commitRequired) {
|
||||
Log.debug("CommandUse: Executing batch, size: "+data.size());
|
||||
Log.debug("CommandUse: Executing batch, size: " + data.size());
|
||||
statement.executeBatch();
|
||||
}
|
||||
} finally {
|
||||
|
@ -7,7 +7,6 @@ import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.database.databases.SQLDB;
|
||||
import main.java.com.djrapitops.plan.utilities.Benchmark;
|
||||
import org.bukkit.GameMode;
|
||||
|
||||
/**
|
||||
@ -120,7 +119,7 @@ public class GMTimesTable extends Table {
|
||||
if (gamemodeTimes == null || gamemodeTimes.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
PreparedStatement statement = null;
|
||||
GameMode[] gms = new GameMode[]{GameMode.SURVIVAL, GameMode.CREATIVE, GameMode.ADVENTURE, GameMode.SPECTATOR};
|
||||
int update = 0;
|
||||
@ -147,12 +146,12 @@ public class GMTimesTable extends Table {
|
||||
}
|
||||
update = statement.executeUpdate();
|
||||
} finally {
|
||||
close(statement);
|
||||
close(statement);
|
||||
}
|
||||
if (update == 0) {
|
||||
addNewGMTimesRow(userId, gamemodeTimes);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
private void addNewGMTimesRow(int userId, Map<GameMode, Long> gamemodeTimes) throws SQLException {
|
||||
|
@ -21,7 +21,7 @@ import main.java.com.djrapitops.plan.utilities.Benchmark;
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class IPsTable extends Table {
|
||||
|
||||
|
||||
private final String columnUserID;
|
||||
private final String columnIP;
|
||||
|
||||
@ -145,7 +145,7 @@ public class IPsTable extends Table {
|
||||
Benchmark.stop("Save Ips");
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param ids
|
||||
@ -183,7 +183,7 @@ public class IPsTable extends Table {
|
||||
Benchmark.stop("Get Ips Multiple " + ids.size());
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
*
|
||||
* @param ips
|
||||
|
@ -91,7 +91,7 @@ public class LocationsTable extends Table {
|
||||
* @return
|
||||
* @throws SQLException
|
||||
*/
|
||||
public List<Location> getLocations(int userId, HashMap<String, World> worlds) throws SQLException {
|
||||
public List<Location> getLocations(int userId, Map<String, World> worlds) throws SQLException {
|
||||
Benchmark.start("Get Locations");
|
||||
PreparedStatement statement = null;
|
||||
ResultSet set = null;
|
||||
@ -111,6 +111,29 @@ public class LocationsTable extends Table {
|
||||
}
|
||||
}
|
||||
|
||||
public Map<Integer, List<Location>> getAllLocations(Map<String, World> worlds) throws SQLException {
|
||||
Benchmark.start("Get Locations Multiple");
|
||||
PreparedStatement statement = null;
|
||||
ResultSet set = null;
|
||||
Map<Integer, List<Location>> locations = new HashMap<>();
|
||||
try {
|
||||
statement = prepareStatement("SELECT * FROM " + tableName);
|
||||
set = statement.executeQuery();
|
||||
while (set.next()) {
|
||||
int id = set.getInt(columnID);
|
||||
if (!locations.containsKey(id)) {
|
||||
locations.put(id, new ArrayList<>());
|
||||
}
|
||||
locations.get(id).add(new Location(worlds.get(set.getString(columnWorld)), set.getInt(columnCoordinatesX), 0, set.getInt(columnCoordinatesZ)));
|
||||
}
|
||||
return locations;
|
||||
} finally {
|
||||
close(set);
|
||||
close(statement);
|
||||
Benchmark.stop("Get Locations Multiple");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param userId
|
||||
@ -121,7 +144,7 @@ public class LocationsTable extends Table {
|
||||
if (locations == null || locations.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Benchmark.start("Save Locations "+locations.size());
|
||||
Benchmark.start("Save Locations " + locations.size());
|
||||
List<Location> newLocations = new ArrayList<>();
|
||||
newLocations.addAll(locations);
|
||||
PreparedStatement statement = null;
|
||||
@ -153,7 +176,7 @@ public class LocationsTable extends Table {
|
||||
}
|
||||
} finally {
|
||||
close(statement);
|
||||
Benchmark.stop("Save Locations "+locations.size());
|
||||
Benchmark.stop("Save Locations " + locations.size());
|
||||
}
|
||||
}
|
||||
|
||||
@ -166,7 +189,7 @@ public class LocationsTable extends Table {
|
||||
if (locations == null || locations.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Benchmark.start("Save Locations Multiple "+locations.size());
|
||||
Benchmark.start("Save Locations Multiple " + locations.size());
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
statement = prepareStatement("INSERT INTO " + tableName + " ("
|
||||
@ -199,7 +222,7 @@ public class LocationsTable extends Table {
|
||||
}
|
||||
} finally {
|
||||
close(statement);
|
||||
Benchmark.stop("Save Locations Multiple "+locations.size());
|
||||
Benchmark.stop("Save Locations Multiple " + locations.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -161,7 +161,7 @@ public class SessionsTable extends Table {
|
||||
if (ids == null || ids.isEmpty()) {
|
||||
return new HashMap<>();
|
||||
}
|
||||
Benchmark.start("Get Sessions multiple "+ids.size());
|
||||
Benchmark.start("Get Sessions multiple " + ids.size());
|
||||
PreparedStatement statement = null;
|
||||
ResultSet set = null;
|
||||
try {
|
||||
@ -185,7 +185,7 @@ public class SessionsTable extends Table {
|
||||
} finally {
|
||||
close(set);
|
||||
close(statement);
|
||||
Benchmark.stop("Get Sessions multiple "+ids.size());
|
||||
Benchmark.stop("Get Sessions multiple " + ids.size());
|
||||
}
|
||||
}
|
||||
|
||||
@ -198,7 +198,7 @@ public class SessionsTable extends Table {
|
||||
if (sessions == null || sessions.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Benchmark.start("Save Sessions multiple "+sessions.size());
|
||||
Benchmark.start("Save Sessions multiple " + sessions.size());
|
||||
Map<Integer, List<SessionData>> saved = getSessionData(sessions.keySet());
|
||||
PreparedStatement statement = null;
|
||||
try {
|
||||
@ -236,7 +236,7 @@ public class SessionsTable extends Table {
|
||||
}
|
||||
} finally {
|
||||
close(statement);
|
||||
Benchmark.start("Save Sessions multiple "+sessions.size());
|
||||
Benchmark.stop("Save Sessions multiple " + sessions.size());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -41,8 +41,7 @@ public class VersionTable extends Table {
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
* @throws SQLException
|
||||
* @return @throws SQLException
|
||||
*/
|
||||
@Override
|
||||
public int getVersion() throws SQLException {
|
||||
|
@ -7,9 +7,9 @@ import main.java.com.djrapitops.plan.data.AnalysisData;
|
||||
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.AnalysisUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.AnalysisUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.MathUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.MathUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
|
@ -35,16 +35,14 @@ public class PlayerActivityGraphCreator {
|
||||
List<Long> sessionStarts = s.get(0);
|
||||
List<Long> sessionEnds = s.get(1);
|
||||
|
||||
Benchmark.start("Player Activity Graph Before Addition");
|
||||
int amount = (int) sessionStarts.stream().filter(start -> start < nowMinusScale).count();
|
||||
for (int i = amount; i > 0; i--) {
|
||||
sessionStarts.add(nowMinusScale);
|
||||
}
|
||||
Benchmark.stop("Player Activity Graph Before Addition");
|
||||
Benchmark.start("Player Activity Graph Amount Calculation");
|
||||
|
||||
|
||||
Map<Long, Integer> change = transformIntoChangeMap(sessionStarts, sessionEnds);
|
||||
|
||||
|
||||
long lastPValue = 0;
|
||||
long lastSavedPValue = -1;
|
||||
long lastSaveIndex = 0;
|
||||
@ -115,7 +113,6 @@ public class PlayerActivityGraphCreator {
|
||||
* @return
|
||||
*/
|
||||
public static List<List<Long>> filterAndTransformSessions(List<SessionData> sessionData, long nowMinusScale) {
|
||||
Benchmark.start("Player Activity Graph Transform " + sessionData.size() + " " + nowMinusScale);
|
||||
List<Long[]> values = sessionData.parallelStream()
|
||||
.filter(session -> (session != null))
|
||||
.filter(session -> session.isValid())
|
||||
@ -131,7 +128,6 @@ public class PlayerActivityGraphCreator {
|
||||
List<List<Long>> r = new ArrayList<>();
|
||||
r.add(sessionStarts);
|
||||
r.add(sessionEnds);
|
||||
Benchmark.stop("Player Activity Graph Transform " + sessionData.size() + " " + nowMinusScale);
|
||||
return r;
|
||||
}
|
||||
|
||||
|
@ -13,8 +13,8 @@ import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.stream.Collectors;
|
||||
import main.java.com.djrapitops.plan.data.SessionData;
|
||||
import main.java.com.djrapitops.plan.utilities.AnalysisUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.MathUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.AnalysisUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.MathUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -3,7 +3,7 @@ package main.java.com.djrapitops.plan.ui.tables;
|
||||
import java.util.Collection;
|
||||
import main.java.com.djrapitops.plan.data.UserData;
|
||||
import main.java.com.djrapitops.plan.ui.Html;
|
||||
import main.java.com.djrapitops.plan.utilities.AnalysisUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.AnalysisUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.Benchmark;
|
||||
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
|
||||
|
@ -106,7 +106,6 @@ public class HtmlUtils {
|
||||
StringBuilder html = new StringBuilder();
|
||||
String temp = "";
|
||||
int evenSize = pluginNames.size() - (pluginNames.size() % 2);
|
||||
Log.debug("Html parsing for:" + pluginNames + ", " + (evenSize));
|
||||
for (int i = 0; i < evenSize; i++) {
|
||||
String name = pluginNames.get(i);
|
||||
if (i % 2 == 0) {
|
||||
@ -134,7 +133,6 @@ public class HtmlUtils {
|
||||
}
|
||||
|
||||
private static String getContent(String name, List<String> placeholders) {
|
||||
Log.debug("Getting content for: "+name);
|
||||
StringBuilder html = new StringBuilder();
|
||||
html.append(Html.HEADER.parse(name));
|
||||
html.append(Html.PLUGIN_CONTAINER_START.parse());
|
||||
|
@ -1,5 +1,7 @@
|
||||
package main.java.com.djrapitops.plan.utilities;
|
||||
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.MathUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.AnalysisUtils;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
|
@ -1,4 +1,4 @@
|
||||
package main.java.com.djrapitops.plan.utilities;
|
||||
package main.java.com.djrapitops.plan.utilities.analysis;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.HashMap;
|
||||
@ -30,6 +30,9 @@ import main.java.com.djrapitops.plan.ui.graphs.PunchCardGraphCreator;
|
||||
import main.java.com.djrapitops.plan.ui.graphs.SessionLengthDistributionGraphCreator;
|
||||
import main.java.com.djrapitops.plan.ui.tables.SortableCommandUseTableCreator;
|
||||
import main.java.com.djrapitops.plan.ui.tables.SortablePlayersTableCreator;
|
||||
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 org.bukkit.GameMode;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scheduler.BukkitTask;
|
||||
@ -113,14 +116,55 @@ public class Analysis {
|
||||
List<UUID> uuids = rawData.stream().map(d -> d.getUuid()).collect(Collectors.toList());
|
||||
Benchmark.stop("Analysis UUID transform");
|
||||
Benchmark.start("Analysis Create Empty dataset");
|
||||
Map<String, Integer> commandUse = plugin.getHandler().getCommandUse();
|
||||
long now = MiscUtils.getTime();
|
||||
final RawAnalysisData sorted = new RawAnalysisData();
|
||||
sorted.setCommandUse(plugin.getHandler().getCommandUse());
|
||||
AnalysisData analysisData = new AnalysisData();
|
||||
Benchmark.stop("Analysis Create Empty dataset");
|
||||
log(Phrase.ANALYSIS_BEGIN_ANALYSIS + "");
|
||||
String playersTable = SortablePlayersTableCreator.createSortablePlayersTable(rawData);
|
||||
analysisData.setSortablePlayersTable(playersTable);
|
||||
|
||||
RawAnalysisData sorted = fillDataset(commandUse, rawData, now);
|
||||
|
||||
// Analyze & Save RawAnalysisData to AnalysisData
|
||||
createCloroplethMap(analysisData, sorted.getGeolocations(), sorted.getGeocodes());
|
||||
createPlayerActivityGraphs(analysisData, sorted.getSessiondata(), sorted.getRegistered());
|
||||
analysisData.setRecentPlayers(RecentPlayersButtonsCreator.createRecentLoginsButtons(sorted.getLatestLogins(), 20));
|
||||
long totalPlaytime = sorted.getTotalPlaytime();
|
||||
analysisData.setTotalPlayTime(totalPlaytime);
|
||||
analysisData.setAveragePlayTime(totalPlaytime / rawData.size());
|
||||
analysisData.setSessionAverage(MathUtils.averageLong(AnalysisUtils.transformSessionDataToLengths(sorted.getSessiondata())));
|
||||
analysisData.setTotalLoginTimes(sorted.getTotalLoginTimes());
|
||||
createActivityVisalization(uuids.size(), sorted.getTotalBanned(), sorted.getActive(), sorted.getInactive(), sorted.getJoinleaver(), analysisData);
|
||||
analysisData.setOps(sorted.getOps());
|
||||
analyzeAverageAge(sorted.getAges(), analysisData);
|
||||
createGamemodeUsageVisualization(sorted.getGmZero(), sorted.getGmOne(), sorted.getGmTwo(), sorted.getGmThree(), analysisData);
|
||||
createCommandUseTable(sorted, analysisData);
|
||||
analysisData.setTotaldeaths(sorted.getTotalDeaths());
|
||||
analysisData.setTotalkills(sorted.getTotalKills());
|
||||
analysisData.setTotalmobkills(sorted.getTotalMobKills());
|
||||
analysisData.setRefreshDate(now);
|
||||
analysisData.setGenderData(sorted.getGenders());
|
||||
analysisData.setPunchCardData(PunchCardGraphCreator.generateDataArray(sorted.getSessiondata()));
|
||||
analysisData.setSessionDistributionData(SessionLengthDistributionGraphCreator.generateDataArraySessions(sorted.getSessiondata()));
|
||||
analysisData.setPlaytimeDistributionData(SessionLengthDistributionGraphCreator.generateDataArray(sorted.getPlaytimes().values()));
|
||||
|
||||
analysisData.setAdditionalDataReplaceMap(analyzeAdditionalPluginData(uuids));
|
||||
|
||||
analysisCache.cache(analysisData);
|
||||
Benchmark.stop("Analysis");
|
||||
if (Settings.ANALYSIS_LOG_FINISHED.isTrue()) {
|
||||
Log.info(Phrase.ANALYSIS_COMPLETE + "");
|
||||
}
|
||||
if (Settings.ANALYSIS_EXPORT.isTrue()) {
|
||||
ExportUtility.export(plugin, analysisData, rawData);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private RawAnalysisData fillDataset(Map<String, Integer> commandUse, List<UserData> rawData, long now) {
|
||||
final RawAnalysisData sorted = new RawAnalysisData();
|
||||
sorted.setCommandUse(commandUse);
|
||||
sorted.fillGeolocations();
|
||||
Benchmark.start("Analysis Fill Dataset");
|
||||
rawData.stream().forEach((uData) -> {
|
||||
@ -204,35 +248,7 @@ public class Analysis {
|
||||
}
|
||||
});
|
||||
Benchmark.stop("Analysis Fill Dataset");
|
||||
createCloroplethMap(analysisData, sorted.getGeolocations(), sorted.getGeocodes());
|
||||
// Analyze & Save RawAnalysisData to AnalysisData
|
||||
createPlayerActivityGraphs(analysisData, sorted.getSessiondata(), sorted.getRegistered());
|
||||
analysisData.setRecentPlayers(RecentPlayersButtonsCreator.createRecentLoginsButtons(sorted.getLatestLogins(), 20));
|
||||
long totalPlaytime = sorted.getTotalPlaytime();
|
||||
analysisData.setTotalPlayTime(totalPlaytime);
|
||||
analysisData.setAveragePlayTime(totalPlaytime / rawData.size());
|
||||
analysisData.setSessionAverage(MathUtils.averageLong(AnalysisUtils.transformSessionDataToLengths(sorted.getSessiondata())));
|
||||
analysisData.setTotalLoginTimes(sorted.getTotalLoginTimes());
|
||||
createActivityVisalization(uuids.size(), sorted.getTotalBanned(), sorted.getActive(), sorted.getInactive(), sorted.getJoinleaver(), analysisData);
|
||||
analysisData.setOps(sorted.getOps());
|
||||
analyzeAverageAge(sorted.getAges(), analysisData);
|
||||
createGamemodeUsageVisualization(sorted.getGmZero(), sorted.getGmOne(), sorted.getGmTwo(), sorted.getGmThree(), analysisData);
|
||||
createCommandUseTable(sorted, analysisData);
|
||||
analysisData.setTotaldeaths(sorted.getTotalDeaths());
|
||||
analysisData.setTotalkills(sorted.getTotalKills());
|
||||
analysisData.setTotalmobkills(sorted.getTotalMobKills());
|
||||
analysisData.setRefreshDate(now);
|
||||
analysisData.setGenderData(sorted.getGenders());
|
||||
analysisData.setPunchCardData(PunchCardGraphCreator.generateDataArray(sorted.getSessiondata()));
|
||||
analysisData.setSessionDistributionData(SessionLengthDistributionGraphCreator.generateDataArraySessions(sorted.getSessiondata()));
|
||||
analysisData.setPlaytimeDistributionData(SessionLengthDistributionGraphCreator.generateDataArray(sorted.getPlaytimes().values()));
|
||||
analysisData.setAdditionalDataReplaceMap(analyzeAdditionalPluginData(uuids));
|
||||
analysisCache.cache(analysisData);
|
||||
Benchmark.stop("Analysis");
|
||||
if (Settings.ANALYSIS_LOG_FINISHED.isTrue()) {
|
||||
Log.info(Phrase.ANALYSIS_COMPLETE + "");
|
||||
}
|
||||
return true;
|
||||
return sorted;
|
||||
}
|
||||
|
||||
private void createCommandUseTable(final RawAnalysisData raw, AnalysisData data) {
|
||||
@ -299,9 +315,9 @@ public class Analysis {
|
||||
List<SessionData> sessions = sData.stream()
|
||||
.filter(session -> (session != null))
|
||||
.filter(session -> session.isValid())
|
||||
.filter((session) -> (session.getSessionStart() >= now-scaleMonth || session.getSessionEnd() >= now-scaleMonth))
|
||||
.filter((session) -> (session.getSessionStart() >= now - scaleMonth || session.getSessionEnd() >= now - scaleMonth))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
String[] dayArray = PlayerActivityGraphCreator.generateDataArray(sessions, scaleDay, maxPlayers);
|
||||
String[] weekArray = PlayerActivityGraphCreator.generateDataArray(sessions, scaleWeek, maxPlayers);
|
||||
String[] monthArray = PlayerActivityGraphCreator.generateDataArray(sessions, scaleMonth, maxPlayers);
|
||||
@ -340,6 +356,7 @@ public class Analysis {
|
||||
}
|
||||
|
||||
private Map<String, String> analyzeAdditionalPluginData(List<UUID> uuids) {
|
||||
Benchmark.start("Analysis 3rd party");
|
||||
final Map<String, String> replaceMap = new HashMap<>();
|
||||
final HookHandler hookHandler = plugin.getHookHandler();
|
||||
final List<PluginData> sources = hookHandler.getAdditionalDataSources();
|
||||
@ -386,6 +403,7 @@ public class Analysis {
|
||||
Benchmark.stop("Source " + source.getPlaceholder("").replace("%", ""));
|
||||
}
|
||||
});
|
||||
Benchmark.stop("Analysis 3rd party");
|
||||
return replaceMap;
|
||||
}
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package main.java.com.djrapitops.plan.utilities;
|
||||
package main.java.com.djrapitops.plan.utilities.analysis;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
||||
@ -11,6 +11,9 @@ import main.java.com.djrapitops.plan.Settings;
|
||||
import main.java.com.djrapitops.plan.data.SessionData;
|
||||
import main.java.com.djrapitops.plan.data.additional.AnalysisType;
|
||||
import main.java.com.djrapitops.plan.data.additional.PluginData;
|
||||
import main.java.com.djrapitops.plan.utilities.Benchmark;
|
||||
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
|
||||
/**
|
||||
*
|
@ -0,0 +1,92 @@
|
||||
/*
|
||||
* 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.utilities.analysis;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.io.IOException;
|
||||
import java.nio.file.Files;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
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.Settings;
|
||||
import main.java.com.djrapitops.plan.data.AnalysisData;
|
||||
import main.java.com.djrapitops.plan.data.UserData;
|
||||
import main.java.com.djrapitops.plan.ui.DataRequestHandler;
|
||||
import main.java.com.djrapitops.plan.ui.webserver.WebSocketServer;
|
||||
import main.java.com.djrapitops.plan.utilities.Benchmark;
|
||||
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.PlaceholderUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @since 3.4.0
|
||||
*/
|
||||
public class ExportUtility {
|
||||
|
||||
private static File getFolder() throws IOException {
|
||||
String path = Settings.ANALYSIS_EXPORT_PATH.toString();
|
||||
if (path.contains(":")) {
|
||||
File folder = new File(path);
|
||||
if (folder.exists()) {
|
||||
if (folder.isDirectory()) {
|
||||
return folder;
|
||||
}
|
||||
}
|
||||
folder.mkdirs();
|
||||
return folder;
|
||||
}
|
||||
File dataFolder = Plan.getInstance().getDataFolder();
|
||||
File folder = new File(dataFolder, path);
|
||||
folder.mkdirs();
|
||||
return folder;
|
||||
}
|
||||
|
||||
public static void export(Plan plugin, AnalysisData analysisData, List<UserData> rawData) {
|
||||
Benchmark.start("Exporting Html pages");
|
||||
try {
|
||||
File folder = getFolder();
|
||||
writeAnalysisHtml(analysisData, folder);
|
||||
File playersFolder = new File(folder, "player");
|
||||
playersFolder.mkdirs();
|
||||
for (UserData userData : rawData) {
|
||||
writeInspectHtml(userData, playersFolder);
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
Log.toLog("ExportUtils.export", ex);
|
||||
} finally {
|
||||
Benchmark.stop("Exporting Html pages");
|
||||
}
|
||||
}
|
||||
|
||||
private static void writeInspectHtml(UserData userData, File playersFolder) throws FileNotFoundException, IOException {
|
||||
String inspectHtml = HtmlUtils.replacePlaceholders(HtmlUtils.getHtmlStringFromResource("player.html"),
|
||||
PlaceholderUtils.getInspectReplaceRules(userData));
|
||||
File playerFolder = new File(playersFolder, userData.getName());
|
||||
playerFolder.mkdir();
|
||||
File inspectHtmlFile = new File(playerFolder, "index.html");
|
||||
if (inspectHtmlFile.exists()) {
|
||||
inspectHtmlFile.delete();
|
||||
}
|
||||
Files.write(inspectHtmlFile.toPath(), Arrays.asList(inspectHtml));
|
||||
}
|
||||
|
||||
private static void writeAnalysisHtml(AnalysisData analysisData, File folder) throws FileNotFoundException, IOException {
|
||||
String analysisHtml = HtmlUtils.replacePlaceholders(HtmlUtils.getHtmlStringFromResource("analysis.html"),
|
||||
PlaceholderUtils.getAnalysisReplaceRules(analysisData))
|
||||
.replace(HtmlUtils.getInspectUrl(""), "./player/");
|
||||
File analysisHtmlFile = new File(folder, "analysis.html");
|
||||
if (analysisHtmlFile.exists()) {
|
||||
analysisHtmlFile.delete();
|
||||
}
|
||||
Files.write(analysisHtmlFile.toPath(), Arrays.asList(analysisHtml));
|
||||
}
|
||||
|
||||
}
|
@ -1,4 +1,4 @@
|
||||
package main.java.com.djrapitops.plan.utilities;
|
||||
package main.java.com.djrapitops.plan.utilities.analysis;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.Collection;
|
@ -808,7 +808,7 @@ function closeNav() {
|
||||
}
|
||||
var navButtons = document.getElementsByClassName("nav-button");
|
||||
var tabs = document.getElementsByClassName("tab");
|
||||
var slideIndex = window.localStorage.getItem("AnalysisSlideIndex");
|
||||
var slideIndex = window.sessionStorage.getItem("AnalysisSlideIndex");
|
||||
if (slideIndex == null) {
|
||||
slideIndex = 0;
|
||||
}
|
||||
@ -844,7 +844,7 @@ function openFunc(i) {
|
||||
slideIndex = i;
|
||||
if (slideIndex>max) {slideIndex=0};
|
||||
if (slideIndex<0) {slideIndex=max};
|
||||
window.localStorage.setItem("AnalysisSlideIndex", slideIndex);
|
||||
window.sessionStorage.setItem("AnalysisSlideIndex", slideIndex);
|
||||
var value = slideIndex*perc;
|
||||
x.style.transition = "0.5s";
|
||||
x.style.transform = "translate3d("+value+"%,0px,0)";
|
||||
|
@ -8,6 +8,9 @@ Settings:
|
||||
LogProgressOnConsole: false
|
||||
NotifyWhenFinished: true
|
||||
MinutesPlayedUntilConsidiredActive: 10
|
||||
Export:
|
||||
Enabled: false
|
||||
DestinationFolder: 'Analysis Results'
|
||||
Cache:
|
||||
Processing:
|
||||
GetLimit: 2000
|
||||
|
@ -560,7 +560,7 @@ function closeNav() {
|
||||
}
|
||||
var navButtons = document.getElementsByClassName("nav-button");
|
||||
var tabs = document.getElementsByClassName("tab");
|
||||
var slideIndex = window.localStorage.getItem("InspectSlideIndex");
|
||||
var slideIndex = window.sessionStorage.getItem("InspectSlideIndex");
|
||||
if (slideIndex == null) {
|
||||
slideIndex = 0;
|
||||
}
|
||||
@ -596,7 +596,7 @@ function openFunc(i) {
|
||||
slideIndex = i;
|
||||
if (slideIndex>max) {slideIndex=0};
|
||||
if (slideIndex<0) {slideIndex=max};
|
||||
window.localStorage.setItem("InspectSlideIndex", slideIndex);
|
||||
window.sessionStorage.setItem("InspectSlideIndex", slideIndex);
|
||||
var value = slideIndex*perc;
|
||||
x.style.transition = "0.5s";
|
||||
x.style.transform = "translate3d("+value+"%,0px,0)";
|
||||
|
@ -60,7 +60,7 @@ public class DataCacheSaveQueueTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public void saveUserData(UUID uuid, UserData data) throws SQLException {
|
||||
public void saveUserData(UserData data) throws SQLException {
|
||||
if (calledSaveUserData) {
|
||||
calledSaveUserData2 = true;
|
||||
}
|
||||
|
@ -65,8 +65,8 @@ public class KillHandlingTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUserId(String uuid) {
|
||||
return 1;
|
||||
public void convertBukkitDataToDB() {
|
||||
|
||||
}
|
||||
};
|
||||
when(plan.getDB()).thenReturn(db);
|
||||
@ -89,7 +89,8 @@ public class KillHandlingTest {
|
||||
public void testProcessKillInfoPlayer() throws SQLException {
|
||||
UserData data = new UserData(MockUtils.mockPlayer(), new DemographicsData());
|
||||
Player dead = MockUtils.mockPlayer2();
|
||||
// db.saveUserData(dead.getUniqueId(), new UserData(dead, new DemographicsData()));
|
||||
db.init();
|
||||
db.saveUserData(new UserData(dead, new DemographicsData()));
|
||||
KillHandling.processKillInfo(data, 10L, dead, "TestWeapon");
|
||||
KillData expected = new KillData(dead.getUniqueId(), 1, "TestWeapon", 10L);
|
||||
assertTrue("Didn't add the kill", data.getPlayerKills().size() == 1);
|
||||
|
@ -59,8 +59,8 @@ public class KillInfoTest {
|
||||
}
|
||||
|
||||
@Override
|
||||
public int getUserId(String uuid) {
|
||||
return 1;
|
||||
public void convertBukkitDataToDB() {
|
||||
|
||||
}
|
||||
};
|
||||
when(plan.getDB()).thenReturn(db);
|
||||
@ -83,7 +83,8 @@ public class KillInfoTest {
|
||||
public void testProcess() throws SQLException {
|
||||
UserData data = new UserData(MockUtils.mockPlayer(), new DemographicsData());
|
||||
Player dead = MockUtils.mockPlayer2();
|
||||
// db.saveUserData(dead.getUniqueId(), new UserData(dead, new DemographicsData()));
|
||||
db.init();
|
||||
db.saveUserData(new UserData(dead, new DemographicsData()));
|
||||
KillInfo i = new KillInfo(data.getUuid(), 10L, dead, "TestWeapon");
|
||||
assertTrue(i.process(data));
|
||||
KillData expected = new KillData(dead.getUniqueId(), 1, "TestWeapon", 10L);
|
||||
|
@ -275,7 +275,7 @@ public class DatabaseTest {
|
||||
db.saveUserData(data2);
|
||||
data.addNickname("s); DROP TABLE plan_users;--");
|
||||
db.saveUserData(data);
|
||||
assertTrue("Removed Users table.", db.getUserId(data2.getUuid().toString()) != -1);
|
||||
assertTrue("Removed Users table.", db.getUsersTable().getUserId(data2.getUuid().toString()) != -1);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -3,13 +3,13 @@
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package test.java.main.java.com.djrapitops.plan.utilities;
|
||||
package test.java.main.java.com.djrapitops.plan.utilities.analysis;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import main.java.com.djrapitops.plan.data.SessionData;
|
||||
import main.java.com.djrapitops.plan.utilities.AnalysisUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.AnalysisUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import static org.junit.Assert.*;
|
@ -3,13 +3,13 @@
|
||||
* To change this template file, choose Tools | Templates
|
||||
* and open the template in the editor.
|
||||
*/
|
||||
package test.java.main.java.com.djrapitops.plan.utilities;
|
||||
package test.java.main.java.com.djrapitops.plan.utilities.analysis;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import main.java.com.djrapitops.plan.utilities.MathUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.MathUtils;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Test;
|
||||
|
Loading…
Reference in New Issue
Block a user