fixed missed command registration for extension, 1.3.0, added optional version.

This commit is contained in:
gnembon committed 2019-12-10 23:01:30 -04:00
1 parent 3dfd44538b
commit 8b1286f8af
5 files changed
+17 -3

No files matched your search

@@ -47,4 +47,6 @@ public interface CarpetExtension
default void onPlayerLoggedOut(ServerPlayerEntity player) {}
default void onServerClosed(MinecraftServer server) {}
default String version() {return null;}
}
+12
View File
@@ -33,6 +33,7 @@ public class CarpetServer // static for now - easier to handle all around the co
{
public static final Random rand = new Random((int)((2>>16)*Math.random()));
public static MinecraftServer minecraft_server;
private static CommandDispatcher<ServerCommandSource> currentCommandDispatcher;
public static CarpetScriptServer scriptServer;
public static SettingsManager settingsManager;
public static List<CarpetExtension> extensions = new ArrayList<>();
@@ -41,6 +42,13 @@ public class CarpetServer // static for now - easier to handle all around the co
public static void manageExtension(CarpetExtension extension)
{
extensions.add(extension);
// for extensions that come late to the party, after server is created / loaded
// we will handle them now.
// that would handle all extensions, even these that add themselves really late to the party
if (currentCommandDispatcher != null)
{
extension.registerCommands(currentCommandDispatcher);
}
}
public static void onGameStarted()
@@ -93,7 +101,10 @@ public class CarpetServer // static for now - easier to handle all around the co
DrawCommand.register(dispatcher);
ScriptCommand.register(dispatcher);
MobAICommand.register(dispatcher);
// registering command of extensions that has registered before either server is created
// for all other, they will have them registered when they add themselves
extensions.forEach(e -> e.registerCommands(dispatcher));
currentCommandDispatcher = dispatcher;
//TestCommand.register(dispatcher);
}
@@ -111,6 +122,7 @@ public class CarpetServer // static for now - easier to handle all around the co
public static void onServerClosed(MinecraftServer server)
{
currentCommandDispatcher = null;
scriptServer.onClose();
settingsManager.detachServer();
LoggerRegistry.stopLoggers();
@@ -29,7 +29,7 @@ import static carpet.settings.RuleCategory.DISPENSER;
public class CarpetSettings
{
public static final String carpetVersion = "1.2.6+v191209";
public static final String carpetVersion = "1.3.0+v191210";
public static final Logger LOG = LogManager.getLogger();
public static boolean skipGenerationChecks = false;
public static boolean impendingFillSkipUpdates = false;