[FEATURE] Use UUID for checkServer token

This commit is contained in:
Gravita 2021-10-17 16:53:33 +07:00
parent 7bcf5f10ab
commit e5b603e2a9
3 changed files with 7 additions and 8 deletions

View file

@ -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

View file

@ -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;
}
}

View file

@ -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;