blob: 05b6ab842162a48d34a5b2f59c810892a8ac3ab8 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
|
import * as vscode from 'vscode';
export function activate(context: vscode.ExtensionContext) {
let disposable = vscode.commands.registerCommand('neudevtools.encodeSkull', async () => {
const answer = await vscode.window.showInputBox({
prompt: "Enter the texture id or skin url"
});
if (!answer) {
vscode.window.showErrorMessage("Please input a skin texture id");
return;
}
let url;
if (!answer.startsWith("http://") && !answer.startsWith("https://")) {
url = `http://textures.minecraft.net/texture/${answer}`;
} else {
url = answer;
}
const toEncode = `{"textures":{"SKIN":{"url":${JSON.stringify(url)}}}}`;
console.log(`Encoding : ${toEncode}`);
const encoded = Buffer.from(toEncode).toString('base64');
console.log(`Encoded: ${encoded}`);
await vscode.window.activeTextEditor?.insertSnippet(new vscode.SnippetString().appendText(encoded));
});
context.subscriptions.push(disposable);
}
export function deactivate() { }
|