aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/client/resources/assets/molehunt/lang/en_us.json3
-rw-r--r--src/client/resources/assets/molehunt/lang/fr_fr.json1
-rw-r--r--src/main/java/world/anhgelus/floodhunt/Floodhunt.java11
-rw-r--r--src/main/java/world/anhgelus/floodhunt/game/Game.java10
4 files changed, 13 insertions, 12 deletions
diff --git a/src/client/resources/assets/molehunt/lang/en_us.json b/src/client/resources/assets/molehunt/lang/en_us.json
index 00c8834..ee20b9a 100644
--- a/src/client/resources/assets/molehunt/lang/en_us.json
+++ b/src/client/resources/assets/molehunt/lang/en_us.json
@@ -13,9 +13,10 @@
"floodhunt.game.end.winners.subtitle": "§6Those who were infected were %s",
"floodhunt.game.start.suspense": "§eYou are...",
"floodhunt.game.start.mole.title": "§cInfected!",
- "floodhunt.game.start.mole.subtitle": "§eGet the list of other infected people with §6/floodhunt role§e.",
+ "floodhunt.game.start.mole.subtitle": "§eGet the list of other infected people with §6/floodhunt role§e and spread the infection.",
"floodhunt.game.start.survivor.title": "§aA survivor!",
"floodhunt.game.start.survivor.subtitle": "§eTry to survive and find out who's infected!",
+ "floodhunt.game.infected": "§cYou are infected.",
"gamerule.floodhunt:game_duration": "Floodhunt: Duration of a game",
"gamerule.floodhunt:flood_percentage": "Floodhunt: Percentage of infected people",
"gamerule.floodhunt:flood_count": "Floodhunt: Number of infected people (set to -1 to use percentage instead)",
diff --git a/src/client/resources/assets/molehunt/lang/fr_fr.json b/src/client/resources/assets/molehunt/lang/fr_fr.json
index 103f165..d932a41 100644
--- a/src/client/resources/assets/molehunt/lang/fr_fr.json
+++ b/src/client/resources/assets/molehunt/lang/fr_fr.json
@@ -16,6 +16,7 @@
"floodhunt.game.start.mole.subtitle": "§eRécupérer la liste des infecté(e)s avec §6/floodhunt role",
"floodhunt.game.start.survivor.title": "§aPas infecté(e)s!",
"floodhunt.game.start.survivor.subtitle": "§eEssayez de survivre et de trouver qui est infecté !",
+ "floodhunt.game.infected": "§cVous êtes infecté(e)s.",
"gamerule.floodhunt:game_duration": "Floodhunt : Durée d'une partie",
"gamerule.floodhunt:flood_percentage": "Floodhunt : Pourcentage d'infecté(e)s",
"gamerule.floodhunt:flood_count": "Floodhunt : Nombre d'infectés (-1 pour utiliser le pourcentage à la place)",
diff --git a/src/main/java/world/anhgelus/floodhunt/Floodhunt.java b/src/main/java/world/anhgelus/floodhunt/Floodhunt.java
index 5dcaf6e..a5f545f 100644
--- a/src/main/java/world/anhgelus/floodhunt/Floodhunt.java
+++ b/src/main/java/world/anhgelus/floodhunt/Floodhunt.java
@@ -4,7 +4,6 @@ import com.mojang.brigadier.Command;
import com.mojang.brigadier.exceptions.SimpleCommandExceptionType;
import net.fabricmc.api.ModInitializer;
import net.fabricmc.fabric.api.command.v2.CommandRegistrationCallback;
-import net.fabricmc.fabric.api.entity.event.v1.ServerLivingEntityEvents;
import net.fabricmc.fabric.api.entity.event.v1.ServerPlayerEvents;
import net.fabricmc.fabric.api.event.lifecycle.v1.ServerLifecycleEvents;
import net.fabricmc.fabric.api.gamerule.v1.GameRuleBuilder;
@@ -17,11 +16,9 @@ import net.minecraft.network.packet.s2c.play.OverlayMessageS2CPacket;
import net.minecraft.server.MinecraftServer;
import net.minecraft.server.command.CommandManager;
import net.minecraft.server.command.ServerCommandSource;
-import net.minecraft.server.network.ServerPlayerEntity;
import net.minecraft.text.Text;
import net.minecraft.util.Formatting;
import net.minecraft.util.Identifier;
-import net.minecraft.world.GameMode;
import net.minecraft.world.rule.GameRule;
import net.minecraft.world.rule.GameRuleCategory;
import org.slf4j.Logger;
@@ -175,16 +172,10 @@ public class Floodhunt implements ModInitializer {
ServerMessageEvents.ALLOW_CHAT_MESSAGE.register((message, sender, params) -> false);
- ServerLivingEntityEvents.AFTER_DEATH.register((entity, damageSource) -> {
- if (!(entity instanceof ServerPlayerEntity) || game == null) return;
- if (!game.started()) return;
- if (game.wonByInfected()) game.end();
- });
-
ServerPlayerEvents.AFTER_RESPAWN.register((oldPlayer, newPlayer, alive) -> {
if (game == null) return;
if (!game.started()) return;
- newPlayer.changeGameMode(GameMode.SPECTATOR);
+ game.onRespawn(newPlayer);
});
ServerPlayConnectionEvents.JOIN.register((handler, sender, server) -> {
diff --git a/src/main/java/world/anhgelus/floodhunt/game/Game.java b/src/main/java/world/anhgelus/floodhunt/game/Game.java
index 868b145..b04b1e9 100644
--- a/src/main/java/world/anhgelus/floodhunt/game/Game.java
+++ b/src/main/java/world/anhgelus/floodhunt/game/Game.java
@@ -121,7 +121,7 @@ public class Game {
end();
}
- public void end() {
+ private void end() {
final var timer = TimerAccess.getTimerFromOverworld(server);
timer.floodhunt_cancel();
@@ -198,4 +198,12 @@ public class Game {
final var payload = new GamePayload(hasStarted);
server.getPlayerManager().sendToAll(ServerPlayNetworking.createS2CPacket(payload));
}
+
+ public void onRespawn(ServerPlayerEntity player) {
+ infected.add(player.getUuid());
+ if (wonByInfected()) end();
+ player.changeGameMode(GameMode.SURVIVAL);
+ player.sendMessage(Text.translatable("floodhunt.game.infected"));
+ player.sendMessage(Text.translatable("floodhunt.game.start.mole.subtitle"));
+ }
}