mirror of
https://github.com/colbster937/originblacklist.git
synced 2026-02-04 02:57:41 +00:00
Compare commits
3 Commits
5e29f7f74a
...
v2.0.5
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
bb71befe78 | ||
|
|
49f4e249e5 | ||
|
|
5491efa79a |
@@ -14,8 +14,8 @@
|
||||
- [x] MiniMessage and legacy formattings supported
|
||||
- [x] Plugin update checker
|
||||
- [x] Send blacklist logs to a webhook
|
||||
- [x] Ingame blacklist management commands
|
||||
- [x] Reverse blacklist (whitelist)
|
||||
- [ ] Ingame blacklist management command
|
||||
- [ ] Subscribe to an auto-updating blacklist
|
||||
|
||||
<h2>Changes from v1</h2>
|
||||
|
||||
@@ -13,7 +13,7 @@ val PLUGIN_NAME = "OriginBlacklist"
|
||||
val PLUGIN_IDEN = "originblacklist"
|
||||
val PLUGIN_DOMN = "xyz.webmc"
|
||||
val PLUGIN_DESC = "An eaglercraft client blacklist plugin."
|
||||
val PLUGIN_VERS = "2.0.4"
|
||||
val PLUGIN_VERS = "2.0.5"
|
||||
val PLUGIN_SITE = "https://github.com/WebMCDevelopment/$PLUGIN_IDEN"
|
||||
val PLUGIN_DEPA = listOf("EaglercraftXServer")
|
||||
val PLUGIN_DEPB = listOf("EaglercraftXServer")
|
||||
|
||||
@@ -193,7 +193,7 @@ public final class OriginBlacklist {
|
||||
this.updatePlugin(() -> {}, () -> {});
|
||||
}
|
||||
|
||||
private final EnumBlacklistType testBlacklist(final OPlayer player) {
|
||||
public final EnumBlacklistType testBlacklist(final OPlayer player) {
|
||||
final String name = player.getName();
|
||||
final String addr = player.getAddr();
|
||||
final String origin = player.getOrigin();
|
||||
@@ -229,7 +229,6 @@ public final class OriginBlacklist {
|
||||
if (isNonNull(name)) {
|
||||
if (whitelist && !type.isBlacklisted()) type = EnumBlacklistType.NAME;
|
||||
for (final Json5Element element : this.config.getArray("blacklist.player_names")) {
|
||||
this.plugin.log(EnumLogLevel.DEBUG, element.getAsString());
|
||||
if (name.matches(element.getAsString())) {
|
||||
if (whitelist) type = EnumBlacklistType.NONE;
|
||||
else if (!type.isBlacklisted()) type = EnumBlacklistType.NAME;
|
||||
@@ -335,34 +334,32 @@ public final class OriginBlacklist {
|
||||
PLUGIN_REPO,
|
||||
PLUGIN_REPO
|
||||
).getBytes();
|
||||
final Json5Element element = this.config.get("discord.webhook_urls");
|
||||
if (element instanceof Json5Array) {
|
||||
for (final Json5Element _element : element.getAsJson5Array()) {
|
||||
this.plugin.runAsync(() -> {
|
||||
try {
|
||||
final URL url = new URL(_element.getAsString());
|
||||
final HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setRequestMethod("POST");
|
||||
conn.setRequestProperty("Content-Type", "application/json");
|
||||
conn.setDoOutput(true);
|
||||
conn.setConnectTimeout(5000);
|
||||
conn.setReadTimeout(5000);
|
||||
conn.connect();
|
||||
final OutputStream os = conn.getOutputStream();
|
||||
os.write(payload);
|
||||
os.close();
|
||||
final Json5Array arr = this.config.get("discord.webhook_urls").getAsJson5Array();
|
||||
for (final Json5Element element : arr) {
|
||||
this.plugin.runAsync(() -> {
|
||||
try {
|
||||
final URL url = new URL(element.getAsString());
|
||||
final HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
conn.setRequestMethod("POST");
|
||||
conn.setRequestProperty("Content-Type", "application/json");
|
||||
conn.setDoOutput(true);
|
||||
conn.setConnectTimeout(5000);
|
||||
conn.setReadTimeout(5000);
|
||||
conn.connect();
|
||||
final OutputStream os = conn.getOutputStream();
|
||||
os.write(payload);
|
||||
os.close();
|
||||
|
||||
final int code = conn.getResponseCode();
|
||||
if (code < 200 || code >= 300) {
|
||||
this.plugin.log(EnumLogLevel.WARN, "Webhook failed (HTTP " + code + ")");
|
||||
}
|
||||
|
||||
conn.disconnect();
|
||||
} catch (final Throwable t) {
|
||||
t.printStackTrace();
|
||||
final int code = conn.getResponseCode();
|
||||
if (code < 200 || code >= 300) {
|
||||
this.plugin.log(EnumLogLevel.WARN, "Webhook failed (HTTP " + code + ")");
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
conn.disconnect();
|
||||
} catch (final Throwable t) {
|
||||
t.printStackTrace();
|
||||
}
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -4,8 +4,12 @@ import xyz.webmc.originblacklist.base.OriginBlacklist;
|
||||
|
||||
public interface CommandContext {
|
||||
public OriginBlacklist getPlugin();
|
||||
|
||||
public String getPlayerName();
|
||||
|
||||
public void reply(final String message);
|
||||
|
||||
public boolean hasPermission(final String permission);
|
||||
|
||||
public String[] getArgs();
|
||||
}
|
||||
|
||||
@@ -4,7 +4,10 @@ import java.util.List;
|
||||
|
||||
public interface ICommand {
|
||||
public static final String NO_PERMISSION = "<red>You don't have permission to use this command.</red>";
|
||||
|
||||
public boolean execute(final CommandContext ctx);
|
||||
|
||||
public List<String> suggest(final CommandContext ctx);
|
||||
|
||||
public void usage(final CommandContext ctx);
|
||||
}
|
||||
|
||||
@@ -1,10 +1,15 @@
|
||||
package xyz.webmc.originblacklist.base.command;
|
||||
|
||||
import xyz.webmc.originblacklist.base.OriginBlacklist;
|
||||
import xyz.webmc.originblacklist.base.config.OriginBlacklistConfig;
|
||||
import xyz.webmc.originblacklist.base.enums.EnumBlacklistType;
|
||||
import xyz.webmc.originblacklist.base.util.OPlayer;
|
||||
|
||||
import java.util.List;
|
||||
|
||||
import de.marhali.json5.Json5Array;
|
||||
import de.marhali.json5.Json5Element;
|
||||
import de.marhali.json5.Json5Primitive;
|
||||
|
||||
public class OriginBlacklistCommand implements ICommand {
|
||||
private final OriginBlacklist plugin;
|
||||
@@ -18,43 +23,26 @@ public class OriginBlacklistCommand implements ICommand {
|
||||
final String[] args = ctx.getArgs();
|
||||
if (ctx.hasPermission("originblacklist.command")) {
|
||||
if (args.length > 0) {
|
||||
final OriginBlacklistConfig config = this.plugin.getConfig();
|
||||
final String command = args[0].toLowerCase();
|
||||
final String argA = args.length > 1 ? args[1].toLowerCase() : null;
|
||||
;
|
||||
final String argB = args.length > 2 ? args[2] : null;
|
||||
final boolean add = "add".equals(command);
|
||||
final boolean remove = "remove".equals(command);
|
||||
if ("reload".equals(command)) {
|
||||
if (ctx.hasPermission("originblacklist.command.reload")) {
|
||||
this.plugin.getConfig().reloadConfig();
|
||||
config.reloadConfig();
|
||||
ctx.reply("<green>Configuration Reloaded</green>");
|
||||
} else {
|
||||
ctx.reply(NO_PERMISSION);
|
||||
}
|
||||
} else if ("list".equals(command)) {
|
||||
if (ctx.hasPermission("originblacklist.command.reload")) {
|
||||
ctx.reply("<aqua>Blacklist:</aqua>");
|
||||
ctx.reply("<gold> - Origins:</gold>");
|
||||
for (final Json5Element element : this.plugin.getConfig().getArray("blacklist.origins")) {
|
||||
ctx.reply("<gray> - " + element.getAsString() + "</gray>");
|
||||
}
|
||||
ctx.reply("<gold> - Brands:</gold>");
|
||||
for (final Json5Element element : this.plugin.getConfig().getArray("blacklist.brands")) {
|
||||
ctx.reply("<gray> - " + element.getAsString() + "</gray>");
|
||||
}
|
||||
ctx.reply("<gold> - Players:</gold>");
|
||||
for (final Json5Element element : this.plugin.getConfig().getArray("blacklist.player_names")) {
|
||||
ctx.reply("<gray> - " + element.getAsString() + "</gray>");
|
||||
}
|
||||
ctx.reply("<gold> - IPs:</gold>");
|
||||
for (final Json5Element element : this.plugin.getConfig().getArray("blacklist.ip_addresses")) {
|
||||
ctx.reply("<gray> - " + element.getAsString() + "</gray>");
|
||||
}
|
||||
} else {
|
||||
ctx.reply(NO_PERMISSION);
|
||||
}
|
||||
} else if ("update".equals(command)) {
|
||||
if (ctx.hasPermission("originblacklist.command.update")) {
|
||||
ctx.reply("<aqua>Checking for updates...</aqua>");
|
||||
final OriginBlacklist plugin = ctx.getPlugin();
|
||||
plugin.checkForUpdates(() -> {
|
||||
this.plugin.checkForUpdates(() -> {
|
||||
ctx.reply("<yellow>Updating plugin...</yellow>");
|
||||
plugin.updatePlugin(() -> {
|
||||
this.plugin.updatePlugin(() -> {
|
||||
ctx.reply("<green>Successfully updated plugin.</green>");
|
||||
}, () -> {
|
||||
ctx.reply("<red>Failed to update plugin.</red>");
|
||||
@@ -65,6 +53,79 @@ public class OriginBlacklistCommand implements ICommand {
|
||||
} else {
|
||||
ctx.reply(NO_PERMISSION);
|
||||
}
|
||||
} else if ((add || remove) && OriginBlacklist.isNonNull(argB)) {
|
||||
if ((add && ctx.hasPermission("originblacklist.command.add"))
|
||||
|| (remove && ctx.hasPermission("originblacklist.command.add"))) {
|
||||
final String arrName;
|
||||
if ("origin".equals(argA)) {
|
||||
arrName = "origins";
|
||||
} else if ("brand".equals(argA)) {
|
||||
arrName = "brands";
|
||||
} else if ("name".equals(argA)) {
|
||||
arrName = "player_names";
|
||||
} else if ("ip".equals(argA)) {
|
||||
arrName = "ip_addresses";
|
||||
} else {
|
||||
arrName = null;
|
||||
}
|
||||
if (OriginBlacklist.isNonNull(arrName)) {
|
||||
final String arrPath = "blacklist." + arrName;
|
||||
final Json5Array arr = config.getArray(arrPath);
|
||||
if (add) {
|
||||
if (!arr.contains(Json5Primitive.fromString(argB))) {
|
||||
arr.add(argB);
|
||||
config.set(arrPath, arr);
|
||||
ctx.reply("<green>Added " + argB + " to the " + argA + " blacklist</green>");
|
||||
} else {
|
||||
ctx.reply("<red>" + argB + " is already on the " + argA + " blacklist</red>");
|
||||
}
|
||||
} else if (remove) {
|
||||
if (arr.contains(Json5Primitive.fromString(argB))) {
|
||||
arr.remove(Json5Primitive.fromString(argB));
|
||||
config.set(arrPath, arr);
|
||||
ctx.reply("<green>Removed " + argB + " from the " + argA + " blacklist</green>");
|
||||
} else {
|
||||
ctx.reply("<red>" + argB + " not on the " + argA + " blacklist</red>");
|
||||
}
|
||||
}
|
||||
} else {
|
||||
this.usage(ctx);
|
||||
}
|
||||
} else {
|
||||
ctx.reply(NO_PERMISSION);
|
||||
}
|
||||
} else if ("test".equals(command) && OriginBlacklist.isNonNull(argA)) {
|
||||
if (ctx.hasPermission("originblacklist.command.test")) {
|
||||
if (this.isBlacklisted(argA)) {
|
||||
ctx.reply("<green>" + argA + " is on the blacklist.</green>");
|
||||
} else {
|
||||
ctx.reply("<red>" + argA + " is not on the blacklist.</red>");
|
||||
}
|
||||
} else {
|
||||
ctx.reply(NO_PERMISSION);
|
||||
}
|
||||
} else if ("list".equals(command)) {
|
||||
if (ctx.hasPermission("originblacklist.command.list")) {
|
||||
ctx.reply("<aqua>Blacklist:</aqua>");
|
||||
ctx.reply("<gold> - Origins:</gold>");
|
||||
for (final Json5Element element : config.getArray("blacklist.origins")) {
|
||||
ctx.reply("<gray> - " + element.getAsString() + "</gray>");
|
||||
}
|
||||
ctx.reply("<gold> - Brands:</gold>");
|
||||
for (final Json5Element element : config.getArray("blacklist.brands")) {
|
||||
ctx.reply("<gray> - " + element.getAsString() + "</gray>");
|
||||
}
|
||||
ctx.reply("<gold> - Players:</gold>");
|
||||
for (final Json5Element element : config.getArray("blacklist.player_names")) {
|
||||
ctx.reply("<gray> - " + element.getAsString() + "</gray>");
|
||||
}
|
||||
ctx.reply("<gold> - IPs:</gold>");
|
||||
for (final Json5Element element : config.getArray("blacklist.ip_addresses")) {
|
||||
ctx.reply("<gray> - " + element.getAsString() + "</gray>");
|
||||
}
|
||||
} else {
|
||||
ctx.reply(NO_PERMISSION);
|
||||
}
|
||||
} else {
|
||||
this.usage(ctx);
|
||||
}
|
||||
@@ -78,17 +139,23 @@ public class OriginBlacklistCommand implements ICommand {
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> suggest(final CommandContext ctx) {
|
||||
public final List<String> suggest(final CommandContext ctx) {
|
||||
return List.of();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void usage(CommandContext ctx) {
|
||||
public final void usage(CommandContext ctx) {
|
||||
ctx.reply("<aqua>Commands:</aqua>");
|
||||
ctx.reply("<gray> - /originblacklist reload</gray>");
|
||||
ctx.reply("<gray> - /originblacklist update</gray>");
|
||||
// ctx.reply("<gray> - /originblacklist add <brand/origin/name/ip> <value></gray>");
|
||||
// ctx.reply("<gray> - /originblacklist remove <brand/origin/name/ip> <value></gray>");
|
||||
ctx.reply("<gray> - /originblacklist add <origin/brand/name/ip> <argB></gray>");
|
||||
ctx.reply("<gray> - /originblacklist remove <origin/brand/name/ip> <argB></gray>");
|
||||
ctx.reply("<gray> - /originblacklist test <argB></gray>");
|
||||
ctx.reply("<gray> - /originblacklist list</gray>");
|
||||
}
|
||||
|
||||
private final boolean isBlacklisted(final String str) {
|
||||
final OPlayer player = new OPlayer(null, str, null, str, str, -1);
|
||||
return this.plugin.testBlacklist(player) != EnumBlacklistType.NONE;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -132,7 +132,7 @@ public final class OriginBlacklistConfig {
|
||||
|
||||
if (this.config != null && OriginBlacklist.isNonNull(key)) {
|
||||
element = this.config;
|
||||
final String[] parts = key.split("\\.");
|
||||
final String[] parts = splitPath(key);
|
||||
|
||||
for (final String part : parts) {
|
||||
if (element instanceof Json5Object) {
|
||||
@@ -155,6 +155,75 @@ public final class OriginBlacklistConfig {
|
||||
return element;
|
||||
}
|
||||
|
||||
public final boolean set(final String key, final Json5Element value) {
|
||||
boolean ret = false;
|
||||
|
||||
if (this.config != null && value != null) {
|
||||
final String[] parts = splitPath(key);
|
||||
|
||||
if (parts.length > 0) {
|
||||
Json5Object obj = this.config;
|
||||
|
||||
for (int i = 0; i < parts.length - 1; i++) {
|
||||
final String part = parts[i];
|
||||
final Json5Element cur = obj.has(part) ? obj.get(part) : null;
|
||||
|
||||
if (cur instanceof Json5Object next) {
|
||||
obj = next;
|
||||
} else {
|
||||
final Json5Object next = new Json5Object();
|
||||
obj.add(part, next);
|
||||
obj = next;
|
||||
}
|
||||
}
|
||||
|
||||
obj.add(parts[parts.length - 1], value.deepCopy());
|
||||
this.saveConfig();
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public final boolean remove(final String key) {
|
||||
boolean ret = false;
|
||||
|
||||
if (this.config != null) {
|
||||
final String[] parts = splitPath(key);
|
||||
|
||||
if (parts.length > 0) {
|
||||
Json5Object obj = this.config;
|
||||
Json5Element element = obj;
|
||||
|
||||
for (int i = 0; i < parts.length - 1; i++) {
|
||||
if (element instanceof Json5Object cur && cur.has(parts[i])) {
|
||||
element = cur.get(parts[i]);
|
||||
if (element instanceof Json5Object) {
|
||||
obj = (Json5Object) element;
|
||||
} else {
|
||||
element = null;
|
||||
}
|
||||
} else {
|
||||
element = null;
|
||||
}
|
||||
|
||||
if (element == null) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (element != null && obj.has(parts[parts.length - 1])) {
|
||||
obj.remove(parts[parts.length - 1]);
|
||||
this.saveConfig();
|
||||
ret = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
public final String getString(final String key) {
|
||||
return this.get(key).getAsString();
|
||||
}
|
||||
@@ -279,4 +348,16 @@ public final class OriginBlacklistConfig {
|
||||
}
|
||||
obj.add(key, value);
|
||||
}
|
||||
|
||||
private static final String[] splitPath(final String key) {
|
||||
final String[] ret;
|
||||
|
||||
if (OriginBlacklist.isNonNull(key)) {
|
||||
ret = key.split("\\.");
|
||||
} else {
|
||||
ret = new String[0];
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@ package xyz.webmc.originblacklist.base.util;
|
||||
import java.io.InputStream;
|
||||
import java.util.Properties;
|
||||
|
||||
public class BuildInfo {
|
||||
public final class BuildInfo {
|
||||
private static final Properties properties;
|
||||
|
||||
public static final String get(final String key) {
|
||||
@@ -14,6 +14,7 @@ public class BuildInfo {
|
||||
properties = new Properties();
|
||||
try (final InputStream in = BuildInfo.class.getClassLoader().getResourceAsStream("build.properties")) {
|
||||
properties.load(in);
|
||||
} catch (final Throwable t) {}
|
||||
} catch (final Throwable t) {
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,13 +12,22 @@ import org.semver4j.Semver;
|
||||
|
||||
public interface IOriginBlacklistPlugin {
|
||||
public String getPluginId();
|
||||
|
||||
public Semver getPluginVersion();
|
||||
|
||||
public Path getPluginJarPath();
|
||||
|
||||
public void log(final EnumLogLevel level, final String txt);
|
||||
|
||||
public void kickPlayer(final Component txt, final OriginBlacklistLoginEvent event);
|
||||
|
||||
public void setMOTD(final Component txt, final OriginBlacklistMOTDEvent event);
|
||||
|
||||
public String parsePlaceholders(final OPlayer player, final String str);
|
||||
|
||||
public void scheduleRepeat(final Runnable task, final int period, final TimeUnit unit);
|
||||
|
||||
public void runAsync(final Runnable task);
|
||||
|
||||
public void shutdown();
|
||||
}
|
||||
|
||||
@@ -78,9 +78,7 @@ public final class OPlayer {
|
||||
}
|
||||
|
||||
private static final String formatIPAddress(String addr) {
|
||||
if (addr == null) {
|
||||
addr = OriginBlacklist.UNKNOWN_STR;
|
||||
} else {
|
||||
if (OriginBlacklist.isNonNull(addr)) {
|
||||
if (addr.startsWith("/")) {
|
||||
addr = addr.substring(1);
|
||||
}
|
||||
@@ -132,6 +130,8 @@ public final class OPlayer {
|
||||
if (hex && c == 6 && addr.indexOf("::") == -1) {
|
||||
addr = addr + "::";
|
||||
}
|
||||
} else {
|
||||
addr = OriginBlacklist.UNKNOWN_STR;
|
||||
}
|
||||
|
||||
return addr;
|
||||
|
||||
@@ -14,10 +14,11 @@ import de.marhali.json5.Json5Object;
|
||||
import org.semver4j.Semver;
|
||||
import org.semver4j.Semver.VersionDiff;
|
||||
|
||||
public class UpdateChecker {
|
||||
public final class UpdateChecker {
|
||||
private static final Json5 json5 = Json5.builder(builder -> builder.build());
|
||||
|
||||
public static final String checkForUpdates(final String repo, final Semver currentVersion, final boolean allowSnapshots) {
|
||||
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 HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||
@@ -46,11 +47,13 @@ public class UpdateChecker {
|
||||
}
|
||||
final boolean pre = obj.get("prerelease").getAsBoolean();
|
||||
if (!pre) {
|
||||
if (rel == null || obj.get("published_at").getAsString().compareTo(rel.get("published_at").getAsString()) > 0) {
|
||||
if (rel == null
|
||||
|| obj.get("published_at").getAsString().compareTo(rel.get("published_at").getAsString()) > 0) {
|
||||
rel = obj;
|
||||
}
|
||||
} else {
|
||||
if (snap == null || obj.get("published_at").getAsString().compareTo(snap.get("published_at").getAsString()) > 0) {
|
||||
if (snap == null
|
||||
|| obj.get("published_at").getAsString().compareTo(snap.get("published_at").getAsString()) > 0) {
|
||||
snap = obj;
|
||||
}
|
||||
}
|
||||
@@ -71,7 +74,8 @@ public class UpdateChecker {
|
||||
} catch (Throwable t) {
|
||||
comm = "";
|
||||
}
|
||||
if (ver.isGreaterThan(currentVersion) || (allowSnapshots && currentVersion.diff(ver) == VersionDiff.BUILD && OriginBlacklist.isNonNull(comm) && !BuildInfo.get("git_cm_hash").startsWith(comm))) {
|
||||
if (ver.isGreaterThan(currentVersion) || (allowSnapshots && currentVersion.diff(ver) == VersionDiff.BUILD
|
||||
&& OriginBlacklist.isNonNull(comm) && !BuildInfo.get("git_cm_hash").startsWith(comm))) {
|
||||
element = obj.get("assets");
|
||||
if (element instanceof Json5Array) {
|
||||
final Json5Array aArr = element.getAsJson5Array();
|
||||
|
||||
@@ -5,7 +5,7 @@ import xyz.webmc.originblacklist.base.command.CommandContext;
|
||||
|
||||
import org.bukkit.command.CommandSender;
|
||||
|
||||
public class BKTCommandContext implements CommandContext {
|
||||
public final class BKTCommandContext implements CommandContext {
|
||||
private final OriginBlacklist plugin;
|
||||
private final CommandSender sender;
|
||||
private final String[] args;
|
||||
@@ -17,27 +17,27 @@ public class BKTCommandContext implements CommandContext {
|
||||
}
|
||||
|
||||
@Override
|
||||
public OriginBlacklist getPlugin() {
|
||||
public final OriginBlacklist getPlugin() {
|
||||
return this.plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerName() {
|
||||
public final String getPlayerName() {
|
||||
return this.sender.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reply(final String message) {
|
||||
public final void reply(final String message) {
|
||||
this.sender.sendMessage(OriginBlacklist.getLegacyFromMiniMessage(message));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final String permission) {
|
||||
public final boolean hasPermission(final String permission) {
|
||||
return this.sender.hasPermission(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArgs() {
|
||||
public final String[] getArgs() {
|
||||
return this.args;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -9,7 +9,7 @@ import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.command.TabExecutor;
|
||||
|
||||
public class OriginBlacklistCommandBukkit extends OriginBlacklistCommand implements TabExecutor {
|
||||
public final class OriginBlacklistCommandBukkit extends OriginBlacklistCommand implements TabExecutor {
|
||||
private final OriginBlacklist plugin;
|
||||
|
||||
public OriginBlacklistCommandBukkit(OriginBlacklist plugin) {
|
||||
@@ -23,7 +23,8 @@ public class OriginBlacklistCommandBukkit extends OriginBlacklistCommand impleme
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(final CommandSender sender, final Command command, final String label, final String[] args) {
|
||||
public List<String> onTabComplete(final CommandSender sender, final Command command, final String label,
|
||||
final String[] args) {
|
||||
return super.suggest(new BKTCommandContext(this.plugin, sender, args));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import xyz.webmc.originblacklist.base.command.CommandContext;
|
||||
import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.chat.TextComponent;
|
||||
|
||||
public class BNGCommandContext implements CommandContext {
|
||||
public final class BNGCommandContext implements CommandContext {
|
||||
private final OriginBlacklist plugin;
|
||||
private final CommandSender sender;
|
||||
private final String[] args;
|
||||
@@ -18,27 +18,27 @@ public class BNGCommandContext implements CommandContext {
|
||||
}
|
||||
|
||||
@Override
|
||||
public OriginBlacklist getPlugin() {
|
||||
public final OriginBlacklist getPlugin() {
|
||||
return this.plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerName() {
|
||||
public final String getPlayerName() {
|
||||
return this.sender.getName();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reply(final String message) {
|
||||
public final void reply(final String message) {
|
||||
this.sender.sendMessage(TextComponent.fromLegacy(OriginBlacklist.getLegacyFromMiniMessage(message)));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final String permission) {
|
||||
public final boolean hasPermission(final String permission) {
|
||||
return this.sender.hasPermission(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArgs() {
|
||||
public final String[] getArgs() {
|
||||
return this.args;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -10,23 +10,24 @@ import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.plugin.Command;
|
||||
import net.md_5.bungee.api.plugin.TabExecutor;
|
||||
|
||||
public class OriginBlacklistCommandBungee extends Command implements TabExecutor {
|
||||
public final class OriginBlacklistCommandBungee extends Command implements TabExecutor {
|
||||
private final OriginBlacklistCommand cmd;
|
||||
private final OriginBlacklist blacklist;
|
||||
|
||||
public OriginBlacklistCommandBungee(final OriginBlacklistBungee plugin, final OriginBlacklist blacklist, final String command) {
|
||||
public OriginBlacklistCommandBungee(final OriginBlacklistBungee plugin, final OriginBlacklist blacklist,
|
||||
final String command) {
|
||||
super(command);
|
||||
this.cmd = new OriginBlacklistCommand(blacklist);
|
||||
this.blacklist = blacklist;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final CommandSender sender, final String[] args) {
|
||||
public final void execute(final CommandSender sender, final String[] args) {
|
||||
this.cmd.execute(new BNGCommandContext(this.blacklist, sender, args));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> onTabComplete(final CommandSender sender, final String[] args) {
|
||||
public final List<String> onTabComplete(final CommandSender sender, final String[] args) {
|
||||
return this.cmd.suggest(new BNGCommandContext(this.blacklist, sender, args));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -64,7 +64,7 @@ public final class OriginBlacklistVelocity implements IOriginBlacklistPlugin {
|
||||
}
|
||||
|
||||
@Subscribe
|
||||
public void onProxyInitialization(ProxyInitializeEvent event) {
|
||||
public final void onProxyInitialization(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)) {
|
||||
|
||||
@@ -7,7 +7,7 @@ import java.util.List;
|
||||
|
||||
import com.velocitypowered.api.command.SimpleCommand;
|
||||
|
||||
public class OriginBlacklistCommandVelocity extends OriginBlacklistCommand implements SimpleCommand {
|
||||
public final class OriginBlacklistCommandVelocity extends OriginBlacklistCommand implements SimpleCommand {
|
||||
private final OriginBlacklist plugin;
|
||||
|
||||
public OriginBlacklistCommandVelocity(OriginBlacklist plugin) {
|
||||
@@ -16,12 +16,12 @@ public class OriginBlacklistCommandVelocity extends OriginBlacklistCommand imple
|
||||
}
|
||||
|
||||
@Override
|
||||
public void execute(final Invocation invocation) {
|
||||
public final void execute(final Invocation invocation) {
|
||||
super.execute(new VCommandContext(this.plugin, invocation));
|
||||
}
|
||||
|
||||
@Override
|
||||
public List<String> suggest(final Invocation invocation) {
|
||||
public final List<String> suggest(final Invocation invocation) {
|
||||
return super.suggest(new VCommandContext(this.plugin, invocation));
|
||||
}
|
||||
}
|
||||
|
||||
@@ -6,7 +6,7 @@ import xyz.webmc.originblacklist.base.command.CommandContext;
|
||||
import com.velocitypowered.api.command.SimpleCommand.Invocation;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
|
||||
public class VCommandContext implements CommandContext {
|
||||
public final class VCommandContext implements CommandContext {
|
||||
private final OriginBlacklist plugin;
|
||||
private final Invocation invocation;
|
||||
|
||||
@@ -16,27 +16,27 @@ public class VCommandContext implements CommandContext {
|
||||
}
|
||||
|
||||
@Override
|
||||
public OriginBlacklist getPlugin() {
|
||||
public final OriginBlacklist getPlugin() {
|
||||
return this.plugin;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getPlayerName() {
|
||||
public final String getPlayerName() {
|
||||
return this.invocation.source().toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public void reply(final String message) {
|
||||
this.invocation.source().sendMessage(MiniMessage.miniMessage().deserialize(message));
|
||||
public final void reply(final String message) {
|
||||
this.invocation.source().sendMessage(MiniMessage.miniMessage().deserialize(message));
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean hasPermission(final String permission) {
|
||||
public final boolean hasPermission(final String permission) {
|
||||
return this.invocation.source().hasPermission(permission);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getArgs() {
|
||||
public final String[] getArgs() {
|
||||
return this.invocation.arguments();
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user