-
Notifications
You must be signed in to change notification settings - Fork 20
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
* Reworked showvanilla files * Removed unnesscary trigger
- Loading branch information
Showing
10 changed files
with
233 additions
and
176 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -4,7 +4,6 @@ name: PR | |
|
||
on: | ||
push: {} | ||
pull_request: {} | ||
workflow_dispatch: {} | ||
|
||
jobs: | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,42 @@ | ||
import path from "path"; | ||
import { commands, ExtensionContext, Uri, window } from "vscode"; | ||
import { Commands, GetBedrockInstallationFolder } from "@blockception/shared"; | ||
import { Glob } from "../../Glob"; | ||
import { commands, ExtensionContext, Uri, window, workspace } from "vscode"; | ||
import { Commands } from "@blockception/shared"; | ||
import { GithubFiles } from "bc-minecraft-bedrock-vanilla-data/lib/src/Lib/Vanilla/sources"; | ||
import fetch, { RequestInit } from "node-fetch"; | ||
|
||
export function Activate(context: ExtensionContext): void { | ||
context.subscriptions.push(commands.registerCommand(Commands.ShowVanillaFile, ShowVanillaFile)); | ||
} | ||
async function ShowVanillaFile(args: any) { | ||
const source = GithubFiles.source; | ||
const files = GithubFiles.files; | ||
|
||
function ShowVanillaFile(args: any) { | ||
const dir = path.join(GetBedrockInstallationFolder(), "data"); | ||
const files = Glob.GetFiles(["{behavior_packs,resource_packs}/vanilla**/**/*.json"], ["behavior_trees", "contents.json"], dir); | ||
if (files.length === 0) { | ||
return; | ||
} | ||
|
||
if (files.length === 0) { | ||
window.showErrorMessage("No vanilla files found"); | ||
return; | ||
} | ||
window.showQuickPick(files).then((filepath) => { | ||
if (!filepath) { | ||
return; | ||
} | ||
|
||
const options: Record<string, string> = {}; | ||
|
||
files.forEach((file) => { | ||
const key = path.basename(file); | ||
options[key] = file; | ||
}); | ||
const uri = Uri.parse(source + filepath); | ||
const options: RequestInit = { | ||
method: "GET", | ||
redirect: "error", | ||
}; | ||
|
||
const keys = Object.keys(options); | ||
keys.sort(); | ||
console.log("Downloading vanilla file", filepath) | ||
return fetch(uri.toString(), options) | ||
.then(data => data.text()) | ||
.then(text => { | ||
workspace.openTextDocument({ language: "json", content: text }).then(doc => window.showTextDocument(doc)) | ||
}) | ||
.catch(err => { | ||
window.showErrorMessage("Failed to download vanilla file", filepath as string, JSON.stringify(err)); | ||
}).finally(() => { | ||
console.log("Downloaded vanilla file", filepath) | ||
}); | ||
|
||
window.showQuickPick(keys).then((key) => { | ||
if (key) { | ||
let file = options[key]; | ||
if (file) { | ||
const uri = Uri.file(file); | ||
}); | ||
} | ||
|
||
window.showTextDocument(uri, { preview: false }); | ||
} | ||
} | ||
}); | ||
context.subscriptions.push(commands.registerCommand(Commands.ShowVanillaFile, ShowVanillaFile)); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
This file was deleted.
Oops, something went wrong.
Submodule minecraft-bedrock-schemas
updated
1 files
+6 −0 | source/behavior/entities/format/components/projectile.json |
Oops, something went wrong.