aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorLéo Kosman <leo.kosman@proton.me>2024-08-24 13:12:01 +0200
committerLéo Kosman <leo.kosman@proton.me>2024-08-24 13:16:15 +0200
commitf59f9bdfadfb804e804cbafc168af82817f334f6 (patch)
tree4cfc13e87e496e20c63d412f524c09155a38ec9c /src
parent5c5851ce8441bced76c6abb2bd9cbfbbfedb01c9 (diff)
feat: config fields and gamerules related to world borders
Diffstat (limited to 'src')
-rw-r--r--src/main/java/world/anhgelus/molehunt/Molehunt.java6
-rw-r--r--src/main/java/world/anhgelus/molehunt/config/Config.java18
2 files changed, 17 insertions, 7 deletions
diff --git a/src/main/java/world/anhgelus/molehunt/Molehunt.java b/src/main/java/world/anhgelus/molehunt/Molehunt.java
index 7e6ce81..7df62fd 100644
--- a/src/main/java/world/anhgelus/molehunt/Molehunt.java
+++ b/src/main/java/world/anhgelus/molehunt/Molehunt.java
@@ -87,10 +87,10 @@ public class Molehunt implements ModInitializer {
GameRules.Category.MISC,
GameRuleFactory.createIntRule(CONFIG_FILE.getOrDefault("final_world_size", 50), 0)
);
- public static final GameRules.Key<GameRules.IntRule> SHRINKING_STARTING_OFFSET = GameRuleRegistry.register(
- MOD_ID +":borderShrinkingStartingOffsetMinutes",
+ public static final GameRules.Key<GameRules.IntRule> SHRINKING_STARTING_TIME_OFFSET = GameRuleRegistry.register(
+ MOD_ID +":borderShrinkingStartingTimeOffsetMinutes",
GameRules.Category.MISC,
- GameRuleFactory.createIntRule(CONFIG_FILE.getOrDefault("border_shrinking_starting_offset", 10), 0)
+ GameRuleFactory.createIntRule(CONFIG_FILE.getOrDefault("border_shrinking_starting_time_offset", 10), 0)
);
public Game game;
diff --git a/src/main/java/world/anhgelus/molehunt/config/Config.java b/src/main/java/world/anhgelus/molehunt/config/Config.java
index eedb659..b42a469 100644
--- a/src/main/java/world/anhgelus/molehunt/config/Config.java
+++ b/src/main/java/world/anhgelus/molehunt/config/Config.java
@@ -16,9 +16,7 @@ public class Config {
public void sendConfigPayload() {
final var payload = new ConfigPayload(areNametagsEnabled(), areSkinsEnabled(), isTabEnabled());
- server.getPlayerManager().getPlayerList().forEach(p -> {
- ServerPlayNetworking.send(p, payload);
- });
+ server.getPlayerManager().getPlayerList().forEach(p -> ServerPlayNetworking.send(p, payload));
}
public void sendConfigPayload(boolean showNametags, boolean showSkins, boolean showTab) {
@@ -50,6 +48,18 @@ public class Config {
return server.getGameRules().getBoolean(Molehunt.SHOW_TAB);
}
+ public int getInitialWorldSize() {
+ return server.getGameRules().getInt(Molehunt.INITIAL_WORLD_SIZE);
+ }
+
+ public int getFinalWorldSize() {
+ return server.getGameRules().getInt(Molehunt.FINAL_WORLD_SIZE);
+ }
+
+ public int getBorderShrinkingStartingTimeOffset() {
+ return server.getGameRules().getInt(Molehunt.SHRINKING_STARTING_TIME_OFFSET);
+ }
+
public static SimpleConfig configFile(String fileName) {
return SimpleConfig.of(fileName).provider(Config::defaultConfig).request();
}
@@ -105,7 +115,7 @@ public class Config {
# Shrinking starting offset (in minutes)
# The time before starting to shrink the world borders.
# Default: 10 minutes.
- border_shrinking_starting_offset = 10
+ border_shrinking_starting_time_offset = 10
""";
}
}