De levensloop van een plugin

Voordat de plugin zichtbaar wordt gemaakt, itereert de plugin-lader door alle beschikbare plugins, bepaalt of alle dependencies aanwezig zijn en sorteert de plugins dan op volgorde gebaseerd op hun dependency. Gebeurtenissen worden aan plugins gegeven in deze volgorde. Bijvoorbeeld, plugin A die “[required-]after:B” bevat krijgt elk event nadat plugin B al het werk heeft gedaan voor de gegeven state. Daarbovenop zijn levenscyclus states globaal. Dit betekent dat alle plugins die zichtbaar zijn voor elkaar alle staten in een keer moeten doorlopen.

Waarschuwing

The Sponge Server object is not always available. Availability can be checked using the method Sponge.isServerAvailable() or Game.isServerAvailable().

State Events

There are three categories of state events:

  1. Initialization: Wanneer Sponge en de plugins geladen worden, voordat het eigenlijke spel begonnen is. Initialization states kunnen slechts een keer gebeuren.
  2. Running: Wanneer het spel en de wereld worden geladen. Running states kunnen meerdere keren gebeuren.
  3. Stopping: When the game is shutting down. Stopping states, like initialization states, only occur once.

Initialization States

Initialization States gebeuren slechts een keer per uitvoering.

CONSTRUCTION

The GameConstructionEvent is triggered. During this state, the @Plugin class instance for each plugin is triggered.

PRE_INITIALIZATION

The GamePreInitializationEvent is triggered. During this state, the plugin gets ready for initialization. Access to a default logger instance and access to information regarding preferred configuration file locations is available.

INITIALIZATION

The GameInitializationEvent is triggered. During this state, the plugin should finish any work needed in order to be functional. Global event handlers should get registered in this stage.

POST_INITIALIZATION

The GamePostInitializationEvent is triggered. By this state, inter-plugin communication should be ready to occur. Plugins providing an API should be ready to accept basic requests.

LOAD_COMPLETE

The GameLoadCompleteEvent is triggered. By this state, all plugin initialization should be completed.

Lopende staten

Running States kunnen meerdere keren gebeuren tijdens een uitvoering. SERVER_ABOUT_TO_START kan SERVER_STOPPED opvolgen en SERVER_STOPPED kan op eender welk moment gebeuren als er een fout gebeurt.

SERVER_ABOUT_TO_START

The GameAboutToStartServerEvent event is triggered. The server instance exists, but worlds are not yet loaded.

SERVER_STARTING

The GameStartingServerEvent is triggered. The server instance exists, and worlds are loaded. Command registration is handled during this state.

SERVER_STARTED

The GameStartedServerEvent event is triggered. The server instance exists, and worlds are loaded.

SERVER_STOPPING

The GameStoppingServerEvent is triggered. This state occurs immediately before the final tick, before the worlds are saved.

SERVER_STOPPED

The GameStoppedServerEvent is triggered. During this state, no players are connected and no changes to worlds are saved.

Stopping States

Stopping states never occur more than once during a single run. They occur when the game stops normally. (On Servers: the /stop command is typed. On Clients: The “Close” button or the “Quit Game” button are clicked)

Waarschuwing

Stopping states are not guaranteed to be run during shutdown. They may not fire if the game is force-stopped via Ctrl-C, Task Manager, a computer crash, or similar situations.

GAME_STOPPING

The GameStoppingEvent is triggered. This state occurs immediately before GAME_STOPPED. Plugins providing an API should still be capable of accepting basic requests.

GAME_STOPPED

The GameStoppedEvent is triggered. Once this event has finished executing, Minecraft will shut down. No further interaction with the game or other plugins should be attempted at this point.