[3.0.1] Merge pull request #82 from Rsl1122/Next-Version

Merge when new version is ready
This commit is contained in:
Rsl1122 2017-05-09 17:27:24 +03:00 committed by GitHub
commit 2bd8377d8a
57 changed files with 108 additions and 453 deletions

View File

@ -6,7 +6,6 @@ import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Scanner; import java.util.Scanner;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
/** /**
* Phrase contains every message that is used in placeholders or commands. The * Phrase contains every message that is used in placeholders or commands. The
@ -243,7 +242,7 @@ public enum Phrase {
String[] split = localeRow.split(" <> "); String[] split = localeRow.split(" <> ");
Phrase.valueOf(split[0]).setText(split[1]); Phrase.valueOf(split[0]).setText(split[1]);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
getPlugin(Plan.class).logError("There is a miswritten line in locale on line " + localeRows.indexOf(localeRow)); Log.error("There is a miswritten line in locale on line " + localeRows.indexOf(localeRow));
} }
} }
} catch (IOException e) { } catch (IOException e) {

View File

@ -149,7 +149,7 @@ public class Plan extends JavaPlugin {
} }
Bukkit.getScheduler().cancelTasks(this); Bukkit.getScheduler().cancelTasks(this);
if (handler != null) { if (handler != null) {
log(Phrase.CACHE_SAVE + ""); Log.info(Phrase.CACHE_SAVE + "");
ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1); ScheduledExecutorService scheduler = Executors.newScheduledThreadPool(1);
scheduler.execute(() -> { scheduler.execute(() -> {
handler.saveCacheOnDisable(); handler.saveCacheOnDisable();
@ -157,59 +157,7 @@ public class Plan extends JavaPlugin {
scheduler.shutdown(); scheduler.shutdown();
} }
log(Phrase.DISABLED + ""); Log.info(Phrase.DISABLED + "");
}
/**
* Logs the message to the console.
*
* @param message "Message" will show up as [INFO][Plan]: Message
*/
@Deprecated
public void log(String message) {
Log.info(message);
}
/**
* Logs an error message to the console.
*
* @param message "Message" will show up as [ERROR][Plan]: Message
*/
@Deprecated
public void logError(String message) {
Log.error(message);
}
/**
* Logs trace of caught Exception to Errors.txt & notifies on console.
*
* @param source Class name the exception was caught in.
* @param e Throwable, eg NullPointerException
*/
@Deprecated
public void toLog(String source, Throwable e) {
Log.toLog(source, e);
}
/**
* Logs multiple caught Errors to Errors.txt.
*
* @param source Class name the exception was caught in.
* @param e Collection of Throwables, eg NullPointerException
*/
@Deprecated
public void toLog(String source, Collection<Throwable> e) {
Log.toLog(source, e);
}
/**
* Logs a message to the Errors.txt with a timestamp.
*
* @param message Message to log to Errors.txt [timestamp] Message
*/
@Deprecated
public void toLog(String message) {
Log.toLog(message);
} }
/** /**
@ -252,11 +200,11 @@ public class Plan extends JavaPlugin {
} }
} }
if (db == null) { if (db == null) {
log(Phrase.DB_TYPE_DOES_NOT_EXIST.toString()); Log.info(Phrase.DB_TYPE_DOES_NOT_EXIST.toString());
return false; return false;
} }
if (!db.init()) { if (!db.init()) {
log(Phrase.DB_FAILURE_DISABLE.toString()); Log.info(Phrase.DB_FAILURE_DISABLE.toString());
setEnabled(false); setEnabled(false);
return false; return false;
} }
@ -278,11 +226,11 @@ public class Plan extends JavaPlugin {
} }
private void startBootAnalysisTask() throws IllegalStateException, IllegalArgumentException { private void startBootAnalysisTask() throws IllegalStateException, IllegalArgumentException {
log(Phrase.ANALYSIS_BOOT_NOTIFY + ""); Log.info(Phrase.ANALYSIS_BOOT_NOTIFY + "");
BukkitTask bootAnalysisTask = (new BukkitRunnable() { BukkitTask bootAnalysisTask = (new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
log(Phrase.ANALYSIS_BOOT + ""); Log.info(Phrase.ANALYSIS_BOOT + "");
analysisCache.updateCache(); analysisCache.updateCache();
this.cancel(); this.cancel();
} }
@ -410,18 +358,22 @@ public class Plan extends JavaPlugin {
localeFile.delete(); localeFile.delete();
} }
} catch (FileNotFoundException ex) { } catch (FileNotFoundException ex) {
logError("Attempted using locale that doesn't exist."); Log.error("Attempted using locale that doesn't exist.");
usingLocale = "Default: EN"; usingLocale = "Default: EN";
} catch (IOException e) { } catch (IOException e) {
} }
} else { } else {
usingLocale = "Default: EN"; usingLocale = "Default: EN";
} }
log("Using locale: " + usingLocale); Log.info("Using locale: " + usingLocale);
} }
public static Plan getInstance() { public static Plan getInstance() {
return PlanHolder.INSTANCE; Plan INSTANCE = PlanHolder.INSTANCE;
if (INSTANCE == null) {
throw new IllegalStateException("Plugin not enabled properly, Singleton instance is null.");
}
return INSTANCE;
} }
public static void setInstance(Plan plan) { public static void setInstance(Plan plan) {

View File

@ -1,5 +1,6 @@
package main.java.com.djrapitops.plan.command.commands.manage; package main.java.com.djrapitops.plan.command.commands.manage;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions; import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Phrase; import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
@ -65,7 +66,7 @@ public class ManageBackupCommand extends SubCommand {
} }
if (database == null) { if (database == null) {
sender.sendMessage(Phrase.MANAGE_DATABASE_FAILURE + ""); sender.sendMessage(Phrase.MANAGE_DATABASE_FAILURE + "");
plugin.logError(db + " was null!"); Log.error(db + " was null!");
return true; return true;
} }
final Database copyFromDB = database; final Database copyFromDB = database;

View File

@ -2,6 +2,7 @@ package main.java.com.djrapitops.plan.command.commands.manage;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Arrays; import java.util.Arrays;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions; import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Phrase; import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
@ -71,7 +72,7 @@ public class ManageClearCommand extends SubCommand {
} }
if (clearDB == null) { if (clearDB == null) {
sender.sendMessage(Phrase.MANAGE_DATABASE_FAILURE + ""); sender.sendMessage(Phrase.MANAGE_DATABASE_FAILURE + "");
plugin.logError(dbToClear + " was null!"); Log.error(dbToClear + " was null!");
return true; return true;
} }
@ -87,7 +88,7 @@ public class ManageClearCommand extends SubCommand {
sender.sendMessage(Phrase.MANAGE_PROCESS_FAIL + ""); sender.sendMessage(Phrase.MANAGE_PROCESS_FAIL + "");
} }
} catch (SQLException e) { } catch (SQLException e) {
plugin.toLog(this.getClass().getName(), e); Log.toLog(this.getClass().getName(), e);
sender.sendMessage(Phrase.MANAGE_PROCESS_FAIL + ""); sender.sendMessage(Phrase.MANAGE_PROCESS_FAIL + "");
} }
this.cancel(); this.cancel();

View File

@ -1,6 +1,7 @@
package main.java.com.djrapitops.plan.command.commands.manage; package main.java.com.djrapitops.plan.command.commands.manage;
import java.sql.SQLException; import java.sql.SQLException;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions; import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Phrase; import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
@ -63,7 +64,7 @@ public class ManageHotswapCommand extends SubCommand {
} }
} }
} catch (NullPointerException | SQLException e) { } catch (NullPointerException | SQLException e) {
plugin.toLog(this.getClass().getName(), e); Log.toLog(this.getClass().getName(), e);
sender.sendMessage(Phrase.MANAGE_DATABASE_FAILURE + ""); sender.sendMessage(Phrase.MANAGE_DATABASE_FAILURE + "");
return true; return true;
} }

View File

@ -3,6 +3,7 @@ package main.java.com.djrapitops.plan.command.commands.manage;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.UUID; import java.util.UUID;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions; import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Phrase; import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
@ -76,12 +77,12 @@ public class ManageMoveCommand extends SubCommand {
} }
if (fromDatabase == null) { if (fromDatabase == null) {
sender.sendMessage(Phrase.MANAGE_DATABASE_FAILURE + ""); sender.sendMessage(Phrase.MANAGE_DATABASE_FAILURE + "");
plugin.logError(fromDB + " was null!"); Log.error(fromDB + " was null!");
return true; return true;
} }
if (toDatabase == null) { if (toDatabase == null) {
sender.sendMessage(Phrase.MANAGE_DATABASE_FAILURE + ""); sender.sendMessage(Phrase.MANAGE_DATABASE_FAILURE + "");
plugin.logError(toDB + " was null!"); Log.error(toDB + " was null!");
return true; return true;
} }

View File

@ -3,6 +3,7 @@ package main.java.com.djrapitops.plan.command.commands.manage;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.Arrays; import java.util.Arrays;
import java.util.UUID; import java.util.UUID;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions; import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Phrase; import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
@ -82,7 +83,7 @@ public class ManageRemoveCommand extends SubCommand {
sender.sendMessage(Phrase.MANAGE_PROCESS_FAIL + ""); sender.sendMessage(Phrase.MANAGE_PROCESS_FAIL + "");
} }
} catch (SQLException e) { } catch (SQLException e) {
plugin.toLog(this.getClass().getName(), e); Log.toLog(this.getClass().getName(), e);
sender.sendMessage(Phrase.MANAGE_PROCESS_FAIL + ""); sender.sendMessage(Phrase.MANAGE_PROCESS_FAIL + "");
} }
this.cancel(); this.cancel();

View File

@ -4,6 +4,7 @@ import java.io.File;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collection; import java.util.Collection;
import java.util.UUID; import java.util.UUID;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions; import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Phrase; import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
@ -66,7 +67,7 @@ public class ManageRestoreCommand extends SubCommand {
} }
if (database == null) { if (database == null) {
sender.sendMessage(Phrase.MANAGE_DATABASE_FAILURE + ""); sender.sendMessage(Phrase.MANAGE_DATABASE_FAILURE + "");
plugin.logError(db + " was null!"); Log.error(db + " was null!");
return true; return true;
} }
final Database copyToDB = database; final Database copyToDB = database;

View File

@ -26,7 +26,6 @@ import main.java.com.djrapitops.plan.utilities.comparators.HandlingInfoTimeCompa
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.scheduler.BukkitTask; import org.bukkit.scheduler.BukkitTask;
import static org.bukkit.Bukkit.getOfflinePlayer; import static org.bukkit.Bukkit.getOfflinePlayer;
@ -127,7 +126,7 @@ public class DataCacheHandler extends LocationCache {
BukkitTask asyncPeriodicCacheSaveTask = (new BukkitRunnable() { BukkitTask asyncPeriodicCacheSaveTask = (new BukkitRunnable() {
@Override @Override
public void run() { public void run() {
DataCacheHandler handler = getPlugin(Plan.class).getHandler(); DataCacheHandler handler = Plan.getInstance().getHandler();
handler.saveHandlerDataToCache(); handler.saveHandlerDataToCache();
handler.saveCachedUserData(); handler.saveCachedUserData();
if (timesSaved % clearAfterXsaves == 0) { if (timesSaved % clearAfterXsaves == 0) {

View File

@ -40,7 +40,7 @@ public class DataCacheProcessQueue {
try { try {
queue.add(info); queue.add(info);
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
// getPlugin(Plan.class).logError(Phrase.ERROR_TOO_SMALL_QUEUE.parse("Save Queue", Settings.PROCESS_SAVE_LIMIT.getNumber() + "")); Log.toLog(this.getClass().getName(), e);
} }
} }
@ -52,7 +52,7 @@ public class DataCacheProcessQueue {
try { try {
queue.addAll(info); queue.addAll(info);
} catch (IllegalStateException e) { } catch (IllegalStateException e) {
// getPlugin(Plan.class).logError(Phrase.ERROR_TOO_SMALL_QUEUE.parse("Save Queue", Settings.PROCESS_SAVE_LIMIT.getNumber() + "")); Log.toLog(this.getClass().getName(), e);
} }
} }

View File

@ -7,12 +7,12 @@ package main.java.com.djrapitops.plan.data.handling;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.UUID; import java.util.UUID;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.KillData; import main.java.com.djrapitops.plan.data.KillData;
import main.java.com.djrapitops.plan.data.UserData; import main.java.com.djrapitops.plan.data.UserData;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
/** /**
* *
@ -28,7 +28,7 @@ public class KillHandling {
* @param weaponName * @param weaponName
*/ */
public static void processKillInfo(UserData data, long time, LivingEntity dead, String weaponName) { public static void processKillInfo(UserData data, long time, LivingEntity dead, String weaponName) {
Plan plugin = getPlugin(Plan.class); Plan plugin = Plan.getInstance();
if (dead instanceof Player) { if (dead instanceof Player) {
Player deadPlayer = (Player) dead; Player deadPlayer = (Player) dead;
int victimID; int victimID;
@ -40,7 +40,7 @@ public class KillHandling {
} }
data.addPlayerKill(new KillData(victimUUID, victimID, weaponName, time)); data.addPlayerKill(new KillData(victimUUID, victimID, weaponName, time));
} catch (SQLException e) { } catch (SQLException e) {
plugin.toLog("main.java.com.djrapitops.plan.KillHandling", e); Log.toLog("main.java.com.djrapitops.plan.KillHandling", e);
} }
} else { } else {
data.setMobKills(data.getMobKills() + 1); data.setMobKills(data.getMobKills() + 1);

View File

@ -3,10 +3,10 @@ package main.java.com.djrapitops.plan.database.databases;
import java.sql.Connection; import java.sql.Connection;
import java.sql.DriverManager; import java.sql.DriverManager;
import java.sql.SQLException; import java.sql.SQLException;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Phrase; import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import org.bukkit.configuration.file.FileConfiguration; import org.bukkit.configuration.file.FileConfiguration;
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
/** /**
* *
@ -30,7 +30,7 @@ public class MySQLDB extends SQLDB {
*/ */
@Override @Override
public Connection getNewConnection() { public Connection getNewConnection() {
FileConfiguration config = getPlugin(Plan.class).getConfig(); FileConfiguration config = Plan.getInstance().getConfig();
try { try {
Class.forName("com.mysql.jdbc.Driver"); Class.forName("com.mysql.jdbc.Driver");
@ -40,7 +40,7 @@ public class MySQLDB extends SQLDB {
return connection; return connection;
} catch (ClassNotFoundException | SQLException e) { } catch (ClassNotFoundException | SQLException e) {
getPlugin(Plan.class).logError(Phrase.DB_CONNECTION_FAIL.parse(getConfigName(), e.getMessage())); Log.error(Phrase.DB_CONNECTION_FAIL.parse(getConfigName(), e.getMessage()));
return null; return null;
} }
} }

View File

@ -501,7 +501,7 @@ public abstract class SQLDB extends Database {
try { try {
checkConnection(); checkConnection();
} catch (SQLException e) { } catch (SQLException e) {
plugin.toLog(this.getClass().getName(), e); Log.toLog(this.getClass().getName(), e);
} }
} }

View File

@ -6,8 +6,6 @@ import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
import main.java.com.djrapitops.plan.Log; import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.data.KillData; import main.java.com.djrapitops.plan.data.KillData;
import main.java.com.djrapitops.plan.database.databases.SQLDB; import main.java.com.djrapitops.plan.database.databases.SQLDB;

View File

@ -5,8 +5,6 @@ import java.sql.ResultSet;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.logging.Level;
import java.util.logging.Logger;
import main.java.com.djrapitops.plan.Log; import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.data.SessionData; import main.java.com.djrapitops.plan.data.SessionData;
import main.java.com.djrapitops.plan.database.databases.SQLDB; import main.java.com.djrapitops.plan.database.databases.SQLDB;

View File

@ -3,8 +3,6 @@ package main.java.com.djrapitops.plan.database.tables;
import java.sql.Connection; import java.sql.Connection;
import java.sql.PreparedStatement; import java.sql.PreparedStatement;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.logging.Level;
import java.util.logging.Logger;
import main.java.com.djrapitops.plan.Log; import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.database.databases.SQLDB; import main.java.com.djrapitops.plan.database.databases.SQLDB;

View File

@ -5,8 +5,7 @@ import java.io.IOException;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.Scanner; import java.util.Scanner;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Log;
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
/** /**
* *
@ -150,7 +149,7 @@ public enum Html {
String[] split = localeRow.split(" <> "); String[] split = localeRow.split(" <> ");
Html.valueOf(split[0]).setHtml(split[1]); Html.valueOf(split[0]).setHtml(split[1]);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
getPlugin(Plan.class).logError("There is a miswritten line in locale on line " + localeRows.indexOf(localeRow)); Log.error("There is a miswritten line in locale on line " + localeRows.indexOf(localeRow));
} }
} }
} catch (IOException e) { } catch (IOException e) {

View File

@ -10,7 +10,6 @@ import main.java.com.djrapitops.plan.data.cache.InspectCacheHandler;
import main.java.com.djrapitops.plan.utilities.AnalysisUtils; import main.java.com.djrapitops.plan.utilities.AnalysisUtils;
import main.java.com.djrapitops.plan.utilities.FormatUtils; import main.java.com.djrapitops.plan.utilities.FormatUtils;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
/** /**
* *
@ -19,7 +18,7 @@ import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
public class TextUI { public class TextUI {
public static String[] getInspectMessages(UUID uuid) { public static String[] getInspectMessages(UUID uuid) {
InspectCacheHandler inspectCache = getPlugin(Plan.class).getInspectCache(); InspectCacheHandler inspectCache = Plan.getInstance().getInspectCache();
if (!inspectCache.isCached(uuid)) { if (!inspectCache.isCached(uuid)) {
return new String[]{"Error has occurred, please retry."}; return new String[]{"Error has occurred, please retry."};
} }
@ -44,7 +43,7 @@ public class TextUI {
} }
public static String[] getAnalysisMessages() { public static String[] getAnalysisMessages() {
AnalysisCacheHandler analysisCache = getPlugin(Plan.class).getAnalysisCache(); AnalysisCacheHandler analysisCache = Plan.getInstance().getAnalysisCache();
if (!analysisCache.isCached()) { if (!analysisCache.isCached()) {
return new String[]{"Error has occurred, please retry."}; return new String[]{"Error has occurred, please retry."};
} }

View File

@ -3,7 +3,7 @@ package main.java.com.djrapitops.plan.ui.graphs;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.stream.Collectors;
import main.java.com.djrapitops.plan.data.SessionData; import main.java.com.djrapitops.plan.data.SessionData;
import main.java.com.djrapitops.plan.utilities.FormatUtils; import main.java.com.djrapitops.plan.utilities.FormatUtils;
@ -23,17 +23,10 @@ public class PlayerActivityGraphCreator {
public static String[] generateDataArray(List<SessionData> sessionData, long scale, int maxPlayers) { public static String[] generateDataArray(List<SessionData> sessionData, long scale, int maxPlayers) {
long now = new Date().toInstant().getEpochSecond() * (long) 1000; long now = new Date().toInstant().getEpochSecond() * (long) 1000;
long nowMinusScale = now - scale; long nowMinusScale = now - scale;
CopyOnWriteArrayList<Long> sessionStarts = new CopyOnWriteArrayList<>(); List<List<Long>> s = filterSessions(sessionData, nowMinusScale);
CopyOnWriteArrayList<Long> sessionEnds = new CopyOnWriteArrayList<>(); List<Long> sessionStarts = s.get(0);
CopyOnWriteArrayList<SessionData> s = new CopyOnWriteArrayList(sessionData); List<Long> sessionEnds = s.get(1);
s.parallelStream() List<Long> playersOnline = new ArrayList<>();
.filter(session -> (session != null))
.filter((session) -> (session.getSessionStart() > nowMinusScale || session.getSessionEnd() > nowMinusScale))
.forEach((session) -> {
sessionEnds.add(session.getSessionEnd());
sessionStarts.add(session.getSessionStart());
});
List<Integer> playersOnline = new ArrayList<>();
List<String> labels = new ArrayList<>(); List<String> labels = new ArrayList<>();
for (Long start : sessionStarts) { for (Long start : sessionStarts) {
@ -42,26 +35,15 @@ public class PlayerActivityGraphCreator {
} }
} }
int lastPValue = 0; long lastPValue = 0;
int lastSavedPValue = -1; long lastSavedPValue = -1;
long lastSaveI = 0; long lastSaveI = 0;
for (long i = nowMinusScale; i <= now; i += 1000) { for (long i = nowMinusScale; i <= now; i += 1000) {
final long j = i;
if (sessionStarts.contains(i)) { if (sessionStarts.contains(i)) {
int amount = 0; lastPValue += getCount(sessionStarts, i);
amount = sessionStarts.parallelStream()
.filter((start) -> (start == j))
.map((item) -> 1)
.reduce(amount, Integer::sum);
lastPValue += amount;
} }
if (sessionEnds.contains(i)) { if (sessionEnds.contains(i)) {
int amount = 0; lastPValue -= getCount(sessionEnds, i);
amount = sessionEnds.parallelStream()
.filter((end) -> (end == j))
.map((item) -> 1)
.reduce(amount, Integer::sum);
lastPValue -= amount;
} }
if (lastSavedPValue != lastPValue || i - lastSaveI > (scale / (long) 75)) { if (lastSavedPValue != lastPValue || i - lastSaveI > (scale / (long) 75)) {
@ -71,9 +53,36 @@ public class PlayerActivityGraphCreator {
playersOnline.add(lastPValue); playersOnline.add(lastPValue);
} }
} }
playersOnline.add(0); playersOnline.add(0L);
playersOnline.add(maxPlayers); playersOnline.add((long) maxPlayers);
return new String[]{playersOnline.toString(), labels.toString()}; return new String[]{playersOnline.toString(), labels.toString()};
} }
public static long getCount(List<Long> values, long lookFor) {
return values.stream()
.filter((start) -> (start == lookFor))
.count();
}
public static List<List<Long>> filterSessions(List<SessionData> sessionData, long nowMinusScale) {
List<Long[]> values = sessionData.parallelStream()
.filter(session -> (session != null))
.filter((session) -> (session.getSessionStart() >= nowMinusScale || session.getSessionEnd() >= nowMinusScale))
.map(session -> new Long[]{session.getSessionStart(), session.getSessionEnd()})
.collect(Collectors.toList());
List<Long> sessionStarts = new ArrayList<>();
List<Long> sessionEnds = new ArrayList<>();
for (Long[] startAndEnd : values) {
sessionStarts.add(getSecond(startAndEnd[0]));
sessionEnds.add(getSecond(startAndEnd[1]));
}
List<List<Long>> r = new ArrayList<>();
r.add(sessionStarts);
r.add(sessionEnds);
return r;
}
public static long getSecond(long ms) {
return ms - (ms % 1000);
}
} }

View File

@ -3,10 +3,9 @@ package main.java.com.djrapitops.plan.ui.tables;
import java.util.Collections; import java.util.Collections;
import java.util.List; import java.util.List;
import java.util.Map; import java.util.Map;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.ui.Html; import main.java.com.djrapitops.plan.ui.Html;
import main.java.com.djrapitops.plan.utilities.comparators.MapComparator; import main.java.com.djrapitops.plan.utilities.comparators.MapComparator;
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
/** /**
* *
@ -31,9 +30,8 @@ public class SortableCommandUseTableCreator {
try { try {
html += Html.TABLELINE_2.parse(values[1], values[0]); html += Html.TABLELINE_2.parse(values[1], values[0]);
} catch (IllegalArgumentException e) { } catch (IllegalArgumentException e) {
Plan plugin = getPlugin(Plan.class); Log.toLog("SortableCommandUseTableCreator", e);
plugin.toLog("SortableCommandUseTableCreator", e); Log.toLog("Cause: " + values[0] + " " + values[1]);
plugin.toLog("Cause: " + values[0] + " " + values[1]);
} }
} }
return html; return html;

View File

@ -3,11 +3,10 @@ package main.java.com.djrapitops.plan.ui.webserver;
import java.io.IOException; import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.util.UUID; import java.util.UUID;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Settings; import main.java.com.djrapitops.plan.Settings;
import main.java.com.djrapitops.plan.ui.DataRequestHandler; import main.java.com.djrapitops.plan.ui.DataRequestHandler;
import main.java.com.djrapitops.plan.utilities.UUIDFetcher; import main.java.com.djrapitops.plan.utilities.UUIDFetcher;
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
/** /**
* *
@ -87,7 +86,7 @@ public class Response {
+ "\r\n"; + "\r\n";
output.write((htmlDef + dataHtml).getBytes()); output.write((htmlDef + dataHtml).getBytes());
} catch (NullPointerException e) { } catch (NullPointerException e) {
getPlugin(Plan.class).toLog(this.getClass().getName(), e); Log.toLog(this.getClass().getName(), e);
String errorMessage = "HTTP/1.1 404 Error\r\n" String errorMessage = "HTTP/1.1 404 Error\r\n"
+ "Content-Type: text/html;\r\n" + "Content-Type: text/html;\r\n"
+ "Content-Length: 30\r\n" + "Content-Length: 30\r\n"
@ -116,7 +115,7 @@ public class Response {
+ "<h1>404 Data was not found in cache</h1>"; + "<h1>404 Data was not found in cache</h1>";
output.write(errorMessage.getBytes()); output.write(errorMessage.getBytes());
} catch (Exception e) { } catch (Exception e) {
getPlugin(Plan.class).toLog(this.getClass().getName(), e); Log.toLog(this.getClass().getName(), e);
} }
} }

View File

@ -6,6 +6,7 @@ import java.io.OutputStream;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.ServerSocket; import java.net.ServerSocket;
import java.net.Socket; import java.net.Socket;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Phrase; import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.Settings; import main.java.com.djrapitops.plan.Settings;
@ -49,7 +50,7 @@ public class WebSocketServer {
if (ENABLED) { if (ENABLED) {
return; return;
} }
plugin.log(Phrase.WEBSERVER_INIT + ""); Log.info(Phrase.WEBSERVER_INIT + "");
try { try {
//Setup server //Setup server
try { try {
@ -85,7 +86,7 @@ public class WebSocketServer {
ENABLED = true; ENABLED = true;
plugin.log(Phrase.WEBSERVER_RUNNING.parse(server.getLocalPort() + "")); Log.info(Phrase.WEBSERVER_RUNNING.parse(server.getLocalPort() + ""));
} catch (IllegalArgumentException | IllegalStateException e) { } catch (IllegalArgumentException | IllegalStateException e) {
ENABLED = false; ENABLED = false;
} }
@ -95,12 +96,12 @@ public class WebSocketServer {
* Shuts down the server - Async thread is closed with shutdown boolean. * Shuts down the server - Async thread is closed with shutdown boolean.
*/ */
public void stop() { public void stop() {
plugin.log(Phrase.WEBSERVER_CLOSE + ""); Log.info(Phrase.WEBSERVER_CLOSE + "");
shutdown = true; shutdown = true;
try { try {
server.close(); server.close();
} catch (IOException e) { } catch (IOException e) {
plugin.toLog(this.getClass().getName(), e); Log.toLog(this.getClass().getName(), e);
} }
} }

View File

@ -89,7 +89,7 @@ public class Analysis {
.collect(Collectors.toList()); .collect(Collectors.toList());
return uuids; return uuids;
} catch (Exception e) { } catch (Exception e) {
plugin.toLog(this.getClass().getName(), e); Log.toLog(this.getClass().getName(), e);
} }
return new ArrayList<>(); return new ArrayList<>();
} }

