aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to 'src')
-rw-r--r--src/main/java/world/anhgelus/molehunt/Game.java24
-rw-r--r--src/main/java/world/anhgelus/molehunt/config/Config.java1
2 files changed, 25 insertions, 0 deletions
diff --git a/src/main/java/world/anhgelus/molehunt/Game.java b/src/main/java/world/anhgelus/molehunt/Game.java
index dbe7ebd..b6c0338 100644
--- a/src/main/java/world/anhgelus/molehunt/Game.java
+++ b/src/main/java/world/anhgelus/molehunt/Game.java
@@ -21,6 +21,8 @@ public class Game {
public final int defaultTime = Molehunt.CONFIG.getGameDuration()*60;
private int remaining = defaultTime;
+ private Timer borderTimeOffsetTime = new Timer();
+
private final MinecraftServer server;
private final List<ServerPlayerEntity> moles = new ArrayList<>();
@@ -57,6 +59,20 @@ 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()) {
+ borderTimeOffsetTime.schedule(new TimerTask() {
+ @Override
+ public void run() {
+ worldBorder.interpolateSize(
+ Molehunt.CONFIG.getInitialWorldSize(),
+ Molehunt.CONFIG.getFinalWorldSize(),
+ (long) (Molehunt.CONFIG.getGameDuration() - Molehunt.CONFIG.getBorderShrinkingStartingTimeOffset()) * 60 * 60);
+ }
+ }, (long) Molehunt.CONFIG.getBorderShrinkingStartingTimeOffset() * 60 * 60);
+ }
+
final var title = new TitleS2CPacket(Text.translatable("molehunt.game.start.suspense"));
playerManager.getPlayerList().forEach(p -> {
p.kill();
@@ -116,6 +132,14 @@ public class Game {
public void end() {
timer.cancel();
timer = new Timer();
+
+ borderTimeOffsetTime.cancel();
+ borderTimeOffsetTime = new Timer();
+
+ final var worldBorder = server.getOverworld().getWorldBorder();
+ // Stops the border shrinking.
+ worldBorder.setSize(worldBorder.getSize());
+
started = false;
final var pm = server.getPlayerManager();
final var winnerSuspense = new TitleS2CPacket(Text.translatable("molehunt.game.end.suspense.title"));
diff --git a/src/main/java/world/anhgelus/molehunt/config/Config.java b/src/main/java/world/anhgelus/molehunt/config/Config.java
index b42a469..3f22df3 100644
--- a/src/main/java/world/anhgelus/molehunt/config/Config.java
+++ b/src/main/java/world/anhgelus/molehunt/config/Config.java
@@ -114,6 +114,7 @@ public class Config {
# 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
""";