mirror of
https://github.com/ProjectSWGCore/Holocore.git
synced 2026-09-12 22:45:18 -04:00
Removed commons.cli and updated pswgcommon pointer to cu
This commit is contained in:
+2
-6
@@ -5,14 +5,11 @@ plugins {
|
||||
kotlin("jvm") version "1.6.10"
|
||||
}
|
||||
|
||||
// Note: define javaVersion, javaMajorVersion, javaHomeLinux, javaHomeMac, and javaHomeWindows
|
||||
// Note: define javaVersion, javaMajorVersion, and kotlinTargetJdk
|
||||
// inside your gradle.properties file
|
||||
val javaVersion: String by project
|
||||
val javaMajorVersion: String by project
|
||||
val kotlinTargetJdk: String by project
|
||||
val javaHomeLinux: String by project
|
||||
val javaHomeMac: String by project
|
||||
val javaHomeWindows: String by project
|
||||
|
||||
subprojects {
|
||||
ext {
|
||||
@@ -38,13 +35,12 @@ sourceSets {
|
||||
implementation(project(":pswgcommon"))
|
||||
implementation(kotlin("stdlib"))
|
||||
|
||||
implementation("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.6.1")
|
||||
|
||||
implementation(group="org.xerial", name="sqlite-jdbc", version="3.30.1")
|
||||
implementation(group="org.mariadb.jdbc", name="mariadb-java-client", version="2.5.4")
|
||||
implementation(group="org.mongodb", name="mongodb-driver-sync", version="3.12.2")
|
||||
implementation(group="me.joshlarson", name="fast-json", version="3.0.1")
|
||||
implementation(group="me.joshlarson", name="jlcommon-network", version="1.1.0")
|
||||
implementation(group="me.joshlarson", name="jlcommon-argparse", version="0.9.4")
|
||||
implementation(group="com.github.madsboddum", name="swgterrain", version="1.1.3")
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
Submodule pswgcommon updated: 502861cc18...f33b78f3f8
@@ -36,6 +36,9 @@ import com.projectswg.holocore.resources.support.data.server_info.mongodb.PswgDa
|
||||
import com.projectswg.holocore.services.gameplay.GameplayManager;
|
||||
import com.projectswg.holocore.services.support.SupportManager;
|
||||
import com.projectswg.holocore.utilities.ScheduledUtilities;
|
||||
import me.joshlarson.jlcommon.argparse.Argument;
|
||||
import me.joshlarson.jlcommon.argparse.ArgumentParser;
|
||||
import me.joshlarson.jlcommon.argparse.ArgumentParserException;
|
||||
import me.joshlarson.jlcommon.concurrency.Delay;
|
||||
import me.joshlarson.jlcommon.control.IntentManager;
|
||||
import me.joshlarson.jlcommon.control.IntentManager.IntentSpeedStatistics;
|
||||
@@ -47,7 +50,6 @@ import me.joshlarson.jlcommon.log.log_wrapper.AnsiColorLogWrapper;
|
||||
import me.joshlarson.jlcommon.log.log_wrapper.ConsoleLogWrapper;
|
||||
import me.joshlarson.jlcommon.log.log_wrapper.FileLogWrapper;
|
||||
import me.joshlarson.jlcommon.utilities.ThreadUtilities;
|
||||
import org.apache.commons.cli.*;
|
||||
|
||||
import java.io.File;
|
||||
import java.io.IOException;
|
||||
@@ -55,6 +57,7 @@ import java.time.OffsetTime;
|
||||
import java.util.Arrays;
|
||||
import java.util.Comparator;
|
||||
import java.util.List;
|
||||
import java.util.Map;
|
||||
|
||||
public class ProjectSWG {
|
||||
|
||||
@@ -78,24 +81,24 @@ public class ProjectSWG {
|
||||
}
|
||||
|
||||
static int run(String [] args) {
|
||||
CommandLine arguments;
|
||||
ArgumentParser parser = createArgumentOptions();
|
||||
Map<String, Object> arguments;
|
||||
try {
|
||||
arguments = new DefaultParser().parse(createArgumentOptions(), args, true);
|
||||
} catch (Throwable t) {
|
||||
//noinspection UseOfSystemOutOrSystemErr
|
||||
System.err.println("Failed to parse arguments. Reason: " + t.getClass().getName() + ": " + t.getMessage());
|
||||
new HelpFormatter().printHelp("java -jar Holocore.jar", createArgumentOptions());
|
||||
arguments = parser.parse(args);
|
||||
} catch (ArgumentParserException e) {
|
||||
System.err.println("Failed to parse arguments. Reason: " + e.getClass().getName() + ": " + e.getMessage());
|
||||
printHelp(parser);
|
||||
return -1;
|
||||
}
|
||||
if (arguments.hasOption("help")) {
|
||||
new HelpFormatter().printHelp("java -jar Holocore.jar", createArgumentOptions());
|
||||
if (arguments.containsKey("help")) {
|
||||
printHelp(parser);
|
||||
return 0;
|
||||
}
|
||||
|
||||
File logDirectory = new File("log");
|
||||
if (!logDirectory.isDirectory() && !logDirectory.mkdir())
|
||||
Log.w("Failed to make log directory!");
|
||||
if (arguments.hasOption("print-colors"))
|
||||
if (arguments.containsKey("print-colors"))
|
||||
Log.addWrapper(new AnsiColorLogWrapper());
|
||||
else
|
||||
Log.addWrapper(new ConsoleLogWrapper());
|
||||
@@ -168,7 +171,7 @@ public class ProjectSWG {
|
||||
new ServerStatusIntent(status).broadcast();
|
||||
}
|
||||
|
||||
private static void setupGalaxy(CommandLine arguments) {
|
||||
private static void setupGalaxy(Map<String, Object> arguments) {
|
||||
GALAXY.setId(1);
|
||||
GALAXY.setName(PswgDatabase.INSTANCE.getConfig().getString(ProjectSWG.class, "galaxyName", "Holocore"));
|
||||
GALAXY.setAddress("");
|
||||
@@ -182,7 +185,7 @@ public class ProjectSWG {
|
||||
GALAXY.setOnlineFreeTrialLimit(PswgDatabase.INSTANCE.getConfig().getInt(ProjectSWG.class, "galaxyMaxOnline", 3000));
|
||||
GALAXY.setRecommended(true);
|
||||
try {
|
||||
GALAXY.setAdminServerPort(Integer.parseInt(arguments.getOptionValue("admin-port", "-1")));
|
||||
GALAXY.setAdminServerPort(Integer.parseInt((String) arguments.getOrDefault("admin-port", "-1")));
|
||||
} catch (NumberFormatException e) {
|
||||
throw new IllegalArgumentException("admin server port must be an integer", e);
|
||||
}
|
||||
@@ -190,21 +193,35 @@ public class ProjectSWG {
|
||||
ChatAvatar.setGalaxy(GALAXY.getName());
|
||||
}
|
||||
|
||||
private static void setupDatabase(CommandLine arguments) {
|
||||
String dbStr = arguments.getOptionValue("database", "mongodb://localhost");
|
||||
String db = arguments.getOptionValue("dbName", "cu");
|
||||
private static void setupDatabase(Map<String, Object> arguments) {
|
||||
String dbStr = (String) arguments.getOrDefault("database", "mongodb://localhost");
|
||||
String db = (String) arguments.getOrDefault("dbName", "cu");
|
||||
|
||||
PswgDatabase.INSTANCE.initialize(dbStr, db);
|
||||
}
|
||||
|
||||
private static Options createArgumentOptions() {
|
||||
Options options = new Options();
|
||||
options.addOption(Option.builder("h").longOpt("help").desc("print this message").build());
|
||||
options.addOption(Option.builder("C").longOpt("print-colors").desc("print colors to signify various log levels").build());
|
||||
options.addOption(Option.builder("a").longOpt("admin-port").argName("port").hasArg(true).desc("sets the admin server port").build());
|
||||
options.addOption(Option.builder("c").longOpt("database").argName("str").hasArg(true).desc("sets the connection string for mongodb (default: mongodb://localhost)").build());
|
||||
options.addOption(Option.builder("d").longOpt("dbName").argName("db").hasArg(true).desc("sets the mongodb database (default: nge)").build());
|
||||
return options;
|
||||
private static ArgumentParser createArgumentOptions() {
|
||||
ArgumentParser parser = new ArgumentParser();
|
||||
parser.addArgument(Argument.builder("help").shortName('h').longName("help").isOptional(true).description("print this message").build());
|
||||
parser.addArgument(Argument.builder("print-colors").shortName('C').longName("print-colors").isOptional(true).description("print colors to signify various log levels").build());
|
||||
parser.addArgument(Argument.builder("database").shortName('c').longName("database").argCount('1').isOptional(true).description("sets the connection string for mongodb (default: mongodb://localhost)").build());
|
||||
parser.addArgument(Argument.builder("database-name").shortName('d').longName("dbName").argCount('1').isOptional(true).description("sets the mongodb database (default: cu)").build());
|
||||
|
||||
return parser;
|
||||
}
|
||||
|
||||
private static void printHelp(ArgumentParser parser) {
|
||||
int maxLengthName = 0;
|
||||
int maxLengthLongName = 0;
|
||||
for (Argument arg : parser.getArguments()) {
|
||||
maxLengthName = Math.max(maxLengthName, arg.getName().length());
|
||||
maxLengthLongName = Math.max(maxLengthLongName, arg.getLongName().length());
|
||||
}
|
||||
System.out.println("Help:");
|
||||
for (Argument arg : parser.getArguments()) {
|
||||
System.out.printf("%-"+maxLengthName+"s -%c%-"+(maxLengthLongName)+"s %s%n", arg.getName(), arg.getShortName(), "", arg.getDescription());
|
||||
System.out.printf("%-"+maxLengthName+"s --%s%n", "", arg.getLongName());
|
||||
}
|
||||
}
|
||||
|
||||
public static class CoreException extends RuntimeException {
|
||||
|
||||
@@ -9,12 +9,11 @@ open module holocore {
|
||||
requires org.mongodb.driver.core;
|
||||
requires me.joshlarson.jlcommon;
|
||||
requires me.joshlarson.jlcommon.network;
|
||||
requires me.joshlarson.jlcommon.argparse;
|
||||
|
||||
requires com.projectswg.common;
|
||||
requires fast.json;
|
||||
requires commons.cli;
|
||||
requires kotlin.stdlib;
|
||||
requires kotlinx.coroutines.core;
|
||||
|
||||
requires swgterrain;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user