Skip to content

Commit da5cba7

Browse files
committed
fix: enable disabled things in region
1 parent aea278c commit da5cba7

1 file changed

Lines changed: 18 additions & 22 deletions

File tree

src/lib/region/index.ts

Lines changed: 18 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -8,14 +8,13 @@ import {
88
world,
99
} from '@minecraft/server'
1010
import { MinecraftEntityTypes, MinecraftItemTypes } from '@minecraft/vanilla-data'
11-
// import { CustomEntityTypes } from 'lib/assets/custom-entity-types'
12-
// import { Items } from 'lib/assets/custom-items'
13-
// import { PlayerEvents, PlayerProperties } from 'lib/assets/player-json'
11+
import { PlayerEvents, PlayerProperties } from 'lib/assets/player-json'
1412
import { ActionbarPriority } from 'lib/extensions/on-screen-display'
1513
import { i18n, noI18n } from 'lib/i18n/text'
16-
// import { onPlayerMove } from 'lib/player-move'
14+
import { onPlayerMove } from 'lib/player-move'
1715
import { is } from 'lib/roles'
1816
import { isNotPlaying } from 'lib/utils/game'
17+
import { createLogger } from 'lib/utils/logger'
1918
import { AbstractPoint } from 'lib/utils/point'
2019
import { Vec } from 'lib/vector'
2120
import { EventSignal } from '../event-signal'
@@ -29,11 +28,7 @@ import {
2928
SWITCHES,
3029
TRAPDOORS,
3130
} from './config'
32-
// import { RegionEvents } from './events'
33-
import { onPlayerMove } from 'lib/player-move'
34-
import { createLogger } from 'lib/utils/logger'
3531
import { RegionEvents } from './events'
36-
import './explosion'
3732
import { Region } from './kinds/region'
3833

3934
export * from './command'
@@ -208,20 +203,21 @@ onPlayerMove.subscribe(({ player, location, dimensionType }) => {
208203

209204
RegionEvents.playerInRegionsCache.set(player, newest)
210205
const currentRegion = newest[0]
211-
// const isPlaying = !isNotPlaying(player)
212-
213-
// const resetNewbie = () => player.setProperty(PlayerProperties['lw:newbie'], !!player.database.survival.newbie)
214-
215-
// if (typeof currentRegion !== 'undefined' && isPlaying) {
216-
// if (currentRegion.permissions.pvp === false) {
217-
// player.triggerEvent(
218-
// player.database.inv === 'spawn' ? PlayerEvents['player:spawn'] : PlayerEvents['player:safezone'],
219-
// )
220-
// player.setProperty(PlayerProperties['lw:newbie'], true)
221-
// } else if (currentRegion.permissions.pvp === 'pve') {
222-
// player.setProperty(PlayerProperties['lw:newbie'], true)
223-
// } else resetNewbie()
224-
// } else resetNewbie()
206+
// TODO Replace with proper damage cancel on beforeEntityHurt once we update
207+
const isPlaying = !isNotPlaying(player)
208+
209+
const resetNewbie = () => player.setProperty(PlayerProperties['lw:newbie'], !!player.database.survival.newbie)
210+
211+
if (typeof currentRegion !== 'undefined' && isPlaying) {
212+
if (currentRegion.permissions.pvp === false) {
213+
player.triggerEvent(
214+
player.database.inv === 'spawn' ? PlayerEvents['player:spawn'] : PlayerEvents['player:safezone'],
215+
)
216+
player.setProperty(PlayerProperties['lw:newbie'], true)
217+
} else if (currentRegion.permissions.pvp === 'pve') {
218+
player.setProperty(PlayerProperties['lw:newbie'], true)
219+
} else resetNewbie()
220+
} else resetNewbie()
225221

226222
EventSignal.emit(RegionEvents.onInterval, { player, currentRegion })
227223
})

0 commit comments

Comments
 (0)