mirror of
https://github.com/GravitLauncher/Launcher
synced 2025-01-09 09:09:46 +03:00
[FEATURE] Reloadable теперь устаревший. Удален ReloadManager
This commit is contained in:
parent
9fb3d44d6a
commit
36350cb661
10 changed files with 8 additions and 144 deletions
|
@ -76,7 +76,6 @@
|
|||
import pro.gravit.launchserver.manangers.MirrorManager;
|
||||
import pro.gravit.launchserver.manangers.ModulesManager;
|
||||
import pro.gravit.launchserver.manangers.ReconfigurableManager;
|
||||
import pro.gravit.launchserver.manangers.ReloadManager;
|
||||
import pro.gravit.launchserver.manangers.SessionManager;
|
||||
import pro.gravit.launchserver.manangers.hook.AuthHookManager;
|
||||
import pro.gravit.launchserver.manangers.hook.BuildHookManager;
|
||||
|
@ -92,8 +91,8 @@
|
|||
import pro.gravit.utils.helper.LogHelper;
|
||||
import pro.gravit.utils.helper.SecurityHelper;
|
||||
|
||||
public final class LaunchServer implements Runnable, AutoCloseable, Reloadable {
|
||||
@Override
|
||||
public final class LaunchServer implements Runnable, AutoCloseable {
|
||||
|
||||
public void reload() throws Exception {
|
||||
config.close();
|
||||
LogHelper.info("Reading LaunchServer config file");
|
||||
|
@ -439,8 +438,6 @@ public static void main(String... args) throws Throwable {
|
|||
|
||||
public final MirrorManager mirrorManager;
|
||||
|
||||
public final ReloadManager reloadManager;
|
||||
|
||||
public final ReconfigurableManager reconfigurableManager;
|
||||
|
||||
public final ConfigManager configManager;
|
||||
|
@ -608,7 +605,6 @@ public LaunchServer(Path dir, boolean testEnv, String[] args) throws IOException
|
|||
proguardConf = new ProguardConf(this);
|
||||
sessionManager = new SessionManager();
|
||||
mirrorManager = new MirrorManager();
|
||||
reloadManager = new ReloadManager();
|
||||
reconfigurableManager = new ReconfigurableManager();
|
||||
authHookManager = new AuthHookManager();
|
||||
configManager = new ConfigManager();
|
||||
|
@ -651,7 +647,6 @@ public LaunchServer(Path dir, boolean testEnv, String[] args) throws IOException
|
|||
}
|
||||
}
|
||||
GarbageManager.registerNeedGC(sessionManager);
|
||||
reloadManager.registerReloadable("launchServer", this);
|
||||
registerObject("permissionsHandler", config.permissionsHandler);
|
||||
for (int i = 0; i < config.auth.length; ++i) {
|
||||
AuthProviderPair pair = config.auth[i];
|
||||
|
@ -987,9 +982,6 @@ public void restart() {
|
|||
}
|
||||
|
||||
public void registerObject(String name, Object object) {
|
||||
if (object instanceof Reloadable) {
|
||||
reloadManager.registerReloadable(name, (Reloadable) object);
|
||||
}
|
||||
if (object instanceof Reconfigurable) {
|
||||
reconfigurableManager.registerReconfigurable(name, (Reconfigurable) object);
|
||||
}
|
||||
|
@ -999,9 +991,6 @@ public void registerObject(String name, Object object) {
|
|||
}
|
||||
|
||||
public void unregisterObject(String name, Object object) {
|
||||
if (object instanceof Reloadable) {
|
||||
reloadManager.unregisterReloadable(name);
|
||||
}
|
||||
if (object instanceof Reconfigurable) {
|
||||
reconfigurableManager.unregisterReconfigurable(name);
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
package pro.gravit.launchserver;
|
||||
|
||||
@FunctionalInterface
|
||||
@Deprecated
|
||||
public interface Reloadable {
|
||||
void reload() throws Exception;
|
||||
}
|
||||
|
|
|
@ -14,15 +14,14 @@
|
|||
import pro.gravit.launcher.ClientPermissions;
|
||||
import pro.gravit.launcher.Launcher;
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.Reloadable;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
public class JsonFilePermissionsHandler extends PermissionsHandler implements Reloadable {
|
||||
public class JsonFilePermissionsHandler extends PermissionsHandler {
|
||||
public String filename = "permissions.json";
|
||||
public static Map<String, ClientPermissions> map;
|
||||
|
||||
@Override
|
||||
|
||||
public void reload() {
|
||||
map.clear();
|
||||
Path path = Paths.get(filename);
|
||||
|
|
|
@ -14,16 +14,15 @@
|
|||
import pro.gravit.launcher.ClientPermissions;
|
||||
import pro.gravit.launcher.Launcher;
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.Reloadable;
|
||||
import pro.gravit.utils.helper.IOHelper;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
public class JsonLongFilePermissionsHandler extends PermissionsHandler implements Reloadable {
|
||||
public class JsonLongFilePermissionsHandler extends PermissionsHandler {
|
||||
public String filename = "permissions.json";
|
||||
public long defaultPerms = 0L;
|
||||
public static Map<String, Long> map;
|
||||
|
||||
@Override
|
||||
|
||||
public void reload() {
|
||||
map.clear();
|
||||
Path path = Paths.get(filename);
|
||||
|
|
|
@ -101,9 +101,6 @@ public static void registerCommands(pro.gravit.utils.command.CommandHandler hand
|
|||
|
||||
//Register service commands
|
||||
BaseCommandCategory service = new BaseCommandCategory();
|
||||
service.registerCommand("reload", new ReloadCommand(server));
|
||||
service.registerCommand("reloadAll", new ReloadAllCommand(server));
|
||||
service.registerCommand("reloadList", new ReloadListCommand(server));
|
||||
service.registerCommand("config", new ConfigCommand(server));
|
||||
service.registerCommand("serverStatus", new ServerStatusCommand(server));
|
||||
service.registerCommand("checkInstall", new CheckInstallCommand(server));
|
||||
|
|
|
@ -1,27 +0,0 @@
|
|||
package pro.gravit.launchserver.command.service;
|
||||
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.command.Command;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
public class ReloadAllCommand extends Command {
|
||||
public ReloadAllCommand(LaunchServer server) {
|
||||
super(server);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getArgsDescription() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsageDescription() {
|
||||
return "Reload all provider/handler/module config";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(String... args) throws Exception {
|
||||
LogHelper.info("Reload all config");
|
||||
server.reloadManager.reloadAll();
|
||||
}
|
||||
}
|
|
@ -1,28 +0,0 @@
|
|||
package pro.gravit.launchserver.command.service;
|
||||
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.command.Command;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
|
||||
public class ReloadCommand extends Command {
|
||||
public ReloadCommand(LaunchServer server) {
|
||||
super(server);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getArgsDescription() {
|
||||
return "[name]";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsageDescription() {
|
||||
return "Reload provider/handler/module config";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(String... args) throws Exception {
|
||||
verifyArgs(args, 1);
|
||||
LogHelper.info("Reload %s config", args[0]);
|
||||
server.reloadManager.reload(args[0]);
|
||||
}
|
||||
}
|
|
@ -1,25 +0,0 @@
|
|||
package pro.gravit.launchserver.command.service;
|
||||
|
||||
import pro.gravit.launchserver.LaunchServer;
|
||||
import pro.gravit.launchserver.command.Command;
|
||||
|
||||
public class ReloadListCommand extends Command {
|
||||
public ReloadListCommand(LaunchServer server) {
|
||||
super(server);
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getArgsDescription() {
|
||||
return "";
|
||||
}
|
||||
|
||||
@Override
|
||||
public String getUsageDescription() {
|
||||
return "print reloadable configs";
|
||||
}
|
||||
|
||||
@Override
|
||||
public void invoke(String... args) {
|
||||
server.reloadManager.printReloadables();
|
||||
}
|
||||
}
|
|
@ -1,41 +0,0 @@
|
|||
package pro.gravit.launchserver.manangers;
|
||||
|
||||
import java.util.HashMap;
|
||||
import java.util.Objects;
|
||||
|
||||
import pro.gravit.launchserver.Reloadable;
|
||||
import pro.gravit.utils.helper.LogHelper;
|
||||
import pro.gravit.utils.helper.VerifyHelper;
|
||||
|
||||
public class ReloadManager {
|
||||
private final HashMap<String, Reloadable> RELOADABLES = new HashMap<>();
|
||||
|
||||
public void registerReloadable(String name, Reloadable reloadable) {
|
||||
VerifyHelper.putIfAbsent(RELOADABLES, name.toLowerCase(), Objects.requireNonNull(reloadable, "adapter"),
|
||||
String.format("Reloadable has been already registered: '%s'", name.toLowerCase()));
|
||||
}
|
||||
|
||||
public Reloadable unregisterReloadable(String name) {
|
||||
return RELOADABLES.remove(name);
|
||||
}
|
||||
|
||||
public void reloadAll() {
|
||||
RELOADABLES.forEach((k, v) -> {
|
||||
try {
|
||||
v.reload();
|
||||
} catch (Exception e) {
|
||||
LogHelper.error(e);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
public void reload(String name) throws Exception {
|
||||
RELOADABLES.get(name.toLowerCase()).reload();
|
||||
}
|
||||
|
||||
public void printReloadables() {
|
||||
LogHelper.info("Print reloadables");
|
||||
RELOADABLES.forEach((k, v) -> LogHelper.subInfo(k));
|
||||
LogHelper.info("Found %d reloadables", RELOADABLES.size());
|
||||
}
|
||||
}
|
2
modules
2
modules
|
@ -1 +1 @@
|
|||
Subproject commit bb42a813e6f389366fd0e16b178abb954f7efbb1
|
||||
Subproject commit 4b7ffbbdda9f6d0e1a5f68f9568e574b8ba551a7
|
Loading…
Reference in a new issue