@@ -65,6 +65,7 @@ static void main(String[] args) throws IOException, InterruptedException {
6565 } else if (!Boolean .getBoolean ("hypertale.useInitWrapper" )) {
6666 System .setProperty ("hypertale.initMethod" , "direct" );
6767 }
68+ MainPlus .setEditionProperties ();
6869 if (args .length == 0 && !isRunningFromTerminal ()) {
6970 // Avoid running a server from a double click.
7071 System .out .println ("[Hypertale] File double click detected! Skipping running!" );
@@ -164,6 +165,14 @@ static void main(String[] args) throws IOException, InterruptedException {
164165 EarlyLogger .log ("Version " + BuildConfig .HYPERTALE_VERSION );
165166 launchGame (EmptyArrays .EMPTY_STRING_ARRAY , true );
166167 return ;
168+ } else if (args .length == 1 && "--patch-class-path" .equals (args [0 ])) {
169+ if (Boolean .getBoolean ("hypertale.premium" )) {
170+ EarlyLogger .start (false );
171+ MainPlus .patchAsClassPath ();
172+ } else {
173+ System .out .println ("This feature is only available on premium builds of Hypertale!" );
174+ }
175+ return ;
167176 }
168177 EarlyLogger .start (false );
169178 EarlyLogger .log ("Version " + BuildConfig .HYPERTALE_VERSION );
@@ -201,6 +210,12 @@ static void main(String[] args) throws IOException, InterruptedException {
201210 if (args .length == 1 && "--noop" .equals (args [0 ])) {
202211 return ;
203212 }
213+ if (HypertaleConfig .hyperOptimizeClassPath ()) {
214+ MainPlus .launchPatchedAsClassPath (args );
215+ return ;
216+ } else if (HypertaleConfig .premiumHyperOptimizeClassPath ) {
217+ EarlyLogger .log ("HyperOptimizeClassPath is only supported on premium builds of Hypertale!" );
218+ }
204219 try {
205220 launchGame (args , false );
206221 } catch (LinkageError e ) {
@@ -263,6 +278,15 @@ private static void launchGame(String[] args, boolean dev) throws IOException {
263278
264279 private static void runPatcher (HypertaleData actualData ) throws IOException , InterruptedException {
265280 EarlyLogger .log ("Patching HytaleServer..." );
281+ execSelf ("--run-patcher" );
282+ actualData .modifiedJarSize = HypertalePaths .hypertaleCacheJar .length ();
283+ actualData .writeTo (HypertalePaths .hypertaleCacheData );
284+ }
285+
286+ public static void execSelf (String arg ) throws IOException , InterruptedException {
287+ if (!EarlyLogger .isDirectLogging ()) {
288+ throw new IllegalStateException ("Invalid state!" );
289+ }
266290 EarlyLogger .stop ();
267291 ArrayList <String > command = new ArrayList <>();
268292 if (System .getProperty ("os.name" ).toLowerCase (Locale .ROOT ).startsWith ("win" )) {
@@ -272,14 +296,12 @@ private static void runPatcher(HypertaleData actualData) throws IOException, Int
272296 }
273297 command .add ("-jar" );
274298 command .add (HypertalePaths .getHypertaleExecJar ().getAbsolutePath ());
275- command .add ("--run-patcher" );
299+ command .add (arg );
276300 int returnCode = new ProcessBuilder (command ).inheritIO ().start ().waitFor ();
277301 if (returnCode != 0 || !HypertalePaths .hypertaleCacheJar .exists ()) {
278302 throw new IOException ("Patch failed with return code is " + returnCode );
279303 }
280304 EarlyLogger .start (true );
281- actualData .modifiedJarSize = HypertalePaths .hypertaleCacheJar .length ();
282- actualData .writeTo (HypertalePaths .hypertaleCacheData );
283305 }
284306
285307 // https://errorprone.info/bugpattern/SystemConsoleNull
0 commit comments