From fc26521594d78533a46a01acb484471717942c99 Mon Sep 17 00:00:00 2001 From: Luck Date: Fri, 13 Mar 2026 07:59:23 +0000 Subject: [PATCH] Update bytebin/bytesocks custom config settings --- .../lucko/luckperms/common/config/ConfigKeys.java | 11 +++-------- .../luckperms/common/http/BytesocksClient.java | 15 +++++++++++---- .../common/plugin/AbstractLuckPermsPlugin.java | 3 +-- .../standalone/WebEditorIntegrationTest.java | 7 +++---- 4 files changed, 18 insertions(+), 18 deletions(-) diff --git a/common/src/main/java/me/lucko/luckperms/common/config/ConfigKeys.java b/common/src/main/java/me/lucko/luckperms/common/config/ConfigKeys.java index aaf889528..00cfbb3cf 100644 --- a/common/src/main/java/me/lucko/luckperms/common/config/ConfigKeys.java +++ b/common/src/main/java/me/lucko/luckperms/common/config/ConfigKeys.java @@ -768,17 +768,12 @@ public final class ConfigKeys { /** * The URL of the bytebin instance used to upload data */ - public static final ConfigKey BYTEBIN_URL = stringKey("bytebin-url", "https://usercontent.luckperms.net/"); + public static final ConfigKey BYTEBIN_URL = notReloadable(stringKey("bytebin-url", "https://usercontent.luckperms.net/")); /** - * The host of the bytesocks instance used to communicate with + * The URL of the bytesocks instance used to communicate with */ - public static final ConfigKey BYTESOCKS_HOST = stringKey("bytesocks-host", "usersockets.luckperms.net"); - - /** - * If TLS (https/wss) should be used when connecting to bytesocks - */ - public static final ConfigKey BYTESOCKS_USE_TLS = booleanKey("bytesocks-use-tls", true); + public static final ConfigKey BYTESOCKS_URL = notReloadable(stringKey("bytesocks-url", "https://usersockets.luckperms.net/")); /** * The URL of the web editor diff --git a/common/src/main/java/me/lucko/luckperms/common/http/BytesocksClient.java b/common/src/main/java/me/lucko/luckperms/common/http/BytesocksClient.java index b8cb50958..470bb5ddf 100644 --- a/common/src/main/java/me/lucko/luckperms/common/http/BytesocksClient.java +++ b/common/src/main/java/me/lucko/luckperms/common/http/BytesocksClient.java @@ -46,14 +46,21 @@ public class BytesocksClient extends AbstractHttpClient { /** * Creates a new bytesocks instance * - * @param host the bytesocks host + * @param url the bytesocks url * @param userAgent the client user agent string */ - public BytesocksClient(OkHttpClient okHttpClient, String host, boolean tls, String userAgent) { + public BytesocksClient(OkHttpClient okHttpClient, String url, String userAgent) { super(okHttpClient); - this.httpUrl = (tls ? "https://" : "http://") + host + "/"; - this.wsUrl = (tls ? "wss://" : "ws://") + host + "/"; + this.httpUrl = url; + if (this.httpUrl.startsWith("http://")) { + this.wsUrl = "ws://" + this.httpUrl.substring(7); + } else if (this.httpUrl.startsWith("https://")) { + this.wsUrl = "wss://" + this.httpUrl.substring(8); + } else { + throw new IllegalArgumentException("Invalid URL: " + url); + } + this.userAgent = userAgent; } diff --git a/common/src/main/java/me/lucko/luckperms/common/plugin/AbstractLuckPermsPlugin.java b/common/src/main/java/me/lucko/luckperms/common/plugin/AbstractLuckPermsPlugin.java index db012ae86..57b264680 100644 --- a/common/src/main/java/me/lucko/luckperms/common/plugin/AbstractLuckPermsPlugin.java +++ b/common/src/main/java/me/lucko/luckperms/common/plugin/AbstractLuckPermsPlugin.java @@ -172,8 +172,7 @@ public abstract class AbstractLuckPermsPlugin implements LuckPermsPlugin { ); this.bytesocks = new BytesocksClient( this.httpClient, - getConfiguration().get(ConfigKeys.BYTESOCKS_HOST), - getConfiguration().get(ConfigKeys.BYTESOCKS_USE_TLS), + getConfiguration().get(ConfigKeys.BYTESOCKS_URL), "luckperms/editor" ); this.webEditorStore = new WebEditorStore(this); diff --git a/standalone/src/test/java/me/lucko/luckperms/standalone/WebEditorIntegrationTest.java b/standalone/src/test/java/me/lucko/luckperms/standalone/WebEditorIntegrationTest.java index 1d88138ff..ccddab8ae 100644 --- a/standalone/src/test/java/me/lucko/luckperms/standalone/WebEditorIntegrationTest.java +++ b/standalone/src/test/java/me/lucko/luckperms/standalone/WebEditorIntegrationTest.java @@ -86,12 +86,11 @@ public class WebEditorIntegrationTest { assertTrue(this.bytesocks.isRunning()); String bytebinUrl = "http://" + this.bytebin.getHost() + ":" + this.bytebin.getFirstMappedPort() + "/"; - String bytesocksHost = this.bytesocks.getHost() + ":" + this.bytesocks.getFirstMappedPort(); + String bytesocksUrl = "http://" + this.bytesocks.getHost() + ":" + this.bytesocks.getFirstMappedPort() + "/"; Map config = ImmutableMap.builder() .put("bytebin-url", bytebinUrl) - .put("bytesocks-host", bytesocksHost) - .put("bytesocks-use-tls", "false") + .put("bytesocks-url", bytesocksUrl) .build(); TestPluginProvider.use(tempDir, config, (app, bootstrap, plugin) -> { @@ -141,7 +140,7 @@ public class WebEditorIntegrationTest { httpClient.newWebSocket( new Request.Builder() - .url("ws://" + bytesocksHost + "/" + bytesocksKey) + .url(bytesocksUrl + bytesocksKey) .build(), new WebSocketListener() { @Override