From 11b6426c7987acc7106997fd4b382b6bd8e66e6a Mon Sep 17 00:00:00 2001 From: RaphiMC <50594595+RaphiMC@users.noreply.github.com> Date: Tue, 5 Nov 2024 20:34:52 +0100 Subject: [PATCH] Updated Via* --- build.gradle | 4 ++-- .../viaproxy/saves/impl/AccountsSaveV3.java | 17 +++++------------ 2 files changed, 7 insertions(+), 14 deletions(-) diff --git a/build.gradle b/build.gradle index 1e32a66..40252a4 100644 --- a/build.gradle +++ b/build.gradle @@ -61,8 +61,8 @@ repositories { } dependencies { - include "com.viaversion:viaversion-common:5.1.1" - include "com.viaversion:viabackwards-common:5.1.1" + include "com.viaversion:viaversion-common:5.1.2-SNAPSHOT" + include "com.viaversion:viabackwards-common:5.1.2-SNAPSHOT" include "com.viaversion:viarewind-common:4.0.3" include "net.raphimc:ViaLegacy:3.0.5" include "net.raphimc:viaaprilfools-common:3.0.4" diff --git a/src/main/java/net/raphimc/viaproxy/saves/impl/AccountsSaveV3.java b/src/main/java/net/raphimc/viaproxy/saves/impl/AccountsSaveV3.java index 86d87ff..26c5db1 100644 --- a/src/main/java/net/raphimc/viaproxy/saves/impl/AccountsSaveV3.java +++ b/src/main/java/net/raphimc/viaproxy/saves/impl/AccountsSaveV3.java @@ -41,22 +41,15 @@ public class AccountsSaveV3 extends AbstractSave { @Override public void load(JsonElement jsonElement) throws Exception { + final List classLoaders = new ArrayList<>(); + classLoaders.add(ViaProxy.class.getClassLoader()); + classLoaders.addAll(ViaProxy.getPluginManager().getPlugins().stream().map(ViaProxyPlugin::getClassLoader).toList()); + this.accounts = new ArrayList<>(); for (JsonElement element : jsonElement.getAsJsonArray()) { final JsonObject jsonObject = element.getAsJsonObject(); final String type = jsonObject.get("accountType").getAsString(); - Class clazz = Classes.byName(type); - if (clazz == null) { - for (ViaProxyPlugin plugin : ViaProxy.getPluginManager().getPlugins()) { - clazz = Classes.byName(type, plugin.getClass().getClassLoader()); - if (clazz != null) { - break; - } - } - } - if (clazz == null) { - throw new ClassNotFoundException(type); - } + final Class clazz = Classes.find(type, true, classLoaders); final Account account = (Account) clazz.getConstructor(JsonObject.class).newInstance(jsonObject); this.accounts.add(account);