Skip to content
This repository has been archived by the owner on Jul 22, 2024. It is now read-only.

Commit

Permalink
Update shit
Browse files Browse the repository at this point in the history
  • Loading branch information
TrashyKitty committed Apr 15, 2024
1 parent b2b0577 commit 0fca0c9
Show file tree
Hide file tree
Showing 3 changed files with 144 additions and 6 deletions.
91 changes: 91 additions & 0 deletions assets/dev_assets/index.html
Original file line number Diff line number Diff line change
@@ -0,0 +1,91 @@
<html>
<head>
<title>Azalea Dev Server</title>
</head>
<body>
<div class="input-area">
<input placeholder="Command">
<button>Send command</button>
</div>
<br>
<textarea disabled="disabled"></textarea>
<br>
<br>
<div align="center" class="text">
🌱🌺 Azalea, made by TheLegendaryTrashCan 🌺🌱
</div>
<style>
body {
background: #222;
}
.input-area {
padding: 1em;
background: #333;
border-radius: 10px;
display: flex;
align-items: center;
justify-content: center;
gap: 10px;
}
.text {
color: #777;
font-family: Arial, Helvetica, sans-serif;
font-style: oblique;
}
button {
background: #AB87FF;
border-radius: 10px;
border: 0;
padding: 0.5em 1em;
cursor: pointer;
color: white;
transition: all 250ms ease;
}
button:hover {
background: #9B70FF;
}
button:active {
background: #8D5CFF;
}
input {
color: white;
padding: 0.5em 1em;
border-radius: 10px;
box-sizing: border-box;
background: #222;
border: 1px solid #777;
outline: 0;
transition: all 250ms ease;
}
textarea {
width: 100%;
resize: none;
height: 80vh;
border-radius: 10px;
background: #333;
border: 1px solid #444;
color: #aaa;
}
input:focus {
border: 1px solid #AB87FF;
}
</style>
<script src="https://cdn.socket.io/4.7.5/socket.io.min.js" integrity="sha384-2huaZvOR9iDzHqslqwpR87isEmrfxqyWOF7hr7BY6KG0+hVKLoEXMPUJw3ynWuhO" crossorigin="anonymous"></script>
<script>
const socket = io();
document.querySelector('textarea').value = ``
socket.on('logger', data=>{
if(`${data}\n`.includes("No targets matched selector") || `${data}\n`.includes("too many tags") || `${data}\n`.includes("Could not op")) return;
document.querySelector('textarea').value += `${data}\n`
document.querySelector('textarea').scrollTop += document.querySelector('textarea').scrollHeight;
})
document.querySelector('button').addEventListener('click', e=>{
let search = new URLSearchParams();
search.set('command', document.querySelector('input').value);
fetch(`/run-command?${search.toString()}`).then(res=>{

})
})
</script>
</body>
</html>
53 changes: 48 additions & 5 deletions gulpfile.js
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,54 @@ const MediaFire = require('mediafire');
const webhooks = require('discord-webhook-node');
const axios = require('axios').default;
const supabase = require('@supabase/supabase-js');
const express = require('express');
gulp.task("dev", function (cb) {
const bedrockServer = require('./minecraft-bedrock-server/src/index')
// const bedrockServer = require('minecraft-bedrock-server')

const fs = require('fs');
let server2;
const onStart = () => {
let buildConfig = YAML.parse(fs.readFileSync('azalea-build-config.yaml').toString());
let app = express();
const httpserver = require('http').createServer(app);
const bedrock = require('bedrock-protocol');
const bpClient = bedrock.createClient({
host: '127.0.0.1', // optional
port: buildConfig.dev_server.port, // optional, default 19132
skipPing: true,
username: 'azaleadevbot', // the username you want to join as, optional if online mode
offline: true // optional, default false. if true, do not login with Xbox Live. You will not be asked to sign-in if set to true.
})
const io = require('socket.io')(httpserver);
io.on('connection', socket=>{
server2.stdout.on('data', (data)=>{
socket.emit('logger', `${data}`);
})
server2.stderr.on('data', (data)=>{
socket.emit('logger', `${data}`);
})
bpClient.on('text', packet=>{
socket.emit('text_packet', packet)
})
})
app.get('/',(req,res)=>{
res.sendFile(__dirname+'/assets/dev_assets/index.html')
})
app.get('/api/stop', (req,res)=>{
server2.stdin.setEncoding('utf-8');
server2.stdin.write("stop\n")
httpserver.close();
res.send('Server Stopped!');
})
app.get('/run-command', (req,res)=>{
if(!req.query.command) return;
server2.stdin.setEncoding('utf-8');
server2.stdin.write(`${req.query.command}\n`)
res.send('Server Stopped!');
})
httpserver.listen(buildConfig.dev_server.http, ()=>{
console.log("DEV SERVER STARTED ON PORT " + buildConfig.dev_server.http.toString())
});
gulp.watch("src/**/*.js", (cb) => {

// server2.stdin.emit("data", "say hi\r\n")
Expand Down Expand Up @@ -58,7 +99,7 @@ gulp.task("dev", function (cb) {
let buildConfig = YAML.parse(fs.readFileSync('azalea-build-config.yaml').toString());
let resourceManifest = require(`${buildConfig.resourcePath}/manifest.json`);
let otherZip = new admzip();
if (!fs.existsSync('bds/worlds/world')) {
if (!fs.existsSync('bds/worlds/world/level.dat')) {
zip.addFile("world_behavior_packs.json", Buffer.from(JSON.stringify([{
"pack_id": behaviorManifest.header.uuid,
"version": behaviorManifest.header.version
Expand Down Expand Up @@ -439,22 +480,24 @@ gulp.task("dev", function (cb) {
zip2.extractAllTo(`bds/development_resource_packs/azalea`, true)
fs.writeFileSync(`bds/server.properties`, fs.readFileSync('server.properties'));
let server3 = bedrockServer.startServer('1.20.72', onStart, {
'server-port': 19155,
'server-portv6': 19156,
'online-mode': true,
'server-port': buildConfig.dev_server.port,
'server-portv6': buildConfig.dev_server.portv6,
'online-mode': false,
path: './bds',
'level-name': 'world',
'default-player-permission-level': 'operator',
'allow-cheats': true,
'gamemode': 'creative',
'difficulty': 'peaceful',
'server-name': '§bAzalea §bDev',

}).then(proc => {
setInterval(()=>{
server2.stdin.setEncoding('utf-8');
server2.stdin.write("op @a\n")
server2.stdin.setEncoding('utf-8');
server2.stdin.write("tag @a add admin\n")
server2.stdin.write("tag @a[name=azaleadevbot] add azalea-bot\n")

},1000);
server2 = proc;
Expand Down
6 changes: 5 additions & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -17,14 +17,18 @@
"adm-zip": "^0.5.12",
"axios": "^1.6.8",
"babel-plugin-wildcard": "^7.0.0",
"bedrock-protocol": "^3.35.0",
"discord-webhook-node": "^1.1.8",
"express": "^4.19.2",
"gulp-babel": "^8.0.0",
"gulp-replace": "^1.1.4",
"jszip": "^3.10.1",
"mediafire": "^0.1.2",
"minecraft-bedrock-server": "^1.4.1",
"socket.io": "^4.7.5",
"terser": "^5.30.3",
"uuid": "^9.0.0",
"ws": "^8.13.0"
"ws": "^8.13.0",
"yaml": "^2.4.1"
}
}

0 comments on commit 0fca0c9

Please sign in to comment.