Add online player positions to sudo context

This commit is contained in:
Claude Code
2026-03-16 19:41:53 -04:00
parent cf2aeb1a5e
commit 0e67883bec
+22 -1
View File
@@ -2367,10 +2367,31 @@ def process_sudo(player, prompt, config):
add_sudo_history(player, prompt, commands, executed)
return
# Collect positions for all online players.
position_lines = []
for p in online:
try:
pos_raw = rcon(
f"data get entity {p} Pos",
config["rcon_host"], config["rcon_port"], config["rcon_password"]
)
pos_m = re.findall(r'(-?[\d.]+)d', pos_raw)
if pos_m and len(pos_m) >= 3:
x, y, z = int(float(pos_m[0])), int(float(pos_m[1])), int(float(pos_m[2]))
position_lines.append(f" {p}: x={x}, y={y}, z={z}")
except Exception:
pass
positions_block = (
"Player positions:\n" + "\n".join(position_lines)
if position_lines else ""
)
context_hint = (
f"Requesting player: {player}\n"
f"Online players: {', '.join(online) or 'none'}\n"
f"Natural language request: {prompt}\n"
+ (positions_block + "\n" if positions_block else "")
+ f"Natural language request: {prompt}\n"
+ get_sudo_history_block()
)