diff options
| author | anhgelus <anhgelus.morhtuuzh@proton.me> | 2024-08-23 13:49:13 +0000 |
|---|---|---|
| committer | anhgelus <anhgelus.morhtuuzh@proton.me> | 2024-08-23 13:49:13 +0000 |
| commit | a39de9ad78f0e3b4b03453dc3f5da0b649f69288 (patch) | |
| tree | 00c322f63fb624d354c184289eaef99c6f350c56 | |
| parent | 909f9ed08454a26e3c42d2cfcf9338cded41c8fb (diff) | |
feat(config): config for nametag, skins and tab
3 files changed, 26 insertions, 7 deletions
diff --git a/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java b/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java index 5f6b735..7770a1b 100644 --- a/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java +++ b/src/client/java/world/anhgelus/molehunt/client/MolehuntClient.java @@ -16,8 +16,8 @@ public class MolehuntClient implements ClientModInitializer { try (final var client = context.client()) { client.execute(() -> { SHOW_SKINS = payload.showSkins(); - SHOW_NAMETAGS = payload.showNametag(); - SHOW_TAB = payload.showNametag(); + SHOW_NAMETAGS = payload.showNametags(); + SHOW_TAB = payload.showTab(); }); } }); diff --git a/src/main/java/world/anhgelus/molehunt/config/Config.java b/src/main/java/world/anhgelus/molehunt/config/Config.java index a396a39..9edfc1b 100644 --- a/src/main/java/world/anhgelus/molehunt/config/Config.java +++ b/src/main/java/world/anhgelus/molehunt/config/Config.java @@ -4,6 +4,9 @@ public class Config { public final int gameDuration; public final double molePercentage; public final int moleCount; + public final boolean showNametags; + public final boolean showTab; + public final boolean showSkins; public Config(String fileName) { final SimpleConfig CONFIG = SimpleConfig.of(fileName).provider(Config::defaultConfig).request(); @@ -12,6 +15,10 @@ public class Config { gameDuration = CONFIG.getOrDefault("game_duration", 90) * 60; molePercentage = CONFIG.getOrDefault("mole_percentage", 25); moleCount = CONFIG.getOrDefault("mole_count", -1); + // bool + showNametags = CONFIG.getOrDefault("show_nametags", false); + showSkins = CONFIG.getOrDefault("show_skins", false); + showTab = CONFIG.getOrDefault("show_tab", false); } private static String defaultConfig(String s) { @@ -19,19 +26,31 @@ public class Config { # Molehunt mod configuration file # The duration of a molehunt game, in minutes. - # Default : 90 minutes (1 hour 30 minutes). + # Default: 90 minutes (1 hour 30 minutes). game_duration = 90 # Mole percentage. # For example, a mole percentage of 25% will get 1 mole every 4 players. - # Default : 25 %. + # Default: 25 %. mole_percentage = 25 # Mole count (absolute). # This setting will overwrite the mole_percentage setting. # If set below 0, this setting is disabled. - # Default : -1. + # Default: -1. mole_count = -1 + + # Show nametags + # Default: false + show_nametags = false + + # Show skins + # Default: false + show_skins = false + + # Show tab + # Default: false + show_tab = false """; } } diff --git a/src/main/java/world/anhgelus/molehunt/config/ConfigPayload.java b/src/main/java/world/anhgelus/molehunt/config/ConfigPayload.java index a884c9a..0123e74 100644 --- a/src/main/java/world/anhgelus/molehunt/config/ConfigPayload.java +++ b/src/main/java/world/anhgelus/molehunt/config/ConfigPayload.java @@ -7,12 +7,12 @@ import net.minecraft.network.packet.CustomPayload; import net.minecraft.util.Identifier;
import world.anhgelus.molehunt.Molehunt;
-public record ConfigPayload(boolean showNametag, boolean showSkins, boolean showTab) implements CustomPayload {
+public record ConfigPayload(boolean showNametags, boolean showSkins, boolean showTab) implements CustomPayload {
public static final Identifier CONFIG_PACKET_ID = Identifier.of(Molehunt.MOD_ID, "config");
public static final CustomPayload.Id<ConfigPayload> ID = new CustomPayload.Id<>(CONFIG_PACKET_ID);
public static final PacketCodec<RegistryByteBuf, ConfigPayload> CODEC = PacketCodec.tuple(
- PacketCodecs.BOOL, ConfigPayload::showNametag,
+ PacketCodecs.BOOL, ConfigPayload::showNametags,
PacketCodecs.BOOL, ConfigPayload::showSkins,
PacketCodecs.BOOL, ConfigPayload::showTab,
ConfigPayload::new
|
