More lifecycle events/fixes
Signed-off-by: Chris Sanders <zidane@outlook.com>
This commit is contained in:
1 parent
5a96c646c0
commit
aebda67de8
7 files changed
+85
-11
No files matched your search
+1
-1
@@ -56,7 +56,7 @@ repositories {
|
||||
|
||||
// Project dependencies
|
||||
dependencies {
|
||||
compile 'org.apache.logging.log4j:log4j-api:2.0.2'
|
||||
compile 'org.apache.logging.log4j:log4j-api:2.0-beta9'
|
||||
}
|
||||
|
||||
// Filter, process, and include resources
|
||||
|
||||
@@ -1,15 +1,15 @@
|
||||
package org.spongepowered.example;
|
||||
|
||||
import org.spongepowered.api.event.SpongeEventHandler;
|
||||
import org.spongepowered.api.event.state.SpongeInitializedEvent;
|
||||
import org.spongepowered.api.event.state.SpongeInitializationEvent;
|
||||
import org.spongepowered.api.event.state.SpongeServerStartingEvent;
|
||||
import org.spongepowered.api.plugin.Plugin;
|
||||
|
||||
@Plugin(id = "ExamplePlugin", name = "Example")
|
||||
public class ExamplePlugin {
|
||||
@SpongeEventHandler
|
||||
public void onInitialized(SpongeInitializedEvent event) {
|
||||
event.game.getLogger().info("Hey folks, I'm initialized!");
|
||||
public void onInitialization(SpongeInitializationEvent event) {
|
||||
event.game.getLogger().info("Hey folks, this is INITIALIZATION!");
|
||||
}
|
||||
|
||||
@SpongeEventHandler
|
||||
|
||||
@@ -27,5 +27,5 @@ package org.spongepowered.api;
|
||||
* TODO Need to match this closely to FML's lifecycle
|
||||
*/
|
||||
public enum GameState {
|
||||
DISABLED, DISABLING, ENABLED, ENABLING, INITIALIZED, SERVER_STARTING
|
||||
DISABLED, DISABLING, ENABLED, ENABLING, INITIALIZED, LOAD, SERVER_ABOUT_TO_START, SERVER_STARTING
|
||||
}
|
||||
@@ -39,6 +39,8 @@ public abstract class SpongeEvent {
|
||||
public final Game game;
|
||||
private final boolean isCancellable;
|
||||
private boolean isCancelled;
|
||||
public Result result = Result.NO_RESULT;
|
||||
|
||||
public SpongeEvent(Game game) {
|
||||
this.game = game;
|
||||
isCancellable = hasAnnotation(Cancellable.class);
|
||||
@@ -48,10 +50,6 @@ public abstract class SpongeEvent {
|
||||
return getClass().getSimpleName();
|
||||
}
|
||||
|
||||
public Result getResult() {
|
||||
return Result.NO_RESULT;
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns if this event can be cancelled.
|
||||
*
|
||||
|
||||
+2
-2
@@ -26,8 +26,8 @@ package org.spongepowered.api.event.state;
|
||||
import org.spongepowered.api.Game;
|
||||
import org.spongepowered.api.GameState;
|
||||
|
||||
public class SpongeInitializedEvent extends SpongeStateEvent {
|
||||
public SpongeInitializedEvent(Game game) {
|
||||
public class SpongeInitializationEvent extends SpongeStateEvent {
|
||||
public SpongeInitializationEvent(Game game) {
|
||||
super(game);
|
||||
}
|
||||
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2014 SpongePowered <http://spongepowered.org/>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.api.event.state;
|
||||
|
||||
import org.spongepowered.api.Game;
|
||||
import org.spongepowered.api.GameState;
|
||||
|
||||
public class SpongeLoadEvent extends SpongeStateEvent {
|
||||
public SpongeLoadEvent(Game game) {
|
||||
super(game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameState getState() {
|
||||
return GameState.LOAD;
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,38 @@
|
||||
/**
|
||||
* This file is part of SpongeAPI, licensed under the MIT License (MIT).
|
||||
*
|
||||
* Copyright (c) 2014 SpongePowered <http://spongepowered.org/>
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
package org.spongepowered.api.event.state;
|
||||
|
||||
import org.spongepowered.api.Game;
|
||||
import org.spongepowered.api.GameState;
|
||||
|
||||
public class SpongeServerAboutToStartEvent extends SpongeStateEvent {
|
||||
public SpongeServerAboutToStartEvent(Game game) {
|
||||
super(game);
|
||||
}
|
||||
|
||||
@Override
|
||||
public GameState getState() {
|
||||
return GameState.SERVER_ABOUT_TO_START;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user