mirror of
https://github.com/colbster937/originblacklist.git
synced 2026-02-04 11:07:41 +00:00
Compare commits
9 Commits
v2.0.8+c4d
...
v2.0.9+df1
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
df17431df0 | ||
|
|
2c0f084bb4 | ||
|
|
c391ec3ad6 | ||
|
|
ce7685367f | ||
|
|
bc16324342 | ||
|
|
f6cf685d1c | ||
|
|
9b955ea77d | ||
|
|
f1fe503357 | ||
|
|
e315eeab24 |
7
.github/dependabot.yml
vendored
7
.github/dependabot.yml
vendored
@@ -5,8 +5,15 @@ updates:
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
open-pull-requests-limit: 10
|
||||
ignore:
|
||||
- dependency-name: "*"
|
||||
update-types: ["version-update:semver-major"]
|
||||
|
||||
- package-ecosystem: "github-actions"
|
||||
directory: "/"
|
||||
schedule:
|
||||
interval: "weekly"
|
||||
open-pull-requests-limit: 10
|
||||
ignore:
|
||||
- dependency-name: "*"
|
||||
update-types: ["version-update:semver-major"]
|
||||
19
.github/workflows/dependabot.yml
vendored
19
.github/workflows/dependabot.yml
vendored
@@ -1,7 +1,5 @@
|
||||
name: Dependabot Auto Merge
|
||||
|
||||
on:
|
||||
pull_request_target:
|
||||
pull_request:
|
||||
|
||||
permissions:
|
||||
contents: write
|
||||
@@ -9,11 +7,16 @@ permissions:
|
||||
|
||||
jobs:
|
||||
dependabot:
|
||||
if: github.actor == 'dependabot[bot]'
|
||||
runs-on: ubuntu-latest
|
||||
if: github.event.pull_request.user.login == 'dependabot[bot]'
|
||||
steps:
|
||||
- uses: fastify/github-action-merge-dependabot@v3
|
||||
- id: metadata
|
||||
uses: dependabot/fetch-metadata@21025c705c08248db411dc16f3619e6b5f9ea21a
|
||||
with:
|
||||
github-token: ${{ secrets.GITHUB_TOKEN }}
|
||||
merge-method: squash
|
||||
target: minor
|
||||
github-token: "${{ secrets.GITHUB_TOKEN }}"
|
||||
|
||||
- if: steps.metadata.outputs.update-type != 'version-update:semver-major'
|
||||
run: gh pr merge --auto --squash "$PR_URL"
|
||||
env:
|
||||
PR_URL: ${{ github.event.pull_request.html_url }}
|
||||
GH_TOKEN: ${{ secrets.GITHUB_TOKEN }}
|
||||
|
||||
2
.github/workflows/gradle.yml
vendored
2
.github/workflows/gradle.yml
vendored
@@ -1,5 +1,3 @@
|
||||
name: Build Plugin
|
||||
|
||||
on:
|
||||
workflow_dispatch:
|
||||
push:
|
||||
|
||||
@@ -24,6 +24,11 @@
|
||||
- [x] Modular multi-platform support
|
||||
- [x] JSON5 based configuration
|
||||
|
||||
<h2>Requirements</h2>
|
||||
|
||||
- Eagler(craft)XServer v1.0.2 or newer
|
||||
- JDK 21 or newer
|
||||
|
||||
<h2>Download</h2>
|
||||
The latest release can be found at <b><a href="https://github.com/WebMCDevelopment/originblacklist/releases/latest/">https://github.com/WebMCDevelopment/originblacklist/releases/latest/</a></b>
|
||||
|
||||
|
||||
@@ -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.8"
|
||||
val PLUGIN_VERS = "2.0.9"
|
||||
val PLUGIN_SITE = "https://github.com/WebMCDevelopment/$PLUGIN_IDEN"
|
||||
val PLUGIN_DEPA = listOf("EaglercraftXServer")
|
||||
val PLUGIN_DEPB = listOf("EaglercraftXServer")
|
||||
@@ -65,7 +65,7 @@ repositories {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
compileOnly("com.velocitypowered:velocity-api:3.4.0-SNAPSHOT")
|
||||
compileOnly("com.velocitypowered:velocity-api:3.5.0-SNAPSHOT")
|
||||
compileOnly("org.bukkit:bukkit:1.8-R0.1-SNAPSHOT")
|
||||
compileOnly("net.md-5:bungeecord-api:1.21-R0.5-SNAPSHOT")
|
||||
compileOnly("net.lax1dude.eaglercraft.backend:api-velocity:1.0.0")
|
||||
@@ -91,7 +91,7 @@ sourceSets {
|
||||
}
|
||||
|
||||
java {
|
||||
toolchain.languageVersion.set(JavaLanguageVersion.of(17))
|
||||
toolchain.languageVersion.set(JavaLanguageVersion.of(21))
|
||||
}
|
||||
|
||||
val BUILD_PROPS = mapOf(
|
||||
@@ -113,7 +113,7 @@ val BUILD_PROPS = mapOf(
|
||||
|
||||
tasks.withType<JavaCompile>().configureEach {
|
||||
options.encoding = "UTF-8"
|
||||
options.release.set(17)
|
||||
options.release.set(21)
|
||||
}
|
||||
|
||||
tasks.withType<ProcessResources>().configureEach {
|
||||
|
||||
@@ -7,6 +7,7 @@ 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.OriginBlacklistRequestHandler;
|
||||
import xyz.webmc.originblacklist.base.metrics.GenericMetricsAdapter;
|
||||
import xyz.webmc.originblacklist.base.util.BuildInfo;
|
||||
import xyz.webmc.originblacklist.base.util.IOriginBlacklistPlugin;
|
||||
import xyz.webmc.originblacklist.base.util.OPlayer;
|
||||
@@ -15,6 +16,7 @@ import xyz.webmc.originblacklist.base.util.UpdateChecker;
|
||||
import java.io.InputStream;
|
||||
import java.io.OutputStream;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
import java.net.URLDecoder;
|
||||
import java.nio.charset.StandardCharsets;
|
||||
@@ -26,7 +28,9 @@ import java.nio.file.StandardOpenOption;
|
||||
import java.time.Instant;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Base64;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import de.marhali.json5.Json5;
|
||||
@@ -38,8 +42,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.IBasePlayer;
|
||||
import net.lax1dude.eaglercraft.backend.server.api.IEaglerPlayer;
|
||||
import net.lax1dude.eaglercraft.backend.server.api.IEaglerXServerAPI;
|
||||
import net.lax1dude.eaglercraft.backend.server.api.query.IMOTDConnection;
|
||||
import org.bstats.charts.AdvancedPie;
|
||||
import org.semver4j.Semver;
|
||||
|
||||
@SuppressWarnings({ "rawtypes" })
|
||||
@@ -55,6 +62,7 @@ public final class OriginBlacklist {
|
||||
|
||||
private final IOriginBlacklistPlugin plugin;
|
||||
private final OriginBlacklistConfig config;
|
||||
private final GenericMetricsAdapter metrics;
|
||||
private final Json5 json5;
|
||||
private String updateURL;
|
||||
private Path jarFile;
|
||||
@@ -62,6 +70,7 @@ public final class OriginBlacklist {
|
||||
public OriginBlacklist(final IOriginBlacklistPlugin plugin) {
|
||||
this.plugin = plugin;
|
||||
this.config = new OriginBlacklistConfig(this);
|
||||
this.metrics = plugin.getMetrics();
|
||||
this.json5 = Json5.builder(builder -> builder.prettyPrinting().indentFactor(0).build());
|
||||
}
|
||||
|
||||
@@ -73,8 +82,24 @@ public final class OriginBlacklist {
|
||||
if (this.isBlacklistAPIEnabled()) {
|
||||
OriginBlacklistRequestHandler.register(this);
|
||||
}
|
||||
this.metrics.addCustomChart(new AdvancedPie("player_types", () -> {
|
||||
final Map<String, Integer> playerMap = new HashMap<>();
|
||||
for (final Object player : this.getEaglerAPI().getAllPlayers()) {
|
||||
if (player instanceof IBasePlayer bPlayer) {
|
||||
final String key = (bPlayer instanceof IEaglerPlayer) ? "Eagler" : "Java";
|
||||
playerMap.put(key, playerMap.getOrDefault(key, 0) + 1);
|
||||
}
|
||||
}
|
||||
return playerMap;
|
||||
}));
|
||||
this.plugin.log(EnumLogLevel.INFO, "Initialized Plugin");
|
||||
this.plugin.log(EnumLogLevel.DEBUG, "Commit " + COMMIT_L);
|
||||
if (this.isMetricsEnabled()) {
|
||||
this.metrics.start();
|
||||
}
|
||||
this.plugin.scheduleRepeat(() -> {
|
||||
this.plugin.log(EnumLogLevel.INFO, String.valueOf(this.isMetricsEnabled()));
|
||||
}, 1, TimeUnit.SECONDS);
|
||||
}
|
||||
|
||||
public final void shutdown() {
|
||||
@@ -82,6 +107,9 @@ public final class OriginBlacklist {
|
||||
if (this.isBlacklistAPIEnabled()) {
|
||||
OriginBlacklistRequestHandler.unRegister(this);
|
||||
}
|
||||
if (this.isMetricsEnabled()) {
|
||||
this.metrics.shutdown();
|
||||
}
|
||||
this.plugin.shutdown();
|
||||
}
|
||||
|
||||
@@ -94,6 +122,14 @@ public final class OriginBlacklist {
|
||||
}
|
||||
} catch (final Throwable t) {
|
||||
}
|
||||
try {
|
||||
if (this.isMetricsEnabled()) {
|
||||
this.metrics.start();
|
||||
} else {
|
||||
this.metrics.shutdown();
|
||||
}
|
||||
} catch (final Throwable t) {
|
||||
}
|
||||
}
|
||||
|
||||
public final void handleLogin(final OriginBlacklistLoginEvent event) {
|
||||
@@ -117,7 +153,7 @@ public final class OriginBlacklist {
|
||||
blacklisted_value, blacklisted.getActionString(), false), event);
|
||||
this.sendWebhooks(event, blacklisted);
|
||||
final String name = player.getName();
|
||||
if (isNonNull(name)) {
|
||||
if (isNonNullStr(name)) {
|
||||
this.plugin.log(EnumLogLevel.INFO, "Prevented blacklisted player " + name + " from joining.");
|
||||
this.updateLogFile(event, blacklisted);
|
||||
}
|
||||
@@ -181,7 +217,8 @@ public final class OriginBlacklist {
|
||||
}
|
||||
final List<String> pLst = new ArrayList<>();
|
||||
for (final Json5Element ln : this.config.getArray("motd.players.hover").getAsJson5Array()) {
|
||||
pLst.add(getLegacyFromMiniMessage(ln.getAsString().replaceAll("%discord_invite%", this.config.getString("discord.invite"))));
|
||||
pLst.add(getLegacyFromMiniMessage(
|
||||
ln.getAsString().replaceAll("%discord_invite%", this.config.getString("discord.invite"))));
|
||||
}
|
||||
conn.setServerMOTD(lst);
|
||||
conn.setPlayerTotal(this.config.getInteger("motd.players.online"));
|
||||
@@ -197,7 +234,7 @@ public final class OriginBlacklist {
|
||||
this.plugin.runAsync(() -> {
|
||||
this.updateURL = UpdateChecker.checkForUpdates(PLUGIN_REPO, this.plugin.getPluginVersion(),
|
||||
this.config.getBoolean("update_checker.allow_snapshots"));
|
||||
if (isNonNull((this.updateURL))) {
|
||||
if (isNonNullStr((this.updateURL))) {
|
||||
action1.run();
|
||||
return;
|
||||
}
|
||||
@@ -210,7 +247,7 @@ public final class OriginBlacklist {
|
||||
|
||||
public final void updatePlugin(final Runnable action1, final Runnable action2) {
|
||||
try {
|
||||
final URL url = new URL(this.updateURL);
|
||||
final URL url = (new URI(this.updateURL)).toURL();
|
||||
final Path jar = this.jarFile;
|
||||
final Path bak = jar.resolveSibling(jar.getFileName().toString() + ".bak");
|
||||
final Path upd = jar
|
||||
@@ -234,14 +271,16 @@ public final class OriginBlacklist {
|
||||
} finally {
|
||||
conn.disconnect();
|
||||
}
|
||||
if (Files.exists(upd)) {
|
||||
Files.delete(jar);
|
||||
Files.delete(bak);
|
||||
this.jarFile = upd;
|
||||
action1.run();
|
||||
return;
|
||||
}
|
||||
} catch (final Throwable t) {
|
||||
t.printStackTrace();
|
||||
Files.move(bak, jar, StandardCopyOption.REPLACE_EXISTING);
|
||||
throw t;
|
||||
}
|
||||
} catch (final Throwable t) {
|
||||
t.printStackTrace();
|
||||
@@ -264,7 +303,7 @@ public final class OriginBlacklist {
|
||||
final boolean whitelist = this.config.getBoolean("blacklist_to_whitelist");
|
||||
EnumBlacklistType type = EnumBlacklistType.NONE;
|
||||
|
||||
if (isNonNull(origin)) {
|
||||
if (isNonNullStr(origin)) {
|
||||
if (whitelist && !type.isBlacklisted())
|
||||
type = EnumBlacklistType.ORIGIN;
|
||||
for (final Json5Element element : this.config.getArray("blacklist.origins").getAsJson5Array()) {
|
||||
@@ -280,7 +319,7 @@ public final class OriginBlacklist {
|
||||
return whitelist ? EnumBlacklistType.NONE : EnumBlacklistType.ORIGIN;
|
||||
}
|
||||
|
||||
if (isNonNull(brand)) {
|
||||
if (isNonNullStr(brand)) {
|
||||
if (whitelist && !type.isBlacklisted())
|
||||
type = EnumBlacklistType.BRAND;
|
||||
for (final Json5Element element : this.config.getArray("blacklist.brands")) {
|
||||
@@ -294,7 +333,7 @@ public final class OriginBlacklist {
|
||||
}
|
||||
}
|
||||
|
||||
if (isNonNull(name)) {
|
||||
if (isNonNullStr(name)) {
|
||||
if (whitelist && !type.isBlacklisted())
|
||||
type = EnumBlacklistType.NAME;
|
||||
for (final Json5Element element : this.config.getArray("blacklist.player_names")) {
|
||||
@@ -308,7 +347,7 @@ public final class OriginBlacklist {
|
||||
}
|
||||
}
|
||||
|
||||
if (isNonNull(addr)) {
|
||||
if (isNonNullStr(addr)) {
|
||||
if (whitelist && !type.isBlacklisted())
|
||||
type = EnumBlacklistType.ADDR;
|
||||
for (final Json5Element element : this.config.getArray("blacklist.ip_addresses")) {
|
||||
@@ -446,7 +485,7 @@ public final class OriginBlacklist {
|
||||
for (final Json5Element element : arr) {
|
||||
this.plugin.runAsync(() -> {
|
||||
try {
|
||||
final URL url = new URL(element.getAsString());
|
||||
final URL url = (new URI(element.getAsString())).toURL();
|
||||
final HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setRequestMethod("POST");
|
||||
conn.setRequestProperty("Content-Type", "application/json");
|
||||
@@ -519,7 +558,7 @@ public final class OriginBlacklist {
|
||||
return BuildInfo.get("plugin_name") + "/" + BuildInfo.get("plugin_vers") + "+" + BuildInfo.get("git_cm_hash");
|
||||
}
|
||||
|
||||
public static final boolean isNonNull(final String str) {
|
||||
public static final boolean isNonNullStr(final String str) {
|
||||
return str != null && !str.isEmpty() && !str.isBlank() && !str.equals("null");
|
||||
}
|
||||
|
||||
|
||||
@@ -54,7 +54,7 @@ public class OriginBlacklistCommand implements ICommand {
|
||||
} else {
|
||||
ctx.reply(NO_PERMISSION);
|
||||
}
|
||||
} else if ((add || remove) && OriginBlacklist.isNonNull(argB)) {
|
||||
} else if ((add || remove) && OriginBlacklist.isNonNullStr(argB)) {
|
||||
if ((add && ctx.hasPermission("originblacklist.command.add"))
|
||||
|| (remove && ctx.hasPermission("originblacklist.command.add"))) {
|
||||
final String arrName;
|
||||
@@ -69,7 +69,7 @@ public class OriginBlacklistCommand implements ICommand {
|
||||
} else {
|
||||
arrName = null;
|
||||
}
|
||||
if (OriginBlacklist.isNonNull(arrName)) {
|
||||
if (OriginBlacklist.isNonNullStr(arrName)) {
|
||||
final String arrPath = "blacklist." + arrName;
|
||||
final Json5Array arr = config.getArray(arrPath);
|
||||
if (add) {
|
||||
@@ -95,7 +95,7 @@ public class OriginBlacklistCommand implements ICommand {
|
||||
} else {
|
||||
ctx.reply(NO_PERMISSION);
|
||||
}
|
||||
} else if ("test".equalsIgnoreCase(command) && OriginBlacklist.isNonNull(argA)) {
|
||||
} else if ("test".equalsIgnoreCase(command) && OriginBlacklist.isNonNullStr(argA)) {
|
||||
if (ctx.hasPermission("originblacklist.command.test")) {
|
||||
if (this.isBlacklisted(argA)) {
|
||||
ctx.reply("<green>" + argA + " is on the blacklist.</green>");
|
||||
|
||||
@@ -132,7 +132,7 @@ public final class OriginBlacklistConfig {
|
||||
public final Json5Element get(final String key) {
|
||||
Json5Element element = null;
|
||||
|
||||
if (this.config != null && OriginBlacklist.isNonNull(key)) {
|
||||
if (this.config != null && OriginBlacklist.isNonNullStr(key)) {
|
||||
element = this.config;
|
||||
final String[] parts = splitPath(key);
|
||||
|
||||
@@ -493,7 +493,7 @@ public final class OriginBlacklistConfig {
|
||||
|
||||
private static final void addJSONObj(final Json5Object obj, final String key, final Json5Element value,
|
||||
final String comment) {
|
||||
if (OriginBlacklist.isNonNull(comment)) {
|
||||
if (OriginBlacklist.isNonNullStr(comment)) {
|
||||
value.setComment(comment);
|
||||
}
|
||||
obj.add(key, value);
|
||||
@@ -502,7 +502,7 @@ public final class OriginBlacklistConfig {
|
||||
private static final String[] splitPath(final String key) {
|
||||
final String[] ret;
|
||||
|
||||
if (OriginBlacklist.isNonNull(key)) {
|
||||
if (OriginBlacklist.isNonNullStr(key)) {
|
||||
ret = key.split("\\.");
|
||||
} else {
|
||||
ret = new String[0];
|
||||
|
||||
@@ -18,7 +18,7 @@ public enum EnumBlacklistType {
|
||||
this.str = str;
|
||||
this.alt = alt;
|
||||
this.arr = arr;
|
||||
this.act = OriginBlacklist.isNonNull(act) ? act : OriginBlacklist.GENERIC_STR.toLowerCase();
|
||||
this.act = OriginBlacklist.isNonNullStr(act) ? act : OriginBlacklist.GENERIC_STR.toLowerCase();
|
||||
}
|
||||
|
||||
public final String getString() {
|
||||
|
||||
@@ -8,7 +8,7 @@ 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 {
|
||||
public final class OriginBlacklistRequestHandler implements IRequestHandler {
|
||||
private static final RouteDesc route = RouteDesc.create("/originblacklist/v2/");
|
||||
private final OriginBlacklist plugin;
|
||||
|
||||
|
||||
@@ -0,0 +1,21 @@
|
||||
package xyz.webmc.originblacklist.base.metrics;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
import org.bstats.charts.CustomChart;
|
||||
|
||||
public abstract class GenericMetricsAdapter {
|
||||
protected final List<CustomChart> charts;
|
||||
|
||||
protected GenericMetricsAdapter() {
|
||||
this.charts = new ArrayList<>();
|
||||
}
|
||||
|
||||
public final void addCustomChart(final CustomChart chart) {
|
||||
this.charts.add(chart);
|
||||
}
|
||||
|
||||
public abstract void start();
|
||||
public abstract void shutdown();
|
||||
}
|
||||
@@ -3,6 +3,7 @@ package xyz.webmc.originblacklist.base.util;
|
||||
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.metrics.GenericMetricsAdapter;
|
||||
|
||||
import java.nio.file.Path;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
@@ -19,6 +20,8 @@ public interface IOriginBlacklistPlugin {
|
||||
|
||||
public Path getPluginJarPath();
|
||||
|
||||
public GenericMetricsAdapter getMetrics();
|
||||
|
||||
public IEaglerXServerAPI getEaglerAPI();
|
||||
|
||||
public void log(final EnumLogLevel level, final String txt);
|
||||
|
||||
@@ -85,7 +85,7 @@ public final class OPlayer {
|
||||
}
|
||||
|
||||
private static final String formatIPAddress(String addr) {
|
||||
if (OriginBlacklist.isNonNull(addr)) {
|
||||
if (OriginBlacklist.isNonNullStr(addr)) {
|
||||
if (addr.startsWith("/")) {
|
||||
addr = addr.substring(1);
|
||||
}
|
||||
|
||||
@@ -5,6 +5,7 @@ import xyz.webmc.originblacklist.base.OriginBlacklist;
|
||||
import java.io.BufferedReader;
|
||||
import java.io.InputStreamReader;
|
||||
import java.net.HttpURLConnection;
|
||||
import java.net.URI;
|
||||
import java.net.URL;
|
||||
|
||||
import de.marhali.json5.Json5;
|
||||
@@ -20,7 +21,7 @@ public final class UpdateChecker {
|
||||
public static final String checkForUpdates(final String repo, final Semver currentVersion,
|
||||
final boolean allowSnapshots) {
|
||||
try {
|
||||
final URL url = new URL("https://api.github.com/repos/" + repo + "/releases");
|
||||
final URL url = (new URI("https://api.github.com/repos/" + repo + "/releases")).toURL();
|
||||
final HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setRequestMethod("GET");
|
||||
conn.setConnectTimeout(5000);
|
||||
@@ -75,7 +76,7 @@ public final class UpdateChecker {
|
||||
comm = "";
|
||||
}
|
||||
if (ver.isGreaterThan(currentVersion) || (allowSnapshots && currentVersion.diff(ver) == VersionDiff.BUILD
|
||||
&& OriginBlacklist.isNonNull(comm) && !BuildInfo.get("git_cm_hash").startsWith(comm))) {
|
||||
&& OriginBlacklist.isNonNullStr(comm) && !BuildInfo.get("git_cm_hash").startsWith(comm))) {
|
||||
element = obj.get("assets");
|
||||
if (element instanceof Json5Array) {
|
||||
final Json5Array aArr = element.getAsJson5Array();
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package xyz.webmc.originblacklist.bukkit;
|
||||
|
||||
import xyz.webmc.originblacklist.base.OriginBlacklist;
|
||||
import xyz.webmc.originblacklist.base.metrics.GenericMetricsAdapter;
|
||||
|
||||
import org.bstats.charts.CustomChart;
|
||||
import org.bstats.bukkit.Metrics;
|
||||
|
||||
public final class BukkitMetricsAdapter extends GenericMetricsAdapter {
|
||||
private final OriginBlacklistBukkit plugin;
|
||||
private Metrics metrics;
|
||||
|
||||
public BukkitMetricsAdapter(final OriginBlacklistBukkit plugin) {
|
||||
super();
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
if (this.metrics == null) {
|
||||
this.metrics = new Metrics(this.plugin, OriginBlacklist.BSTATS.BUKKIT);
|
||||
for (final CustomChart chart : this.charts) {
|
||||
this.metrics.addCustomChart(chart);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
if (this.metrics != null) {
|
||||
this.metrics.shutdown();
|
||||
this.metrics = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -136,6 +136,11 @@ public final class OriginBlacklistBukkit extends JavaPlugin implements Listener,
|
||||
return Paths.get(this.getFile().getAbsolutePath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final BukkitMetricsAdapter getMetrics() {
|
||||
return new BukkitMetricsAdapter(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IEaglerXServerAPI getEaglerAPI() {
|
||||
return EaglerXServerAPI.instance();
|
||||
@@ -248,7 +253,6 @@ public final class OriginBlacklistBukkit extends JavaPlugin implements Listener,
|
||||
|
||||
@Override
|
||||
public final void shutdown() {
|
||||
this.metrics.shutdown();
|
||||
Bukkit.getScheduler().cancelTasks(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -0,0 +1,35 @@
|
||||
package xyz.webmc.originblacklist.bungee;
|
||||
|
||||
import xyz.webmc.originblacklist.base.OriginBlacklist;
|
||||
import xyz.webmc.originblacklist.base.metrics.GenericMetricsAdapter;
|
||||
|
||||
import org.bstats.charts.CustomChart;
|
||||
import org.bstats.bungeecord.Metrics;
|
||||
|
||||
public final class BungeeMetricsAdapter extends GenericMetricsAdapter {
|
||||
private final OriginBlacklistBungee plugin;
|
||||
private Metrics metrics;
|
||||
|
||||
public BungeeMetricsAdapter(final OriginBlacklistBungee plugin) {
|
||||
super();
|
||||
this.plugin = plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
if (this.metrics == null) {
|
||||
this.metrics = new Metrics(this.plugin, OriginBlacklist.BSTATS.BUNGEE);
|
||||
for (final CustomChart chart : this.charts) {
|
||||
this.metrics.addCustomChart(chart);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
if (this.metrics != null) {
|
||||
this.metrics.shutdown();
|
||||
this.metrics = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
@@ -14,8 +14,6 @@ import xyz.webmc.originblacklist.bungee.command.OriginBlacklistCommandBungee;
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import net.kyori.adventure.text.Component;
|
||||
@@ -34,8 +32,6 @@ import net.md_5.bungee.api.plugin.Listener;
|
||||
import net.md_5.bungee.api.plugin.Plugin;
|
||||
import net.md_5.bungee.event.EventHandler;
|
||||
import net.md_5.bungee.event.EventPriority;
|
||||
import org.bstats.bungeecord.Metrics;
|
||||
import org.bstats.charts.AdvancedPie;
|
||||
import org.semver4j.Semver;
|
||||
|
||||
@SuppressWarnings({ "deprecation", "rawtypes" })
|
||||
@@ -44,7 +40,6 @@ public final class OriginBlacklistBungee extends Plugin implements Listener, IOr
|
||||
private boolean papiPlaceholdersEnabled;
|
||||
private Object papi;
|
||||
private OriginBlacklist blacklist;
|
||||
private Metrics metrics;
|
||||
|
||||
@Override
|
||||
public final void onEnable() {
|
||||
@@ -75,20 +70,6 @@ public final class OriginBlacklistBungee extends Plugin implements Listener, IOr
|
||||
new OriginBlacklistCommandBungee(this, this.blacklist, "originblacklist"));
|
||||
this.getProxy().getPluginManager().registerListener(this, this);
|
||||
this.blacklist.init();
|
||||
if (this.blacklist.isMetricsEnabled()) {
|
||||
this.metrics = new Metrics(this, OriginBlacklist.BSTATS.BUNGEE);
|
||||
this.metrics.addCustomChart(new AdvancedPie("player_types", () -> {
|
||||
final Map<String, Integer> playerMap = new HashMap<>();
|
||||
|
||||
for (final ProxiedPlayer player : this.proxy.getPlayers()) {
|
||||
final boolean eagler = this.getEaglerAPI().isEaglerPlayerByUUID(player.getUniqueId());
|
||||
final String key = eagler ? "Eagler" : "Java";
|
||||
playerMap.put(key, playerMap.getOrDefault(key, 0) + 1);
|
||||
}
|
||||
|
||||
return playerMap;
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
@@ -152,6 +133,11 @@ public final class OriginBlacklistBungee extends Plugin implements Listener, IOr
|
||||
return Paths.get(this.getFile().getAbsolutePath());
|
||||
}
|
||||
|
||||
@Override
|
||||
public final BungeeMetricsAdapter getMetrics() {
|
||||
return new BungeeMetricsAdapter(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IEaglerXServerAPI getEaglerAPI() {
|
||||
return EaglerXServerAPI.instance();
|
||||
@@ -226,7 +212,6 @@ public final class OriginBlacklistBungee extends Plugin implements Listener, IOr
|
||||
|
||||
@Override
|
||||
public final void shutdown() {
|
||||
this.metrics.shutdown();
|
||||
this.proxy.getScheduler().cancel(this);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,9 +14,7 @@ import xyz.webmc.originblacklist.velocity.command.OriginBlacklistCommandVelocity
|
||||
import java.net.InetSocketAddress;
|
||||
import java.nio.file.Path;
|
||||
import java.nio.file.Paths;
|
||||
import java.util.HashMap;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import com.google.inject.Inject;
|
||||
@@ -39,13 +37,11 @@ import net.lax1dude.eaglercraft.backend.server.api.IEaglerXServerAPI;
|
||||
import net.lax1dude.eaglercraft.backend.server.api.velocity.EaglerXServerAPI;
|
||||
import net.lax1dude.eaglercraft.backend.server.api.velocity.event.EaglercraftLoginEvent;
|
||||
import net.lax1dude.eaglercraft.backend.server.api.velocity.event.EaglercraftMOTDEvent;
|
||||
import org.bstats.charts.AdvancedPie;
|
||||
import org.bstats.velocity.Metrics;
|
||||
import org.bstats.velocity.Metrics.Factory;
|
||||
import org.semver4j.Semver;
|
||||
import org.slf4j.Logger;
|
||||
|
||||
@SuppressWarnings({ "deprecation", "unchecked", "rawtypes" })
|
||||
@SuppressWarnings({ "deprecation", "rawtypes" })
|
||||
public final class OriginBlacklistVelocity implements IOriginBlacklistPlugin {
|
||||
private final PluginContainer plugin;
|
||||
private final Factory metricsFactory;
|
||||
@@ -55,7 +51,6 @@ public final class OriginBlacklistVelocity implements IOriginBlacklistPlugin {
|
||||
private boolean papiPlaceholdersEnabled;
|
||||
private Object papi;
|
||||
private OriginBlacklist blacklist;
|
||||
private Metrics metrics;
|
||||
|
||||
@Inject
|
||||
public OriginBlacklistVelocity(final PluginContainer plugin, Factory metricsFactory, final ProxyServer proxy,
|
||||
@@ -67,7 +62,7 @@ public final class OriginBlacklistVelocity implements IOriginBlacklistPlugin {
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public final void onProxyInitialization(ProxyInitializeEvent event) {
|
||||
public final void onProxyInitialization(final ProxyInitializeEvent event) {
|
||||
this.proxy.getPluginManager().getPlugin("eaglerxserver").ifPresentOrElse(plugin -> {
|
||||
final Semver version = new Semver(plugin.getDescription().getVersion().orElse("1.0.0"));
|
||||
if (version.isLowerThan(OriginBlacklist.REQUIRED_API_VER)) {
|
||||
@@ -91,20 +86,6 @@ public final class OriginBlacklistVelocity implements IOriginBlacklistPlugin {
|
||||
this.blacklist = new OriginBlacklist(this);
|
||||
this.proxy.getCommandManager().register("originblacklist", new OriginBlacklistCommandVelocity(this.blacklist));
|
||||
this.blacklist.init();
|
||||
if (this.blacklist.isMetricsEnabled()) {
|
||||
this.metrics = this.metricsFactory.make(this, OriginBlacklist.BSTATS.VELOCITY);
|
||||
this.metrics.addCustomChart(new AdvancedPie("player_types", () -> {
|
||||
final Map<String, Integer> playerMap = new HashMap<>();
|
||||
|
||||
for (final Player player : this.proxy.getAllPlayers()) {
|
||||
final boolean eagler = this.getEaglerAPI().isEaglerPlayerByUUID(player.getUniqueId());
|
||||
final String key = eagler ? "Eagler" : "Java";
|
||||
playerMap.put(key, playerMap.getOrDefault(key, 0) + 1);
|
||||
}
|
||||
|
||||
return playerMap;
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
@@ -173,6 +154,11 @@ public final class OriginBlacklistVelocity implements IOriginBlacklistPlugin {
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public final VelocityMetricsAdapter getMetrics() {
|
||||
return new VelocityMetricsAdapter(this, this.metricsFactory);
|
||||
}
|
||||
|
||||
@Override
|
||||
public final IEaglerXServerAPI getEaglerAPI() {
|
||||
return EaglerXServerAPI.instance();
|
||||
@@ -254,7 +240,6 @@ public final class OriginBlacklistVelocity implements IOriginBlacklistPlugin {
|
||||
|
||||
@Override
|
||||
public final void shutdown() {
|
||||
this.metrics.shutdown();
|
||||
for (ScheduledTask task : this.proxy.getScheduler().tasksByPlugin(this.plugin)) {
|
||||
task.cancel();
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
package xyz.webmc.originblacklist.velocity;
|
||||
|
||||
import xyz.webmc.originblacklist.base.OriginBlacklist;
|
||||
import xyz.webmc.originblacklist.base.metrics.GenericMetricsAdapter;
|
||||
|
||||
import org.bstats.charts.CustomChart;
|
||||
import org.bstats.velocity.Metrics;
|
||||
import org.bstats.velocity.Metrics.Factory;
|
||||
|
||||
public final class VelocityMetricsAdapter extends GenericMetricsAdapter {
|
||||
private final OriginBlacklistVelocity plugin;
|
||||
private final Factory factory;
|
||||
private Metrics metrics;
|
||||
|
||||
public VelocityMetricsAdapter(final OriginBlacklistVelocity plugin, final Factory factory) {
|
||||
super();
|
||||
this.plugin = plugin;
|
||||
this.factory = factory;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void start() {
|
||||
if (this.metrics == null) {
|
||||
this.metrics = this.factory.make(this.plugin, OriginBlacklist.BSTATS.VELOCITY);
|
||||
for (final CustomChart chart : this.charts) {
|
||||
this.metrics.addCustomChart(chart);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void shutdown() {
|
||||
if (this.metrics != null) {
|
||||
this.metrics.shutdown();
|
||||
this.metrics = null;
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user