Compare commits

...

19 Commits
dev ... main

Author SHA1 Message Date
Colbster937
1a22788630
change back number of lines before eagler face :> 2025-05-21 18:16:02 -05:00
Colbster937
cf0481fb58
Merge pull request #1 from Atticuss26/main
Update config.yml to add a hacked client site
2025-05-21 18:15:02 -05:00
Colbster937
f8ea6d5bfd
Add more hacked clients 2025-05-21 18:14:47 -05:00
Atticuss26
8d5e5d688b
Update config.yml to add a hacked client site 2025-05-21 16:04:58 -07:00
Colbster937
2648377276 ? 2025-05-13 19:17:57 -05:00
Colbster937
16953bc708 1.0.6 cool cool player blacklisting 2025-05-13 19:15:57 -05:00
Colbster937
0f80dded63 fix some logic 2025-05-11 14:41:03 -05:00
Colbster937
af478adb3b fix some logic 2025-05-11 14:40:36 -05:00
Colbster937
8dbd01f016 remove temp files 2025-05-08 11:25:06 -05:00
Colbster937
71ad3059cc use .replaceAll instead of .replace 2025-05-08 11:24:44 -05:00
Colbster937
c5a2b1002f Fix OriginBlacklist on bungeecord 2025-05-08 11:12:46 -05:00
Colbster937
4d0f0542ca Fix OriginBlacklist on bungeecord 2025-05-08 11:12:27 -05:00
Colbster937
5453ed0280 fix plugin name on bukkit & bungee 2025-05-08 10:47:41 -05:00
Colbster937
47ab6554c4 Update readme 2025-05-08 10:40:01 -05:00
Colbster937
c076d48e06 use EaglercraftClientBrandEvent instead of EaglercraftLoginEvent 2025-05-08 10:39:53 -05:00
Colbster937
a0ab221ff7 update readme 2025-05-07 19:27:14 -05:00
Colbster937
ec6f618971 better workflow 2025-05-07 19:23:16 -05:00
Colbster937
a417fa7281 fix readme 2025-05-07 19:19:30 -05:00
Colbster937
c62cdb8a7e fix workflow final 2025-05-07 19:19:07 -05:00
10 changed files with 238 additions and 110 deletions

View File

