mirror of
https://github.com/PHIDIAS0303/ExpCluster.git
synced 2026-11-12 07:54:52 +09:00
Join messages were stored in exp_legacy's PlayerData, which nothing ever synced. The controller now keeps a players.json datastore of per-player settings keyed by player name, starting with the join message, and saves it on the save and shutdown hooks. Records with nothing set are removed. When a player joins, the instance plugin fetches their record and prints the message to everyone over rcon in the player's colour, so no lua is needed to show it. The in-game /set-join-message and /remove-join-message commands send ipc which the instance forwards to the controller; /set-join-message without a message asks the instance, which prints the stored message back to the player. Greetings is now a feature. Disabling it stops the greeting, the commands, and the printed join messages. The private greeting with the community name and Discord link is shown to every joining player, even those with a join message, since one is a welcome for the player and the other an announcement to everyone else. Two controller permissions cover the web interface: exp_scenario.join_message.set for your own message and .set_other for anyone's, checked against the requesting user the same way exp_discord_auth checks unlinking. The seed grants them to Supporter and Moderator alongside the in-game commands. The user page gets a Scenario section showing the message with an edit button for users who may change it. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
35 lines
1.1 KiB
TypeScript
35 lines
1.1 KiB
TypeScript
import React, { useCallback, useSyncExternalStore } from "react";
|
|
import { WebPluginContext } from "@clusterio/web_ui";
|
|
|
|
import * as lib from "@clusterio/lib";
|
|
import * as messages from "../messages.js";
|
|
|
|
import FeaturesPage from "./components/FeaturesPage";
|
|
import Seed from "./components/Seed";
|
|
import UserPlayerSettings from "./components/UserPlayerSettings";
|
|
|
|
let features: lib.MapSubscriber<messages.FeatureUpdatedEvent> | undefined;
|
|
|
|
export function useFeatures() {
|
|
const subscribe = useCallback((cb: () => void) => features!.subscribe(cb), []);
|
|
return useSyncExternalStore(subscribe, () => features!.getSnapshot());
|
|
}
|
|
|
|
export default function registerPlugin(context: WebPluginContext) {
|
|
context.control.hooks.extensionComponents.attach("exp_scenario", () => ({
|
|
RolesPage: Seed,
|
|
UserViewPage: UserPlayerSettings,
|
|
}));
|
|
|
|
context.control.hooks.pages.attach("exp_scenario", () => [
|
|
{
|
|
path: "/scenario_features",
|
|
sidebarName: "Scenario Features",
|
|
permission: "exp_scenario.config.view",
|
|
content: <FeaturesPage />,
|
|
},
|
|
]);
|
|
|
|
features = new lib.MapSubscriber(messages.FeatureUpdatedEvent, context.control);
|
|
}
|