aboutsummaryrefslogtreecommitdiff
path: root/src/main
diff options
context:
space:
mode:
Diffstat (limited to 'src/main')
-rw-r--r--src/main/java/world/anhgelus/molehunt/Game.java25
1 files changed, 10 insertions, 15 deletions
diff --git a/src/main/java/world/anhgelus/molehunt/Game.java b/src/main/java/world/anhgelus/molehunt/Game.java
index b8d7136..300b4c2 100644
--- a/src/main/java/world/anhgelus/molehunt/Game.java
+++ b/src/main/java/world/anhgelus/molehunt/Game.java
@@ -21,18 +21,6 @@ public class Game {
public final int defaultTime = Molehunt.CONFIG.getGameDuration()*60;
private int remaining = defaultTime;
- private Timer borderTimeOffsetTimer = new Timer();
- private final TimerTask borderTimeOffsetTask = 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);
- }
- };
-
private final MinecraftServer server;
private final List<ServerPlayerEntity> moles = new ArrayList<>();
@@ -72,7 +60,16 @@ public class Game {
final var worldBorder = server.getOverworld().getWorldBorder();
worldBorder.setSize(Molehunt.CONFIG.getInitialWorldSize());
if (Molehunt.CONFIG.getBorderShrinkingStartingTimeOffset() < Molehunt.CONFIG.getGameDuration()) {
- borderTimeOffsetTimer.schedule(borderTimeOffsetTask, (long) Molehunt.CONFIG.getBorderShrinkingStartingTimeOffset() * 60 * 1000);
+ 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);
+ }
+ }, (long) Molehunt.CONFIG.getBorderShrinkingStartingTimeOffset() * 60 * 1000);
}
final var title = new TitleS2CPacket(Text.translatable("molehunt.game.start.suspense"));
@@ -135,8 +132,6 @@ public class Game {
timer.cancel();
timer = new Timer();
- borderTimeOffsetTask.cancel();
-
final var worldBorder = server.getOverworld().getWorldBorder();
// Stops the border shrinking.
worldBorder.setSize(worldBorder.getSize());