aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
authoranhgelus <anhgelus.morhtuuzh@proton.me>2024-08-23 22:26:50 +0000
committeranhgelus <anhgelus.morhtuuzh@proton.me>2024-08-23 22:26:50 +0000
commit6401c130571f5dbd069cd04e7b1c58fb97d6de08 (patch)
treeec518a7af5bf33f6867cdaf0f82276484342e57c /src/main
parent191d51a2c337d37a83d6076abf5c67c76f6235b7 (diff)
fix(game): ending game just after the start
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/world/anhgelus/molehunt/Game.java4
-rw-r--r--src/main/java/world/anhgelus/molehunt/Molehunt.java3
2 files changed, 4 insertions, 3 deletions
diff --git a/src/main/java/world/anhgelus/molehunt/Game.java b/src/main/java/world/anhgelus/molehunt/Game.java
index 89ee9b3..ce6f335 100644
--- a/src/main/java/world/anhgelus/molehunt/Game.java
+++ b/src/main/java/world/anhgelus/molehunt/Game.java
@@ -89,7 +89,6 @@ public class Game {
// reset time and weather
server.getOverworld().setTimeOfDay(0);
server.getOverworld().resetWeather();
-
started = true;
timer.scheduleAtFixedRate(new TimerTask() {
@@ -137,6 +136,7 @@ public class Game {
pm.sendToAll(new SubtitleS2CPacket(Text.translatable("molehunt.game.end.winners.subtitle").append(getMolesAsString())));
pm.sendToAll(winner);
pm.sendToAll(timing);
+ moles.clear();
}
}, 4*1000);
}
@@ -158,7 +158,7 @@ public class Game {
}
public boolean isAMole(ServerPlayerEntity player) {
- return hasStarted() && moles.contains(player);
+ return moles.contains(player);
}
public boolean gameWonByMoles() {
diff --git a/src/main/java/world/anhgelus/molehunt/Molehunt.java b/src/main/java/world/anhgelus/molehunt/Molehunt.java
index 7a55450..c6ce7c7 100644
--- a/src/main/java/world/anhgelus/molehunt/Molehunt.java
+++ b/src/main/java/world/anhgelus/molehunt/Molehunt.java
@@ -102,7 +102,7 @@ public class Molehunt implements ModInitializer {
if (game == null || !game.hasStarted()) {
player.networkHandler.sendPacket(new OverlayMessageS2CPacket(
- Text.translatable("commands.molehunt.stop.failed").setStyle(Style.EMPTY.withColor(16733525))
+ Text.translatable("commands.molehunt.stop.failed").setStyle(Style.EMPTY.withColor(16733525))
));
} else {
player.networkHandler.sendPacket(new OverlayMessageS2CPacket(Text.of(game.getShortRemainingText())));
@@ -144,6 +144,7 @@ public class Molehunt implements ModInitializer {
ServerLivingEntityEvents.AFTER_DEATH.register((entity, damageSource) -> {
if (!(entity instanceof ServerPlayerEntity) || game == null) return;
+ if (!game.hasStarted()) return;
if (game.gameWonByMoles()) game.end();
});