플러그인 생명 주기

플러그인 로더(Plugin Loader)는 플러그인을 드러나게 하는 어떠한 상태보다도 먼저 사용 가능한 플러그인들을 불러온 뒤, 모든 의존물(dependency)이 존재하는지 확인한 다음, 플러그인들을 의존 순서에 맞게 배열합니다. 생명 주기 이벤트들은 플러그인을 이러한 순서로 호출합니다. 예를 들어, “[required-]after:B”를 포함하는 플러그인 A는 플러그인 B가 주어진 상태 이벤트와 관련된 작업을 종료한 다음 해당 이벤트의 호출을 받을 것입니다. 참고로, 외부에 공개된 모든 플러그인들은 생명 주기 상태들을 모두 한 번씩 이행시키도록 되어 있습니다.

경고

Sponge의 Server 객체를 구할 수 없는 상황이 가끔 발생합니다. Sponge.isServerAvailable() 또는 Game.isServerAvailable() 메소드를 통해 이 객체를 사용할 수 있는지 확인할 수 있습니다.

상태 이벤트

상태 이벤트는 세 가지 범주로 나뉩니다:

  1. 초기화 이벤트: 실제 게임이 시작되기 전에 Sponge와 플러그인들을 불러오는 시기입니다. 초기화 상태는 한 번만 발생합니다.

  2. **진행 이벤트: ** 게임과 세계를 불러오는 시기입니다. 진행 이벤트는 여러 번 발생할 수 있습니다.

  3. 종료 이벤트: 게임이 종료되는 시기입니다. 초기화 상태와 같은 상태가 종료되는 것은 한 번만 발생합니다.

초기화 상태

Initialization 상태는 한번의 실행에 한번만 발생합니다.

CONSTRUCTION

:javadoc:`GameConstructionEvent`이 발생합니다. 이 상태 동안 각 플러그인에 대 한 ``@Plugin`` 클래스 인스턴스가 발생합니다.

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.

Running States

Running States can occur multiple times during a single run. SERVER_ABOUT_TO_START may follow SERVER_STOPPED, and SERVER_STOPPED may occur at any point during the process if there is an error.

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)

경고

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 GameStoppingServerEvent is triggered. This state occurs immediately before GAME_STOPPED. Plugins providing an API should still be capable of accepting basic requests.

GAME_STOPPED

The GameStoppedServerEvent 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.