From e5b603e2a91e1a6cd5e3b86c2ca58a5e03bf9d4b Mon Sep 17 00:00:00 2001 From: Gravita Date: Sun, 17 Oct 2021 16:53:33 +0700 Subject: [PATCH] [FEATURE] Use UUID for checkServer token --- .../gravit/launchserver/command/service/TokenCommand.java | 6 +++--- .../pro/gravit/launchserver/manangers/AuthManager.java | 2 +- .../java/pro/gravit/launcher/server/ServerWrapper.java | 7 +++---- 3 files changed, 7 insertions(+), 8 deletions(-) diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/TokenCommand.java b/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/TokenCommand.java index 646fe1ce..178c2088 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/TokenCommand.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/command/service/TokenCommand.java @@ -28,7 +28,7 @@ public void invoke(String... args) throws Exception { AuthProviderPair pair = args.length > 1 ? server.config.getAuthProviderPair(args[1]) : server.config.getAuthProviderPair(); ClientProfile profile = null; for(ClientProfile p : server.getProfiles()) { - if(p.getTitle().equals(args[0])) { + if(p.getTitle().equals(args[0]) || p.getUUID().toString().equals(args[0])) { profile = p; break; } @@ -40,7 +40,7 @@ public void invoke(String... args) throws Exception { logger.error("AuthId {} not found", args[1]); return; } - String token = server.authManager.newCheckServerToken(args[0], pair.name); + String token = server.authManager.newCheckServerToken(profile != null ? profile.getUUID().toString() : args[0], pair.name); logger.info("Server token {} authId {}: {}", args[0], pair.name, token); } }); @@ -48,7 +48,7 @@ public void invoke(String... args) throws Exception { @Override public String getArgsDescription() { - return "[new/info/token name] [args]"; + return "[server/info/token name] [args]"; } @Override diff --git a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/AuthManager.java b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/AuthManager.java index 7d3a3960..ce23b57d 100644 --- a/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/AuthManager.java +++ b/LaunchServer/src/main/java/pro/gravit/launchserver/manangers/AuthManager.java @@ -86,7 +86,7 @@ public boolean accept(Client client, AuthProviderPair pair, String extendedToken client.auth = server.config.getAuthProviderPair(info.authId); if(client.permissions == null) client.permissions = new ClientPermissions(); client.permissions.addPerm("launchserver.checkserver"); - client.permissions.addPerm(String.format("launchserver.profiles.%s.show", info.serverName)); + client.permissions.addPerm(String.format("launchserver.profile.%s.show", info.serverName)); return true; } } diff --git a/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java b/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java index b775aa40..22e1f27b 100644 --- a/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java +++ b/ServerWrapper/src/main/java/pro/gravit/launcher/server/ServerWrapper.java @@ -163,7 +163,7 @@ public void run(String... args) throws Throwable { LogHelper.error(e); } }; - LogHelper.info("ServerWrapper: Project %s, LaunchServer address: %s. Title: %s", config.projectname, config.address, Launcher.profile != null ? Launcher.profile.getTitle() : "unknown"); + LogHelper.info("ServerWrapper: LaunchServer address: %s. Title: %s", config.address, Launcher.profile != null ? Launcher.profile.getTitle() : "unknown"); LogHelper.info("Minecraft Version (for profile): %s", wrapper.profile == null ? "unknown" : wrapper.profile.getVersion().name); LogHelper.info("Start Minecraft Server"); LogHelper.debug("Invoke main method %s", mainClass.getName()); @@ -181,8 +181,7 @@ public void run(String... args) throws Throwable { } public void updateLauncherConfig() { - - LauncherConfig cfg = new LauncherConfig(config.address, null, null, new HashMap<>(), config.projectname); + LauncherConfig cfg = new LauncherConfig(config.address, null, null, new HashMap<>(), "ServerWrapper"); Launcher.setConfig(cfg); } @@ -200,7 +199,6 @@ public void setConfig(Config config) { public Config getDefaultConfig() { Config newConfig = new Config(); newConfig.serverName = "your server name"; - newConfig.projectname = "MineCraft"; newConfig.mainclass = ""; newConfig.extendedTokens = new HashMap<>(); newConfig.args = new ArrayList<>(); @@ -211,6 +209,7 @@ public Config getDefaultConfig() { } public static final class Config { + @Deprecated public String projectname; public String address; public String serverName;