diff options
| author | Léo Kosman <leo.kosman@proton.me> | 2024-08-24 18:37:21 +0200 |
|---|---|---|
| committer | Léo Kosman <leo.kosman@proton.me> | 2024-08-24 18:37:21 +0200 |
| commit | 06027e9cd2b71a9606fb38dbde261cc629a68cc1 (patch) | |
| tree | dff72ec2c10976920df24b690f0305b03e28db93 /src/main/java/world | |
| parent | 7f60288c07c356616fdee270ece7b2a625dcfdd1 (diff) | |
perf: do not recycle timer task because somehow it's actually better ? idk anymore
Diffstat (limited to 'src/main/java/world')
| -rw-r--r-- | src/main/java/world/anhgelus/molehunt/Game.java | 25 |
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());
|
