Compare commits

..

1 commit

Author SHA1 Message Date
Metall
24f6b34e5a
Merge 05530b6664 into 911ca1e69f 2025-05-06 04:45:59 +00:00
12 changed files with 54 additions and 117 deletions

View file

@ -35,7 +35,6 @@ jobs:
run: | run: |
mkdir -p artifacts/modules mkdir -p artifacts/modules
cd LaunchServer/build/libs cd LaunchServer/build/libs
mv proguard proguard-libraries
zip -r -9 ../../../artifacts/libraries.zip * -x "LaunchServer.jar" -x "LaunchServer-clean.jar" zip -r -9 ../../../artifacts/libraries.zip * -x "LaunchServer.jar" -x "LaunchServer-clean.jar"
cp LaunchServer.jar ../../../artifacts/LaunchServer.jar cp LaunchServer.jar ../../../artifacts/LaunchServer.jar
cd ../../.. cd ../../..

View file

@ -338,32 +338,6 @@ public void invoke(String... args) throws Exception {
} }
} }
}); });
map.put("newSession", new SubCommand("[username/uuid] [isShadow] (CLIENT/API)", "create access/refresh token without password") {
@Override
public void invoke(String... args) throws Exception {
verifyArgs(args, 2);
String login = args[0];
boolean isShadow = Boolean.parseBoolean(args[1]);
User user;
if(login.length() == 36) {
UUID uuid = UUID.fromString(login);
user = getUserByUUID(uuid);
} else {
user = getUserByUsername(login);
}
if(user == null) {
logger.error("User {} not found", login);
return;
}
var report = instance.sudo(user, isShadow);
User user1 = report.session().getUser();
logger.info("Created session {} for user {} ({})", report.session().getID(), user1.getUsername(), user.getUUID());
logger.info("- AccessToken: {}", report.oauthAccessToken());
logger.info("- RefreshToken: {}", report.oauthRefreshToken());
logger.info("- ExpireIn: {}", report.oauthExpire());
logger.info("- MinecraftAccessToken: {}", report.minecraftAccessToken());
}
});
} }
} }
return map; return map;

View file

