Skip to content

Commit 7bfe8c5

Browse files
committed
fix
1 parent 34b532c commit 7bfe8c5

1 file changed

Lines changed: 14 additions & 4 deletions

File tree

src/modules/places/dungeons/dungeon.ts

Lines changed: 14 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -73,7 +73,10 @@ export class DungeonRegion extends Region {
7373
dungeon.ldb.spawnerCooldowns ??= {}
7474
const cooldown = dungeon.ldb.spawnerCooldowns[spawner.id]
7575
if (!cooldown || Cooldown.isExpired(cooldown, spawner.restoreTime)) {
76-
if (dungeon.spawn(spawner)) dungeon.ldb.spawnerCooldowns[spawner.id] = Date.now()
76+
if (dungeon.spawn(spawner)) {
77+
dungeon.ldb.spawnerCooldowns[spawner.id] = Date.now()
78+
dungeon.save()
79+
}
7780
}
7881
}
7982

@@ -192,6 +195,12 @@ export class DungeonRegion extends Region {
192195
form.button(noI18n`Снова установить структуру`, () => {
193196
this.placeStructure()
194197
})
198+
form.button(noI18n`Сбросить кд`, () => {
199+
this.ldb.spawnerCooldowns = {}
200+
this.ldb.chests = {}
201+
this.save()
202+
player.success()
203+
})
195204
}
196205

197206
customFormDescription(player: Player): Text.Table {
@@ -309,8 +318,8 @@ export class DungeonRegion extends Region {
309318

310319
private brokenTypeIdsMap = new Map([['evoker', MinecraftEntityTypes.EvocationIllager]])
311320

312-
private spawn(spawner: DungeonSpawner) {
313-
if (!anyPlayerNear(spawner.location, this.dimensionType, 50)) return
321+
private spawn(spawner: DungeonSpawner): boolean {
322+
if (!anyPlayerNear(spawner.location, this.dimensionType, 50)) return true
314323

315324
// eslint-disable-next-line prefer-const
316325
for (let { typeId, amount } of spawner.entities) {
@@ -333,13 +342,13 @@ export class DungeonRegion extends Region {
333342
for (let i = 0; i < toSpawn; i++) {
334343
try {
335344
this.dimension.spawnEntity(type, spawner.location)
336-
return true
337345
} catch (e) {
338346
logger.error('spawn', e)
339347
}
340348
}
341349
}
342350
}
351+
return true
343352
}
344353

345354
private chests: DungeonChest[] = []
@@ -369,6 +378,7 @@ export class DungeonRegion extends Region {
369378
if (!block?.isValid) return
370379

371380
this.ldb.chests[chest.id] = Date.now()
381+
this.save()
372382

373383
if (block.typeId !== MinecraftBlockTypes.Chest) block.setType(MinecraftBlockTypes.Chest)
374384

0 commit comments

Comments
 (0)