mirror of
https://github.com/colbster937/originblacklist.git
synced 2025-06-08 00:34:48 +00:00
Compare commits
No commits in common. "26483772769e1513bccb105398dbab5e47c31906" and "0f80dded6384cf45f9933bf977b167c549f3bb22" have entirely different histories.
2648377276
...
0f80dded63
@ -8,7 +8,6 @@ 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
|
||||
|
@ -8,7 +8,7 @@ plugins {
|
||||
|
||||
|
||||
group = 'dev.colbster937'
|
||||
version = '1.0.6'
|
||||
version = '1.0.5'
|
||||
description = 'A reimplementation of OriginBlacklist for EaglerXServer'
|
||||
def targetJavaVersion = 17
|
||||
|
||||
|
@ -4,6 +4,7 @@ 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.*;
|
||||
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.query.IMOTDConnection;
|
||||
@ -13,6 +14,8 @@ import java.awt.image.BufferedImage;
|
||||
import java.io.*;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URL;
|
||||
import java.nio.charset.Charset;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
import java.nio.file.Files;
|
||||
import java.nio.file.StandardCopyOption;
|
||||
import java.util.List;
|
||||
@ -66,43 +69,41 @@ public class Base {
|
||||
IEaglerLoginConnection conn = e.getLoginConnection();
|
||||
String origin = conn.getWebSocketHeader(EnumWebSocketHeader.HEADER_ORIGIN);
|
||||
String brand = conn.getEaglerBrandString();
|
||||
String name = conn.getUsername();
|
||||
|
||||
if (origin != null && !origin.equals("null")) {
|
||||
if (origin != null && !origin.equals("null") && !config.blacklist.missing_origin) {
|
||||
for (String origin1 : config.blacklist.origins) {
|
||||
if (matches(origin, origin1)) {
|
||||
setKick(e, formatKickMessage("origin", "website", origin, conn.getWebSocketHost()));
|
||||
setKick(e, kick("origin", "website", origin, conn.getWebSocketHost()));
|
||||
webhook(conn, origin, brand, "origin");
|
||||
return;
|
||||
}
|
||||
}
|
||||
} else if (origin != null && !origin.equals("null")) {
|
||||
setKick(e, kick("origin", "website", origin, conn.getWebSocketHost()));
|
||||
webhook(conn, "null", brand, "origin");
|
||||
return;
|
||||
}
|
||||
|
||||
if (brand != null && !brand.equals("null")) {
|
||||
for (String brand1 : config.blacklist.brands) {
|
||||
if (matches(brand, brand1)) {
|
||||
setKick(e, formatKickMessage("brand", "client", brand, conn.getWebSocketHost()));
|
||||
setKick(e, kick("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 {
|
||||
String redir = config.blacklist.blacklist_redirect;
|
||||
if (redir.equals("") || redir.equals("null")) {
|
||||
e.setKickMessage(msg);
|
||||
} else {
|
||||
e.setKickRedirect(redir);
|
||||
}
|
||||
getLogger().info("Kicked " + e.getProfileUsername());
|
||||
e.setKickMessage(msg);
|
||||
} catch (Throwable ignored) {
|
||||
String msg1 = LegacyComponentSerializer.legacySection().serialize(msg);
|
||||
e.setKickMessage(msg1);
|
||||
@ -123,7 +124,7 @@ public class Base {
|
||||
MiniMessage.miniMessage().deserialize(line)))
|
||||
.collect(Collectors.toList());
|
||||
|
||||
if (origin != null && !origin.equals("null")) {
|
||||
if (origin != null && !origin.equals("null") && !config.blacklist.missing_origin) {
|
||||
for (String origin1 : config.blacklist.origins) {
|
||||
if (matches(origin, origin1)) {
|
||||
setMOTD(conn, m);
|
||||
@ -172,16 +173,9 @@ public class Base {
|
||||
return text1.toLowerCase().matches(text2.replace(".", "\\.").replaceAll("\\*", ".*").toLowerCase());
|
||||
}
|
||||
|
||||
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;
|
||||
}
|
||||
public static Component kick(String type, String easytype, String value, String host) {
|
||||
return MiniMessage.miniMessage().deserialize(
|
||||
config.messages.kick
|
||||
.replaceAll("%help%", help)
|
||||
.replaceAll("%blocktype%", type)
|
||||
.replaceAll("%easyblocktype%", easytype)
|
||||
.replaceAll("%blocked%", value)
|
||||
|
@ -79,7 +79,6 @@ public class ConfigManager {
|
||||
public static class Messages {
|
||||
public String kick;
|
||||
public MOTD motd;
|
||||
public Help help;
|
||||
}
|
||||
|
||||
public static class MOTD {
|
||||
@ -87,9 +86,4 @@ public class ConfigManager {
|
||||
public String text;
|
||||
public String icon;
|
||||
}
|
||||
|
||||
public static class Help {
|
||||
public String generic;
|
||||
public String player;
|
||||
}
|
||||
}
|
||||
|
@ -4,21 +4,13 @@ messages:
|
||||
# - %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
|
||||
@ -35,8 +27,8 @@ blacklist:
|
||||
brands:
|
||||
- "*dragonx*"
|
||||
- "*piclient*"
|
||||
players:
|
||||
- "Admin"
|
||||
missing_origin: false
|
||||
blacklist_redirect: ""
|
||||
|
||||
discord:
|
||||
webhook: ""
|
||||
@ -55,6 +47,15 @@ discord:
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user