Package com.ultikits.ultitools.manager
Class ServerPropertiesManager
java.lang.Object
com.ultikits.ultitools.manager.ServerPropertiesManager
Safe server.properties manager for remote editing via WebSocket.
Only exposes a curated whitelist of non-sensitive keys.
-
Nested Class Summary
Nested ClassesModifier and TypeClassDescriptionstatic final classOutcome of oneset_allbatch.private static enumWhat actually happened to one key. -
Field Summary
Fields -
Constructor Summary
Constructors -
Method Summary
Modifier and TypeMethodDescriptionapplySetAll(com.google.gson.JsonObject values) Apply a batch of properties, report it over the socket, and hand the outcome back.private com.google.gson.JsonObjectprivate static StringOne line naming why a single-key write did not happen, ornullwhen itdid.private voidvoidhandleServerProperties(com.google.gson.JsonObject data) Handle WebSocket message for server properties operations.private voidhandleSet(com.google.gson.JsonObject data) private voidhandleSetAll(com.google.gson.JsonObject data) private voidsendResponse(com.google.gson.JsonObject response) booleansetProperty(String key, String value) voidprivate static com.google.gson.JsonArraytoJsonArray(List<String> keys) private voidThe response above is what the panel reads; this is what a server operator reads.writeProperty(String key, String value) Why this exists next tosetProperty(String, String): the boolean is lossy.
-
Field Details
-
serverRoot
-
webSocketClient
-
SAFE_KEYS
-
-
Constructor Details
-
ServerPropertiesManager
-
-
Method Details
-
setWebSocketClient
-
getSafeProperties
-
setProperty
-
writeProperty
Why this exists next tosetProperty(String, String): the boolean is lossy. Afalsecould mean "the key is not on the whitelist", "the running server version has no such key", "there is no server.properties to write to", or "the write itself failed" — four situations with four different fixes, collapsed into one value. The batch path has to tell the caller which one happened, so the real outcome is produced here andsetPropertykeeps its original contract by narrowing it. -
describeOutcome
One line naming why a single-key write did not happen, ornullwhen itdid. Exposed throughhandleSet(JsonObject)'s response so a panel operator is told the reason, not justsuccess: false. -
handleServerProperties
public void handleServerProperties(com.google.gson.JsonObject data) Handle WebSocket message for server properties operations.- Parameters:
data- the message data
-
handleGet
private void handleGet() -
handleSet
private void handleSet(com.google.gson.JsonObject data) -
handleSetAll
private void handleSetAll(com.google.gson.JsonObject data) -
applySetAll
Apply a batch of properties, report it over the socket, and hand the outcome back.The return value is the point.
handleSetAlldoes not need it — it only ever builds a message — butupdate_configwithfileName: server_propertiesroutes through here too, and itsconfig_update_responseis supposed to distinguish "delivered" from "took effect". Before this returned anything, that path had no way to learn the answer and reported success unconditionally.- Parameters:
values- key → value, an explicit JSON null meaning "leave this key alone"- Returns:
- what happened to each key
-
buildSetAllResponse
-
toJsonArray
-
warnIfIncomplete
The response above is what the panel reads; this is what a server operator reads. Both are needed: someone changing a setting that silently does not apply otherwise finds nothing on either side. -
sendResponse
private void sendResponse(com.google.gson.JsonObject response)
-