Skip to content

Commit

Permalink
Merge remote-tracking branch 'origin/next' into webgpu-true
Browse files Browse the repository at this point in the history
  • Loading branch information
zardoy committed Oct 22, 2024
2 parents bd24709 + 6c994a5 commit 9621179
Show file tree
Hide file tree
Showing 3 changed files with 40 additions and 8 deletions.
24 changes: 20 additions & 4 deletions .github/workflows/preview.yml
Original file line number Diff line number Diff line change
Expand Up @@ -6,22 +6,38 @@ env:
on:
issue_comment:
types: [created]
pull_request:
jobs:
deploy:
runs-on: ubuntu-latest
# todo skip already created deploys on that commit
if: >-
github.event.issue.pull_request != '' &&
(
contains(github.event.comment.body, '/deploy')
github.event.issue.pull_request != '' &&
(
contains(github.event.comment.body, '/deploy')
)
) ||
(
github.event_name == 'pull_request' && (
env.AUTO_DEPLOY_PRS contains $'\n' + toString(github.event.pull_request.number) + $'\n' ||
startsWith(env.AUTO_DEPLOY_PRS, toString(github.event.pull_request.number) + $'\n') ||
endsWith(env.AUTO_DEPLOY_PRS, $'\n' + toString(github.event.pull_request.number)) ||
env.AUTO_DEPLOY_PRS == toString(github.event.pull_request.number)
)
)
permissions:
pull-requests: write
steps:
- name: Checkout
- name: Checkout PR (comment)
uses: actions/checkout@v2
if: github.event_name == 'issue_comment'
with:
ref: refs/pull/${{ github.event.issue.number }}/head
- name: Checkout PR (pull_request)
uses: actions/checkout@v2
if: github.event_name == 'pull_request'

- run: npm i -g [email protected]
- uses: actions/setup-node@v4
with:
Expand Down Expand Up @@ -59,7 +75,7 @@ jobs:
id: alias
env:
ALIASES: ${{ env.ALIASES }}
PULL_URL: ${{ github.event.issue.pull_request.url }}
PULL_URL: ${{ github.event.issue.pull_request.url || github.event.pull_request.url }}
- name: Set deployment alias
if: ${{ steps.alias.outputs.alias != '' && steps.alias.outputs.alias != 'mcraft.fun' && steps.alias.outputs.alias != 's.mcraft.fun' }}
run: vercel alias set ${{ steps.deploy.outputs.stdout }} ${{ steps.alias.outputs.alias }} --token=${{ secrets.VERCEL_TOKEN }} --scope=zaro
23 changes: 19 additions & 4 deletions src/builtinCommands.ts
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ const writeText = (text) => {

const commands: Array<{
command: string[],
invoke (): Promise<void> | void
invoke (args: string[]): Promise<void> | void
//@ts-format-ignore-region
}> = [
{
Expand All @@ -108,18 +108,33 @@ const commands: Array<{
await saveServer(false)
writeText('Saved to browser memory')
}
},
{
command: ['/pos'],
async invoke ([type]) {
let pos: string | undefined
if (type === 'block') {
pos = window.cursorBlockRel()?.position?.toString().slice(1, -1)
} else {
pos = bot.entity.position.toString().slice(1, -1)
}
if (!pos) return
await navigator.clipboard.writeText(pos)
writeText(`Copied position to clipboard: ${pos}`)
}
}
]
//@ts-format-ignore-endregion

export const getBuiltinCommandsList = () => commands.flatMap(command => command.command)

export const tryHandleBuiltinCommand = (message) => {
export const tryHandleBuiltinCommand = (message: string) => {
if (!localServer) return
const [userCommand, ...args] = message.split(' ')

for (const command of commands) {
if (command.command.includes(message)) {
void command.invoke() // ignoring for now
if (command.command.includes(userCommand)) {
void command.invoke(args) // ignoring for now
return true
}
}
Expand Down
1 change: 1 addition & 0 deletions src/globals.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
import EventEmitter from 'events'

window.reportError = window.reportError ?? console.error
window.bot = undefined
window.THREE = undefined
window.localServer = undefined
Expand Down

0 comments on commit 9621179

Please sign in to comment.