[FIX] Более быстрое получение провайдера по названий... (коллекция в которой он хранится lasy fill)

This commit is contained in:
Zaxar163 2020-02-10 19:18:22 +01:00
parent b57ad71539
commit adefda970e
No known key found for this signature in database
GPG key ID: 1FE4F2E1F053831B

View file

@ -52,12 +52,15 @@ public LaunchServerConfig setLaunchServer(LaunchServer server) {
public DaoProvider dao; public DaoProvider dao;
private transient AuthProviderPair authDefault; private transient AuthProviderPair authDefault;
private transient Map<String, AuthProviderPair> authPairs = null;
public AuthProviderPair getAuthProviderPair(String name) { public AuthProviderPair getAuthProviderPair(String name) {
for (AuthProviderPair pair : auth) { if (authPairs == null) {
if (pair.name.equals(name)) return pair; Map<String, AuthProviderPair> pairs = new HashMap<>();
for (AuthProviderPair p : auth) pairs.put(p.name, p);
authPairs = pairs;
} }
return null; return authPairs.get(name);
} }
public ProtectHandler protectHandler; public ProtectHandler protectHandler;
@ -125,6 +128,7 @@ public void verify() {
public void init(LaunchServer.ReloadType type) { public void init(LaunchServer.ReloadType type) {
Launcher.applyLauncherEnv(env); Launcher.applyLauncherEnv(env);
authPairs = null;
for (AuthProviderPair provider : auth) { for (AuthProviderPair provider : auth) {
provider.init(server); provider.init(server);
} }
@ -144,8 +148,6 @@ public void init(LaunchServer.ReloadType type) {
server.registerObject("auth.".concat(pair.name).concat(".hwid"), pair.hwid); server.registerObject("auth.".concat(pair.name).concat(".hwid"), pair.hwid);
} }
} }
Arrays.stream(mirrors).forEach(server.mirrorManager::addMirror); Arrays.stream(mirrors).forEach(server.mirrorManager::addMirror);
} }