mirror of
https://github.com/plan-player-analytics/Plan.git
synced 2024-12-21 05:50:18 +08:00
Merge pull request #241 from Rsl1122/Fuzzlemann-master
Merge fixes Fuzzlemann master
This commit is contained in:
commit
baf24c5673
@ -24,7 +24,7 @@ public class ManageCommand extends TreeCommand<Plan> {
|
|||||||
* @param plugin Current instance of Plan
|
* @param plugin Current instance of Plan
|
||||||
*/
|
*/
|
||||||
public ManageCommand(Plan plugin) {
|
public ManageCommand(Plan plugin) {
|
||||||
super(plugin, "manage,m", CommandType.CONSOLE, Permissions.MANAGE.getPermission(), Locale.get(Msg.CMD_USG_MANAGE) + "", "plan m");
|
super(plugin, "manage,m", CommandType.CONSOLE, Permissions.MANAGE.getPermission(), Locale.get(Msg.CMD_USG_MANAGE).toString(), "plan m");
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -50,8 +50,12 @@ public class ManageDumpCommand extends SubCommand {
|
|||||||
plugin.getRunnableFactory().createNew(new AbsRunnable("DumpTask") {
|
plugin.getRunnableFactory().createNew(new AbsRunnable("DumpTask") {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
sender.sendLink("Link to the Dump", DumpUtils.dump(plugin));
|
try {
|
||||||
sender.sendLink("Report Issues here", "https://github.com/Rsl1122/Plan-PlayerAnalytics/issues/new");
|
sender.sendLink("Link to the Dump", DumpUtils.dump(plugin));
|
||||||
|
sender.sendLink("Report Issues here", "https://github.com/Rsl1122/Plan-PlayerAnalytics/issues/new");
|
||||||
|
} finally {
|
||||||
|
this.cancel();
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}).runTaskAsynchronously();
|
}).runTaskAsynchronously();
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ public class DataCacheClearQueue extends Queue<UUID> {
|
|||||||
* @param handler current instance of DataCacheHandler.
|
* @param handler current instance of DataCacheHandler.
|
||||||
*/
|
*/
|
||||||
public DataCacheClearQueue(DataCacheHandler handler) {
|
public DataCacheClearQueue(DataCacheHandler handler) {
|
||||||
super(new ArrayBlockingQueue(Settings.PROCESS_CLEAR_LIMIT.getNumber()));
|
super(new ArrayBlockingQueue<>(Settings.PROCESS_CLEAR_LIMIT.getNumber()));
|
||||||
setup = new ClearSetup(queue, handler);
|
setup = new ClearSetup(queue, handler);
|
||||||
setup.go();
|
setup.go();
|
||||||
}
|
}
|
||||||
@ -65,7 +65,7 @@ class ClearConsumer extends Consumer<UUID> implements Runnable {
|
|||||||
|
|
||||||
private DataCacheHandler handler;
|
private DataCacheHandler handler;
|
||||||
|
|
||||||
ClearConsumer(BlockingQueue q, DataCacheHandler handler) {
|
ClearConsumer(BlockingQueue<UUID> q, DataCacheHandler handler) {
|
||||||
super(q, "ClearQueueConsumer");
|
super(q, "ClearQueueConsumer");
|
||||||
this.handler = handler;
|
this.handler = handler;
|
||||||
}
|
}
|
||||||
@ -97,7 +97,7 @@ class ClearConsumer extends Consumer<UUID> implements Runnable {
|
|||||||
|
|
||||||
class ClearSetup extends Setup<UUID> {
|
class ClearSetup extends Setup<UUID> {
|
||||||
|
|
||||||
public ClearSetup(BlockingQueue<UUID> q, DataCacheHandler handler) {
|
ClearSetup(BlockingQueue<UUID> q, DataCacheHandler handler) {
|
||||||
super(new ClearConsumer(q, handler));
|
super(new ClearConsumer(q, handler));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -27,7 +27,7 @@ public class DataCacheGetQueue extends Queue<Map<UUID, List<DBCallableProcessor>
|
|||||||
* @param plugin current instance of Plan
|
* @param plugin current instance of Plan
|
||||||
*/
|
*/
|
||||||
public DataCacheGetQueue(Plan plugin) {
|
public DataCacheGetQueue(Plan plugin) {
|
||||||
super(new ArrayBlockingQueue(Settings.PROCESS_GET_LIMIT.getNumber()));
|
super(new ArrayBlockingQueue<>(Settings.PROCESS_GET_LIMIT.getNumber()));
|
||||||
setup = new GetSetup(queue, plugin.getDB());
|
setup = new GetSetup(queue, plugin.getDB());
|
||||||
setup.go();
|
setup.go();
|
||||||
}
|
}
|
||||||
@ -50,8 +50,12 @@ public class DataCacheGetQueue extends Queue<Map<UUID, List<DBCallableProcessor>
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean containsUUIDtoBeCached(UUID uuid) {
|
boolean containsUUIDtoBeCached(UUID uuid) {
|
||||||
return uuid != null && new ArrayList<>(queue).stream().anyMatch(map -> (map.get(uuid) != null && map.get(uuid).size() >= 2));
|
return uuid != null
|
||||||
|
&& queue.stream()
|
||||||
|
.map(map -> map.get(uuid))
|
||||||
|
.filter(Objects::nonNull)
|
||||||
|
.anyMatch(list -> list.size() >= 2);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -59,7 +63,7 @@ class GetConsumer extends Consumer<Map<UUID, List<DBCallableProcessor>>> {
|
|||||||
|
|
||||||
private Database db;
|
private Database db;
|
||||||
|
|
||||||
GetConsumer(BlockingQueue q, Database db) {
|
GetConsumer(BlockingQueue<Map<UUID, List<DBCallableProcessor>>> q, Database db) {
|
||||||
super(q, "GetQueueConsumer");
|
super(q, "GetQueueConsumer");
|
||||||
this.db = db;
|
this.db = db;
|
||||||
}
|
}
|
||||||
|
@ -39,7 +39,7 @@ public class Locale implements Closeable {
|
|||||||
private final Map<Msg, Message> messages;
|
private final Map<Msg, Message> messages;
|
||||||
|
|
||||||
public Locale(Plan plugin) {
|
public Locale(Plan plugin) {
|
||||||
LocaleHolder.setLOCALE(this);
|
LocaleHolder.setLocale(this);
|
||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
messages = new HashMap<>();
|
messages = new HashMap<>();
|
||||||
}
|
}
|
||||||
@ -62,9 +62,9 @@ public class Locale implements Closeable {
|
|||||||
}
|
}
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.toLog(this.getClass().getName(), e);
|
Log.toLog(this.getClass().getName(), e);
|
||||||
|
} finally {
|
||||||
|
Benchmark.stop("Enable", "Initializing locale");
|
||||||
}
|
}
|
||||||
Benchmark.stop("Enable", "Initializing locale");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private void writeNewDefaultLocale() throws IOException {
|
private void writeNewDefaultLocale() throws IOException {
|
||||||
@ -316,25 +316,24 @@ public class Locale implements Closeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Message getMessage(Msg msg) {
|
public Message getMessage(Msg msg) {
|
||||||
Message message = messages.get(msg);
|
return messages.getOrDefault(msg, new Message(""));
|
||||||
return message != null ? message : new Message("");
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void close() {
|
public void close() {
|
||||||
messages.clear();
|
messages.clear();
|
||||||
LocaleHolder.LOCALE = null;
|
LocaleHolder.locale = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void unload() {
|
public static void unload() {
|
||||||
Locale locale = LocaleHolder.getLOCALE();
|
Locale locale = LocaleHolder.getLocale();
|
||||||
if (locale != null) {
|
if (locale != null) {
|
||||||
locale.close();
|
locale.close();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Message get(Msg msg) {
|
public static Message get(Msg msg) {
|
||||||
Locale locale = LocaleHolder.getLOCALE();
|
Locale locale = LocaleHolder.getLocale();
|
||||||
if (locale == null) {
|
if (locale == null) {
|
||||||
throw new IllegalStateException("Locale has not been initialized.");
|
throw new IllegalStateException("Locale has not been initialized.");
|
||||||
}
|
}
|
||||||
@ -343,14 +342,14 @@ public class Locale implements Closeable {
|
|||||||
|
|
||||||
private static class LocaleHolder {
|
private static class LocaleHolder {
|
||||||
|
|
||||||
private static Locale LOCALE;
|
private static Locale locale;
|
||||||
|
|
||||||
public static void setLOCALE(Locale LOCALE) {
|
public static void setLocale(Locale locale) {
|
||||||
LocaleHolder.LOCALE = LOCALE;
|
LocaleHolder.locale = locale;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Locale getLOCALE() {
|
public static Locale getLocale() {
|
||||||
return LOCALE;
|
return locale;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -84,12 +84,12 @@ public class TextUI {
|
|||||||
final TPSPart tps = d.getTpsPart();
|
final TPSPart tps = d.getTpsPart();
|
||||||
return new String[]{
|
return new String[]{
|
||||||
ball + " Total Players: " + sec + count.getPlayerCount(),
|
ball + " Total Players: " + sec + count.getPlayerCount(),
|
||||||
//
|
|
||||||
ball + " Active: " + sec + activity.getActive().size()
|
ball + " Active: " + sec + activity.getActive().size()
|
||||||
+ main + " Inactive: " + sec + activity.getInactive().size()
|
+ main + " Inactive: " + sec + activity.getInactive().size()
|
||||||
+ main + " Single Join: " + sec + activity.getJoinedOnce().size()
|
+ main + " Single Join: " + sec + activity.getJoinedOnce().size()
|
||||||
+ main + " Banned: " + sec + activity.getBans().size(),
|
+ main + " Banned: " + sec + activity.getBans().size(),
|
||||||
//
|
|
||||||
ball + " New Players 24h: " + sec + join.get("npday") + main + " 7d: " + sec + d.get("npweek") + main + " 30d: " + sec + d.get("npmonth"),
|
ball + " New Players 24h: " + sec + join.get("npday") + main + " 7d: " + sec + d.get("npweek") + main + " 30d: " + sec + d.get("npmonth"),
|
||||||
"",
|
"",
|
||||||
ball + " Total Playtime: " + sec + playtime.get("totalplaytime") + main + " Player Avg: " + sec + playtime.get("avgplaytime"),
|
ball + " Total Playtime: " + sec + playtime.get("totalplaytime") + main + " Player Avg: " + sec + playtime.get("avgplaytime"),
|
||||||
|
@ -167,7 +167,7 @@ public class Analysis {
|
|||||||
|
|
||||||
PageCacheHandler.cachePage("analysisPage", () -> new AnalysisPageResponse(plugin.getUiServer().getDataReqHandler()));
|
PageCacheHandler.cachePage("analysisPage", () -> new AnalysisPageResponse(plugin.getUiServer().getDataReqHandler()));
|
||||||
PageCacheHandler.cachePage("players", () -> new PlayersPageResponse(plugin));
|
PageCacheHandler.cachePage("players", () -> new PlayersPageResponse(plugin));
|
||||||
ExportUtility.export(plugin, analysisData, rawData);
|
ExportUtility.export(analysisData, rawData);
|
||||||
} catch (Exception e) {
|
} catch (Exception e) {
|
||||||
Log.toLog(this.getClass().getName(), e);
|
Log.toLog(this.getClass().getName(), e);
|
||||||
plugin.processStatus().setStatus("Analysis", "Error: " + e);
|
plugin.processStatus().setStatus("Analysis", "Error: " + e);
|
||||||
|
@ -54,27 +54,31 @@ public class ExportUtility {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @param plugin
|
|
||||||
* @param analysisData
|
* @param analysisData
|
||||||
* @param rawData
|
* @param rawData
|
||||||
*/
|
*/
|
||||||
public static void export(Plan plugin, AnalysisData analysisData, List<UserData> rawData) {
|
public static void export(AnalysisData analysisData, List<UserData> rawData) {
|
||||||
if (!Settings.ANALYSIS_EXPORT.isTrue()) {
|
if (!Settings.ANALYSIS_EXPORT.isTrue()) {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
Benchmark.start("Exporting Html pages");
|
Benchmark.start("Exporting Html pages");
|
||||||
try {
|
try {
|
||||||
File folder = getFolder();
|
File folder = getFolder();
|
||||||
Log.debug("Export", "Folder: " + folder.getAbsolutePath());
|
Log.debug("Export", "Folder: " + folder.getAbsolutePath());
|
||||||
|
|
||||||
writePlayersPageHtml(rawData, new File(folder, "players"));
|
writePlayersPageHtml(rawData, new File(folder, "players"));
|
||||||
writeAnalysisHtml(analysisData, new File(folder, "server"));
|
writeAnalysisHtml(analysisData, new File(folder, "server"));
|
||||||
|
|
||||||
File playersFolder = getPlayersFolder(folder);
|
File playersFolder = getPlayersFolder(folder);
|
||||||
Log.debug("Export", "Player html files.");
|
Log.debug("Export", "Player html files.");
|
||||||
Log.debug("Export", "Player Page Folder: " + playersFolder.getAbsolutePath());
|
Log.debug("Export", "Player Page Folder: " + playersFolder.getAbsolutePath());
|
||||||
|
|
||||||
String playerHtml = HtmlUtils.getStringFromResource("player.html");
|
String playerHtml = HtmlUtils.getStringFromResource("player.html");
|
||||||
rawData.forEach(userData -> {
|
|
||||||
writeInspectHtml(userData, playersFolder, playerHtml);
|
Benchmark.start("Exporting Player pages");
|
||||||
});
|
rawData.forEach(userData -> writeInspectHtml(userData, playersFolder, playerHtml));
|
||||||
|
Benchmark.stop("Exporting Player pages");
|
||||||
} catch (IOException ex) {
|
} catch (IOException ex) {
|
||||||
Log.toLog("ExportUtils.export", ex);
|
Log.toLog("ExportUtils.export", ex);
|
||||||
} finally {
|
} finally {
|
||||||
@ -96,17 +100,18 @@ public class ExportUtility {
|
|||||||
/**
|
/**
|
||||||
* @param userData
|
* @param userData
|
||||||
* @param playersFolder
|
* @param playersFolder
|
||||||
* @throws FileNotFoundException
|
|
||||||
* @throws IOException
|
|
||||||
*/
|
*/
|
||||||
public static boolean writeInspectHtml(UserData userData, File playersFolder, String playerHtml) {
|
public static void writeInspectHtml(UserData userData, File playersFolder, String playerHtml) {
|
||||||
if (!Settings.ANALYSIS_EXPORT.isTrue()) {
|
if (!Settings.ANALYSIS_EXPORT.isTrue()) {
|
||||||
return false;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
String name = userData.getName();
|
String name = userData.getName();
|
||||||
|
|
||||||
if (name.endsWith(".")) {
|
if (name.endsWith(".")) {
|
||||||
name = name.replace(".", "%2E");
|
name = name.replace(".", "%2E");
|
||||||
}
|
}
|
||||||
|
|
||||||
if (name.endsWith(" ")) {
|
if (name.endsWith(" ")) {
|
||||||
name = name.replace(" ", "%20");
|
name = name.replace(" ", "%20");
|
||||||
}
|
}
|
||||||
@ -114,16 +119,17 @@ public class ExportUtility {
|
|||||||
try {
|
try {
|
||||||
String inspectHtml = HtmlUtils.replacePlaceholders(playerHtml,
|
String inspectHtml = HtmlUtils.replacePlaceholders(playerHtml,
|
||||||
PlaceholderUtils.getInspectReplaceRules(userData));
|
PlaceholderUtils.getInspectReplaceRules(userData));
|
||||||
|
|
||||||
File playerFolder = new File(playersFolder, name);
|
File playerFolder = new File(playersFolder, name);
|
||||||
playerFolder.mkdirs();
|
playerFolder.mkdirs();
|
||||||
|
|
||||||
File inspectHtmlFile = new File(playerFolder, "index.html");
|
File inspectHtmlFile = new File(playerFolder, "index.html");
|
||||||
inspectHtmlFile.createNewFile();
|
inspectHtmlFile.createNewFile();
|
||||||
|
|
||||||
Files.write(inspectHtmlFile.toPath(), Collections.singletonList(inspectHtml));
|
Files.write(inspectHtmlFile.toPath(), Collections.singletonList(inspectHtml));
|
||||||
} catch (IOException e) {
|
} catch (IOException e) {
|
||||||
Log.toLog("Export.inspectPage: " + name, e);
|
Log.toLog("Export.writeInspectHtml: " + name, e);
|
||||||
return false;
|
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -1,5 +1,7 @@
|
|||||||
package main.java.com.djrapitops.plan.utilities.file.dump;
|
package main.java.com.djrapitops.plan.utilities.file.dump;
|
||||||
|
|
||||||
|
import com.google.common.base.Splitter;
|
||||||
|
import com.google.common.collect.ImmutableList;
|
||||||
import main.java.com.djrapitops.plan.Log;
|
import main.java.com.djrapitops.plan.Log;
|
||||||
import org.json.simple.JSONObject;
|
import org.json.simple.JSONObject;
|
||||||
import org.json.simple.parser.JSONParser;
|
import org.json.simple.parser.JSONParser;
|
||||||
@ -21,7 +23,7 @@ import java.util.List;
|
|||||||
*/
|
*/
|
||||||
public class DumpLog {
|
public class DumpLog {
|
||||||
|
|
||||||
private List<CharSequence> lines = new ArrayList<>();
|
private final List<CharSequence> lines = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Writes a header
|
* Writes a header
|
||||||
@ -88,6 +90,11 @@ public class DumpLog {
|
|||||||
* @param line The content of the line
|
* @param line The content of the line
|
||||||
*/
|
*/
|
||||||
private void addLine(CharSequence line) {
|
private void addLine(CharSequence line) {
|
||||||
|
if (line == null) {
|
||||||
|
lines.add("\n");
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
lines.add(line.toString());
|
lines.add(line.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -97,7 +104,27 @@ public class DumpLog {
|
|||||||
* @return The link to the Dump Log
|
* @return The link to the Dump Log
|
||||||
*/
|
*/
|
||||||
String upload() {
|
String upload() {
|
||||||
String content = this.toString();
|
List<String> parts = ImmutableList.copyOf(split()).reverse();
|
||||||
|
|
||||||
|
String lastLink = null;
|
||||||
|
for (String part : parts) {
|
||||||
|
if (lastLink != null) {
|
||||||
|
part += "\n" + lastLink;
|
||||||
|
}
|
||||||
|
|
||||||
|
lastLink = upload(part);
|
||||||
|
}
|
||||||
|
|
||||||
|
return lastLink;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Uploads the content to Hastebin using HTTPS and POST
|
||||||
|
*
|
||||||
|
* @param content The content
|
||||||
|
* @return The link to the content
|
||||||
|
*/
|
||||||
|
private String upload(String content) {
|
||||||
HttpsURLConnection connection = null;
|
HttpsURLConnection connection = null;
|
||||||
try {
|
try {
|
||||||
URL url = new URL("https://hastebin.com/documents");
|
URL url = new URL("https://hastebin.com/documents");
|
||||||
@ -111,13 +138,16 @@ public class DumpLog {
|
|||||||
connection.setDoOutput(true);
|
connection.setDoOutput(true);
|
||||||
|
|
||||||
DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
|
DataOutputStream wr = new DataOutputStream(connection.getOutputStream());
|
||||||
wr.writeBytes(this.toString());
|
wr.writeBytes(content);
|
||||||
wr.flush();
|
wr.flush();
|
||||||
wr.close();
|
wr.close();
|
||||||
|
|
||||||
BufferedReader rd = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
BufferedReader reader = new BufferedReader(new InputStreamReader(connection.getInputStream()));
|
||||||
|
|
||||||
|
String response = reader.readLine();
|
||||||
|
|
||||||
JSONParser parser = new JSONParser();
|
JSONParser parser = new JSONParser();
|
||||||
JSONObject json = (JSONObject) parser.parse(rd.readLine());
|
JSONObject json = (JSONObject) parser.parse(response);
|
||||||
|
|
||||||
return "https://hastebin.com/" + json.get("key");
|
return "https://hastebin.com/" + json.get("key");
|
||||||
} catch (IOException | ParseException e) {
|
} catch (IOException | ParseException e) {
|
||||||
@ -130,6 +160,15 @@ public class DumpLog {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Splits the content of the DumpLog into parts
|
||||||
|
*
|
||||||
|
* @return The splitted content
|
||||||
|
*/
|
||||||
|
private Iterable<String> split() {
|
||||||
|
return Splitter.fixedLength(390000).split(this.toString());
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String toString() {
|
public String toString() {
|
||||||
return String.join("\n", lines);
|
return String.join("\n", lines);
|
||||||
|
@ -741,12 +741,12 @@
|
|||||||
|
|
||||||
function openFunc(i) {
|
function openFunc(i) {
|
||||||
return function() {
|
return function() {
|
||||||
if (window.getComputedStyle(document.getElementById("navbutton")).getPropertyValue('display') == "inline") {
|
if (window.getComputedStyle(document.getElementById("navbutton")).getPropertyValue('display') === "inline") {
|
||||||
closeNav();
|
closeNav();
|
||||||
}
|
}
|
||||||
var max = navButtons.length;
|
var max = navButtons.length;
|
||||||
for (var j = 0; j < max; j++) {
|
for (var j = 0; j < max; j++) {
|
||||||
if (j == i) {
|
if (j === i) {
|
||||||
navButtons[j].classList.add('active');
|
navButtons[j].classList.add('active');
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
@ -770,9 +770,7 @@
|
|||||||
var begin = new Date(%refreshlong%);
|
var begin = new Date(%refreshlong%);
|
||||||
var seconds = now.getTime() - begin.getTime();
|
var seconds = now.getTime() - begin.getTime();
|
||||||
|
|
||||||
var out = formatTime(seconds);
|
document.getElementById('divTime').innerHTML = formatTime(seconds);
|
||||||
|
|
||||||
document.getElementById('divTime').innerHTML = out;
|
|
||||||
setTimeout('countUpTimer()', 1000);
|
setTimeout('countUpTimer()', 1000);
|
||||||
}
|
}
|
||||||
</script>
|
</script>
|
||||||
|
@ -16,7 +16,6 @@ import org.bukkit.entity.Player;
|
|||||||
import org.mockito.Mockito;
|
import org.mockito.Mockito;
|
||||||
import org.powermock.api.mockito.PowerMockito;
|
import org.powermock.api.mockito.PowerMockito;
|
||||||
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.InetAddress;
|
import java.net.InetAddress;
|
||||||
import java.net.InetSocketAddress;
|
import java.net.InetSocketAddress;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -154,7 +153,7 @@ public class MockUtils {
|
|||||||
return PowerMockito.mock(CommandSender.class);
|
return PowerMockito.mock(CommandSender.class);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HttpServer mockHTTPServer() throws IOException {
|
public static HttpServer mockHTTPServer() {
|
||||||
HttpServer httpServer = PowerMockito.mock(HttpServer.class);
|
HttpServer httpServer = PowerMockito.mock(HttpServer.class);
|
||||||
when(httpServer.getAddress()).thenReturn(new InetSocketAddress(80));
|
when(httpServer.getAddress()).thenReturn(new InetSocketAddress(80));
|
||||||
when(httpServer.getExecutor()).thenReturn(command -> System.out.println("HTTP Server command received"));
|
when(httpServer.getExecutor()).thenReturn(command -> System.out.println("HTTP Server command received"));
|
||||||
|
Loading…
Reference in New Issue
Block a user