@ -21,9 +21,6 @@ public static void registerHandlers() {
public abstract boolean allowGetAccessToken(AuthResponse.AuthContext context); public abstract boolean allowGetAccessToken(AuthResponse.AuthContext context);
public boolean allowJoinServer(Client client) { public boolean allowJoinServer(Client client) {
if(client.permissions != null && client.permissions.hasPerm("launchserver.debug.joinserver")) {
return client.isAuth;
}
return client.isAuth && client.type == AuthResponse.ConnectTypes.CLIENT; return client.isAuth && client.type == AuthResponse.ConnectTypes.CLIENT;
} }

View file

@ -29,14 +29,19 @@
import java.util.UUID; import java.util.UUID;
public class ClientRuntimeProvider implements RuntimeProvider { public class ClientRuntimeProvider implements RuntimeProvider {
@Override @Override
public void run(String[] args) { public void run(String[] args) {
ArrayList<String> newArgs = new ArrayList<>(Arrays.asList(args)); ArrayList<String> newArgs = new ArrayList<>(Arrays.asList(args));
try { try {
String username = DebugProperties.USERNAME; String username = System.getProperty("launcher.runtime.username", null);
String uuid = DebugProperties.UUID; String uuid = System.getProperty("launcher.runtime.uuid", null);
String minecraftAccessToken = DebugProperties.MINECRAFT_ACCESS_TOKEN; String login = System.getProperty("launcher.runtime.login", username);
String password = System.getProperty("launcher.runtime.password", "Player");
String authId = System.getProperty("launcher.runtime.auth.authid", "std");
String accessToken = System.getProperty("launcher.runtime.auth.accesstoken", null);
String refreshToken = System.getProperty("launcher.runtime.auth.refreshtoken", null);
String minecraftAccessToken = System.getProperty("launcher.runtime.auth.minecraftaccesstoken", "DEBUG");
long expire = Long.parseLong(System.getProperty("launcher.runtime.auth.expire", "0"));
String profileUUID = System.getProperty("launcher.runtime.profileuuid", null); String profileUUID = System.getProperty("launcher.runtime.profileuuid", null);
String mainClass = System.getProperty("launcher.runtime.mainclass", null); String mainClass = System.getProperty("launcher.runtime.mainclass", null);
String mainModule = System.getProperty("launcher.runtime.mainmodule", null); String mainModule = System.getProperty("launcher.runtime.mainmodule", null);
@ -50,14 +55,28 @@ public void run(String[] args) {
throw new NullPointerException("Add `-Dlauncher.runtime.mainclass=YOUR_MAIN_CLASS` to jvmArgs"); throw new NullPointerException("Add `-Dlauncher.runtime.mainclass=YOUR_MAIN_CLASS` to jvmArgs");
} }
if(uuid == null) { if(uuid == null) {
var data = DebugMain.authorize(); if(accessToken != null) {
minecraftAccessToken = data.userInfo().accessToken; Request.setOAuth(authId, new AuthRequestEvent.OAuthRequestEvent(accessToken, refreshToken, expire));
permissions = data.userInfo().permissions; Request.RequestRestoreReport report = Request.restore(true, false, true);
username = data.userInfo().playerProfile.username; permissions = report.userInfo.permissions;
uuid = data.userInfo().playerProfile.uuid.toString(); username = report.userInfo.playerProfile.username;
uuid = report.userInfo.playerProfile.uuid.toString();
if(report.userInfo.accessToken != null) {
minecraftAccessToken = report.userInfo.accessToken;
}
} else {
AuthRequest request = new AuthRequest(login, password, authId, AuthRequest.ConnectTypes.API);
AuthRequestEvent event = request.request();
Request.setOAuth(authId, event.oauth);
if(event.accessToken != null) {
minecraftAccessToken = event.accessToken;
}
username = event.playerProfile.username;
uuid = event.playerProfile.uuid.toString();
}
} }
if(profileUUID != null) { if(profileUUID != null) {
UUID profileUuid = java.util.UUID.fromString(profileUUID); UUID profileUuid = UUID.fromString(profileUUID);
ProfilesRequest profiles = new ProfilesRequest(); ProfilesRequest profiles = new ProfilesRequest();
ProfilesRequestEvent event = profiles.request(); ProfilesRequestEvent event = profiles.request();
for(ClientProfile profile : event.profiles) { for(ClientProfile profile : event.profiles) {
@ -75,7 +94,7 @@ public void run(String[] args) {
replaceOrCreateArgument(newArgs, "--username", username); replaceOrCreateArgument(newArgs, "--username", username);
replaceOrCreateArgument(newArgs, "--uuid", uuid); replaceOrCreateArgument(newArgs, "--uuid", uuid);
replaceOrCreateArgument(newArgs, "--accessToken", minecraftAccessToken); replaceOrCreateArgument(newArgs, "--accessToken", minecraftAccessToken);
AuthService.uuid = java.util.UUID.fromString(uuid); AuthService.uuid = UUID.fromString(uuid);
AuthService.username = username; AuthService.username = username;
AuthService.permissions = permissions; AuthService.permissions = permissions;
Launch launch; Launch launch;

View file

@ -1,12 +1,7 @@
package pro.gravit.launcher.runtime.debug; package pro.gravit.launcher.runtime.debug;
import pro.gravit.launcher.base.ClientPermissions;
import pro.gravit.launcher.base.Launcher; import pro.gravit.launcher.base.Launcher;
import pro.gravit.launcher.base.LauncherConfig; import pro.gravit.launcher.base.LauncherConfig;
import pro.gravit.launcher.base.events.request.AuthRequestEvent;
import pro.gravit.launcher.base.events.request.CurrentUserRequestEvent;
import pro.gravit.launcher.base.profiles.PlayerProfile;
import pro.gravit.launcher.base.request.auth.AuthRequest;
import pro.gravit.launcher.client.ClientLauncherMethods; import pro.gravit.launcher.client.ClientLauncherMethods;
import pro.gravit.launcher.runtime.LauncherEngine; import pro.gravit.launcher.runtime.LauncherEngine;
import pro.gravit.launcher.client.RuntimeLauncherCoreModule; import pro.gravit.launcher.client.RuntimeLauncherCoreModule;
@ -26,11 +21,19 @@
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.nio.file.Paths; import java.nio.file.Paths;
import java.util.HashMap; import java.util.HashMap;
import java.util.UUID;
import java.util.concurrent.atomic.AtomicBoolean; import java.util.concurrent.atomic.AtomicBoolean;
public class DebugMain { public class DebugMain {
public static final AtomicBoolean IS_DEBUG = new AtomicBoolean(false); public static final AtomicBoolean IS_DEBUG = new AtomicBoolean(false);
public static String webSocketURL = System.getProperty("launcherdebug.websocket", "ws://localhost:9274/api");
public static String projectName = System.getProperty("launcherdebug.projectname", "Minecraft");
public static String unlockSecret = System.getProperty("launcherdebug.unlocksecret", "");
public static boolean disableConsole = Boolean.getBoolean("launcherdebug.disableConsole");
public static boolean offlineMode = Boolean.getBoolean("launcherdebug.offlinemode");
public static boolean disableAutoRefresh = Boolean.getBoolean("launcherdebug.disableautorefresh");
public static String[] moduleClasses = System.getProperty("launcherdebug.modules", "").split(",");
public static String[] moduleFiles = System.getProperty("launcherdebug.modulefiles", "").split(",");
public static LauncherConfig.LauncherEnvironment environment = LauncherConfig.LauncherEnvironment.valueOf(System.getProperty("launcherdebug.env", "STD"));
public static void main(String[] args) throws Throwable { public static void main(String[] args) throws Throwable {
LogHelper.printVersion("Launcher"); LogHelper.printVersion("Launcher");
@ -46,63 +49,42 @@ public static void initialize() throws Exception {
IS_DEBUG.set(true); IS_DEBUG.set(true);
LogHelper.info("Launcher start in DEBUG mode (Only for developers)"); LogHelper.info("Launcher start in DEBUG mode (Only for developers)");
LogHelper.debug("Initialization LauncherConfig"); LogHelper.debug("Initialization LauncherConfig");
LauncherConfig config = new LauncherConfig(DebugProperties.WEBSOCKET_URL, new HashMap<>(), DebugProperties.PROJECT_NAME, DebugProperties.ENV, new DebugLauncherTrustManager(DebugLauncherTrustManager.TrustDebugMode.TRUST_ALL)); LauncherConfig config = new LauncherConfig(webSocketURL, new HashMap<>(), projectName, environment, new DebugLauncherTrustManager(DebugLauncherTrustManager.TrustDebugMode.TRUST_ALL));
config.unlockSecret = DebugProperties.UNLOCK_SECRET; config.unlockSecret = unlockSecret;
Launcher.setConfig(config); Launcher.setConfig(config);
Launcher.applyLauncherEnv(DebugProperties.ENV); Launcher.applyLauncherEnv(environment);
LauncherEngine.modulesManager = new RuntimeModuleManager(); LauncherEngine.modulesManager = new RuntimeModuleManager();
LauncherEngine.modulesManager.loadModule(new RuntimeLauncherCoreModule()); LauncherEngine.modulesManager.loadModule(new RuntimeLauncherCoreModule());
for (String moduleClassName : DebugProperties.MODULE_CLASSES) { for (String moduleClassName : moduleClasses) {
if (moduleClassName.isEmpty()) continue; if (moduleClassName.isEmpty()) continue;
LauncherEngine.modulesManager.loadModule(newModule(moduleClassName)); LauncherEngine.modulesManager.loadModule(newModule(moduleClassName));
} }
for (String moduleFileName : DebugProperties.MODULE_FILES) { for (String moduleFileName : moduleFiles) {
if (moduleFileName.isEmpty()) continue; if (moduleFileName.isEmpty()) continue;
LauncherEngine.modulesManager.loadModule(Paths.get(moduleFileName)); LauncherEngine.modulesManager.loadModule(Paths.get(moduleFileName));
} }
LauncherEngine.modulesManager.initModules(null); LauncherEngine.modulesManager.initModules(null);
LauncherEngine.initGson(LauncherEngine.modulesManager); LauncherEngine.initGson(LauncherEngine.modulesManager);
if(!DebugProperties.DISABLE_CONSOLE) { if(!disableConsole) {
ConsoleManager.initConsole(); ConsoleManager.initConsole();
} }
LauncherEngine.modulesManager.invokeEvent(new PreConfigPhase()); LauncherEngine.modulesManager.invokeEvent(new PreConfigPhase());
RequestService service; RequestService service;
if (DebugProperties.OFFLINE_MODE) { if (offlineMode) {
OfflineRequestService offlineRequestService = new OfflineRequestService(); OfflineRequestService offlineRequestService = new OfflineRequestService();
ClientLauncherMethods.applyBasicOfflineProcessors(offlineRequestService); ClientLauncherMethods.applyBasicOfflineProcessors(offlineRequestService);
OfflineModeEvent event = new OfflineModeEvent(offlineRequestService); OfflineModeEvent event = new OfflineModeEvent(offlineRequestService);
LauncherEngine.modulesManager.invokeEvent(event); LauncherEngine.modulesManager.invokeEvent(event);
service = event.service; service = event.service;
} else { } else {
service = StdWebSocketService.initWebSockets(DebugProperties.WEBSOCKET_URL).get(); service = StdWebSocketService.initWebSockets(webSocketURL).get();
} }
Request.setRequestService(service); Request.setRequestService(service);
if(!DebugProperties.DISABLE_AUTO_REFRESH) { if(!disableAutoRefresh) {
Request.startAutoRefresh(); Request.startAutoRefresh();
} }
} }
public static AuthorizationData authorize() throws Exception {
if(DebugProperties.ACCESS_TOKEN != null) {
Request.setOAuth(DebugProperties.AUTH_ID, new AuthRequestEvent.OAuthRequestEvent(DebugProperties.ACCESS_TOKEN, DebugProperties.REFRESH_TOKEN, DebugProperties.EXPIRE));
Request.RequestRestoreReport report = Request.restore(true, false, true);
return new AuthorizationData(new AuthRequestEvent.OAuthRequestEvent(DebugProperties.ACCESS_TOKEN, DebugProperties.REFRESH_TOKEN, DebugProperties.EXPIRE), report.userInfo);
} else if(DebugProperties.LOGIN != null) {
AuthRequest request = new AuthRequest(DebugProperties.LOGIN, DebugProperties.PASSWORD, DebugProperties.AUTH_ID, AuthRequest.ConnectTypes.API);
AuthRequestEvent event = request.request();
Request.setOAuth(DebugProperties.AUTH_ID, event.oauth);
return new AuthorizationData(event.oauth, new CurrentUserRequestEvent.UserInfo(event.permissions, event.accessToken, event.playerProfile));
} else {
return new AuthorizationData(new AuthRequestEvent.OAuthRequestEvent("ACCESS_TOKEN", "REFRESH_TOKEN", 0),
new CurrentUserRequestEvent.UserInfo(new ClientPermissions(), "ACCESS_TOKEN", new PlayerProfile(UUID.fromString(DebugProperties.UUID),
DebugProperties.USERNAME, new HashMap<>(), new HashMap<>())));
}
}
public record AuthorizationData(AuthRequestEvent.OAuthRequestEvent event, CurrentUserRequestEvent.UserInfo userInfo) {
}
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
public static LauncherModule newModule(String className) throws ClassNotFoundException, InvocationTargetException { public static LauncherModule newModule(String className) throws ClassNotFoundException, InvocationTargetException {
Class<? extends LauncherModule> clazz = (Class<? extends LauncherModule>) Class.forName(className); Class<? extends LauncherModule> clazz = (Class<? extends LauncherModule>) Class.forName(className);

View file

@ -3,6 +3,5 @@
public class DebugMainInlineInitializer { public class DebugMainInlineInitializer {
public static void run() throws Exception { public static void run() throws Exception {
DebugMain.initialize(); DebugMain.initialize();
DebugMain.authorize();
} }
} }

View file

@ -1,24 +0,0 @@
package pro.gravit.launcher.runtime.debug;
import pro.gravit.launcher.base.LauncherConfig;
public class DebugProperties {
public static final String ACCESS_TOKEN = System.getProperty("launcher.runtime.auth.accesstoken", null);
public static final String AUTH_ID = System.getProperty("launcher.runtime.auth.authid", "std");
public static final String REFRESH_TOKEN = System.getProperty("launcher.runtime.auth.refreshtoken", null);
public static final String MINECRAFT_ACCESS_TOKEN = System.getProperty("launcher.runtime.auth.minecraftaccesstoken", "DEBUG");
public static final long EXPIRE = Long.parseLong(System.getProperty("launcher.runtime.auth.expire", "0"));
public static final String USERNAME = System.getProperty("launcher.runtime.username", null);
public static final String LOGIN = System.getProperty("launcher.runtime.login", USERNAME);
public static final String UUID = System.getProperty("launcher.runtime.uuid", null);
public static final String PASSWORD = System.getProperty("launcher.runtime.password", null);
public static String WEBSOCKET_URL = System.getProperty("launcherdebug.websocket", "ws://localhost:9274/api");
public static String PROJECT_NAME = System.getProperty("launcherdebug.projectname", "Minecraft");
public static String UNLOCK_SECRET = System.getProperty("launcherdebug.unlocksecret", "");
public static boolean DISABLE_CONSOLE = Boolean.getBoolean("launcherdebug.disableConsole");
public static boolean OFFLINE_MODE = Boolean.getBoolean("launcherdebug.offlinemode");
public static boolean DISABLE_AUTO_REFRESH = Boolean.getBoolean("launcherdebug.disableautorefresh");
public static String[] MODULE_CLASSES = System.getProperty("launcherdebug.modules", "").split(",");
public static String[] MODULE_FILES = System.getProperty("launcherdebug.modulefiles", "").split(",");
public static LauncherConfig.LauncherEnvironment ENV = LauncherConfig.LauncherEnvironment.valueOf(System.getProperty("launcherdebug.env", "STD"));
}

View file

@ -20,14 +20,5 @@ public static class UserInfo {
public ClientPermissions permissions; public ClientPermissions permissions;
public String accessToken; public String accessToken;
public PlayerProfile playerProfile; public PlayerProfile playerProfile;
public UserInfo() {
}
public UserInfo(ClientPermissions permissions, String accessToken, PlayerProfile playerProfile) {
this.permissions = permissions;
this.accessToken = accessToken;
this.playerProfile = playerProfile;
}
} }
} }

View file

@ -6,9 +6,9 @@ public final class Version implements Comparable<Version> {
public static final int MAJOR = 5; public static final int MAJOR = 5;
public static final int MINOR = 6; public static final int MINOR = 6;
public static final int PATCH = 16; public static final int PATCH = 14;
public static final int BUILD = 1; public static final int BUILD = 1;
public static final Version.Type RELEASE = Type.DEV; public static final Version.Type RELEASE = Type.STABLE;
public final int major; public final int major;
public final int minor; public final int minor;
public final int patch; public final int patch;

View file

@ -282,12 +282,12 @@ public void setConfig(Config config) {
@Override @Override
public Config getDefaultConfig() { public Config getDefaultConfig() {
Config newConfig = new Config(); Config newConfig = new Config();
newConfig.serverName = ""; newConfig.serverName = "your server name";
newConfig.mainclass = ""; newConfig.mainclass = "";
newConfig.extendedTokens = new HashMap<>(); newConfig.extendedTokens = new HashMap<>();
newConfig.args = new ArrayList<>(); newConfig.args = new ArrayList<>();
newConfig.classpath = new ArrayList<>(); newConfig.classpath = new ArrayList<>();
newConfig.address = ""; newConfig.address = "ws://localhost:9274/api";
newConfig.classLoaderConfig = ClientProfile.ClassLoaderConfig.SYSTEM_ARGS; newConfig.classLoaderConfig = ClientProfile.ClassLoaderConfig.SYSTEM_ARGS;
newConfig.env = LauncherConfig.LauncherEnvironment.STD; newConfig.env = LauncherConfig.LauncherEnvironment.STD;
newConfig.properties = new HashMap<>(); newConfig.properties = new HashMap<>();

View file

@ -5,7 +5,7 @@
id 'org.openjfx.javafxplugin' version '0.1.0' apply false id 'org.openjfx.javafxplugin' version '0.1.0' apply false
} }
group = 'pro.gravit.launcher' group = 'pro.gravit.launcher'
version = '5.6.16-SNAPSHOT' version = '5.6.14'
apply from: 'props.gradle' apply from: 'props.gradle'

@ -1 +1 @@
Subproject commit a18e0b7d7b6aff2b46c13d0290826cdb8e815dbe Subproject commit a2c3ccecadb7f864039b88e6269583c4b77fba13