aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authorAnhgelus Morhtuuzh <william@herges.fr>2026-03-17 14:30:43 +0100
committerAnhgelus Morhtuuzh <william@herges.fr>2026-03-17 18:06:18 +0100
commit365a7e7906c3623eddef7401b27c1db635439787 (patch)
tree34e88d47c6d6f4d59d3e663e5cc2aea9f0b667d2 /src/main
parent66856d971b331b3986a17306b9812ac52f0fa3bf (diff)
fix(): cannot launch game
invalid version number invalid identifier for gamerules infinite recursive mixin
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/world/anhgelus/molehunt/Molehunt.java129
1 files changed, 58 insertions, 71 deletions
diff --git a/src/main/java/world/anhgelus/molehunt/Molehunt.java b/src/main/java/world/anhgelus/molehunt/Molehunt.java
index 984f906..966d6c5 100644
--- a/src/main/java/world/anhgelus/molehunt/Molehunt.java
+++ b/src/main/java/world/anhgelus/molehunt/Molehunt.java
@@ -42,84 +42,71 @@ public class Molehunt implements ModInitializer {
public static final String MOD_ID = "molehunt";
public static final Logger LOGGER = LoggerFactory.getLogger(MOD_ID);
- public static Config CONFIG;
-
public static final SimpleConfig CONFIG_FILE = Config.configFile(MOD_ID);
-
public static final GameRule<Integer> GAME_DURATION = GameRuleBuilder
.forInteger(CONFIG_FILE.getOrDefault("game_duration", 90))
.category(GameRuleCategory.MISC)
- .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "gameDurationMinutes"));
-
+ .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "game_duration_minutes"));
public static final GameRule<Integer> MOLE_PERCENTAGE = GameRuleBuilder
.forInteger(CONFIG_FILE.getOrDefault("mole_percentage", 25))
.range(0, 100)
.category(GameRuleCategory.MISC)
- .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "molePercentage"));
-
+ .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "mole_percentage"));
public static final GameRule<Integer> MOLE_COUNT = GameRuleBuilder
.forInteger(CONFIG_FILE.getOrDefault("mole_count", -1))
.category(GameRuleCategory.MISC)
- .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "moleCount"));
-
+ .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "mole_count"));
public static final GameRule<Boolean> SHOW_NAMETAGS = GameRuleBuilder
.forBoolean(CONFIG_FILE.getOrDefault("show_nametags", false))
.category(GameRuleCategory.MISC)
- .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "showNametags"));
-
+ .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "show_nametags"));
public static final GameRule<Boolean> SHOW_TAB = GameRuleBuilder
.forBoolean(CONFIG_FILE.getOrDefault("show_tab", false))
.category(GameRuleCategory.MISC)
- .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "showTab"));
-
+ .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "show_tab"));
public static final GameRule<Boolean> SHOW_SKINS = GameRuleBuilder
.forBoolean(CONFIG_FILE.getOrDefault("show_skins", false))
.category(GameRuleCategory.MISC)
- .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "showSkins"));
-
+ .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "show_skins"));
public static final GameRule<Integer> INITIAL_WORLD_SIZE = GameRuleBuilder
.forInteger(CONFIG_FILE.getOrDefault("initial_world_size", 600))
.minValue(0)
.category(GameRuleCategory.MISC)
- .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "initialWorldSize"));
-
+ .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "initial_world_size"));
public static final GameRule<Integer> FINAL_WORLD_SIZE = GameRuleBuilder
.forInteger(CONFIG_FILE.getOrDefault("final_world_size", 100))
.minValue(0)
.category(GameRuleCategory.MISC)
- .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "finalWorldSize"));
-
+ .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "final_world_size"));
public static final GameRule<Integer> MOVING_STARTING_TIME_OFFSET = GameRuleBuilder
.forInteger(CONFIG_FILE.getOrDefault("border_moving_starting_time_offset", 30))
.minValue(0)
.category(GameRuleCategory.MISC)
- .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "borderMovingStartingTimeOffsetMinutes"));
-
+ .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "border_moving_starting_time_offset_minutes"));
public static final GameRule<Boolean> ENABLE_PORTALS = GameRuleBuilder
.forBoolean(CONFIG_FILE.getOrDefault("enable_portals", false))
.category(GameRuleCategory.MISC)
- .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "enablePortals"));
-
+ .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "enable_portals"));
public static final GameRule<Boolean> FOOD_ON_START = GameRuleBuilder
.forBoolean(CONFIG_FILE.getOrDefault("food_on_start", true))
.category(GameRuleCategory.MISC)
- .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "foodOnStart"));
-
- public Game game;
-
+ .buildAndRegister(Identifier.fromNamespaceAndPath(MOD_ID, "food_on_start"));
+ public static Config CONFIG;
public static HashMap<UUID, Boolean> timerVisibility = new HashMap<>();
- private static <T> void sendConfigPayload(T v, MinecraftServer server) {
- if (CONFIG == null) return;
- CONFIG.sendConfigPayload();
- }
-
static {
GameRuleEvents.changeCallback(SHOW_NAMETAGS).register(Molehunt::sendConfigPayload);
GameRuleEvents.changeCallback(SHOW_TAB).register(Molehunt::sendConfigPayload);
GameRuleEvents.changeCallback(SHOW_SKINS).register(Molehunt::sendConfigPayload);
}
+ public Game game;
+
+ private static <T> void sendConfigPayload(T v, MinecraftServer server) {
+ if (CONFIG == null) return;
+ CONFIG.sendConfigPayload();
+ }
+
@Override
public void onInitialize() {
LOGGER.info("Initializing Molehunt");
@@ -128,10 +115,10 @@ public class Molehunt implements ModInitializer {
command.then(literal("start")
.requires(Commands.hasPermission(Commands.LEVEL_GAMEMASTERS))
.executes(context -> {
- game = new Game(context.getSource().getServer());
- game.start();
- return Command.SINGLE_SUCCESS;
- }));
+ game = new Game(context.getSource().getServer());
+ game.start();
+ return Command.SINGLE_SUCCESS;
+ }));
command.then(literal("timer").requires(CommandSourceStack::isPlayer).then(
literal("show").executes(context -> {
var player = context.getSource().getPlayer();
@@ -142,7 +129,7 @@ public class Molehunt implements ModInitializer {
if (game == null || !game.started()) {
player.connection.send(new ClientboundSetActionBarTextPacket(
- Component.translatable("commands.molehunt.error.game_not_started").withStyle(ChatFormatting.RED)
+ Component.translatable("commands.molehunt.error.game_not_started").withStyle(ChatFormatting.RED)
));
} else {
player.connection.send(new ClientboundSetActionBarTextPacket(Component.translationArg(game.getRemainingText())));
@@ -163,45 +150,45 @@ public class Molehunt implements ModInitializer {
command.then(literal("role")
.requires(CommandSourceStack::isPlayer)
.executes(context -> {
- if (game == null || !game.started()) {
- throw (new SimpleCommandExceptionType(Component.translatable("commands.molehunt.error.game_not_started"))).create();
- }
-
- final var source = context.getSource();
- final var player = source.getPlayer();
- assert player != null;
-
- if (game.isMole(player)) {
- source.sendSuccess(
- () -> Component.translatable("commands.molehunt.role.mole")
- .append("\n\n")
- .append(Component.translatable("commands.molehunt.role.mole.list", game.getMolesAsString())),
- false);
- } else if (player.isSpectator()) {
- source.sendSuccess(
- () -> Component.translatable("commands.molehunt.role.survivor.mole_count", game.getMoles().size()),
- false);
- } else {
- source.sendSuccess(
- () -> Component.translatable("commands.molehunt.role.survivor")
- .append("\n\n")
- .append(Component.translatable("commands.molehunt.role.survivor.mole_count", game.getMoles().size())),
- false);
- }
-
- return Command.SINGLE_SUCCESS;
- }));
+ if (game == null || !game.started()) {
+ throw (new SimpleCommandExceptionType(Component.translatable("commands.molehunt.error.game_not_started"))).create();
+ }
+
+ final var source = context.getSource();
+ final var player = source.getPlayer();
+ assert player != null;
+
+ if (game.isMole(player)) {
+ source.sendSuccess(
+ () -> Component.translatable("commands.molehunt.role.mole")
+ .append("\n\n")
+ .append(Component.translatable("commands.molehunt.role.mole.list", game.getMolesAsString())),
+ false);
+ } else if (player.isSpectator()) {
+ source.sendSuccess(
+ () -> Component.translatable("commands.molehunt.role.survivor.mole_count", game.getMoles().size()),
+ false);
+ } else {
+ source.sendSuccess(
+ () -> Component.translatable("commands.molehunt.role.survivor")
+ .append("\n\n")
+ .append(Component.translatable("commands.molehunt.role.survivor.mole_count", game.getMoles().size())),
+ false);
+ }
+
+ return Command.SINGLE_SUCCESS;
+ }));
command.then(literal("stop")
.requires(Commands.hasPermission(Commands.LEVEL_GAMEMASTERS))
.executes(context -> {
- if (game == null || !game.started()) {
- throw (new SimpleCommandExceptionType(Component.translatable("commands.molehunt.error.game_not_started"))).create();
- }
+ if (game == null || !game.started()) {
+ throw (new SimpleCommandExceptionType(Component.translatable("commands.molehunt.error.game_not_started"))).create();
+ }
- game.stop();
+ game.stop();
- return Command.SINGLE_SUCCESS;
- }));
+ return Command.SINGLE_SUCCESS;
+ }));
ServerLifecycleEvents.SERVER_STARTED.register(server -> CONFIG = new Config(server));