Compare commits

...

4 Commits

Author SHA1 Message Date
Colbster937
f22e800439 share plugin commit in http api 2026-01-21 10:43:47 -06:00
Colbster937
f0274ff4d4 only unregister routes fi enabled 2026-01-21 10:21:05 -06:00
Colbster937
12f9d669b4 make it register an eaglerxserver route 2026-01-20 22:03:34 -06:00
Colbster937
c43de8a1c9 accept eula 2026-01-19 15:40:40 -06:00
11 changed files with 252 additions and 147 deletions

View File

@@ -15,6 +15,7 @@
- [x] Plugin update checker
- [x] Send blacklist logs to a webhook
- [x] Ingame blacklist management commands
- [x] Blacklist sharing via EaglerXServer routes
- [x] Reverse blacklist (whitelist)
- [ ] Subscribe to an auto-updating blacklist

View File

@@ -14,7 +14,7 @@ val PLUGIN_NAME = "OriginBlacklist"
val PLUGIN_IDEN = "originblacklist"
val PLUGIN_DOMN = "xyz.webmc.$PLUGIN_IDEN"
val PLUGIN_DESC = "An eaglercraft client blacklist plugin."
val PLUGIN_VERS = "2.0.6"
val PLUGIN_VERS = "2.0.7"
val PLUGIN_SITE = "https://github.com/WebMCDevelopment/$PLUGIN_IDEN"
val PLUGIN_DEPA = listOf("EaglercraftXServer")
val PLUGIN_DEPB = listOf("EaglercraftXServer")
@@ -171,6 +171,7 @@ tasks.register("printVars") {
tasks.withType<RunServer>().configureEach {
minecraftVersion("1.12.2")
runDirectory.set(layout.projectDirectory.dir("run/paper"))
jvmArgs("-Dcom.mojang.eula.agree=true")
downloadPlugins {
github("lax1dude", "eaglerxserver", "v" + EAGXS_VER, "EaglerXServer.jar")
modrinth("placeholderapi", "2.11.7")

View File

@@ -6,7 +6,7 @@ import xyz.webmc.originblacklist.base.enums.EnumConnectionType;
import xyz.webmc.originblacklist.base.enums.EnumLogLevel;
import xyz.webmc.originblacklist.base.events.OriginBlacklistLoginEvent;
import xyz.webmc.originblacklist.base.events.OriginBlacklistMOTDEvent;
import xyz.webmc.originblacklist.base.http.OriginBlacklistHTTPServer;
import xyz.webmc.originblacklist.base.http.OriginBlacklistRequestHandler;
import xyz.webmc.originblacklist.base.util.BuildInfo;
import xyz.webmc.originblacklist.base.util.IOriginBlacklistPlugin;
import xyz.webmc.originblacklist.base.util.OPlayer;
@@ -38,9 +38,11 @@ import inet.ipaddr.IPAddressString;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
import net.lax1dude.eaglercraft.backend.server.api.IEaglerXServerAPI;
import net.lax1dude.eaglercraft.backend.server.api.query.IMOTDConnection;
import org.semver4j.Semver;
@SuppressWarnings({ "rawtypes" })
public final class OriginBlacklist {
private static final String COMMIT_L = BuildInfo.get("git_cm_hash");
private static final String COMMIT_S = COMMIT_L.substring(0, 8);
@@ -54,7 +56,6 @@ public final class OriginBlacklist {
private final IOriginBlacklistPlugin plugin;
private final OriginBlacklistConfig config;
private final OriginBlacklistHTTPServer http;
private final Json5 json5;
private String updateURL;
private Path jarFile;
@@ -62,7 +63,6 @@ public final class OriginBlacklist {
public OriginBlacklist(final IOriginBlacklistPlugin plugin) {
this.plugin = plugin;
this.config = new OriginBlacklistConfig(this);
this.http = new OriginBlacklistHTTPServer(this);
this.json5 = Json5.builder(builder -> builder.prettyPrinting().indentFactor(0).build());
}
@@ -71,8 +71,8 @@ public final class OriginBlacklist {
this.plugin.scheduleRepeat(() -> {
this.checkForUpdates();
}, this.config.getInteger("update_checker.check_timer"), TimeUnit.SECONDS);
if (this.isHTTPServerEnabled()) {
this.http.start();
if (this.isBlacklistAPIEnabled()) {
OriginBlacklistRequestHandler.register(this);
}
this.plugin.log(EnumLogLevel.INFO, "Initialized Plugin");
this.plugin.log(EnumLogLevel.DEBUG, "Commit " + COMMIT_L);
@@ -80,15 +80,20 @@ public final class OriginBlacklist {
public final void shutdown() {
this.plugin.log(EnumLogLevel.INFO, "Shutting down...");
this.http.stop();
if (this.isBlacklistAPIEnabled()) {
OriginBlacklistRequestHandler.unRegister(this);
}
this.plugin.shutdown();
}
public final void handleReload() {
if (this.isHTTPServerEnabled()) {
this.http.start();
} else {
this.http.stop();
try {
if (this.isBlacklistAPIEnabled()) {
OriginBlacklistRequestHandler.register(this);
} else {
OriginBlacklistRequestHandler.unRegister(this);
}
} catch (final Throwable t) {
}
}
@@ -150,8 +155,8 @@ public final class OriginBlacklist {
return this.config.getBoolean("logFile");
}
public final boolean isHTTPServerEnabled() {
return this.config.getBoolean("blacklist_http_share.enabled");
public final boolean isBlacklistAPIEnabled() {
return this.config.getBoolean("blacklist_http_api");
}
public final OriginBlacklistConfig getConfig() {
@@ -316,6 +321,7 @@ public final class OriginBlacklist {
try {
final Json5Object obj = new Json5Object();
obj.addProperty("plugin_version", this.plugin.getPluginVersion().getVersion());
obj.addProperty("git_commit", COMMIT_L);
obj.addProperty("blacklist_to_whitelist", this.config.getBoolean("blacklist_to_whitelist"));
obj.addProperty("block_undefined_origin", this.config.getBoolean("block_undefined_origin"));
final Json5Object bObj = new Json5Object();
@@ -334,6 +340,10 @@ public final class OriginBlacklist {
return "plugins/" + plugin.getPluginId();
}
public final IEaglerXServerAPI getEaglerAPI() {
return this.plugin.getEaglerAPI();
}
private final Component getBlacklistedComponent(final String type, final String id, final String blockType,
final String blockTypeAlt, final String notAllowed, final String notAllowedAlt, final String blockValue,
final String action) {

View File

@@ -11,6 +11,7 @@ import java.nio.charset.StandardCharsets;
import java.nio.file.Files;
import java.nio.file.Path;
import java.nio.file.StandardCopyOption;
import java.util.ArrayList;
import javax.imageio.ImageIO;
@@ -21,6 +22,8 @@ import de.marhali.json5.Json5Object;
import de.marhali.json5.Json5Primitive;
public final class OriginBlacklistConfig {
private static final Json5Object DEFAULT_CONFIG = getDefaultConfig();
private final Json5 json5;
private final File file;
private final Path filePath;
@@ -70,16 +73,14 @@ public final class OriginBlacklistConfig {
Json5Element parsed = this.json5.parse(text);
if (parsed instanceof Json5Object) {
this.config = (Json5Object) parsed;
if (merge(this.config, getDefaultConfig())) {
this.saveConfig();
}
merge(this.config, DEFAULT_CONFIG);
} else {
throw new IOException("Config must be an object!");
}
} else {
this.config = getDefaultConfig();
this.saveConfig();
this.config = DEFAULT_CONFIG;
}
this.saveConfig();
}
private final void reloadIconImage() {
@@ -206,7 +207,6 @@ public final class OriginBlacklistConfig {
} else {
element = null;
}
if (element == null) {
break;
}
@@ -312,11 +312,7 @@ public final class OriginBlacklistConfig {
addJSONObj(uObj, "check_timer", Json5Primitive.fromNumber(3600), null);
addJSONObj(uObj, "auto_update", Json5Primitive.fromBoolean(true), null);
addJSONObj(obj, "update_checker", uObj, null);
final Json5Object hObj = new Json5Object();
addJSONObj(hObj, "enabled", Json5Primitive.fromBoolean(false), null);
addJSONObj(hObj, "http_port", Json5Primitive.fromNumber(8080), null);
addJSONObj(hObj, "listen_addr", Json5Primitive.fromString("0.0.0.0"), null);
addJSONObj(obj, "blacklist_http_share", hObj, null);
addJSONObj(obj, "blacklist_http_api", Json5Primitive.fromBoolean(false), null);
addJSONObj(obj, "blacklist_to_whitelist", Json5Primitive.fromBoolean(false), null);
addJSONObj(obj, "block_undefined_origin", Json5Primitive.fromBoolean(false), null);
addJSONObj(obj, "bStats", Json5Primitive.fromBoolean(true), null);
@@ -325,24 +321,157 @@ public final class OriginBlacklistConfig {
return obj;
}
private static final boolean merge(final Json5Object a, final Json5Object b) {
private static final boolean merge(final Json5Object aObj, final Json5Object bObj) {
final Json5Object ret = new Json5Object();
boolean changed = false;
for (String key : b.keySet()) {
Json5Element element = b.get(key);
if (!a.has(key)) {
a.add(key, element.deepCopy());
changed = true;
} else {
final Json5Element _element = a.get(key);
if (_element instanceof Json5Object objA && element instanceof Json5Object objB) {
if (merge(objA, objB)) {
for (final String key : bObj.keySet()) {
final Json5Element dv = bObj.get(key);
if (aObj.has(key)) {
final Json5Element v = aObj.get(key);
if (dv instanceof Json5Object) {
if (v instanceof Json5Object) {
final boolean c = merge((Json5Object) v, (Json5Object) dv);
ret.add(key, (Json5Object) v);
if (c) {
changed = true;
}
} else {
ret.add(key, dv.deepCopy());
changed = true;
}
} else if (dv instanceof Json5Array) {
if (v instanceof Json5Array) {
final Json5Array vArr = (Json5Array) v;
final Json5Array dArr = (Json5Array) dv;
if (dArr.size() == 0) {
ret.add(key, vArr.deepCopy());
} else {
final Json5Element d0 = dArr.get(0);
if (d0 instanceof Json5Primitive && ((Json5Primitive) d0).isString()) {
final Json5Array out = new Json5Array();
for (final Json5Element e : vArr) {
if (e instanceof Json5Primitive && ((Json5Primitive) e).isString()) {
out.add(e.deepCopy());
}
}
if (out.size() > 0) {
if (out.size() != vArr.size()) {
changed = true;
}
ret.add(key, out);
} else {
ret.add(key, dArr.deepCopy());
changed = true;
}
} else {
boolean a = true;
for (final Json5Element e : vArr) {
if (e == null) {
a = false;
} else if (d0 instanceof Json5Object) {
if (!(e instanceof Json5Object)) {
a = false;
}
} else if (d0 instanceof Json5Array) {
if (!(e instanceof Json5Array)) {
a = false;
}
} else if (d0 instanceof Json5Primitive && e instanceof Json5Primitive) {
final Json5Primitive bp = (Json5Primitive) d0;
final Json5Primitive ap = (Json5Primitive) e;
if (bp.isBoolean()) {
if (!ap.isBoolean()) {
a = false;
}
} else if (bp.isNumber()) {
if (!ap.isNumber()) {
a = false;
}
} else if (bp.isString()) {
if (!ap.isString()) {
a = false;
}
}
} else {
a = false;
}
if (!a) {
break;
}
}
if (a) {
ret.add(key, vArr.deepCopy());
} else {
ret.add(key, dArr.deepCopy());
changed = true;
}
}
}
} else {
ret.add(key, dv.deepCopy());
changed = true;
}
} else if (dv instanceof Json5Primitive) {
if (v instanceof Json5Primitive) {
final Json5Primitive dp = (Json5Primitive) dv;
final Json5Primitive vp = (Json5Primitive) v;
if (dp.isBoolean()) {
if (vp.isBoolean()) {
ret.add(key, vp.deepCopy());
} else {
ret.add(key, dv.deepCopy());
changed = true;
}
} else if (dp.isNumber()) {
if (vp.isNumber()) {
ret.add(key, vp.deepCopy());
} else {
ret.add(key, dv.deepCopy());
changed = true;
}
} else if (dp.isString()) {
if (vp.isString()) {
ret.add(key, vp.deepCopy());
} else {
ret.add(key, dv.deepCopy());
changed = true;
}
} else {
ret.add(key, dv.deepCopy());
changed = true;
}
} else {
ret.add(key, dv.deepCopy());
changed = true;
}
} else {
ret.add(key, dv.deepCopy());
changed = true;
}
} else {
ret.add(key, dv.deepCopy());
changed = true;
}
}
for (final String key : aObj.keySet()) {
if (!bObj.has(key)) {
ret.add(key, aObj.get(key).deepCopy());
}
}
for (final String key : aObj.keySet()) {
if (!bObj.has(key)) {
ret.add(key, aObj.get(key).deepCopy());
}
}
for (final String k : new ArrayList<>(aObj.keySet())) {
aObj.remove(k);
}
for (final String k : ret.keySet()) {
aObj.add(k, ret.get(k));
}
for (final String key : ret.keySet()) {
aObj.add(key, ret.get(key));
}
return changed;
}

View File

@@ -1,39 +0,0 @@
package xyz.webmc.originblacklist.base.http;
import xyz.webmc.originblacklist.base.OriginBlacklist;
import java.io.IOException;
import java.io.OutputStream;
import java.nio.charset.StandardCharsets;
import com.sun.net.httpserver.HttpExchange;
import com.sun.net.httpserver.HttpHandler;
public class OriginBlacklistHTTPHandler implements HttpHandler {
private final OriginBlacklist plugin;
public OriginBlacklistHTTPHandler(final OriginBlacklist plugin) {
this.plugin = plugin;
}
@Override
public final void handle(final HttpExchange exchange) throws IOException {
try {
final String path = exchange.getRequestURI().getPath();
if ("/".equals(path)) {
final byte[] bytes = this.plugin.getBlacklistShare().getBytes(StandardCharsets.UTF_8);
exchange.getResponseHeaders().set("Content-Type", "application/json; charset=utf-8");
exchange.sendResponseHeaders(200, bytes.length);
try (final OutputStream os = exchange.getResponseBody()) {
os.write(bytes);
}
} else {
exchange.sendResponseHeaders(404, -1);
}
} finally {
exchange.close();
}
}
}

View File

@@ -1,56 +0,0 @@
package xyz.webmc.originblacklist.base.http;
import xyz.webmc.originblacklist.base.OriginBlacklist;
import xyz.webmc.originblacklist.base.config.OriginBlacklistConfig;
import java.net.InetSocketAddress;
import java.util.concurrent.ExecutorService;
import java.util.concurrent.Executors;
import com.sun.net.httpserver.HttpServer;
public class OriginBlacklistHTTPServer {
private final OriginBlacklist plugin;
private final ExecutorService executor;
private HttpServer server;
private boolean running;
public OriginBlacklistHTTPServer(final OriginBlacklist plugin) {
this.plugin = plugin;
this.executor = Executors.newFixedThreadPool(4);
this.running = false;
}
public final void start() {
if (!this.running) {
try {
this.server = this.createServer();
this.server.start();
this.running = true;
} catch (final Throwable t) {
}
}
}
public final void stop() {
if (this.running && this.server != null) {
this.server.stop(0);
this.running = false;
}
}
public final void shutdown() {
this.stop();
this.executor.shutdownNow();
}
private final HttpServer createServer() throws Throwable {
final OriginBlacklistConfig config = this.plugin.getConfig();
final HttpServer server = HttpServer
.create(new InetSocketAddress(config.getString("blacklist_http_share.listen_addr"),
config.getInteger("blacklist_http_share.http_port")), 0);
server.createContext("/", new OriginBlacklistHTTPHandler(this.plugin));
server.setExecutor(executor);
return server;
}
}

View File

@@ -0,0 +1,40 @@
package xyz.webmc.originblacklist.base.http;
import xyz.webmc.originblacklist.base.OriginBlacklist;
import java.nio.charset.StandardCharsets;
import net.lax1dude.eaglercraft.backend.server.api.webserver.IRequestContext;
import net.lax1dude.eaglercraft.backend.server.api.webserver.IRequestHandler;
import net.lax1dude.eaglercraft.backend.server.api.webserver.RouteDesc;
public class OriginBlacklistRequestHandler implements IRequestHandler {
private static final RouteDesc route = RouteDesc.create("/originblacklist/v2/");
private final OriginBlacklist plugin;
public OriginBlacklistRequestHandler(final OriginBlacklist plugin) {
this.plugin = plugin;
}
@Override
public final void handleRequest(final IRequestContext ctx) {
final String path = ctx.getPath();
if (route.getPattern().equals(path)) {
final byte[] bytes = this.plugin.getBlacklistShare().getBytes(StandardCharsets.UTF_8);
ctx.addResponseHeader("Content-Type", "application/json; charset=utf-8");
ctx.setResponseCode(200);
ctx.setResponseBody(bytes);
} else {
ctx.getServer().get404Handler().handleRequest(ctx);
}
}
public static final void register(final OriginBlacklist plugin) {
plugin.getEaglerAPI().getWebServer().registerRoute(plugin, route, new OriginBlacklistRequestHandler(plugin));
}
public static final void unRegister(final OriginBlacklist plugin) {
plugin.getEaglerAPI().getWebServer().unregisterRoute(plugin, route);
}
}

View File

@@ -8,8 +8,10 @@ import java.nio.file.Path;
import java.util.concurrent.TimeUnit;
import net.kyori.adventure.text.Component;
import net.lax1dude.eaglercraft.backend.server.api.IEaglerXServerAPI;
import org.semver4j.Semver;
@SuppressWarnings({ "rawtypes" })
public interface IOriginBlacklistPlugin {
public String getPluginId();
@@ -17,6 +19,8 @@ public interface IOriginBlacklistPlugin {
public Path getPluginJarPath();
public IEaglerXServerAPI getEaglerAPI();
public void log(final EnumLogLevel level, final String txt);
public void kickPlayer(final Component txt, final OriginBlacklistLoginEvent event);

View File

@@ -45,7 +45,6 @@ public final class OriginBlacklistBukkit extends JavaPlugin implements Listener,
private boolean papiPlaceholdersEnabled;
private Object papi;
private OriginBlacklist blacklist;
private IEaglerXServerAPI eaglerAPI;
private Metrics metrics;
private CachedServerIcon iconCache;
@@ -73,7 +72,6 @@ public final class OriginBlacklistBukkit extends JavaPlugin implements Listener,
this.papi = null;
}
this.blacklist = new OriginBlacklist(this);
this.eaglerAPI = EaglerXServerAPI.instance();
this.getCommand("originblacklist").setExecutor(new OriginBlacklistCommandBukkit(this.blacklist));
this.getServer().getPluginManager().registerEvents(this, this);
this.blacklist.init();
@@ -83,7 +81,7 @@ public final class OriginBlacklistBukkit extends JavaPlugin implements Listener,
final Map<String, Integer> playerMap = new HashMap<>();
for (final Player player : Bukkit.getOnlinePlayers()) {
final boolean eagler = eaglerAPI.isEaglerPlayerByUUID(player.getUniqueId());
final boolean eagler = this.getEaglerAPI().isEaglerPlayerByUUID(player.getUniqueId());
final String key = eagler ? "Eagler" : "Java";
playerMap.put(key, playerMap.getOrDefault(key, 0) + 1);
}
@@ -112,13 +110,14 @@ public final class OriginBlacklistBukkit extends JavaPlugin implements Listener,
@EventHandler(priority = EventPriority.LOWEST)
public final void onJavaLogin(final AsyncPlayerPreLoginEvent event) {
final OPlayer player = new OPlayer(null, event.getName(), event.getUniqueId(), event.getAddress().toString(), OriginBlacklist.UNKNOWN_STR, OriginBlacklist.UNKNOWN_STR, -1);
final OPlayer player = new OPlayer(null, event.getName(), event.getUniqueId(), event.getAddress().toString(),
OriginBlacklist.UNKNOWN_STR, OriginBlacklist.UNKNOWN_STR, -1);
this.blacklist.handleLogin(new OriginBlacklistLoginEvent(null, event, EnumConnectionType.JAVA, player));
}
@EventHandler(priority = EventPriority.HIGHEST)
public final void onJavaMOTD(final ServerListPingEvent event) {
final OPlayer player = new OPlayer(null, null, null, event.getAddress().toString(), null, null, -1);
final OPlayer player = new OPlayer(null, null, null, event.getAddress().toString(), null, null, -1);
this.blacklist.handleMOTD(new OriginBlacklistMOTDEvent(null, event, EnumConnectionType.JAVA, player));
}
@@ -137,6 +136,11 @@ public final class OriginBlacklistBukkit extends JavaPlugin implements Listener,
return Paths.get(this.getFile().getAbsolutePath());
}
@Override
public final IEaglerXServerAPI getEaglerAPI() {
return EaglerXServerAPI.instance();
}
@Override
public final void log(final EnumLogLevel level, final String txt) {
if (level == EnumLogLevel.WARN) {

View File

@@ -43,7 +43,6 @@ public final class OriginBlacklistBungee extends Plugin implements Listener, IOr
private boolean papiPlaceholdersEnabled;
private Object papi;
private OriginBlacklist blacklist;
private IEaglerXServerAPI eaglerAPI;
private Metrics metrics;
@Override
@@ -71,8 +70,8 @@ public final class OriginBlacklistBungee extends Plugin implements Listener, IOr
this.papi = null;
}
this.blacklist = new OriginBlacklist(this);
this.eaglerAPI = EaglerXServerAPI.instance();
this.getProxy().getPluginManager().registerCommand(this, new OriginBlacklistCommandBungee(this, this.blacklist, "originblacklist"));
this.getProxy().getPluginManager().registerCommand(this,
new OriginBlacklistCommandBungee(this, this.blacklist, "originblacklist"));
this.getProxy().getPluginManager().registerListener(this, this);
this.blacklist.init();
if (this.blacklist.isMetricsEnabled()) {
@@ -81,7 +80,7 @@ public final class OriginBlacklistBungee extends Plugin implements Listener, IOr
final Map<String, Integer> playerMap = new HashMap<>();
for (final ProxiedPlayer player : this.proxy.getPlayers()) {
final boolean eagler = eaglerAPI.isEaglerPlayerByUUID(player.getUniqueId());
final boolean eagler = this.getEaglerAPI().isEaglerPlayerByUUID(player.getUniqueId());
final String key = eagler ? "Eagler" : "Java";
playerMap.put(key, playerMap.getOrDefault(key, 0) + 1);
}
@@ -114,7 +113,8 @@ public final class OriginBlacklistBungee extends Plugin implements Listener, IOr
final InetSocketAddress vhost = conn.getVirtualHost();
final ProxiedPlayer aPlayer = event.getPlayer();
final OPlayer bPlayer = new OPlayer(null, aPlayer.getName(), aPlayer.getUniqueId(),
aPlayer.getAddress().toString(), aPlayer.getClientBrand(), vhost.getHostString() + vhost.getPort(), conn.getVersion());
aPlayer.getAddress().toString(), aPlayer.getClientBrand(), vhost.getHostString() + vhost.getPort(),
conn.getVersion());
this.blacklist.handleLogin(new OriginBlacklistLoginEvent(null, event, EnumConnectionType.JAVA, bPlayer));
}
@@ -122,7 +122,8 @@ public final class OriginBlacklistBungee extends Plugin implements Listener, IOr
public final void onJavaHandshake(final PreLoginEvent event) {
final PendingConnection conn = event.getConnection();
final InetSocketAddress vhost = conn.getVirtualHost();
final OPlayer player = new OPlayer(null, null, null, conn.getAddress().toString(), OriginBlacklist.UNKNOWN_STR, vhost.getHostString() + vhost.getPort(), conn.getVersion());
final OPlayer player = new OPlayer(null, null, null, conn.getAddress().toString(), OriginBlacklist.UNKNOWN_STR,
vhost.getHostString() + vhost.getPort(), conn.getVersion());
this.blacklist.handleLogin(new OriginBlacklistLoginEvent(null, event, EnumConnectionType.JAVA, player));
}
@@ -130,7 +131,8 @@ public final class OriginBlacklistBungee extends Plugin implements Listener, IOr
public final void onJavaMOTD(final ProxyPingEvent event) {
final PendingConnection conn = event.getConnection();
final InetSocketAddress vhost = conn.getVirtualHost();
final OPlayer player = new OPlayer(null, null, null, conn.getAddress().toString(), null, vhost.getHostString() + vhost.getPort(), -1);
final OPlayer player = new OPlayer(null, null, null, conn.getAddress().toString(), null,
vhost.getHostString() + vhost.getPort(), -1);
this.blacklist.handleMOTD(new OriginBlacklistMOTDEvent(null, event, EnumConnectionType.JAVA, player));
}
@@ -149,6 +151,11 @@ public final class OriginBlacklistBungee extends Plugin implements Listener, IOr
return Paths.get(this.getFile().getAbsolutePath());
}
@Override
public final IEaglerXServerAPI getEaglerAPI() {
return EaglerXServerAPI.instance();
}
@Override
public final void log(final EnumLogLevel level, final String txt) {
if (level == EnumLogLevel.WARN) {

View File

@@ -54,7 +54,6 @@ public final class OriginBlacklistVelocity implements IOriginBlacklistPlugin {
private boolean papiPlaceholdersEnabled;
private Object papi;
private OriginBlacklist blacklist;
private IEaglerXServerAPI eaglerAPI;
private Metrics metrics;
@Inject
@@ -89,7 +88,6 @@ public final class OriginBlacklistVelocity implements IOriginBlacklistPlugin {
this.papi = null;
}
this.blacklist = new OriginBlacklist(this);
this.eaglerAPI = EaglerXServerAPI.instance();
this.proxy.getCommandManager().register("originblacklist", new OriginBlacklistCommandVelocity(this.blacklist));
this.blacklist.init();
if (this.blacklist.isMetricsEnabled()) {
@@ -98,7 +96,7 @@ public final class OriginBlacklistVelocity implements IOriginBlacklistPlugin {
final Map<String, Integer> playerMap = new HashMap<>();
for (final Player player : this.proxy.getAllPlayers()) {
final boolean eagler = eaglerAPI.isEaglerPlayerByUUID(player.getUniqueId());
final boolean eagler = this.getEaglerAPI().isEaglerPlayerByUUID(player.getUniqueId());
final String key = eagler ? "Eagler" : "Java";
playerMap.put(key, playerMap.getOrDefault(key, 0) + 1);
}
@@ -149,7 +147,8 @@ public final class OriginBlacklistVelocity implements IOriginBlacklistPlugin {
public final void onJavaMOTD(final ProxyPingEvent event) {
final InboundConnection conn = event.getConnection();
final InetSocketAddress vhost = conn.getVirtualHost().orElseThrow();
final OPlayer player = new OPlayer(null, null, null, conn.getRemoteAddress().getHostString(), vhost.getHostString() + vhost.getPort(),
final OPlayer player = new OPlayer(null, null, null, conn.getRemoteAddress().getHostString(),
vhost.getHostString() + vhost.getPort(),
null, -1);
this.blacklist.handleMOTD(new OriginBlacklistMOTDEvent(null, event, EnumConnectionType.JAVA, player));
}
@@ -173,6 +172,11 @@ public final class OriginBlacklistVelocity implements IOriginBlacklistPlugin {
}
}
@Override
public final IEaglerXServerAPI getEaglerAPI() {
return EaglerXServerAPI.instance();
}
@Override
public final void log(final EnumLogLevel level, final String txt) {
if (level == EnumLogLevel.WARN) {