mirror of
https://github.com/MCCTeam/Minecraft-Console-Client
synced 2026-08-15 13:04:36 +00:00
feat: enhance decompilation and server management scripts
- Introduced `decompile.sh` to automate the decompilation process, including downloading `MinecraftDecompiler.jar` and server.jar for specified Minecraft versions. - Added `mc-rcon.sh` for sending RCON commands to a Minecraft server, improving server management capabilities. - Created `mcc-env.sh` to provide helper functions for managing Minecraft servers, including starting, stopping, and sending commands. - Implemented `start-server.sh` to launch a Minecraft server in a tmux session with a named pipe for stdin, facilitating easier command input. - Updated `README.md` to reflect new tools and usage instructions for decompiling and server management. These changes streamline the workflow for adapting to new Minecraft versions and enhance the overall development experience.
This commit is contained in:
parent
9e3bfaa868
commit
cca4134e8b
6 changed files with 301 additions and 11 deletions
46
tools/mc-rcon.sh
Normal file
46
tools/mc-rcon.sh
Normal file
|
|
@ -0,0 +1,46 @@
|
|||
#!/bin/bash
|
||||
# Send an RCON command to a Minecraft server
|
||||
# Usage: mc-rcon.sh <command> [port] [password]
|
||||
set -euo pipefail
|
||||
|
||||
CMD="${1:?Usage: mc-rcon.sh <command> [port] [password]}"
|
||||
PORT="${2:-25575}"
|
||||
PW="${3:-test123}"
|
||||
|
||||
python3 -c "
|
||||
import socket, struct, sys
|
||||
|
||||
s = socket.socket()
|
||||
s.settimeout(5)
|
||||
try:
|
||||
s.connect(('localhost', $PORT))
|
||||
except Exception as e:
|
||||
print(f'Connection failed: {e}', file=sys.stderr)
|
||||
sys.exit(1)
|
||||
|
||||
def send(req_id, pkt_type, body):
|
||||
body = body.encode()
|
||||
s.send(struct.pack('<iii', 10 + len(body), req_id, pkt_type) + body + b'\x00\x00')
|
||||
|
||||
def recv():
|
||||
length = struct.unpack('<i', s.recv(4))[0]
|
||||
data = b''
|
||||
while len(data) < length:
|
||||
data += s.recv(length - len(data))
|
||||
return data
|
||||
|
||||
send(1, 3, '$PW')
|
||||
r = recv()
|
||||
rid = struct.unpack('<i', r[:4])[0]
|
||||
if rid == -1:
|
||||
print('Auth failed', file=sys.stderr)
|
||||
s.close()
|
||||
sys.exit(1)
|
||||
|
||||
send(2, 2, \"\"\"$CMD\"\"\")
|
||||
r = recv()
|
||||
body = r[8:-2].decode(errors='replace')
|
||||
if body:
|
||||
print(body)
|
||||
s.close()
|
||||
"
|
||||
Loading…
Add table
Add a link
Reference in a new issue