mirror of
https://code.chipmunk.land/Parker2991/NitoriBot/
synced 2026-11-29 13:45:38 -05:00
added a lot of stuff
This commit is contained in:
+5
-1
@@ -1,8 +1,9 @@
|
||||
# ignore node_modules
|
||||
node_modules
|
||||
|
||||
# ignore js build folder
|
||||
# ignore build folders
|
||||
jsBuild
|
||||
build
|
||||
|
||||
# ignore config
|
||||
config.js
|
||||
@@ -17,3 +18,6 @@ old
|
||||
|
||||
# ignore the gradle build folder
|
||||
gradleBuild
|
||||
|
||||
# ignore the testing folder
|
||||
testing
|
||||
-81
@@ -1,81 +0,0 @@
|
||||
import mc from "minecraft-protocol";
|
||||
import { EventEmitter } from "events";
|
||||
import { Chat } from "./modules/Chat";
|
||||
import fs from "fs";
|
||||
import path from "path";
|
||||
import java from "java";
|
||||
java.classpath.push("nbt-3.2.1.jar");
|
||||
console.log(java)
|
||||
/*net.lenni0451.mcstructs
|
||||
java.classpath.push("commons-lang3-3.19.0.jar");
|
||||
itemRegistry.getMeta(123)
|
||||
.types(ItemType.HELMET)
|
||||
.tags(ItemTag.DAMAGEABLE, ItemTag.MATERIAL_LEATHER)
|
||||
.maxCount(1)
|
||||
.maxDamage(321);
|
||||
*/
|
||||
export class Bot {
|
||||
public static listener = new EventEmitter();
|
||||
|
||||
public static chat: any;
|
||||
|
||||
public static bots: Array<any>
|
||||
|
||||
public static options: any;
|
||||
|
||||
public static entityId: any;
|
||||
|
||||
public static config: any;
|
||||
|
||||
private static loadModules () {
|
||||
new Chat(this)
|
||||
}
|
||||
|
||||
public static Bot (options: any, config: any) {
|
||||
const listeners = Bot.listener;
|
||||
|
||||
Bot.options = {
|
||||
host: options.host ??= "localhost",
|
||||
port: options.port ??= 25565,
|
||||
version: options.version ??= "1.21.8",
|
||||
username: options.username ??= "FNFBoyfriendBot"
|
||||
};
|
||||
|
||||
Bot.config = {
|
||||
prefixes: config.prefixes ??= ["!"],
|
||||
console: {
|
||||
prefix: config.console.prefix ??= "c.",
|
||||
timezone: "America/CHICAGO",
|
||||
},
|
||||
bots: config.bots ??= []
|
||||
}
|
||||
|
||||
Bot.options = options;
|
||||
|
||||
Bot.config = config;
|
||||
|
||||
|
||||
listeners.on("init_client", (packet: any) => {
|
||||
client?.on('packet', (data: any, meta: any) => {
|
||||
listeners.emit("packet", data, meta);
|
||||
listeners.emit("packet." + meta.name, data)
|
||||
});
|
||||
|
||||
client.on('login', (packet: any) => {
|
||||
Bot.entityId = packet.entityId;
|
||||
});
|
||||
|
||||
client?.on("end", (reason: any) => {
|
||||
listeners.emit("end", reason);
|
||||
});
|
||||
});
|
||||
|
||||
const client = mc.createClient(options);
|
||||
|
||||
listeners.emit('init_client', client);
|
||||
Bot.bots = options.bots ?? [listeners];
|
||||
|
||||
this.loadModules()
|
||||
return Bot;
|
||||
}
|
||||
}
|
||||
@@ -1,12 +0,0 @@
|
||||
import { Bot } from "./Bot";
|
||||
|
||||
const config = require('../config.js');
|
||||
|
||||
let bots = [];
|
||||
|
||||
for (const options of config.bots) {
|
||||
//let bot = new Bot.Bot(options, config)//Bot.Bot().Bot//(options, config);
|
||||
let bot = Bot.Bot(options, config)
|
||||
//bot.bots.push(bot);
|
||||
//console.log(bot)
|
||||
}
|
||||
@@ -1,18 +0,0 @@
|
||||
export class Chat {
|
||||
|
||||
public static player (packet = "packet.player_chat") {
|
||||
|
||||
}
|
||||
|
||||
public static system (packet = "packet.system_chat") {
|
||||
|
||||
}
|
||||
|
||||
public static diguised (packet = "packet.profileless_chat") {
|
||||
|
||||
}
|
||||
|
||||
constructor (bot: any) {
|
||||
|
||||
}
|
||||
}
|
||||
@@ -1,13 +0,0 @@
|
||||
{
|
||||
"build": "5010",
|
||||
"codename": {
|
||||
"translate": "%s-%s-%s",
|
||||
"color": "dark_aqua",
|
||||
"with": [
|
||||
{ "text": "Night", "color": "blue" },
|
||||
{ "text": "of", "color": "dark_blue" },
|
||||
{ "text": "Nights", "color": "blue" }
|
||||
]
|
||||
},
|
||||
"version": "v9.0.0-alpha"
|
||||
}
|
||||
+2
-3
@@ -16,10 +16,9 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
implementation("io.github.zucchero-sintattico.typescript-gradle-plugin:io.github.zucchero-sintattico.typescript-gradle-plugin.gradle.plugin:4.5.7")
|
||||
implementation("net.lenni0451.mcstructs:all:3.2.1")
|
||||
}
|
||||
|
||||
typescript {
|
||||
tsConfig = "tsconfig.json"
|
||||
outputDir = "./jsBuild"
|
||||
}
|
||||
outputDir = "./jsBuild/"
|
||||
}
|
||||
|
||||
Generated
+649
-108
File diff suppressed because it is too large
Load Diff
+3
-1
@@ -10,10 +10,12 @@
|
||||
"prismarine-world": "^3.6.3",
|
||||
"smol-toml": "^1.5.2",
|
||||
"socket.io-client": "^4.8.1",
|
||||
"ts-mixer": "^6.0.4",
|
||||
"undici": "^7.18.2",
|
||||
"yaml": "^2.8.2"
|
||||
},
|
||||
"devDependencies": {
|
||||
"@types/node": "^24.10.9"
|
||||
"@types/node": "^24.10.9",
|
||||
"irc-framework": "^4.14.0"
|
||||
}
|
||||
}
|
||||
|
||||
+1
-1
@@ -1 +1 @@
|
||||
rootProject.name = "FNFBoyfriendBot"
|
||||
rootProject.name = "FNFBoyfriendBot"
|
||||
+118
@@ -0,0 +1,118 @@
|
||||
import mc from "minecraft-protocol";
|
||||
import { EventEmitter } from "events";
|
||||
import { Chat } from "./modules/Chat";
|
||||
import { Extras } from "./modules/extrasMessaging/Extras";
|
||||
import { IRC } from "./modules/IRC";
|
||||
import { Position } from "./modules/Position";
|
||||
import { CommandCore } from "./modules/CommandCore"
|
||||
import { Tellraw } from "./modules/Tellraw";
|
||||
import { Reconnect } from "./modules/Reconnect";
|
||||
|
||||
//export const listener = new EventEmitter();
|
||||
|
||||
//export let reconnect: any;
|
||||
|
||||
//export let chat: any
|
||||
|
||||
export class Bot {
|
||||
public static readonly listener = new EventEmitter()
|
||||
|
||||
public static reconnectDelay: any;
|
||||
|
||||
public static reconnect: Reconnect
|
||||
|
||||
public static tellraw: any;
|
||||
|
||||
public static core: CommandCore;
|
||||
|
||||
public static ircClient: any;
|
||||
|
||||
public static irc: IRC;
|
||||
|
||||
public static _client: any;
|
||||
|
||||
public static chat: Chat;
|
||||
|
||||
public static extras: Extras;
|
||||
|
||||
public static bots: Array<any>;
|
||||
|
||||
public static options: any;
|
||||
|
||||
public static entityId: any;
|
||||
|
||||
public static config: any;
|
||||
|
||||
public static position: Position;
|
||||
|
||||
private static loadModules () {
|
||||
this.chat = new Chat();
|
||||
this.extras = new Extras();
|
||||
this.irc = new IRC();
|
||||
this.position = new Position();
|
||||
this.core = new CommandCore();
|
||||
this.tellraw = new Tellraw().tellraw
|
||||
this.reconnect = new Reconnect();
|
||||
}
|
||||
|
||||
private static clearRegistry () {
|
||||
|
||||
}
|
||||
|
||||
private static loadRegistry () {
|
||||
|
||||
}
|
||||
|
||||
public static Bot (options: any, config: any, ircClient: any) {
|
||||
const listener = this.listener;
|
||||
|
||||
this.options = {
|
||||
host: options.host ??= "localhost",
|
||||
port: options.port ??= 25565,
|
||||
version: options.version ??= "1.21.8",
|
||||
username: options.username ??= "FNFBoyfriendBot"
|
||||
};
|
||||
|
||||
this.config = {
|
||||
prefixes: config.prefixes ??= ["!"],
|
||||
console: {
|
||||
prefix: config.console.prefix ??= "c.",
|
||||
timezone: "America/CHICAGO",
|
||||
},
|
||||
bots: config.bots ??= []
|
||||
}
|
||||
|
||||
this.options = options;
|
||||
|
||||
this.config = config;
|
||||
|
||||
this.ircClient = ircClient;
|
||||
|
||||
listener.on("init_client", (client: any) => {
|
||||
client.on('packet', (data: any, meta: any) => {
|
||||
listener.emit("packet", data, meta);
|
||||
listener.emit("packet." + meta.name, data)
|
||||
});
|
||||
|
||||
client.on('login', (packet: any) => {
|
||||
this.entityId = packet.entityId;
|
||||
});
|
||||
|
||||
client.on('error', (error: any) => {})
|
||||
|
||||
client.on("end", (reason: any) => {
|
||||
listener.emit("end", reason);
|
||||
});
|
||||
});
|
||||
|
||||
const client = mc.createClient(options);
|
||||
|
||||
listener.emit('init_client', client);
|
||||
this.bots = options.bots ?? [listener];
|
||||
this._client = client;
|
||||
|
||||
this.loadModules();
|
||||
|
||||
return Bot;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,13 @@
|
||||
import { Bot } from "./Bot";
|
||||
const irc = require('irc-framework');
|
||||
const config = require('../config.js');
|
||||
|
||||
const ircClient = new irc.Client();
|
||||
|
||||
ircClient.connect(config.irc.client);
|
||||
|
||||
let bots = [];
|
||||
|
||||
for (const options of config.bots) {
|
||||
let bot = Bot.Bot(options, config, ircClient)
|
||||
}
|
||||
@@ -0,0 +1,130 @@
|
||||
import { Bot } from "../Bot";
|
||||
import convertNbtComponentToJson from "../util/ConvertNbtComponentToJson";
|
||||
let chatTypes = ''
|
||||
|
||||
function parseChatType (chatTypes: any, type: any, sender: any, target: any, message: any) {
|
||||
const chatType = chatTypes[type]
|
||||
const parsed = convertNbtComponentToJson(null, chatType.value.value.chat)
|
||||
const array: any[] = []
|
||||
for (const parameter of parsed.parameters) {
|
||||
|
||||
switch (parameter) {
|
||||
case "sender": array.push(sender)
|
||||
break;
|
||||
case "target": array.push(target)
|
||||
case "content": array.push(message)
|
||||
break;
|
||||
}
|
||||
}
|
||||
let json = { translate: parsed.translation_key, with: array }
|
||||
|
||||
if (type === 4) json = message
|
||||
|
||||
return json
|
||||
}
|
||||
|
||||
|
||||
export class Chat {
|
||||
private parseMessage () {
|
||||
|
||||
}
|
||||
|
||||
public static getMessageAsPrismarine () {
|
||||
|
||||
}
|
||||
|
||||
public static chatParsers: any; // stub for now
|
||||
|
||||
public player (packet: any): void {
|
||||
const bot = Bot
|
||||
const unsigned = convertNbtComponentToJson(null, packet.unsignedChatContent);
|
||||
const networkName = convertNbtComponentToJson(null, packet.networkName)
|
||||
bot.listener.emit('message', {
|
||||
type: "minecraft:player_chat",
|
||||
message: unsigned
|
||||
})
|
||||
}
|
||||
|
||||
private system (packet: any): void {
|
||||
const bot = Bot
|
||||
const message = convertNbtComponentToJson(null, packet.content);
|
||||
if (
|
||||
message.translate === "advMode.setCommand.success"
|
||||
||
|
||||
message.translate === "multiplayer.message_not_delivered"
|
||||
||
|
||||
packet.isActionBar
|
||||
||
|
||||
message.translate === "advMode.notAllowed"
|
||||
)
|
||||
return;
|
||||
|
||||
bot.listener.emit("message", {
|
||||
type: "minecraft:system_chat",
|
||||
message: message
|
||||
});
|
||||
}
|
||||
|
||||
private diguised (data: any): void {
|
||||
const bot = Bot
|
||||
const sender = convertNbtComponentToJson(null, data.name);
|
||||
const message = convertNbtComponentToJson(null, data.message);
|
||||
const target = convertNbtComponentToJson(null, data.target)
|
||||
const type = data.type.chatType;
|
||||
const parsed = parseChatType(chatTypes, type, sender, target, message)
|
||||
bot.listener.emit('message', {
|
||||
type: "minecraft:disguised_chat",
|
||||
message: parsed
|
||||
})
|
||||
}
|
||||
|
||||
public message (message: any) {
|
||||
const bot = Bot
|
||||
const acc = 0;
|
||||
const bitset = Buffer.allocUnsafe(3);
|
||||
bitset[0] = acc & 0xff;
|
||||
bitset[1] = (acc >> 8) & 0xff;
|
||||
bitset[2] = (acc >> 16) & 0xff;
|
||||
bot._client.write('chat_message', {
|
||||
message: message?.substring(0, 256)?.replaceAll("§", "&"),
|
||||
timestamp: BigInt(Date.now()),
|
||||
salt: BigInt(0),
|
||||
offset: 0,
|
||||
acknowledged: bitset,
|
||||
})
|
||||
}
|
||||
|
||||
public command (command: any) {
|
||||
const bot = Bot;
|
||||
bot._client.write("chat_command", {
|
||||
command: command?.substring(0, 256)?.replaceAll("§", "&"),
|
||||
timestamp: BigInt(Date.now()),
|
||||
salt: BigInt(0),
|
||||
argumentSignatures: [],
|
||||
signedPreview: false,
|
||||
messageCount: 0,
|
||||
acknowledged: Buffer.alloc(3),
|
||||
previousMessages: [],
|
||||
});
|
||||
}
|
||||
|
||||
public static send () {
|
||||
|
||||
}
|
||||
|
||||
constructor () {
|
||||
const bot = Bot;
|
||||
const listener = bot.listener;
|
||||
|
||||
listener.on('packet.registry_data', (packet: any) => {
|
||||
if (packet.id !== 'minecraft:chat_type') return // taken from the 1.21.1 build of my bot that chayapak made
|
||||
chatTypes = packet.entries
|
||||
})
|
||||
|
||||
listener.on("packet.player_chat", this.player);
|
||||
|
||||
listener.on("packet.system_chat", this.system);
|
||||
|
||||
listener.on("packet.profileless_chat", this.diguised);
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,104 @@
|
||||
import { Bot } from "../Bot";
|
||||
const config = require('../../config')
|
||||
|
||||
// i may or may not have used v4's command core for a base here
|
||||
export class CommandCore {
|
||||
public area = {
|
||||
start: config.core.area.start ?? { x: 0, y: 0, z: 0 },
|
||||
end: config.core.area.end ?? { x: 15, y: 0, z: 15 }
|
||||
};
|
||||
|
||||
public position: any;
|
||||
|
||||
public itemPosition: any;
|
||||
|
||||
public currentBlockRelative = { x: 0, y: 0, z: 0 };
|
||||
|
||||
public chatRefill () {
|
||||
const bot = Bot;
|
||||
const pos = this.position;
|
||||
const { start, end } = this.area;
|
||||
|
||||
if (!pos) return;
|
||||
|
||||
bot.chat.command(`minecraft:fill ${pos.x + start.x} ${pos.y + start.y} ${pos.z + start.z} ${pos.x + end.x} ${pos.y + end.y} ${pos.z + end.z} command_block`);
|
||||
};
|
||||
|
||||
public itemRefill () {
|
||||
// will work on this later
|
||||
};
|
||||
|
||||
public move (pos = this.position) {
|
||||
this.position = {
|
||||
x: Math.floor(pos.x / 16) * 16,
|
||||
y: 0,
|
||||
z: Math.floor(pos.z / 16) * 16
|
||||
}
|
||||
|
||||
this.itemPosition = {
|
||||
x: Math.floor(pos.x),
|
||||
y: Math.floor(pos.y - 1),
|
||||
z: Math.floor(pos.z),
|
||||
};
|
||||
|
||||
this.chatRefill();
|
||||
}
|
||||
|
||||
public useCommandBlock (command: any, location: any, mode: any, flags: any) {
|
||||
const bot = Bot
|
||||
bot._client.write("update_command_block", {
|
||||
command: command?.substring(0, 32767),
|
||||
location: location,
|
||||
mode: mode,
|
||||
flags: flags,
|
||||
});
|
||||
};
|
||||
|
||||
public currentBlock () {
|
||||
const relativePosition = this.currentBlockRelative
|
||||
const corePosition = this.position
|
||||
if (!corePosition) return null
|
||||
return { x: relativePosition.x + corePosition.x, y: relativePosition.y + corePosition.y, z: relativePosition.z + corePosition.z }
|
||||
}
|
||||
|
||||
public incrementCurrentBlock () {
|
||||
const relativePosition = this.currentBlockRelative
|
||||
const { start, end } = this.area
|
||||
|
||||
relativePosition.x++
|
||||
|
||||
if (relativePosition.x > end.x) {
|
||||
relativePosition.x = start.x
|
||||
relativePosition.z++
|
||||
}
|
||||
|
||||
if (relativePosition.z > end.z) {
|
||||
relativePosition.z = start.z
|
||||
relativePosition.y++
|
||||
}
|
||||
|
||||
if (relativePosition.y > end.y) {
|
||||
relativePosition.x = start.x
|
||||
relativePosition.y = start.y
|
||||
relativePosition.z = start.z
|
||||
}
|
||||
}
|
||||
|
||||
public run (command: any) {
|
||||
const bot = Bot
|
||||
const location = this.currentBlock()
|
||||
if (!location) return
|
||||
|
||||
bot._client.write('update_command_block', { command, location, mode: 1, flags: 0b100 })
|
||||
|
||||
this.incrementCurrentBlock();
|
||||
}
|
||||
|
||||
constructor () {
|
||||
const bot = Bot
|
||||
bot.listener.on('move', () => {
|
||||
this.move(bot.position)
|
||||
this.run('say meow :3')
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,116 @@
|
||||
import { Bot } from '../Bot';
|
||||
const ChatMessage = require('prismarine-chat')('1.21.9');
|
||||
let queueCount = 0;
|
||||
import version from '../resources/version.json';
|
||||
|
||||
export class IRC {
|
||||
private handleMessages (message: any) {
|
||||
|
||||
}
|
||||
|
||||
private send (message: any) {
|
||||
const bot = Bot;
|
||||
queueCount++
|
||||
const client = bot.ircClient;
|
||||
|
||||
const string = ChatMessage.fromNotch(message.message)?.toString().substring(0, 512);
|
||||
|
||||
const channel = client.channel(bot.options.ircChannel);
|
||||
|
||||
if (queueCount > 4) return
|
||||
else channel.say(string)
|
||||
}
|
||||
|
||||
constructor () {
|
||||
const bot = Bot;
|
||||
const client = bot.ircClient;
|
||||
const options = bot.options;
|
||||
const botCodename = ChatMessage.fromNotch(version.bot.codename)?.toString();
|
||||
const fouCodename = ChatMessage.fromNotch(version.foundation.codename)?.toString();
|
||||
|
||||
client.on('registered', (data: any) => {
|
||||
client.join(options.ircChannel);
|
||||
const channel = client.channel(options.ircChannel);
|
||||
channel.say(`FNFBoyfriendBot ${version.bot.version}-${botCodename} Build: ${version.bot.build}`);
|
||||
channel.say(`${fouCodename} Foundation ${version.foundation.version} Build: ${version.foundation.build}`);
|
||||
});
|
||||
|
||||
client.on('whois', (data: any) => {
|
||||
|
||||
})
|
||||
|
||||
client.on('join', (data: any) => {
|
||||
|
||||
})
|
||||
|
||||
bot.listener.on('message', this.send)
|
||||
|
||||
client.on('message', (data: any) => {
|
||||
const user = data.nick;
|
||||
const message = data.message;
|
||||
|
||||
client.who(options.ircChannel)
|
||||
|
||||
client.on('wholist', (dataa: any) => {
|
||||
const users = dataa.users;
|
||||
const findUser = users.find((a: any) => a.nick === user);
|
||||
console.log(findUser);
|
||||
});
|
||||
|
||||
let component = [];
|
||||
|
||||
component.push(
|
||||
{
|
||||
translate: "[%s] %s \u203a %s",
|
||||
with: [
|
||||
{
|
||||
translate: "%s%s%s %s",
|
||||
bold: false,
|
||||
with: [
|
||||
{
|
||||
text: "FNF",
|
||||
bold: false,
|
||||
color: "blue",
|
||||
},
|
||||
{
|
||||
text: "Boyfriend",
|
||||
bold: false,
|
||||
color: "dark_aqua",
|
||||
},
|
||||
{
|
||||
text: "Bot",
|
||||
bold: false,
|
||||
color: "dark_blue",
|
||||
},
|
||||
{
|
||||
text: "IRC",
|
||||
bold: false,
|
||||
color: "blue"
|
||||
}
|
||||
],
|
||||
},
|
||||
{
|
||||
translate: "<%s>",
|
||||
color: "blue",
|
||||
bold: false,
|
||||
with: [
|
||||
{
|
||||
text: `${user}`,
|
||||
bold: false,
|
||||
color: "dark_blue",
|
||||
}
|
||||
]
|
||||
},
|
||||
message
|
||||
]
|
||||
}
|
||||
) // component totally wasnt taking from Reignite's discord module :tm:
|
||||
|
||||
bot.tellraw("@a", component);
|
||||
});
|
||||
|
||||
setInterval(() => {
|
||||
queueCount = 0;
|
||||
}, 3000)
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,29 @@
|
||||
import { Bot } from '../Bot';
|
||||
export class Position {
|
||||
public x: any;
|
||||
|
||||
public y: any;
|
||||
|
||||
public z: any;
|
||||
|
||||
constructor () {
|
||||
const bot = Bot;
|
||||
const listener = bot.listener;
|
||||
|
||||
listener.on("packet.position", (packet: any) => {
|
||||
this.x = packet.x;
|
||||
this.y = packet.y;
|
||||
this.z = packet.z;
|
||||
|
||||
bot._client.write("teleport_confirm", { teleportId: packet.teleportId });
|
||||
|
||||
listener.emit("move");
|
||||
});
|
||||
|
||||
listener.on("end", () => {
|
||||
this.x = null;
|
||||
this.y = null;
|
||||
this.z = null;
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,19 @@
|
||||
import mc from "minecraft-protocol";
|
||||
import { Bot } from '../Bot';
|
||||
|
||||
export class Reconnect {
|
||||
constructor() {
|
||||
const bot = Bot
|
||||
let client;
|
||||
const options = bot.options
|
||||
bot.reconnectDelay = options.reconnectDelay;
|
||||
|
||||
bot.listener.on("end", () => {
|
||||
setTimeout(() => {
|
||||
client = options.client ?? mc.createClient(options)
|
||||
bot._client = client;
|
||||
bot.listener.emit("init_client", bot._client);
|
||||
}, bot.reconnectDelay);
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
export class SkiBot {
|
||||
|
||||
}
|
||||
@@ -0,0 +1,7 @@
|
||||
import { Bot } from '../Bot';
|
||||
|
||||
export class Tellraw {
|
||||
public tellraw (selector: any, ...message: any): void {
|
||||
Bot.core.run(`minecraft:tellraw ${selector} ` + JSON.stringify(message));
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,41 @@
|
||||
const channels = "extras:register\0extras:unregister\0extras:message\0";
|
||||
import { Bot } from "../../Bot";
|
||||
|
||||
export class Extras {
|
||||
public static channels = [];
|
||||
|
||||
public register (channel: any) {
|
||||
|
||||
}
|
||||
|
||||
public unregister (channel: any) {
|
||||
|
||||
}
|
||||
|
||||
public unregisterAll () {
|
||||
|
||||
}
|
||||
|
||||
public send (channel: any, ...message: any) {
|
||||
const bot = Bot;
|
||||
const buffer = Buffer.from(channel, "utf8");
|
||||
|
||||
buffer[buffer.length - 1]! |= 0x80;
|
||||
|
||||
bot._client.write("custom_payload", {
|
||||
channel: "extras:message",
|
||||
data: Buffer.concat([buffer, Buffer.from(`${message}`, "utf8")])
|
||||
})
|
||||
}
|
||||
|
||||
|
||||
constructor () {
|
||||
const bot = Bot
|
||||
bot.listener.on('packet.login', () => {
|
||||
bot._client.write("custom_payload", {
|
||||
channel: "minecraft:register",
|
||||
data: Buffer.from(channels, "utf8")
|
||||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,20 @@
|
||||
{
|
||||
"bot": {
|
||||
"build": "5010",
|
||||
"codename": {
|
||||
"translate": "%s-%s-%s",
|
||||
"color": "dark_aqua",
|
||||
"with": [
|
||||
{ "text": "Night", "color": "blue" },
|
||||
{ "text": "of", "color": "dark_blue" },
|
||||
{ "text": "Nights", "color": "blue" }
|
||||
]
|
||||
},
|
||||
"version": "v9.0.0-alpha"
|
||||
},
|
||||
"foundation": {
|
||||
"build": "1200",
|
||||
"codename": { "text": "Ultimate", "color": "black" },
|
||||
"version": "v5.0.0-alpha"
|
||||
}
|
||||
}
|
||||
@@ -8,11 +8,11 @@ const BOOLEAN_TYPES = [
|
||||
"strikethrough",
|
||||
"obfuscated",
|
||||
];
|
||||
function convertNbtComponentToJson(key, tag) {
|
||||
export = function convertNbtComponentToJson(key: any, tag: any): any {
|
||||
if (!tag) {
|
||||
return null;
|
||||
} else if (tag.type === "compound") {
|
||||
const object = {};
|
||||
const object: any = {};
|
||||
|
||||
for (const key of Object.keys(tag.value)) {
|
||||
object[key === "" ? "text" : key] = convertNbtComponentToJson(
|
||||
@@ -62,4 +62,3 @@ function convertNbtComponentToJson(key, tag) {
|
||||
return { text: "" };
|
||||
}
|
||||
}
|
||||
module.exports = convertNbtComponentToJson;
|
||||
+12
-3
@@ -1,12 +1,21 @@
|
||||
{
|
||||
"exclude": ["./build", "./config.js", "./convertYaodesHardcode.js", "./old", "./jsBuild"],
|
||||
"exclude": [
|
||||
"./build",
|
||||
"./config.js",
|
||||
"./old",
|
||||
"./jsBuild",
|
||||
"./SkiBot",
|
||||
"./extrasRecieving.js",
|
||||
"./Recieving.ts",
|
||||
"./testing/*"
|
||||
],
|
||||
"compilerOptions": {
|
||||
"useUnknownInCatchVariables": false,
|
||||
"rootDir": "./bot",
|
||||
"rootDir": "./src",
|
||||
"outDir": "./jsBuild",
|
||||
"module": "commonjs",
|
||||
"allowJs": true,
|
||||
"target": "es2022",
|
||||
"target": "es6",
|
||||
"types": ["node"],
|
||||
"sourceMap": false,
|
||||
"declaration": false,
|
||||
|
||||
Reference in New Issue
Block a user