Skip to content

Commit 41feaa5

Browse files
fix(ravengard): dungeon join dedupe and observable relight
Every queued join fired its own teleport when the dungeon became ready and all but the first crashed on entering the instance the runner was already in, which is what the repeated scheduler exceptions were. Joins now dedupe through a pending set, a runner already inside teleports instead of switching instance, and the relight pass logs its duration and any failure instead of swallowing them, so the next report shows what lighting actually did.
1 parent 17fdd29 commit 41feaa5

2 files changed

Lines changed: 24 additions & 7 deletions

File tree

type.ravengarddungeon/src/main/java/net/swofty/type/ravengarddungeon/game/DungeonInstanceRegistry.java

Lines changed: 16 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -205,9 +205,11 @@ public static DungeonInstance findByIdPrefix(String prefix) {
205205
return null;
206206
}
207207

208+
private static final Set<UUID> PENDING_TELEPORTS = ConcurrentHashMap.newKeySet();
209+
208210
public static void sendPlayerIn(net.minestom.server.entity.Player player, DungeonInstance instance) {
209-
if (instance.getPlayers().contains(player.getUuid()) && !instance.whenReady().isDone()) {
210-
player.sendMessage("§7Your dungeon is still being stamped, hold on...");
211+
if (!PENDING_TELEPORTS.add(player.getUuid())) {
212+
player.sendMessage("§7Your dungeon is still being prepared, hold on...");
211213
return;
212214
}
213215
instance.markPlayerJoined(player.getUuid());
@@ -226,10 +228,18 @@ public static void sendPlayerIn(net.minestom.server.entity.Player player, Dungeo
226228
} else {
227229
spawn = instance.getGenerated().spawn().withY(67);
228230
}
229-
player.setInstance(instance.getInstance(), spawn);
230-
player.sendMessage("§aEntered dungeon §f" + instance.getGameId().toString().substring(0, 8)
231-
+ "§a (" + instance.getGenerated().dungeon().getRoomCount() + " rooms, mode "
232-
+ instance.getMode() + ").");
231+
try {
232+
if (player.getInstance() == instance.getInstance()) {
233+
player.teleport(spawn);
234+
} else {
235+
player.setInstance(instance.getInstance(), spawn);
236+
}
237+
player.sendMessage("§aEntered dungeon §f" + instance.getGameId().toString().substring(0, 8)
238+
+ "§a (" + instance.getGenerated().dungeon().getRoomCount() + " rooms, mode "
239+
+ instance.getMode() + ").");
240+
} finally {
241+
PENDING_TELEPORTS.remove(player.getUuid());
242+
}
233243
}));
234244
}
235245

type.ravengarddungeon/src/main/java/net/swofty/type/ravengarddungeon/generator/RavengardDungeonGenerator.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -127,10 +127,17 @@ public static CompletableFuture<Void> stamp(GeneratedDungeon generated, Instance
127127
// executor and the client renders unlit sections as invisible,
128128
// so lighting is part of readiness
129129
Thread.startVirtualThread(() -> {
130+
long lightingStarted = System.currentTimeMillis();
130131
try {
131132
net.minestom.server.instance.LightingChunk.relight(instance,
132133
new ArrayList<>(instance.getChunks()));
133-
} catch (Exception ignored) {
134+
org.tinylog.Logger.info("Dungeon relight of {} chunks took {}ms",
135+
instance.getChunks().size(),
136+
System.currentTimeMillis() - lightingStarted);
137+
} catch (Exception exception) {
138+
org.tinylog.Logger.error(exception,
139+
"Dungeon relight failed after {}ms",
140+
System.currentTimeMillis() - lightingStarted);
134141
}
135142
future.complete(null);
136143
})))

0 commit comments

Comments
 (0)