mirror of
https://github.com/colbster937/originblacklist.git
synced 2025-06-08 08:44:48 +00:00
Compare commits
No commits in common. "8dbd01f0164f8d6bc7f5ba2d7bd3487dcf157c26" and "a0ab221ff7c62707dce1399cbdc3bbbdc1571093" have entirely different histories.
8dbd01f016
...
a0ab221ff7
@ -18,7 +18,6 @@ basically just a reimplementation of originblacklist but for eaglerxserver
|
|||||||
- [ ] Simple blacklist command
|
- [ ] Simple blacklist command
|
||||||
- [ ] Blacklist -> Whitelist
|
- [ ] Blacklist -> Whitelist
|
||||||
- [ ] IP blacklisting
|
- [ ] IP blacklisting
|
||||||
- [ ] Update system
|
|
||||||
|
|
||||||
### Download
|
### Download
|
||||||
**[https://github.com/colbster937/originblacklist/releases/latest/](https://github.com/colbster937/originblacklist/releases/latest/)**
|
**[https://github.com/colbster937/originblacklist/releases/latest/](https://github.com/colbster937/originblacklist/releases/latest/)**
|
||||||
|
@ -8,7 +8,7 @@ plugins {
|
|||||||
|
|
||||||
|
|
||||||
group = 'dev.colbster937'
|
group = 'dev.colbster937'
|
||||||
version = '1.0.4'
|
version = '1.0.2'
|
||||||
description = 'A reimplementation of OriginBlacklist for EaglerXServer'
|
description = 'A reimplementation of OriginBlacklist for EaglerXServer'
|
||||||
def targetJavaVersion = 17
|
def targetJavaVersion = 17
|
||||||
|
|
||||||
|
@ -4,7 +4,7 @@ import net.kyori.adventure.text.Component;
|
|||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||||
import net.lax1dude.eaglercraft.backend.server.api.*;
|
import net.lax1dude.eaglercraft.backend.server.api.*;
|
||||||
import net.lax1dude.eaglercraft.backend.server.api.event.IEaglercraftClientBrandEvent;
|
import net.lax1dude.eaglercraft.backend.server.api.event.IEaglercraftLoginEvent;
|
||||||
import net.lax1dude.eaglercraft.backend.server.api.event.IEaglercraftMOTDEvent;
|
import net.lax1dude.eaglercraft.backend.server.api.event.IEaglercraftMOTDEvent;
|
||||||
import net.lax1dude.eaglercraft.backend.server.api.query.IMOTDConnection;
|
import net.lax1dude.eaglercraft.backend.server.api.query.IMOTDConnection;
|
||||||
|
|
||||||
@ -34,20 +34,6 @@ public class Base {
|
|||||||
api = api1;
|
api = api1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static String apiVer = "1.0.2";
|
|
||||||
|
|
||||||
public static boolean checkVer(String v1, String v2) {
|
|
||||||
String[] c = v1.split("\\.");
|
|
||||||
String[] r = v2.split("\\.");
|
|
||||||
for (int i = 0; i < Math.max(c.length, r.length); i++) {
|
|
||||||
int c1 = i < c.length ? Integer.parseInt(c[i]) : 0;
|
|
||||||
int r1 = i < r.length ? Integer.parseInt(r[i]) : 0;
|
|
||||||
if (c1 < r1) return false;
|
|
||||||
if (c1 > r1) return true;
|
|
||||||
}
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static LoggerAdapter getLogger() {
|
public static LoggerAdapter getLogger() {
|
||||||
if (adapter == null) throw new IllegalStateException("Logger not initialized!");
|
if (adapter == null) throw new IllegalStateException("Logger not initialized!");
|
||||||
return adapter;
|
return adapter;
|
||||||
@ -59,21 +45,21 @@ public class Base {
|
|||||||
void error(String msg);
|
void error(String msg);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handleConnection(IEaglercraftClientBrandEvent e) {
|
public static void handleConnection(IEaglercraftLoginEvent e) {
|
||||||
IEaglerPendingConnection conn = e.getPendingConnection();
|
IEaglerLoginConnection conn = e.getLoginConnection();
|
||||||
String origin = conn.getWebSocketHeader(EnumWebSocketHeader.HEADER_ORIGIN);
|
String origin = conn.getWebSocketHeader(EnumWebSocketHeader.HEADER_ORIGIN);
|
||||||
String brand = conn.getEaglerBrandString();
|
String brand = conn.getEaglerBrandString();
|
||||||
if ((origin != "null" || origin != null) && !config.blacklist.missing_origin) {
|
if ((origin != "null" || origin != null) && !config.blacklist.missing_origin) {
|
||||||
for (String origin1 : config.blacklist.origins) {
|
for (String origin1 : config.blacklist.origins) {
|
||||||
if (matches(origin, origin1)) {
|
if (matches(origin, origin1)) {
|
||||||
setKickMessage(e, kick("origin", "website", origin, conn.getWebSocketHost()));
|
e.setKickMessage(kick("origin", "website", origin));
|
||||||
webhook(conn, origin, brand, "origin");
|
webhook(conn, origin, brand, "origin");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
if (origin != "null" || origin != null) {
|
if (origin != "null" || origin != null) {
|
||||||
setKickMessage(e, kick("origin", "website", origin, conn.getWebSocketHost()));
|
e.setKickMessage(kick("origin", "website", origin));
|
||||||
webhook(conn, "null", brand, "origin");
|
webhook(conn, "null", brand, "origin");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -81,7 +67,7 @@ public class Base {
|
|||||||
if (brand != "null" && brand != null) {
|
if (brand != "null" && brand != null) {
|
||||||
for (String brand1 : config.blacklist.brands) {
|
for (String brand1 : config.blacklist.brands) {
|
||||||
if (matches(brand, brand1)) {
|
if (matches(brand, brand1)) {
|
||||||
setKickMessage(e, kick("brand", "client", brand, conn.getWebSocketHost()));
|
e.setKickMessage(kick("brand", "client", brand));
|
||||||
webhook(conn, origin, brand, "brand");
|
webhook(conn, origin, brand, "brand");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
@ -89,25 +75,15 @@ public class Base {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void setKickMessage(IEaglercraftClientBrandEvent e, Component msg) {
|
|
||||||
try {
|
|
||||||
e.setKickMessage(msg);
|
|
||||||
} catch (Throwable ignored) {
|
|
||||||
String msg1 = LegacyComponentSerializer.legacySection().serialize(msg);
|
|
||||||
e.setKickMessage(msg1);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void handleMOTD(IEaglercraftMOTDEvent e) {
|
public static void handleMOTD(IEaglercraftMOTDEvent e) {
|
||||||
if (config.messages.motd.enabled) {
|
if (config.messages.motd.enabled) {
|
||||||
IMOTDConnection conn = e.getMOTDConnection();
|
IMOTDConnection conn = e.getMOTDConnection();
|
||||||
String origin = conn.getWebSocketHeader(EnumWebSocketHeader.HEADER_ORIGIN);
|
String origin = conn.getWebSocketHeader(EnumWebSocketHeader.HEADER_ORIGIN);
|
||||||
List<String> m = List.of(config.messages.motd.text.split("\n")).stream()
|
List<String> m = List.of(config.messages.motd.text.split("\n")).stream()
|
||||||
.map(line -> line
|
.map(line -> line
|
||||||
.replaceAll("%blocktype%", "origin")
|
.replace("%blocktype%", "origin")
|
||||||
.replaceAll("%easyblocktype%", "website")
|
.replace("%easyblocktype%", "website")
|
||||||
.replaceAll("%blocked%", origin)
|
.replace("%blocked%", origin))
|
||||||
.replaceAll("%host%", conn.getWebSocketHost()))
|
|
||||||
.map(line -> LegacyComponentSerializer.legacySection().serialize(
|
.map(line -> LegacyComponentSerializer.legacySection().serialize(
|
||||||
MiniMessage.miniMessage().deserialize(
|
MiniMessage.miniMessage().deserialize(
|
||||||
line
|
line
|
||||||
@ -161,13 +137,12 @@ public class Base {
|
|||||||
return text1.toLowerCase().matches(text2.replace(".", "\\.").replaceAll("\\*", ".*").toLowerCase());
|
return text1.toLowerCase().matches(text2.replace(".", "\\.").replaceAll("\\*", ".*").toLowerCase());
|
||||||
}
|
}
|
||||||
|
|
||||||
public static Component kick(String type, String easytype, String value, String host) {
|
public static Component kick(String type, String easytype, String value) {
|
||||||
return MiniMessage.miniMessage().deserialize(
|
return MiniMessage.miniMessage().deserialize(
|
||||||
config.messages.kick
|
config.messages.kick
|
||||||
.replaceAll("%blocktype%", type)
|
.replace("%blocktype%", type)
|
||||||
.replaceAll("%easyblocktype%", easytype)
|
.replace("%easyblocktype%", easytype)
|
||||||
.replaceAll("%blocked%", value)
|
.replace("%blocked%", value)
|
||||||
.replaceAll("%host%", host)
|
|
||||||
);
|
);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -180,7 +155,6 @@ public class Base {
|
|||||||
? (String.valueOf(plr.getRewindProtocolVersion()) != null ? String.valueOf(plr.getRewindProtocolVersion()) : "undefined")
|
? (String.valueOf(plr.getRewindProtocolVersion()) != null ? String.valueOf(plr.getRewindProtocolVersion()) : "undefined")
|
||||||
: (String.valueOf(plr.getMinecraftProtocol()) != null ? String.valueOf(plr.getMinecraftProtocol()) : "undefined");
|
: (String.valueOf(plr.getMinecraftProtocol()) != null ? String.valueOf(plr.getMinecraftProtocol()) : "undefined");
|
||||||
String rewind = plr.isEaglerXRewindPlayer() ? "Yes" : "No";
|
String rewind = plr.isEaglerXRewindPlayer() ? "Yes" : "No";
|
||||||
String host = plr.getWebSocketHost();
|
|
||||||
String userAgent = plr.getWebSocketHeader(EnumWebSocketHeader.HEADER_USER_AGENT);
|
String userAgent = plr.getWebSocketHeader(EnumWebSocketHeader.HEADER_USER_AGENT);
|
||||||
if (userAgent == null || userAgent.isEmpty()) userAgent = "undefined";
|
if (userAgent == null || userAgent.isEmpty()) userAgent = "undefined";
|
||||||
|
|
||||||
@ -190,11 +164,11 @@ public class Base {
|
|||||||
"embeds": [
|
"embeds": [
|
||||||
{
|
{
|
||||||
"title": "Player Information",
|
"title": "Player Information",
|
||||||
"description": "🎮 **Name:** %s\\n🏠 **Address:** %s\\n🌄 **PVN:** %s\\n🌐 **Origin:** %s\\n🔋 **Brand:** %s\\n🪑 **Host:** %s\\n🧊 **User Agent:** %s\\n⏪ **Rewind:** %s"
|
"description": "🎮 **Name:** %s\\n🏠 **Address:** %s\\n🌄 **PVN:** %s\\n🌐 **Origin:** %s\\n🔋 **Brand:** %s\\n🧊 **User Agent:** %s\\n⏪ **Rewind:** %s"
|
||||||
}
|
}
|
||||||
]
|
]
|
||||||
}
|
}
|
||||||
""", type, plr.getAuthUsername(), addr, protocol, origin, brand, host, userAgent, rewind);
|
""", type, plr.getAuthUsername(), addr, protocol, origin, brand, userAgent, rewind);
|
||||||
|
|
||||||
try {
|
try {
|
||||||
HttpURLConnection conn = (HttpURLConnection) new URL(webhook).openConnection();
|
HttpURLConnection conn = (HttpURLConnection) new URL(webhook).openConnection();
|
||||||
|
@ -2,29 +2,16 @@ package dev.colbster937.originblacklist.bukkit;
|
|||||||
|
|
||||||
import dev.colbster937.originblacklist.base.Base;
|
import dev.colbster937.originblacklist.base.Base;
|
||||||
import net.lax1dude.eaglercraft.backend.server.api.bukkit.EaglerXServerAPI;
|
import net.lax1dude.eaglercraft.backend.server.api.bukkit.EaglerXServerAPI;
|
||||||
import net.lax1dude.eaglercraft.backend.server.api.bukkit.event.EaglercraftClientBrandEvent;
|
import net.lax1dude.eaglercraft.backend.server.api.bukkit.event.EaglercraftLoginEvent;
|
||||||
import net.lax1dude.eaglercraft.backend.server.api.bukkit.event.EaglercraftMOTDEvent;
|
import net.lax1dude.eaglercraft.backend.server.api.bukkit.event.EaglercraftMOTDEvent;
|
||||||
import org.bukkit.event.EventHandler;
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.plugin.java.JavaPlugin;
|
import org.bukkit.plugin.java.JavaPlugin;
|
||||||
import org.bukkit.plugin.Plugin;
|
|
||||||
|
|
||||||
public class OriginBlacklistBukkit extends JavaPlugin implements Listener {
|
public class OriginBlacklistBukkit extends JavaPlugin implements Listener {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
Plugin plugin = getServer().getPluginManager().getPlugin("EaglercraftXServer");
|
|
||||||
if (plugin != null) {
|
|
||||||
String version = plugin.getDescription().getVersion();
|
|
||||||
if (!Base.checkVer(version, Base.apiVer)) {
|
|
||||||
getLogger().severe("EaglerXServer " + Base.apiVer + " is required!");
|
|
||||||
throw new RuntimeException("Incompatible API version");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw new RuntimeException("Missing EaglerXServer");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Base.setLogger(new Base.LoggerAdapter() {
|
Base.setLogger(new Base.LoggerAdapter() {
|
||||||
@Override public void info(String msg) { getLogger().info(msg); }
|
@Override public void info(String msg) { getLogger().info(msg); }
|
||||||
@Override public void warn(String msg) { getLogger().warning(msg); }
|
@Override public void warn(String msg) { getLogger().warning(msg); }
|
||||||
@ -42,7 +29,7 @@ public class OriginBlacklistBukkit extends JavaPlugin implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onLogin(EaglercraftClientBrandEvent event) {
|
public void onLogin(EaglercraftLoginEvent event) {
|
||||||
Base.handleConnection(event);
|
Base.handleConnection(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -2,7 +2,7 @@ package dev.colbster937.originblacklist.bungee;
|
|||||||
|
|
||||||
import dev.colbster937.originblacklist.base.Base;
|
import dev.colbster937.originblacklist.base.Base;
|
||||||
import net.lax1dude.eaglercraft.backend.server.api.bungee.EaglerXServerAPI;
|
import net.lax1dude.eaglercraft.backend.server.api.bungee.EaglerXServerAPI;
|
||||||
import net.lax1dude.eaglercraft.backend.server.api.bungee.event.EaglercraftClientBrandEvent;
|
import net.lax1dude.eaglercraft.backend.server.api.bungee.event.EaglercraftLoginEvent;
|
||||||
import net.lax1dude.eaglercraft.backend.server.api.bungee.event.EaglercraftMOTDEvent;
|
import net.lax1dude.eaglercraft.backend.server.api.bungee.event.EaglercraftMOTDEvent;
|
||||||
import net.md_5.bungee.api.plugin.Plugin;
|
import net.md_5.bungee.api.plugin.Plugin;
|
||||||
import net.md_5.bungee.api.plugin.Listener;
|
import net.md_5.bungee.api.plugin.Listener;
|
||||||
@ -12,18 +12,6 @@ public class OriginBlacklistBungee extends Plugin implements Listener {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void onEnable() {
|
public void onEnable() {
|
||||||
Plugin plugin = getProxy().getPluginManager().getPlugin("EaglercraftXServer");
|
|
||||||
if (plugin != null) {
|
|
||||||
String version = plugin.getDescription().getVersion();
|
|
||||||
if (!Base.checkVer(version, Base.apiVer)) {
|
|
||||||
getLogger().severe("EaglerXServer " + Base.apiVer + " is required!");
|
|
||||||
throw new RuntimeException("Incompatible API version");
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
throw new RuntimeException("Missing EaglerXServer");
|
|
||||||
}
|
|
||||||
|
|
||||||
|
|
||||||
Base.setLogger(new Base.LoggerAdapter() {
|
Base.setLogger(new Base.LoggerAdapter() {
|
||||||
@Override public void info(String msg) { getLogger().info(msg); }
|
@Override public void info(String msg) { getLogger().info(msg); }
|
||||||
@Override public void warn(String msg) { getLogger().warning(msg); }
|
@Override public void warn(String msg) { getLogger().warning(msg); }
|
||||||
@ -41,7 +29,7 @@ public class OriginBlacklistBungee extends Plugin implements Listener {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onLogin(EaglercraftClientBrandEvent event) {
|
public void onLogin(EaglercraftLoginEvent event) {
|
||||||
Base.handleConnection(event);
|
Base.handleConnection(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -6,7 +6,7 @@ import com.velocitypowered.api.event.Subscribe;
|
|||||||
import com.velocitypowered.api.proxy.ProxyServer;
|
import com.velocitypowered.api.proxy.ProxyServer;
|
||||||
import dev.colbster937.originblacklist.base.Base;
|
import dev.colbster937.originblacklist.base.Base;
|
||||||
import net.lax1dude.eaglercraft.backend.server.api.velocity.EaglerXServerAPI;
|
import net.lax1dude.eaglercraft.backend.server.api.velocity.EaglerXServerAPI;
|
||||||
import net.lax1dude.eaglercraft.backend.server.api.velocity.event.EaglercraftClientBrandEvent;
|
import net.lax1dude.eaglercraft.backend.server.api.velocity.event.EaglercraftLoginEvent;
|
||||||
import net.lax1dude.eaglercraft.backend.server.api.velocity.event.EaglercraftMOTDEvent;
|
import net.lax1dude.eaglercraft.backend.server.api.velocity.event.EaglercraftMOTDEvent;
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
@ -28,14 +28,6 @@ public class OriginBlacklistVelocity {
|
|||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onProxyInitialization(ProxyInitializeEvent event) {
|
public void onProxyInitialization(ProxyInitializeEvent event) {
|
||||||
proxy.getPluginManager().getPlugin("eaglerxserver").ifPresentOrElse(plugin -> {
|
|
||||||
if (!Base.checkVer(plugin.getDescription().getVersion().orElse("1.0.0"), Base.apiVer)) {
|
|
||||||
logger.error("EaglerXServer " + Base.apiVer + " is required!");
|
|
||||||
throw new RuntimeException("Incompatible api version");
|
|
||||||
}
|
|
||||||
}, () -> {
|
|
||||||
throw new RuntimeException("Missing EaglerXServer");
|
|
||||||
});
|
|
||||||
Base.setApi(EaglerXServerAPI.instance());
|
Base.setApi(EaglerXServerAPI.instance());
|
||||||
Base.reloadConfig();
|
Base.reloadConfig();
|
||||||
Base.init();
|
Base.init();
|
||||||
@ -44,7 +36,7 @@ public class OriginBlacklistVelocity {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
@Subscribe
|
||||||
public void onLogin(EaglercraftClientBrandEvent event) {
|
public void onLogin(EaglercraftLoginEvent event) {
|
||||||
Base.handleConnection(event);
|
Base.handleConnection(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,7 +3,6 @@ messages:
|
|||||||
# - %blocked% - The player's origin/brand that was blocked
|
# - %blocked% - The player's origin/brand that was blocked
|
||||||
# - %blocktype% - Shows what the player was blocked for
|
# - %blocktype% - Shows what the player was blocked for
|
||||||
# - %easyblocktype% - Shows what the player was blocked for in an eagler-kid readable form
|
# - %easyblocktype% - Shows what the player was blocked for in an eagler-kid readable form
|
||||||
# - %host% - The IP the player pinged
|
|
||||||
|
|
||||||
kick: |
|
kick: |
|
||||||
<red>This %easyblocktype% is not allowed on the server!</red>
|
<red>This %easyblocktype% is not allowed on the server!</red>
|
||||||
@ -64,6 +63,7 @@ discord:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
# :>
|
# :>
|
Loading…
x
Reference in New Issue
Block a user