Fix rules-to-wiki and generalize some code for extension's equivalents (#696)

* Fix rules-to-wiki output

* Publicize OLD_OUT in RulePrinter to simplify extension's equivalents

And rename to CarpetRulePrinter because of the same reason
This commit is contained in:
altrisi authored and GitHub committed 2021-02-08 23:52:49 -04:00
1 parent 2604ff5a9d
commit 4807e4d518
3 files changed
+35 -23

No files matched your search

+2 -1
View File
@@ -159,7 +159,8 @@ jobs:
"id": "carpet",
"version": "1.4.11",
"entrypoints": {
"preLaunch": [ "carpet.utils.RulePrinter" ]
"server": [ "carpet.utils.CarpetRulePrinter" ],
"preLaunch": [ "carpet.utils.CarpetRulePrinter" ]
}
}' > fabric.mod.json
cd ../../../
@@ -0,0 +1,33 @@
package carpet.utils;
import carpet.CarpetServer;
import net.fabricmc.api.DedicatedServerModInitializer;
import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint;
import java.io.PrintStream;
import java.lang.System;
/**
* Runs only from GitHub Actions to generate the wiki
* page with all Carpet rules on it.
* It is here so it can be managed by the IDE
*
*/
public class CarpetRulePrinter implements DedicatedServerModInitializer, PreLaunchEntrypoint {
public static final PrintStream OLD_OUT = System.out;
@Override
public void onInitializeServer() {
// Minecraft (or whatever) changes the System.out to have prefixes,
// our simple parser doesn't like that. So we change it back
System.setOut(OLD_OUT);
CarpetServer.onGameStarted();
CarpetServer.settingsManager.printAllRulesToLog(null);
System.exit(0);
}
@Override
public void onPreLaunch() {
// Just initializes our OLD_OUT by nooping the class
}
}
@@ -1,22 +0,0 @@
package carpet.utils;
import carpet.CarpetServer;
import net.fabricmc.loader.api.entrypoint.PreLaunchEntrypoint;
import java.lang.System;
/**
* Runs only from GitHub Actions to generate the wiki
* page with all Carpet rules on it.
* It is here so it can be managed by the IDE
*
* @author altrisi
*
*/
public class RulePrinter implements PreLaunchEntrypoint {
@Override
public void onPreLaunch() {
CarpetServer.onGameStarted();
CarpetServer.settingsManager.printAllRulesToLog(null);
System.exit(0);
}
}