Skip to content

Commit 8a636cd

Browse files
committed
fix dungeon
1 parent 7bfe8c5 commit 8a636cd

3 files changed

Lines changed: 18 additions & 17 deletions

File tree

src/modules/chat/chat.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -72,7 +72,7 @@ export class Chat {
7272

7373
const messageText = event.message.replace(/\\n/g, '\n').replace(/§./g, '').trim()
7474

75-
const caps = messageText.split('').reduce((p, c) => (c === c.toUpperCase() ? p + 1 : p), 0)
75+
const caps = messageText.split('').reduce((p, c) => (c !== c.toLowerCase() ? p + 1 : p), 0)
7676
if (caps > this.settings.capsLimit) {
7777
return event.sender.fail(noI18n.error`В сообщении слишком много капса (${caps}/${this.settings.capsLimit})`)
7878
}
@@ -85,7 +85,7 @@ export class Chat {
8585
location: event.sender.location,
8686
maxDistance: this.settings.range,
8787
})
88-
.filter(e => e.id !== event.sender.id)
88+
.filter(e => e.id !== event.sender.id && e.dimension.id === event.sender.dimension.id)
8989

9090
// Array with ranged players (include sender id)
9191
const nID = nearPlayers.map(e => e.id)

src/modules/commands/leaderboard.ts

Lines changed: 14 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,10 @@
11
/* i18n-ignore */
22

33
import { Player, world } from '@minecraft/server'
4-
import { ActionForm, BUTTON, Leaderboard, ModalForm } from 'lib'
4+
import { ActionForm } from 'lib/form/action'
5+
import { ModalForm } from 'lib/form/modal'
6+
import { BUTTON } from 'lib/form/utils'
7+
import { Leaderboard, LeaderboardInfo } from 'lib/rpg/leaderboard'
58
import { Vec } from 'lib/vector'
69

710
new Command('leaderboard')
@@ -30,11 +33,7 @@ function info(lb: Leaderboard) {
3033
return lb.info.displayName + '\n' + Vec.string(Vec.floor(lb.info.location))
3134
}
3235

33-
function editLeaderboard(
34-
player: Player,
35-
lb?: Leaderboard,
36-
data: Partial<import('lib').LeaderboardInfo> = lb?.info ?? {},
37-
) {
36+
function editLeaderboard(player: Player, lb?: Leaderboard, data: Partial<LeaderboardInfo> = lb?.info ?? {}) {
3837
const action = lb ? 'Изменить ' : 'Выбрать '
3938
function update() {
4039
if (!lb && isRequired(data)) {
@@ -108,7 +107,6 @@ function editLeaderboard(
108107
data.location = { x, y, z }
109108
}
110109
data.dimension = dimension
111-
if (lb && data.location) lb.entity.teleport(data.location, { dimension: world[dimension] })
112110
update()
113111
})
114112
})
@@ -128,15 +126,18 @@ function editLeaderboard(
128126
})
129127
})
130128

131-
if (lb) form.ask('§cУдалить таблицу лидеров', '§cУдалить', () => lb && lb.remove(), 'Отмена')
129+
if (lb) {
130+
form.button('Переместить к себе', () => {
131+
data.location = Vec.floor(player.location).add(Vec.one.multiply(0.5))
132+
data.dimension = player.dimension.type
133+
update()
134+
})
135+
form.ask('§cУдалить таблицу лидеров', '§cУдалить', () => lb && lb.remove(), 'Отмена')
136+
}
132137

133138
form.show(player)
134139
}
135140

136-
/**
137-
* @param {Partial<import('lib').LeaderboardInfo>} data
138-
* @returns {data is import('lib').LeaderboardInfo}
139-
*/
140-
function isRequired(data: Partial<import('lib').LeaderboardInfo>): data is import('lib').LeaderboardInfo {
141+
function isRequired(data: Partial<LeaderboardInfo>): data is LeaderboardInfo {
141142
return !!data.dimension && !!data.displayName && !!data.location && !!data.objective && !!data.style
142143
}

src/modules/places/dungeons/dungeon.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -319,7 +319,7 @@ export class DungeonRegion extends Region {
319319
private brokenTypeIdsMap = new Map([['evoker', MinecraftEntityTypes.EvocationIllager]])
320320

321321
private spawn(spawner: DungeonSpawner): boolean {
322-
if (!anyPlayerNear(spawner.location, this.dimensionType, 50)) return true
322+
if (!anyPlayerNear(spawner.location, this.dimensionType, 50)) return false
323323

324324
// eslint-disable-next-line prefer-const
325325
for (let { typeId, amount } of spawner.entities) {
@@ -333,7 +333,7 @@ export class DungeonRegion extends Region {
333333
continue
334334
}
335335

336-
const entities = this.dimension.getEntities({ location: spawner.location, maxDistance: 20 })
336+
const entities = this.dimension.getEntities({ location: spawner.location, type: typeId, maxDistance: 20 })
337337
if (entities.length < amount) {
338338
const toSpawn = amount - entities.length
339339
logger.info(

0 commit comments

Comments
 (0)