diff --git a/docs/src/guide/advanced/external-plugin-api.md b/docs/src/guide/advanced/external-plugin-api.md index b526e04..9b3d318 100644 --- a/docs/src/guide/advanced/external-plugin-api.md +++ b/docs/src/guide/advanced/external-plugin-api.md @@ -65,7 +65,11 @@ On registration failure, UltiTools rolls back its registrations, including parti As of v7.1.0, `connect` rejects conflicting entity ownership or data folders before creating any components. A message namespace conflict is still refused before component scanning, as in v7.0.0: storage is not opened and the plugin data folder is not created. If scanning itself fails (for example, because a service needs a proxy but its class is `final`), storage may already be open. -As of v7.2.0, `disconnect` waits for in-flight framework async command bodies within the [command wait allowance](../essentials/cmd-executor#execution-threads-and-unload), then releases registrations and destroys managed beans. A cleanup failure does not skip subsequent cleanup. +As of v7.2.0, call `disconnect` on the server thread. If you call it off the server thread, the UI teardown step fails. UltiTools logs the failure, but the remaining cleanup continues. + +On explicit disconnect or automatic disconnect at disable, UltiTools waits for in-flight framework async command bodies within the [command wait allowance](../essentials/cmd-executor#execution-threads-and-unload). It then ends the connection's `UiService` sessions, retires its `Scheduler`, releases registrations and runs `@PreDestroy` on managed beans. The retired scheduler rejects new submissions with `RejectedExecutionException`; reconnecting gives the plugin a new scheduler and UI service. + +As of v7.2.0, if you call `PluginManager.registerExternal` directly, use a new `ExternalPluginAdapter` for every attempt. Reusing an adapter throws `IllegalStateException`, even if the previous registration failed. `UltiToolsAPI.connect` already creates a fresh adapter when connecting, so callers of that API need no change. During framework shutdown, UltiTools still attempts external disconnections before unloading its modules. As of v7.2.0, it logs each teardown failure by plugin or module name and continues, so a failed disconnect no longer prevents module unload. @@ -84,7 +88,7 @@ When sharing a compiled output directory, use disjoint packages. For example, a | `@Service` | Creates a managed bean with constructor or `@Autowired` field injection. As of v7.1.0, requesting `Plugin` or any class from the runtime class through `PluginBase` gives you the plugin itself. See [Plugin injection types](#plugin-injection). | | `@CmdExecutor` | An annotated `BaseCommandExecutor` bean is compiled into a Brigadier tree unless `manualRegister = true`. The framework also discovers managed `BrigadierCommand` beans. | | `@EventListener` | A bean implementing Bukkit `Listener` is registered unless `manualRegister = true`. Use Bukkit `@EventHandler` on its methods. | -| `@Scheduled` | Scheduled methods on managed beans use the framework scheduler and are cancelled on disconnect. Use literal `delay` and `period`; an asynchronous literal period is measured in wall-clock time at 50 ms per configured tick. | +| `@Scheduled` | As of v7.2.0, scheduled methods on managed beans use the same scheduler as work submitted through the connection's injected `Scheduler`. Disconnect cancels pending and repeating work from both sources. Use literal `delay` and `period`; an asynchronous literal period is measured in wall-clock time at 50 ms per configured tick. | | `@PlayerCache` | Registers per-player cache fields for quit handling, including any configured save hook; the fields stop being tracked on disconnect. | | `@ModuleEventHandler` | A public method on a managed bean with one `ModuleEvent` parameter (or a subtype) subscribes to the shared EventBus. Publish with `UltiToolsAPI.getEventBus().publish(event)`. | @@ -102,9 +106,13 @@ As of v7.1.0, the following rules apply to an external plugin that calls `UltiTo | `JavaPlugin`, the plugin's main class, its runtime class | The same plugin instance. Code already injecting `JavaPlugin` or the main class needs no change. | | An author-defined base class between the main class and `JavaPlugin` | The same plugin instance. In v7.0.0 an unbound intermediate class could not be injected. | | `CommandExecutor`, `TabExecutor`, `TabCompleter` | As of v7.2.0, resolved only from assignable components in the plugin's own container. If none match, an optional dependency stays absent and a required dependency fails. In v7.1.0, these types could fall back to UltiTools. | -| `LifecycleEventOwner`, `Namespaced` | These interfaces are not bound to the connected plugin. With no matching local component, the lookup can still return UltiTools through the parent container. | +| `LifecycleEventOwner`, `Namespaced` | As of v7.2.0, an assignable local component wins; otherwise, injection gives you the connected plugin. In v7.1.0, the fallback could return UltiTools. | +| `UltiTools` (concrete class) | As of v7.2.0, the framework plugin is no longer a by-type fallback. Without a matching local component, an optional dependency stays absent and a required dependency fails the connection. | +| `Scheduler`, `UiService` | As of v7.2.0, each connection receives its own [scheduler](./scheduled-tasks#scheduler-api) and [UI service](./ui-service). | + +As of v7.2.0, when a by-type lookup falls back to the framework plugin, the container substitutes the connected plugin if it matches the requested type. Otherwise the dependency is absent. Other framework beans remain available. `getBeanNamesForType` still lists the `ultiTools` bean for matching types, and lookup by name (`getBean("ultiTools")`) still returns the framework plugin. Replace `@Autowired UltiTools` used to obtain the framework plugin with `Bukkit.getPluginManager().getPlugin("UltiTools")`. -The fallback in the last row remains a [known limitation (#1129)](https://github.com/UltiKits/UltiTools-Reborn/issues/1129). Declare a component implementing the required command callback interface to inject your own handler. To obtain the connected plugin, inject `Plugin` or the main class. Paper marks `LifecycleEventOwner` as non-extendable, so use the plugin rather than implementing it in a component. To obtain UltiTools explicitly, use `Bukkit.getPluginManager().getPlugin("UltiTools")`. A `@Bean` product is registered by its concrete class: declaring the method's return type as `Plugin` or another bound type does not change what is injected for that type. +Declare a component implementing the required command callback interface to inject your own handler. To obtain the connected plugin, inject `Plugin` or the main class. Paper marks `LifecycleEventOwner` as non-extendable, so use the plugin rather than implementing it in a component. A `@Bean` product is registered by its concrete class: declaring the method's return type as `Plugin` or another bound type does not change what is injected for that type. ### Migration from v7.0.0 @@ -181,8 +189,12 @@ A namespace conflict is refused before component scanning and does not create th `[ULTI-6001] External plugin 'MatchingProbe' cannot use message namespace 'matchingprobe': it is already used by module 'MatchingProbe'` +Catalogue preparation can also fail with a runtime exception, such as `InvalidPathException` for an invalid path or `SecurityException` when signature verification fails while reading a signed JAR. These errors do not necessarily have a catalogue-specific `ULTI-` code. Check the cause of the `connect` exception, and inspect the packaged JAR and its path. + Call `UltiToolsAPI.reloadMessages(this)` from your own reload command to reread the bundled files and overrides. It can run on any thread, but performs synchronous file I/O under the text engine lock. Call it after `connect` returns successfully, not during bean initialization. Before connection, during registration or after disconnect, it throws `IllegalStateException` with `Plugin is not connected to UltiTools`. A connected plugin without a bundled catalogue gets a no-op. Malformed override files warn in the console and are ignored; bundled text remains the fallback. `/ul reload` does not refresh external catalogues. +Do not retain a plugin-owned `Messages` view across disconnection. See [External plugin messages](/guide/essentials/messages#external-plugin-messages) for the lifetime of that view. + ## Module-only features | Feature | External plugin | diff --git a/docs/src/guide/advanced/scheduled-tasks.md b/docs/src/guide/advanced/scheduled-tasks.md index 701d2c6..1dd603d 100644 --- a/docs/src/guide/advanced/scheduled-tasks.md +++ b/docs/src/guide/advanced/scheduled-tasks.md @@ -139,7 +139,7 @@ The 7.0 module descriptor must declare an integer `api-version` of at least `700 ## Scheduler API {#scheduler-api} -Each module instance owns one `Scheduler`. Inject it into a module bean: +Each module instance owns one `Scheduler`. As of v7.2.0, each external plugin connection also owns a `Scheduler`. Inject it into a managed bean: ```java @Service @@ -207,6 +207,8 @@ An async delay is not a deadline: the actual start depends on the server’s asy Unloading a module retires its scheduler before `onUnregister()` or `@PreDestroy`: queued work and repeating tasks are cancelled, and a running one-shot may finish. Submission to a retired owner throws `RejectedExecutionException`, so perform cleanup directly in those callbacks. A failed module load also retires the instance’s scheduler, including work submitted in bean construction, `@PostConstruct` or `registerSelf()`. Neither path cancels another module instance’s work or direct Bukkit tasks. +As of v7.2.0, an external plugin's `@Scheduled` methods and work submitted through its injected `Scheduler` share the connection's scheduler. Disconnect cancels queued and repeating tasks from both sources before `@PreDestroy`; a task body already running can finish. After disconnect, submissions through the old scheduler throw `RejectedExecutionException`. Reconnecting gives you a new scheduler. See [External Plugin API](./external-plugin-api) for the disconnect order. + ### Framework-scheduled work {#framework-scheduled-work} As of v7.0.0, the framework schedules its own background and main-thread work on a framework-owned `Scheduler` whose owner name is `UltiTools`, with the same contexts and rules as a module's scheduler ([#963](https://github.com/UltiKits/UltiTools-Reborn/pull/963)). Module code does not change; the differences you can observe are these: @@ -231,7 +233,7 @@ As of v7.0.0, async command bodies (`@RunAsync`, `@AsyncCommand`) and the comman ## Automatic Lifecycle -UltiTools schedules eligible bean methods after `registerSelf()` succeeds. When the module unloads or the server stops, the owning scheduler cancels pending and repeating tasks; a running method can finish. If an annotated method throws, the framework logs a WARNING naming the method. A repeating annotation continues on subsequent triggers. This warning comes from the annotation handler, not from the direct `Scheduler` task-failure contract above. +For a module, UltiTools schedules eligible bean methods after `registerSelf()` succeeds. For an external plugin, it schedules them during `connect`. When the module unloads or the plugin disconnects, the owning scheduler cancels pending and repeating tasks; a running method can finish. If an annotated method throws, the framework logs a WARNING naming the method. A repeating annotation continues on subsequent triggers. This warning comes from the annotation handler, not from the direct `Scheduler` task-failure contract above. ## Requirements diff --git a/docs/src/guide/advanced/ui-service.md b/docs/src/guide/advanced/ui-service.md index 4e787bf..ed022a6 100644 --- a/docs/src/guide/advanced/ui-service.md +++ b/docs/src/guide/advanced/ui-service.md @@ -1,6 +1,6 @@ # UI: Intents and Sessions -As of v7.0.0, modules show screens to players through the framework's `UiService` (package `com.ultikits.ultitools.ui`). A module describes what it wants to show or ask as an intent. The service picks a backend that can display it, a Paper dialog or a chest inventory, and returns a `UiSession` whose result says how the screen ended. The [declarative GUI](/guide/advanced/declarative-gui) builds its pages on the same service. +As of v7.0.0, modules show screens to players through the framework's `UiService` (package `com.ultikits.ultitools.ui`). As of v7.2.0, connected external plugins can use it too. You describe what you want to show or ask as an intent. The service picks a backend that can display it, a Paper dialog or a chest inventory, and returns a `UiSession` whose result says how the screen ended. The [declarative GUI](/guide/advanced/declarative-gui) builds its pages on the same service. ::: info As of v7.0.0 6.x has no `UiService`. For the 6.x screen classes, see the [archived v6.5.0 guide](/v6.5.0/guide/advanced/gui.html). @@ -24,7 +24,7 @@ public class ArenaScreens { The framework registers the service in the module's container before the component scan, so it is injected before any `@PostConstruct` method runs. The module's main class and its scanned beans receive the same instance. -Each loaded copy of a module has its own service. The framework keys it by the module instance, not by the module name: a replacement copy with the same name receives a new service, and unloading one copy ends only that copy's screens. `owner()` returns the module name for diagnostics only. Every method of `UiService` may be called from any thread, except `container(...)`, which must be called on the server thread. +Each loaded module instance has its own service. As of v7.2.0, each external plugin connection also has its own `UiService`, available to its managed beans before `@PostConstruct`. The framework does not use the name to identify the owner: replacing a module or reconnecting a plugin gives it a fresh service, and unloading or disconnecting one owner ends only its screens. `owner()` returns the module or plugin name for diagnostics only. Every method of `UiService` may be called from any thread, except `container(...)`, which must be called on the server thread. ## Intents @@ -88,7 +88,7 @@ Properties to plan for: - Clicks do not pass through the command pipeline, so command blockers of other plugins never see them. - Paper logs an exception thrown by a button's action and does not disconnect the player. - The two buttons are independent: confirm and then cancel runs both actions once each. A module that needs mutually exclusive actions enforces that itself. -- Unloading the module does not revoke pending callbacks; until one expires, clicking an old button can still run code of the unloaded module. +- Unloading a module or disconnecting an external plugin does not revoke pending callbacks. Until a callback expires, clicking an old button can still run the action. ### Choice @@ -181,8 +181,8 @@ Paper's dialog carries slider numbers as `float`. The dialog backend accepts a f | `Closed(DISCONNECTED)` | The player left the server, or was already offline when `show` was called | | `Closed(REPLACED)` | Another intent was shown to the same player; a player has at most one open session | | `Closed(TIMED_OUT)` | The timeout elapsed | -| `Closed(CLOSED_BY_CODE)` | The module called `session.close()` | -| `Closed(OWNER_UNLOADED)` | The module that showed it was unloaded | +| `Closed(CLOSED_BY_CODE)` | Code called `session.close()` | +| `Closed(OWNER_UNLOADED)` | The module was unloaded or, as of v7.2.0, the external plugin disconnected | | `Closed(UNSUPPORTED)` | No backend can show the intent to this player, or opening it failed | When no backend supports an intent, nothing opens and the player's previous session stays open. More `CloseReason` constants may be added in a 7.x minor release. @@ -199,8 +199,8 @@ As of v7.0.0, `INTERRUPTED` covers the cases where the screen ended without the | `DISCONNECTED` | The player left the server | The player left the server. A close the game reports as "cannot use" followed by a quit in the same tick also counts | | `INTERRUPTED` | The player died, changed worlds, or another inventory opened for the player (the open event was not cancelled) | The game or another plugin closed the inventory: death, teleport, another inventory opened, a plugin call. Also when the framework could not open the screen, or reopen it after a title change | | `REPLACED` | The framework showed the player's next screen | The same | -| `CLOSED_BY_CODE` | The module called `session.close()` | The same | -| `OWNER_UNLOADED` | The module was unloaded | The same | +| `CLOSED_BY_CODE` | Code called `session.close()` | The same | +| `OWNER_UNLOADED` | The module was unloaded or, as of v7.2.0, the external plugin disconnected | The same | | `TIMED_OUT` | The timeout elapsed | The same, if you set a timeout | A chest screen also ends at once with `INTERRUPTED` when its first open, or its reopen after a title change, is refused, for example because another plugin cancelled the open event. The storage commit still runs as usual (see below). @@ -252,11 +252,11 @@ ui.show(player, form, ShowOptions.builder().timeout(Duration.ofMinutes(2)).build | What | Thread | | --- | --- | | `result()` completes | In a task of the viewer's entity context, or of the global context if the viewer has quit | -| `result()` at owner unload | On the unloading thread before the unload returns (on Paper the main thread) | +| `result()` at owner unload or disconnect | On the server thread before unload or disconnect returns | | `GridAction` | In a later task of the viewer's entity context, never inside the inventory event | | `SlotContainer` methods | The server thread only, except `owner()`, `size()` and `kind()` | -A non-async dependent attached before the result completes runs on the completing thread. A non-async dependent attached after completion runs at once on the attaching thread, which may be an async thread. To touch the player whatever thread attaches the dependent, use an async variant with the module's [scheduler](/guide/advanced/scheduled-tasks#scheduler-api): +A non-async dependent attached before the result completes runs on the completing thread. A non-async dependent attached after completion runs at once on the attaching thread, which may be an async thread. To touch the player whatever thread attaches the dependent, use an async variant with your [scheduler](/guide/advanced/scheduled-tasks#scheduler-api): ```java session.result().thenAcceptAsync(result -> handle(player, result), scheduler.entity(player)); @@ -350,26 +350,28 @@ The store answers `StoreAnswer.written()`, `refused(current)` or `unknown(cause) As of v7.0.0, `/upm uninstall ` queues removal for the next restart; it does not unload the running module or close its UI. See [module changes on a server](/guide/advanced/module-versioning#updating-and-uninstalling-on-a-server). When a module actually unloads, for example at server stop or after a load failure once the service was issued, the framework ends its UI before it cancels the module's `@Scheduled` tasks and before `onUnregister()` runs. On the unloading thread it runs pending deliveries, starts the write of every `COMMIT` container with changes, ends every open session with `Closed(OWNER_UNLOADED)` (or the outcome already chosen), and then waits for the store answers. `show` during or after the unload returns a session that is already `Closed(OWNER_UNLOADED)` and opens nothing. +As of v7.2.0, an external plugin's sessions end the same way on `disconnect`, including when Paper disables the plugin. They end before its scheduler retires and before its managed beans run `@PreDestroy`. An old service's `show` returns `Closed(OWNER_UNLOADED)` after disconnect and opens nothing. Call `disconnect` on the server thread. + The store wait is bounded: | Situation | Wait | | --- | --- | -| Unloading one module | Each write waits at most its remaining commit timeout or the remaining unload wait of about 10 seconds, whichever comes first | -| Server stop | All modules share one budget of about 10 seconds, started before the first module unloads. Only the time spent unloading UI storage is charged, not the time other modules spend in their shutdown hooks; the budget is never refilled | +| Unloading one module or disconnecting one external plugin during normal operation | Each write waits at most its remaining commit timeout or the remaining unload wait of about 10 seconds, whichever comes first | +| UltiTools shutdown | Modules and external connections torn down during UltiTools shutdown share one budget of about 10 seconds. Only the time spent unloading UI storage is charged, not time spent in other shutdown steps; the budget is never refilled | -Once storage waits have used up the server-stop budget, later modules get no wait at all: their writes are treated as timed out at once. Unanswered writes count as unknown and those containers end with `UNKNOWN_KEPT_BY_STORE`: no items are returned and the store is responsible for them. +Once storage waits have used up the shutdown budget, later owners get no wait at all: their writes are treated as timed out at once. Unanswered writes count as unknown and those containers end with `UNKNOWN_KEPT_BY_STORE`: no items are returned and the store is responsible for them. -::: warning Keep storage alive until onUnregister -Keep the connections and thread pools your `ContainerStore` uses open until your `onUnregister()` hook runs. Complete the store's stage without the server thread: during an unload the server thread is the one waiting, and tasks scheduled for it no longer run. +::: warning Storage resources during teardown +Keep the connections and thread pools your `ContainerStore` uses open until `onUnregister()` for a module or until `disconnect` completes for an external plugin. Complete the store's stage without relying on the server thread, which is waiting during teardown. ::: ## Known limitations -- The server stop shares one storage-wait budget of about 10 seconds across all modules, as described above; a module unloaded after the budget is used up gets no wait. +- During UltiTools shutdown, the shared storage-wait budget described above can run out before a module or external connection is torn down. - Chest inventories contain display copies. The backend cancels clicks and drags before it applies its own transfers. Another plugin must not clear that cancellation with `setCancelled(false)` or `setResult(ALLOW)`, or vanilla can move the display copies and duplicate items. - Number-key swaps and Shift moves depend on the `InventoryAction` Paper computes from the displayed copy. While a redraw is pending the input may be ignored; wait for the redraw and retry. - Paper gives no signal when another plugin replaces a dialog. If another plugin shows its own dialog after yours, the timeout dismissal of yours also closes that dialog. - Do not open two screens for the same storage key at once. If a screen for a key is still open with unsaved changes and you open another for the same key, the new screen reads the old data; the framework does not merge the two copies. End the old screen, wait for its commit, then read the key and show it again. - When the framework rejects a click, the client first draws its own prediction and the server then corrects it, so the picture can flicker. This is part of the game protocol. Other viewers of the same container see a change one tick later than the player who made it. -- During an actual unload or reload on a running server, the framework waits on the server thread for unsaved storage screens for up to about 10 seconds. That equals Paper's default `watchdog.early-warning-delay` (10000 milliseconds), so a full wait can make Paper print `The server has not responded for 10 seconds! Creating thread dump` and a thread dump. The server is not crashing; look at the store that did not answer. Paper prints no such warning while the server is stopping. +- During an actual module unload or reload, or when an external plugin disconnects on a running server, the framework waits on the server thread for unsaved storage screens for up to about 10 seconds. That equals Paper's default `watchdog.early-warning-delay` (10000 milliseconds), so a full wait can make Paper print `The server has not responded for 10 seconds! Creating thread dump` and a thread dump. This warning does not mean the server crashed; check the store that did not answer. Paper prints no such warning while the server is stopping. - The declarative engine now hands `Grid` snapshots to the `UiService` instead of inheriting obliviate's `Gui`. Modules with 6.x screens must be migrated and rebuilt against 7.0; see [Declarative GUI](/guide/advanced/declarative-gui). The legacy chest pages and both old confirmation widgets (chest and chat) are removed too; see [Chat confirmation](#chat-confirmation) and [Legacy chest pages and confirmation widgets in 7.0](/guide/advanced/upgrading-to-7#chest-and-confirmation). diff --git a/docs/src/guide/essentials/messages.md b/docs/src/guide/essentials/messages.md index dd5c415..1b27821 100644 --- a/docs/src/guide/essentials/messages.md +++ b/docs/src/guide/essentials/messages.md @@ -190,6 +190,10 @@ As of v7.0.0, a `JavaPlugin` connected through `UltiToolsAPI.connect(this)` gets Put overrides in `plugins//messages/.yml`, not in `messages/reference/`. `/ul reload` does not read these overrides; use your plugin's reload command to call `UltiToolsAPI.reloadMessages(this)` after connection. See [External Plugin API](/guide/advanced/external-plugin-api#external-plugin-messages) for locale filenames, source language, and reload restrictions. +Disconnect withdraws the published catalogue. While no catalogue is published for that namespace, the old `Messages` view cannot find its keys: `isDefined` returns `false` and rendering falls back to the namespaced key itself. The view can render messages from a catalogue later published under the same namespace. Discard the view on disconnect and use the newly injected `Messages` after reconnecting. + +A module using the [legacy connector constructor](../advanced/auto-register) does not publish a catalogue and can load after an external plugin with the same namespace; it does not replace the external catalogue. + ## Module annotation text {#module-annotation-text} ::: info Annotation text as of v7.0.0 diff --git a/docs/src/guide/release-notes/7.1.0.md b/docs/src/guide/release-notes/7.1.0.md index 1455c2c..e6cfbc2 100644 --- a/docs/src/guide/release-notes/7.1.0.md +++ b/docs/src/guide/release-notes/7.1.0.md @@ -52,7 +52,7 @@ In both 7.0.0 and 7.1.0, if a JAR has no directory entry for a scan package (suc In 7.0.0 and 7.1.0, module JARs share one class loader, so if two module JARs use the same base package, or one module's base package contains another's, the scanner finds that package in only one JAR. Commands, listeners and services in that package in the other JAR are skipped without a warning, and the module that owns the other JAR registers the found JAR's components in that package instead. `@Table` entities are not affected. External plugins connected with `UltiToolsAPI.connect(this)` use their own plugin class loader and are not affected. Give each module its own base package. See [component scanning](../advanced/ioc-container#automatic-scanning) and [issue #1107](https://github.com/UltiKits/UltiTools-Reborn/issues/1107). -External plugins still receive the framework's own `Scheduler` and `UiService`; only tasks and listeners registered through the injected `Plugin` belong to your plugin ([issue #1129](https://github.com/UltiKits/UltiTools-Reborn/issues/1129)). +Correction: The original note incorrectly stated that external plugins received the framework's `UiService`. In v7.1.0, they receive the framework's `Scheduler`, but UltiTools does not provide them with an injectable `UiService`. As of v7.2.0, each external connection has its own instances of both services; see [External Plugin API](../advanced/external-plugin-api#plugin-injection). In-process tests are stricter than Paper: they reject modules supplied as JARs and restrict entity discovery in class directories. Module registration order can differ from a server, and advancing ticks cannot verify the wall-clock cadence of literal async `@Scheduled` tasks. Bootstrap content and operations not implemented by MockBukkit need real Paper. See [differences from a real server](../advanced/testing#differences-from-a-real-server) for the full list and alternatives. Conversely, a passing in-process test cannot detect [component scanning](../advanced/ioc-container#automatic-scanning) problems caused by missing package directory entries or by module JARs with shared or nested base packages; check the packaged JAR with `@UltiToolsServerTest`. diff --git a/docs/src/zh/guide/advanced/external-plugin-api.md b/docs/src/zh/guide/advanced/external-plugin-api.md index a1d72ca..158a42c 100644 --- a/docs/src/zh/guide/advanced/external-plugin-api.md +++ b/docs/src/zh/guide/advanced/external-plugin-api.md @@ -65,7 +65,11 @@ UltiTools 尚未加载时,`connect` 抛出 `IllegalStateException`。登记抛 自 v7.1.0 起,实体归属或数据目录冲突会在创建任何组件前终止连接。消息命名空间冲突与 v7.0.0 相同,仍在组件扫描前终止连接,不打开存储,也不创建插件数据目录。若在扫描过程中才失败(例如服务需要代理,但类是 `final`),存储可能已经打开。 -自 v7.2.0 起,`disconnect` 先在[命令等待限额](../essentials/cmd-executor#执行线程与卸载)内等待框架已开始执行的异步命令,再撤销登记并销毁受管 Bean。清理失败不会跳过后续步骤。 +自 v7.2.0 起,请在服务器线程调用 `disconnect`。在其他线程调用会导致界面清理失败。UltiTools 会记录该错误,但其余清理步骤会继续。 + +显式断开或禁用时自动断开,UltiTools 都会在[命令等待限额](../essentials/cmd-executor#执行线程与卸载)内等待框架已开始执行的异步命令。随后先结束该连接的 `UiService` 界面会话,再停用其 `Scheduler` 调度器、撤销登记,并运行受管 Bean 的 `@PreDestroy`。向已停用的调度器提交任务会抛出 `RejectedExecutionException`;重连会获得新的调度器和界面服务。 + +自 v7.2.0 起,直接调用 `PluginManager.registerExternal` 时,每次登记都须使用新的 `ExternalPluginAdapter`。复用会抛出 `IllegalStateException`,即使上次登记失败也一样。`UltiToolsAPI.connect` 建立连接时已创建新的适配器,使用此 API 无须修改。 框架关停时,仍先尝试断开外部插件,再卸载模块。自 v7.2.0 起,框架按插件或模块名记录每次清理失败,并继续处理其余插件或模块。断开失败不再阻止模块卸载。 @@ -84,7 +88,7 @@ UltiTools 尚未加载时,`connect` 抛出 `IllegalStateException`。登记抛 | `@Service` | 创建受管 Bean,支持构造器注入和 `@Autowired` 字段注入。自 v7.1.0 起,注入 `Plugin`,或从实际运行类到 `PluginBase`(含两端)的任一类,均得到插件本身,见[插件实例的注入类型](#plugin-injection)。 | | `@CmdExecutor` | 除非设置 `manualRegister = true`,否则会把带注解的 `BaseCommandExecutor` Bean 编译成 Brigadier 命令树。框架也会发现受管的 `BrigadierCommand` Bean。 | | `@EventListener` | 自动注册实现 Bukkit `Listener` 的 Bean,除非设置 `manualRegister = true`。处理方法使用 Bukkit 的 `@EventHandler`。 | -| `@Scheduled` | 受管 Bean 上的定时方法由框架调度器执行,断开时取消。使用字面量 `delay` 和 `period`;异步的字面量周期按实际时间计时,每配置一 tick 等于 50 毫秒。 | +| `@Scheduled` | 自 v7.2.0 起,受管 Bean 的定时方法与通过注入的 `Scheduler` 提交的任务使用同一个连接的调度器。断开时,两种来源的排队任务与重复任务都会取消。使用字面量 `delay` 和 `period`;异步的字面量周期按实际时间计时,每配置一 tick 等于 50 毫秒。 | | `@PlayerCache` | 登记玩家缓存字段,在玩家退出时处理,包括已配置的保存回调。断开后停止跟踪这些字段。 | | `@ModuleEventHandler` | 受管 Bean 的公开方法只接收一个 `ModuleEvent` 或其子类型参数时,可订阅共享事件总线。发布事件使用 `UltiToolsAPI.getEventBus().publish(event)`。 | @@ -102,9 +106,13 @@ UltiTools 尚未加载时,`connect` 抛出 `IllegalStateException`。登记抛 | `JavaPlugin`、插件主类、实际运行类 | 同一个插件实例。原来注入 `JavaPlugin` 或主类的代码不需要改。 | | 插件主类与 `JavaPlugin` 之间自定义的基类 | 同一个插件实例。v7.0.0 不能注入未绑定的中间基类。 | | `CommandExecutor`、`TabExecutor`、`TabCompleter` | 自 v7.2.0 起,只在插件自己的容器中查找实现该接口的组件。未找到时,可选依赖保持缺失,必需依赖注入失败。v7.1.0 中,这些类型可能回退到 UltiTools。 | -| `LifecycleEventOwner`、`Namespaced` | 这些接口不绑定到接入的插件实例。没有匹配的本地组件时,仍可能通过父容器取到 UltiTools。 | +| `LifecycleEventOwner`、`Namespaced` | 自 v7.2.0 起,优先注入匹配的本地组件;没有时注入接入的插件实例。v7.1.0 在没有本地组件时可能返回 UltiTools。 | +| `UltiTools`(具体类) | 自 v7.2.0 起,按类型查找不再回退到框架插件。没有匹配的本地组件时,可选依赖保持未注入,必需依赖使连接失败。 | +| `Scheduler`、`UiService` | 自 v7.2.0 起,每个连接获得自己的[调度器](./scheduled-tasks#调度器-api)和[界面服务](./ui-service)。 | + +自 v7.2.0 起,按类型查找回退到框架插件时,如果接入的插件符合请求类型,容器就返回它,否则视为依赖缺失。其他框架 Bean 仍可用。`getBeanNamesForType` 仍会为匹配的类型列出 `ultiTools`,按名称调用 `getBean("ultiTools")` 仍会返回框架插件。若原先用 `@Autowired UltiTools` 取得框架插件,请改用 `Bukkit.getPluginManager().getPlugin("UltiTools")`。 -最后一行的回退行为仍是[已知限制(#1129)](https://github.com/UltiKits/UltiTools-Reborn/issues/1129)。要注入自己的命令处理器,请声明实现相应命令回调接口的组件。要取得接入的插件实例,请注入 `Plugin` 或主类。Paper 将 `LifecycleEventOwner` 标记为不可扩展,请使用插件实例,不要让组件实现它。若要取得 UltiTools,请显式调用 `Bukkit.getPluginManager().getPlugin("UltiTools")`。`@Bean` 创建的对象按实际具体类登记,仅把方法的返回类型声明为 `Plugin` 等已绑定类型不会改变该类型的注入结果。 +要注入自己的命令处理器,请声明实现相应命令回调接口的组件。要取得接入的插件实例,请注入 `Plugin` 或主类。Paper 将 `LifecycleEventOwner` 标记为不可扩展,请使用插件实例,不要让组件实现它。`@Bean` 创建的对象按实际具体类登记,仅把方法的返回类型声明为 `Plugin` 等已绑定类型不会改变该类型的注入结果。 ### 从 v7.0.0 升级 @@ -181,8 +189,12 @@ UltiTools 尚未加载时,`connect` 抛出 `IllegalStateException`。登记抛 `[ULTI-6001] External plugin 'MatchingProbe' cannot use message namespace 'matchingprobe': it is already used by module 'MatchingProbe'` +准备消息目录时也可能抛出运行时异常,例如路径无效时的 `InvalidPathException`,或读取已签名 JAR 时签名验证失败导致的 `SecurityException`。这些错误不一定带有消息目录专用的 `ULTI-` 错误码。请查看 `connect` 异常的原因,并检查打包后的 JAR 及其路径。 + 在插件自己的重载命令中调用 `UltiToolsAPI.reloadMessages(this)` 可重读随包文件与覆盖文件。任何线程均可调用,但它会在文本引擎锁内同步读文件。请在 `connect` 成功返回后调用,不要放在 Bean 初始化中。未连接、正在登记或已断开时会抛出 `IllegalStateException`,消息为 `Plugin is not connected to UltiTools`。没有随包消息目录的已连接插件调用此方法不会执行任何操作。无效的覆盖文件会被忽略,控制台记录警告,查找可回退到随包文本。`/ul reload` 不刷新外部插件的消息目录。 +不要在连接断开后继续持有插件自己的 `Messages` 视图。视图的生命周期见[外部插件消息](/zh/guide/essentials/messages#external-plugin-messages)。 + ## 模块专属功能 | 功能 | 外部插件 | diff --git a/docs/src/zh/guide/advanced/scheduled-tasks.md b/docs/src/zh/guide/advanced/scheduled-tasks.md index b50964f..39de49f 100644 --- a/docs/src/zh/guide/advanced/scheduled-tasks.md +++ b/docs/src/zh/guide/advanced/scheduled-tasks.md @@ -139,7 +139,7 @@ public class BoundScheduleService { ## 调度器 API {#调度器-api} -每个模块实例拥有一个 `Scheduler`,可注入到模块的 Bean 中: +每个模块实例拥有一个 `Scheduler`。自 v7.2.0 起,每次外部插件连接也拥有自己的 `Scheduler`。可将它注入受管 Bean: ```java @Service @@ -207,6 +207,8 @@ tick 上下文把延迟和周期向上取整为整数 tick(`Ticks.ceil`), 卸载模块时,框架在 `onUnregister()` 或 `@PreDestroy` 前停用其调度器:排队及重复任务会被取消,正在运行的一次性任务可以完成。向已停用的调度器提交任务会抛出 `RejectedExecutionException`,请直接在这些回调中执行清理。加载失败也会停用该实例的调度器,包括在 Bean 构建、`@PostConstruct` 或 `registerSelf()` 中提交的工作。两种情况都不会取消其他模块实例的工作,也不会取消直接提交给 Bukkit 的任务。 +自 v7.2.0 起,外部插件的 `@Scheduled` 方法与通过注入的 `Scheduler` 提交的任务共用该连接的调度器。断开时,框架在 `@PreDestroy` 之前取消两种来源的排队任务和重复任务;已经开始执行的任务体可以完成。断开后向旧调度器提交任务会抛出 `RejectedExecutionException`。重连会获得新的调度器。断开时的清理顺序见[外部插件 API](./external-plugin-api)。 + ### 框架调度的工作 {#框架调度的工作} 自 v7.0.0 起,框架把自己的后台与主线程工作提交到一个框架自有的 `Scheduler`,其所属者名称为 `UltiTools`,上下文和规则与模块的调度器相同([#963](https://github.com/UltiKits/UltiTools-Reborn/pull/963))。模块代码无需改动,可以观察到的差异如下: @@ -231,7 +233,7 @@ tick 上下文把延迟和周期向上取整为整数 tick(`Ticks.ceil`), ## 自动生命周期管理 -`registerSelf()` 成功后,UltiTools 调度符合条件的 Bean 方法。模块卸载或停服时,所属调度器取消排队与重复任务,已经运行的方法可以完成。若被注解的方法抛出异常,框架会记录指明方法的 WARNING;重复任务仍会在之后触发。该警告来自注解处理逻辑,不适用上文直接使用 `Scheduler` 时的任务失败约定。 +对于模块,`registerSelf()` 成功后,UltiTools 调度符合条件的 Bean 方法。对于外部插件,UltiTools 在 `connect` 期间调度这些方法。模块卸载或外部插件断开时,所属调度器取消排队与重复任务,已经运行的方法可以完成。若被注解的方法抛出异常,框架会记录指明方法的 WARNING;重复任务仍会在之后触发。该警告来自注解处理逻辑,不适用上文直接使用 `Scheduler` 时的任务失败约定。 ## 使用要求 diff --git a/docs/src/zh/guide/advanced/ui-service.md b/docs/src/zh/guide/advanced/ui-service.md index 968efa8..7998d88 100644 --- a/docs/src/zh/guide/advanced/ui-service.md +++ b/docs/src/zh/guide/advanced/ui-service.md @@ -1,6 +1,6 @@ # 界面:意图与会话 -自 v7.0.0 起,模块通过框架的 `UiService`(包 `com.ultikits.ultitools.ui`)向玩家显示界面。模块把要显示或要询问的内容描述为一个意图(intent),服务选择能够显示它的后端,即 Paper 对话框或箱子物品栏,并返回一个 `UiSession`,其结果说明界面如何结束。[声明式 GUI](/zh/guide/advanced/declarative-gui) 的页面也建立在同一个服务之上。 +自 v7.0.0 起,模块通过框架的 `UiService`(包 `com.ultikits.ultitools.ui`)向玩家显示界面。自 v7.2.0 起,已连接的外部插件也可使用此服务。你把要显示或要询问的内容描述为一个意图(intent),服务选择能够显示它的后端,即 Paper 对话框或箱子物品栏,并返回一个 `UiSession`,其结果说明界面如何结束。[声明式 GUI](/zh/guide/advanced/declarative-gui) 的页面也建立在同一个服务之上。 ::: info 自 v7.0.0 起 6.x 没有 `UiService`。旧版界面类见 [v6.5.0 归档指南](/zh/v6.5.0/guide/advanced/gui.html)。 @@ -24,7 +24,7 @@ public class ArenaScreens { 框架在组件扫描之前就把服务注册进模块的容器,因此它在任何 `@PostConstruct` 方法运行之前已经注入。模块主类与其扫描到的 bean 拿到的是同一个实例。 -模块每个已加载的副本都有自己的服务。框架按模块实例而不是按模块名区分:同名的替换副本会拿到新的服务,卸载一个副本只结束该副本的界面。`owner()` 返回模块名,仅用于诊断。`UiService` 的方法都可以在任意线程调用,只有 `container(...)` 必须在服务器线程调用。 +每个已加载的模块实例都有自己的服务。自 v7.2.0 起,每次外部插件连接也拥有自己的 `UiService`,受管 Bean 在 `@PostConstruct` 之前就可以注入它。框架不按名称区分所有者:替换模块或重连插件会得到新的服务,卸载或断开只结束该所有者的界面。`owner()` 返回模块名或插件名,仅用于诊断。`UiService` 的方法都可以在任意线程调用,只有 `container(...)` 必须在服务器线程调用。 ## 意图 {#intents} @@ -88,7 +88,7 @@ player.sendMessage(Component.text("Delete this home?").appendNewline().append(ye - 点击不经过命令管线,其他插件的命令拦截器看不到它。 - 按钮动作抛出的异常由 Paper 记录,不会让玩家掉线。 - 两个按钮相互独立:先点确认再点取消,两个动作各执行一次。需要互斥的模块须自己保证。 -- 卸载模块不会撤销待点回调;在回调过期之前,点击旧按钮仍可能运行已卸载模块的代码。 +- 模块卸载或外部插件断开时,待处理的按钮回调不会撤销。在回调过期之前,点击旧按钮仍可能执行相应动作。 ### Choice {#choice} @@ -181,8 +181,8 @@ Paper 对话框以 `float` 传递滑块数值。对话框后端只接受每个 | `Closed(DISCONNECTED)` | 玩家离开服务器,或调用 `show` 时玩家已离线 | | `Closed(REPLACED)` | 同一玩家被显示了另一个意图;每个玩家最多有一个打开的会话 | | `Closed(TIMED_OUT)` | 超时 | -| `Closed(CLOSED_BY_CODE)` | 模块调用了 `session.close()` | -| `Closed(OWNER_UNLOADED)` | 显示它的模块被卸载 | +| `Closed(CLOSED_BY_CODE)` | 代码调用了 `session.close()` | +| `Closed(OWNER_UNLOADED)` | 模块被卸载,或自 v7.2.0 起外部插件断开 | | `Closed(UNSUPPORTED)` | 没有后端能向该玩家显示这个意图,或打开失败 | 没有后端支持某个意图时,什么也不会打开,玩家之前的会话保持打开。7.x 的次版本可能增加 `CloseReason` 常量。 @@ -199,8 +199,8 @@ Paper 对话框以 `float` 传递滑块数值。对话框后端只接受每个 | `DISCONNECTED` | 玩家离开服务器 | 玩家离开服务器。游戏报告「无法使用」且同一 tick 内玩家退出,也算这个原因 | | `INTERRUPTED` | 玩家死亡、换世界,或为玩家打开了另一个物品栏(打开事件没有被取消) | 游戏或其他插件关闭了物品栏:死亡、传送、打开另一个物品栏、插件调用。框架无法打开界面,或在改标题后无法重新打开时也是这个原因 | | `REPLACED` | 框架向玩家显示了下一个界面 | 相同 | -| `CLOSED_BY_CODE` | 模块调用了 `session.close()` | 相同 | -| `OWNER_UNLOADED` | 模块被卸载 | 相同 | +| `CLOSED_BY_CODE` | 代码调用了 `session.close()` | 相同 | +| `OWNER_UNLOADED` | 模块被卸载,或自 v7.2.0 起外部插件断开 | 相同 | | `TIMED_OUT` | 超时 | 相同(需要自己设置超时) | 箱子界面首次打开,或改标题后的重新打开被拒绝(例如其他插件取消了打开事件)时,会话也立即以 `INTERRUPTED` 结束。存储照常提交(见下文)。 @@ -252,11 +252,11 @@ ui.show(player, form, ShowOptions.builder().timeout(Duration.ofMinutes(2)).build | 内容 | 线程 | | --- | --- | | `result()` 完成 | 在查看者实体上下文的任务中;查看者已退出时在全局上下文的任务中 | -| 拥有者卸载时的 `result()` | 在卸载线程上、卸载返回之前(Paper 上为主线程) | +| 所有者卸载或断开时的 `result()` | 在服务器线程上,卸载或断开返回之前 | | `GridAction` | 在查看者实体上下文随后的任务中,从不在物品栏事件内部 | | `SlotContainer` 的方法 | 只能在服务器线程调用,`owner()`、`size()` 与 `kind()` 除外 | -结果完成之前挂上的非异步后续操作在完成它的线程上运行。结果完成之后才挂上的非异步后续操作立即在挂上它的线程上运行,这可能是异步线程。无论在哪个线程挂上,都要操作玩家时,使用异步变体并传入模块的[调度器](/zh/guide/advanced/scheduled-tasks#调度器-api): +结果完成之前挂上的非异步后续操作在完成它的线程上运行。结果完成之后才挂上的非异步后续操作立即在挂上它的线程上运行,这可能是异步线程。无论在哪个线程挂上,都要操作玩家时,使用异步变体并传入你自己的[调度器](/zh/guide/advanced/scheduled-tasks#调度器-api): ```java session.result().thenAcceptAsync(result -> handle(player, result), scheduler.entity(player)); @@ -350,26 +350,28 @@ ui.show(player, Grid.builder(Text.of(messages.key("bag.title")), 3) 自 v7.0.0 起,`/upm uninstall <模块>` 将卸载排到下次重启,不会卸载正在运行的模块或关闭它的界面。见[服务器上的模块变更](/zh/guide/advanced/module-versioning#在服务器上更新和卸载)。模块真正卸载时,例如服务器停止或取得界面服务后加载失败时,框架先结束它的界面,然后才取消模块的 `@Scheduled` 任务、运行 `onUnregister()`。在卸载线程上,框架依次执行待处理的发放,开始写入每个有改动的 `COMMIT` 容器,以 `Closed(OWNER_UNLOADED)`(或已经选定的结果)结束每个打开的会话,然后等待存储的回答。卸载期间或之后调用 `show`,返回的会话已经是 `Closed(OWNER_UNLOADED)`,不会打开任何界面。 +自 v7.2.0 起,外部插件断开时(包括 Paper 禁用插件时)也按上述方式结束会话,且先于调度器停用及受管 Bean 的 `@PreDestroy`。断开后通过旧服务调用 `show` 会返回 `Closed(OWNER_UNLOADED)`,不会打开界面。请在服务器线程调用 `disconnect`。 + 存储等待有上限: | 情形 | 等待 | | --- | --- | -| 卸载单个模块 | 每次写入最多等待其剩余的提交超时,或剩余的约 10 秒卸载等待,以先到者为准 | -| 停服 | 所有模块共用约 10 秒的预算,在卸载第一个模块之前开始计算。只扣除界面存储卸载本身的耗时,不扣其他模块卸载钩子的耗时;预算不会重新补满 | +| 服务器运行时卸载单个模块或断开单个外部插件 | 每次写入最多等待其剩余的提交超时,或剩余的约 10 秒卸载等待,以先到者为准 | +| UltiTools 关闭 | 在 UltiTools 关闭期间清理的模块和外部连接共用约 10 秒的预算。只扣除界面存储卸载本身的耗时,不扣其他清理步骤的耗时;预算不会重新补满 | -存储等待用完停服预算之后,后面的模块完全没有等待时间,其写入立即按超时处理。未得到回答的写入按未知处理,这些容器以 `UNKNOWN_KEPT_BY_STORE` 结束:不退还物品,物品由存储负责。 +存储等待用完关闭预算之后,后续清理的所有者没有等待时间,其写入立即按超时处理。未得到回答的写入按未知处理,这些容器以 `UNKNOWN_KEPT_BY_STORE` 结束:不退还物品,物品由存储负责。 -::: warning 存储资源保留到 onUnregister -`ContainerStore` 使用的连接与线程池要一直保持打开,直到你的 `onUnregister()` 钩子运行。完成存储返回的阶段时不要依赖服务器线程:卸载期间正是服务器线程在等待,排给它的任务不会再运行。 +::: warning 清理期间的存储资源 +`ContainerStore` 使用的连接与线程池要一直保持打开,直到模块的 `onUnregister()` 运行,或外部插件的 `disconnect` 完成。完成存储返回的阶段时不要依赖服务器线程,因为它在清理期间会等待存储。 ::: ## 已知限制 {#known-limitations} -- 停服时所有模块共用约 10 秒的存储等待预算,见上文;预算用完之后才卸载的模块没有等待时间。 +- UltiTools 关闭时,上文所述的共用存储等待预算可能在某个模块或外部连接被清理前用完。 - 箱子物品栏里是展示副本。后端先取消点击与拖拽,再执行自己的转移。其他插件不得用 `setCancelled(false)` 或 `setResult(ALLOW)` 清掉取消状态,否则原版可能移动展示副本并复制物品。 - 数字键交换与 Shift 移动依赖 Paper 根据展示副本算出的 `InventoryAction`。重绘尚未到达时这次输入可能不生效;请等重绘完成后重试。 - 其他插件替换对话框时 Paper 不发出信号。如果其他插件在你的对话框之后显示了自己的对话框,你的对话框超时关闭时也会关掉那个对话框。 - 不要为同一个存储键同时打开两个界面。某个键的界面仍开着、还有未保存的改动时,再为同一个键打开另一个界面,新界面读到的是旧数据;框架不会合并两份副本。请先结束旧界面、等它提交完成,再读取该键并重新显示。 - 框架拒绝某次点击时,客户端会先画出自己的预测,随后被服务器纠正,画面可能闪一下。这是游戏协议本身的特性。同一个容器的其他观看者比操作的玩家晚一个 tick 看到变化。 -- 在运行中的服务器上实际卸载或重载模块时,框架在服务器线程上等待未保存的存储界面,最多约 10 秒。这与 Paper 默认的 `watchdog.early-warning-delay`(10000 毫秒)相同,等满时 Paper 可能打印 `The server has not responded for 10 seconds! Creating thread dump` 和一段线程转储。服务器并没有崩溃,该排查的是没有答复的存储。停服过程中 Paper 不打印这种预警。 +- 在运行中的服务器上实际卸载或重载模块,或断开外部插件时,框架在服务器线程上等待未保存的存储界面,最多约 10 秒。这与 Paper 默认的 `watchdog.early-warning-delay`(10000 毫秒)相同,等满时 Paper 可能打印 `The server has not responded for 10 seconds! Creating thread dump` 和一段线程转储。这条预警并不表示服务器崩溃,请检查没有答复的存储。停服过程中 Paper 不打印这种预警。 - 声明式引擎现在向 `UiService` 提交 `Grid` 快照,不再继承 obliviate 的 `Gui`。使用 6.x 界面的模块需要迁移并针对 7.0 重新构建;参见[声明式 GUI](/zh/guide/advanced/declarative-gui)。旧箱子页面和两个旧确认组件(箱子式与聊天式)也已删除,见[聊天确认](#chat-confirmation)和[7.0 中的旧箱子页面与确认组件](/zh/guide/advanced/upgrading-to-7#chest-and-confirmation)。 diff --git a/docs/src/zh/guide/essentials/messages.md b/docs/src/zh/guide/essentials/messages.md index 82da770..b637e0e 100644 --- a/docs/src/zh/guide/essentials/messages.md +++ b/docs/src/zh/guide/essentials/messages.md @@ -190,6 +190,10 @@ fallback-language: "auto" 将覆盖文件放在 `plugins/<插件名>/messages/<语言>.yml`,不要放到 `messages/reference/`。`/ul reload` 不读取这些覆盖文件;请在插件自己的重载命令中于连接成功后调用 `UltiToolsAPI.reloadMessages(this)`。语言文件名、源语言和重载限制见[外部插件 API](/zh/guide/advanced/external-plugin-api#external-plugin-messages)。 +断开连接会撤下已发布的消息目录。在该命名空间没有已发布目录期间,旧的 `Messages` 视图查不到其中的键:`isDefined` 返回 `false`,渲染时使用带命名空间的键本身。之后若有目录在同一命名空间发布,旧视图可以渲染该目录的消息。断开时丢弃旧视图,重连后使用新注入的 `Messages`。 + +使用[旧式连接器构造器](../advanced/auto-register)的模块不发布消息目录,可以在同命名空间的外部插件之后加载,但不会替换外部插件的消息目录。 + ## 配置注释、命令描述与补全提示 {#module-annotation-text} ::: info 注解文本(自 v7.0.0 起) diff --git a/docs/src/zh/guide/release-notes/7.1.0.md b/docs/src/zh/guide/release-notes/7.1.0.md index 8139cd2..55ccc78 100644 --- a/docs/src/zh/guide/release-notes/7.1.0.md +++ b/docs/src/zh/guide/release-notes/7.1.0.md @@ -52,7 +52,7 @@ 在 7.0.0 和 7.1.0 中,模块 JAR 共用同一个类加载器,所以两个模块 JAR 使用同一个基础包,或一个模块的基础包包含另一个模块的基础包时,扫描器只会在其中一个 JAR 中找到该包。另一个 JAR 在该包中的命令、监听器和服务会被跳过,且没有警告;拥有另一个 JAR 的模块会改为登记被找到的 JAR 在该包中的组件。`@Table` 实体不受影响。通过 `UltiToolsAPI.connect(this)` 接入的外部插件使用自己的插件类加载器,不受影响。每个模块用自己独有的基础包。见[组件扫描](../advanced/ioc-container#自动扫描)和 [issue #1107](https://github.com/UltiKits/UltiTools-Reborn/issues/1107)。 -外部插件注入的 `Scheduler` 和 `UiService` 仍是框架自己的;只有通过注入的 `Plugin` 注册的任务和监听器归属于你的插件([issue #1129](https://github.com/UltiKits/UltiTools-Reborn/issues/1129))。 +更正:原说明称外部插件可以注入框架的 `UiService`,这一说法不准确。在 v7.1.0 中,外部插件注入的是框架的 `Scheduler`,但 UltiTools 不向外部插件提供可注入的 `UiService`。自 v7.2.0 起,每个外部连接都有自己的这两项服务实例,见[外部插件 API](../advanced/external-plugin-api#plugin-injection)。 进程内测试比真 Paper 服务器更严格:它不接受以 JAR 形式提供的模块,在类目录中发现实体的范围也更窄。模块注册顺序可能与服务器不同,推进 tick 也不能验证字面量异步 `@Scheduled` 任务按实际时间的执行频率。引导期内容和 MockBukkit 未实现的操作需要在真 Paper 上测试。完整列表及改法见[与真服务器的差异](../advanced/testing#与真服务器的差异)。反过来,进程内测试通过,也测不出 JAR 缺少包目录条目,或多个模块 JAR 的基础包相同或互相嵌套造成的[组件扫描](../advanced/ioc-container#自动扫描)问题;用 `@UltiToolsServerTest` 检查打好的 JAR。