@ -36,16 +36,29 @@ jobs:
name: OriginBlacklist
path: build/libs/OriginBlacklist.jar
- name: Extract Version
id: version
run: |
VERSION=$(grep "^version" build.gradle | head -n 1 | cut -d\' -f2)
echo "version=$VERSION" >> "$GITHUB_OUTPUT"
- name: Remove Existing Release
run: |
gh release delete v${{ steps.version.outputs.version }} -y || true
git push origin :refs/tags/v${{ steps.version.outputs.version }} || true
env:
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
- name: Create Release
id: create_release
uses: actions/create-release@v1
uses: softprops/action-gh-release@v1
with:
tag_name: v${{ steps.version.outputs.version }}
name: ${{ steps.version.outputs.version }}
draft: false
prerelease: false
env:
GITHUB_TOKEN: ${{ secrets.GITHUB_TOKEN }}
with:
tag_name: dev
release_name: dev
draft: true
prerelease: true
- uses: actions/upload-release-asset@v1.0.1
env:
@ -53,7 +66,7 @@ jobs:
with:
upload_url: ${{ steps.create_release.outputs.upload_url }}
asset_path: ./build/libs/OriginBlacklist.jar
asset_name: OriginBlacklist.jar
asset_name: OriginBlacklist_${{ steps.version.outputs.version }}.jar
asset_content_type: application/java-archive
- uses: eregon/publish-release@v1

1
.gitignore vendored
View File

@ -4,5 +4,6 @@
gradle
build
run
bin
gradlew
gradlew.bat

View File

@ -8,6 +8,7 @@ basically just a reimplementation of originblacklist but for eaglerxserver
### Features
- [x] Origin Blacklisting
- [x] Brand Blacklisting
- [x] Username blacklisting
- [x] Custom kick message
- [x] Custom blacklist MOTD
- [x] MiniMessage formatting for messages
@ -18,9 +19,10 @@ basically just a reimplementation of originblacklist but for eaglerxserver
- [ ] Simple blacklist command
- [ ] Blacklist -> Whitelist
- [ ] IP blacklisting
- [ ] Update system
### Download
**https://nightly.link/colbster937/originblacklist/workflows/build/main/OriginBlacklist.zip](https://nightly.link/colbster937/originblacklist/workflows/build/main/OriginBlacklist.zip)**
**[https://github.com/colbster937/originblacklist/releases/latest/](https://github.com/colbster937/originblacklist/releases/latest/)**
### Building
```

View File

@ -8,7 +8,7 @@ plugins {
group = 'dev.colbster937'
version = '1.0.2'
version = '1.0.6'
description = 'A reimplementation of OriginBlacklist for EaglerXServer'
def targetJavaVersion = 17
@ -64,7 +64,7 @@ java {
}
processResources {
filesMatching(['plugin.yml', 'bungee.yml', 'velocity-plugin.json']) {
filesMatching(['plugin.yml', 'bungee.yml', 'velocity-plugin.json', 'Base.java']) {
expand(
version: project.version,
description: project.description

View File

@ -8,17 +8,15 @@ 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.query.IMOTDConnection;
import java.io.InputStream;
import java.io.OutputStream;
import java.net.HttpURLConnection;
import javax.imageio.ImageIO;
import java.awt.image.BufferedImage;
import java.io.File;
import java.io.IOException;
import java.io.*;
import java.net.HttpURLConnection;
import java.net.URL;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.List;
import java.util.concurrent.CompletableFuture;
import java.util.stream.Collectors;
public class Base {
@ -34,14 +32,33 @@ public class Base {
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() {
if (adapter == null) throw new IllegalStateException("Logger not initialized!");
if (adapter == null)
throw new IllegalStateException("Logger not initialized!");
return adapter;
}
public interface LoggerAdapter {
void info(String msg);
void warn(String msg);
void error(String msg);
}
@ -49,30 +66,47 @@ public class Base {
IEaglerLoginConnection conn = e.getLoginConnection();
String origin = conn.getWebSocketHeader(EnumWebSocketHeader.HEADER_ORIGIN);
String brand = conn.getEaglerBrandString();
if ((origin != "null" || origin != null) && !config.blacklist.missing_origin) {
String name = conn.getUsername();
if (origin != null && !origin.equals("null")) {
for (String origin1 : config.blacklist.origins) {
if (matches(origin, origin1)) {
e.setKickMessage(kick("origin", "website", origin));
setKick(e, formatKickMessage("origin", "website", origin, conn.getWebSocketHost()));
webhook(conn, origin, brand, "origin");
return;
}
}
} else {
if (origin != "null" || origin != null) {
e.setKickMessage(kick("origin", "website", origin));
webhook(conn, "null", brand, "origin");
return;
}
}
if (brand != "null" && brand != null) {
if (brand != null && !brand.equals("null")) {
for (String brand1 : config.blacklist.brands) {
if (matches(brand, brand1)) {
e.setKickMessage(kick("brand", "client", brand));
setKick(e, formatKickMessage("brand", "client", brand, conn.getWebSocketHost()));
webhook(conn, origin, brand, "brand");
return;
}
}
}
if (name != null && !name.equals("null")) {
for (String name1 : config.blacklist.players) {
if (matches(name, name1) || (name.length() > 16 || name.length() < 3)) {
setKick(e, formatKickMessage("player", "username", name, conn.getWebSocketHost()));
webhook(conn, origin, name, "player");
return;
}
}
}
}
public static void setKick(IEaglercraftLoginEvent e, Component msg) {
try {
getLogger().info("Kicked " + e.getProfileUsername());
e.setKickMessage(msg);
} catch (Throwable ignored) {
String msg1 = LegacyComponentSerializer.legacySection().serialize(msg);
e.setKickMessage(msg1);
}
}
public static void handleMOTD(IEaglercraftMOTDEvent e) {
@ -81,25 +115,23 @@ public class Base {
String origin = conn.getWebSocketHeader(EnumWebSocketHeader.HEADER_ORIGIN);
List<String> m = List.of(config.messages.motd.text.split("\n")).stream()
.map(line -> line
.replace("%blocktype%", "origin")
.replace("%easyblocktype%", "website")
.replace("%blocked%", origin))
.replaceAll("%blocktype%", "origin")
.replaceAll("%easyblocktype%", "website")
.replaceAll("%blocked%", origin)
.replaceAll("%host%", conn.getWebSocketHost()))
.map(line -> LegacyComponentSerializer.legacySection().serialize(
MiniMessage.miniMessage().deserialize(
line
)
)).collect(Collectors.toList());
if ((origin != "null" || origin != null) && !config.blacklist.missing_origin) {
MiniMessage.miniMessage().deserialize(line)))
.collect(Collectors.toList());
if (origin != null && !origin.equals("null")) {
for (String origin1 : config.blacklist.origins) {
if (matches(origin, origin1)) {
setMOTD(conn, m);
return;
}
}
} else {
if (origin != "null" || origin != null) {
setMOTD(conn, m);
}
} else if (origin != null && !origin.equals("null")) {
setMOTD(conn, m);
}
}
}
@ -109,13 +141,15 @@ public class Base {
conn.setPlayerTotal(0);
conn.setPlayerMax(0);
conn.setPlayerList(List.of());
if (config.messages.motd.icon != null && !config.messages.motd.icon.isEmpty())
if (config.messages.motd.icon != null && !config.messages.motd.icon.isEmpty()) {
try {
BufferedImage img = ImageIO.read(new File(config.messages.motd.icon));
if (img.getWidth() != 64 || img.getHeight() != 64) {
getLogger().warn("Icon must be 64x64");
return;
}
byte[] bytes = new byte[64 * 64 * 4];
for (int y = 0; y < 64; y++) {
for (int x = 0; x < 64; x++) {
@ -131,61 +165,74 @@ public class Base {
} catch (IOException ex) {
getLogger().error(ex.toString());
}
}
}
public static boolean matches(String text1, String text2) {
return text1.toLowerCase().matches(text2.replace(".", "\\.").replaceAll("\\*", ".*").toLowerCase());
}
public static Component kick(String type, String easytype, String value) {
public static Component formatKickMessage(String type, String easytype, String value, String host) {
String help = "";
if (type != "player") {
help = config.messages.help.generic;
} else {
help = config.messages.help.player;
}
return MiniMessage.miniMessage().deserialize(
config.messages.kick
.replace("%blocktype%", type)
.replace("%easyblocktype%", easytype)
.replace("%blocked%", value)
);
.replaceAll("%help%", help)
.replaceAll("%blocktype%", type)
.replaceAll("%easyblocktype%", easytype)
.replaceAll("%blocked%", value)
.replaceAll("%host%", host));
}
public static void webhook(IEaglerPendingConnection plr, String origin, String brand, String type) {
public static void webhook(IEaglerLoginConnection plr, String origin, String brand, String type) {
String webhook = config.discord.webhook;
if (webhook == null || webhook.isBlank()) return;
if (webhook == null || webhook.isBlank())
return;
String addr = plr.getPlayerAddress() != null ? plr.getPlayerAddress().toString().substring(1) : "undefined";
String protocol = plr.isEaglerXRewindPlayer()
? (String.valueOf(plr.getRewindProtocolVersion()) != null ? String.valueOf(plr.getRewindProtocolVersion()) : "undefined")
: (String.valueOf(plr.getMinecraftProtocol()) != null ? String.valueOf(plr.getMinecraftProtocol()) : "undefined");
String rewind = plr.isEaglerXRewindPlayer() ? "Yes" : "No";
String userAgent = plr.getWebSocketHeader(EnumWebSocketHeader.HEADER_USER_AGENT);
if (userAgent == null || userAgent.isEmpty()) userAgent = "undefined";
CompletableFuture.runAsync(() -> {
String addr = (plr.getPlayerAddress() != null ? plr.getPlayerAddress().toString().substring(1) : "undefined:undefined").split(":")[0];
int protocol = !plr.isEaglerXRewindPlayer() ? plr.getMinecraftProtocol() : plr.getRewindProtocolVersion();
String host = plr.getWebSocketHost();
String userAgent = plr.getWebSocketHeader(EnumWebSocketHeader.HEADER_USER_AGENT);
Boolean rewind = plr.isEaglerXRewindPlayer();
if (userAgent == null || userAgent.isEmpty())
userAgent = "undefined";
String payload = String.format("""
{
"content": "Blocked a blacklisted %s from joining",
"embeds": [
{
"title": "Player Information",
"description": "🎮 **Name:** %s\\n🏠 **Address:** %s\\n🌄 **PVN:** %s\\n🌐 **Origin:** %s\\n🔋 **Brand:** %s\\n🧊 **User Agent:** %s\\n⏪ **Rewind:** %s"
String payload = String.format(
"""
{
"content": "Blocked a blacklisted %s from joining",
"embeds": [
{
"title": "Player Information",
"description": "🎮 **Name:** %s\\n🏠 **IP:** %s\\n🌄 **PVN:** %s\\n🌐 **Origin:** %s\\n🔋 **Brand:** %s\\n🪑 **Host:** %s\\n🧊 **User Agent:** %s\\n⏪ **Rewind:** %s"
}
]
}
""",
type, plr.getUsername(), addr, protocol, origin, brand, plr.isWebSocketSecure() ? "wss://" : "ws://" + host, userAgent, rewind ? "Yes" : "No");
try {
HttpURLConnection conn = (HttpURLConnection) new URL(webhook).openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/json");
conn.setDoOutput(true);
conn.setConnectTimeout(5000);
conn.setReadTimeout(5000);
try (OutputStream os = conn.getOutputStream()) {
os.write(payload.getBytes());
}
conn.getInputStream().close();
} catch (Exception e) {
getLogger().warn("Failed to send webhook: " + e);
}
]
}
""", type, plr.getAuthUsername(), addr, protocol, origin, brand, userAgent, rewind);
try {
HttpURLConnection conn = (HttpURLConnection) new URL(webhook).openConnection();
conn.setRequestMethod("POST");
conn.setRequestProperty("Content-Type", "application/json");
conn.setDoOutput(true);
conn.setConnectTimeout(5000);
conn.setReadTimeout(5000);
try (OutputStream os = conn.getOutputStream()) {
os.write(payload.getBytes());
}
conn.getInputStream().close();
} catch (Exception e) {
getLogger().warn("Failed to send webhook: " + e);
}
});
}
public static void init() {

View File

@ -3,47 +3,73 @@ package dev.colbster937.originblacklist.base;
import org.yaml.snakeyaml.Yaml;
import org.yaml.snakeyaml.LoaderOptions;
import org.yaml.snakeyaml.constructor.Constructor;
import java.io.File;
import java.io.InputStream;
import java.io.FileInputStream;
import java.io.IOException;
import org.yaml.snakeyaml.DumperOptions;
import java.io.*;
import java.nio.file.Files;
import java.nio.file.StandardCopyOption;
import java.util.List;
import java.util.Map;
public class ConfigManager {
public Messages messages = new Messages();
public List<String> subscriptions;
public List<String> subscriptions = List.of();
public Blacklist blacklist = new Blacklist();
public Discord discord = new Discord();
public static ConfigManager loadConfig(Base.LoggerAdapter logger) {
File conf = new File("plugins/originblacklist/config.yml");
File f = new File("plugins/originblacklist/config.yml");
try {
if (!conf.exists()) {
conf.getParentFile().mkdirs();
if (!f.exists()) {
f.getParentFile().mkdirs();
try (InputStream in = ConfigManager.class.getResourceAsStream("/config.yml")) {
if (in != null) {
Files.copy(in, conf.toPath(), StandardCopyOption.REPLACE_EXISTING);
}
if (in != null) Files.copy(in, f.toPath(), StandardCopyOption.REPLACE_EXISTING);
}
}
LoaderOptions options = new LoaderOptions();
Constructor constructor = new Constructor(ConfigManager.class, options);
Yaml yaml = new Yaml(constructor);
return yaml.load(new FileInputStream(conf));
Yaml y = new Yaml(new Constructor(ConfigManager.class, new LoaderOptions()));
ConfigManager l;
try (InputStream in = new FileInputStream(f)) { l = y.load(in); }
if (l == null) l = new ConfigManager();
Yaml raw = new Yaml();
Map<String, Object> u = raw.load(new FileInputStream(f));
Map<String, Object> d = raw.load(ConfigManager.class.getResourceAsStream("/config.yml"));
if (mergeConfig(u, d)) saveConfig(u, f);
return l;
} catch (IOException e) {
return new ConfigManager();
}
}
@SuppressWarnings("unchecked")
private static boolean mergeConfig(Map<String, Object> u, Map<String, Object> d) {
boolean c = false;
for (String k : d.keySet()) {
if (!u.containsKey(k)) {
u.put(k, d.get(k));
c = true;
} else if (u.get(k) instanceof Map && d.get(k) instanceof Map)
c |= mergeConfig((Map<String, Object>) u.get(k), (Map<String, Object>) d.get(k));
}
return c;
}
private static void saveConfig(Map<String, Object> m, File f) throws IOException {
DumperOptions o = new DumperOptions();
o.setDefaultFlowStyle(DumperOptions.FlowStyle.BLOCK);
o.setPrettyFlow(true);
new Yaml(o).dump(m, new FileWriter(f));
}
public static class Blacklist {
public List<String> origins;
public List<String> brands;
public List<String> players;
public boolean missing_origin;
public String blacklist_redirect;
}
public static class Discord {
@ -53,6 +79,7 @@ public class ConfigManager {
public static class Messages {
public String kick;
public MOTD motd;
public Help help;
}
public static class MOTD {
@ -60,4 +87,9 @@ public class ConfigManager {
public String text;
public String icon;
}
public static class Help {
public String generic;
public String player;
}
}

View File

@ -7,11 +7,24 @@ import net.lax1dude.eaglercraft.backend.server.api.bukkit.event.EaglercraftMOTDE
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.plugin.Plugin;
public class OriginBlacklistBukkit extends JavaPlugin implements Listener {
@Override
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() {
@Override public void info(String msg) { getLogger().info(msg); }
@Override public void warn(String msg) { getLogger().warning(msg); }

View File

@ -12,6 +12,18 @@ public class OriginBlacklistBungee extends Plugin implements Listener {
@Override
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() {
@Override public void info(String msg) { getLogger().info(msg); }
@Override public void warn(String msg) { getLogger().warning(msg); }

View File

@ -28,6 +28,14 @@ public class OriginBlacklistVelocity {
@Subscribe
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.reloadConfig();
Base.init();

View File

@ -3,13 +3,22 @@ messages:
# - %blocked% - The player's origin/brand that was blocked
# - %blocktype% - Shows what the player was blocked for
# - %easyblocktype% - Shows what the player was blocked for in an eagler-kid readable form
# - %host% - The IP the player pinged
# - %help% - The configured help message for the block type
kick: |
<red>This %easyblocktype% is not allowed on the server!</red>
<dark_gray>»</dark_gray> <gray>%blocked%</gray> <dark_gray>«</dark_gray>
%help%
<gray>Think this is a mistake? Join our discord:</gray>
<blue>discord.gg/changethisintheconfig</blue>
# Please note that help is only supported in the kick message, not the MOTD
help:
generic: "<gray>Please switch to a different %easyblocktype%.</gray>"
player: "<gray>Please change your %easyblocktype%.</gray>"
motd:
enabled: true
@ -22,11 +31,14 @@ messages:
# Everything should be lowercase
blacklist:
origins:
- "hack.example.com"
- "*eagler-clients.vercel.app*"
- "*eaglerhackedclients.vercel.app*"
- "*eaglerhacks.github.io*"
brands:
- "*dragonx*"
- "*piclient*"
missing_origin: false
players:
- "Admin"
discord:
webhook: ""
@ -54,16 +66,4 @@ discord:
# :>
# :>