mirror of
https://github.com/colbster937/originblacklist.git
synced 2026-02-04 19:17:40 +00:00
Compare commits
2 Commits
v2.0.3+581
...
v2.0.4+5e2
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
5e29f7f74a | ||
|
|
ffdbcfa3b4 |
@@ -9,16 +9,19 @@
|
|||||||
- [x] Client brand based blacklisting
|
- [x] Client brand based blacklisting
|
||||||
- [x] Username based blacklisting
|
- [x] Username based blacklisting
|
||||||
- [x] IP based blacklisting
|
- [x] IP based blacklisting
|
||||||
- [x] Modular multi-platform support
|
|
||||||
- [x] JSON5 based configuration
|
|
||||||
- [x] Kick message customization
|
- [x] Kick message customization
|
||||||
- [x] Blacklist MOTD customization
|
- [x] Blacklist MOTD customization
|
||||||
- [x] MiniMessage and legacy formattings supported
|
- [x] MiniMessage and legacy formattings supported
|
||||||
- [x] Plugin update checker
|
- [x] Plugin update checker
|
||||||
- [x] Send blacklist logs to a webhook
|
- [x] Send blacklist logs to a webhook
|
||||||
|
- [x] Reverse blacklist (whitelist)
|
||||||
- [ ] Ingame blacklist management command
|
- [ ] Ingame blacklist management command
|
||||||
- [ ] Subscribe to an auto-updating blacklist
|
- [ ] Subscribe to an auto-updating blacklist
|
||||||
- [ ] Reverse blacklist (whitelist)
|
|
||||||
|
<h2>Changes from v1</h2>
|
||||||
|
|
||||||
|
- [x] Modular multi-platform support
|
||||||
|
- [x] JSON5 based configuration
|
||||||
|
|
||||||
<h2>Download</h2>
|
<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>
|
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>
|
||||||
|
|||||||
@@ -13,7 +13,7 @@ val PLUGIN_NAME = "OriginBlacklist"
|
|||||||
val PLUGIN_IDEN = "originblacklist"
|
val PLUGIN_IDEN = "originblacklist"
|
||||||
val PLUGIN_DOMN = "xyz.webmc"
|
val PLUGIN_DOMN = "xyz.webmc"
|
||||||
val PLUGIN_DESC = "An eaglercraft client blacklist plugin."
|
val PLUGIN_DESC = "An eaglercraft client blacklist plugin."
|
||||||
val PLUGIN_VERS = "2.0.3"
|
val PLUGIN_VERS = "2.0.4"
|
||||||
val PLUGIN_SITE = "https://github.com/WebMCDevelopment/$PLUGIN_IDEN"
|
val PLUGIN_SITE = "https://github.com/WebMCDevelopment/$PLUGIN_IDEN"
|
||||||
val PLUGIN_DEPA = listOf("EaglercraftXServer")
|
val PLUGIN_DEPA = listOf("EaglercraftXServer")
|
||||||
val PLUGIN_DEPB = listOf("EaglercraftXServer")
|
val PLUGIN_DEPB = listOf("EaglercraftXServer")
|
||||||
|
|||||||
@@ -24,7 +24,6 @@ import java.nio.file.StandardCopyOption;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Base64;
|
import java.util.Base64;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CompletableFuture;
|
|
||||||
import java.util.concurrent.TimeUnit;
|
import java.util.concurrent.TimeUnit;
|
||||||
|
|
||||||
import de.marhali.json5.Json5Array;
|
import de.marhali.json5.Json5Array;
|
||||||
@@ -54,8 +53,8 @@ public final class OriginBlacklist {
|
|||||||
this.plugin = plugin;
|
this.plugin = plugin;
|
||||||
this.config = new OriginBlacklistConfig(plugin);
|
this.config = new OriginBlacklistConfig(plugin);
|
||||||
plugin.scheduleRepeat(() -> {
|
plugin.scheduleRepeat(() -> {
|
||||||
this.checkForUpdate();
|
this.checkForUpdates();
|
||||||
}, 60, TimeUnit.MINUTES);
|
}, this.config.getInteger("update_checker.check_timer"), TimeUnit.SECONDS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public final void init() {
|
public final void init() {
|
||||||
@@ -109,11 +108,11 @@ public final class OriginBlacklist {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public final boolean isDebugEnabled() {
|
public final boolean isDebugEnabled() {
|
||||||
return this.config.get("debug").getAsBoolean();
|
return this.config.getBoolean("debug");
|
||||||
}
|
}
|
||||||
|
|
||||||
public final boolean isMetricsEnabled() {
|
public final boolean isMetricsEnabled() {
|
||||||
return this.config.get("bStats").getAsBoolean();
|
return this.config.getBoolean("bStats");
|
||||||
}
|
}
|
||||||
|
|
||||||
public final OriginBlacklistConfig getConfig() {
|
public final OriginBlacklistConfig getConfig() {
|
||||||
@@ -135,57 +134,133 @@ public final class OriginBlacklist {
|
|||||||
conn.disconnect();
|
conn.disconnect();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final void checkForUpdates(Runnable action1, Runnable action2) {
|
||||||
|
if (this.config.getBoolean("update_checker.enabled")) {
|
||||||
|
this.plugin.runAsync(() -> {
|
||||||
|
this.updateURL = UpdateChecker.checkForUpdates(PLUGIN_REPO, this.plugin.getPluginVersion(),
|
||||||
|
this.config.getBoolean("update_checker.allow_snapshots"));
|
||||||
|
if (isNonNull((this.updateURL))) {
|
||||||
|
action1.run();
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
action2.run();
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
action2.run();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void updatePlugin(Runnable action1, Runnable action2) {
|
||||||
|
try {
|
||||||
|
final URL url = new URL(this.updateURL);
|
||||||
|
final Path jar = this.plugin.getPluginJarPath();
|
||||||
|
final Path bak = jar.resolveSibling(jar.getFileName().toString() + ".bak");
|
||||||
|
final Path upd = jar.resolveSibling(Paths.get(URLDecoder.decode(url.getPath(), StandardCharsets.UTF_8)).getFileName());
|
||||||
|
|
||||||
|
try {
|
||||||
|
Files.copy(jar, bak, StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
} catch (final Throwable t) {
|
||||||
|
t.printStackTrace();
|
||||||
|
}
|
||||||
|
|
||||||
|
try {
|
||||||
|
final HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||||
|
conn.setRequestMethod("GET");
|
||||||
|
conn.setConnectTimeout(15000);
|
||||||
|
conn.setReadTimeout(15000);
|
||||||
|
conn.setRequestProperty("User-Agent", OriginBlacklist.getUserAgent());
|
||||||
|
conn.connect();
|
||||||
|
try (final InputStream in = conn.getInputStream()) {
|
||||||
|
Files.copy(in, upd, StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
} finally {
|
||||||
|
conn.disconnect();
|
||||||
|
}
|
||||||
|
Files.delete(jar);
|
||||||
|
Files.delete(bak);
|
||||||
|
action1.run();
|
||||||
|
return;
|
||||||
|
} catch (final Throwable t) {
|
||||||
|
t.printStackTrace();
|
||||||
|
Files.move(bak, jar, StandardCopyOption.REPLACE_EXISTING);
|
||||||
|
}
|
||||||
|
} catch (final Throwable t) {
|
||||||
|
t.printStackTrace();
|
||||||
|
}
|
||||||
|
action2.run();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final void updatePlugin() {
|
||||||
|
this.updatePlugin(() -> {}, () -> {});
|
||||||
|
}
|
||||||
|
|
||||||
private final EnumBlacklistType testBlacklist(final OPlayer player) {
|
private final EnumBlacklistType testBlacklist(final OPlayer player) {
|
||||||
final String name = player.getName();
|
final String name = player.getName();
|
||||||
final String addr = player.getAddr();
|
final String addr = player.getAddr();
|
||||||
final String origin = player.getOrigin();
|
final String origin = player.getOrigin();
|
||||||
final String brand = player.getBrand();
|
final String brand = player.getBrand();
|
||||||
|
|
||||||
|
final boolean whitelist = this.config.getBoolean("blacklist_to_whitelist");
|
||||||
|
EnumBlacklistType type = EnumBlacklistType.NONE;
|
||||||
|
|
||||||
if (isNonNull(origin)) {
|
if (isNonNull(origin)) {
|
||||||
for (final Json5Element element : this.config.get("blacklist.origins").getAsJson5Array()) {
|
if (whitelist && !type.isBlacklisted()) type = EnumBlacklistType.ORIGIN;
|
||||||
|
for (final Json5Element element : this.config.getArray("blacklist.origins").getAsJson5Array()) {
|
||||||
if (origin.matches(element.getAsString())) {
|
if (origin.matches(element.getAsString())) {
|
||||||
return EnumBlacklistType.ORIGIN;
|
if (whitelist) type = EnumBlacklistType.NONE;
|
||||||
|
else if (!type.isBlacklisted()) type = EnumBlacklistType.ORIGIN;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
} else if (this.config.getBoolean("block_undefined_origin")) {
|
||||||
|
return whitelist ? EnumBlacklistType.NONE : EnumBlacklistType.ORIGIN;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isNonNull(brand)) {
|
if (isNonNull(brand)) {
|
||||||
for (final Json5Element element : this.config.get("blacklist.brands").getAsJson5Array()) {
|
if (whitelist && !type.isBlacklisted()) type = EnumBlacklistType.BRAND;
|
||||||
|
for (final Json5Element element : this.config.getArray("blacklist.brands")) {
|
||||||
if (brand.matches(element.getAsString())) {
|
if (brand.matches(element.getAsString())) {
|
||||||
return EnumBlacklistType.BRAND;
|
if (whitelist) type = EnumBlacklistType.NONE;
|
||||||
|
else if (!type.isBlacklisted()) type = EnumBlacklistType.BRAND;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isNonNull(name)) {
|
if (isNonNull(name)) {
|
||||||
for (final Json5Element element : this.config.get("blacklist.player_names").getAsJson5Array()) {
|
if (whitelist && !type.isBlacklisted()) type = EnumBlacklistType.NAME;
|
||||||
|
for (final Json5Element element : this.config.getArray("blacklist.player_names")) {
|
||||||
this.plugin.log(EnumLogLevel.DEBUG, element.getAsString());
|
this.plugin.log(EnumLogLevel.DEBUG, element.getAsString());
|
||||||
if (name.matches(element.getAsString())) {
|
if (name.matches(element.getAsString())) {
|
||||||
return EnumBlacklistType.NAME;
|
if (whitelist) type = EnumBlacklistType.NONE;
|
||||||
|
else if (!type.isBlacklisted()) type = EnumBlacklistType.NAME;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (isNonNull(addr)) {
|
if (isNonNull(addr)) {
|
||||||
for (final Json5Element element : this.config.get("blacklist.ip_addresses").getAsJson5Array()) {
|
if (whitelist && !type.isBlacklisted()) type = EnumBlacklistType.ADDR;
|
||||||
|
for (final Json5Element element : this.config.getArray("blacklist.ip_addresses")) {
|
||||||
try {
|
try {
|
||||||
if ((new IPAddressString(element.getAsString()).toAddress())
|
if ((new IPAddressString(element.getAsString()).toAddress())
|
||||||
.contains((new IPAddressString(addr)).toAddress())) {
|
.contains((new IPAddressString(addr)).toAddress())) {
|
||||||
return EnumBlacklistType.ADDR;
|
if (whitelist) type = EnumBlacklistType.NONE;
|
||||||
|
else if (!type.isBlacklisted()) type = EnumBlacklistType.ADDR;
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
} catch (final AddressStringException exception) {
|
} catch (final AddressStringException exception) {
|
||||||
// exception.printStackTrace();
|
if (this.isDebugEnabled()) exception.printStackTrace();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return EnumBlacklistType.NONE;
|
return type;
|
||||||
}
|
}
|
||||||
|
|
||||||
private final Component getBlacklistedComponent(final String type, final String id, final String blockType,
|
private final Component getBlacklistedComponent(final String type, final String id, final String blockType,
|
||||||
final String blockTypeAlt, final String notAllowed, final String notAllowedAlt, final String blockValue,
|
final String blockTypeAlt, final String notAllowed, final String notAllowedAlt, final String blockValue,
|
||||||
final String action) {
|
final String action) {
|
||||||
final Json5Array arr = this.config.get("messages." + type).getAsJson5Array();
|
final Json5Array arr = this.config.getArray("messages." + type);
|
||||||
final StringBuilder sb = new StringBuilder();
|
final StringBuilder sb = new StringBuilder();
|
||||||
for (int i = 0; i < arr.size(); i++) {
|
for (int i = 0; i < arr.size(); i++) {
|
||||||
if (i > 0)
|
if (i > 0)
|
||||||
@@ -193,7 +268,7 @@ public final class OriginBlacklist {
|
|||||||
sb.append(arr.get(i).getAsString());
|
sb.append(arr.get(i).getAsString());
|
||||||
}
|
}
|
||||||
final String str = sb.toString()
|
final String str = sb.toString()
|
||||||
.replaceAll("%action%", this.config.get("messages.actions." + action).getAsString())
|
.replaceAll("%action%", this.config.getString("messages.actions." + action))
|
||||||
.replaceAll("%block_type%", blockType)
|
.replaceAll("%block_type%", blockType)
|
||||||
.replaceAll("%block_type%", blockType)
|
.replaceAll("%block_type%", blockType)
|
||||||
.replaceAll("%not_allowed%", notAllowed)
|
.replaceAll("%not_allowed%", notAllowed)
|
||||||
@@ -203,8 +278,7 @@ public final class OriginBlacklist {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private final void sendWebhooks(final OriginBlacklistLoginEvent event, final EnumBlacklistType type) {
|
private final void sendWebhooks(final OriginBlacklistLoginEvent event, final EnumBlacklistType type) {
|
||||||
Json5Element element = this.config.get("discord.enabled");
|
if (this.config.getBoolean("discord.enabled")) {
|
||||||
if (element.getAsBoolean()) {
|
|
||||||
final OPlayer player = event.getPlayer();
|
final OPlayer player = event.getPlayer();
|
||||||
final EnumConnectionType connType = event.getConnectionType();
|
final EnumConnectionType connType = event.getConnectionType();
|
||||||
final String userAgent;
|
final String userAgent;
|
||||||
@@ -252,7 +326,7 @@ public final class OriginBlacklist {
|
|||||||
player.getName().replaceAll("_", "\\_"),
|
player.getName().replaceAll("_", "\\_"),
|
||||||
player.getOrigin(),
|
player.getOrigin(),
|
||||||
player.getBrand(),
|
player.getBrand(),
|
||||||
this.config.get("discord.send_ips").getAsBoolean() ? player.getAddr() : "*\\*CENSORED\\**",
|
this.config.getBoolean("discord.send_ips") ? player.getAddr() : "*\\*CENSORED\\**",
|
||||||
player.getPVN(),
|
player.getPVN(),
|
||||||
userAgent,
|
userAgent,
|
||||||
player.isRewind() ? "YES" : "NO",
|
player.isRewind() ? "YES" : "NO",
|
||||||
@@ -261,10 +335,10 @@ public final class OriginBlacklist {
|
|||||||
PLUGIN_REPO,
|
PLUGIN_REPO,
|
||||||
PLUGIN_REPO
|
PLUGIN_REPO
|
||||||
).getBytes();
|
).getBytes();
|
||||||
element = this.config.get("discord.webhook_urls");
|
final Json5Element element = this.config.get("discord.webhook_urls");
|
||||||
if (element instanceof Json5Array) {
|
if (element instanceof Json5Array) {
|
||||||
for (final Json5Element _element : element.getAsJson5Array()) {
|
for (final Json5Element _element : element.getAsJson5Array()) {
|
||||||
CompletableFuture.runAsync(() -> {
|
this.plugin.runAsync(() -> {
|
||||||
try {
|
try {
|
||||||
final URL url = new URL(_element.getAsString());
|
final URL url = new URL(_element.getAsString());
|
||||||
final HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
final HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||||
@@ -293,56 +367,14 @@ public final class OriginBlacklist {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private final void checkForUpdate() {
|
private final void checkForUpdates() {
|
||||||
if (this.config.get("update_checker.enabled").getAsBoolean()) {
|
this.checkForUpdates(() -> {
|
||||||
CompletableFuture.runAsync(() -> {
|
if (!this.config.getBoolean("update_checker.auto_update")) {
|
||||||
this.updateURL = UpdateChecker.checkForUpdate(PLUGIN_REPO, this.plugin.getPluginVersion(),
|
this.plugin.log(EnumLogLevel.INFO, "An update is available! Download it at " + this.updateURL);
|
||||||
this.config.get("update_checker.allow_snapshots").getAsBoolean());
|
} else {
|
||||||
if (isNonNull((this.updateURL))) {
|
this.updatePlugin();
|
||||||
if (!this.config.get("update_checker.auto_update").getAsBoolean()) {
|
|
||||||
this.plugin.log(EnumLogLevel.INFO, "An update is available! Download it at " + this.updateURL);
|
|
||||||
} else {
|
|
||||||
this.updatePlugin();
|
|
||||||
}
|
|
||||||
}
|
|
||||||
});
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private final void updatePlugin() {
|
|
||||||
try {
|
|
||||||
final URL url = new URL(this.updateURL);
|
|
||||||
final Path jar = this.plugin.getPluginJarPath();
|
|
||||||
final Path bak = jar.resolveSibling(jar.getFileName().toString() + ".bak");
|
|
||||||
final Path upd = jar.resolveSibling(Paths.get(URLDecoder.decode(url.getPath(), StandardCharsets.UTF_8)).getFileName());
|
|
||||||
|
|
||||||
try {
|
|
||||||
Files.copy(jar, bak, StandardCopyOption.REPLACE_EXISTING);
|
|
||||||
} catch (final Throwable t) {
|
|
||||||
t.printStackTrace();
|
|
||||||
}
|
}
|
||||||
|
}, () -> {});
|
||||||
try {
|
|
||||||
final HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
|
||||||
conn.setRequestMethod("GET");
|
|
||||||
conn.setConnectTimeout(15000);
|
|
||||||
conn.setReadTimeout(15000);
|
|
||||||
conn.setRequestProperty("User-Agent", OriginBlacklist.getUserAgent());
|
|
||||||
conn.connect();
|
|
||||||
try (final InputStream in = conn.getInputStream()) {
|
|
||||||
Files.copy(in, upd, StandardCopyOption.REPLACE_EXISTING);
|
|
||||||
} finally {
|
|
||||||
conn.disconnect();
|
|
||||||
}
|
|
||||||
Files.delete(jar);
|
|
||||||
Files.delete(bak);
|
|
||||||
} catch (final Throwable t) {
|
|
||||||
t.printStackTrace();
|
|
||||||
Files.move(bak, jar, StandardCopyOption.REPLACE_EXISTING);
|
|
||||||
}
|
|
||||||
} catch (final Throwable t) {
|
|
||||||
t.printStackTrace();
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static final String getComponentString(final Component comp) {
|
public static final String getComponentString(final Component comp) {
|
||||||
|
|||||||
@@ -1,6 +1,9 @@
|
|||||||
package xyz.webmc.originblacklist.base.command;
|
package xyz.webmc.originblacklist.base.command;
|
||||||
|
|
||||||
|
import xyz.webmc.originblacklist.base.OriginBlacklist;
|
||||||
|
|
||||||
public interface CommandContext {
|
public interface CommandContext {
|
||||||
|
public OriginBlacklist getPlugin();
|
||||||
public String getPlayerName();
|
public String getPlayerName();
|
||||||
public void reply(final String message);
|
public void reply(final String message);
|
||||||
public boolean hasPermission(final String permission);
|
public boolean hasPermission(final String permission);
|
||||||
|
|||||||
@@ -30,24 +30,41 @@ public class OriginBlacklistCommand implements ICommand {
|
|||||||
if (ctx.hasPermission("originblacklist.command.reload")) {
|
if (ctx.hasPermission("originblacklist.command.reload")) {
|
||||||
ctx.reply("<aqua>Blacklist:</aqua>");
|
ctx.reply("<aqua>Blacklist:</aqua>");
|
||||||
ctx.reply("<gold> - Origins:</gold>");
|
ctx.reply("<gold> - Origins:</gold>");
|
||||||
for (final Json5Element element : this.plugin.getConfig().get("blacklist.origins").getAsJson5Array()) {
|
for (final Json5Element element : this.plugin.getConfig().getArray("blacklist.origins")) {
|
||||||
ctx.reply("<gray> - " + element.getAsString() + "</gray>");
|
ctx.reply("<gray> - " + element.getAsString() + "</gray>");
|
||||||
}
|
}
|
||||||
ctx.reply("<gold> - Brands:</gold>");
|
ctx.reply("<gold> - Brands:</gold>");
|
||||||
for (final Json5Element element : this.plugin.getConfig().get("blacklist.brands").getAsJson5Array()) {
|
for (final Json5Element element : this.plugin.getConfig().getArray("blacklist.brands")) {
|
||||||
ctx.reply("<gray> - " + element.getAsString() + "</gray>");
|
ctx.reply("<gray> - " + element.getAsString() + "</gray>");
|
||||||
}
|
}
|
||||||
ctx.reply("<gold> - Players:</gold>");
|
ctx.reply("<gold> - Players:</gold>");
|
||||||
for (final Json5Element element : this.plugin.getConfig().get("blacklist.player_names").getAsJson5Array()) {
|
for (final Json5Element element : this.plugin.getConfig().getArray("blacklist.player_names")) {
|
||||||
ctx.reply("<gray> - " + element.getAsString() + "</gray>");
|
ctx.reply("<gray> - " + element.getAsString() + "</gray>");
|
||||||
}
|
}
|
||||||
ctx.reply("<gold> - IPs:</gold>");
|
ctx.reply("<gold> - IPs:</gold>");
|
||||||
for (final Json5Element element : this.plugin.getConfig().get("blacklist.ip_addresses").getAsJson5Array()) {
|
for (final Json5Element element : this.plugin.getConfig().getArray("blacklist.ip_addresses")) {
|
||||||
ctx.reply("<gray> - " + element.getAsString() + "</gray>");
|
ctx.reply("<gray> - " + element.getAsString() + "</gray>");
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
ctx.reply(NO_PERMISSION);
|
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(() -> {
|
||||||
|
ctx.reply("<yellow>Updating plugin...</yellow>");
|
||||||
|
plugin.updatePlugin(() -> {
|
||||||
|
ctx.reply("<green>Successfully updated plugin.</green>");
|
||||||
|
}, () -> {
|
||||||
|
ctx.reply("<red>Failed to update plugin.</red>");
|
||||||
|
});
|
||||||
|
}, () -> {
|
||||||
|
ctx.reply("<green>Plugin is up to date.</green>");
|
||||||
|
});
|
||||||
|
} else {
|
||||||
|
ctx.reply(NO_PERMISSION);
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
this.usage(ctx);
|
this.usage(ctx);
|
||||||
}
|
}
|
||||||
@@ -69,6 +86,7 @@ public class OriginBlacklistCommand implements ICommand {
|
|||||||
public void usage(CommandContext ctx) {
|
public void usage(CommandContext ctx) {
|
||||||
ctx.reply("<aqua>Commands:</aqua>");
|
ctx.reply("<aqua>Commands:</aqua>");
|
||||||
ctx.reply("<gray> - /originblacklist reload</gray>");
|
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 add <brand/origin/name/ip> <value></gray>");
|
||||||
// ctx.reply("<gray> - /originblacklist remove <brand/origin/name/ip> <value></gray>");
|
// ctx.reply("<gray> - /originblacklist remove <brand/origin/name/ip> <value></gray>");
|
||||||
ctx.reply("<gray> - /originblacklist list</gray>");
|
ctx.reply("<gray> - /originblacklist list</gray>");
|
||||||
|
|||||||
@@ -31,7 +31,7 @@ public final class OriginBlacklistConfig {
|
|||||||
private byte[] icon;
|
private byte[] icon;
|
||||||
private String icon64;
|
private String icon64;
|
||||||
|
|
||||||
public OriginBlacklistConfig(IOriginBlacklistPlugin plugin) {
|
public OriginBlacklistConfig(final IOriginBlacklistPlugin plugin) {
|
||||||
this.json5 = Json5.builder(builder -> builder
|
this.json5 = Json5.builder(builder -> builder
|
||||||
.quoteless()
|
.quoteless()
|
||||||
.quoteSingle()
|
.quoteSingle()
|
||||||
@@ -155,6 +155,26 @@ public final class OriginBlacklistConfig {
|
|||||||
return element;
|
return element;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final String getString(final String key) {
|
||||||
|
return this.get(key).getAsString();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final boolean getBoolean(final String key) {
|
||||||
|
return this.get(key).getAsBoolean();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final int getInteger(final String key) {
|
||||||
|
return this.get(key).getAsInt();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final Json5Array getArray(final String key) {
|
||||||
|
return this.get(key).getAsJson5Array();
|
||||||
|
}
|
||||||
|
|
||||||
|
public final Json5Object getObject(final String key) {
|
||||||
|
return this.get(key).getAsJson5Object();
|
||||||
|
}
|
||||||
|
|
||||||
public final byte[] getIconBytes() {
|
public final byte[] getIconBytes() {
|
||||||
return this.icon;
|
return this.icon;
|
||||||
}
|
}
|
||||||
@@ -221,9 +241,13 @@ public final class OriginBlacklistConfig {
|
|||||||
final Json5Object uobj = new Json5Object();
|
final Json5Object uobj = new Json5Object();
|
||||||
addJSONObj(uobj, "enabled", Json5Primitive.fromBoolean(true), null);
|
addJSONObj(uobj, "enabled", Json5Primitive.fromBoolean(true), null);
|
||||||
addJSONObj(uobj, "allow_snapshots", Json5Primitive.fromBoolean(false), null);
|
addJSONObj(uobj, "allow_snapshots", Json5Primitive.fromBoolean(false), null);
|
||||||
|
addJSONObj(uobj, "check_timer", Json5Primitive.fromNumber(3600), null);
|
||||||
addJSONObj(uobj, "auto_update", Json5Primitive.fromBoolean(true), null);
|
addJSONObj(uobj, "auto_update", Json5Primitive.fromBoolean(true), null);
|
||||||
addJSONObj(obj, "update_checker", uobj, null);
|
addJSONObj(obj, "update_checker", uobj, null);
|
||||||
|
addJSONObj(obj, "blacklist_to_whitelist", Json5Primitive.fromBoolean(false), null);
|
||||||
|
addJSONObj(obj, "block_undefined_origin", Json5Primitive.fromBoolean(false), null);
|
||||||
addJSONObj(obj, "bStats", Json5Primitive.fromBoolean(true), null);
|
addJSONObj(obj, "bStats", Json5Primitive.fromBoolean(true), null);
|
||||||
|
addJSONObj(obj, "config_version", Json5Primitive.fromNumber(1), "DO NOT CHANGE");
|
||||||
return obj;
|
return obj;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -36,4 +36,8 @@ public enum EnumBlacklistType {
|
|||||||
public final String getActionString() {
|
public final String getActionString() {
|
||||||
return this.act;
|
return this.act;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public final boolean isBlacklisted() {
|
||||||
|
return this != NONE;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,5 +19,6 @@ public interface IOriginBlacklistPlugin {
|
|||||||
public void setMOTD(final Component txt, final OriginBlacklistMOTDEvent event);
|
public void setMOTD(final Component txt, final OriginBlacklistMOTDEvent event);
|
||||||
public String parsePlaceholders(final OPlayer player, final String str);
|
public String parsePlaceholders(final OPlayer player, final String str);
|
||||||
public void scheduleRepeat(final Runnable task, final int period, final TimeUnit unit);
|
public void scheduleRepeat(final Runnable task, final int period, final TimeUnit unit);
|
||||||
|
public void runAsync(final Runnable task);
|
||||||
public void shutdown();
|
public void shutdown();
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -17,7 +17,7 @@ import org.semver4j.Semver.VersionDiff;
|
|||||||
public class UpdateChecker {
|
public class UpdateChecker {
|
||||||
private static final Json5 json5 = Json5.builder(builder -> builder.build());
|
private static final Json5 json5 = Json5.builder(builder -> builder.build());
|
||||||
|
|
||||||
public static final String checkForUpdate(final String repo, final Semver currentVersion, final boolean allowSnapshots) {
|
public static final String checkForUpdates(final String repo, final Semver currentVersion, final boolean allowSnapshots) {
|
||||||
try {
|
try {
|
||||||
final URL url = new URL("https://api.github.com/repos/" + repo + "/releases");
|
final URL url = new URL("https://api.github.com/repos/" + repo + "/releases");
|
||||||
final HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
final HttpURLConnection conn = (HttpURLConnection) url.openConnection();
|
||||||
@@ -31,42 +31,62 @@ public class UpdateChecker {
|
|||||||
String ret = null;
|
String ret = null;
|
||||||
Json5Element element = json5.parse(reader);
|
Json5Element element = json5.parse(reader);
|
||||||
reader.close();
|
reader.close();
|
||||||
|
|
||||||
|
Json5Object rel = null;
|
||||||
|
Json5Object snap = null;
|
||||||
|
|
||||||
if (element instanceof Json5Array) {
|
if (element instanceof Json5Array) {
|
||||||
final Json5Array arr = element.getAsJson5Array();
|
final Json5Array arr = element.getAsJson5Array();
|
||||||
if (arr.size() > 0) {
|
for (int i = 0; i < arr.size(); i++) {
|
||||||
for (int i = 0; i < Math.min(2, arr.size()); i++) {
|
element = arr.get(i);
|
||||||
element = arr.get(i);
|
if (element instanceof Json5Object) {
|
||||||
if (element instanceof Json5Object) {
|
final Json5Object obj = element.getAsJson5Object();
|
||||||
final Json5Object obj = element.getAsJson5Object();
|
if (!obj.has("published_at")) {
|
||||||
if (allowSnapshots || !obj.get("prerelease").getAsBoolean()) {
|
continue;
|
||||||
final String tag = obj.get("tag_name").getAsString();
|
}
|
||||||
final Semver ver = new Semver(tag.startsWith("v") ? tag.substring(1) : tag);
|
final boolean pre = obj.get("prerelease").getAsBoolean();
|
||||||
String comm;
|
if (!pre) {
|
||||||
try {
|
if (rel == null || obj.get("published_at").getAsString().compareTo(rel.get("published_at").getAsString()) > 0) {
|
||||||
comm = ver.getBuild().get(0).trim();
|
rel = obj;
|
||||||
} catch (Throwable t) {
|
}
|
||||||
comm = "";
|
} else {
|
||||||
}
|
if (snap == null || obj.get("published_at").getAsString().compareTo(snap.get("published_at").getAsString()) > 0) {
|
||||||
if (ver.isGreaterThan(currentVersion) || (allowSnapshots && currentVersion.diff(ver) == VersionDiff.BUILD && OriginBlacklist.isNonNull(comm) && !BuildInfo.get("git_cm_hash").startsWith(comm))) {
|
snap = obj;
|
||||||
element = obj.get("assets");
|
}
|
||||||
if (element instanceof Json5Array) {
|
}
|
||||||
final Json5Array aArr = element.getAsJson5Array();
|
}
|
||||||
if (aArr.size() > 0) {
|
continue;
|
||||||
element = aArr.get(0);
|
}
|
||||||
if (element instanceof Json5Object) {
|
|
||||||
final Json5Object vObj = element.getAsJson5Object();
|
for (int i = 0; i < 2; i++) {
|
||||||
ret = vObj.get("browser_download_url").getAsString();
|
final Json5Object obj = i == 0 ? rel : snap;
|
||||||
break;
|
if (obj == null || (i == 1 && !allowSnapshots)) {
|
||||||
}
|
continue;
|
||||||
}
|
}
|
||||||
}
|
final String tag = obj.get("tag_name").getAsString();
|
||||||
|
final Semver ver = new Semver(tag.startsWith("v") ? tag.substring(1) : tag);
|
||||||
|
String comm;
|
||||||
|
try {
|
||||||
|
comm = ver.getBuild().get(0).trim();
|
||||||
|
} catch (Throwable t) {
|
||||||
|
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();
|
||||||
|
if (aArr.size() > 0) {
|
||||||
|
element = aArr.get(0);
|
||||||
|
if (element instanceof Json5Object) {
|
||||||
|
ret = element.getAsJson5Object().get("browser_download_url").getAsString();
|
||||||
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
continue;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
conn.disconnect();
|
conn.disconnect();
|
||||||
return ret;
|
return ret;
|
||||||
} catch (final Throwable t) {
|
} catch (final Throwable t) {
|
||||||
|
|||||||
@@ -234,6 +234,11 @@ public final class OriginBlacklistBukkit extends JavaPlugin implements Listener,
|
|||||||
Bukkit.getScheduler().runTaskTimer(this, task, 0, ticks);
|
Bukkit.getScheduler().runTaskTimer(this, task, 0, ticks);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void runAsync(final Runnable task) {
|
||||||
|
Bukkit.getScheduler().runTaskAsynchronously(this, task);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void shutdown() {
|
public final void shutdown() {
|
||||||
this.metrics.shutdown();
|
this.metrics.shutdown();
|
||||||
|
|||||||
@@ -6,14 +6,21 @@ import xyz.webmc.originblacklist.base.command.CommandContext;
|
|||||||
import org.bukkit.command.CommandSender;
|
import org.bukkit.command.CommandSender;
|
||||||
|
|
||||||
public class BKTCommandContext implements CommandContext {
|
public class BKTCommandContext implements CommandContext {
|
||||||
|
private final OriginBlacklist plugin;
|
||||||
private final CommandSender sender;
|
private final CommandSender sender;
|
||||||
private final String[] args;
|
private final String[] args;
|
||||||
|
|
||||||
public BKTCommandContext(final CommandSender sender, final String[] args) {
|
public BKTCommandContext(final OriginBlacklist plugin, final CommandSender sender, final String[] args) {
|
||||||
|
this.plugin = plugin;
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
this.args = args;
|
this.args = args;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OriginBlacklist getPlugin() {
|
||||||
|
return this.plugin;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPlayerName() {
|
public String getPlayerName() {
|
||||||
return this.sender.getName();
|
return this.sender.getName();
|
||||||
|
|||||||
@@ -10,17 +10,20 @@ import org.bukkit.command.CommandSender;
|
|||||||
import org.bukkit.command.TabExecutor;
|
import org.bukkit.command.TabExecutor;
|
||||||
|
|
||||||
public class OriginBlacklistCommandBukkit extends OriginBlacklistCommand implements TabExecutor {
|
public class OriginBlacklistCommandBukkit extends OriginBlacklistCommand implements TabExecutor {
|
||||||
|
private final OriginBlacklist plugin;
|
||||||
|
|
||||||
public OriginBlacklistCommandBukkit(OriginBlacklist plugin) {
|
public OriginBlacklistCommandBukkit(OriginBlacklist plugin) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
|
public boolean onCommand(final CommandSender sender, final Command command, final String label, final String[] args) {
|
||||||
return super.execute(new BKTCommandContext(sender, args));
|
return super.execute(new BKTCommandContext(this.plugin, sender, args));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@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(sender, args));
|
return super.suggest(new BKTCommandContext(this.plugin, sender, args));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -198,6 +198,11 @@ public final class OriginBlacklistBungee extends Plugin implements Listener, IOr
|
|||||||
this.proxy.getScheduler().schedule(this, task, 0, period, unit);
|
this.proxy.getScheduler().schedule(this, task, 0, period, unit);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void runAsync(final Runnable task) {
|
||||||
|
this.proxy.getScheduler().runAsync(this, task);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void shutdown() {
|
public final void shutdown() {
|
||||||
this.metrics.shutdown();
|
this.metrics.shutdown();
|
||||||
|
|||||||
@@ -7,14 +7,21 @@ import net.md_5.bungee.api.CommandSender;
|
|||||||
import net.md_5.bungee.api.chat.TextComponent;
|
import net.md_5.bungee.api.chat.TextComponent;
|
||||||
|
|
||||||
public class BNGCommandContext implements CommandContext {
|
public class BNGCommandContext implements CommandContext {
|
||||||
|
private final OriginBlacklist plugin;
|
||||||
private final CommandSender sender;
|
private final CommandSender sender;
|
||||||
private final String[] args;
|
private final String[] args;
|
||||||
|
|
||||||
public BNGCommandContext(final CommandSender sender, final String[] args) {
|
public BNGCommandContext(final OriginBlacklist plugin, final CommandSender sender, final String[] args) {
|
||||||
|
this.plugin = plugin;
|
||||||
this.sender = sender;
|
this.sender = sender;
|
||||||
this.args = args;
|
this.args = args;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OriginBlacklist getPlugin() {
|
||||||
|
return this.plugin;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPlayerName() {
|
public String getPlayerName() {
|
||||||
return this.sender.getName();
|
return this.sender.getName();
|
||||||
|
|||||||
@@ -12,19 +12,21 @@ import net.md_5.bungee.api.plugin.TabExecutor;
|
|||||||
|
|
||||||
public class OriginBlacklistCommandBungee extends Command implements TabExecutor {
|
public class OriginBlacklistCommandBungee extends Command implements TabExecutor {
|
||||||
private final OriginBlacklistCommand cmd;
|
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);
|
super(command);
|
||||||
this.cmd = new OriginBlacklistCommand(blacklist);
|
this.cmd = new OriginBlacklistCommand(blacklist);
|
||||||
|
this.blacklist = blacklist;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final CommandSender sender, final String[] args) {
|
public void execute(final CommandSender sender, final String[] args) {
|
||||||
this.cmd.execute(new BNGCommandContext(sender, args));
|
this.cmd.execute(new BNGCommandContext(this.blacklist, sender, args));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> onTabComplete(final CommandSender sender, final String[] args) {
|
public List<String> onTabComplete(final CommandSender sender, final String[] args) {
|
||||||
return this.cmd.suggest(new BNGCommandContext(sender, args));
|
return this.cmd.suggest(new BNGCommandContext(this.blacklist, sender, args));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -120,7 +120,8 @@ public final class OriginBlacklistVelocity implements IOriginBlacklistPlugin {
|
|||||||
@Subscribe(order = PostOrder.FIRST)
|
@Subscribe(order = PostOrder.FIRST)
|
||||||
public final void onJavaLogin(final PreLoginEvent event) {
|
public final void onJavaLogin(final PreLoginEvent event) {
|
||||||
final OPlayer player = new OPlayer(null, event.getUsername(), event.getUniqueId(),
|
final OPlayer player = new OPlayer(null, event.getUsername(), event.getUniqueId(),
|
||||||
event.getConnection().getRemoteAddress().toString(), OriginBlacklist.UNKNOWN_STR, event.getConnection().getProtocolVersion().getProtocol());
|
event.getConnection().getRemoteAddress().toString(), OriginBlacklist.UNKNOWN_STR,
|
||||||
|
event.getConnection().getProtocolVersion().getProtocol());
|
||||||
this.blacklist.handleLogin(new OriginBlacklistLoginEvent(null, event, EnumConnectionType.JAVA, player));
|
this.blacklist.handleLogin(new OriginBlacklistLoginEvent(null, event, EnumConnectionType.JAVA, player));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -128,7 +129,8 @@ public final class OriginBlacklistVelocity implements IOriginBlacklistPlugin {
|
|||||||
public final void onJavaHandshake(final PlayerClientBrandEvent event) {
|
public final void onJavaHandshake(final PlayerClientBrandEvent event) {
|
||||||
final Player aPlayer = (Player) event.getPlayer();
|
final Player aPlayer = (Player) event.getPlayer();
|
||||||
final OPlayer bPlayer = new OPlayer(null, aPlayer.getUsername(), aPlayer.getUniqueId(),
|
final OPlayer bPlayer = new OPlayer(null, aPlayer.getUsername(), aPlayer.getUniqueId(),
|
||||||
aPlayer.getRemoteAddress().getAddress().toString(), event.getBrand(), event.getPlayer().getProtocolVersion().getProtocol());
|
aPlayer.getRemoteAddress().getAddress().toString(), event.getBrand(),
|
||||||
|
event.getPlayer().getProtocolVersion().getProtocol());
|
||||||
this.blacklist.handleLogin(new OriginBlacklistLoginEvent(null, event, EnumConnectionType.JAVA, bPlayer));
|
this.blacklist.handleLogin(new OriginBlacklistLoginEvent(null, event, EnumConnectionType.JAVA, bPlayer));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -225,6 +227,13 @@ public final class OriginBlacklistVelocity implements IOriginBlacklistPlugin {
|
|||||||
.schedule();
|
.schedule();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public final void runAsync(final Runnable task) {
|
||||||
|
this.proxy.getScheduler()
|
||||||
|
.buildTask(this, task)
|
||||||
|
.schedule();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public final void shutdown() {
|
public final void shutdown() {
|
||||||
this.metrics.shutdown();
|
this.metrics.shutdown();
|
||||||
|
|||||||
@@ -8,17 +8,20 @@ import java.util.List;
|
|||||||
import com.velocitypowered.api.command.SimpleCommand;
|
import com.velocitypowered.api.command.SimpleCommand;
|
||||||
|
|
||||||
public class OriginBlacklistCommandVelocity extends OriginBlacklistCommand implements SimpleCommand {
|
public class OriginBlacklistCommandVelocity extends OriginBlacklistCommand implements SimpleCommand {
|
||||||
|
private final OriginBlacklist plugin;
|
||||||
|
|
||||||
public OriginBlacklistCommandVelocity(OriginBlacklist plugin) {
|
public OriginBlacklistCommandVelocity(OriginBlacklist plugin) {
|
||||||
super(plugin);
|
super(plugin);
|
||||||
|
this.plugin = plugin;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void execute(final Invocation invocation) {
|
public void execute(final Invocation invocation) {
|
||||||
super.execute(new VCommandContext(invocation));
|
super.execute(new VCommandContext(this.plugin, invocation));
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<String> suggest(final Invocation invocation) {
|
public List<String> suggest(final Invocation invocation) {
|
||||||
return super.suggest(new VCommandContext(invocation));
|
return super.suggest(new VCommandContext(this.plugin, invocation));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,17 +1,25 @@
|
|||||||
package xyz.webmc.originblacklist.velocity.command;
|
package xyz.webmc.originblacklist.velocity.command;
|
||||||
|
|
||||||
|
import xyz.webmc.originblacklist.base.OriginBlacklist;
|
||||||
import xyz.webmc.originblacklist.base.command.CommandContext;
|
import xyz.webmc.originblacklist.base.command.CommandContext;
|
||||||
|
|
||||||
import com.velocitypowered.api.command.SimpleCommand.Invocation;
|
import com.velocitypowered.api.command.SimpleCommand.Invocation;
|
||||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||||
|
|
||||||
public class VCommandContext implements CommandContext {
|
public class VCommandContext implements CommandContext {
|
||||||
|
private final OriginBlacklist plugin;
|
||||||
private final Invocation invocation;
|
private final Invocation invocation;
|
||||||
|
|
||||||
public VCommandContext(final Invocation invocation) {
|
public VCommandContext(final OriginBlacklist plugin, final Invocation invocation) {
|
||||||
|
this.plugin = plugin;
|
||||||
this.invocation = invocation;
|
this.invocation = invocation;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public OriginBlacklist getPlugin() {
|
||||||
|
return this.plugin;
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String getPlayerName() {
|
public String getPlayerName() {
|
||||||
return this.invocation.source().toString();
|
return this.invocation.source().toString();
|
||||||
|
|||||||
Reference in New Issue
Block a user