Move to new sign-based threat refuge system

This commit is contained in:
Tanner committed 2026-11-10 23:10:37 +00:00
1 parent 038fc503f0
commit 586772cb3b
6 files changed
+418 -195

No files matched your search

+19
View File
@@ -24,6 +24,7 @@ from munch import Munch
from mosfet import commands
from mosfet import game
from mosfet.jobs import check_threats
from mosfet import job
from mosfet import path
from mosfet import print_help
@@ -39,6 +40,7 @@ for module in [
blocks,
commands,
game,
check_threats,
items,
job,
mcdata,
@@ -607,6 +609,7 @@ def refresh_runtime(global_state, reload_managers=False):
"""Rebind reloadable runtime adapters without touching the connection."""
g = global_state
connection = g.get('connection')
previous_threat_monitor = g.get('threat_monitor')
_remove_instance_listeners(connection, g.get('chat'))
_remove_instance_listeners(connection, g.get('game'))
@@ -643,6 +646,22 @@ def refresh_runtime(global_state, reload_managers=False):
replacement_state = getattr(g.job, state_name, None)
if replacement_state is not None:
g.job.state = replacement_state
from mosfet.jobs.check_threats import ThreatMonitor
threat_monitor = ThreatMonitor(g)
if previous_threat_monitor is not None:
monitor_state = getattr(
previous_threat_monitor.state, '__name__', 'watching')
for attribute in (
'next_scan_at', 'retry_at', 'safe_since', 'safety',
'safe_sign', 'threats', 'resume_job_name',
'job_suspended'):
if hasattr(previous_threat_monitor, attribute):
setattr(threat_monitor, attribute,
getattr(previous_threat_monitor, attribute))
threat_monitor.state = getattr(
threat_monitor, monitor_state, threat_monitor.watching)
g.threat_monitor = threat_monitor
g.commands = commands.Commands(g)
if not reload_managers:
g.mcdata = DataManager()