mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2025-04-12 18:20:26 +08:00
3.5.0
This commit is contained in:
parent
e6b941e85d
commit
42035bfabb
@ -12,6 +12,7 @@
|
||||
</repository>
|
||||
</repositories>
|
||||
<dependencies>
|
||||
<!-- Spigot 1.12 built with Buildtools for Database classes.-->
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
|
@ -48,6 +48,8 @@ import main.java.com.djrapitops.plan.utilities.Check;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import com.djrapitops.javaplugin.task.ITask;
|
||||
import java.io.FileWriter;
|
||||
import java.io.PrintWriter;
|
||||
|
||||
/**
|
||||
* Javaplugin class that contains methods for starting the plugin, logging to
|
||||
@ -293,26 +295,31 @@ public class Plan extends RslPlugin<Plan> {
|
||||
Benchmark.stop("Enable: Schedule boot analysis task");
|
||||
}
|
||||
|
||||
private void initLocale() {
|
||||
String locale = Settings.LOCALE.toString().toUpperCase();
|
||||
/*// Used to write a new Locale file
|
||||
/**
|
||||
* Used to write a new Locale file in the plugin's datafolder.
|
||||
*/
|
||||
public void writeNewLocaleFile() {
|
||||
File genLocale = new File(getDataFolder(), "locale_EN.txt");
|
||||
try {
|
||||
genLocale.createNewFile();
|
||||
FileWriter fw = new FileWriter(genLocale, true);
|
||||
PrintWriter pw = new PrintWriter(fw);
|
||||
for (Phrase p : Phrase.values()) {
|
||||
pw.println(p.name()+" <> "+p.parse());
|
||||
pw.flush();
|
||||
for (Phrase p : Phrase.values()) {
|
||||
pw.println(p.name() + " <> " + p.parse());
|
||||
pw.flush();
|
||||
}
|
||||
pw.println("<<<<<<HTML>>>>>>");
|
||||
for (Html h : Html.values()) {
|
||||
pw.println(h.name()+" <> "+h.parse());
|
||||
pw.flush();
|
||||
for (Html h : Html.values()) {
|
||||
pw.println(h.name() + " <> " + h.parse());
|
||||
pw.flush();
|
||||
}
|
||||
} catch (IOException ex) {
|
||||
Logger.getLogger(Plan.class.getName()).log(Level.SEVERE, null, ex);
|
||||
}*/
|
||||
Log.toLog(this.getClass().getName(), ex);
|
||||
}
|
||||
}
|
||||
|
||||
private void initLocale() {
|
||||
String locale = Settings.LOCALE.toString().toUpperCase();
|
||||
Benchmark.start("Enable: Initializing locale");
|
||||
File localeFile = new File(getDataFolder(), "locale.txt");
|
||||
boolean skipLoc = false;
|
||||
@ -455,15 +462,15 @@ public class Plan extends RslPlugin<Plan> {
|
||||
* Plan and the instance is null.
|
||||
*/
|
||||
public static API getPlanAPI() throws IllegalStateException {
|
||||
Plan INSTANCE = getInstance();
|
||||
if (INSTANCE == null) {
|
||||
Plan instance = getInstance();
|
||||
if (instance == null) {
|
||||
throw new IllegalStateException("Plugin not enabled properly, Singleton instance is null.");
|
||||
}
|
||||
return INSTANCE.api;
|
||||
return instance.api;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get the plugin instance singleton.
|
||||
* Used to get the plugin-instance singleton.
|
||||
*
|
||||
* @return this object.
|
||||
*/
|
||||
|
@ -1,6 +1,5 @@
|
||||
package main.java.com.djrapitops.plan;
|
||||
|
||||
import main.java.com.djrapitops.plan.utilities.Benchmark;
|
||||
import org.bukkit.Server;
|
||||
|
||||
/**
|
||||
@ -20,13 +19,13 @@ public class ServerVariableHolder {
|
||||
*
|
||||
* @param server instance the plugin is running on.
|
||||
*/
|
||||
public ServerVariableHolder(Server server) {
|
||||
public ServerVariableHolder(Server server) {
|
||||
maxPlayers = server.getMaxPlayers();
|
||||
ip = server.getIp();
|
||||
ip = server.getIp();
|
||||
}
|
||||
|
||||
/**
|
||||
* Maximum amount of players defined in server.properties
|
||||
* Maximum amount of players defined in server.properties.
|
||||
*
|
||||
* @return number.
|
||||
*/
|
||||
@ -35,7 +34,7 @@ public class ServerVariableHolder {
|
||||
}
|
||||
|
||||
/**
|
||||
* Ip string in server.properties
|
||||
* Ip string in server.properties.
|
||||
*
|
||||
* @return the ip.
|
||||
*/
|
||||
|
@ -1,6 +1,5 @@
|
||||
package main.java.com.djrapitops.plan;
|
||||
|
||||
import com.djrapitops.javaplugin.utilities.Verify;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
|
@ -2,6 +2,7 @@ package main.java.com.djrapitops.plan.api;
|
||||
|
||||
import com.djrapitops.javaplugin.utilities.UUIDFetcher;
|
||||
import com.djrapitops.javaplugin.utilities.Verify;
|
||||
import com.djrapitops.javaplugin.utilities.player.IOfflinePlayer;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
@ -19,8 +20,6 @@ import main.java.com.djrapitops.plan.data.handling.info.HandlingInfo;
|
||||
import main.java.com.djrapitops.plan.ui.DataRequestHandler;
|
||||
import main.java.com.djrapitops.plan.ui.webserver.WebSocketServer;
|
||||
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
|
||||
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
/**
|
||||
* This class contains the API methods.
|
||||
@ -228,12 +227,14 @@ public class API {
|
||||
*
|
||||
* @param uuid UUID of the player.
|
||||
* @return Playername, eg "Rsl1122"
|
||||
* @throws NullPointerException If uuid is null.
|
||||
* @throws IllegalStateException If the player has not played on the server
|
||||
* before.
|
||||
*/
|
||||
public String getPlayerName(UUID uuid) throws IllegalStateException {
|
||||
OfflinePlayer offlinePlayer = getOfflinePlayer(uuid);
|
||||
if (offlinePlayer.hasPlayedBefore()) {
|
||||
public String getPlayerName(UUID uuid) throws IllegalStateException, NullPointerException {
|
||||
Verify.nullCheck(uuid);
|
||||
IOfflinePlayer offlinePlayer = Plan.getInstance().fetch().getOfflinePlayer(uuid);
|
||||
if (Verify.notNull(offlinePlayer)) {
|
||||
return offlinePlayer.getName();
|
||||
}
|
||||
throw new IllegalStateException("Player has not played on this server before.");
|
||||
|
@ -2,10 +2,9 @@ package main.java.com.djrapitops.plan.command;
|
||||
|
||||
import com.djrapitops.javaplugin.utilities.Verify;
|
||||
import java.util.UUID;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.Settings;
|
||||
import main.java.com.djrapitops.plan.utilities.uuid.UUIDUtility;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
/**
|
||||
* This class contains static methods used by the commands to check whether or
|
||||
@ -53,7 +52,6 @@ public class ConditionUtils {
|
||||
if (!Verify.notNull(uuid)) {
|
||||
return false;
|
||||
}
|
||||
OfflinePlayer p = Bukkit.getOfflinePlayer(uuid);
|
||||
return p.hasPlayedBefore();
|
||||
return Plan.getInstance().fetch().hasPlayedBefore(uuid);
|
||||
}
|
||||
}
|
||||
|
@ -19,7 +19,6 @@ import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.command.CommandException;
|
||||
import org.bukkit.entity.Player;
|
||||
import com.djrapitops.javaplugin.task.ITask;
|
||||
|
||||
/**
|
||||
* This subcommand is used to run the analysis and access the /server link.
|
||||
|
@ -14,7 +14,6 @@ import main.java.com.djrapitops.plan.data.cache.AnalysisCacheHandler;
|
||||
import main.java.com.djrapitops.plan.ui.TextUI;
|
||||
import main.java.com.djrapitops.plan.utilities.Check;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import com.djrapitops.javaplugin.task.ITask;
|
||||
|
||||
/**
|
||||
* This subcommand is used to run the analysis and to view some of the data in
|
||||
|
@ -6,16 +6,12 @@ import com.djrapitops.javaplugin.command.sender.ISender;
|
||||
import com.djrapitops.javaplugin.task.runnable.RslRunnable;
|
||||
import com.djrapitops.javaplugin.utilities.FormattingUtils;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import main.java.com.djrapitops.plan.Permissions;
|
||||
import main.java.com.djrapitops.plan.Phrase;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.utilities.Check;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
/**
|
||||
* This subcommand is used to search for a user, and to view all matches' data.
|
||||
@ -43,7 +39,7 @@ public class SearchCommand extends SubCommand {
|
||||
return true;
|
||||
}
|
||||
sender.sendMessage(Phrase.CMD_SEARCH_SEARCHING + "");
|
||||
|
||||
|
||||
runSearchTask(args, sender);
|
||||
return true;
|
||||
}
|
||||
@ -53,14 +49,12 @@ public class SearchCommand extends SubCommand {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
Set<OfflinePlayer> matches = MiscUtils.getMatchingDisplaynames(args[0]);
|
||||
sender.sendMessage(Phrase.CMD_SEARCH_HEADER + args[0] + " (" + matches.size() + ")");
|
||||
List<String> names = MiscUtils.getMatchingPlayerNames(args[0]);
|
||||
sender.sendMessage(Phrase.CMD_SEARCH_HEADER + args[0] + " (" + names.size() + ")");
|
||||
// Results
|
||||
if (matches.isEmpty()) {
|
||||
if (names.isEmpty()) {
|
||||
sender.sendMessage(Phrase.CMD_NO_RESULTS.parse(Arrays.toString(args)));
|
||||
} else {
|
||||
List<String> names = matches.stream().map(p -> p.getName()).collect(Collectors.toList());
|
||||
Collections.sort(names);
|
||||
sender.sendMessage(Phrase.CMD_MATCH + "" + FormattingUtils.collectionToStringNoBrackets(names));
|
||||
}
|
||||
sender.sendMessage(Phrase.CMD_FOOTER + "");
|
||||
|
@ -5,7 +5,7 @@ import com.djrapitops.javaplugin.command.SubCommand;
|
||||
import com.djrapitops.javaplugin.command.sender.ISender;
|
||||
import com.djrapitops.javaplugin.task.runnable.RslRunnable;
|
||||
import com.djrapitops.javaplugin.utilities.FormattingUtils;
|
||||
import java.util.Arrays;
|
||||
import com.djrapitops.javaplugin.utilities.player.Fetch;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.UUID;
|
||||
@ -16,7 +16,6 @@ import main.java.com.djrapitops.plan.Plan;
|
||||
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.Check;
|
||||
import static org.bukkit.Bukkit.getOfflinePlayers;
|
||||
|
||||
/**
|
||||
* This manage subcommand is used to import data from 3rd party plugins.
|
||||
@ -62,7 +61,7 @@ public class ManageImportCommand extends SubCommand {
|
||||
}
|
||||
|
||||
String[] importArguments = FormattingUtils.removeFirstArgument(args);
|
||||
|
||||
|
||||
final Importer importer = importPlugins.get(importFromPlugin);
|
||||
runImportTask(sender, importer, importArguments);
|
||||
return true;
|
||||
@ -74,7 +73,7 @@ public class ManageImportCommand extends SubCommand {
|
||||
public void run() {
|
||||
try {
|
||||
sender.sendMessage(Phrase.MANAGE_IMPORTING + "");
|
||||
List<UUID> uuids = Arrays.stream(getOfflinePlayers()).map(p -> p.getUniqueId()).collect(Collectors.toList());
|
||||
List<UUID> uuids = Fetch.getIOfflinePlayers().stream().map(p -> p.getUniqueId()).collect(Collectors.toList());
|
||||
if (importer.importData(uuids, importArguments)) {
|
||||
sender.sendMessage(Phrase.MANAGE_SUCCESS + "");
|
||||
} else {
|
||||
|
@ -6,7 +6,6 @@ import com.djrapitops.javaplugin.command.sender.ISender;
|
||||
import com.djrapitops.javaplugin.task.runnable.RslRunnable;
|
||||
import com.djrapitops.javaplugin.utilities.Verify;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
import java.util.UUID;
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.Permissions;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package main.java.com.djrapitops.plan.data;
|
||||
|
||||
import com.djrapitops.javaplugin.utilities.Verify;
|
||||
import java.util.ArrayList;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -17,48 +18,27 @@ import main.java.com.djrapitops.plan.utilities.analysis.Analysis;
|
||||
*/
|
||||
public class RawAnalysisData {
|
||||
|
||||
private long gmZero;
|
||||
private long gmOne;
|
||||
private long gmTwo;
|
||||
private long gmThree;
|
||||
private long totalLoginTimes;
|
||||
private long totalPlaytime;
|
||||
private int totalBanned;
|
||||
private int active;
|
||||
private int joinleaver;
|
||||
private int inactive;
|
||||
private long totalKills;
|
||||
private long totalMobKills;
|
||||
private long totalDeaths;
|
||||
private int ops;
|
||||
private List<Integer> ages;
|
||||
private Map<String, Long> latestLogins;
|
||||
private Map<String, Long> playtimes;
|
||||
private List<SessionData> sessiondata;
|
||||
private Map<UUID, List<SessionData>> sortedSessionData;
|
||||
private Map<String, Integer> commandUse;
|
||||
private Map<String, Integer> geolocations;
|
||||
private Map<String, String> geocodes;
|
||||
private List<Long> registered;
|
||||
private final Map<RawData, Long> longValues;
|
||||
private final Map<RawData, Integer> intValues;
|
||||
|
||||
private final List<Integer> ages;
|
||||
private final List<Long> registered;
|
||||
private final Map<String, Long> latestLogins;
|
||||
private final Map<String, Long> playtimes;
|
||||
private final List<SessionData> sessiondata;
|
||||
private final Map<UUID, List<SessionData>> sortedSessionData;
|
||||
private final Map<String, Integer> commandUse;
|
||||
private final Map<String, Integer> geolocations;
|
||||
private final Map<String, String> geocodes;
|
||||
|
||||
/**
|
||||
* Constructor for a new empty dataset.
|
||||
*/
|
||||
public RawAnalysisData() {
|
||||
gmZero = 0;
|
||||
gmOne = 0;
|
||||
gmTwo = 0;
|
||||
gmThree = 0;
|
||||
totalLoginTimes = 0;
|
||||
totalPlaytime = 0;
|
||||
totalBanned = 0;
|
||||
active = 0;
|
||||
joinleaver = 0;
|
||||
inactive = 0;
|
||||
totalKills = 0;
|
||||
totalMobKills = 0;
|
||||
totalDeaths = 0;
|
||||
ops = 0;
|
||||
longValues = new HashMap<>();
|
||||
intValues = new HashMap<>();
|
||||
placeDefaultValues();
|
||||
|
||||
ages = new ArrayList<>();
|
||||
latestLogins = new HashMap<>();
|
||||
playtimes = new HashMap<>();
|
||||
@ -70,6 +50,49 @@ public class RawAnalysisData {
|
||||
registered = new ArrayList<>();
|
||||
}
|
||||
|
||||
private void placeDefaultValues() {
|
||||
longValues.put(RawData.TIME_GM0, 0L);
|
||||
longValues.put(RawData.TIME_GM1, 0L);
|
||||
longValues.put(RawData.TIME_GM2, 0L);
|
||||
longValues.put(RawData.TIME_GM3, 0L);
|
||||
longValues.put(RawData.LOGINTIMES, 0L);
|
||||
longValues.put(RawData.PLAYTIME, 0L);
|
||||
longValues.put(RawData.KILLS, 0L);
|
||||
longValues.put(RawData.MOBKILLS, 0L);
|
||||
longValues.put(RawData.DEATHS, 0L);
|
||||
intValues.put(RawData.AMOUNT_ACTIVE, 0);
|
||||
intValues.put(RawData.AMOUNT_BANNED, 0);
|
||||
intValues.put(RawData.AMOUNT_INACTIVE, 0);
|
||||
intValues.put(RawData.AMOUNT_UNKNOWN, 0);
|
||||
intValues.put(RawData.AMOUNT_OPS, 0);
|
||||
}
|
||||
|
||||
public long getLong(RawData key) {
|
||||
return Verify.nullCheck(longValues.get(key));
|
||||
}
|
||||
|
||||
public int getInt(RawData key) {
|
||||
return Verify.nullCheck(intValues.get(key));
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
private void add(RawData key, long amount) {
|
||||
addTo(key, amount);
|
||||
}
|
||||
|
||||
public void addTo(RawData key, long amount) {
|
||||
Verify.nullCheck(key);
|
||||
Long l = longValues.get(key);
|
||||
Integer i = intValues.get(key);
|
||||
if (Verify.notNull(l)) {
|
||||
longValues.replace(key, l + amount);
|
||||
} else if (Verify.notNull(i)) {
|
||||
intValues.replace(key, i + (int) amount);
|
||||
} else {
|
||||
throw new IllegalArgumentException("Incorrect key: " + key.name());
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param country
|
||||
@ -114,230 +137,6 @@ public class RawAnalysisData {
|
||||
return geocodes;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param gmZero
|
||||
*/
|
||||
public void addToGmZero(long gmZero) {
|
||||
this.gmZero += gmZero;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param gmOne
|
||||
*/
|
||||
public void addToGmOne(long gmOne) {
|
||||
this.gmOne += gmOne;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param gmTwo
|
||||
*/
|
||||
public void addToGmTwo(long gmTwo) {
|
||||
this.gmTwo += gmTwo;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param gmThree
|
||||
*/
|
||||
public void addGmThree(long gmThree) {
|
||||
this.gmThree += gmThree;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param totalLoginTimes
|
||||
*/
|
||||
public void addTotalLoginTimes(long totalLoginTimes) {
|
||||
this.totalLoginTimes += totalLoginTimes;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param totalPlaytime
|
||||
*/
|
||||
public void addTotalPlaytime(long totalPlaytime) {
|
||||
this.totalPlaytime += totalPlaytime;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param totalBanned
|
||||
*/
|
||||
public void addTotalBanned(int totalBanned) {
|
||||
this.totalBanned += totalBanned;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param active
|
||||
*/
|
||||
public void addActive(int active) {
|
||||
this.active += active;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param joinleaver
|
||||
*/
|
||||
public void addJoinleaver(int joinleaver) {
|
||||
this.joinleaver += joinleaver;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param inactive
|
||||
*/
|
||||
public void addInactive(int inactive) {
|
||||
this.inactive += inactive;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param totalKills
|
||||
*/
|
||||
public void addTotalKills(long totalKills) {
|
||||
this.totalKills += totalKills;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param totalMobKills
|
||||
*/
|
||||
public void addTotalMobKills(long totalMobKills) {
|
||||
this.totalMobKills += totalMobKills;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param totalDeaths
|
||||
*/
|
||||
public void addTotalDeaths(long totalDeaths) {
|
||||
this.totalDeaths += totalDeaths;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @param ops
|
||||
*/
|
||||
public void addOps(int ops) {
|
||||
this.ops += ops;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public long getGmZero() {
|
||||
return gmZero;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public long getGmOne() {
|
||||
return gmOne;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public long getGmTwo() {
|
||||
return gmTwo;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public long getGmThree() {
|
||||
return gmThree;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public long getTotalLoginTimes() {
|
||||
return totalLoginTimes;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public long getTotalPlaytime() {
|
||||
return totalPlaytime;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getTotalBanned() {
|
||||
return totalBanned;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getActive() {
|
||||
return active;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getJoinleaver() {
|
||||
return joinleaver;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getInactive() {
|
||||
return inactive;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public long getTotalKills() {
|
||||
return totalKills;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public long getTotalMobKills() {
|
||||
return totalMobKills;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public long getTotalDeaths() {
|
||||
return totalDeaths;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getOps() {
|
||||
return ops;
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
@ -393,7 +192,7 @@ public class RawAnalysisData {
|
||||
* @param commandUse
|
||||
*/
|
||||
public void setCommandUse(Map<String, Integer> commandUse) {
|
||||
this.commandUse = commandUse;
|
||||
this.commandUse.putAll(commandUse);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -411,4 +210,5 @@ public class RawAnalysisData {
|
||||
public List<Long> getRegistered() {
|
||||
return registered;
|
||||
}
|
||||
|
||||
}
|
||||
|
27
Plan/src/main/java/com/djrapitops/plan/data/RawData.java
Normal file
27
Plan/src/main/java/com/djrapitops/plan/data/RawData.java
Normal file
@ -0,0 +1,27 @@
|
||||
/*
|
||||
* 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;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public enum RawData {
|
||||
TIME_GM0,
|
||||
TIME_GM1,
|
||||
TIME_GM2,
|
||||
TIME_GM3,
|
||||
LOGINTIMES,
|
||||
PLAYTIME,
|
||||
AMOUNT_BANNED,
|
||||
AMOUNT_ACTIVE,
|
||||
AMOUNT_INACTIVE,
|
||||
AMOUNT_UNKNOWN,
|
||||
KILLS,
|
||||
MOBKILLS,
|
||||
DEATHS,
|
||||
AMOUNT_OPS
|
||||
}
|
@ -1,6 +1,11 @@
|
||||
package main.java.com.djrapitops.plan.data;
|
||||
|
||||
import com.djrapitops.javaplugin.utilities.Verify;
|
||||
import com.djrapitops.javaplugin.utilities.player.BukkitOfflinePlayer;
|
||||
import com.djrapitops.javaplugin.utilities.player.BukkitPlayer;
|
||||
import com.djrapitops.javaplugin.utilities.player.Gamemode;
|
||||
import com.djrapitops.javaplugin.utilities.player.IOfflinePlayer;
|
||||
import com.djrapitops.javaplugin.utilities.player.IPlayer;
|
||||
import java.net.InetAddress;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
@ -15,8 +20,6 @@ import java.util.stream.Collectors;
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
* This class is used for storing information about a player during runtime.
|
||||
@ -29,7 +32,6 @@ public class UserData {
|
||||
private boolean clearAfterSave;
|
||||
|
||||
private UUID uuid;
|
||||
private Location location;
|
||||
private List<Location> locations;
|
||||
private Set<InetAddress> ips;
|
||||
private Set<String> nicknames;
|
||||
@ -40,8 +42,8 @@ public class UserData {
|
||||
private int loginTimes;
|
||||
private int timesKicked;
|
||||
private long lastGmSwapTime;
|
||||
private GameMode lastGamemode;
|
||||
private Map<GameMode, Long> gmTimes;
|
||||
private Gamemode lastGamemode;
|
||||
private Map<Gamemode, Long> gmTimes;
|
||||
private boolean isOp;
|
||||
private boolean isBanned;
|
||||
private DemographicsData demData;
|
||||
@ -56,6 +58,11 @@ public class UserData {
|
||||
private SessionData currentSession;
|
||||
private List<SessionData> sessions;
|
||||
|
||||
@Deprecated
|
||||
public UserData(UUID uuid, long reg, Location loc, boolean op, GameMode lastGM, DemographicsData demData, String name, boolean online) {
|
||||
this(uuid, reg, loc, op, Gamemode.wrap(lastGM), demData, name, online);
|
||||
}
|
||||
|
||||
/**
|
||||
* Creates a new UserData object with given values and default values.
|
||||
*
|
||||
@ -80,22 +87,21 @@ public class UserData {
|
||||
* @param name Name of the player.
|
||||
* @param online Is the player online?
|
||||
*/
|
||||
public UserData(UUID uuid, long reg, Location loc, boolean op, GameMode lastGM, DemographicsData demData, String name, boolean online) {
|
||||
public UserData(UUID uuid, long reg, Location loc, boolean op, Gamemode lastGM, DemographicsData demData, String name, boolean online) {
|
||||
accessing = 0;
|
||||
this.uuid = uuid;
|
||||
registered = reg;
|
||||
location = loc;
|
||||
isOp = op;
|
||||
locations = new ArrayList<>();
|
||||
nicknames = new HashSet<>();
|
||||
ips = new HashSet<>();
|
||||
gmTimes = new HashMap<>();
|
||||
long zero = 0;
|
||||
gmTimes.put(GameMode.SURVIVAL, zero);
|
||||
gmTimes.put(GameMode.CREATIVE, zero);
|
||||
gmTimes.put(GameMode.ADVENTURE, zero);
|
||||
gmTimes.put(Gamemode.SURVIVAL, zero);
|
||||
gmTimes.put(Gamemode.CREATIVE, zero);
|
||||
gmTimes.put(Gamemode.ADVENTURE, zero);
|
||||
try {
|
||||
gmTimes.put(GameMode.SPECTATOR, zero);
|
||||
gmTimes.put(Gamemode.SPECTATOR, zero);
|
||||
} catch (NoSuchFieldError e) {
|
||||
}
|
||||
lastGamemode = lastGM;
|
||||
@ -124,8 +130,12 @@ public class UserData {
|
||||
* @param player Player object.
|
||||
* @param demData Demographics data.
|
||||
*/
|
||||
public UserData(Player player, DemographicsData demData) {
|
||||
this(player.getUniqueId(), player.getFirstPlayed(), player.getLocation(), player.isOp(), player.getGameMode(), demData, player.getName(), player.isOnline());
|
||||
public UserData(org.bukkit.entity.Player player, DemographicsData demData) {
|
||||
this(BukkitPlayer.wrap(player), demData);
|
||||
}
|
||||
|
||||
public UserData(IPlayer player, DemographicsData demData) {
|
||||
this(player.getUuid(), player.getFirstPlayed(), null, player.isOp(), player.getGamemode(), demData, player.getName(), player.isOnline());
|
||||
try {
|
||||
isBanned = player.isBanned();
|
||||
} catch (Exception e) {
|
||||
@ -156,8 +166,13 @@ public class UserData {
|
||||
* @param player OfflinePlayer object.
|
||||
* @param demData Demographics data.
|
||||
*/
|
||||
public UserData(OfflinePlayer player, DemographicsData demData) {
|
||||
this(player.getUniqueId(), player.getFirstPlayed(), null, player.isOp(), GameMode.SURVIVAL, demData, player.getName(), player.isOnline());
|
||||
@Deprecated
|
||||
public UserData(org.bukkit.OfflinePlayer player, DemographicsData demData) {
|
||||
this(BukkitOfflinePlayer.wrap(player), demData);
|
||||
}
|
||||
|
||||
public UserData(IOfflinePlayer player, DemographicsData demData) {
|
||||
this(player.getUniqueId(), player.getFirstPlayed(), null, player.isOp(), Gamemode.SURVIVAL, demData, player.getName(), player.isOnline());
|
||||
try {
|
||||
isBanned = player.isBanned();
|
||||
} catch (Exception e) {
|
||||
@ -175,7 +190,6 @@ public class UserData {
|
||||
public UserData(UserData data) {
|
||||
this.accessing = 0;
|
||||
this.uuid = data.getUuid();
|
||||
this.location = data.getLocation();
|
||||
this.locations = new ArrayList<>();
|
||||
locations.addAll(data.getLocations());
|
||||
this.ips = new HashSet<>();
|
||||
@ -211,7 +225,7 @@ public class UserData {
|
||||
@Override
|
||||
public String toString() {
|
||||
try {
|
||||
return "{" + "accessing:" + accessing + "|uuid:" + uuid + "|location:" + location + "|locations:" + locations.size() + "|ips:" + ips + "|nicknames:" + nicknames + "|lastNick:" + lastNick + "|registered:" + registered + "|lastPlayed:" + lastPlayed + "|playTime:" + playTime + "|loginTimes:" + loginTimes + "|timesKicked:" + timesKicked + "|lastGmSwapTime:" + lastGmSwapTime + "|lastGamemode:" + lastGamemode + "|gmTimes:" + gmTimes + "|isOp:" + isOp + "|isBanned:" + isBanned + "|demData:" + demData + "|mobKills:" + mobKills + "|playerKills:" + playerKills + "|deaths:" + deaths + "|name:" + name + "|isOnline:" + isOnline + "|currentSession:" + currentSession + "|sessions:" + sessions + '}';
|
||||
return "{" + "accessing:" + accessing + "|uuid:" + uuid + "|locations:" + locations.size() + "|ips:" + ips + "|nicknames:" + nicknames + "|lastNick:" + lastNick + "|registered:" + registered + "|lastPlayed:" + lastPlayed + "|playTime:" + playTime + "|loginTimes:" + loginTimes + "|timesKicked:" + timesKicked + "|lastGmSwapTime:" + lastGmSwapTime + "|lastGamemode:" + lastGamemode + "|gmTimes:" + gmTimes + "|isOp:" + isOp + "|isBanned:" + isBanned + "|demData:" + demData + "|mobKills:" + mobKills + "|playerKills:" + playerKills + "|deaths:" + deaths + "|name:" + name + "|isOnline:" + isOnline + "|currentSession:" + currentSession + "|sessions:" + sessions + '}';
|
||||
} catch (Throwable e) {
|
||||
return "UserData: Error on toString:" + e;
|
||||
}
|
||||
@ -244,14 +258,13 @@ public class UserData {
|
||||
/**
|
||||
* Adds a location to the locations list.
|
||||
*
|
||||
* null value filtered. loc will be set as the latest location.
|
||||
* null value filtered.
|
||||
*
|
||||
* @param loc Location of the player.
|
||||
*/
|
||||
public void addLocation(Location loc) {
|
||||
if (Verify.notNull(loc)) {
|
||||
locations.add(loc);
|
||||
location = loc;
|
||||
}
|
||||
}
|
||||
|
||||
@ -266,7 +279,6 @@ public class UserData {
|
||||
if (!addLocs.isEmpty()) {
|
||||
List<Location> locs = addLocs.stream().filter(l -> l != null).collect(Collectors.toList());
|
||||
locations.addAll(locs);
|
||||
location = locations.get(locations.size() - 1);
|
||||
}
|
||||
}
|
||||
|
||||
@ -309,7 +321,7 @@ public class UserData {
|
||||
* @param gm GameMode.
|
||||
* @param time Milliseconds spent in the gamemode.
|
||||
*/
|
||||
public void setGMTime(GameMode gm, long time) {
|
||||
public void setGMTime(Gamemode gm, long time) {
|
||||
if (!Verify.notNull(gmTimes)) {
|
||||
gmTimes = new HashMap<>();
|
||||
}
|
||||
@ -328,11 +340,11 @@ public class UserData {
|
||||
*/
|
||||
public void setAllGMTimes(long survivalTime, long creativeTime, long adventureTime, long spectatorTime) {
|
||||
gmTimes.clear();
|
||||
gmTimes.put(GameMode.SURVIVAL, survivalTime);
|
||||
gmTimes.put(GameMode.CREATIVE, creativeTime);
|
||||
gmTimes.put(GameMode.ADVENTURE, adventureTime);
|
||||
gmTimes.put(Gamemode.SURVIVAL, survivalTime);
|
||||
gmTimes.put(Gamemode.CREATIVE, creativeTime);
|
||||
gmTimes.put(Gamemode.ADVENTURE, adventureTime);
|
||||
try {
|
||||
gmTimes.put(GameMode.SPECTATOR, spectatorTime);
|
||||
gmTimes.put(Gamemode.SPECTATOR, spectatorTime);
|
||||
} catch (NoSuchFieldError e) {
|
||||
}
|
||||
}
|
||||
@ -432,17 +444,6 @@ public class UserData {
|
||||
return uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to get the latest location.
|
||||
*
|
||||
* NOT INITIALIZED BY CONSTRUCTORS
|
||||
*
|
||||
* @return Location.
|
||||
*/
|
||||
public Location getLocation() {
|
||||
return location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Get the list of all locations inside the UserData object.
|
||||
*
|
||||
@ -531,7 +532,7 @@ public class UserData {
|
||||
* @return a GameMode map with 4 keys: SURVIVAL, CREATIVE, ADVENTURE,
|
||||
* SPECTATOR.
|
||||
*/
|
||||
public Map<GameMode, Long> getGmTimes() {
|
||||
public Map<Gamemode, Long> getGmTimes() {
|
||||
if (gmTimes == null) {
|
||||
gmTimes = new HashMap<>();
|
||||
}
|
||||
@ -554,7 +555,7 @@ public class UserData {
|
||||
*
|
||||
* @return Gamemode.
|
||||
*/
|
||||
public GameMode getLastGamemode() {
|
||||
public Gamemode getLastGamemode() {
|
||||
return lastGamemode;
|
||||
}
|
||||
|
||||
@ -603,17 +604,6 @@ public class UserData {
|
||||
this.uuid = uuid;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the current location.
|
||||
*
|
||||
* Not in use.
|
||||
*
|
||||
* @param location a location in the world.
|
||||
*/
|
||||
public void setLocation(Location location) {
|
||||
this.location = location;
|
||||
}
|
||||
|
||||
/**
|
||||
* Set the list of locations the user has been in.
|
||||
*
|
||||
@ -707,7 +697,7 @@ public class UserData {
|
||||
* @param gmTimes Map containing SURVIVAL, CREATIVE, ADVENTURE and SPECTATOR
|
||||
* (After 1.8) keys.
|
||||
*/
|
||||
public void setGmTimes(Map<GameMode, Long> gmTimes) {
|
||||
public void setGmTimes(Map<Gamemode, Long> gmTimes) {
|
||||
if (Verify.notNull(gmTimes)) {
|
||||
this.gmTimes = gmTimes;
|
||||
}
|
||||
@ -727,7 +717,7 @@ public class UserData {
|
||||
*
|
||||
* @param lastGamemode gamemode.
|
||||
*/
|
||||
public void setLastGamemode(GameMode lastGamemode) {
|
||||
public void setLastGamemode(Gamemode lastGamemode) {
|
||||
this.lastGamemode = lastGamemode;
|
||||
}
|
||||
|
||||
|
@ -4,7 +4,6 @@ import com.djrapitops.javaplugin.task.runnable.RslRunnable;
|
||||
import com.djrapitops.javaplugin.utilities.Verify;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
@ -25,19 +24,16 @@ import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.NewPlayerCreator;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.MathUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.comparators.HandlingInfoTimeComparator;
|
||||
import org.bukkit.Bukkit;
|
||||
import static org.bukkit.Bukkit.getPlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import com.djrapitops.javaplugin.task.ITask;
|
||||
import static org.bukkit.Bukkit.getPlayer;
|
||||
import com.djrapitops.javaplugin.utilities.player.IPlayer;
|
||||
|
||||
/**
|
||||
* This Class contains the Cache.
|
||||
*
|
||||
* This class is the main processing class that initializes Save, Clear, Process
|
||||
* This class is the main processing class that initialises Save, Clear, Process
|
||||
* and Get queue and Starts the asyncronous save task.
|
||||
*
|
||||
* It is used to store commanduse, locations, active sessions and UserData
|
||||
* It is used to store command use, locations, active sessions and UserData
|
||||
* objects in memory.
|
||||
*
|
||||
* It's methods can be used to access all the data it stores and to clear them.
|
||||
@ -270,15 +266,15 @@ public class DataCacheHandler extends LocationCache {
|
||||
List<HandlingInfo> toProcess = processTask.stopAndReturnLeftovers();
|
||||
Benchmark.start("ProcessOnlineHandlingInfo");
|
||||
Log.debug("ToProcess size: " + toProcess.size() + " DataCache size: " + dataCache.keySet().size());
|
||||
Collection<? extends Player> onlinePlayers = Bukkit.getOnlinePlayers();
|
||||
List<IPlayer> onlinePlayers = plugin.fetch().getOnlinePlayers();
|
||||
Log.debug("Online: " + onlinePlayers.size());
|
||||
for (Player p : onlinePlayers) {
|
||||
UUID uuid = p.getUniqueId();
|
||||
for (IPlayer p : onlinePlayers) {
|
||||
UUID uuid = p.getUuid();
|
||||
endSession(uuid);
|
||||
if (dataCache.containsKey(uuid)) {
|
||||
dataCache.get(uuid).addLocations(getLocationsForSaving(uuid));
|
||||
}
|
||||
toProcess.add(new LogoutInfo(uuid, time, p.isBanned(), p.getGameMode(), getSession(uuid)));
|
||||
toProcess.add(new LogoutInfo(uuid, time, p.isBanned(), p.getGamemode(), getSession(uuid)));
|
||||
}
|
||||
Log.debug("ToProcess size_AFTER: " + toProcess.size() + " DataCache size: " + dataCache.keySet().size());
|
||||
Collections.sort(toProcess, new HandlingInfoTimeComparator());
|
||||
@ -390,15 +386,16 @@ public class DataCacheHandler extends LocationCache {
|
||||
* Refreshes the calculations for all online players with ReloadInfo.
|
||||
*/
|
||||
public void saveHandlerDataToCache() {
|
||||
Bukkit.getServer().getOnlinePlayers().stream().forEach((p) -> {
|
||||
final List<IPlayer> onlinePlayers = plugin.fetch().getOnlinePlayers();
|
||||
onlinePlayers.stream().forEach((p) -> {
|
||||
saveHandlerDataToCache(p, false);
|
||||
});
|
||||
}
|
||||
|
||||
private void saveHandlerDataToCache(Player player, boolean pool) {
|
||||
private void saveHandlerDataToCache(IPlayer player, boolean pool) {
|
||||
long time = MiscUtils.getTime();
|
||||
UUID uuid = player.getUniqueId();
|
||||
ReloadInfo info = new ReloadInfo(uuid, time, player.getAddress().getAddress(), player.isBanned(), player.getDisplayName(), player.getGameMode());
|
||||
UUID uuid = player.getUuid();
|
||||
ReloadInfo info = new ReloadInfo(uuid, time, player.getAddress().getAddress(), player.isBanned(), player.getDisplayName(), player.getGamemode());
|
||||
if (!pool) {
|
||||
UserData data = dataCache.get(uuid);
|
||||
if (data != null) {
|
||||
@ -423,7 +420,7 @@ public class DataCacheHandler extends LocationCache {
|
||||
*/
|
||||
public void clearFromCache(UUID uuid) {
|
||||
Log.debug(uuid + ": Clear");
|
||||
if (Verify.notNull(getPlayer(uuid))) {
|
||||
if (Verify.notNull(plugin.fetch().getPlayer(uuid))) {
|
||||
Log.debug(uuid + ": Online, did not clear");
|
||||
UserData data = dataCache.get(uuid);
|
||||
if (data != null) {
|
||||
@ -468,7 +465,7 @@ public class DataCacheHandler extends LocationCache {
|
||||
*
|
||||
* @param player Player the new UserData is created for
|
||||
*/
|
||||
public void newPlayer(Player player) {
|
||||
public void newPlayer(IPlayer player) {
|
||||
newPlayer(NewPlayerCreator.createNewPlayer(player));
|
||||
}
|
||||
|
||||
@ -509,8 +506,9 @@ public class DataCacheHandler extends LocationCache {
|
||||
ITask asyncReloadCacheUpdateTask = plugin.getRunnableFactory().createNew(new RslRunnable("ReloadCacheUpdateTask") {
|
||||
@Override
|
||||
public void run() {
|
||||
for (Player player : Bukkit.getOnlinePlayers()) {
|
||||
UUID uuid = player.getUniqueId();
|
||||
final List<IPlayer> onlinePlayers = plugin.fetch().getOnlinePlayers();
|
||||
for (IPlayer player : onlinePlayers) {
|
||||
UUID uuid = player.getUuid();
|
||||
boolean isNewPlayer = !db.wasSeenBefore(uuid);
|
||||
if (isNewPlayer) {
|
||||
newPlayer(player);
|
||||
|
@ -1,8 +1,8 @@
|
||||
package main.java.com.djrapitops.plan.data.handling;
|
||||
|
||||
import com.djrapitops.javaplugin.utilities.player.Gamemode;
|
||||
import java.util.Map;
|
||||
import main.java.com.djrapitops.plan.data.UserData;
|
||||
import org.bukkit.GameMode;
|
||||
|
||||
/**
|
||||
* Class containing static methods for processing information contained in a
|
||||
@ -21,17 +21,17 @@ public class GamemodeHandling {
|
||||
* @param time Epoch ms the event occurred.
|
||||
* @param newGM The Gamemode the player changed to.
|
||||
*/
|
||||
public static void processGamemodeInfo(UserData data, long time, GameMode newGM) {
|
||||
public static void processGamemodeInfo(UserData data, long time, Gamemode newGM) {
|
||||
if (newGM == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
GameMode lastGamemode = data.getLastGamemode();
|
||||
Gamemode lastGamemode = data.getLastGamemode();
|
||||
if (lastGamemode == null) {
|
||||
data.setLastGamemode(newGM);
|
||||
}
|
||||
lastGamemode = data.getLastGamemode();
|
||||
Map<GameMode, Long> times = data.getGmTimes();
|
||||
Map<Gamemode, Long> times = data.getGmTimes();
|
||||
Long currentGMTime = times.get(lastGamemode);
|
||||
if (currentGMTime == null) {
|
||||
currentGMTime = 0L;
|
||||
|
@ -1,8 +1,9 @@
|
||||
package main.java.com.djrapitops.plan.data.handling.importing;
|
||||
|
||||
import com.djrapitops.javaplugin.utilities.player.IOfflinePlayer;
|
||||
import com.djrapitops.javaplugin.utilities.player.Fetch;
|
||||
import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
@ -19,8 +20,6 @@ import main.java.com.djrapitops.plan.data.handling.info.InfoType;
|
||||
import main.java.com.djrapitops.plan.database.Database;
|
||||
import main.java.com.djrapitops.plan.utilities.Benchmark;
|
||||
import main.java.com.djrapitops.plan.utilities.NewPlayerCreator;
|
||||
import static org.bukkit.Bukkit.getOfflinePlayers;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
/**
|
||||
* Abstract class used for importing data from other plugins.
|
||||
@ -79,13 +78,13 @@ public abstract class Importer {
|
||||
unSaved.removeAll(saved);
|
||||
String createUserObjects = "Creating new UserData objects for: " + unSaved.size();
|
||||
plan.processStatus().setStatus(processName, createUserObjects);
|
||||
Map<UUID, OfflinePlayer> offlinePlayers = Arrays.stream(getOfflinePlayers()).collect(Collectors.toMap(OfflinePlayer::getUniqueId, Function.identity()));
|
||||
Map<UUID, IOfflinePlayer> offlinePlayers = Fetch.getIOfflinePlayers().stream().collect(Collectors.toMap(IOfflinePlayer::getUuid, Function.identity()));
|
||||
Benchmark.start(createUserObjects);
|
||||
List<OfflinePlayer> offlineP = unSaved.stream().map(uuid
|
||||
List<IOfflinePlayer> offlineP = unSaved.stream().map(uuid
|
||||
-> offlinePlayers.get(uuid)).collect(Collectors.toList());
|
||||
List<UserData> newUsers = new ArrayList<>();
|
||||
for (OfflinePlayer p : offlineP) {
|
||||
UserData newPlayer = NewPlayerCreator.createNewPlayer(p);
|
||||
for (IOfflinePlayer p : offlineP) {
|
||||
UserData newPlayer = NewPlayerCreator.createNewOfflinePlayer(p);
|
||||
newPlayer.setLastPlayed(newPlayer.getRegistered());
|
||||
newUsers.add(newPlayer);
|
||||
plan.processStatus().setStatus(processName, "Creating new UserData objects: " + newUsers.size() + "/" + unSaved.size());
|
||||
|
@ -1,9 +1,9 @@
|
||||
package main.java.com.djrapitops.plan.data.handling.info;
|
||||
|
||||
import com.djrapitops.javaplugin.utilities.player.Gamemode;
|
||||
import java.util.UUID;
|
||||
import main.java.com.djrapitops.plan.data.UserData;
|
||||
import main.java.com.djrapitops.plan.data.handling.GamemodeHandling;
|
||||
import org.bukkit.GameMode;
|
||||
|
||||
/**
|
||||
* HandlingInfo Class for GamemodeChangeEvent information.
|
||||
@ -13,7 +13,7 @@ import org.bukkit.GameMode;
|
||||
*/
|
||||
public class GamemodeInfo extends HandlingInfo {
|
||||
|
||||
private GameMode currentGamemode;
|
||||
private final Gamemode currentGamemode;
|
||||
|
||||
/**
|
||||
* Constructor.
|
||||
@ -22,7 +22,7 @@ public class GamemodeInfo extends HandlingInfo {
|
||||
* @param time Epoch ms of the event.
|
||||
* @param gm Gamemode the player changed to.
|
||||
*/
|
||||
public GamemodeInfo(UUID uuid, long time, GameMode gm) {
|
||||
public GamemodeInfo(UUID uuid, long time, Gamemode gm) {
|
||||
super(uuid, InfoType.GM, time);
|
||||
currentGamemode = gm;
|
||||
}
|
||||
|
@ -1,10 +1,10 @@
|
||||
package main.java.com.djrapitops.plan.data.handling.info;
|
||||
|
||||
import com.djrapitops.javaplugin.utilities.player.Gamemode;
|
||||
import java.net.InetAddress;
|
||||
import java.util.UUID;
|
||||
import main.java.com.djrapitops.plan.data.UserData;
|
||||
import main.java.com.djrapitops.plan.data.handling.LoginHandling;
|
||||
import org.bukkit.GameMode;
|
||||
|
||||
/**
|
||||
* HandlingInfo Class for JoinEvent information.
|
||||
@ -31,7 +31,7 @@ public class LoginInfo extends HandlingInfo {
|
||||
* @param gm current gamemode of the player
|
||||
* @param loginTimes number the loginTimes should be incremented with.
|
||||
*/
|
||||
public LoginInfo(UUID uuid, long time, InetAddress ip, boolean banned, String nickname, GameMode gm, int loginTimes) {
|
||||
public LoginInfo(UUID uuid, long time, InetAddress ip, boolean banned, String nickname, Gamemode gm, int loginTimes) {
|
||||
super(uuid, InfoType.LOGIN, time);
|
||||
this.ip = ip;
|
||||
this.banned = banned;
|
||||
@ -50,7 +50,7 @@ public class LoginInfo extends HandlingInfo {
|
||||
* @param nickname Nickname of the player
|
||||
* @param gm current gamemode of the player
|
||||
*/
|
||||
public LoginInfo(UUID uuid, long time, InetAddress ip, boolean banned, String nickname, GameMode gm) {
|
||||
public LoginInfo(UUID uuid, long time, InetAddress ip, boolean banned, String nickname, Gamemode gm) {
|
||||
this(uuid, time, ip, banned, nickname, gm, 0);
|
||||
}
|
||||
|
||||
|
@ -1,10 +1,10 @@
|
||||
package main.java.com.djrapitops.plan.data.handling.info;
|
||||
|
||||
import com.djrapitops.javaplugin.utilities.player.Gamemode;
|
||||
import java.util.UUID;
|
||||
import main.java.com.djrapitops.plan.data.SessionData;
|
||||
import main.java.com.djrapitops.plan.data.UserData;
|
||||
import main.java.com.djrapitops.plan.data.handling.LogoutHandling;
|
||||
import org.bukkit.GameMode;
|
||||
|
||||
/**
|
||||
* HandlingInfo Class for QuitEvent information.
|
||||
@ -28,7 +28,7 @@ public class LogoutInfo extends HandlingInfo {
|
||||
* @param sData session that has been ended at the moment of the logout
|
||||
* event.
|
||||
*/
|
||||
public LogoutInfo(UUID uuid, long time, boolean banned, GameMode gm, SessionData sData) {
|
||||
public LogoutInfo(UUID uuid, long time, boolean banned, Gamemode gm, SessionData sData) {
|
||||
super(uuid, InfoType.LOGOUT, time);
|
||||
this.banned = banned;
|
||||
this.sData = sData;
|
||||
|
@ -1,10 +1,10 @@
|
||||
package main.java.com.djrapitops.plan.data.handling.info;
|
||||
|
||||
import com.djrapitops.javaplugin.utilities.player.Gamemode;
|
||||
import java.net.InetAddress;
|
||||
import java.util.UUID;
|
||||
import main.java.com.djrapitops.plan.data.UserData;
|
||||
import main.java.com.djrapitops.plan.data.handling.LoginHandling;
|
||||
import org.bukkit.GameMode;
|
||||
|
||||
/**
|
||||
* HandlingInfo Class for refreshing data in the cache for online players.
|
||||
@ -29,7 +29,7 @@ public class ReloadInfo extends HandlingInfo {
|
||||
* @param nickname Nickname of the player
|
||||
* @param gm current gamemode of the player
|
||||
*/
|
||||
public ReloadInfo(UUID uuid, long time, InetAddress ip, boolean banned, String nickname, GameMode gm) {
|
||||
public ReloadInfo(UUID uuid, long time, InetAddress ip, boolean banned, String nickname, Gamemode gm) {
|
||||
super(uuid, InfoType.RELOAD, time);
|
||||
this.ip = ip;
|
||||
this.banned = banned;
|
||||
|
@ -1,5 +1,6 @@
|
||||
package main.java.com.djrapitops.plan.data.listeners;
|
||||
|
||||
import com.djrapitops.javaplugin.utilities.player.Gamemode;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.data.cache.DataCacheHandler;
|
||||
import main.java.com.djrapitops.plan.data.handling.info.GamemodeInfo;
|
||||
@ -42,6 +43,6 @@ public class PlanGamemodeChangeListener implements Listener {
|
||||
return;
|
||||
}
|
||||
Player p = event.getPlayer();
|
||||
handler.addToPool(new GamemodeInfo(p.getUniqueId(), MiscUtils.getTime(), event.getNewGameMode()));
|
||||
handler.addToPool(new GamemodeInfo(p.getUniqueId(), MiscUtils.getTime(), Gamemode.wrap(event.getNewGameMode())));
|
||||
}
|
||||
}
|
||||
|
@ -19,6 +19,8 @@ import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerKickEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import com.djrapitops.javaplugin.task.ITask;
|
||||
import com.djrapitops.javaplugin.utilities.player.BukkitPlayer;
|
||||
import com.djrapitops.javaplugin.utilities.player.Gamemode;
|
||||
|
||||
/**
|
||||
* Event Listener for PlayerJoin, PlayerQuit and PlayerKickEvents.
|
||||
@ -60,10 +62,10 @@ public class PlanPlayerListener implements Listener {
|
||||
ITask asyncNewPlayerCheckTask = plugin.getRunnableFactory().createNew(new RslRunnable("NewPlayerCheckTask") {
|
||||
@Override
|
||||
public void run() {
|
||||
LoginInfo loginInfo = new LoginInfo(uuid, MiscUtils.getTime(), player.getAddress().getAddress(), player.isBanned(), player.getDisplayName(), player.getGameMode(), 1);
|
||||
LoginInfo loginInfo = new LoginInfo(uuid, MiscUtils.getTime(), player.getAddress().getAddress(), player.isBanned(), player.getDisplayName(), Gamemode.wrap(player.getGameMode()), 1);
|
||||
boolean isNewPlayer = !plugin.getDB().wasSeenBefore(uuid);
|
||||
if (isNewPlayer) {
|
||||
UserData newUserData = NewPlayerCreator.createNewPlayer(player);
|
||||
UserData newUserData = NewPlayerCreator.createNewPlayer(BukkitPlayer.wrap(player));
|
||||
loginInfo.process(newUserData);
|
||||
handler.newPlayer(newUserData);
|
||||
} else {
|
||||
@ -90,7 +92,7 @@ public class PlanPlayerListener implements Listener {
|
||||
UUID uuid = player.getUniqueId();
|
||||
handler.endSession(uuid);
|
||||
Log.debug(uuid + ": PlayerQuitEvent");
|
||||
handler.addToPool(new LogoutInfo(uuid, MiscUtils.getTime(), player.isBanned(), player.getGameMode(), handler.getSession(uuid)));
|
||||
handler.addToPool(new LogoutInfo(uuid, MiscUtils.getTime(), player.isBanned(), Gamemode.wrap(player.getGameMode()), handler.getSession(uuid)));
|
||||
handler.saveCachedData(uuid);
|
||||
Log.debug(uuid + ": PlayerQuitEvent_END");
|
||||
}
|
||||
@ -110,7 +112,7 @@ public class PlanPlayerListener implements Listener {
|
||||
Player player = event.getPlayer();
|
||||
UUID uuid = player.getUniqueId();
|
||||
handler.endSession(uuid);
|
||||
handler.addToPool(new LogoutInfo(uuid, MiscUtils.getTime(), player.isBanned(), player.getGameMode(), handler.getSession(uuid)));
|
||||
handler.addToPool(new LogoutInfo(uuid, MiscUtils.getTime(), player.isBanned(), Gamemode.wrap(player.getGameMode()), handler.getSession(uuid)));
|
||||
handler.addToPool(new KickInfo(uuid));
|
||||
handler.saveCachedData(uuid);
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package main.java.com.djrapitops.plan.database.databases;
|
||||
|
||||
import com.djrapitops.javaplugin.task.runnable.RslRunnable;
|
||||
import com.djrapitops.javaplugin.utilities.player.Gamemode;
|
||||
import java.net.InetAddress;
|
||||
import java.sql.Connection;
|
||||
import java.sql.SQLException;
|
||||
@ -22,7 +23,6 @@ import main.java.com.djrapitops.plan.database.Database;
|
||||
import main.java.com.djrapitops.plan.database.tables.*;
|
||||
import main.java.com.djrapitops.plan.utilities.Benchmark;
|
||||
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
|
||||
/**
|
||||
@ -325,7 +325,7 @@ public abstract class SQLDB extends Database {
|
||||
List<InetAddress> ips = ipsTable.getIPAddresses(userId);
|
||||
data.addIpAddresses(ips);
|
||||
|
||||
Map<GameMode, Long> times = gmTimesTable.getGMTimes(userId);
|
||||
Map<Gamemode, Long> times = gmTimesTable.getGMTimes(userId);
|
||||
data.setGmTimes(times);
|
||||
List<SessionData> sessions = sessionsTable.getSessionData(userId);
|
||||
data.addSessions(sessions);
|
||||
@ -370,7 +370,7 @@ public abstract class SQLDB extends Database {
|
||||
Map<Integer, Set<InetAddress>> ipList = ipsTable.getIPList(ids);
|
||||
Map<Integer, List<KillData>> playerKills = killsTable.getPlayerKills(ids, idUuidRel);
|
||||
Map<Integer, List<SessionData>> sessionData = sessionsTable.getSessionData(ids);
|
||||
Map<Integer, Map<GameMode, Long>> gmTimes = gmTimesTable.getGMTimes(ids);
|
||||
Map<Integer, Map<Gamemode, Long>> gmTimes = gmTimesTable.getGMTimes(ids);
|
||||
Log.debug("Sizes: UUID:" + uuids.size() + " DATA:" + data.size() + " ID:" + userIds.size() + " N:" + nicknames.size() + " I:" + ipList.size() + " K:" + playerKills.size() + " S:" + sessionData.size());
|
||||
for (UserData uData : data) {
|
||||
UUID uuid = uData.getUuid();
|
||||
@ -412,7 +412,7 @@ public abstract class SQLDB extends Database {
|
||||
Map<Integer, List<KillData>> kills = new HashMap<>();
|
||||
Map<Integer, UUID> uuids = userIds.entrySet().stream().collect(Collectors.toMap(Map.Entry::getValue, Map.Entry::getKey));
|
||||
Map<Integer, List<SessionData>> sessions = new HashMap<>();
|
||||
Map<Integer, Map<GameMode, Long>> gmTimes = new HashMap<>();
|
||||
Map<Integer, Map<Gamemode, Long>> gmTimes = new HashMap<>();
|
||||
// Put to dataset
|
||||
for (UUID uuid : userDatas.keySet()) {
|
||||
Integer id = userIds.get(uuid);
|
||||
|
@ -1,5 +1,6 @@
|
||||
package main.java.com.djrapitops.plan.database.tables;
|
||||
|
||||
import com.djrapitops.javaplugin.utilities.player.Gamemode;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@ -11,7 +12,6 @@ import java.util.Set;
|
||||
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;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -89,20 +89,20 @@ public class GMTimesTable extends Table {
|
||||
* @return
|
||||
* @throws SQLException
|
||||
*/
|
||||
public Map<GameMode, Long> getGMTimes(int userId) throws SQLException {
|
||||
public Map<Gamemode, Long> getGMTimes(int userId) throws SQLException {
|
||||
PreparedStatement statement = null;
|
||||
ResultSet set = null;
|
||||
try {
|
||||
statement = prepareStatement("SELECT * FROM " + tableName + " WHERE (" + columnUserID + "=?)");
|
||||
statement.setInt(1, userId);
|
||||
set = statement.executeQuery();
|
||||
HashMap<GameMode, Long> times = new HashMap<>();
|
||||
HashMap<Gamemode, Long> times = new HashMap<>();
|
||||
while (set.next()) {
|
||||
times.put(GameMode.SURVIVAL, set.getLong(columnSurvivalTime));
|
||||
times.put(GameMode.CREATIVE, set.getLong(columnCreativeTime));
|
||||
times.put(GameMode.ADVENTURE, set.getLong(columnAdventureTime));
|
||||
times.put(Gamemode.SURVIVAL, set.getLong(columnSurvivalTime));
|
||||
times.put(Gamemode.CREATIVE, set.getLong(columnCreativeTime));
|
||||
times.put(Gamemode.ADVENTURE, set.getLong(columnAdventureTime));
|
||||
try {
|
||||
times.put(GameMode.SPECTATOR, set.getLong(columnSpectatorTime));
|
||||
times.put(Gamemode.SPECTATOR, set.getLong(columnSpectatorTime));
|
||||
} catch (NoSuchFieldError e) {
|
||||
}
|
||||
}
|
||||
@ -113,24 +113,24 @@ public class GMTimesTable extends Table {
|
||||
}
|
||||
}
|
||||
|
||||
public Map<Integer, Map<GameMode, Long>> getGMTimes(Collection<Integer> userIds) throws SQLException {
|
||||
public Map<Integer, Map<Gamemode, Long>> getGMTimes(Collection<Integer> userIds) throws SQLException {
|
||||
PreparedStatement statement = null;
|
||||
ResultSet set = null;
|
||||
Map<Integer, Map<GameMode, Long>> times = new HashMap<>();
|
||||
Map<Integer, Map<Gamemode, Long>> times = new HashMap<>();
|
||||
try {
|
||||
statement = prepareStatement("SELECT * FROM " + tableName);
|
||||
set = statement.executeQuery();
|
||||
while (set.next()) {
|
||||
Map<GameMode, Long> gmTimes = new HashMap<>();
|
||||
Map<Gamemode, Long> gmTimes = new HashMap<>();
|
||||
int id = set.getInt(columnUserID);
|
||||
if (!userIds.contains(id)) {
|
||||
continue;
|
||||
}
|
||||
gmTimes.put(GameMode.SURVIVAL, set.getLong(columnSurvivalTime));
|
||||
gmTimes.put(GameMode.CREATIVE, set.getLong(columnCreativeTime));
|
||||
gmTimes.put(GameMode.ADVENTURE, set.getLong(columnAdventureTime));
|
||||
gmTimes.put(Gamemode.SURVIVAL, set.getLong(columnSurvivalTime));
|
||||
gmTimes.put(Gamemode.CREATIVE, set.getLong(columnCreativeTime));
|
||||
gmTimes.put(Gamemode.ADVENTURE, set.getLong(columnAdventureTime));
|
||||
try {
|
||||
gmTimes.put(GameMode.SPECTATOR, set.getLong(columnSpectatorTime));
|
||||
gmTimes.put(Gamemode.SPECTATOR, set.getLong(columnSpectatorTime));
|
||||
} catch (NoSuchFieldError e) {
|
||||
}
|
||||
times.put(id, gmTimes);
|
||||
@ -148,12 +148,12 @@ public class GMTimesTable extends Table {
|
||||
* @param gamemodeTimes
|
||||
* @throws SQLException
|
||||
*/
|
||||
public void saveGMTimes(int userId, Map<GameMode, Long> gamemodeTimes) throws SQLException {
|
||||
public void saveGMTimes(int userId, Map<Gamemode, Long> gamemodeTimes) throws SQLException {
|
||||
if (gamemodeTimes == null || gamemodeTimes.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
PreparedStatement statement = null;
|
||||
GameMode[] gms = new GameMode[]{GameMode.SURVIVAL, GameMode.CREATIVE, GameMode.ADVENTURE, GameMode.SPECTATOR};
|
||||
Gamemode[] gms = Gamemode.values();
|
||||
int update = 0;
|
||||
try {
|
||||
statement = prepareStatement(
|
||||
@ -202,13 +202,13 @@ public class GMTimesTable extends Table {
|
||||
}
|
||||
}
|
||||
|
||||
public void saveGMTimes(Map<Integer, Map<GameMode, Long>> gamemodeTimes) throws SQLException {
|
||||
public void saveGMTimes(Map<Integer, Map<Gamemode, Long>> gamemodeTimes) throws SQLException {
|
||||
if (gamemodeTimes == null || gamemodeTimes.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
Benchmark.start("Save GMTimes");
|
||||
PreparedStatement statement = null;
|
||||
GameMode[] gms = new GameMode[]{GameMode.SURVIVAL, GameMode.CREATIVE, GameMode.ADVENTURE, GameMode.SPECTATOR};
|
||||
Gamemode[] gms = Gamemode.values();
|
||||
Set<Integer> savedIDs = getSavedIDs();
|
||||
try {
|
||||
statement = prepareStatement(
|
||||
@ -226,7 +226,7 @@ public class GMTimesTable extends Table {
|
||||
statement.setInt(5, id);
|
||||
for (int i = 0; i < gms.length; i++) {
|
||||
try {
|
||||
Map<GameMode, Long> times = gamemodeTimes.get(id);
|
||||
Map<Gamemode, Long> times = gamemodeTimes.get(id);
|
||||
Long time = times.get(gms[i]);
|
||||
if (time != null) {
|
||||
statement.setLong(i + 1, time);
|
||||
@ -251,12 +251,12 @@ public class GMTimesTable extends Table {
|
||||
Benchmark.stop("Save GMTimes");
|
||||
}
|
||||
|
||||
private void addNewGMTimesRows(Map<Integer, Map<GameMode, Long>> gamemodeTimes) throws SQLException {
|
||||
private void addNewGMTimesRows(Map<Integer, Map<Gamemode, Long>> gamemodeTimes) throws SQLException {
|
||||
if (gamemodeTimes == null || gamemodeTimes.isEmpty()) {
|
||||
return;
|
||||
}
|
||||
PreparedStatement statement = null;
|
||||
GameMode[] gms = new GameMode[]{GameMode.SURVIVAL, GameMode.CREATIVE, GameMode.ADVENTURE, GameMode.SPECTATOR};
|
||||
Gamemode[] gms = Gamemode.values();
|
||||
try {
|
||||
statement = prepareStatement(
|
||||
"INSERT INTO " + tableName + " ("
|
||||
@ -271,7 +271,7 @@ public class GMTimesTable extends Table {
|
||||
statement.setInt(1, id);
|
||||
for (int i = 0; i < gms.length; i++) {
|
||||
try {
|
||||
Map<GameMode, Long> times = gamemodeTimes.get(id);
|
||||
Map<Gamemode, Long> times = gamemodeTimes.get(id);
|
||||
Long time = times.get(gms[i]);
|
||||
if (time != null) {
|
||||
statement.setLong(i + 2, time);
|
||||
@ -293,9 +293,9 @@ public class GMTimesTable extends Table {
|
||||
}
|
||||
}
|
||||
|
||||
private void addNewGMTimesRow(int userId, Map<GameMode, Long> gamemodeTimes) throws SQLException {
|
||||
private void addNewGMTimesRow(int userId, Map<Gamemode, Long> gamemodeTimes) throws SQLException {
|
||||
PreparedStatement statement = null;
|
||||
GameMode[] gms = new GameMode[]{GameMode.SURVIVAL, GameMode.CREATIVE, GameMode.ADVENTURE, GameMode.SPECTATOR};
|
||||
Gamemode[] gms = Gamemode.values();
|
||||
try {
|
||||
statement = prepareStatement("INSERT INTO " + tableName + " ("
|
||||
+ columnUserID + ", "
|
||||
|
@ -1,5 +1,7 @@
|
||||
package main.java.com.djrapitops.plan.database.tables;
|
||||
|
||||
import com.djrapitops.javaplugin.utilities.player.Gamemode;
|
||||
import com.djrapitops.javaplugin.utilities.player.Fetch;
|
||||
import java.sql.PreparedStatement;
|
||||
import java.sql.ResultSet;
|
||||
import java.sql.SQLException;
|
||||
@ -14,6 +16,7 @@ import java.util.UUID;
|
||||
import java.util.function.Function;
|
||||
import java.util.stream.Collectors;
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.api.Gender;
|
||||
import main.java.com.djrapitops.plan.data.DemographicsData;
|
||||
import main.java.com.djrapitops.plan.data.UserData;
|
||||
@ -21,7 +24,6 @@ import main.java.com.djrapitops.plan.database.DBUtils;
|
||||
import main.java.com.djrapitops.plan.database.databases.SQLDB;
|
||||
import main.java.com.djrapitops.plan.utilities.Benchmark;
|
||||
import main.java.com.djrapitops.plan.utilities.uuid.UUIDUtility;
|
||||
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||
import org.bukkit.GameMode;
|
||||
|
||||
/**
|
||||
@ -295,7 +297,7 @@ public class UsersTable extends Table {
|
||||
data = getUserDataForKnown(uuid);
|
||||
}
|
||||
if (data == null) {
|
||||
data = new UserData(getOfflinePlayer(uuid), new DemographicsData());
|
||||
data = new UserData(Fetch.getOfflinePlayer(uuid, Plan.class), new DemographicsData());
|
||||
addUserInformationToUserData(data);
|
||||
}
|
||||
Benchmark.stop(uuid + " Get UserData");
|
||||
@ -337,7 +339,7 @@ public class UsersTable extends Table {
|
||||
List<UserData> noBukkitData = new ArrayList<>();
|
||||
Benchmark.start("Create UserData objects for No BukkitData players " + uuids.size());
|
||||
for (UUID uuid : uuids) {
|
||||
UserData uData = new UserData(getOfflinePlayer(uuid), new DemographicsData());
|
||||
UserData uData = new UserData(Fetch.getOfflinePlayer(uuid, Plan.class), new DemographicsData());
|
||||
noBukkitData.add(uData);
|
||||
}
|
||||
Benchmark.stop("Create UserData objects for No BukkitData players " + uuids.size());
|
||||
@ -393,7 +395,7 @@ public class UsersTable extends Table {
|
||||
demData.setAge(set.getInt(columnDemAge));
|
||||
demData.setGender(Gender.parse(set.getString(columnDemGender)));
|
||||
demData.setGeoLocation(set.getString(columnDemGeoLocation));
|
||||
GameMode gm = GameMode.valueOf(set.getString(columnLastGM));
|
||||
Gamemode gm = Gamemode.valueOf(set.getString(columnLastGM));
|
||||
boolean op = set.getBoolean(columnOP);
|
||||
boolean banned = set.getBoolean(columnBanned);
|
||||
String name = set.getString(columnName);
|
||||
@ -435,7 +437,7 @@ public class UsersTable extends Table {
|
||||
demData.setAge(set.getInt(columnDemAge));
|
||||
demData.setGender(Gender.parse(set.getString(columnDemGender)));
|
||||
demData.setGeoLocation(set.getString(columnDemGeoLocation));
|
||||
GameMode gm = GameMode.valueOf(set.getString(columnLastGM));
|
||||
Gamemode gm = Gamemode.valueOf(set.getString(columnLastGM));
|
||||
boolean op = set.getBoolean(columnOP);
|
||||
boolean banned = set.getBoolean(columnBanned);
|
||||
String name = set.getString(columnName);
|
||||
@ -476,7 +478,7 @@ public class UsersTable extends Table {
|
||||
data.getDemData().setAge(set.getInt(columnDemAge));
|
||||
data.getDemData().setGender(Gender.parse(set.getString(columnDemGender)));
|
||||
data.getDemData().setGeoLocation(set.getString(columnDemGeoLocation));
|
||||
data.setLastGamemode(GameMode.valueOf(set.getString(columnLastGM)));
|
||||
data.setLastGamemode(Gamemode.valueOf(set.getString(columnLastGM)));
|
||||
data.setLastGmSwapTime(set.getLong(columnLastGMSwapTime));
|
||||
data.setPlayTime(set.getLong(columnPlayTime));
|
||||
data.setLoginTimes(set.getInt(columnLoginTimes));
|
||||
@ -514,7 +516,7 @@ public class UsersTable extends Table {
|
||||
uData.getDemData().setAge(set.getInt(columnDemAge));
|
||||
uData.getDemData().setGender(Gender.parse(set.getString(columnDemGender)));
|
||||
uData.getDemData().setGeoLocation(set.getString(columnDemGeoLocation));
|
||||
uData.setLastGamemode(GameMode.valueOf(set.getString(columnLastGM)));
|
||||
uData.setLastGamemode(Gamemode.valueOf(set.getString(columnLastGM)));
|
||||
uData.setLastGmSwapTime(set.getLong(columnLastGMSwapTime));
|
||||
uData.setPlayTime(set.getLong(columnPlayTime));
|
||||
uData.setLoginTimes(set.getInt(columnLoginTimes));
|
||||
@ -564,11 +566,11 @@ public class UsersTable extends Table {
|
||||
statement.setInt(1, data.getDemData().getAge());
|
||||
statement.setString(2, data.getDemData().getGender().toString().toLowerCase());
|
||||
statement.setString(3, data.getDemData().getGeoLocation());
|
||||
GameMode gm = data.getLastGamemode();
|
||||
Gamemode gm = data.getLastGamemode();
|
||||
if (gm != null) {
|
||||
statement.setString(4, data.getLastGamemode().name());
|
||||
} else {
|
||||
statement.setString(4, GameMode.SURVIVAL.name());
|
||||
statement.setString(4, Gamemode.SURVIVAL.name());
|
||||
}
|
||||
statement.setLong(5, data.getLastGmSwapTime());
|
||||
statement.setLong(6, data.getPlayTime());
|
||||
@ -609,11 +611,11 @@ public class UsersTable extends Table {
|
||||
statement.setInt(2, data.getDemData().getAge());
|
||||
statement.setString(3, data.getDemData().getGender().toString().toLowerCase());
|
||||
statement.setString(4, data.getDemData().getGeoLocation());
|
||||
GameMode gm = data.getLastGamemode();
|
||||
Gamemode gm = data.getLastGamemode();
|
||||
if (gm != null) {
|
||||
statement.setString(5, data.getLastGamemode().name());
|
||||
} else {
|
||||
statement.setString(5, GameMode.SURVIVAL.name());
|
||||
statement.setString(5, Gamemode.SURVIVAL.name());
|
||||
}
|
||||
statement.setLong(6, data.getLastGmSwapTime());
|
||||
statement.setLong(7, data.getPlayTime());
|
||||
@ -685,7 +687,7 @@ public class UsersTable extends Table {
|
||||
statement.setInt(2, uData.getDemData().getAge());
|
||||
statement.setString(3, uData.getDemData().getGender().toString().toLowerCase());
|
||||
statement.setString(4, uData.getDemData().getGeoLocation());
|
||||
GameMode gm = uData.getLastGamemode();
|
||||
Gamemode gm = uData.getLastGamemode();
|
||||
if (gm != null) {
|
||||
statement.setString(5, uData.getLastGamemode().name());
|
||||
} else {
|
||||
@ -766,7 +768,7 @@ public class UsersTable extends Table {
|
||||
statement.setInt(1, uData.getDemData().getAge());
|
||||
statement.setString(2, uData.getDemData().getGender().toString().toLowerCase());
|
||||
statement.setString(3, uData.getDemData().getGeoLocation());
|
||||
GameMode gm = uData.getLastGamemode();
|
||||
Gamemode gm = uData.getLastGamemode();
|
||||
if (gm != null) {
|
||||
statement.setString(4, uData.getLastGamemode().name());
|
||||
} else {
|
||||
|
@ -1,12 +1,12 @@
|
||||
package main.java.com.djrapitops.plan.ui.tables;
|
||||
|
||||
import com.djrapitops.javaplugin.utilities.player.Fetch;
|
||||
import com.djrapitops.javaplugin.utilities.player.IOfflinePlayer;
|
||||
import java.util.List;
|
||||
import main.java.com.djrapitops.plan.data.KillData;
|
||||
import main.java.com.djrapitops.plan.ui.Html;
|
||||
import main.java.com.djrapitops.plan.utilities.FormatUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.HtmlUtils;
|
||||
import static org.bukkit.Bukkit.getOfflinePlayer;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -30,7 +30,7 @@ public class SortableKillsTableCreator {
|
||||
break;
|
||||
}
|
||||
long date = kill.getDate();
|
||||
OfflinePlayer victim = getOfflinePlayer(kill.getVictim());
|
||||
IOfflinePlayer victim = Fetch.getIOfflinePlayer(kill.getVictim());
|
||||
String name = victim.getName();
|
||||
html += Html.TABLELINE_3_CUSTOMKEY_1.parse(
|
||||
date + "", FormatUtils.formatTimeStamp(date),
|
||||
|
@ -2,15 +2,12 @@ package main.java.com.djrapitops.plan.utilities;
|
||||
|
||||
import com.djrapitops.javaplugin.command.CommandUtils;
|
||||
import com.djrapitops.javaplugin.command.sender.ISender;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashSet;
|
||||
import com.djrapitops.javaplugin.utilities.player.Fetch;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Set;
|
||||
import java.util.stream.Collectors;
|
||||
import main.java.com.djrapitops.plan.Permissions;
|
||||
import main.java.com.djrapitops.plan.Phrase;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
|
||||
/**
|
||||
* Utility method class containing various static methods.
|
||||
@ -49,7 +46,7 @@ public class MiscUtils {
|
||||
*/
|
||||
public static String getPlayerName(String[] args, ISender sender, Permissions perm) {
|
||||
String playerName = "";
|
||||
boolean isConsole = CommandUtils.isConsole(sender);
|
||||
boolean isConsole = !CommandUtils.isPlayer(sender);
|
||||
if (isConsole) {
|
||||
playerName = args[0];
|
||||
} else if (args.length > 0) {
|
||||
@ -67,20 +64,18 @@ public class MiscUtils {
|
||||
}
|
||||
|
||||
/**
|
||||
* Get matching playernames from the offlineplayers
|
||||
* Get matching player names from the offline players.
|
||||
*
|
||||
* @param search Part of a name to search for.
|
||||
* @return Set of OfflinePlayers that match.
|
||||
* @return Alphabetically sorted list of matching player names.
|
||||
*/
|
||||
public static Set<OfflinePlayer> getMatchingDisplaynames(String search) {
|
||||
List<OfflinePlayer> players = new ArrayList<>();
|
||||
players.addAll(Arrays.asList(Bukkit.getOfflinePlayers()));
|
||||
Set<OfflinePlayer> matches = new HashSet<>();
|
||||
players.stream()
|
||||
.filter(player -> (player.getName().toLowerCase().contains(search.toLowerCase())))
|
||||
.forEach(player -> {
|
||||
matches.add(player);
|
||||
});
|
||||
public static List<String> getMatchingPlayerNames(String search) {
|
||||
final String searchFor = search.toLowerCase();
|
||||
List<String> matches = Fetch.getIOfflinePlayers().stream()
|
||||
.map(p -> p.getName())
|
||||
.filter(name -> name.toLowerCase().contains(searchFor))
|
||||
.collect(Collectors.toList());
|
||||
Collections.sort(matches);
|
||||
return matches;
|
||||
}
|
||||
}
|
||||
|
@ -1,11 +1,11 @@
|
||||
package main.java.com.djrapitops.plan.utilities;
|
||||
|
||||
import com.djrapitops.javaplugin.utilities.player.Gamemode;
|
||||
import com.djrapitops.javaplugin.utilities.player.IOfflinePlayer;
|
||||
import com.djrapitops.javaplugin.utilities.player.IPlayer;
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.data.DemographicsData;
|
||||
import main.java.com.djrapitops.plan.data.UserData;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -19,8 +19,8 @@ public class NewPlayerCreator {
|
||||
* @param player Player the UserData is created for.
|
||||
* @return a new UserData object
|
||||
*/
|
||||
public static UserData createNewPlayer(Player player) {
|
||||
return createNewPlayer((OfflinePlayer) player, player.getGameMode());
|
||||
public static UserData createNewPlayer(IPlayer player) {
|
||||
return createNewPlayer((IOfflinePlayer) player, player.getGamemode());
|
||||
}
|
||||
|
||||
/**
|
||||
@ -29,8 +29,8 @@ public class NewPlayerCreator {
|
||||
* @param player OfflinePlayer the UserData is created for.
|
||||
* @return a new UserData object
|
||||
*/
|
||||
public static UserData createNewPlayer(OfflinePlayer player) {
|
||||
return createNewPlayer(player, GameMode.SURVIVAL);
|
||||
public static UserData createNewOfflinePlayer(IOfflinePlayer player) {
|
||||
return createNewPlayer(player, Gamemode.SURVIVAL);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -40,9 +40,9 @@ public class NewPlayerCreator {
|
||||
* @param gm Gamemode set as the starting Gamemode
|
||||
* @return a new UserData object
|
||||
*/
|
||||
public static UserData createNewPlayer(OfflinePlayer player, GameMode gm) {
|
||||
public static UserData createNewPlayer(IOfflinePlayer player, Gamemode gm) {
|
||||
long registered = player.getFirstPlayed();
|
||||
UserData data = new UserData(player.getUniqueId(), registered, null, player.isOp(), GameMode.SURVIVAL, new DemographicsData(), player.getName(), player.isOnline());
|
||||
UserData data = new UserData(player.getUniqueId(), registered, null, player.isOp(), Gamemode.SURVIVAL, new DemographicsData(), player.getName(), player.isOnline());
|
||||
data.setLastGamemode(gm);
|
||||
data.setLastPlayed(MiscUtils.getTime());
|
||||
data.setPlayTime(0L);
|
||||
|
@ -1,5 +1,6 @@
|
||||
package main.java.com.djrapitops.plan.utilities;
|
||||
|
||||
import com.djrapitops.javaplugin.utilities.player.Gamemode;
|
||||
import java.io.FileNotFoundException;
|
||||
import java.util.Arrays;
|
||||
import java.util.HashMap;
|
||||
@ -18,7 +19,6 @@ import main.java.com.djrapitops.plan.ui.tables.SortableKillsTableCreator;
|
||||
import main.java.com.djrapitops.plan.ui.tables.SortableSessionTableCreator;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.AnalysisUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.MathUtils;
|
||||
import org.bukkit.GameMode;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -165,10 +165,10 @@ public class PlaceholderUtils {
|
||||
int age = data.getDemData().getAge();
|
||||
replaceMap.put("%age%", (age != -1) ? "" + age : Phrase.DEM_UNKNOWN + "");
|
||||
replaceMap.put("%gender%", "" + data.getDemData().getGender().name().toLowerCase());
|
||||
Map<GameMode, Long> gmTimes = data.getGmTimes();
|
||||
Map<Gamemode, Long> gmTimes = data.getGmTimes();
|
||||
long gmThree;
|
||||
try {
|
||||
Long gm3 = gmTimes.get(GameMode.SPECTATOR);
|
||||
Long gm3 = gmTimes.get(Gamemode.SPECTATOR);
|
||||
if (gm3 == null) {
|
||||
gm3 = (long) 0;
|
||||
}
|
||||
@ -177,9 +177,9 @@ public class PlaceholderUtils {
|
||||
gmThree = 0;
|
||||
}
|
||||
long[] gmData = new long[]{
|
||||
(gmTimes.get(GameMode.SURVIVAL) != null ? gmTimes.get(GameMode.SURVIVAL) : 0L),
|
||||
(gmTimes.get(GameMode.CREATIVE) != null ? gmTimes.get(GameMode.CREATIVE) : 0L),
|
||||
(gmTimes.get(GameMode.ADVENTURE) != null ? gmTimes.get(GameMode.ADVENTURE) : 0L),
|
||||
(gmTimes.get(Gamemode.SURVIVAL) != null ? gmTimes.get(Gamemode.SURVIVAL) : 0L),
|
||||
(gmTimes.get(Gamemode.CREATIVE) != null ? gmTimes.get(Gamemode.CREATIVE) : 0L),
|
||||
(gmTimes.get(Gamemode.ADVENTURE) != null ? gmTimes.get(Gamemode.ADVENTURE) : 0L),
|
||||
gmThree
|
||||
};
|
||||
long total = gmData[0] + gmData[1] + gmData[2] + gmData[3];
|
||||
|
@ -41,13 +41,15 @@ import main.java.com.djrapitops.plan.utilities.HtmlUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import org.bukkit.GameMode;
|
||||
import com.djrapitops.javaplugin.task.ITask;
|
||||
import com.djrapitops.javaplugin.utilities.player.Gamemode;
|
||||
import main.java.com.djrapitops.plan.data.RawData;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author Rsl1122
|
||||
*/
|
||||
public class Analysis {
|
||||
|
||||
|
||||
private final Plan plugin;
|
||||
private final InspectCacheHandler inspectCache;
|
||||
private int taskId = -1;
|
||||
@ -153,29 +155,29 @@ public class Analysis {
|
||||
log(Phrase.ANALYSIS_BEGIN_ANALYSIS.parse(rawData.size() + "", Benchmark.stop("Analysis Fetch Phase") + ""));
|
||||
String playersTable = SortablePlayersTableCreator.createSortablePlayersTable(rawData);
|
||||
analysisData.setSortablePlayersTable(playersTable);
|
||||
|
||||
|
||||
analysisData.setTpsData(TPSGraphCreator.generateDataArray(tpsData, now));
|
||||
analysisData.setAverageTPS(MathUtils.averageDouble(tpsData.stream().map(t -> t.getTps())));
|
||||
|
||||
|
||||
RawAnalysisData sorted = fillDataset(commandUse, rawData, now);
|
||||
|
||||
// Analyze & Save RawAnalysisData to AnalysisData
|
||||
createCloroplethMap(analysisData, sorted.getGeolocations(), sorted.getGeocodes());
|
||||
createPlayerActivityGraphs(analysisData, sorted.getSessiondata(), sorted.getRegistered(), sorted.getSortedSessionData());
|
||||
analysisData.setRecentPlayers(RecentPlayersButtonsCreator.createRecentLoginsButtons(sorted.getLatestLogins(), 20));
|
||||
long totalPlaytime = sorted.getTotalPlaytime();
|
||||
long totalPlaytime = sorted.getLong(RawData.PLAYTIME);
|
||||
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());
|
||||
analysisData.setTotalLoginTimes(sorted.getLong(RawData.LOGINTIMES));
|
||||
createActivityVisalization(uuids.size(), sorted.getInt(RawData.AMOUNT_BANNED), sorted.getInt(RawData.AMOUNT_ACTIVE), sorted.getInt(RawData.AMOUNT_INACTIVE), sorted.getInt(RawData.AMOUNT_UNKNOWN), analysisData);
|
||||
analysisData.setOps(sorted.getInt(RawData.AMOUNT_OPS));
|
||||
analyzeAverageAge(sorted.getAges(), analysisData);
|
||||
createGamemodeUsageVisualization(sorted.getGmZero(), sorted.getGmOne(), sorted.getGmTwo(), sorted.getGmThree(), analysisData);
|
||||
createGamemodeUsageVisualization(sorted.getLong(RawData.TIME_GM0), sorted.getLong(RawData.TIME_GM1), sorted.getLong(RawData.TIME_GM2), sorted.getLong(RawData.TIME_GM3), analysisData);
|
||||
createCommandUseTable(sorted, analysisData);
|
||||
analysisData.setTotaldeaths(sorted.getTotalDeaths());
|
||||
analysisData.setTotalkills(sorted.getTotalKills());
|
||||
analysisData.setTotalmobkills(sorted.getTotalMobKills());
|
||||
analysisData.setTotaldeaths(sorted.getLong(RawData.DEATHS));
|
||||
analysisData.setTotalkills(sorted.getLong(RawData.KILLS));
|
||||
analysisData.setTotalmobkills(sorted.getLong(RawData.MOBKILLS));
|
||||
analysisData.setRefreshDate(now);
|
||||
analysisData.setPunchCardData(PunchCardGraphCreator.generateDataArray(sorted.getSessiondata()));
|
||||
analysisData.setSessionDistributionData(SessionLengthDistributionGraphCreator.generateDataArraySessions(sorted.getSessiondata()));
|
||||
@ -184,7 +186,7 @@ public class Analysis {
|
||||
log(Phrase.ANALYSIS_THIRD_PARTY + "");
|
||||
plugin.processStatus().setStatus("Analysis", "Analyzing additional data sources (3rd party)");
|
||||
analysisData.setAdditionalDataReplaceMap(analyzeAdditionalPluginData(uuids));
|
||||
|
||||
|
||||
analysisCache.cache(analysisData);
|
||||
long time = plugin.processStatus().finishExecution("Analysis");
|
||||
if (Settings.ANALYSIS_LOG_FINISHED.isTrue()) {
|
||||
@ -199,43 +201,43 @@ public class Analysis {
|
||||
}
|
||||
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) -> {
|
||||
Map<GameMode, Long> gmTimes = uData.getGmTimes();
|
||||
Map<Gamemode, Long> gmTimes = uData.getGmTimes();
|
||||
if (gmTimes != null) {
|
||||
Long survival = gmTimes.get(GameMode.SURVIVAL);
|
||||
Long survival = gmTimes.get(Gamemode.SURVIVAL);
|
||||
if (survival != null) {
|
||||
sorted.addToGmZero(survival);
|
||||
sorted.addTo(RawData.TIME_GM0, survival);
|
||||
}
|
||||
Long creative = gmTimes.get(GameMode.CREATIVE);
|
||||
Long creative = gmTimes.get(Gamemode.CREATIVE);
|
||||
if (creative != null) {
|
||||
sorted.addToGmOne(creative);
|
||||
sorted.addTo(RawData.TIME_GM1, creative);
|
||||
}
|
||||
Long adventure = gmTimes.get(GameMode.ADVENTURE);
|
||||
Long adventure = gmTimes.get(Gamemode.ADVENTURE);
|
||||
if (adventure != null) {
|
||||
sorted.addToGmTwo(adventure);
|
||||
sorted.addTo(RawData.TIME_GM2, adventure);
|
||||
}
|
||||
try {
|
||||
Long gm = gmTimes.get(GameMode.SPECTATOR);
|
||||
Long gm = gmTimes.get(Gamemode.SPECTATOR);
|
||||
if (gm != null) {
|
||||
sorted.addGmThree(gm);
|
||||
sorted.addTo(RawData.TIME_GM3, gm);
|
||||
}
|
||||
} catch (NoSuchFieldError e) {
|
||||
}
|
||||
}
|
||||
long playTime = uData.getPlayTime();
|
||||
sorted.addTotalPlaytime(playTime);
|
||||
sorted.addTo(RawData.PLAYTIME, playTime);
|
||||
String playerName = uData.getName();
|
||||
String url = HtmlUtils.getInspectUrl(playerName);
|
||||
String html = Html.BUTTON.parse(url, playerName);
|
||||
|
||||
|
||||
sorted.getLatestLogins().put(html, uData.getLastPlayed());
|
||||
sorted.addTotalLoginTimes(uData.getLoginTimes());
|
||||
sorted.addTo(RawData.LOGINTIMES, uData.getLoginTimes());
|
||||
DemographicsData demData = uData.getDemData();
|
||||
if (demData == null) {
|
||||
demData = new DemographicsData();
|
||||
@ -245,24 +247,24 @@ public class Analysis {
|
||||
sorted.getAges().add(age);
|
||||
}
|
||||
if (uData.isOp()) {
|
||||
sorted.addOps(1);
|
||||
sorted.addTo(RawData.AMOUNT_OPS, 1);
|
||||
}
|
||||
if (uData.isBanned()) {
|
||||
sorted.addTotalBanned(1);
|
||||
sorted.addTo(RawData.AMOUNT_BANNED, 1);
|
||||
} else if (uData.getLoginTimes() == 1) {
|
||||
sorted.addJoinleaver(1);
|
||||
sorted.addTo(RawData.AMOUNT_UNKNOWN, 1);
|
||||
} else if (AnalysisUtils.isActive(now, uData.getLastPlayed(), playTime, uData.getLoginTimes())) {
|
||||
sorted.addActive(1);
|
||||
sorted.addTo(RawData.AMOUNT_ACTIVE, 1);
|
||||
sorted.getPlaytimes().put(html, playTime);
|
||||
} else {
|
||||
sorted.addInactive(1);
|
||||
sorted.addTo(RawData.AMOUNT_INACTIVE, 1);
|
||||
}
|
||||
List<KillData> playerKills = uData.getPlayerKills();
|
||||
if (playerKills != null) {
|
||||
sorted.addTotalKills(playerKills.size());
|
||||
sorted.addTo(RawData.KILLS, playerKills.size());
|
||||
}
|
||||
sorted.addTotalMobKills(uData.getMobKills());
|
||||
sorted.addTotalDeaths(uData.getDeaths());
|
||||
sorted.addTo(RawData.MOBKILLS, uData.getMobKills());
|
||||
sorted.addTo(RawData.DEATHS, uData.getDeaths());
|
||||
List<SessionData> sessions = uData.getSessions();
|
||||
if (!sessions.isEmpty()) {
|
||||
sorted.addSessions(uData.getUuid(), sessions);
|
||||
@ -274,9 +276,9 @@ public class Analysis {
|
||||
Benchmark.stop("Analysis Fill Dataset");
|
||||
return sorted;
|
||||
}
|
||||
|
||||
|
||||
private void createCommandUseTable(final RawAnalysisData raw, AnalysisData data) {
|
||||
|
||||
|
||||
Map<String, Integer> commandUse = raw.getCommandUse();
|
||||
if (!commandUse.isEmpty()) {
|
||||
String tableHtml = SortableCommandUseTableCreator.createSortedCommandUseTable(commandUse);
|
||||
@ -287,7 +289,7 @@ public class Analysis {
|
||||
data.setTotalCommands(0);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void createActivityVisalization(int total, int totalBanned, int active, int inactive, int joinleaver, AnalysisData data) {
|
||||
Benchmark.start("Analysis Activity Visualization");
|
||||
data.setActive(active);
|
||||
@ -297,7 +299,7 @@ public class Analysis {
|
||||
data.setTotal(total);
|
||||
Benchmark.stop("Analysis Activity Visualization");
|
||||
}
|
||||
|
||||
|
||||
private void analyzeAverageAge(List<Integer> ages, AnalysisData data) {
|
||||
double averageAge = MathUtils.averageInt(ages.stream());
|
||||
if (averageAge == 0) {
|
||||
@ -305,7 +307,7 @@ public class Analysis {
|
||||
}
|
||||
data.setAverageAge(averageAge);
|
||||
}
|
||||
|
||||
|
||||
private void createGamemodeUsageVisualization(long gmZero, long gmOne, long gmTwo, long gmThree, AnalysisData data) {
|
||||
Benchmark.start("Analysis GMVisualization");
|
||||
long gmTotal = gmZero + gmOne + gmTwo + gmThree;
|
||||
@ -323,50 +325,50 @@ public class Analysis {
|
||||
data.setGm3Perc((gmThree * 1.0 / gmTotal));
|
||||
Benchmark.stop("Analysis GMVisualization");
|
||||
}
|
||||
|
||||
|
||||
private void createPlayerActivityGraphs(AnalysisData data, List<SessionData> sData, List<Long> registered, Map<UUID, List<SessionData>> sortedSData) {
|
||||
long now = new Date().toInstant().getEpochSecond() * (long) 1000;
|
||||
|
||||
|
||||
long scaleDay = TimeAmount.DAY.ms();
|
||||
long scaleWeek = TimeAmount.WEEK.ms();
|
||||
long scaleMonth = TimeAmount.MONTH.ms();
|
||||
|
||||
|
||||
data.setNewPlayersDay(AnalysisUtils.getNewPlayers(registered, scaleDay, now));
|
||||
data.setNewPlayersWeek(AnalysisUtils.getNewPlayers(registered, scaleWeek, now));
|
||||
data.setNewPlayersMonth(AnalysisUtils.getNewPlayers(registered, scaleMonth, now));
|
||||
|
||||
|
||||
Benchmark.start("Analysis Unique/day");
|
||||
data.setAvgUniqJoins(AnalysisUtils.getUniqueJoinsPerDay(sortedSData, -1));
|
||||
data.setAvgUniqJoinsDay(AnalysisUtils.getUniqueJoinsPerDay(sortedSData, scaleDay));
|
||||
data.setAvgUniqJoinsWeek(AnalysisUtils.getUniqueJoinsPerDay(sortedSData, scaleWeek));
|
||||
data.setAvgUniqJoinsMonth(AnalysisUtils.getUniqueJoinsPerDay(sortedSData, scaleMonth));
|
||||
Benchmark.stop("Analysis Unique/day");
|
||||
|
||||
|
||||
Benchmark.start("Analysis Unique");
|
||||
data.setUniqueJoinsDay(AnalysisUtils.getUniqueJoins(sortedSData, scaleDay));
|
||||
data.setUniqueJoinsWeek(AnalysisUtils.getUniqueJoins(sortedSData, scaleWeek));
|
||||
data.setUniqueJoinsMonth(AnalysisUtils.getUniqueJoins(sortedSData, scaleMonth));
|
||||
Benchmark.stop("Analysis Unique");
|
||||
|
||||
|
||||
List<SessionData> sessions = sData.stream()
|
||||
.filter(session -> (session != null))
|
||||
.filter(session -> session.isValid())
|
||||
.filter((session) -> (session.getSessionStart() >= now - scaleMonth || session.getSessionEnd() >= now - scaleMonth))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
|
||||
String[] dayArray = PlayerActivityGraphCreator.generateDataArray(sessions, scaleDay);
|
||||
String[] weekArray = PlayerActivityGraphCreator.generateDataArray(sessions, scaleWeek);
|
||||
String[] monthArray = PlayerActivityGraphCreator.generateDataArray(sessions, scaleMonth);
|
||||
|
||||
|
||||
data.setPlayersDataArray(new String[]{dayArray[0], dayArray[1], weekArray[0], weekArray[1], monthArray[0], monthArray[1]});
|
||||
}
|
||||
|
||||
|
||||
private void log(String msg) {
|
||||
if (Settings.ANALYSIS_LOG_TO_CONSOLE.isTrue()) {
|
||||
Log.info(msg);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
private void createCloroplethMap(AnalysisData aData, Map<String, Integer> geolocations, Map<String, String> geocodes) {
|
||||
Benchmark.start("Analysis Chloropleth map");
|
||||
String locations = "[";
|
||||
@ -390,7 +392,7 @@ public class Analysis {
|
||||
aData.setGeomapCodes(text.replace(",]", "]"));
|
||||
Benchmark.stop("Analysis Chloropleth map");
|
||||
}
|
||||
|
||||
|
||||
private Map<String, String> analyzeAdditionalPluginData(List<UUID> uuids) {
|
||||
Benchmark.start("Analysis 3rd party");
|
||||
final Map<String, String> replaceMap = new HashMap<>();
|
||||
@ -436,7 +438,7 @@ public class Analysis {
|
||||
}
|
||||
} catch (Throwable e) {
|
||||
Log.error("A PluginData-source caused an exception: " + source.getPlaceholder("").replace("%", ""));
|
||||
|
||||
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
} finally {
|
||||
Benchmark.stop("Source " + source.getPlaceholder("").replace("%", ""));
|
||||
@ -453,7 +455,7 @@ public class Analysis {
|
||||
public boolean isAnalysisBeingRun() {
|
||||
return taskId != -1;
|
||||
}
|
||||
|
||||
|
||||
public void setTaskId(int id) {
|
||||
if (id == -2) {
|
||||
plugin.processStatus().setStatus("Analysis", "Temporarily Disabled");
|
||||
|
@ -638,7 +638,7 @@
|
||||
</div>
|
||||
</div>
|
||||
<div class="tab">
|
||||
<div class="row">
|
||||
<div class="row" style="width: 100%;">
|
||||
<div class="box column">
|
||||
<div class="headerbox">
|
||||
<div class="header-icon" style="width: 50%">
|
||||
@ -661,7 +661,7 @@
|
||||
<canvas id="tps7d" width="1000" height="600" style="width: 95%;"></canvas>
|
||||
</div>
|
||||
</div>
|
||||
<div class="row">
|
||||
<!-- <div class="row">
|
||||
<div class="box column">
|
||||
<div class="headerbox">
|
||||
<div class="header-icon" style="width: 50%">
|
||||
@ -669,7 +669,7 @@
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>
|
||||
</div>-->
|
||||
</div>
|
||||
<div class="tab">
|
||||
<div class="row" style="width: 100%;">
|
||||
|
@ -8,7 +8,6 @@ package test.java.main.java.com.djrapitops.plan;
|
||||
import main.java.com.djrapitops.plan.Permissions;
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Test;
|
||||
import test.java.utils.MockUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -0,0 +1,14 @@
|
||||
/*
|
||||
* 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 test.java.main.java.com.djrapitops.plan.data;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author ristolah
|
||||
*/
|
||||
public class Tep {
|
||||
|
||||
}
|
@ -5,6 +5,7 @@
|
||||
*/
|
||||
package test.java.main.java.com.djrapitops.plan.data;
|
||||
|
||||
import com.djrapitops.javaplugin.utilities.player.Gamemode;
|
||||
import java.io.IOException;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
@ -17,7 +18,6 @@ import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.data.DemographicsData;
|
||||
import main.java.com.djrapitops.plan.data.SessionData;
|
||||
import main.java.com.djrapitops.plan.data.UserData;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.World;
|
||||
@ -58,7 +58,7 @@ public class UserDataTest {
|
||||
assertTrue("Not set up", t.setUp());
|
||||
plan = t.getPlanMock();
|
||||
DemographicsData demData = new DemographicsData();
|
||||
test = new UserData(UUID.fromString("7f8149a0-b5a5-4fcd-80b5-6cff083a99f1"), 0, null, true, GameMode.CREATIVE, demData, "Testname", true);
|
||||
test = new UserData(UUID.fromString("7f8149a0-b5a5-4fcd-80b5-6cff083a99f1"), 0, null, true, Gamemode.CREATIVE, demData, "Testname", true);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -203,8 +203,10 @@ public class UserDataTest {
|
||||
*/
|
||||
@Test
|
||||
public void testSetGMTime() {
|
||||
test.setGMTime(GameMode.SURVIVAL, 1L);
|
||||
assertTrue("" + test.getGmTimes().get(GameMode.SURVIVAL), test.getGmTimes().get(GameMode.SURVIVAL) == 1L);
|
||||
final Gamemode gm = Gamemode.SURVIVAL;
|
||||
test.setGMTime(gm, 1L);
|
||||
final Long result = test.getGmTimes().get(gm);
|
||||
assertTrue("" + result, result == 1L);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -213,8 +215,10 @@ public class UserDataTest {
|
||||
@Test
|
||||
public void testSetGMTimeWhenGMTimesNull() {
|
||||
test.setGmTimes(null);
|
||||
test.setGMTime(GameMode.SURVIVAL, 1L);
|
||||
assertTrue("" + test.getGmTimes().get(GameMode.SURVIVAL), test.getGmTimes().get(GameMode.SURVIVAL) == 1L);
|
||||
final Gamemode gm = Gamemode.SURVIVAL;
|
||||
test.setGMTime(gm, 1L);
|
||||
final Long result = test.getGmTimes().get(gm);
|
||||
assertTrue("" + result, result == 1L);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -231,16 +235,16 @@ public class UserDataTest {
|
||||
*/
|
||||
@Test
|
||||
public void testSetAllGMTimes() {
|
||||
HashMap<GameMode, Long> gmTimes = new HashMap<>();
|
||||
HashMap<Gamemode, Long> gmTimes = new HashMap<>();
|
||||
gmTimes.put(null, 0L);
|
||||
test.setGmTimes(gmTimes);
|
||||
test.setAllGMTimes(1L, 2L, 3L, 4L);
|
||||
Map<GameMode, Long> times = test.getGmTimes();
|
||||
Map<Gamemode, Long> times = test.getGmTimes();
|
||||
assertTrue("Cleared gmTimes", !times.containsKey(null));
|
||||
assertTrue("Not equal 0", times.get(GameMode.SURVIVAL) == 1L);
|
||||
assertTrue("Not equal 1", times.get(GameMode.CREATIVE) == 2L);
|
||||
assertTrue("Not equal 2", times.get(GameMode.ADVENTURE) == 3L);
|
||||
assertTrue("Not equal 3", times.get(GameMode.SPECTATOR) == 4L);
|
||||
assertTrue("Not equal 0", times.get(Gamemode.SURVIVAL) == 1L);
|
||||
assertTrue("Not equal 1", times.get(Gamemode.CREATIVE) == 2L);
|
||||
assertTrue("Not equal 2", times.get(Gamemode.ADVENTURE) == 3L);
|
||||
assertTrue("Not equal 3", times.get(Gamemode.SPECTATOR) == 4L);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -359,7 +363,7 @@ public class UserDataTest {
|
||||
*/
|
||||
@Test
|
||||
public void testEquals() {
|
||||
assertTrue("Not Equals!", test.equals(new UserData(UUID.fromString("7f8149a0-b5a5-4fcd-80b5-6cff083a99f1"), 0, null, true, GameMode.CREATIVE, null, "Testname", true)));
|
||||
assertTrue("Not Equals!", test.equals(new UserData(UUID.fromString("7f8149a0-b5a5-4fcd-80b5-6cff083a99f1"), 0, null, true, Gamemode.CREATIVE, null, "Testname", true)));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -367,7 +371,7 @@ public class UserDataTest {
|
||||
*/
|
||||
@Test
|
||||
public void testEqualsNot() {
|
||||
UserData notEqual = new UserData(UUID.fromString("7f8149a0-b5a5-4fcd-80b5-6cff083a99f1"), 0, null, true, GameMode.CREATIVE, null, "WRONG", true);
|
||||
UserData notEqual = new UserData(UUID.fromString("7f8149a0-b5a5-4fcd-80b5-6cff083a99f1"), 0, null, true, Gamemode.CREATIVE, null, "WRONG", true);
|
||||
assertTrue("Equals!", !notEqual.equals(test));
|
||||
}
|
||||
|
||||
@ -395,7 +399,7 @@ public class UserDataTest {
|
||||
@Test
|
||||
public void testPlayerConstructor() {
|
||||
test = new UserData(MockUtils.mockPlayer(), new DemographicsData());
|
||||
UserData expected = new UserData(UUID.fromString("45b0dfdb-f71d-4cf3-8c21-27c9d4c651db"), 1234567L, new Location(MockUtils.mockWorld(), 0, 0, 0), true, GameMode.SURVIVAL, new DemographicsData(), "TestName", true);
|
||||
UserData expected = new UserData(UUID.fromString("45b0dfdb-f71d-4cf3-8c21-27c9d4c651db"), 1234567L, new Location(MockUtils.mockWorld(), 0, 0, 0), true, Gamemode.SURVIVAL, new DemographicsData(), "TestName", true);
|
||||
expected.updateBanned(true);
|
||||
assertTrue("Not equal!", test.equals(expected));
|
||||
}
|
||||
@ -407,7 +411,7 @@ public class UserDataTest {
|
||||
@Test
|
||||
public void testPlayerConstructorBrokenBanned() throws IOException {
|
||||
test = new UserData(MockUtils.mockBrokenPlayer(), new DemographicsData());
|
||||
UserData expected = new UserData(UUID.fromString("45b0dfdb-f71d-4cf3-8c21-27c9d4c651db"), 1234567L, new Location(MockUtils.mockWorld(), 0, 0, 0), true, GameMode.SURVIVAL, new DemographicsData(), "TestName", true);
|
||||
UserData expected = new UserData(UUID.fromString("45b0dfdb-f71d-4cf3-8c21-27c9d4c651db"), 1234567L, new Location(MockUtils.mockWorld(), 0, 0, 0), true, Gamemode.SURVIVAL, new DemographicsData(), "TestName", true);
|
||||
expected.updateBanned(false);
|
||||
assertTrue("Not equal!", test.equals(expected));
|
||||
}
|
||||
@ -418,7 +422,7 @@ public class UserDataTest {
|
||||
@Test
|
||||
public void testOfflinePlayerConstructor() {
|
||||
test = new UserData((OfflinePlayer) MockUtils.mockPlayer(), new DemographicsData());
|
||||
UserData expected = new UserData(UUID.fromString("45b0dfdb-f71d-4cf3-8c21-27c9d4c651db"), 1234567L, new Location(MockUtils.mockWorld(), 0, 0, 0), true, GameMode.SURVIVAL, new DemographicsData(), "TestName", true);
|
||||
UserData expected = new UserData(UUID.fromString("45b0dfdb-f71d-4cf3-8c21-27c9d4c651db"), 1234567L, new Location(MockUtils.mockWorld(), 0, 0, 0), true, Gamemode.SURVIVAL, new DemographicsData(), "TestName", true);
|
||||
expected.updateBanned(true);
|
||||
assertTrue("Not equal!", test.equals(expected));
|
||||
}
|
||||
@ -430,7 +434,7 @@ public class UserDataTest {
|
||||
@Test
|
||||
public void testOfflinePlayerConstructorBrokenBanned() throws IOException {
|
||||
test = new UserData((OfflinePlayer) MockUtils.mockBrokenPlayer(), new DemographicsData());
|
||||
UserData expected = new UserData(UUID.fromString("45b0dfdb-f71d-4cf3-8c21-27c9d4c651db"), 1234567L, new Location(MockUtils.mockWorld(), 0, 0, 0), true, GameMode.SURVIVAL, new DemographicsData(), "TestName", true);
|
||||
UserData expected = new UserData(UUID.fromString("45b0dfdb-f71d-4cf3-8c21-27c9d4c651db"), 1234567L, new Location(MockUtils.mockWorld(), 0, 0, 0), true, Gamemode.SURVIVAL, new DemographicsData(), "TestName", true);
|
||||
expected.updateBanned(false);
|
||||
assertTrue("Not equal!", test.equals(expected));
|
||||
}
|
||||
|
@ -21,17 +21,17 @@ import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.junit.After;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import static org.powermock.api.mockito.PowerMockito.when;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import test.java.utils.MockUtils;
|
||||
import test.java.utils.TestInit;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.powermock.api.mockito.PowerMockito.when;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -5,6 +5,8 @@
|
||||
*/
|
||||
package test.java.main.java.com.djrapitops.plan.data.cache.queue;
|
||||
|
||||
import com.djrapitops.javaplugin.utilities.player.BukkitOfflinePlayer;
|
||||
import com.djrapitops.javaplugin.utilities.player.IOfflinePlayer;
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
@ -16,7 +18,6 @@ import main.java.com.djrapitops.plan.data.cache.DataCacheHandler;
|
||||
import main.java.com.djrapitops.plan.data.cache.queue.DataCacheProcessQueue;
|
||||
import main.java.com.djrapitops.plan.data.handling.info.HandlingInfo;
|
||||
import main.java.com.djrapitops.plan.data.handling.info.InfoType;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.junit.After;
|
||||
import static org.junit.Assert.*;
|
||||
@ -69,11 +70,11 @@ public class DataCacheProcessQueueTest {
|
||||
@Override
|
||||
public void getUserDataForProcessing(DBCallableProcessor p, UUID uuid) {
|
||||
if (uuid.equals(MockUtils.getPlayerUUID())) {
|
||||
OfflinePlayer op = MockUtils.mockPlayer();
|
||||
IOfflinePlayer op = BukkitOfflinePlayer.wrap(MockUtils.mockPlayer());
|
||||
UserData d = new UserData(op, new DemographicsData());
|
||||
p.process(d);
|
||||
} else if (uuid.equals(MockUtils.getPlayer2UUID())) {
|
||||
OfflinePlayer op = MockUtils.mockPlayer2();
|
||||
IOfflinePlayer op = BukkitOfflinePlayer.wrap(MockUtils.mockPlayer2());
|
||||
UserData d = new UserData(op, new DemographicsData());
|
||||
p.process(d);
|
||||
}
|
||||
|
@ -18,10 +18,10 @@ import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import static org.powermock.api.mockito.PowerMockito.when;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import test.java.utils.TestInit;
|
||||
import static org.powermock.api.mockito.PowerMockito.when;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -5,10 +5,10 @@
|
||||
*/
|
||||
package test.java.main.java.com.djrapitops.plan.data.handling;
|
||||
|
||||
import com.djrapitops.javaplugin.utilities.player.Gamemode;
|
||||
import main.java.com.djrapitops.plan.data.DemographicsData;
|
||||
import main.java.com.djrapitops.plan.data.UserData;
|
||||
import main.java.com.djrapitops.plan.data.handling.GamemodeHandling;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Before;
|
||||
@ -49,19 +49,19 @@ public class GamemodeHandlingTest {
|
||||
public void testProcessGamemodeInfo() {
|
||||
UserData data = new UserData(MockUtils.mockPlayer(), new DemographicsData());
|
||||
data.setPlayTime(100L);
|
||||
data.setLastGamemode(GameMode.CREATIVE);
|
||||
data.setLastGamemode(Gamemode.CREATIVE);
|
||||
data.setLastGmSwapTime(50L);
|
||||
data.setLastPlayed(1000L);
|
||||
long time = 2000L;
|
||||
GamemodeHandling.processGamemodeInfo(data, time, GameMode.SURVIVAL);
|
||||
Long result = data.getGmTimes().get(GameMode.CREATIVE);
|
||||
GamemodeHandling.processGamemodeInfo(data, time, Gamemode.SURVIVAL);
|
||||
Long result = data.getGmTimes().get(Gamemode.CREATIVE);
|
||||
assertTrue("Gamemode time was " + result, result == 1050L);
|
||||
result = data.getPlayTime();
|
||||
assertTrue("Playtime was" + result, result == 1100L);
|
||||
result = data.getLastPlayed();
|
||||
assertTrue("Last Played was" + result, result == 2000L);
|
||||
GameMode lastGM = data.getLastGamemode();
|
||||
assertTrue("Last gm not Survival", lastGM == GameMode.SURVIVAL);
|
||||
Gamemode lastGM = data.getLastGamemode();
|
||||
assertTrue("Last gm not Survival", lastGM == Gamemode.SURVIVAL);
|
||||
result = data.getLastGmSwapTime();
|
||||
assertTrue("Last swaptime was " + result, result == 1100L);
|
||||
}
|
||||
@ -73,19 +73,19 @@ public class GamemodeHandlingTest {
|
||||
public void testProcessGamemodeInfoSameGM() {
|
||||
UserData data = new UserData(MockUtils.mockPlayer(), new DemographicsData());
|
||||
data.setPlayTime(100L);
|
||||
data.setLastGamemode(GameMode.SURVIVAL);
|
||||
data.setLastGamemode(Gamemode.SURVIVAL);
|
||||
data.setLastGmSwapTime(50L);
|
||||
data.setLastPlayed(1000L);
|
||||
long time = 2000L;
|
||||
GamemodeHandling.processGamemodeInfo(data, time, GameMode.SURVIVAL);
|
||||
Long result = data.getGmTimes().get(GameMode.SURVIVAL);
|
||||
GamemodeHandling.processGamemodeInfo(data, time, Gamemode.SURVIVAL);
|
||||
Long result = data.getGmTimes().get(Gamemode.SURVIVAL);
|
||||
assertTrue("Gamemode time was " + result, result == 1050L);
|
||||
result = data.getPlayTime();
|
||||
assertTrue("Playtime was" + result, result == 1100L);
|
||||
result = data.getLastPlayed();
|
||||
assertTrue("Last Played was" + result, result == 2000L);
|
||||
GameMode lastGM = data.getLastGamemode();
|
||||
assertTrue("Last gm not Survival", lastGM == GameMode.SURVIVAL);
|
||||
Gamemode lastGM = data.getLastGamemode();
|
||||
assertTrue("Last gm not Survival", lastGM == Gamemode.SURVIVAL);
|
||||
result = data.getLastGmSwapTime();
|
||||
assertTrue("Last swaptime was " + result, result == 1100L);
|
||||
}
|
||||
@ -97,19 +97,19 @@ public class GamemodeHandlingTest {
|
||||
public void testProcessGamemodeInfoNullNewGM() {
|
||||
UserData data = new UserData(MockUtils.mockPlayer(), new DemographicsData());
|
||||
data.setPlayTime(100L);
|
||||
data.setLastGamemode(GameMode.SURVIVAL);
|
||||
data.setLastGamemode(Gamemode.SURVIVAL);
|
||||
data.setLastGmSwapTime(50L);
|
||||
data.setLastPlayed(1000L);
|
||||
long time = 2000L;
|
||||
GamemodeHandling.processGamemodeInfo(data, time, null);
|
||||
Long result = data.getGmTimes().get(GameMode.SURVIVAL);
|
||||
Long result = data.getGmTimes().get(Gamemode.SURVIVAL);
|
||||
assertTrue("Gamemode time was " + result, result == 0L);
|
||||
result = data.getPlayTime();
|
||||
assertTrue("Playtime was" + result, result == 100L);
|
||||
result = data.getLastPlayed();
|
||||
assertTrue("Last Played was" + result, result == 1000L);
|
||||
GameMode lastGM = data.getLastGamemode();
|
||||
assertTrue("Last gm not Survival", lastGM == GameMode.SURVIVAL);
|
||||
Gamemode lastGM = data.getLastGamemode();
|
||||
assertTrue("Last gm not Survival", lastGM == Gamemode.SURVIVAL);
|
||||
result = data.getLastGmSwapTime();
|
||||
assertTrue("Last swaptime was " + result, result == 50L);
|
||||
}
|
||||
@ -125,15 +125,15 @@ public class GamemodeHandlingTest {
|
||||
data.setLastGmSwapTime(50L);
|
||||
data.setLastPlayed(1000L);
|
||||
long time = 2000L;
|
||||
GamemodeHandling.processGamemodeInfo(data, time, GameMode.SURVIVAL);
|
||||
Long result = data.getGmTimes().get(GameMode.SURVIVAL);
|
||||
GamemodeHandling.processGamemodeInfo(data, time, Gamemode.SURVIVAL);
|
||||
Long result = data.getGmTimes().get(Gamemode.SURVIVAL);
|
||||
assertTrue("Gamemode time was " + result, result == 1050L);
|
||||
result = data.getPlayTime();
|
||||
assertTrue("Playtime was" + result, result == 1100L);
|
||||
result = data.getLastPlayed();
|
||||
assertTrue("Last Played was" + result, result == 2000L);
|
||||
GameMode lastGM = data.getLastGamemode();
|
||||
assertTrue("Last gm not Survival", lastGM == GameMode.SURVIVAL);
|
||||
Gamemode lastGM = data.getLastGamemode();
|
||||
assertTrue("Last gm not Survival", lastGM == Gamemode.SURVIVAL);
|
||||
result = data.getLastGmSwapTime();
|
||||
assertTrue("Last swaptime was " + result, result == 1100L);
|
||||
}
|
||||
@ -150,15 +150,15 @@ public class GamemodeHandlingTest {
|
||||
data.setLastGmSwapTime(50L);
|
||||
data.setLastPlayed(1000L);
|
||||
long time = 2000L;
|
||||
GamemodeHandling.processGamemodeInfo(data, time, GameMode.SURVIVAL);
|
||||
Long result = data.getGmTimes().get(GameMode.SURVIVAL);
|
||||
GamemodeHandling.processGamemodeInfo(data, time, Gamemode.SURVIVAL);
|
||||
Long result = data.getGmTimes().get(Gamemode.SURVIVAL);
|
||||
assertTrue("Gamemode time was " + result, result == 1050L);
|
||||
result = data.getPlayTime();
|
||||
assertTrue("Playtime was" + result, result == 1100L);
|
||||
result = data.getLastPlayed();
|
||||
assertTrue("Last Played was" + result, result == 2000L);
|
||||
GameMode lastGM = data.getLastGamemode();
|
||||
assertTrue("Last gm not Survival", lastGM == GameMode.SURVIVAL);
|
||||
Gamemode lastGM = data.getLastGamemode();
|
||||
assertTrue("Last gm not Survival", lastGM == Gamemode.SURVIVAL);
|
||||
result = data.getLastGmSwapTime();
|
||||
assertTrue("Last swaptime was " + result, result == 1100L);
|
||||
}
|
||||
|
@ -18,17 +18,16 @@ import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.junit.After;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import static org.powermock.api.mockito.PowerMockito.when;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import test.java.utils.MockUtils;
|
||||
import test.java.utils.TestInit;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import static org.powermock.api.mockito.PowerMockito.when;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -103,9 +102,9 @@ public class KillHandlingTest {
|
||||
* @throws SQLException
|
||||
* @throws IOException
|
||||
*/
|
||||
@Ignore
|
||||
@Test
|
||||
public void testProcessKillInfoException() throws SQLException, IOException {
|
||||
db.init();
|
||||
UserData data = new UserData(MockUtils.mockPlayer(), new DemographicsData());
|
||||
Player dead = MockUtils.mockPlayer2();
|
||||
KillHandling.processKillInfo(data, 10L, dead, "TestWeapon");
|
||||
|
@ -5,10 +5,10 @@
|
||||
*/
|
||||
package test.java.main.java.com.djrapitops.plan.data.handling.info;
|
||||
|
||||
import com.djrapitops.javaplugin.utilities.player.Gamemode;
|
||||
import main.java.com.djrapitops.plan.data.DemographicsData;
|
||||
import main.java.com.djrapitops.plan.data.UserData;
|
||||
import main.java.com.djrapitops.plan.data.handling.info.GamemodeInfo;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Before;
|
||||
@ -49,20 +49,20 @@ public class GamemodeInfoTest {
|
||||
public void testProcess() {
|
||||
UserData data = new UserData(MockUtils.mockPlayer(), new DemographicsData());
|
||||
data.setPlayTime(100L);
|
||||
data.setLastGamemode(GameMode.CREATIVE);
|
||||
data.setLastGamemode(Gamemode.CREATIVE);
|
||||
data.setLastGmSwapTime(50L);
|
||||
data.setLastPlayed(1000L);
|
||||
long time = 2000L;
|
||||
GamemodeInfo i = new GamemodeInfo(data.getUuid(), time, GameMode.SURVIVAL);
|
||||
GamemodeInfo i = new GamemodeInfo(data.getUuid(), time, Gamemode.SURVIVAL);
|
||||
assertTrue(i.process(data));
|
||||
Long result = data.getGmTimes().get(GameMode.CREATIVE);
|
||||
Long result = data.getGmTimes().get(Gamemode.CREATIVE);
|
||||
assertTrue("Gamemode time was " + result, result == 1050L);
|
||||
result = data.getPlayTime();
|
||||
assertTrue("Playtime was" + result, result == 1100L);
|
||||
result = data.getLastPlayed();
|
||||
assertTrue("Last Played was" + result, result == 2000L);
|
||||
GameMode lastGM = data.getLastGamemode();
|
||||
assertTrue("Last gm not Survival", lastGM == GameMode.SURVIVAL);
|
||||
Gamemode lastGM = data.getLastGamemode();
|
||||
assertTrue("Last gm not Survival", lastGM == Gamemode.SURVIVAL);
|
||||
result = data.getLastGmSwapTime();
|
||||
assertTrue("Last swaptime was " + result, result == 1100L);
|
||||
}
|
||||
@ -74,20 +74,20 @@ public class GamemodeInfoTest {
|
||||
public void testProcessWrongUUID() {
|
||||
UserData data = new UserData(MockUtils.mockPlayer(), new DemographicsData());
|
||||
data.setPlayTime(100L);
|
||||
data.setLastGamemode(GameMode.CREATIVE);
|
||||
data.setLastGamemode(Gamemode.CREATIVE);
|
||||
data.setLastGmSwapTime(50L);
|
||||
data.setLastPlayed(1000L);
|
||||
long time = 2000L;
|
||||
GamemodeInfo i = new GamemodeInfo(null, time, GameMode.SURVIVAL);
|
||||
GamemodeInfo i = new GamemodeInfo(null, time, Gamemode.SURVIVAL);
|
||||
assertTrue(!i.process(data));
|
||||
Long result = data.getGmTimes().get(GameMode.CREATIVE);
|
||||
Long result = data.getGmTimes().get(Gamemode.CREATIVE);
|
||||
assertTrue("Gamemode time was " + result, result == 0L);
|
||||
result = data.getPlayTime();
|
||||
assertTrue("Playtime was" + result, result == 100L);
|
||||
result = data.getLastPlayed();
|
||||
assertTrue("Last Played was" + result, result == 1000L);
|
||||
GameMode lastGM = data.getLastGamemode();
|
||||
assertTrue("Last gm not Survival", lastGM == GameMode.CREATIVE);
|
||||
Gamemode lastGM = data.getLastGamemode();
|
||||
assertTrue("Last gm not Survival", lastGM == Gamemode.CREATIVE);
|
||||
result = data.getLastGmSwapTime();
|
||||
assertTrue("Last swaptime was " + result, result == 50L);
|
||||
}
|
||||
@ -99,20 +99,20 @@ public class GamemodeInfoTest {
|
||||
public void testProcessNullGM() {
|
||||
UserData data = new UserData(MockUtils.mockPlayer(), new DemographicsData());
|
||||
data.setPlayTime(100L);
|
||||
data.setLastGamemode(GameMode.CREATIVE);
|
||||
data.setLastGamemode(Gamemode.CREATIVE);
|
||||
data.setLastGmSwapTime(50L);
|
||||
data.setLastPlayed(1000L);
|
||||
long time = 2000L;
|
||||
GamemodeInfo i = new GamemodeInfo(data.getUuid(), time, null);
|
||||
assertTrue(!i.process(data));
|
||||
Long result = data.getGmTimes().get(GameMode.CREATIVE);
|
||||
Long result = data.getGmTimes().get(Gamemode.CREATIVE);
|
||||
assertTrue("Gamemode time was " + result, result == 0L);
|
||||
result = data.getPlayTime();
|
||||
assertTrue("Playtime was" + result, result == 100L);
|
||||
result = data.getLastPlayed();
|
||||
assertTrue("Last Played was" + result, result == 1000L);
|
||||
GameMode lastGM = data.getLastGamemode();
|
||||
assertTrue("Last gm not Survival", lastGM == GameMode.CREATIVE);
|
||||
Gamemode lastGM = data.getLastGamemode();
|
||||
assertTrue("Last gm not Survival", lastGM == Gamemode.CREATIVE);
|
||||
result = data.getLastGmSwapTime();
|
||||
assertTrue("Last swaptime was " + result, result == 50L);
|
||||
}
|
||||
|
@ -21,11 +21,11 @@ import static org.junit.Assert.*;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import static org.powermock.api.mockito.PowerMockito.when;
|
||||
import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import test.java.utils.MockUtils;
|
||||
import test.java.utils.TestInit;
|
||||
import static org.powermock.api.mockito.PowerMockito.when;
|
||||
|
||||
/**
|
||||
*
|
||||
|
@ -5,13 +5,13 @@
|
||||
*/
|
||||
package test.java.main.java.com.djrapitops.plan.data.handling.info;
|
||||
|
||||
import com.djrapitops.javaplugin.utilities.player.Gamemode;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.data.DemographicsData;
|
||||
import main.java.com.djrapitops.plan.data.UserData;
|
||||
import main.java.com.djrapitops.plan.data.handling.info.LoginInfo;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Before;
|
||||
@ -57,7 +57,7 @@ public class LoginInfoTest {
|
||||
long time = 10L;
|
||||
int loginTimes = data.getLoginTimes();
|
||||
String nick = "TestProcessLoginInfo";
|
||||
LoginInfo i = new LoginInfo(data.getUuid(), time, ip, true, nick, GameMode.CREATIVE, 1);
|
||||
LoginInfo i = new LoginInfo(data.getUuid(), time, ip, true, nick, Gamemode.CREATIVE, 1);
|
||||
assertTrue(i.process(data));
|
||||
assertTrue("LastPlayed wrong: " + data.getLastPlayed(), data.getLastPlayed() == time);
|
||||
assertTrue("Ip not added", data.getIps().contains(ip));
|
||||
@ -66,7 +66,7 @@ public class LoginInfoTest {
|
||||
assertTrue("Nick not last nick", data.getLastNick().equals(nick));
|
||||
String geo = data.getDemData().getGeoLocation();
|
||||
assertTrue("Wrong location " + geo, geo.equals("United States"));
|
||||
assertTrue("Didn't process gamemode", data.getLastGamemode() == GameMode.CREATIVE);
|
||||
assertTrue("Didn't process gamemode", data.getLastGamemode() == Gamemode.CREATIVE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -79,7 +79,7 @@ public class LoginInfoTest {
|
||||
InetAddress ip = InetAddress.getByName("137.19.188.146");
|
||||
long time = 10L;
|
||||
String nick = "TestProcessLoginInfo";
|
||||
LoginInfo i = new LoginInfo(null, time, ip, true, nick, GameMode.CREATIVE, 1);
|
||||
LoginInfo i = new LoginInfo(null, time, ip, true, nick, Gamemode.CREATIVE, 1);
|
||||
assertTrue(!i.process(data));
|
||||
assertTrue("LastPlayed wrong: " + data.getLastPlayed(), data.getLastPlayed() == 0L);
|
||||
assertTrue("Ip not added", !data.getIps().contains(ip));
|
||||
@ -87,7 +87,7 @@ public class LoginInfoTest {
|
||||
assertTrue("Nick not added", !data.getNicknames().contains(nick));
|
||||
String geo = data.getDemData().getGeoLocation();
|
||||
assertTrue("Wrong location " + geo, geo.equals("Not Known"));
|
||||
assertTrue("Didn't process gamemode", data.getLastGamemode() == GameMode.SURVIVAL);
|
||||
assertTrue("Didn't process gamemode", data.getLastGamemode() == Gamemode.SURVIVAL);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,11 +5,11 @@
|
||||
*/
|
||||
package test.java.main.java.com.djrapitops.plan.data.handling.info;
|
||||
|
||||
import com.djrapitops.javaplugin.utilities.player.Gamemode;
|
||||
import main.java.com.djrapitops.plan.data.DemographicsData;
|
||||
import main.java.com.djrapitops.plan.data.SessionData;
|
||||
import main.java.com.djrapitops.plan.data.UserData;
|
||||
import main.java.com.djrapitops.plan.data.handling.info.LogoutInfo;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Before;
|
||||
@ -53,13 +53,13 @@ public class LogoutInfoTest {
|
||||
data.updateBanned(false);
|
||||
long time = 20L;
|
||||
Exception ex = null;
|
||||
data.setLastGamemode(GameMode.SURVIVAL);
|
||||
LogoutInfo i = new LogoutInfo(data.getUuid(), time, true, GameMode.CREATIVE, new SessionData(0, 1));
|
||||
data.setLastGamemode(Gamemode.SURVIVAL);
|
||||
LogoutInfo i = new LogoutInfo(data.getUuid(), time, true, Gamemode.CREATIVE, new SessionData(0, 1));
|
||||
assertTrue(i.process(data));
|
||||
assertTrue("Last Played wrong", data.getLastPlayed() == 20L);
|
||||
assertTrue("Playtime wrong", data.getPlayTime() == 10L);
|
||||
assertTrue("Banned wrong", data.isBanned());
|
||||
assertTrue("Didn't process gamemode", data.getLastGamemode() == GameMode.CREATIVE);
|
||||
assertTrue("Didn't process gamemode", data.getLastGamemode() == Gamemode.CREATIVE);
|
||||
assertEquals(1, data.getSessions().size());
|
||||
}
|
||||
|
||||
@ -73,7 +73,7 @@ public class LogoutInfoTest {
|
||||
data.updateBanned(false);
|
||||
long time = 20L;
|
||||
Exception ex = null;
|
||||
LogoutInfo i = new LogoutInfo(null, time, true, GameMode.CREATIVE, new SessionData(0, 1));
|
||||
LogoutInfo i = new LogoutInfo(null, time, true, Gamemode.CREATIVE, new SessionData(0, 1));
|
||||
try {
|
||||
assertTrue(!i.process(data));
|
||||
} catch (NullPointerException e) {
|
||||
@ -83,7 +83,7 @@ public class LogoutInfoTest {
|
||||
assertTrue("Last Played wrong", data.getLastPlayed() == 10L);
|
||||
assertTrue("Playtime wrong", data.getPlayTime() == 0L);
|
||||
assertTrue("Banned wrong", !data.isBanned());
|
||||
assertTrue("Didn't process gamemode", data.getLastGamemode() == GameMode.SURVIVAL);
|
||||
assertTrue("Didn't process gamemode", data.getLastGamemode() == Gamemode.SURVIVAL);
|
||||
assertEquals(0, data.getSessions().size());
|
||||
}
|
||||
|
||||
|
@ -5,13 +5,13 @@
|
||||
*/
|
||||
package test.java.main.java.com.djrapitops.plan.data.handling.info;
|
||||
|
||||
import com.djrapitops.javaplugin.utilities.player.Gamemode;
|
||||
import java.net.InetAddress;
|
||||
import java.net.UnknownHostException;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.data.DemographicsData;
|
||||
import main.java.com.djrapitops.plan.data.UserData;
|
||||
import main.java.com.djrapitops.plan.data.handling.info.ReloadInfo;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Before;
|
||||
@ -57,7 +57,7 @@ public class ReloadInfoTest {
|
||||
long time = 10L;
|
||||
int loginTimes = data.getLoginTimes();
|
||||
String nick = "TestProcessLoginInfo";
|
||||
ReloadInfo i = new ReloadInfo(data.getUuid(), time, ip, true, nick, GameMode.CREATIVE);
|
||||
ReloadInfo i = new ReloadInfo(data.getUuid(), time, ip, true, nick, Gamemode.CREATIVE);
|
||||
assertTrue(i.process(data));
|
||||
assertTrue("LastPlayed wrong: " + data.getLastPlayed(), data.getLastPlayed() == time);
|
||||
assertTrue("Ip not added", data.getIps().contains(ip));
|
||||
@ -66,7 +66,7 @@ public class ReloadInfoTest {
|
||||
assertTrue("Nick not last nick", data.getLastNick().equals(nick));
|
||||
String geo = data.getDemData().getGeoLocation();
|
||||
assertTrue("Wrong location " + geo, geo.equals("United States"));
|
||||
assertTrue("Didn't process gamemode", data.getLastGamemode() == GameMode.CREATIVE);
|
||||
assertTrue("Didn't process gamemode", data.getLastGamemode() == Gamemode.CREATIVE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -79,7 +79,7 @@ public class ReloadInfoTest {
|
||||
InetAddress ip = InetAddress.getByName("137.19.188.146");
|
||||
long time = 10L;
|
||||
String nick = "TestProcessLoginInfo";
|
||||
ReloadInfo i = new ReloadInfo(null, time, ip, true, nick, GameMode.CREATIVE);
|
||||
ReloadInfo i = new ReloadInfo(null, time, ip, true, nick, Gamemode.CREATIVE);
|
||||
assertTrue(!i.process(data));
|
||||
}
|
||||
}
|
||||
|
@ -40,8 +40,6 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.bukkit.scheduler.*;
|
||||
import org.easymock.EasyMock;
|
||||
import org.junit.After;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@ -50,6 +48,8 @@ import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import test.java.utils.MockUtils;
|
||||
import test.java.utils.TestInit;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -314,8 +314,6 @@ public class DatabaseTest {
|
||||
list.add(data2);
|
||||
db.saveMultipleUserData(list);
|
||||
data.addPlayerKill(new KillData(MockUtils.getPlayer2UUID(), 2, "DiamondSword", 75843759L));
|
||||
data.setLocation(null);
|
||||
data2.setLocation(null);
|
||||
DBCallableProcessor process = new DBCallableProcessor() {
|
||||
@Override
|
||||
public void process(UserData d) {
|
||||
|
@ -7,7 +7,7 @@ package test.java.main.java.com.djrapitops.plan.utilities;
|
||||
|
||||
import com.djrapitops.javaplugin.command.sender.BukkitCMDSender;
|
||||
import com.djrapitops.javaplugin.command.sender.ISender;
|
||||
import java.util.Set;
|
||||
import java.util.List;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
@ -15,7 +15,6 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.easymock.EasyMock;
|
||||
import static org.junit.Assert.*;
|
||||
import org.junit.Before;
|
||||
import org.junit.Ignore;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
import org.powermock.api.easymock.PowerMock;
|
||||
@ -128,21 +127,15 @@ public class MiscUtilsTest {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Ignore("Inconsistant")
|
||||
@Test
|
||||
public void testGetMatchingDisplaynames() {
|
||||
String search = "testname";
|
||||
OfflinePlayer exp1 = MockUtils.mockPlayer();
|
||||
OfflinePlayer exp2 = MockUtils.mockPlayer2();
|
||||
Set<OfflinePlayer> result = MiscUtils.getMatchingDisplaynames(search);
|
||||
String exp1 = "TestName";
|
||||
String exp2 = "TestName2";
|
||||
List<String> result = MiscUtils.getMatchingPlayerNames(search);
|
||||
assertEquals(2, result.size());
|
||||
for (OfflinePlayer r : result) {
|
||||
boolean equalToExp1 = r.getName().equals(exp1.getName());
|
||||
boolean equalToExp2 = r.getName().equals(exp2.getName());
|
||||
if (!(equalToExp1 || equalToExp2)) {
|
||||
fail("Unknown result!: " + r.getName());
|
||||
}
|
||||
}
|
||||
assertEquals(exp1, result.get(0));
|
||||
assertEquals(exp2, result.get(1));
|
||||
}
|
||||
|
||||
/**
|
||||
@ -151,13 +144,9 @@ public class MiscUtilsTest {
|
||||
@Test
|
||||
public void testGetMatchingDisplaynames2() {
|
||||
String search = "2";
|
||||
OfflinePlayer exp2 = MockUtils.mockPlayer2();
|
||||
Set<OfflinePlayer> result = MiscUtils.getMatchingDisplaynames(search);
|
||||
String exp2 = "TestName2";
|
||||
List<String> result = MiscUtils.getMatchingPlayerNames(search);
|
||||
assertEquals(1, result.size());
|
||||
for (OfflinePlayer r : result) {
|
||||
if (!r.getName().equals(exp2.getName())) {
|
||||
fail("Unknown result!: " + r.getName());
|
||||
}
|
||||
}
|
||||
assertEquals(exp2, result.get(0));
|
||||
}
|
||||
}
|
||||
|
@ -5,16 +5,17 @@
|
||||
*/
|
||||
package test.java.main.java.com.djrapitops.plan.utilities;
|
||||
|
||||
import com.djrapitops.javaplugin.utilities.player.BukkitOfflinePlayer;
|
||||
import com.djrapitops.javaplugin.utilities.player.BukkitPlayer;
|
||||
import com.djrapitops.javaplugin.utilities.player.Gamemode;
|
||||
import com.djrapitops.javaplugin.utilities.player.IOfflinePlayer;
|
||||
import com.djrapitops.javaplugin.utilities.player.IPlayer;
|
||||
import main.java.com.djrapitops.plan.data.DemographicsData;
|
||||
import main.java.com.djrapitops.plan.data.UserData;
|
||||
import main.java.com.djrapitops.plan.utilities.MiscUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.NewPlayerCreator;
|
||||
import org.bukkit.GameMode;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.junit.After;
|
||||
import static org.junit.Assert.assertTrue;
|
||||
import org.junit.Before;
|
||||
import org.junit.Test;
|
||||
import org.junit.runner.RunWith;
|
||||
@ -22,6 +23,7 @@ import org.powermock.core.classloader.annotations.PrepareForTest;
|
||||
import org.powermock.modules.junit4.PowerMockRunner;
|
||||
import test.java.utils.MockUtils;
|
||||
import test.java.utils.TestInit;
|
||||
import static org.junit.Assert.*;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -58,10 +60,10 @@ public class NewPlayerCreatorTest {
|
||||
*/
|
||||
@Test
|
||||
public void testCreateNewPlayer_Player() {
|
||||
OfflinePlayer p = MockUtils.mockPlayer2();
|
||||
UserData result = NewPlayerCreator.createNewPlayer(p);
|
||||
IOfflinePlayer p = BukkitOfflinePlayer.wrap(MockUtils.mockPlayer2());
|
||||
UserData result = NewPlayerCreator.createNewOfflinePlayer(p);
|
||||
UserData exp = new UserData(p, new DemographicsData());
|
||||
exp.setLastGamemode(GameMode.SURVIVAL);
|
||||
exp.setLastGamemode(Gamemode.SURVIVAL);
|
||||
exp.setLastPlayed(MiscUtils.getTime());
|
||||
long zero = Long.parseLong("0");
|
||||
exp.setPlayTime(zero);
|
||||
@ -78,10 +80,10 @@ public class NewPlayerCreatorTest {
|
||||
*/
|
||||
@Test
|
||||
public void testCreateNewPlayer_OfflinePlayer() {
|
||||
Player p = MockUtils.mockPlayer2();
|
||||
IPlayer p = BukkitPlayer.wrap(MockUtils.mockPlayer2());
|
||||
UserData result = NewPlayerCreator.createNewPlayer(p);
|
||||
UserData exp = new UserData(p, new DemographicsData());
|
||||
exp.setLastGamemode(GameMode.SPECTATOR);
|
||||
exp.setLastGamemode(Gamemode.SPECTATOR);
|
||||
exp.setLastPlayed(MiscUtils.getTime());
|
||||
long zero = Long.parseLong("0");
|
||||
exp.setPlayTime(zero);
|
||||
@ -97,11 +99,11 @@ public class NewPlayerCreatorTest {
|
||||
*
|
||||
*/
|
||||
@Test
|
||||
public void testCreateNewPlayer_OfflinePlayer_GameMode() {
|
||||
Player p = MockUtils.mockPlayer();
|
||||
UserData result = NewPlayerCreator.createNewPlayer(p, GameMode.CREATIVE);
|
||||
public void testCreateNewPlayer_OfflinePlayer_Gamemode() {
|
||||
IOfflinePlayer p = BukkitOfflinePlayer.wrap(MockUtils.mockPlayer());
|
||||
UserData result = NewPlayerCreator.createNewPlayer(p, Gamemode.CREATIVE);
|
||||
UserData exp = new UserData(p, new DemographicsData());
|
||||
exp.setLastGamemode(GameMode.CREATIVE);
|
||||
exp.setLastGamemode(Gamemode.CREATIVE);
|
||||
exp.setLastPlayed(MiscUtils.getTime());
|
||||
long zero = Long.parseLong("0");
|
||||
exp.setPlayTime(zero);
|
||||
|
@ -5,13 +5,13 @@
|
||||
*/
|
||||
package test.java.main.java.com.djrapitops.plan.utilities.comparators;
|
||||
|
||||
import com.djrapitops.javaplugin.utilities.player.Gamemode;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import main.java.com.djrapitops.plan.data.handling.info.GamemodeInfo;
|
||||
import main.java.com.djrapitops.plan.data.handling.info.HandlingInfo;
|
||||
import main.java.com.djrapitops.plan.utilities.comparators.HandlingInfoTimeComparator;
|
||||
import org.bukkit.GameMode;
|
||||
import static org.junit.Assert.assertEquals;
|
||||
import org.junit.Test;
|
||||
|
||||
@ -33,13 +33,13 @@ public class HandlingInfoTimeComparatorTest {
|
||||
@Test
|
||||
public void testCompare() {
|
||||
List<HandlingInfo> i = new ArrayList<>();
|
||||
GamemodeInfo one = new GamemodeInfo(null, 500L, GameMode.CREATIVE);
|
||||
GamemodeInfo one = new GamemodeInfo(null, 500L, Gamemode.CREATIVE);
|
||||
i.add(one);
|
||||
GamemodeInfo two = new GamemodeInfo(null, 400L, GameMode.CREATIVE);
|
||||
GamemodeInfo two = new GamemodeInfo(null, 400L, Gamemode.CREATIVE);
|
||||
i.add(two);
|
||||
GamemodeInfo three = new GamemodeInfo(null, 100L, GameMode.CREATIVE);
|
||||
GamemodeInfo three = new GamemodeInfo(null, 100L, Gamemode.CREATIVE);
|
||||
i.add(three);
|
||||
GamemodeInfo four = new GamemodeInfo(null, 700L, GameMode.CREATIVE);
|
||||
GamemodeInfo four = new GamemodeInfo(null, 700L, Gamemode.CREATIVE);
|
||||
i.add(four);
|
||||
Collections.sort(i, new HandlingInfoTimeComparator());
|
||||
assertEquals(three, i.get(0));
|
||||
|
@ -7,7 +7,9 @@ package test.java.utils;
|
||||
|
||||
import com.djrapitops.javaplugin.status.ProcessStatus;
|
||||
import com.djrapitops.javaplugin.utilities.BenchmarkUtil;
|
||||
import com.djrapitops.javaplugin.utilities.compatibility.CompatibilityUtility;
|
||||
import com.djrapitops.javaplugin.utilities.log.BukkitLog;
|
||||
import com.djrapitops.javaplugin.utilities.player.Fetch;
|
||||
import java.io.File;
|
||||
import java.io.FileInputStream;
|
||||
import java.nio.file.Files;
|
||||
@ -15,6 +17,7 @@ import java.util.logging.Logger;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.ServerVariableHolder;
|
||||
import main.java.com.djrapitops.plan.Settings;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.Server;
|
||||
import org.bukkit.configuration.file.YamlConfiguration;
|
||||
import org.powermock.api.mockito.PowerMockito;
|
||||
@ -42,6 +45,8 @@ public class TestInit {
|
||||
try {
|
||||
planMock = PowerMockito.mock(Plan.class);
|
||||
Plan.setInstance(Plan.class, planMock);
|
||||
Plan.setInstance(planMock.getClass(), planMock);
|
||||
CompatibilityUtility.setUtilityProviderPluginClass(planMock.getClass());
|
||||
File configfile = new File(getClass().getResource("/config.yml").getPath());
|
||||
YamlConfiguration configuration = new YamlConfiguration();
|
||||
configuration.load(configfile.getAbsolutePath());
|
||||
@ -65,7 +70,9 @@ public class TestInit {
|
||||
Server mockServer = PowerMockito.mock(Server.class);
|
||||
when(mockServer.getIp()).thenReturn("0.0.0.0");
|
||||
when(mockServer.getMaxPlayers()).thenReturn(20);
|
||||
// Mockito.doReturn("0.0.0.0").when(mockServer).getIp();
|
||||
OfflinePlayer[] ops = new OfflinePlayer[]{MockUtils.mockPlayer(), MockUtils.mockPlayer2()};
|
||||
when(mockServer.getOfflinePlayers()).thenReturn(ops);
|
||||
|
||||
when(planMock.getServer()).thenReturn(mockServer);
|
||||
when(planMock.getLogger()).thenReturn(Logger.getGlobal());
|
||||
BukkitLog<Plan> log = new BukkitLog(planMock, "console", "");
|
||||
@ -76,6 +83,8 @@ public class TestInit {
|
||||
when(planMock.getVariable()).thenReturn(serverVariableHolder);
|
||||
ProcessStatus<Plan> process = new ProcessStatus(planMock);
|
||||
when(planMock.processStatus()).thenReturn(process);
|
||||
Fetch fetch = new Fetch(planMock);
|
||||
when(planMock.fetch()).thenReturn(fetch);
|
||||
// Mockito.doReturn("0.0.0.0").when(planMock).getServer().getIp();
|
||||
Settings.DEBUG.setValue(true);
|
||||
return true;
|
||||
|
Loading…
x
Reference in New Issue
Block a user