mirror of
https://github.com/ViaVersion/ViaProxy.git
synced 2024-11-24 12:16:40 +01:00
Search through plugin classloaders when loading accounts
This commit is contained in:
parent
197f9dd256
commit
83ab4b8079
@ -20,7 +20,9 @@ package net.raphimc.viaproxy.saves.impl;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonElement;
|
||||
import com.google.gson.JsonObject;
|
||||
import net.lenni0451.reflect.Classes;
|
||||
import net.raphimc.viaproxy.ViaProxy;
|
||||
import net.raphimc.viaproxy.plugins.ViaProxyPlugin;
|
||||
import net.raphimc.viaproxy.saves.AbstractSave;
|
||||
import net.raphimc.viaproxy.saves.impl.accounts.Account;
|
||||
import net.raphimc.viaproxy.saves.impl.accounts.OfflineAccount;
|
||||
@ -43,7 +45,19 @@ public class AccountsSaveV3 extends AbstractSave {
|
||||
for (JsonElement element : jsonElement.getAsJsonArray()) {
|
||||
final JsonObject jsonObject = element.getAsJsonObject();
|
||||
final String type = jsonObject.get("accountType").getAsString();
|
||||
final Class<?> clazz = Class.forName(type);
|
||||
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 Account account = (Account) clazz.getConstructor(JsonObject.class).newInstance(jsonObject);
|
||||
this.accounts.add(account);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user