mirror of
https://github.com/GravitLauncher/Launcher
synced 2024-11-15 03:31:15 +03:00
JsonFilePermissionsHandler теперь Reloadable
This commit is contained in:
parent
e341f144b9
commit
172eb97ce6
2 changed files with 29 additions and 1 deletions
|
@ -364,6 +364,19 @@ public LaunchServer(Path dir) throws IOException, InvalidKeySpecException {
|
|||
reloadManager = new ReloadManager();
|
||||
GarbageManager.registerNeedGC(sessionManager);
|
||||
GarbageManager.registerNeedGC(limiter);
|
||||
if(config.permissionsHandler instanceof Reloadable)
|
||||
reloadManager.registerReloadable("permissionsHandler",(Reloadable) config.permissionsHandler);
|
||||
if(config.authHandler instanceof Reloadable)
|
||||
reloadManager.registerReloadable("authHandler",(Reloadable) config.authHandler);
|
||||
for(int i=0;i<config.authProvider.length;++i)
|
||||
{
|
||||
AuthProvider provider = config.authProvider[i];
|
||||
if(provider instanceof Reloadable)
|
||||
reloadManager.registerReloadable("authHandler".concat(String.valueOf(i)),(Reloadable) provider);
|
||||
}
|
||||
if(config.textureProvider instanceof Reloadable)
|
||||
reloadManager.registerReloadable("textureProvider",(Reloadable) config.textureProvider);
|
||||
|
||||
Arrays.stream(config.mirrors).forEach(s -> {
|
||||
try {
|
||||
mirrorManager.addMirror(s);
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
|
||||
import com.google.gson.reflect.TypeToken;
|
||||
import ru.gravit.launcher.Launcher;
|
||||
import ru.gravit.launchserver.Reloadable;
|
||||
import ru.gravit.launchserver.auth.ClientPermissions;
|
||||
import ru.gravit.launchserver.manangers.PermissionsManager;
|
||||
import ru.gravit.utils.helper.IOHelper;
|
||||
|
@ -16,9 +17,23 @@
|
|||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
public class JsonFilePermissionsHandler extends PermissionsHandler {
|
||||
public class JsonFilePermissionsHandler extends PermissionsHandler implements Reloadable {
|
||||
public String filename = "permissions.json";
|
||||
public static Map<String,ClientPermissions> map;
|
||||
|
||||
@Override
|
||||
public void reload() throws Exception {
|
||||
map.clear();
|
||||
Path path = Paths.get(filename);
|
||||
Type type = new TypeToken<Map<String,ClientPermissions>>(){}.getType();
|
||||
try(Reader reader = IOHelper.newReader(path))
|
||||
{
|
||||
map = Launcher.gson.fromJson(reader,type);
|
||||
} catch (IOException e) {
|
||||
LogHelper.error(e);
|
||||
}
|
||||
}
|
||||
|
||||
public static class Enity
|
||||
{
|
||||
public String username;
|
||||
|
|
Loading…
Reference in a new issue