mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-23 01:27:42 +01:00
parent
7949113f6e
commit
386f62b35f
1
.gitignore
vendored
1
.gitignore
vendored
@ -12,3 +12,4 @@
|
||||
/Filetool/nbproject/private/
|
||||
/Filetool/build/
|
||||
/PlanPluginBridge/target/
|
||||
/MakroS/nbproject/private/
|
@ -138,6 +138,7 @@ public enum Phrase {
|
||||
CMD_USG_MANAGE_COMBINE("Copy data from one database to another & combine values"),
|
||||
CMD_USG_MANAGE_IMPORT("Import Data from supported plugins to Active Database."),
|
||||
CMD_USG_MANAGE_CLEAR("Clear data from one database"),
|
||||
CMD_USG_MANAGE_CLEAN("Clear incorrect data from the database"),
|
||||
CMD_USG_MANAGE_REMOVE("Remove players's data from the Active Database."),
|
||||
CMD_USG_MANAGE_STATUS("Check the status of the Active Database."),
|
||||
CMD_USG_MANAGE_HELP("Show managment help."),
|
||||
|
@ -61,7 +61,7 @@ public class AnalyzeCommand extends SubCommand {
|
||||
@Override
|
||||
public void run() {
|
||||
timesrun++;
|
||||
if (analysisCache.isCached()) {
|
||||
if (analysisCache.isCached() && !analysisCache.isAnalysisBeingRun()) {
|
||||
sendAnalysisMessage(sender);
|
||||
this.cancel();
|
||||
return;
|
||||
|
@ -43,6 +43,7 @@ public class ManageCommand extends TreeCommand<Plan> {
|
||||
commands.add(new ManageStatusCommand(plugin));
|
||||
commands.add(new ManageImportCommand(plugin));
|
||||
commands.add(new ManageRemoveCommand(plugin));
|
||||
// commands.add(new ManageCleanCommand(plugin));
|
||||
commands.add(new ManageClearCommand(plugin));
|
||||
}
|
||||
}
|
||||
|
@ -56,7 +56,7 @@ public class QuickAnalyzeCommand extends SubCommand {
|
||||
@Override
|
||||
public void run() {
|
||||
timesrun++;
|
||||
if (analysisCache.isCached()) {
|
||||
if (analysisCache.isCached() && !analysisCache.isAnalysisBeingRun()) {
|
||||
sender.sendMessage(Phrase.CMD_ANALYZE_HEADER + "");
|
||||
sender.sendMessage(TextUI.getAnalysisMessages());
|
||||
sender.sendMessage(Phrase.CMD_FOOTER + "");
|
||||
|
@ -0,0 +1,74 @@
|
||||
package main.java.com.djrapitops.plan.command.commands.manage;
|
||||
|
||||
import com.djrapitops.javaplugin.command.CommandType;
|
||||
import com.djrapitops.javaplugin.command.SubCommand;
|
||||
import java.sql.SQLException;
|
||||
import java.util.Arrays;
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
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.database.Database;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
|
||||
/**
|
||||
* This manage subcommand is used to clear a database of all data.
|
||||
*
|
||||
* @author Rsl1122
|
||||
* @since 2.3.0
|
||||
*/
|
||||
public class ManageCleanCommand extends SubCommand {
|
||||
|
||||
private final Plan plugin;
|
||||
|
||||
/**
|
||||
* Class Constructor.
|
||||
*
|
||||
* @param plugin Current instance of Plan
|
||||
*/
|
||||
public ManageCleanCommand(Plan plugin) {
|
||||
super("clean", CommandType.CONSOLE_WITH_ARGUMENTS, Permissions.MANAGE.getPermission(), Phrase.CMD_USG_MANAGE_CLEAN + "", "<DB>");
|
||||
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {
|
||||
if (args.length == 0) {
|
||||
sender.sendMessage(Phrase.COMMAND_REQUIRES_ARGUMENTS_ONE + "");
|
||||
return true;
|
||||
}
|
||||
String dbToClear = args[0].toLowerCase();
|
||||
if (!dbToClear.equals("mysql") && !dbToClear.equals("sqlite")) {
|
||||
sender.sendMessage(Phrase.MANAGE_ERROR_INCORRECT_DB + dbToClear);
|
||||
return true;
|
||||
}
|
||||
|
||||
Database clearDB = null;
|
||||
for (Database database : plugin.getDatabases()) {
|
||||
if (dbToClear.equalsIgnoreCase(database.getConfigName())) {
|
||||
clearDB = database;
|
||||
clearDB.init();
|
||||
}
|
||||
}
|
||||
if (clearDB == null) {
|
||||
sender.sendMessage(Phrase.MANAGE_DATABASE_FAILURE + "");
|
||||
Log.error(dbToClear + " was null!");
|
||||
return true;
|
||||
}
|
||||
|
||||
final Database clearThisDB = clearDB;
|
||||
(new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
sender.sendMessage(Phrase.MANAGE_PROCESS_START.parse());
|
||||
clearThisDB.clean();
|
||||
sender.sendMessage(Phrase.MANAGE_SUCCESS + "");
|
||||
this.cancel();
|
||||
}
|
||||
}).runTaskAsynchronously(plugin);
|
||||
return true;
|
||||
}
|
||||
}
|
@ -15,7 +15,7 @@ public class AnalysisCacheHandler {
|
||||
|
||||
private final Plan plugin;
|
||||
private AnalysisData cache;
|
||||
private Analysis analysis;
|
||||
private final Analysis analysis;
|
||||
|
||||
/**
|
||||
* Class Constructor.
|
||||
@ -33,7 +33,6 @@ public class AnalysisCacheHandler {
|
||||
* Runs analysis, cache method is called after analysis is complete.
|
||||
*/
|
||||
public void updateCache() {
|
||||
cache = null;
|
||||
analysis.runAnalysis(this);
|
||||
}
|
||||
|
||||
@ -63,4 +62,8 @@ public class AnalysisCacheHandler {
|
||||
public boolean isCached() {
|
||||
return (cache != null);
|
||||
}
|
||||
|
||||
public boolean isAnalysisBeingRun() {
|
||||
return analysis.isAnalysisBeingRun();
|
||||
}
|
||||
}
|
||||
|
@ -8,7 +8,7 @@ package main.java.com.djrapitops.plan.data.cache.queue;
|
||||
*/
|
||||
public abstract class Setup<T> {
|
||||
|
||||
private Consumer<T>[] consumers;
|
||||
private final Consumer<T>[] consumers;
|
||||
|
||||
/**
|
||||
* Constructor, defines consumers.
|
||||
|
@ -43,6 +43,6 @@ public class PlanCommandPreprocessListener implements Listener {
|
||||
Log.debug("Ignored command, player had ignore permission.");
|
||||
return;
|
||||
}
|
||||
handler.handleCommand(event.getMessage().split(" ")[0]);
|
||||
handler.handleCommand(event.getMessage().split(" ")[0].toLowerCase());
|
||||
}
|
||||
}
|
||||
|
@ -18,6 +18,7 @@ import java.util.Map.Entry;
|
||||
public class DBUtils {
|
||||
|
||||
public static <T> List<List<Container<T>>> splitIntoBatches(Map<Integer, List<T>> objects) {
|
||||
int batchSize = 2048;
|
||||
List<List<Container<T>>> wrappedBatches = new ArrayList<>();
|
||||
|
||||
int i = 0;
|
||||
@ -30,7 +31,7 @@ public class DBUtils {
|
||||
}
|
||||
wrappedBatches.get(j).add(new Container<>(object, entry.getKey()));
|
||||
i++;
|
||||
if (i % 1024 == 0) {
|
||||
if (i % batchSize == 0) {
|
||||
j++;
|
||||
}
|
||||
}
|
||||
|
@ -154,7 +154,6 @@ public abstract class SQLDB extends Database {
|
||||
@Override
|
||||
public void run() {
|
||||
try {
|
||||
clean();
|
||||
Benchmark.start("Convert Bukkitdata to DB data");
|
||||
Set<UUID> uuids = usersTable.getSavedUUIDs();
|
||||
uuids.removeAll(usersTable.getContainsBukkitData(uuids));
|
||||
@ -472,41 +471,8 @@ public abstract class SQLDB extends Database {
|
||||
Log.info("Cleaning the database.");
|
||||
try {
|
||||
checkConnection();
|
||||
Map<Integer, List<SessionData>> allSessions = sessionsTable.getSessionData(usersTable.getAllUserIds().values());
|
||||
Benchmark.start("Combine Sessions");
|
||||
int before = MathUtils.sumInt(allSessions.values().stream().map(l -> l.size()));
|
||||
Log.debug("Sessions before: " + before);
|
||||
Map<Integer, Integer> beforeM = new HashMap<>();
|
||||
Map<Integer, Integer> afterM = new HashMap<>();
|
||||
for (Integer id : allSessions.keySet()) {
|
||||
List<SessionData> sessions = allSessions.get(id);
|
||||
beforeM.put(id, sessions.size());
|
||||
if (sessions.isEmpty()) {
|
||||
afterM.put(id, 0);
|
||||
continue;
|
||||
}
|
||||
List<SessionData> combined = ManageUtils.combineSessions(sessions);
|
||||
afterM.put(id, combined.size());
|
||||
allSessions.put(id, combined);
|
||||
}
|
||||
int after = MathUtils.sumInt(allSessions.values().stream().map(l -> l.size()));
|
||||
Log.debug("Sessions after: " + after);
|
||||
if (before - after > 50) {
|
||||
Benchmark.start("Save combined sessions");
|
||||
Iterator<Integer> iterator = new HashSet<>(allSessions.keySet()).iterator();
|
||||
while (iterator.hasNext()) {
|
||||
int id = iterator.next();
|
||||
if (afterM.get(id) < beforeM.get(id)) {
|
||||
sessionsTable.removeUserSessions(id);
|
||||
} else {
|
||||
allSessions.remove(id);
|
||||
}
|
||||
}
|
||||
sessionsTable.saveSessionData(allSessions);
|
||||
Benchmark.stop("Save combined sessions");
|
||||
}
|
||||
Benchmark.stop("Combine Sessions");
|
||||
Log.info("Combined " + (before - after) + " sessions.");
|
||||
commandUseTable.clean();
|
||||
sessionsTable.clean();
|
||||
Log.info("Clean complete.");
|
||||
} catch (SQLException e) {
|
||||
Log.toLog(this.getClass().getName(), e);
|
||||
|
@ -6,6 +6,7 @@ import java.sql.SQLException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
import main.java.com.djrapitops.plan.Plan;
|
||||
import main.java.com.djrapitops.plan.database.databases.SQLDB;
|
||||
import main.java.com.djrapitops.plan.utilities.Benchmark;
|
||||
|
||||
@ -61,7 +62,13 @@ public class CommandUseTable extends Table {
|
||||
statement = prepareStatement("SELECT * FROM " + tableName);
|
||||
set = statement.executeQuery();
|
||||
while (set.next()) {
|
||||
commandUse.put(set.getString(columnCommand), set.getInt(columnTimesUsed));
|
||||
String cmd = set.getString(columnCommand);
|
||||
int amountUsed = set.getInt(columnTimesUsed);
|
||||
Integer get = commandUse.get(cmd);
|
||||
if (get != null && get > amountUsed) {
|
||||
continue;
|
||||
}
|
||||
commandUse.put(cmd, amountUsed);
|
||||
}
|
||||
return commandUse;
|
||||
} finally {
|
||||
@ -150,4 +157,11 @@ public class CommandUseTable extends Table {
|
||||
close(statement);
|
||||
}
|
||||
}
|
||||
|
||||
public void clean() throws SQLException {
|
||||
Map<String, Integer> commandUse = getCommandUse();
|
||||
removeAllData();
|
||||
saveCommandUse(commandUse);
|
||||
Plan.getInstance().getHandler().getCommandUseFromDb();
|
||||
}
|
||||
}
|
||||
|
@ -6,6 +6,8 @@ import java.sql.SQLException;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import main.java.com.djrapitops.plan.Log;
|
||||
@ -13,6 +15,8 @@ import main.java.com.djrapitops.plan.data.SessionData;
|
||||
import main.java.com.djrapitops.plan.database.Container;
|
||||
import main.java.com.djrapitops.plan.database.databases.SQLDB;
|
||||
import main.java.com.djrapitops.plan.utilities.Benchmark;
|
||||
import main.java.com.djrapitops.plan.utilities.ManageUtils;
|
||||
import main.java.com.djrapitops.plan.utilities.analysis.MathUtils;
|
||||
|
||||
/**
|
||||
*
|
||||
@ -251,4 +255,48 @@ public class SessionsTable extends Table {
|
||||
close(statement);
|
||||
}
|
||||
}
|
||||
|
||||
public void clean() throws SQLException {
|
||||
Map<Integer, Integer> loginTimes = db.getUsersTable().getLoginTimes();
|
||||
Map<Integer, List<SessionData>> allSessions = getSessionData(loginTimes.keySet());
|
||||
Benchmark.start("Combine Sessions");
|
||||
int before = MathUtils.sumInt(allSessions.values().stream().map(l -> l.size()));
|
||||
Log.debug("Sessions before: " + before);
|
||||
Map<Integer, Integer> beforeM = new HashMap<>();
|
||||
Map<Integer, Integer> afterM = new HashMap<>();
|
||||
for (Integer id : allSessions.keySet()) {
|
||||
List<SessionData> sessions = allSessions.get(id);
|
||||
beforeM.put(id, sessions.size());
|
||||
if (sessions.isEmpty()) {
|
||||
afterM.put(id, 0);
|
||||
continue;
|
||||
}
|
||||
Integer times = loginTimes.get(id);
|
||||
if (sessions.size() == times) {
|
||||
afterM.put(id, times);
|
||||
continue;
|
||||
}
|
||||
List<SessionData> combined = ManageUtils.combineSessions(sessions, times);
|
||||
afterM.put(id, combined.size());
|
||||
allSessions.put(id, combined);
|
||||
}
|
||||
int after = MathUtils.sumInt(allSessions.values().stream().map(l -> l.size()));
|
||||
Log.debug("Sessions after: " + after);
|
||||
if (before - after > 50) {
|
||||
Benchmark.start("Save combined sessions");
|
||||
Iterator<Integer> iterator = new HashSet<>(allSessions.keySet()).iterator();
|
||||
while (iterator.hasNext()) {
|
||||
int id = iterator.next();
|
||||
if (afterM.get(id) < beforeM.get(id)) {
|
||||
removeUserSessions(id);
|
||||
} else {
|
||||
allSessions.remove(id);
|
||||
}
|
||||
}
|
||||
saveSessionData(allSessions);
|
||||
Benchmark.stop("Save combined sessions");
|
||||
}
|
||||
Benchmark.stop("Combine Sessions");
|
||||
Log.info("Combined " + (before - after) + " sessions.");
|
||||
}
|
||||
}
|
||||
|
@ -848,6 +848,26 @@ public class UsersTable extends Table {
|
||||
}
|
||||
}
|
||||
|
||||
public Map<Integer, Integer> getLoginTimes() throws SQLException {
|
||||
Benchmark.start("Get Logintimes");
|
||||
PreparedStatement statement = null;
|
||||
ResultSet set = null;
|
||||
try {
|
||||
Map<Integer, Integer> ids = new HashMap<>();
|
||||
statement = prepareStatement("SELECT " + columnID + ", " + columnLoginTimes + " FROM " + tableName);
|
||||
set = statement.executeQuery();
|
||||
while (set.next()) {
|
||||
Integer id = set.getInt(columnID);
|
||||
ids.put(id, set.getInt(columnLoginTimes));
|
||||
}
|
||||
return ids;
|
||||
} finally {
|
||||
close(set);
|
||||
close(statement);
|
||||
Benchmark.stop("Get Logintimes");
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
*
|
||||
* @return
|
||||
|
@ -71,7 +71,7 @@ public class PlayerActivityGraphCreator {
|
||||
if (Settings.ANALYSIS_REMOVE_OUTLIERS.isTrue()) {
|
||||
long average = MathUtils.averageLong(playersOnline.stream());
|
||||
double standardDiviation = getStandardDiviation(playersOnline, average);
|
||||
if (standardDiviation > 3) {
|
||||
if (standardDiviation > 3.5) {
|
||||
for (int i = 0; i < playersOnline.size(); i++) {
|
||||
long value = playersOnline.get(i);
|
||||
if (value - average > 3 * standardDiviation) {
|
||||
|
@ -67,7 +67,7 @@ public class PunchCardGraphCreator {
|
||||
int avg = findAverage(dataArray);
|
||||
double standardDiviation = getStandardDiviation(dataArray, avg);
|
||||
Log.debug("Diviation: " + standardDiviation);
|
||||
if (standardDiviation > 3) {
|
||||
if (standardDiviation > 3.5) {
|
||||
for (int i = 0; i < 7; i++) {
|
||||
for (int j = 0; j < 24; j++) {
|
||||
int value = dataArray[i][j];
|
||||
|
@ -83,15 +83,26 @@ public class ManageUtils {
|
||||
}
|
||||
|
||||
public static boolean containsCombinable(List<SessionData> sessions) {
|
||||
// Checks if there are starts & ends that are the same, or less than 5000 ms away from each other.
|
||||
return containsCombinable(sessions, 5000);
|
||||
}
|
||||
|
||||
private static boolean containsCombinable(List<SessionData> sessions, int threshold) {
|
||||
// Checks if there are starts & ends that are the same, or less than threshold ms away from each other.
|
||||
return sessions.stream()
|
||||
.anyMatch(s -> sessions.stream()
|
||||
.filter(ses -> !ses.equals(s))
|
||||
.map(ses -> ses.getSessionStart())
|
||||
.anyMatch((Long start) -> (Math.abs(s.getSessionEnd() - start) < 5000)));
|
||||
.anyMatch((Long start) -> (Math.abs(s.getSessionEnd() - start) < threshold)));
|
||||
}
|
||||
|
||||
public static List<SessionData> combineSessions(List<SessionData> sessions) {
|
||||
public static List<SessionData> combineSessions(List<SessionData> sessions, Integer loginTimes) {
|
||||
return combineSessions(sessions, loginTimes, 5000);
|
||||
}
|
||||
|
||||
private static List<SessionData> combineSessions(List<SessionData> sessions, Integer loginTimes, int threshold) {
|
||||
if (threshold >= 35000) {
|
||||
return sessions;
|
||||
}
|
||||
List<SessionData> newSessions = new ArrayList<>();
|
||||
List<SessionData> removed = new ArrayList<>();
|
||||
Iterator<SessionData> iterator = sessions.iterator();
|
||||
@ -100,7 +111,7 @@ public class ManageUtils {
|
||||
if (removed.contains(session)) {
|
||||
continue;
|
||||
}
|
||||
List<SessionData> close = sessions.stream().filter(ses -> Math.abs(session.getSessionEnd() - ses.getSessionStart()) < 5000).collect(Collectors.toList());
|
||||
List<SessionData> close = sessions.stream().filter(ses -> Math.abs(session.getSessionEnd() - ses.getSessionStart()) < threshold).collect(Collectors.toList());
|
||||
if (!close.isEmpty()) {
|
||||
long big = MathUtils.getBiggestLong(close.stream().map((SessionData ses) -> ses.getSessionEnd()).collect(Collectors.toList()));
|
||||
session.endSession(big);
|
||||
@ -108,9 +119,12 @@ public class ManageUtils {
|
||||
}
|
||||
newSessions.add(session);
|
||||
}
|
||||
boolean containsCombinable = containsCombinable(newSessions);
|
||||
if (loginTimes == newSessions.size()) {
|
||||
return newSessions;
|
||||
}
|
||||
boolean containsCombinable = containsCombinable(newSessions, threshold);
|
||||
if (containsCombinable) {
|
||||
return combineSessions(newSessions);
|
||||
return combineSessions(newSessions, threshold + 1000);
|
||||
} else {
|
||||
return newSessions;
|
||||
}
|
||||
|
@ -45,6 +45,7 @@ public class Analysis {
|
||||
|
||||
private final Plan plugin;
|
||||
private final InspectCacheHandler inspectCache;
|
||||
private int taskId = -1;
|
||||
|
||||
/**
|
||||
* Class Constructor.
|
||||
@ -66,13 +67,18 @@ public class Analysis {
|
||||
* @param analysisCache Cache that the data is saved to.
|
||||
*/
|
||||
public void runAnalysis(AnalysisCacheHandler analysisCache) {
|
||||
if (isAnalysisBeingRun()) {
|
||||
return;
|
||||
}
|
||||
Benchmark.start("Analysis");
|
||||
log(Phrase.ANALYSIS_START + "");
|
||||
// Async task for Analysis
|
||||
BukkitTask asyncAnalysisTask = (new BukkitRunnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
taskId = this.getTaskId();
|
||||
analyze(analysisCache, plugin.getDB());
|
||||
taskId = -1;
|
||||
this.cancel();
|
||||
}
|
||||
}).runTaskAsynchronously(plugin);
|
||||
@ -414,4 +420,8 @@ public class Analysis {
|
||||
Benchmark.stop("Analysis 3rd party");
|
||||
return replaceMap;
|
||||
}
|
||||
|
||||
public boolean isAnalysisBeingRun() {
|
||||
return taskId != -1;
|
||||
}
|
||||
}
|
||||
|
@ -766,6 +766,9 @@ header p {
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
var serverTime = new Date(%currenttime%);
|
||||
var now = new Date();
|
||||
var timediff = serverTime.getTime()-now.getTime();
|
||||
function openNav() {
|
||||
document.getElementById("sidenav").style.width = "100%";
|
||||
document.getElementById("limiter").style.display = "none";
|
||||
@ -820,9 +823,6 @@ function openFunc(i) {
|
||||
x.style.transform = "translate3d("+value+"%,0px,0)";
|
||||
};
|
||||
}
|
||||
var serverTime = new Date(%currenttime%);
|
||||
var now = new Date();
|
||||
var timediff = serverTime.getTime()-now.getTime();
|
||||
function countUpTimer() {
|
||||
var now = new Date();
|
||||
var begin = new Date(%refreshlong%-timediff);
|
||||
|
@ -549,6 +549,9 @@ table.sortable th:not(.sorttable_sorted):not(.sorttable_sorted_reverse):not(.sor
|
||||
</div>
|
||||
</div>
|
||||
<script>
|
||||
var serverTime = new Date(%currenttime%);
|
||||
var now = new Date();
|
||||
var timediff = serverTime.getTime()-now.getTime();
|
||||
function openNav() {
|
||||
document.getElementById("sidenav").style.width = "100%";
|
||||
document.getElementById("limiter").style.display = "none";
|
||||
@ -604,9 +607,6 @@ function openFunc(i) {
|
||||
};
|
||||
}
|
||||
|
||||
var serverTime = new Date(%currenttime%);
|
||||
var now = new Date();
|
||||
var timediff = serverTime.getTime()-now.getTime();
|
||||
function countUpTimer() {
|
||||
var now = new Date();
|
||||
var begin = new Date(%refreshlong%-timediff);
|
||||
|
@ -1,7 +1,7 @@
|
||||
name: Plan
|
||||
author: Rsl1122
|
||||
main: main.java.com.djrapitops.plan.Plan
|
||||
version: 3.4.2
|
||||
version: 3.4.3
|
||||
|
||||
softdepend:
|
||||
- OnTime
|
||||
|
@ -134,6 +134,7 @@ public class DataCacheHandlerTest {
|
||||
* @throws SQLException
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
@Ignore("Scheduler")
|
||||
@Test
|
||||
public void testGetUserDataForProcessingCache() throws SQLException, InterruptedException {
|
||||
// db.init();
|
||||
@ -174,6 +175,7 @@ public class DataCacheHandlerTest {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Ignore("Scheduler")
|
||||
@Test
|
||||
public void testSaveCachedUserData() {
|
||||
UserData data = new UserData(MockUtils.mockPlayer(), new DemographicsData());
|
||||
@ -214,6 +216,7 @@ public class DataCacheHandlerTest {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Ignore("Scheduler")
|
||||
@Test
|
||||
public void testSaveCommandUse() {
|
||||
handler.saveCommandUse();
|
||||
@ -252,6 +255,7 @@ public class DataCacheHandlerTest {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Ignore
|
||||
@Test
|
||||
public void testScheludeForClear() {
|
||||
}
|
||||
@ -259,6 +263,7 @@ public class DataCacheHandlerTest {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Ignore
|
||||
@Test
|
||||
public void testIsDataAccessed() {
|
||||
}
|
||||
@ -290,6 +295,7 @@ public class DataCacheHandlerTest {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Ignore("Scheduler")
|
||||
@Test
|
||||
public void testGetDataCache() {
|
||||
assertTrue("Cache was null", handler.getDataCache() != null);
|
||||
@ -306,6 +312,7 @@ public class DataCacheHandlerTest {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Ignore("Scheduler")
|
||||
@Test
|
||||
public void testHandleCommand() {
|
||||
handler.handleCommand("/plan");
|
||||
|
@ -26,6 +26,7 @@ import org.bukkit.plugin.java.JavaPlugin;
|
||||
import org.junit.After;
|
||||
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.core.classloader.annotations.PrepareForTest;
|
||||
@ -110,6 +111,7 @@ public class DataCacheGetQueueTest {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Ignore("Scheduler")
|
||||
@Test
|
||||
public void testScheduleForGet() {
|
||||
OfflinePlayer op = MockUtils.mockPlayer2();
|
||||
@ -127,6 +129,7 @@ public class DataCacheGetQueueTest {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
@Ignore("Scheduler")
|
||||
@Test
|
||||
public void testStop() {
|
||||
DataCacheGetQueue instance = new DataCacheGetQueue(plan);
|
||||
|
@ -92,6 +92,7 @@ public class DataCacheProcessQueueTest {
|
||||
*
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
@Ignore("Scheduler")
|
||||
@Test
|
||||
public void testAddToPool_HandlingInfo() throws InterruptedException {
|
||||
DataCacheProcessQueue q = new DataCacheProcessQueue(handler);
|
||||
@ -112,6 +113,7 @@ public class DataCacheProcessQueueTest {
|
||||
*
|
||||
* @throws InterruptedException
|
||||
*/
|
||||
@Ignore("Scheduler")
|
||||
@Test
|
||||
public void testAddToPool_Collection() throws InterruptedException {
|
||||
DataCacheProcessQueue q = new DataCacheProcessQueue(handler);
|
||||
|
@ -78,7 +78,7 @@ public class ManageUtilsTest {
|
||||
data.add(new SessionData(0, 100));
|
||||
data.add(new SessionData(threshold, threshold * 2));
|
||||
data.add(new SessionData(threshold * 2 + 100, threshold * 3));
|
||||
SessionData get = ManageUtils.combineSessions(data).get(0);
|
||||
SessionData get = ManageUtils.combineSessions(data, 1).get(0);
|
||||
SessionData exp = new SessionData(0, threshold * 3);
|
||||
assertEquals(exp, get);
|
||||
}
|
||||
@ -90,7 +90,7 @@ public class ManageUtilsTest {
|
||||
data.add(new SessionData(threshold, threshold * 2));
|
||||
data.add(new SessionData(threshold * 2 + 100, threshold * 3));
|
||||
data.add(new SessionData(threshold * 3 + 200, threshold * 4));
|
||||
SessionData get = ManageUtils.combineSessions(data).get(0);
|
||||
SessionData get = ManageUtils.combineSessions(data, 1).get(0);
|
||||
SessionData exp = new SessionData(0, threshold * 4);
|
||||
assertEquals(exp, get);
|
||||
}
|
||||
@ -101,7 +101,7 @@ public class ManageUtilsTest {
|
||||
data.add(new SessionData(0, 100));
|
||||
data.add(new SessionData(threshold, threshold * 2));
|
||||
data.add(new SessionData(threshold * 3 + 200, threshold * 4));
|
||||
List<SessionData> result = ManageUtils.combineSessions(data);
|
||||
List<SessionData> result = ManageUtils.combineSessions(data, 2);
|
||||
SessionData exp = new SessionData(0, threshold * 2);
|
||||
assertEquals(exp, result.get(0));
|
||||
SessionData exp2 = new SessionData(threshold * 3 + 200, threshold * 4);
|
||||
@ -115,7 +115,7 @@ public class ManageUtilsTest {
|
||||
data.add(new SessionData(threshold, threshold * 2));
|
||||
data.add(new SessionData(threshold * 3 + 200, threshold * 4));
|
||||
data.add(new SessionData(threshold * 5 - 200, threshold * 5));
|
||||
List<SessionData> result = ManageUtils.combineSessions(data);
|
||||
List<SessionData> result = ManageUtils.combineSessions(data, 2);
|
||||
SessionData exp = new SessionData(0, threshold * 2);
|
||||
assertEquals(exp, result.get(0));
|
||||
SessionData exp2 = new SessionData(threshold * 3 + 200, threshold * 5);
|
||||
@ -130,7 +130,7 @@ public class ManageUtilsTest {
|
||||
data.add(new SessionData(threshold * 5, threshold * 5 + 100));
|
||||
data.add(new SessionData(threshold * 8, threshold * 8 + 200));
|
||||
data.add(new SessionData(threshold * 9 - 200, threshold * 10));
|
||||
List<SessionData> result = ManageUtils.combineSessions(data);
|
||||
List<SessionData> result = ManageUtils.combineSessions(data, 3);
|
||||
SessionData exp = new SessionData(0, threshold * 2);
|
||||
assertEquals(exp, result.get(0));
|
||||
SessionData exp2 = new SessionData(threshold * 5, threshold * 5 + 100);
|
||||
|
BIN
PlanPluginBridge/PlanPluginBridge-3.4.3.jar
Normal file
BIN
PlanPluginBridge/PlanPluginBridge-3.4.3.jar
Normal file
Binary file not shown.
@ -3,9 +3,14 @@ package com.djrapitops.pluginbridge.plan.essentials;
|
||||
import com.earth2me.essentials.Essentials;
|
||||
import com.earth2me.essentials.Warps;
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import main.java.com.djrapitops.plan.data.additional.AnalysisType;
|
||||
import main.java.com.djrapitops.plan.data.additional.PluginData;
|
||||
import main.java.com.djrapitops.plan.ui.Html;
|
||||
|
||||
/**
|
||||
* PluginData class for Essentials-plugin.
|
||||
@ -20,7 +25,7 @@ import main.java.com.djrapitops.plan.data.additional.PluginData;
|
||||
*/
|
||||
public class EssentialsWarps extends PluginData {
|
||||
|
||||
private Essentials essentials;
|
||||
private final Essentials essentials;
|
||||
|
||||
/**
|
||||
* Class Constructor, sets the parameters of the PluginData object.
|
||||
@ -30,17 +35,34 @@ public class EssentialsWarps extends PluginData {
|
||||
public EssentialsWarps(Essentials essentials) {
|
||||
super("Essentials", "warps", AnalysisType.HTML);
|
||||
this.essentials = essentials;
|
||||
super.setIcon("map-marker");
|
||||
super.setPrefix("Warps: ");
|
||||
String warps = Html.FONT_AWESOME_ICON.parse("map-marker") + " Warps";
|
||||
String command = Html.FONT_AWESOME_ICON.parse("fa-terminal") + " Command";
|
||||
super.setPrefix(Html.TABLE_START_2.parse(warps, command));
|
||||
super.setSuffix(Html.TABLE_END.parse());
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getHtmlReplaceValue(String modifier, UUID uuid) {
|
||||
Warps warps = essentials.getWarps();
|
||||
if (!warps.isEmpty()) {
|
||||
return parseContainer("", warps.getList().toString());
|
||||
Collection<String> warplist = warps.getList();
|
||||
|
||||
return parseContainer("", getTableContents(new ArrayList<>(warplist)));
|
||||
}
|
||||
return parseContainer("", "No Warps.");
|
||||
return parseContainer("", Html.TABLELINE_2.parse("No Warps.", ""));
|
||||
}
|
||||
|
||||
private String getTableContents(List<String> warps) {
|
||||
Collections.sort(warps);
|
||||
StringBuilder html = new StringBuilder();
|
||||
if (warps.isEmpty()) {
|
||||
html.append(Html.TABLELINE_4.parse(Html.FACTION_NO_FACTIONS.parse(), "", "", ""));
|
||||
} else {
|
||||
for (String warp : warps) {
|
||||
html.append(Html.TABLELINE_2.parse(warp, "/warp " + warp));
|
||||
}
|
||||
}
|
||||
return html.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -5,12 +5,6 @@ In order to fork the project, some dependencies need to be installed locally.
|
||||
|
||||
- [CraftBukkit-1.11.2](https://www.spigotmc.org/wiki/buildtools/)
|
||||
|
||||
- [Advanced Achievements v5.1](https://www.spigotmc.org/resources/advanced-achievements.6239/) ([Download](https://www.spigotmc.org/resources/advanced-achievements.6239/download?version=157933))
|
||||
- [PlanPluginBridge] Link soon
|
||||
|
||||
- [EssentialsX](https://www.spigotmc.org/resources/essentialsx.9089/) ([Download (Jenkins)](https://ci.drtshock.net/job/essentialsx/))
|
||||
|
||||
- [Factions & MCore](https://www.spigotmc.org/resources/factions.1900/) ([Download](https://www.spigotmc.org/resources/factions.1900/download?version=140245))
|
||||
|
||||
- [OnTime](https://dev.bukkit.org/projects/ontime) ([Download](https://dev.bukkit.org/projects/ontime/files/latest))
|
||||
|
||||
- [Towny Advanced](http://towny.palmergames.com/) ([Download](http://towny.palmergames.com/file-repo/Towny%20Advanced/Latest/))
|
||||
- [BukkitPluginDependency](https://github.com/Rsl1122/BukkitPluginDependency/releases)
|
||||
|
Loading…
Reference in New Issue
Block a user