Skip to content

Commit

Permalink
fix: fix warps support
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy committed Mar 21, 2024
1 parent e1053b7 commit ce9dd8d
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 3 deletions.
4 changes: 4 additions & 0 deletions src/lib/modules/tabComplete.ts
Original file line number Diff line number Diff line change
Expand Up @@ -122,6 +122,10 @@ export const player = function (player: Player, serv: Server, options: Options)
serv.tabComplete.add('item_enchantment', () => {
return ['unbreaking', 'silk_touch', 'fortune']
})

serv.tabComplete.add('warps', () => {
return serv.warps.map(w => w.name)
})
}
declare global {
interface Server {
Expand Down
5 changes: 3 additions & 2 deletions src/lib/modules/warps.ts
Original file line number Diff line number Diff line change
Expand Up @@ -54,6 +54,7 @@ export const server = async function (serv: Server, options: Options) {
info: 'Teleport to a warp',
usage: '/warp [set] <name>',
op: true,
tab: ['warps', 'warps'],
commandBlock: false,
parse (string, ctx) {
// todo worlds support
Expand All @@ -62,7 +63,7 @@ export const server = async function (serv: Server, options: Options) {
return { name, set: true }
}
const warp = serv.warps.find(w => w.name === string)
if (!warp) return
if (!warp) return false
return { name: warp.name }
},
async action ({ name, set }, { player }) {
Expand All @@ -80,7 +81,7 @@ export const server = async function (serv: Server, options: Options) {
player.teleport(new Vec3(warp.x, warp.y, warp.z))
if (warp.yaw) player.yaw = warp.yaw
if (warp.pitch) player.pitch = warp.pitch
return true
player.chat(`Teleported to ${name}. Press ctrl+a if nothing appears on your screen.`)
}
})
}
Expand Down
3 changes: 2 additions & 1 deletion src/lib/modules/world.ts
Original file line number Diff line number Diff line change
Expand Up @@ -458,7 +458,8 @@ export const usedServerPathsV1 = [
'region',
'level.dat',
'playerdata',
'Warp files'
'Warp files',
'icon.png'
]

declare global {
Expand Down

0 comments on commit ce9dd8d

Please sign in to comment.