Ciclo de Vida de um Plugin

Antes de qualquer estado que fazem do plugin visível, o “carregador de plugins” primeiro organiza todos plugins disponíveis, determina se suas dependências estão presentes, e organiza os plugins por ordem de dependência. Os eventos de “ciclo de vida” são enviado para os plugins nesta ordem. Por exemplo, um plugin contendo “[required-]after:B” (“[requerido-]após:B” em tradução livre) irá receber os eventos após o plugin B completar o processo para o determinado estado. Além disto, o ciclo de vida é global. Isto significa que todos plugins visíveis ao outro devem passar por todos estados ao mesmo tempo.

Aviso

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

Eventos de estado

Existem três categorias de eventos de estado:

  1. Inicialização: Quando o Sponge e todos os plugins estão carregando, antes do jogo realmente iniciar. Estados de inicialização só ocorrem uma vez.

  2. Funcionando: Quando o jogo e o mundo estão carregando. Estados de funcionamento podem ocorrer múltiplas vezes.

  3. Parando: Quando o jogo está parando. Estados de parada, igualmente aos estados de inicialização, só ocorrem uma vez.

Estados de inicialização

Estados de inicialização somente ocorrem uma vez durante uma única inicialização.

CONSTRUCTION (CONSTRUÇÃO)

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

PRE_INITIALIZATION (PRE_INICIALIZAÇÃO)

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 (INICIALIZAÇÃO)

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 (PÓS INICIALIZAÇÃO)

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 (CARREGAMENTO COMPLETO)

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

Estados de execução

Estados de execução podem ocorrer várias vezes durante uma única incialização. SERVER_ABOUT_TO_START pode ser chamado junto com SERVER_STOPPED, e SERVER_STOPPED pode ocorrer a qualquer momento durante o processo caso haja erro.

SERVER_ABOUT_TO_START (SERVIDOR PERTO DE INICIAR)

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

SERVER_STARTING (SERVIDOR INICIANDO)

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

SERVER_STARTED (SERVIDOR INICIADO)

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

SERVER_STOPPING (SERVIDOR PARANDO)

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

SERVER_STOPPED (SERVIDOR PAROU)

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

Estados de parada

Os estados de parada nunca ocorrem mais de uma vez. Eles ocorrem quando o jogo para normalmente. (Em servidores: O comando /stop é digitado. Em clientes: Ao clicar no botão “Fechar” ou “Sair do Jogo”)

Aviso

Não é garantido que os estados de parada serão chamados quando o servidor fechar. Eles podem não ser chamados caso o jogo for forçado a fechar, via Ctrl-C, gerenciador de tarefas, uma falha no computador, ou situações similares.

GAME_STOPPING (JOGO PARANDO)

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 (JOGO PAROU)

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.