Java Code Examples for net.minecraft.launchwrapper.Launch#main()

The following examples show how to use net.minecraft.launchwrapper.Launch#main() . You can vote up the ones you like or vote down the ones you don't like, and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example 1
Source File: Start.java    From The-5zig-Mod with GNU General Public License v3.0 5 votes vote down vote up
public static void main(String[] args) throws IOException {
	OptionParser optionParser = new OptionParser();
	optionParser.allowsUnrecognizedOptions();
	OptionSpec<String> uuidSpec = optionParser.accepts("uuid").withRequiredArg();
	OptionSet optionSet = optionParser.parse(args);

	if (optionSet.has(uuidSpec)) {
		File launcherProfilesFile = new File(getMinecraftDirectory(), "launcher_profiles.json");
		JsonObject root = new JsonParser().parse(IOUtils.toString(launcherProfilesFile.toURI())).getAsJsonObject();
		String selectedUser = optionSet.valueOf(uuidSpec);
		JsonObject authenticationDatabase = null;
		for (Map.Entry<String, JsonElement> entry : root.get("authenticationDatabase").getAsJsonObject().entrySet()) {
			if (!entry.getValue().isJsonObject()) {
				continue;
			}
			if (entry.getValue().getAsJsonObject().getAsJsonObject("profiles").has(selectedUser)) {
				authenticationDatabase = entry.getValue().getAsJsonObject();
			}
		}

		Validate.notNull(authenticationDatabase, "Profile " + selectedUser + " not found!");
		String accessToken = authenticationDatabase.get("accessToken").getAsString();
		String displayName = authenticationDatabase.getAsJsonObject("profiles").getAsJsonObject(selectedUser).get("displayName").getAsString();

		System.out.println("Launching Minecraft as " + displayName + " (token:" + accessToken + ":" + selectedUser + ")");

		Launch.main(Utils.concat(new String[]{"--assetsDir", "assets", "--userProperties", "{}", "--username", displayName, "--accessToken", accessToken, "--tweakClass",
				"eu.the5zig.mod.asm.ClassTweaker"}, args));
	} else {
		Launch.main(Utils.concat(
				new String[]{"--assetsDir", "assets", "--userProperties", "{}", "--username", "Steve", "--uuid", "00000000000000000000000000000000", "--accessToken", "0", "--tweakClass",
						"eu.the5zig.mod.asm.ClassTweaker"}, args));
	}
}
 
Example 2
Source File: Start.java    From The-5zig-Mod with MIT License 5 votes vote down vote up
public static void main(String[] args) throws IOException {
		OptionParser optionParser = new OptionParser();
		optionParser.allowsUnrecognizedOptions();
		OptionSpec<String> uuidSpec = optionParser.accepts("uuid").withRequiredArg();
		OptionSet optionSet = optionParser.parse(args);

		if (optionSet.has(uuidSpec)) {
			File launcherProfilesFile = new File(getMinecraftDirectory(), "launcher_profiles.json");
			JsonObject root = new JsonParser().parse(IOUtils.toString(launcherProfilesFile.toURI())).getAsJsonObject();
			String selectedUser = optionSet.valueOf(uuidSpec);
			JsonObject authenticationDatabase = null;
			for (Map.Entry<String, JsonElement> entry : root.get("authenticationDatabase").getAsJsonObject().entrySet()) {
				if (!entry.getValue().isJsonObject()) {
					continue;
				}
				if (entry.getValue().getAsJsonObject().getAsJsonObject("profiles").has(selectedUser)) {
					authenticationDatabase = entry.getValue().getAsJsonObject();
				}
			}

			Validate.notNull(authenticationDatabase, "Profile " + selectedUser + " not found!");
			String accessToken = authenticationDatabase.get("accessToken").getAsString();
			String displayName = authenticationDatabase.getAsJsonObject("profiles").getAsJsonObject(selectedUser).get("displayName").getAsString();
//			JsonObject authenticationDatabase = root.get("authenticationDatabase").getAsJsonObject().entrySet().iterator().next().getValue().getAsJsonObject();
//			String accessToken = authenticationDatabase.get("accessToken").getAsString();
//			String displayName = authenticationDatabase.get("displayName").getAsString();

			System.out.println("Launching Minecraft as " + displayName + " (token:" + accessToken + ":" + selectedUser + ")");

			Launch.main(Utils.concat(new String[]{"--assetsDir", "assets", "--userProperties", "{}", "--username", displayName, "--accessToken", accessToken, "--tweakClass",
					"eu.the5zig.mod.asm.ClassTweaker"}, args));
		} else {
			Launch.main(Utils.concat(
					new String[]{"--assetsDir", "assets", "--userProperties", "{}", "--username", "Steve", "--uuid", "00000000000000000000000000000000", "--accessToken", "0", "--tweakClass",
							"eu.the5zig.mod.asm.ClassTweaker"}, args));
		}
	}
 
Example 3
Source File: ServerRunner.java    From BoundingBoxOutlineReloaded with MIT License 5 votes vote down vote up
public static void run(List<String> args) throws IOException {
    String serverJarUrl = VANILLA_SERVER_JARS.get(Versions.minecraft);

    addURLToClasspath(getOrDownload(new File("."), serverJarUrl));
    for (String url : LIBRARIES) {
        addURLToClasspath(getOrDownload(new File("libs"), url));
    }

    args = new ArrayList<>(args);
    args.add("--tweakClass");
    args.add("com.irtimaled.bbor.launch.ServerTweaker");

    System.out.println("Launching server...");
    Launch.main(args.toArray(new String[0]));
}