mirror of
https://github.com/colbster937/originblacklist.git
synced 2025-06-08 08:44:48 +00:00
Compare commits
No commits in common. "7de763e640f74551ac4c1e48ff4356cc5a0c417b" and "fdf4847239826a7db8bfb4413c4a84f11c7189b3" have entirely different histories.
7de763e640
...
fdf4847239
15
README.md
15
README.md
@ -5,26 +5,11 @@ basically just a reimplementation of originblacklist but for eaglerxserver
|
|||||||
> [!WARNING]
|
> [!WARNING]
|
||||||
> **Velocity is the main platform I'm developing this for, bungee & bukkit will still work but will probably have some bugs and will receive less support!**
|
> **Velocity is the main platform I'm developing this for, bungee & bukkit will still work but will probably have some bugs and will receive less support!**
|
||||||
|
|
||||||
### Features
|
|
||||||
- [x] Origin Blacklisting
|
|
||||||
- [x] Brand Blacklisting
|
|
||||||
- [x] Custom kick message
|
|
||||||
- [x] Custom blacklist MOTD
|
|
||||||
- [x] MiniMessage formatting for messages
|
|
||||||
- [x] Velocity, *Bungee, and *Bukkit support
|
|
||||||
<br>_<sub><span style="color:gray">Bungee and Bukkit are should work, but have bugs.</span></sub>_
|
|
||||||
- [x] Send blacklists to a discord webhook
|
|
||||||
- [ ] Blacklist subscription URLs
|
|
||||||
- [ ] Blacklist -> Whitelist
|
|
||||||
- [ ] IP blacklisting
|
|
||||||
|
|
||||||
### Download
|
### Download
|
||||||
**[https://github.com/colbster937/originblacklist/releases](https://github.com/colbster937/originblacklist/releases)**
|
**[https://github.com/colbster937/originblacklist/releases](https://github.com/colbster937/originblacklist/releases)**
|
||||||
|
|
||||||
### Building
|
### Building
|
||||||
```
|
```
|
||||||
$ git clone https://github.com/colbster937/originblacklist.git
|
|
||||||
$ cd originblacklist
|
|
||||||
$ gradle wrapper
|
$ gradle wrapper
|
||||||
$ ./gradle.<bat|sh> shadowJar
|
$ ./gradle.<bat|sh> shadowJar
|
||||||
```
|
```
|
@ -8,7 +8,7 @@ plugins {
|
|||||||
|
|
||||||
|
|
||||||
group = 'dev.colbster937'
|
group = 'dev.colbster937'
|
||||||
version = '1.0.1'
|
version = '1.0.0'
|
||||||
|
|
||||||
repositories {
|
repositories {
|
||||||
mavenCentral()
|
mavenCentral()
|
||||||
|
@ -6,21 +6,9 @@ import net.lax1dude.eaglercraft.backend.server.api.IEaglerXServerAPI;
|
|||||||
import net.lax1dude.eaglercraft.backend.server.api.IEaglerPlayer;
|
import net.lax1dude.eaglercraft.backend.server.api.IEaglerPlayer;
|
||||||
import net.lax1dude.eaglercraft.backend.server.api.EnumWebSocketHeader;
|
import net.lax1dude.eaglercraft.backend.server.api.EnumWebSocketHeader;
|
||||||
import net.lax1dude.eaglercraft.backend.server.api.event.IEaglercraftInitializePlayerEvent;
|
import net.lax1dude.eaglercraft.backend.server.api.event.IEaglercraftInitializePlayerEvent;
|
||||||
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.io.OutputStream;
|
||||||
import java.net.HttpURLConnection;
|
import java.net.HttpURLConnection;
|
||||||
import javax.imageio.ImageIO;
|
|
||||||
import java.awt.image.BufferedImage;
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.net.URL;
|
import java.net.URL;
|
||||||
import java.nio.file.Files;
|
|
||||||
import java.nio.file.StandardCopyOption;
|
|
||||||
import java.util.List;
|
|
||||||
import java.util.stream.Collectors;
|
|
||||||
|
|
||||||
public class Base {
|
public class Base {
|
||||||
private static LoggerAdapter adapter;
|
private static LoggerAdapter adapter;
|
||||||
@ -73,60 +61,6 @@ public class Base {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void handleMOTD(IEaglercraftMOTDEvent e) {
|
|
||||||
if (config.messages.motd.enabled) {
|
|
||||||
IMOTDConnection conn = e.getMOTDConnection();
|
|
||||||
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))
|
|
||||||
.map(line -> LegacyComponentSerializer.legacySection()
|
|
||||||
.serialize(MiniMessage.miniMessage().deserialize(line)))
|
|
||||||
.collect(Collectors.toList());
|
|
||||||
if ((origin != "null" || origin != null) && !config.blacklist.missing_origin) {
|
|
||||||
for (String origin1 : config.blacklist.origins) {
|
|
||||||
if (matches(origin, origin1)) {
|
|
||||||
setMOTD(conn, m);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
} else {
|
|
||||||
setMOTD(conn, m);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void setMOTD(IMOTDConnection conn, List<String> m) {
|
|
||||||
conn.setServerMOTD(m);
|
|
||||||
conn.setPlayerTotal(0);
|
|
||||||
conn.setPlayerMax(0);
|
|
||||||
conn.setPlayerList(List.of());
|
|
||||||
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++) {
|
|
||||||
int pixel = img.getRGB(x, y);
|
|
||||||
int i = (y * 64 + x) * 4;
|
|
||||||
bytes[i] = (byte) ((pixel >> 16) & 0xFF);
|
|
||||||
bytes[i + 1] = (byte) ((pixel >> 8) & 0xFF);
|
|
||||||
bytes[i + 2] = (byte) (pixel & 0xFF);
|
|
||||||
bytes[i + 3] = (byte) ((pixel >> 24) & 0xFF);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
conn.setServerIcon(bytes);
|
|
||||||
} catch (IOException ex) {
|
|
||||||
getLogger().error(ex.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static boolean matches(String text1, String text2) {
|
public static boolean matches(String text1, String text2) {
|
||||||
return text1.toLowerCase().matches(text2.replace(".", "\\.").replaceAll("\\*", ".*").toLowerCase());
|
return text1.toLowerCase().matches(text2.replace(".", "\\.").replaceAll("\\*", ".*").toLowerCase());
|
||||||
}
|
}
|
||||||
@ -185,19 +119,6 @@ public class Base {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void init() {
|
|
||||||
File motdIcon = new File(config.messages.motd.icon);
|
|
||||||
if (!motdIcon.exists()) {
|
|
||||||
try (InputStream in = ConfigManager.class.getResourceAsStream("/server-blocked.png")) {
|
|
||||||
if (in != null) {
|
|
||||||
Files.copy(in, motdIcon.toPath(), StandardCopyOption.REPLACE_EXISTING);
|
|
||||||
}
|
|
||||||
} catch (IOException e) {
|
|
||||||
getLogger().warn(e.toString());
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void reloadConfig() {
|
public static void reloadConfig() {
|
||||||
config = ConfigManager.loadConfig(adapter);
|
config = ConfigManager.loadConfig(adapter);
|
||||||
}
|
}
|
||||||
|
@ -44,6 +44,8 @@ public class ConfigManager {
|
|||||||
public List<String> brands;
|
public List<String> brands;
|
||||||
public List<String> players;
|
public List<String> players;
|
||||||
public boolean missing_origin;
|
public boolean missing_origin;
|
||||||
|
|
||||||
|
public Blacklist() {}
|
||||||
}
|
}
|
||||||
|
|
||||||
public static class Discord {
|
public static class Discord {
|
||||||
@ -52,12 +54,5 @@ public class ConfigManager {
|
|||||||
|
|
||||||
public static class Messages {
|
public static class Messages {
|
||||||
public String kick;
|
public String kick;
|
||||||
public MOTD motd;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static class MOTD {
|
|
||||||
public boolean enabled;
|
|
||||||
public String text;
|
|
||||||
public String icon;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ 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.EaglercraftInitializePlayerEvent;
|
import net.lax1dude.eaglercraft.backend.server.api.bukkit.event.EaglercraftInitializePlayerEvent;
|
||||||
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;
|
||||||
@ -20,7 +19,6 @@ public class OriginBlacklistBukkit extends JavaPlugin implements Listener {
|
|||||||
|
|
||||||
Base.setApi(EaglerXServerAPI.instance());
|
Base.setApi(EaglerXServerAPI.instance());
|
||||||
Base.reloadConfig();
|
Base.reloadConfig();
|
||||||
Base.init();
|
|
||||||
|
|
||||||
getCommand("originblacklist").setExecutor(new CommandBukkit());
|
getCommand("originblacklist").setExecutor(new CommandBukkit());
|
||||||
getServer().getPluginManager().registerEvents(this, this);
|
getServer().getPluginManager().registerEvents(this, this);
|
||||||
@ -32,9 +30,4 @@ public class OriginBlacklistBukkit extends JavaPlugin implements Listener {
|
|||||||
public void onLogin(EaglercraftInitializePlayerEvent event) {
|
public void onLogin(EaglercraftInitializePlayerEvent event) {
|
||||||
Base.handleConnection(event);
|
Base.handleConnection(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onMOTD(EaglercraftMOTDEvent event) {
|
|
||||||
Base.handleMOTD(event);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -3,7 +3,6 @@ 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.EaglercraftInitializePlayerEvent;
|
import net.lax1dude.eaglercraft.backend.server.api.bungee.event.EaglercraftInitializePlayerEvent;
|
||||||
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;
|
||||||
import net.md_5.bungee.event.EventHandler;
|
import net.md_5.bungee.event.EventHandler;
|
||||||
@ -20,7 +19,6 @@ public class OriginBlacklistBungee extends Plugin implements Listener {
|
|||||||
|
|
||||||
Base.setApi(EaglerXServerAPI.instance());
|
Base.setApi(EaglerXServerAPI.instance());
|
||||||
Base.reloadConfig();
|
Base.reloadConfig();
|
||||||
Base.init();
|
|
||||||
|
|
||||||
getProxy().getPluginManager().registerCommand(this, new CommandBungee());
|
getProxy().getPluginManager().registerCommand(this, new CommandBungee());
|
||||||
getProxy().getPluginManager().registerListener(this, this);
|
getProxy().getPluginManager().registerListener(this, this);
|
||||||
@ -32,9 +30,4 @@ public class OriginBlacklistBungee extends Plugin implements Listener {
|
|||||||
public void onLogin(EaglercraftInitializePlayerEvent event) {
|
public void onLogin(EaglercraftInitializePlayerEvent event) {
|
||||||
Base.handleConnection(event);
|
Base.handleConnection(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@EventHandler
|
|
||||||
public void onMOTD(EaglercraftMOTDEvent event) {
|
|
||||||
Base.handleMOTD(event);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -9,14 +9,12 @@ 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.EaglercraftInitializePlayerEvent;
|
import net.lax1dude.eaglercraft.backend.server.api.velocity.event.EaglercraftInitializePlayerEvent;
|
||||||
import net.lax1dude.eaglercraft.backend.server.api.event.IEaglercraftMOTDEvent;
|
|
||||||
import net.lax1dude.eaglercraft.backend.server.api.velocity.event.EaglercraftMOTDEvent;
|
|
||||||
import org.slf4j.Logger;
|
import org.slf4j.Logger;
|
||||||
|
|
||||||
@Plugin(
|
@Plugin(
|
||||||
id = "originblacklist",
|
id = "originblacklist",
|
||||||
name = "OriginBlacklist",
|
name = "OriginBlacklist",
|
||||||
version = "1.0.1",
|
version = "1.0.0",
|
||||||
authors = {"Colbster937"},
|
authors = {"Colbster937"},
|
||||||
description = "A reimplementation of OriginBlacklist for EaglerXServer",
|
description = "A reimplementation of OriginBlacklist for EaglerXServer",
|
||||||
dependencies = {@Dependency(id = "eaglerxserver")}
|
dependencies = {@Dependency(id = "eaglerxserver")}
|
||||||
@ -41,7 +39,6 @@ public class OriginBlacklistVelocity {
|
|||||||
public void onProxyInitialization(ProxyInitializeEvent event) {
|
public void onProxyInitialization(ProxyInitializeEvent event) {
|
||||||
Base.setApi(EaglerXServerAPI.instance());
|
Base.setApi(EaglerXServerAPI.instance());
|
||||||
Base.reloadConfig();
|
Base.reloadConfig();
|
||||||
Base.init();
|
|
||||||
proxy.getCommandManager().register("originblacklist", new CommandVelocity());
|
proxy.getCommandManager().register("originblacklist", new CommandVelocity());
|
||||||
logger.info("Loaded Velocity plugin");
|
logger.info("Loaded Velocity plugin");
|
||||||
}
|
}
|
||||||
@ -50,9 +47,4 @@ public class OriginBlacklistVelocity {
|
|||||||
public void onLogin(EaglercraftInitializePlayerEvent event) {
|
public void onLogin(EaglercraftInitializePlayerEvent event) {
|
||||||
Base.handleConnection(event);
|
Base.handleConnection(event);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Subscribe
|
|
||||||
public void onMOTD(IEaglercraftMOTDEvent event) {
|
|
||||||
Base.handleMOTD(event);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name: OriginBlacklist
|
name: OriginBlacklist
|
||||||
version: 1.0.1
|
version: 1.0.0
|
||||||
main: dev.colbster937.originblacklist.bungee.OriginBlacklistBungee
|
main: dev.colbster937.originblacklist.bungee.OriginBlacklistBungee
|
||||||
description: A reimplementation of OriginBlacklist for EaglerXServer
|
description: A reimplementation of OriginBlacklist for EaglerXServer
|
||||||
author: Colbster937
|
author: Colbster937
|
||||||
|
@ -11,13 +11,6 @@ messages:
|
|||||||
<gray>Think this is a mistake? Join our discord:</gray>
|
<gray>Think this is a mistake? Join our discord:</gray>
|
||||||
<blue>discord.gg/changethisintheconfig</blue>
|
<blue>discord.gg/changethisintheconfig</blue>
|
||||||
|
|
||||||
motd:
|
|
||||||
enabled: true
|
|
||||||
text: |
|
|
||||||
<red>This %easyblocktype% is not allowed!</red>
|
|
||||||
<dark_gray>»</dark_gray> <gray>%blocked%</gray> <dark_gray>«</dark_gray>
|
|
||||||
icon: "blacklisted.png"
|
|
||||||
|
|
||||||
# Origin + Brand blacklist supports wildcards
|
# Origin + Brand blacklist supports wildcards
|
||||||
# Everything should be lowercase
|
# Everything should be lowercase
|
||||||
blacklist:
|
blacklist:
|
||||||
@ -58,6 +51,13 @@ discord:
|
|||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
name: OriginBlacklist
|
name: OriginBlacklist
|
||||||
version: 1.0.1
|
version: 1.0.0
|
||||||
main: dev.colbster937.originblacklist.bukkit.OriginBlacklistBukkit
|
main: dev.colbster937.originblacklist.bukkit.OriginBlacklistBukkit
|
||||||
description: A reimplementation of OriginBlacklist for EaglerXServer
|
description: A reimplementation of OriginBlacklist for EaglerXServer
|
||||||
author: Colbster937
|
author: Colbster937
|
||||||
|
Binary file not shown.
Before Width: | Height: | Size: 5.3 KiB |
Loading…
x
Reference in New Issue
Block a user