View File

@ -6,7 +6,6 @@ import java.util.HashMap;
import java.util.Scanner; import java.util.Scanner;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.Settings; import main.java.com.djrapitops.plan.Settings;
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
/** /**
* *
@ -21,7 +20,7 @@ public class HtmlUtils {
* @throws FileNotFoundException * @throws FileNotFoundException
*/ */
public static String getHtmlStringFromResource(String fileName) throws FileNotFoundException { public static String getHtmlStringFromResource(String fileName) throws FileNotFoundException {
Plan plugin = getPlugin(Plan.class); Plan plugin = Plan.getInstance();
File localFile = new File(plugin.getDataFolder(), fileName); File localFile = new File(plugin.getDataFolder(), fileName);
Scanner scanner = new Scanner(plugin.getResource(fileName)); Scanner scanner = new Scanner(plugin.getResource(fileName));
if (localFile.exists()) { if (localFile.exists()) {
@ -54,7 +53,7 @@ public class HtmlUtils {
*/ */
public static String getServerAnalysisUrl() { public static String getServerAnalysisUrl() {
int port = Settings.WEBSERVER_PORT.getNumber(); int port = Settings.WEBSERVER_PORT.getNumber();
String ip = getPlugin(Plan.class).getServer().getIp() + ":" + port; String ip = Plan.getInstance().getServer().getIp() + ":" + port;
String securityCode = Settings.SECURITY_CODE.toString(); String securityCode = Settings.SECURITY_CODE.toString();
boolean useAlternativeIP = Settings.SHOW_ALTERNATIVE_IP.isTrue(); boolean useAlternativeIP = Settings.SHOW_ALTERNATIVE_IP.isTrue();
if (useAlternativeIP) { if (useAlternativeIP) {
@ -71,7 +70,7 @@ public class HtmlUtils {
*/ */
public static String getInspectUrl(String playerName) { public static String getInspectUrl(String playerName) {
int port = Settings.WEBSERVER_PORT.getNumber(); int port = Settings.WEBSERVER_PORT.getNumber();
String ip = getPlugin(Plan.class).getServer().getIp() + ":" + port; String ip = Plan.getInstance().getServer().getIp() + ":" + port;
String securityCode = Settings.SECURITY_CODE.toString(); String securityCode = Settings.SECURITY_CODE.toString();
boolean useAlternativeIP = Settings.SHOW_ALTERNATIVE_IP.isTrue(); boolean useAlternativeIP = Settings.SHOW_ALTERNATIVE_IP.isTrue();
if (useAlternativeIP) { if (useAlternativeIP) {

View File

@ -9,6 +9,7 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.UserData; import main.java.com.djrapitops.plan.data.UserData;
import main.java.com.djrapitops.plan.data.cache.DBCallableProcessor; import main.java.com.djrapitops.plan.data.cache.DBCallableProcessor;
@ -18,7 +19,6 @@ import main.java.com.djrapitops.plan.database.databases.SQLiteDB;
import static org.bukkit.Bukkit.getOfflinePlayer; import static org.bukkit.Bukkit.getOfflinePlayer;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
/** /**
* *
@ -34,7 +34,7 @@ public class ManageUtils {
* @return success? * @return success?
*/ */
public static boolean backup(String dbName, Database copyFromDB) { public static boolean backup(String dbName, Database copyFromDB) {
Plan plugin = getPlugin(Plan.class); Plan plugin = Plan.getInstance();
Date now = new Date(); Date now = new Date();
SQLiteDB backupDB = new SQLiteDB(plugin, SQLiteDB backupDB = new SQLiteDB(plugin,
dbName + "-backup-" + now.toString().substring(4, 10).replaceAll(" ", "-").replaceAll(":", "-")); dbName + "-backup-" + now.toString().substring(4, 10).replaceAll(" ", "-").replaceAll(":", "-"));
@ -86,12 +86,11 @@ public class ManageUtils {
* @return uuids hashset as a Collection. * @return uuids hashset as a Collection.
*/ */
public static Collection<UUID> getUUIDS(Database db) { public static Collection<UUID> getUUIDS(Database db) {
Plan plugin = getPlugin(Plan.class);
final Set<UUID> uuids = new HashSet<>(); final Set<UUID> uuids = new HashSet<>();
try { try {
uuids.addAll(db.getSavedUUIDs()); uuids.addAll(db.getSavedUUIDs());
} catch (SQLException e) { } catch (SQLException e) {
plugin.toLog("ManageUtils.getUUIDS", e); Log.toLog("ManageUtils.getUUIDS", e);
} }
return uuids; return uuids;
} }
@ -106,7 +105,6 @@ public class ManageUtils {
* @return success? * @return success?
*/ */
public static boolean clearAndCopy(Database clearAndCopyToDB, Database copyFromDB, Collection<UUID> fromDBsavedUUIDs) { public static boolean clearAndCopy(Database clearAndCopyToDB, Database copyFromDB, Collection<UUID> fromDBsavedUUIDs) {
Plan plugin = getPlugin(Plan.class);
try { try {
clearAndCopyToDB.removeAllData(); clearAndCopyToDB.removeAllData();
List<UserData> allUserData = new ArrayList<>(); List<UserData> allUserData = new ArrayList<>();
@ -124,7 +122,7 @@ public class ManageUtils {
clearAndCopyToDB.saveMultipleUserData(allUserData); clearAndCopyToDB.saveMultipleUserData(allUserData);
clearAndCopyToDB.saveCommandUse(copyFromDB.getCommandUse()); clearAndCopyToDB.saveCommandUse(copyFromDB.getCommandUse());
} catch (SQLException | NullPointerException e) { } catch (SQLException | NullPointerException e) {
plugin.toLog("ManageUtils.move", e); Log.toLog("ManageUtils.move", e);
return false; return false;
} }
return true; return true;

View File

@ -8,6 +8,7 @@ import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Scanner; import java.util.Scanner;
import java.util.Set; import java.util.Set;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Permissions; import main.java.com.djrapitops.plan.Permissions;
import main.java.com.djrapitops.plan.Phrase; import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
@ -15,7 +16,6 @@ import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
/** /**
* *
@ -30,12 +30,12 @@ public class MiscUtils {
*/ */
public static String checkVersion() { public static String checkVersion() {
try { try {
Plan plugin = getPlugin(Plan.class); Plan plugin = Plan.getInstance();
String cVersion = plugin.getDescription().getVersion(); String cVersion = plugin.getDescription().getVersion();
String gitVersion = getGitVersion(); String gitVersion = getGitVersion();
return checkVersion(cVersion, gitVersion); return checkVersion(cVersion, gitVersion);
} catch (IOException | NumberFormatException e) { } catch (IOException | NumberFormatException e) {
getPlugin(Plan.class).logError(Phrase.VERSION_CHECK_ERROR + ""); Log.error(Phrase.VERSION_CHECK_ERROR + "");
} }
return Phrase.VERSION_FAIL + ""; return Phrase.VERSION_FAIL + "";
} }

View File

@ -16,7 +16,6 @@ import main.java.com.djrapitops.plan.ui.graphs.PlayerActivityGraphCreator;
import main.java.com.djrapitops.plan.ui.tables.SortableKillsTableCreator; import main.java.com.djrapitops.plan.ui.tables.SortableKillsTableCreator;
import main.java.com.djrapitops.plan.ui.tables.SortableSessionTableCreator; import main.java.com.djrapitops.plan.ui.tables.SortableSessionTableCreator;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import static org.bukkit.plugin.java.JavaPlugin.getPlugin;
/** /**
* *
@ -57,7 +56,7 @@ public class PlaceholderUtils {
replaceMap.put("%deaths%", data.getTotalDeaths() + ""); replaceMap.put("%deaths%", data.getTotalDeaths() + "");
replaceMap.put("%playerkills%", data.getTotalPlayerKills() + ""); replaceMap.put("%playerkills%", data.getTotalPlayerKills() + "");
replaceMap.put("%mobkills%", data.getTotalMobKills() + ""); replaceMap.put("%mobkills%", data.getTotalMobKills() + "");
Plan plugin = getPlugin(Plan.class); Plan plugin = Plan.getInstance();
replaceMap.put("%version%", plugin.getDescription().getVersion()); replaceMap.put("%version%", plugin.getDescription().getVersion());
replaceMap.put("%planlite%", ""); replaceMap.put("%planlite%", "");
replaceMap.put("%sortabletable%", data.getSortablePlayersTable()); replaceMap.put("%sortabletable%", data.getSortablePlayersTable());
@ -177,7 +176,7 @@ public class PlaceholderUtils {
replaceMap.put("%sessionstable%", SortableSessionTableCreator.createSortedSessionDataTable10(data.getSessions())); replaceMap.put("%sessionstable%", SortableSessionTableCreator.createSortedSessionDataTable10(data.getSessions()));
replaceMap.put("%sessionaverage%", FormatUtils.formatTimeAmount(AnalysisUtils.average(AnalysisUtils.transformSessionDataToLengths(data.getSessions())) + "")); replaceMap.put("%sessionaverage%", FormatUtils.formatTimeAmount(AnalysisUtils.average(AnalysisUtils.transformSessionDataToLengths(data.getSessions())) + ""));
replaceMap.put("%killstable%", SortableKillsTableCreator.createSortedSessionDataTable10(data.getPlayerKills())); replaceMap.put("%killstable%", SortableKillsTableCreator.createSortedSessionDataTable10(data.getPlayerKills()));
Plan plugin = getPlugin(Plan.class); Plan plugin = Plan.getInstance();
replaceMap.put("%version%", plugin.getDescription().getVersion()); replaceMap.put("%version%", plugin.getDescription().getVersion());
replaceMap.put("%planlite%", ""); replaceMap.put("%planlite%", "");
String[] playersDataArray = PlayerActivityGraphCreator.generateDataArray(data.getSessions(), (long) 604800 * 1000, 2); String[] playersDataArray = PlayerActivityGraphCreator.generateDataArray(data.getSessions(), (long) 604800 * 1000, 2);

View File

@ -1,7 +1,7 @@
name: Plan name: Plan
author: Rsl1122 author: Rsl1122
main: main.java.com.djrapitops.plan.Plan main: main.java.com.djrapitops.plan.Plan
version: 3.0.0 version: 3.0.1
softdepend: softdepend:
- OnTime - OnTime

View File

@ -9,12 +9,10 @@ import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import org.bukkit.ChatColor; import org.bukkit.ChatColor;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.easymock.EasyMock;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
import test.java.utils.TestInit; import test.java.utils.TestInit;
@ -43,12 +41,6 @@ public class PhraseTest {
TestInit t = new TestInit(); TestInit t = new TestInit();
assertTrue("Not set up", t.setUp()); assertTrue("Not set up", t.setUp());
plan = t.getPlanMock(); plan = t.getPlanMock();
PowerMock.mockStatic(JavaPlugin.class);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
PowerMock.replay(JavaPlugin.class);
// PowerMock.verify(JavaPlugin.class);
} }
/** /**

View File

@ -5,15 +5,12 @@
*/ */
package test.java.main.java.com.djrapitops.plan; package test.java.main.java.com.djrapitops.plan;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.Settings; import main.java.com.djrapitops.plan.Settings;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.easymock.EasyMock;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
import test.java.utils.TestInit; import test.java.utils.TestInit;
@ -39,11 +36,6 @@ public class SettingsTest {
public void setUp() { public void setUp() {
TestInit t = new TestInit(); TestInit t = new TestInit();
assertTrue("Not set up", t.setUp()); assertTrue("Not set up", t.setUp());
Plan plan = t.getPlanMock();
PowerMock.mockStatic(JavaPlugin.class);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
PowerMock.replay(JavaPlugin.class);
// PowerMock.verify(JavaPlugin.class);
} }
/** /**

View File

@ -6,16 +6,13 @@
package test.java.main.java.com.djrapitops.plan.data; package test.java.main.java.com.djrapitops.plan.data;
import main.java.com.djrapitops.plan.Phrase; import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.api.Gender; import main.java.com.djrapitops.plan.api.Gender;
import main.java.com.djrapitops.plan.data.DemographicsData; import main.java.com.djrapitops.plan.data.DemographicsData;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.easymock.EasyMock;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
import test.java.utils.TestInit; import test.java.utils.TestInit;
@ -41,13 +38,6 @@ public class DemographicsDataTest {
public void setUp() { public void setUp() {
TestInit t = new TestInit(); TestInit t = new TestInit();
assertTrue("Not set up", t.setUp()); assertTrue("Not set up", t.setUp());
Plan plan = t.getPlanMock();
PowerMock.mockStatic(JavaPlugin.class);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
PowerMock.replay(JavaPlugin.class);
// PowerMock.verify(JavaPlugin.class);
} }
/** /**

View File

@ -22,13 +22,11 @@ import org.bukkit.Location;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.World; import org.bukkit.World;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.easymock.EasyMock;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
import test.java.utils.MockUtils; import test.java.utils.MockUtils;
@ -59,13 +57,6 @@ public class UserDataTest {
TestInit t = new TestInit(); TestInit t = new TestInit();
assertTrue("Not set up", t.setUp()); assertTrue("Not set up", t.setUp());
plan = t.getPlanMock(); plan = t.getPlanMock();
PowerMock.mockStatic(JavaPlugin.class);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
PowerMock.replay(JavaPlugin.class);
// PowerMock.verify(JavaPlugin.class);
DemographicsData demData = new DemographicsData(); 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);
} }

View File

@ -11,7 +11,6 @@ import java.util.Date;
import java.util.HashMap; import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.DemographicsData; import main.java.com.djrapitops.plan.data.DemographicsData;
import main.java.com.djrapitops.plan.data.UserData; import main.java.com.djrapitops.plan.data.UserData;
@ -21,8 +20,6 @@ import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.database.databases.SQLiteDB; import main.java.com.djrapitops.plan.database.databases.SQLiteDB;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.easymock.EasyMock;
import static org.easymock.EasyMock.anyString;
import org.junit.After; import org.junit.After;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
@ -30,7 +27,6 @@ import org.junit.Before;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import static org.powermock.api.mockito.PowerMockito.when; import static org.powermock.api.mockito.PowerMockito.when;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
@ -112,23 +108,6 @@ public class DataCacheHandlerTest {
} }
}; };
when(plan.getDB()).thenReturn(db); when(plan.getDB()).thenReturn(db);
PowerMock.mockStatic(JavaPlugin.class);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
PowerMock.replay(JavaPlugin.class);
handler = new DataCacheHandler(plan) { handler = new DataCacheHandler(plan) {
@Override @Override
public void startAsyncPeriodicSaveTask() throws IllegalArgumentException, IllegalStateException { public void startAsyncPeriodicSaveTask() throws IllegalArgumentException, IllegalStateException {

View File

@ -6,18 +6,15 @@
package test.java.main.java.com.djrapitops.plan.data.cache; package test.java.main.java.com.djrapitops.plan.data.cache;
import java.util.UUID; import java.util.UUID;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.DemographicsData; import main.java.com.djrapitops.plan.data.DemographicsData;
import main.java.com.djrapitops.plan.data.SessionData; import main.java.com.djrapitops.plan.data.SessionData;
import main.java.com.djrapitops.plan.data.UserData; import main.java.com.djrapitops.plan.data.UserData;
import main.java.com.djrapitops.plan.data.cache.SessionCache; import main.java.com.djrapitops.plan.data.cache.SessionCache;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.easymock.EasyMock;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
import test.java.utils.MockUtils; import test.java.utils.MockUtils;
@ -46,18 +43,6 @@ public class SessionCacheTest {
public void setUp() { public void setUp() {
TestInit t = new TestInit(); TestInit t = new TestInit();
assertTrue(t.setUp()); assertTrue(t.setUp());
Plan plan = t.getPlanMock();
PowerMock.mockStatic(JavaPlugin.class);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
PowerMock.replay(JavaPlugin.class);
test = new SessionCache(); test = new SessionCache();
} }

View File

@ -5,17 +5,14 @@
*/ */
package test.java.main.java.com.djrapitops.plan.data.cache.queue; package test.java.main.java.com.djrapitops.plan.data.cache.queue;
import java.io.File;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.cache.DataCacheHandler; import main.java.com.djrapitops.plan.data.cache.DataCacheHandler;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.easymock.EasyMock;
import org.junit.After; import org.junit.After;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
import test.java.utils.TestInit; import test.java.utils.TestInit;
@ -45,15 +42,6 @@ public class DataCacheClearQueueTest {
TestInit t = new TestInit(); TestInit t = new TestInit();
assertTrue("Not set up", t.setUp()); assertTrue("Not set up", t.setUp());
plan = t.getPlanMock(); plan = t.getPlanMock();
PowerMock.mockStatic(JavaPlugin.class);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
PowerMock.replay(JavaPlugin.class);
File f = new File(plan.getDataFolder(), "Errors.txt");
handler = new DataCacheHandler(plan) { handler = new DataCacheHandler(plan) {
@Override @Override
public boolean getCommandUseFromDb() { public boolean getCommandUseFromDb() {

View File

@ -23,13 +23,11 @@ import main.java.com.djrapitops.plan.database.databases.SQLiteDB;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.easymock.EasyMock;
import org.junit.After; import org.junit.After;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
import test.java.utils.MockUtils; import test.java.utils.MockUtils;
@ -86,17 +84,6 @@ public class DataCacheGetQueueTest {
} }
} }
}; };
PowerMock.mockStatic(JavaPlugin.class);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
PowerMock.replay(JavaPlugin.class);
File f = new File(plan.getDataFolder(), "Errors.txt"); File f = new File(plan.getDataFolder(), "Errors.txt");
rows = 0; rows = 0;
if (f.exists()) { if (f.exists()) {

View File

@ -18,14 +18,11 @@ import main.java.com.djrapitops.plan.data.handling.info.HandlingInfo;
import main.java.com.djrapitops.plan.data.handling.info.InfoType; import main.java.com.djrapitops.plan.data.handling.info.InfoType;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.easymock.EasyMock;
import org.junit.After; import org.junit.After;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
import test.java.utils.MockUtils; import test.java.utils.MockUtils;
@ -54,21 +51,7 @@ public class DataCacheProcessQueueTest {
public void setUp() { public void setUp() {
TestInit t = new TestInit(); TestInit t = new TestInit();
assertTrue("Not set up", t.setUp()); assertTrue("Not set up", t.setUp());
Plan plan = t.getPlanMock(); handler = new DataCacheHandler(Plan.getInstance()) {
PowerMock.mockStatic(JavaPlugin.class);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
PowerMock.replay(JavaPlugin.class);
handler = new DataCacheHandler(plan) {
@Override @Override
public boolean getCommandUseFromDb() { public boolean getCommandUseFromDb() {
return true; return true;

View File

@ -6,29 +6,22 @@
package test.java.main.java.com.djrapitops.plan.data.cache.queue; package test.java.main.java.com.djrapitops.plan.data.cache.queue;
import java.sql.SQLException; import java.sql.SQLException;
import java.util.ArrayList;
import java.util.Date; import java.util.Date;
import java.util.List;
import java.util.UUID; import java.util.UUID;
import main.java.com.djrapitops.plan.Plan; 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.UserData;
import main.java.com.djrapitops.plan.data.cache.queue.DataCacheSaveQueue;
import main.java.com.djrapitops.plan.database.Database; import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.database.databases.SQLiteDB; import main.java.com.djrapitops.plan.database.databases.SQLiteDB;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.easymock.EasyMock;
import org.junit.After; import org.junit.After;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import static org.powermock.api.mockito.PowerMockito.when; import static org.powermock.api.mockito.PowerMockito.when;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
import test.java.utils.MockUtils;
import test.java.utils.TestInit; import test.java.utils.TestInit;
/** /**

View File

@ -11,12 +11,10 @@ import main.java.com.djrapitops.plan.data.DemographicsData;
import main.java.com.djrapitops.plan.data.UserData; import main.java.com.djrapitops.plan.data.UserData;
import main.java.com.djrapitops.plan.data.handling.ChatHandling; import main.java.com.djrapitops.plan.data.handling.ChatHandling;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.easymock.EasyMock;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
import test.java.utils.MockUtils; import test.java.utils.MockUtils;
@ -44,16 +42,6 @@ public class ChatHandlingTest {
TestInit t = new TestInit(); TestInit t = new TestInit();
assertTrue("Not set up", t.setUp()); assertTrue("Not set up", t.setUp());
Plan plan = t.getPlanMock(); Plan plan = t.getPlanMock();
PowerMock.mockStatic(JavaPlugin.class);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
PowerMock.replay(JavaPlugin.class);
// PowerMock.verify(JavaPlugin.class);
} }
/** /**

View File

@ -5,18 +5,15 @@
*/ */
package test.java.main.java.com.djrapitops.plan.data.handling; package test.java.main.java.com.djrapitops.plan.data.handling;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.DemographicsData; import main.java.com.djrapitops.plan.data.DemographicsData;
import main.java.com.djrapitops.plan.data.UserData; import main.java.com.djrapitops.plan.data.UserData;
import main.java.com.djrapitops.plan.data.handling.GamemodeHandling; import main.java.com.djrapitops.plan.data.handling.GamemodeHandling;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.easymock.EasyMock;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
import test.java.utils.MockUtils; import test.java.utils.MockUtils;
@ -43,13 +40,6 @@ public class GamemodeHandlingTest {
public void setUp() { public void setUp() {
TestInit t = new TestInit(); TestInit t = new TestInit();
assertTrue("Not set up", t.setUp()); assertTrue("Not set up", t.setUp());
Plan plan = t.getPlanMock();
PowerMock.mockStatic(JavaPlugin.class);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
PowerMock.replay(JavaPlugin.class);
// PowerMock.verify(JavaPlugin.class);
} }
/** /**

View File

@ -17,7 +17,6 @@ import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.database.databases.SQLiteDB; import main.java.com.djrapitops.plan.database.databases.SQLiteDB;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.easymock.EasyMock;
import org.junit.After; import org.junit.After;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
@ -25,7 +24,6 @@ import org.junit.Before;
import org.junit.Ignore; import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import static org.powermock.api.mockito.PowerMockito.when; import static org.powermock.api.mockito.PowerMockito.when;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
@ -69,12 +67,6 @@ public class KillHandlingTest {
} }
}; };
when(plan.getDB()).thenReturn(db); when(plan.getDB()).thenReturn(db);
PowerMock.mockStatic(JavaPlugin.class);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
PowerMock.replay(JavaPlugin.class);
} }
/** /**

View File

@ -7,17 +7,14 @@ package test.java.main.java.com.djrapitops.plan.data.handling;
import java.net.InetAddress; import java.net.InetAddress;
import java.net.UnknownHostException; 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.DemographicsData;
import main.java.com.djrapitops.plan.data.UserData; import main.java.com.djrapitops.plan.data.UserData;
import main.java.com.djrapitops.plan.data.handling.LoginHandling; import main.java.com.djrapitops.plan.data.handling.LoginHandling;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.easymock.EasyMock;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
import test.java.utils.MockUtils; import test.java.utils.MockUtils;
@ -44,13 +41,6 @@ public class LoginHandlingTest {
public void setUp() { public void setUp() {
TestInit t = new TestInit(); TestInit t = new TestInit();
assertTrue("Not set up", t.setUp()); assertTrue("Not set up", t.setUp());
Plan plan = t.getPlanMock();
PowerMock.mockStatic(JavaPlugin.class);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
PowerMock.replay(JavaPlugin.class);
// PowerMock.verify(JavaPlugin.class);
} }
/** /**

View File

@ -10,12 +10,10 @@ import main.java.com.djrapitops.plan.data.DemographicsData;
import main.java.com.djrapitops.plan.data.UserData; import main.java.com.djrapitops.plan.data.UserData;
import main.java.com.djrapitops.plan.data.handling.LogoutHandling; import main.java.com.djrapitops.plan.data.handling.LogoutHandling;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.easymock.EasyMock;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
import test.java.utils.MockUtils; import test.java.utils.MockUtils;
@ -43,13 +41,6 @@ public class LogoutHandlingTest {
TestInit t = new TestInit(); TestInit t = new TestInit();
assertTrue("Not set up", t.setUp()); assertTrue("Not set up", t.setUp());
Plan plan = t.getPlanMock(); Plan plan = t.getPlanMock();
PowerMock.mockStatic(JavaPlugin.class);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
PowerMock.replay(JavaPlugin.class);
// PowerMock.verify(JavaPlugin.class);
} }
/** /**

View File

@ -5,18 +5,15 @@
*/ */
package test.java.main.java.com.djrapitops.plan.data.handling.info; package test.java.main.java.com.djrapitops.plan.data.handling.info;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.api.Gender; import main.java.com.djrapitops.plan.api.Gender;
import main.java.com.djrapitops.plan.data.DemographicsData; import main.java.com.djrapitops.plan.data.DemographicsData;
import main.java.com.djrapitops.plan.data.UserData; import main.java.com.djrapitops.plan.data.UserData;
import main.java.com.djrapitops.plan.data.handling.info.ChatInfo; import main.java.com.djrapitops.plan.data.handling.info.ChatInfo;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.easymock.EasyMock;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
import test.java.utils.MockUtils; import test.java.utils.MockUtils;
@ -37,17 +34,6 @@ public class ChatInfoTest {
public void setUp() { public void setUp() {
TestInit t = new TestInit(); TestInit t = new TestInit();
assertTrue("Not set up", t.setUp()); assertTrue("Not set up", t.setUp());
Plan plan = t.getPlanMock();
PowerMock.mockStatic(JavaPlugin.class);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
PowerMock.replay(JavaPlugin.class);
// PowerMock.verify(JavaPlugin.class);
} }
/** /**

View File

@ -5,17 +5,14 @@
*/ */
package test.java.main.java.com.djrapitops.plan.data.handling.info; package test.java.main.java.com.djrapitops.plan.data.handling.info;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.DemographicsData; import main.java.com.djrapitops.plan.data.DemographicsData;
import main.java.com.djrapitops.plan.data.UserData; import main.java.com.djrapitops.plan.data.UserData;
import main.java.com.djrapitops.plan.data.handling.info.DeathInfo; import main.java.com.djrapitops.plan.data.handling.info.DeathInfo;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.easymock.EasyMock;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
import test.java.utils.MockUtils; import test.java.utils.MockUtils;
@ -42,13 +39,6 @@ public class DeathInfoTest {
public void setUp() { public void setUp() {
TestInit t = new TestInit(); TestInit t = new TestInit();
assertTrue("Not set up", t.setUp()); assertTrue("Not set up", t.setUp());
Plan plan = t.getPlanMock();
PowerMock.mockStatic(JavaPlugin.class);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
PowerMock.replay(JavaPlugin.class);
// PowerMock.verify(JavaPlugin.class);
} }
/** /**

View File

@ -5,18 +5,15 @@
*/ */
package test.java.main.java.com.djrapitops.plan.data.handling.info; package test.java.main.java.com.djrapitops.plan.data.handling.info;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.DemographicsData; import main.java.com.djrapitops.plan.data.DemographicsData;
import main.java.com.djrapitops.plan.data.UserData; import main.java.com.djrapitops.plan.data.UserData;
import main.java.com.djrapitops.plan.data.handling.info.GamemodeInfo; import main.java.com.djrapitops.plan.data.handling.info.GamemodeInfo;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.easymock.EasyMock;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
import test.java.utils.MockUtils; import test.java.utils.MockUtils;
@ -43,13 +40,6 @@ public class GamemodeInfoTest {
public void setUp() { public void setUp() {
TestInit t = new TestInit(); TestInit t = new TestInit();
assertTrue("Not set up", t.setUp()); assertTrue("Not set up", t.setUp());
Plan plan = t.getPlanMock();
PowerMock.mockStatic(JavaPlugin.class);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
PowerMock.replay(JavaPlugin.class);
// PowerMock.verify(JavaPlugin.class);
} }
/** /**

View File

@ -5,17 +5,14 @@
*/ */
package test.java.main.java.com.djrapitops.plan.data.handling.info; package test.java.main.java.com.djrapitops.plan.data.handling.info;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.DemographicsData; import main.java.com.djrapitops.plan.data.DemographicsData;
import main.java.com.djrapitops.plan.data.UserData; import main.java.com.djrapitops.plan.data.UserData;
import main.java.com.djrapitops.plan.data.handling.info.KickInfo; import main.java.com.djrapitops.plan.data.handling.info.KickInfo;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.easymock.EasyMock;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
import test.java.utils.MockUtils; import test.java.utils.MockUtils;
@ -42,13 +39,6 @@ public class KickInfoTest {
public void setUp() { public void setUp() {
TestInit t = new TestInit(); TestInit t = new TestInit();
assertTrue("Not set up", t.setUp()); assertTrue("Not set up", t.setUp());
Plan plan = t.getPlanMock();
PowerMock.mockStatic(JavaPlugin.class);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
PowerMock.replay(JavaPlugin.class);
// PowerMock.verify(JavaPlugin.class);
} }
/** /**

View File

@ -16,13 +16,11 @@ import main.java.com.djrapitops.plan.database.Database;
import main.java.com.djrapitops.plan.database.databases.SQLiteDB; import main.java.com.djrapitops.plan.database.databases.SQLiteDB;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.easymock.EasyMock;
import org.junit.After; import org.junit.After;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import static org.powermock.api.mockito.PowerMockito.when; import static org.powermock.api.mockito.PowerMockito.when;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
@ -65,12 +63,6 @@ public class KillInfoTest {
} }
}; };
when(plan.getDB()).thenReturn(db); when(plan.getDB()).thenReturn(db);
PowerMock.mockStatic(JavaPlugin.class);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
PowerMock.replay(JavaPlugin.class);
} }
/** /**

View File

@ -13,12 +13,10 @@ import main.java.com.djrapitops.plan.data.UserData;
import main.java.com.djrapitops.plan.data.handling.info.LoginInfo; import main.java.com.djrapitops.plan.data.handling.info.LoginInfo;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.easymock.EasyMock;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
import test.java.utils.MockUtils; import test.java.utils.MockUtils;
@ -46,12 +44,6 @@ public class LoginInfoTest {
TestInit t = new TestInit(); TestInit t = new TestInit();
assertTrue("Not set up", t.setUp()); assertTrue("Not set up", t.setUp());
Plan plan = t.getPlanMock(); Plan plan = t.getPlanMock();
PowerMock.mockStatic(JavaPlugin.class);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
PowerMock.replay(JavaPlugin.class);
// PowerMock.verify(JavaPlugin.class);
} }
/** /**

View File

@ -5,19 +5,16 @@
*/ */
package test.java.main.java.com.djrapitops.plan.data.handling.info; package test.java.main.java.com.djrapitops.plan.data.handling.info;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.DemographicsData; import main.java.com.djrapitops.plan.data.DemographicsData;
import main.java.com.djrapitops.plan.data.SessionData; import main.java.com.djrapitops.plan.data.SessionData;
import main.java.com.djrapitops.plan.data.UserData; import main.java.com.djrapitops.plan.data.UserData;
import main.java.com.djrapitops.plan.data.handling.info.LogoutInfo; import main.java.com.djrapitops.plan.data.handling.info.LogoutInfo;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.easymock.EasyMock;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
import test.java.utils.MockUtils; import test.java.utils.MockUtils;
@ -44,14 +41,6 @@ public class LogoutInfoTest {
public void setUp() { public void setUp() {
TestInit t = new TestInit(); TestInit t = new TestInit();
assertTrue("Not set up", t.setUp()); assertTrue("Not set up", t.setUp());
Plan plan = t.getPlanMock();
PowerMock.mockStatic(JavaPlugin.class);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
PowerMock.replay(JavaPlugin.class);
// PowerMock.verify(JavaPlugin.class);
} }
/** /**

View File

@ -13,12 +13,10 @@ import main.java.com.djrapitops.plan.data.UserData;
import main.java.com.djrapitops.plan.data.handling.info.ReloadInfo; import main.java.com.djrapitops.plan.data.handling.info.ReloadInfo;
import org.bukkit.GameMode; import org.bukkit.GameMode;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.easymock.EasyMock;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
import test.java.utils.MockUtils; import test.java.utils.MockUtils;
@ -46,12 +44,6 @@ public class ReloadInfoTest {
TestInit t = new TestInit(); TestInit t = new TestInit();
assertTrue("Not set up", t.setUp()); assertTrue("Not set up", t.setUp());
Plan plan = t.getPlanMock(); Plan plan = t.getPlanMock();
PowerMock.mockStatic(JavaPlugin.class);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
PowerMock.replay(JavaPlugin.class);
// PowerMock.verify(JavaPlugin.class);
} }
/** /**

View File

@ -34,7 +34,6 @@ import org.junit.After;
import static org.junit.Assert.assertEquals; import static org.junit.Assert.assertEquals;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import org.junit.Before; import org.junit.Before;
import org.junit.Ignore;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock; import org.powermock.api.easymock.PowerMock;
@ -78,12 +77,6 @@ public class DatabaseTest {
} }
}; };
PowerMock.mockStatic(JavaPlugin.class);
for (int i = 0; i < 40; i++) {
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
}
PowerMock.replay(JavaPlugin.class);
// PowerMock.verify(JavaPlugin.class);
File f = new File(plan.getDataFolder(), "Errors.txt"); File f = new File(plan.getDataFolder(), "Errors.txt");
rows = 0; rows = 0;
if (f.exists()) { if (f.exists()) {

View File

@ -9,16 +9,13 @@ import java.util.ArrayList;
import java.util.Collection; import java.util.Collection;
import java.util.Date; import java.util.Date;
import java.util.List; import java.util.List;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.SessionData; import main.java.com.djrapitops.plan.data.SessionData;
import main.java.com.djrapitops.plan.utilities.AnalysisUtils; import main.java.com.djrapitops.plan.utilities.AnalysisUtils;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.easymock.EasyMock;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
import test.java.utils.TestInit; import test.java.utils.TestInit;
@ -44,13 +41,6 @@ public class AnalysisUtilsTest {
public void setUp() { public void setUp() {
TestInit t = new TestInit(); TestInit t = new TestInit();
assertTrue("Not set up", t.setUp()); assertTrue("Not set up", t.setUp());
Plan plan = t.getPlanMock();
PowerMock.mockStatic(JavaPlugin.class);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
PowerMock.replay(JavaPlugin.class);
// PowerMock.verify(JavaPlugin.class);
} }
/** /**

View File

@ -10,12 +10,10 @@ import java.util.HashMap;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.utilities.HtmlUtils; import main.java.com.djrapitops.plan.utilities.HtmlUtils;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.easymock.EasyMock;
import static org.junit.Assert.*; import static org.junit.Assert.*;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
import test.java.utils.TestInit; import test.java.utils.TestInit;
@ -41,14 +39,6 @@ public class HtmlUtilsTest {
public void setUp() { public void setUp() {
TestInit t = new TestInit(); TestInit t = new TestInit();
assertTrue("Not set up", t.setUp()); assertTrue("Not set up", t.setUp());
Plan plan = t.getPlanMock();
PowerMock.mockStatic(JavaPlugin.class);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
PowerMock.replay(JavaPlugin.class);
// PowerMock.verify(JavaPlugin.class);
} }
/** /**

View File

@ -7,7 +7,6 @@ package test.java.main.java.com.djrapitops.plan.utilities;
import java.util.Set; import java.util.Set;
import main.java.com.djrapitops.plan.Phrase; import main.java.com.djrapitops.plan.Phrase;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.utilities.MiscUtils; import main.java.com.djrapitops.plan.utilities.MiscUtils;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
@ -45,13 +44,6 @@ public class MiscUtilsTest {
public void setUp() { public void setUp() {
TestInit t = new TestInit(); TestInit t = new TestInit();
assertTrue("Not set up", t.setUp()); assertTrue("Not set up", t.setUp());
Plan plan = t.getPlanMock();
PowerMock.mockStatic(JavaPlugin.class);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
PowerMock.replay(JavaPlugin.class);
PowerMock.mockStatic(Bukkit.class); PowerMock.mockStatic(Bukkit.class);
OfflinePlayer op = MockUtils.mockPlayer(); OfflinePlayer op = MockUtils.mockPlayer();
OfflinePlayer op2 = MockUtils.mockPlayer2(); OfflinePlayer op2 = MockUtils.mockPlayer2();

View File

@ -6,7 +6,6 @@
package test.java.main.java.com.djrapitops.plan.utilities; package test.java.main.java.com.djrapitops.plan.utilities;
import java.util.Date; import java.util.Date;
import main.java.com.djrapitops.plan.Plan;
import main.java.com.djrapitops.plan.data.DemographicsData; import main.java.com.djrapitops.plan.data.DemographicsData;
import main.java.com.djrapitops.plan.data.UserData; import main.java.com.djrapitops.plan.data.UserData;
import main.java.com.djrapitops.plan.utilities.NewPlayerCreator; import main.java.com.djrapitops.plan.utilities.NewPlayerCreator;
@ -14,13 +13,11 @@ import org.bukkit.GameMode;
import org.bukkit.OfflinePlayer; import org.bukkit.OfflinePlayer;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
import org.easymock.EasyMock;
import org.junit.After; import org.junit.After;
import static org.junit.Assert.assertTrue; import static org.junit.Assert.assertTrue;
import org.junit.Before; import org.junit.Before;
import org.junit.Test; import org.junit.Test;
import org.junit.runner.RunWith; import org.junit.runner.RunWith;
import org.powermock.api.easymock.PowerMock;
import org.powermock.core.classloader.annotations.PrepareForTest; import org.powermock.core.classloader.annotations.PrepareForTest;
import org.powermock.modules.junit4.PowerMockRunner; import org.powermock.modules.junit4.PowerMockRunner;
import test.java.utils.MockUtils; import test.java.utils.MockUtils;
@ -47,15 +44,6 @@ public class NewPlayerCreatorTest {
public void setUp() { public void setUp() {
TestInit t = new TestInit(); TestInit t = new TestInit();
assertTrue("Not set up", t.setUp()); assertTrue("Not set up", t.setUp());
Plan plan = t.getPlanMock();
PowerMock.mockStatic(JavaPlugin.class);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
EasyMock.expect(JavaPlugin.getPlugin(Plan.class)).andReturn(plan);
PowerMock.replay(JavaPlugin.class);
} }
/** /**

View File

@ -9,7 +9,6 @@ import java.io.File;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.nio.file.Files; import java.nio.file.Files;
import java.util.logging.Logger; import java.util.logging.Logger;
import main.java.com.djrapitops.plan.Log;
import main.java.com.djrapitops.plan.Plan; import main.java.com.djrapitops.plan.Plan;
import org.bukkit.Server; import org.bukkit.Server;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;