diff --git a/build.gradle b/build.gradle index f5df3b5..8d909f5 100644 --- a/build.gradle +++ b/build.gradle @@ -3,7 +3,7 @@ plugins { } dependencies { - implementation("net.raphimc:ViaProxy:3.4.12") { + implementation("net.raphimc:ViaProxy:3.5.0-SNAPSHOT") { transitive = false } } diff --git a/src/main/java/net/raphimc/authhook/AuthHook.java b/src/main/java/net/raphimc/authhook/AuthHook.java index 3e23341..c8a4c03 100644 --- a/src/main/java/net/raphimc/authhook/AuthHook.java +++ b/src/main/java/net/raphimc/authhook/AuthHook.java @@ -54,11 +54,11 @@ public void onEnable() { @EventHandler private void onViaProxyLoaded(final ViaProxyLoadedEvent event) { - if (!ViaProxy.getConfig().isProxyOnlineMode()) { + if (!ViaProxy.getConfig().getFrontend().isOnlineMode()) { Logger.LOGGER.warn("Proxy online mode is disabled, please enable it to use the AuthHook plugin!"); Logger.LOGGER.warn("Without online mode the AuthHook plugin would be effectively useless and allow anyone to connect to your server without authentication."); Logger.LOGGER.info("Force enabling online mode"); - ViaProxy.getConfig().setProxyOnlineMode(true); + ViaProxy.getConfig().getFrontend().setOnlineMode(true); } final Map locales = RStream.of(I18n.class).fields().by("LOCALES").get(); @@ -67,7 +67,7 @@ private void onViaProxyLoaded(final ViaProxyLoadedEvent event) { @EventHandler private void onJoinServerRequest(final JoinServerRequestEvent event) { - if (ViaProxy.getConfig().getAuthMethod() == AUTH_HOOK) { + if (ViaProxy.getConfig().getBackend().getAuthMethod() == AUTH_HOOK) { this.httpServer.addPendingConnection(event.getServerIdHash(), event.getProxyConnection()); event.setCancelled(true); } diff --git a/src/main/java/net/raphimc/authhook/config/AuthHookConfig.java b/src/main/java/net/raphimc/authhook/config/AuthHookConfig.java index 8f59cbd..dc4df10 100644 --- a/src/main/java/net/raphimc/authhook/config/AuthHookConfig.java +++ b/src/main/java/net/raphimc/authhook/config/AuthHookConfig.java @@ -17,6 +17,10 @@ */ package net.raphimc.authhook.config; +import java.io.File; +import java.net.SocketAddress; +import java.util.UUID; + import net.lenni0451.optconfig.ConfigLoader; import net.lenni0451.optconfig.annotations.Description; import net.lenni0451.optconfig.annotations.NotReloadable; @@ -25,12 +29,9 @@ import net.lenni0451.optconfig.annotations.TypeSerializer; import net.lenni0451.optconfig.provider.ConfigProvider; import net.raphimc.viaproxy.util.AddressUtil; +import net.raphimc.viaproxy.util.config.SocketAddressTypeSerializer; import net.raphimc.viaproxy.util.logging.Logger; -import java.io.File; -import java.net.SocketAddress; -import java.util.UUID; - @OptConfig @SuppressWarnings("checkstyle:VisibilityModifier") public final class AuthHookConfig { diff --git a/src/main/java/net/raphimc/authhook/config/SocketAddressTypeSerializer.java b/src/main/java/net/raphimc/authhook/config/SocketAddressTypeSerializer.java deleted file mode 100644 index 3caba44..0000000 --- a/src/main/java/net/raphimc/authhook/config/SocketAddressTypeSerializer.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * This file is part of ViaProxyAuthHook - https://github.com/ViaVersionAddons/ViaProxyAuthHook - * Copyright (C) 2024-2026 RK_01/RaphiMC and contributors - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package net.raphimc.authhook.config; - -import net.lenni0451.optconfig.serializer.ConfigTypeSerializer; -import net.raphimc.viaproxy.util.AddressUtil; - -import java.net.SocketAddress; - -public class SocketAddressTypeSerializer extends ConfigTypeSerializer { - - public SocketAddressTypeSerializer(final AuthHookConfig config) { - super(config); - } - - @Override - public SocketAddress deserialize(final Class typeClass, final Object serializedObject) { - return AddressUtil.parse((String) serializedObject, null); - } - - @Override - public Object serialize(final SocketAddress object) { - return AddressUtil.toString(object); - } - -} diff --git a/src/main/java/net/raphimc/authhook/httpserver/HttpServer.java b/src/main/java/net/raphimc/authhook/httpserver/HttpServer.java index bba5944..a49edfd 100644 --- a/src/main/java/net/raphimc/authhook/httpserver/HttpServer.java +++ b/src/main/java/net/raphimc/authhook/httpserver/HttpServer.java @@ -53,7 +53,7 @@ public HttpServer(final InetSocketAddress bindAddress) { } public void addPendingConnection(final String serverIdHash, final ProxyConnection connection) { - this.pendingConnections.put(serverIdHash + "_" + connection.getGameProfile().getName(), connection); + this.pendingConnections.put(serverIdHash + "_" + connection.getGameProfile().name(), connection); } public void stop() { diff --git a/src/main/java/net/raphimc/authhook/httpserver/handler/SessionServiceHandler.java b/src/main/java/net/raphimc/authhook/httpserver/handler/SessionServiceHandler.java index 221e49d..c548657 100644 --- a/src/main/java/net/raphimc/authhook/httpserver/handler/SessionServiceHandler.java +++ b/src/main/java/net/raphimc/authhook/httpserver/handler/SessionServiceHandler.java @@ -56,11 +56,11 @@ public Either handleRequest(final String host, final Http if (proxyConnection != null) { final GameProfile gameProfile = proxyConnection.getGameProfile(); final JsonObject responseObj = new JsonObject(); - responseObj.addProperty("name", gameProfile.getName()); - responseObj.addProperty("id", gameProfile.getId().toString().replace("-", "")); - if (!gameProfile.getProperties().isEmpty()) { + responseObj.addProperty("name", gameProfile.name()); + responseObj.addProperty("id", gameProfile.id().toString().replace("-", "")); + if (!gameProfile.properties().isEmpty()) { final JsonArray propertiesArray = new JsonArray(); - gameProfile.getProperties().forEach((key, value) -> { + gameProfile.properties().forEach((key, value) -> { final JsonObject propertyObj = new JsonObject(); propertyObj.addProperty("name", key); propertyObj.addProperty("value", value.value());