Skip to content

Commit

Permalink
fix: an issue that caused the dungeon map of the instances being loaded
Browse files Browse the repository at this point in the history
(cherry picked from commit b44fdfc)
  • Loading branch information
Morazzer committed Nov 16, 2024
1 parent af135cc commit 2923a1f
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,7 @@ public class DungeonFeatures {
.expireAfterWrite(45, TimeUnit.MINUTES)
.removalListener(this::removeInstance)
.build();
private long dungeonInstanceCreatorTime = -1;
private CompletableFuture<String> dungeonInstanceCreator;

/**
Expand Down Expand Up @@ -109,6 +110,7 @@ private void onDungeonJoin(String string) {
private void awaitDungeonCreation(DungeonType dungeonType, int floorLevel) {
sendDebugMessage("Awaiting dungeon creation " + dungeonType.name().toLowerCase() + " " + floorLevel);
this.dungeonInstanceCreator = new CompletableFuture<>();
this.dungeonInstanceCreatorTime = System.currentTimeMillis();
PartyUtils.request();
this.dungeonInstanceCreator.whenComplete(this.createDungeon(dungeonType, floorLevel));
}
Expand Down Expand Up @@ -151,13 +153,16 @@ private void setInstance(DungeonInstance dungeonInstance) {
*/
public void startDungeon(String serverId) {
this.exitDungeon();
this.setInstance(this.cache.getIfPresent(serverId));
if (this.dungeonInstanceCreatorTime + 1000 * 20 < System.currentTimeMillis()) {
this.setInstance(this.cache.getIfPresent(serverId));
}
if (this.currentInstance != null) {
sendDebugMessage("Restored dungeon session " + this.currentInstance.serverId());
}
if (this.currentInstance == null && this.dungeonInstanceCreator != null) {
this.dungeonInstanceCreator.complete(serverId);
this.dungeonInstanceCreator = null;
this.dungeonInstanceCreatorTime = -1;
}
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,6 +1,5 @@
package codes.cookies.mod.features.dungeons;

import codes.cookies.mod.utils.cookies.CookiesUtils;
import dev.morazzer.cookies.entities.websocket.Packet;
import dev.morazzer.cookies.entities.websocket.packets.DungeonJoinPacket;
import dev.morazzer.cookies.entities.websocket.packets.DungeonLeavePacket;
Expand Down Expand Up @@ -344,8 +343,6 @@ private void handlePuzzleEntry(Text text, int row) {
* Called every 5 ingame ticks, this should be used to perform various performance intensive methods.
*/
public void periodicalTicks5() {
CookiesUtils.sendMessage(Text.literal("" + (-200+(32 * dungeonMap.getRoomsInX()))), true);

if (this.getPhase() == DungeonPhase.BLOOD &&
(this.getPlayerPosition().x > -200+(32 * dungeonMap.getRoomsInX()) || this.getPlayerPosition().z > -200+(32 * dungeonMap.getRoomsInY()))) {
this.setPhase(DungeonPhase.BOSS);
Expand Down

0 comments on commit 2923a1f

Please sign in to comment.