diff options
| -rw-r--r-- | README.md | 29 | ||||
| -rw-r--r-- | Writerside/topics/configuration.md | 31 | ||||
| -rw-r--r-- | src/client/resources/assets/molehunt/lang/en_us.json | 18 | ||||
| -rw-r--r-- | src/client/resources/assets/molehunt/lang/fr_fr.json | 18 | ||||
| -rw-r--r-- | src/main/java/world/anhgelus/molehunt/Molehunt.java | 17 | ||||
| -rw-r--r-- | src/main/java/world/anhgelus/molehunt/config/Config.java | 39 | ||||
| -rw-r--r-- | src/main/java/world/anhgelus/molehunt/game/Game.java | 23 |
7 files changed, 138 insertions, 37 deletions
@@ -16,33 +16,26 @@ Start the game with `/molehunt start` and enjoy! Every player has the same skin.
-Players' nametag are disabled.
+Players' nametags are disabled.
-The tab, the chat and all message commands (`/msg`, `/tell` and `/w`) are disabled.
+The player list, the chat and the message commands (`/msg`, `/tell` and `/w`) are disabled.
Death and advancement messages are disabled.
-Stop the game when every innocent is dead or when the timer ended (one hour and half).
+World borders are set when starting and slowly shrink over the entire game.
+
+The mod stops the game when every innocent is dead or when the timer ended.
The moles can see the name of other moles with `/molehunt moles`.
-## Configuration
+_Almost_ everything in the mod can configured.
-You can configure every text line and the skin with a resource pack (for reference, check out
-[the default lang file](src/client/resources/assets/molehunt/lang/en_us.json) and [the default
-skin file](src/client/resources/assets/molehunt/textures/skin.png)).
+## Configuration
-Also, more server-side values can be changed in the configuration file, located in your server config directory.
-These settings will be applied by default to every new world.
-If you want to customize only one world, use the gamerules.
+To change most values, you can play with the gamerules added by the mod with the
+`/gamerule` command. Every gamerule introduced by the mod starts with `molehunt:`.
-Every setting can be modified in game with these gamerules:
-- `molehunt:gameDuration`
-- `molehunt:molePercentage`
-- `molehunt:moleCount`
-- `molehunt:showNametags`
-- `molehunt:showTab`
-- `molehunt:showSkins`
+To dive deeper into the configuration, [an online wiki is available](https://www.anhgelus.world/molehunt/configuration.html).
## Technologies
@@ -52,6 +45,6 @@ Every setting can be modified in game with these gamerules: ## Credits
-Creator of the skin used is unknown.
+Creator of the default skin used is unknown.
Thanks @leo-210 for the help!
diff --git a/Writerside/topics/configuration.md b/Writerside/topics/configuration.md index e6fc92a..41c4ff4 100644 --- a/Writerside/topics/configuration.md +++ b/Writerside/topics/configuration.md @@ -6,6 +6,7 @@ The second one modifies the default settings of all your worlds. ## Common concept +### Molehunt game configuration : - Game's duration: `game_duration` (or `gameDuration`). Sets the game's duration in minutes (default: 90). - Percentage of mole: `mole_percentage` (or `molePercentage`). @@ -13,6 +14,8 @@ Sets the percentage of mole (default: 25). - Number of mole: `mole_count` (or `moleCount`). Sets the number of mole (default: -1). If you want to use the percentage of mole instead, set this value to -1. + +### Client-side settings (applies to all players) : - Enable players' nametag: `show_nametags` (or `showNametags`). Players' nametag is visible (default: false). - Enable players' skin: `show_skins` (or `showSkins`). @@ -20,6 +23,11 @@ Players' skin is visible (default: false). - Enable tab: `show_tab` (or `showTab`). Tab can be used (default: false). +### World-border settings : +- World border size when starting the game : `initial_world_size` (or `initialWorldSize`). +- Target border size on the end of the game : `final_world_size` (or `finalWorldSize`). +- Time before moving the borders : `border_moving_starting_time_offset` (or `borderMovingStartingTimeOffsetMinutes`). + Every clientside rules (nametag, skin and tab) are only used by the client during a game. Before and after the game, they are not used. @@ -41,6 +49,9 @@ This is `molehunt.properties`. ```ini # Molehunt mod configuration file +# To regenerate the default configuration, delete, move or rename this file. + +# Game settings # The duration of a molehunt game, in minutes. # Default: 90 minutes (1 hour 30 minutes). @@ -57,6 +68,9 @@ mole_percentage = 25 # Default: -1. mole_count = -1 + +# Client-side settings (applies to all players) + # Show nametags # Default: false show_nametags = false @@ -68,4 +82,21 @@ show_skins = false # Show tab # Default: false show_tab = false + + +# World border settings : + +# Initial world size (in blocks). +# Default: 200 blocks. +initial_world_size = 200 + +# Final world size (in blocks). +# Default: 50 blocks. +final_world_size = 50 + +# Shrinking starting offset (in minutes) +# The time before starting to shrink the world borders. +# If this value is greater than the game duration, borders will never shrink. +# Default: 10 minutes. +border_shrinking_starting_time_offset = 10 ``` diff --git a/src/client/resources/assets/molehunt/lang/en_us.json b/src/client/resources/assets/molehunt/lang/en_us.json index 3a50d81..5896c03 100644 --- a/src/client/resources/assets/molehunt/lang/en_us.json +++ b/src/client/resources/assets/molehunt/lang/en_us.json @@ -12,11 +12,15 @@ "molehunt.game.start.suspense": "§eYou are...", "molehunt.game.start.mole.title": "§cThe Mole!", "molehunt.game.start.mole.subtitle": "§eGet the list of moles with §6/molehunt moles", - "molehunt.game.start.survivor": "§aNot the Mole!", - "gamerule.molehunt:gameDuration": "Duration of a game", - "gamerule.molehunt:molePercentage": "Percentage of Mole", - "gamerule.molehunt:moleCount": "Number of Mole", - "gamerule.molehunt:showNametags": "Show players' nametag", - "gamerule.molehunt:showTab": "Enable the tab", - "gamerule.molehunt:showSkins": "Show players' skin" + "molehunt.game.start.survivor.title": "§aNot the Mole!", + "molehunt.game.start.survivor.subtitle": "§eTry to survive and find out who's the mole!", + "gamerule.molehunt:gameDuration": "Molehunt: Duration of a game", + "gamerule.molehunt:molePercentage": "Molehunt: Percentage of Mole", + "gamerule.molehunt:moleCount": "Molehunt: Number of Mole", + "gamerule.molehunt:showNametags": "Molehunt: Show players' nametag", + "gamerule.molehunt:showTab": "Molehunt: Enable the tab", + "gamerule.molehunt:showSkins": "Molehunt: Show players' skin", + "gamerule.molehunt:initialWorldSize": "Molehunt: Initial world size", + "gamerule.molehunt:finalWorldSize": "Molehunt: Final world size", + "gamerule.molehunt:borderMovingStartingTimeOffsetMinutes": "Molehunt: Time before moving the borders" }
\ No newline at end of file diff --git a/src/client/resources/assets/molehunt/lang/fr_fr.json b/src/client/resources/assets/molehunt/lang/fr_fr.json index bb73ca8..42b4722 100644 --- a/src/client/resources/assets/molehunt/lang/fr_fr.json +++ b/src/client/resources/assets/molehunt/lang/fr_fr.json @@ -12,11 +12,15 @@ "molehunt.game.start.suspense": "§eVous êtes...", "molehunt.game.start.mole.title": "§cLa Taupe !", "molehunt.game.start.mole.subtitle": "§eRécupérer la liste des taupes avec §6/molehunt moles", - "molehunt.game.start.survivor": "§aPas la Taupe!", - "gamerule.molehunt:gameDuration": "Durée d'une partie", - "gamerule.molehunt:molePercentage": "Pourcentage de Taupes", - "gamerule.molehunt:moleCount": "Nombre de Taupes", - "gamerule.molehunt:showNametags": "Affiche les nametags des joueurs", - "gamerule.molehunt:showTab": "Active le tab", - "gamerule.molehunt:showSkins": "Affiche les skins des joueurs" + "molehunt.game.start.survivor.title": "§aPas la taupe!", + "molehunt.game.start.survivor.subtitle": "§eEssaye de survivre et de trouver qui est la taupe !", + "gamerule.molehunt:gameDuration": "Molehunt : Durée d'une partie", + "gamerule.molehunt:molePercentage": "Molehunt : Pourcentage de Taupes", + "gamerule.molehunt:moleCount": "Molehunt : Nombre de Taupes", + "gamerule.molehunt:showNametags": "Molehunt : Affiche les nametags des joueurs", + "gamerule.molehunt:showTab": "Molehunt : Active la liste des joueurs", + "gamerule.molehunt:showSkins": "Molehunt : Affiche les skins des joueurs", + "gamerule.molehunt:initialWorldSize": "Molehunt : Taille initiale du monde", + "gamerule.molehunt:finalWorldSize": "Molehunt : Taille finale du monde", + "gamerule.molehunt:borderMovingStartingTimeOffsetMinutes": "Molehunt : Temps avant de bouger les bordures du monde" }
\ No newline at end of file diff --git a/src/main/java/world/anhgelus/molehunt/Molehunt.java b/src/main/java/world/anhgelus/molehunt/Molehunt.java index afd6960..52399dc 100644 --- a/src/main/java/world/anhgelus/molehunt/Molehunt.java +++ b/src/main/java/world/anhgelus/molehunt/Molehunt.java @@ -41,7 +41,7 @@ public class Molehunt implements ModInitializer { public static final SimpleConfig CONFIG_FILE = Config.configFile(MOD_ID); public static final GameRules.Key<GameRules.IntRule> GAME_DURATION = GameRuleRegistry.register( - MOD_ID +":gameDuration", + MOD_ID +":gameDurationMinutes", GameRules.Category.MISC, GameRuleFactory.createIntRule(CONFIG_FILE.getOrDefault("game_duration", 90)) ); @@ -79,6 +79,21 @@ public class Molehunt implements ModInitializer { CONFIG.sendConfigPayload(); }) ); + public static final GameRules.Key<GameRules.IntRule> INITIAL_WORLD_SIZE = GameRuleRegistry.register( + MOD_ID +":initialWorldSize", + GameRules.Category.MISC, + GameRuleFactory.createIntRule(CONFIG_FILE.getOrDefault("initial_world_size", 200), 0) + ); + public static final GameRules.Key<GameRules.IntRule> FINAL_WORLD_SIZE = GameRuleRegistry.register( + MOD_ID +":finalWorldSize", + GameRules.Category.MISC, + GameRuleFactory.createIntRule(CONFIG_FILE.getOrDefault("final_world_size", 50), 0) + ); + public static final GameRules.Key<GameRules.IntRule> MOVING_STARTING_TIME_OFFSET = GameRuleRegistry.register( + MOD_ID +":borderMovingStartingTimeOffsetMinutes", + GameRules.Category.MISC, + GameRuleFactory.createIntRule(CONFIG_FILE.getOrDefault("border_moving_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 dbaebcf..e1c84a4 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.MOVING_STARTING_TIME_OFFSET); + } + public static SimpleConfig configFile(String fileName) { return SimpleConfig.of(fileName).provider(Config::defaultConfig).request(); } @@ -57,7 +67,10 @@ public class Config { private static String defaultConfig(String s) { return """ # Molehunt mod configuration file + # To regenerate the default configuration, delete, move or rename this file. + # Game settings + # The duration of a molehunt game, in minutes. # Default: 90 minutes (1 hour 30 minutes). game_duration = 90 @@ -73,6 +86,9 @@ public class Config { # Default: -1. mole_count = -1 + + # Client-side settings (applies to all players) + # Show nametags # Default: false show_nametags = false @@ -84,6 +100,23 @@ public class Config { # Show tab # Default: false show_tab = false + + + # World border settings : + + # Initial world size (in blocks). + # Default: 200 blocks. + initial_world_size = 200 + + # Final world size (in blocks). + # Default: 50 blocks. + final_world_size = 50 + + # Moving starting time offset (in minutes) + # The time before starting to move the world borders. + # If this value is greater than the game duration, borders will never move. + # Default: 10 minutes. + border_moving_starting_time_offset = 10 """; } } diff --git a/src/main/java/world/anhgelus/molehunt/game/Game.java b/src/main/java/world/anhgelus/molehunt/game/Game.java index a98516c..a2fdfbb 100644 --- a/src/main/java/world/anhgelus/molehunt/game/Game.java +++ b/src/main/java/world/anhgelus/molehunt/game/Game.java @@ -59,6 +59,21 @@ public class Game { gamerules.get(GameRules.DO_IMMEDIATE_RESPAWN).set(true, server);
gamerules.get(GameRules.DO_ENTITY_DROPS).set(false, server);
+ final var worldBorder = server.getOverworld().getWorldBorder();
+ worldBorder.setSize(Molehunt.CONFIG.getInitialWorldSize());
+ if (Molehunt.CONFIG.getBorderShrinkingStartingTimeOffset() < Molehunt.CONFIG.getGameDuration()) {
+ timer.schedule(new TimerTask() {
+ @Override
+ public void run() {
+ final var worldBorder = server.getOverworld().getWorldBorder();
+ worldBorder.interpolateSize(
+ Molehunt.CONFIG.getInitialWorldSize(),
+ Molehunt.CONFIG.getFinalWorldSize(),
+ (long) (Molehunt.CONFIG.getGameDuration() - Molehunt.CONFIG.getBorderShrinkingStartingTimeOffset()) * 60 * 1000);
+ }
+ }, (long) Molehunt.CONFIG.getBorderShrinkingStartingTimeOffset() * 60 * 1000);
+ }
+
final var title = new TitleS2CPacket(Text.translatable("molehunt.game.start.suspense"));
playerManager.getPlayerList().forEach(p -> {
p.kill();
@@ -78,7 +93,8 @@ public class Game { p.networkHandler.sendPacket(new TitleS2CPacket(Text.translatable("molehunt.game.start.mole.title")));
p.networkHandler.sendPacket(new SubtitleS2CPacket(Text.translatable("molehunt.game.start.mole.subtitle")));
} else {
- p.networkHandler.sendPacket(new TitleS2CPacket(Text.translatable("molehunt.game.start.survivor")));
+ p.networkHandler.sendPacket(new TitleS2CPacket(Text.translatable("molehunt.game.start.survivor.title")));
+ p.networkHandler.sendPacket(new SubtitleS2CPacket(Text.translatable("molehunt.game.start.survivor.subtitle")));
}
// reset health and food level
p.setHealth(p.getMaxHealth());
@@ -118,6 +134,11 @@ public class Game { public void end() {
timer.cancel();
timer = new Timer();
+
+ final var worldBorder = server.getOverworld().getWorldBorder();
+ // Stops the border shrinking.
+ worldBorder.setSize(worldBorder.getSize());
+
changeState(false);
final var pm = server.getPlayerManager();
final var winnerSuspense = new TitleS2CPacket(Text.translatable("molehunt.game.end.suspense.title"));
|
