Added event to be called when game stops

This commit is contained in:
LCastr0 2017-04-07 14:13:53 -03:00
parent b441dc5edf
commit 8bcb5bc948
2 changed files with 49 additions and 1 deletions

View File

@ -0,0 +1,41 @@
package mineplex.core.arcadeevents;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
/**
* This event is called when a game stops in arcade
* It's called inside Arcade and handled inside Core,
* so we can track game events in core
*/
public class CoreGameStopEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private GameType _gameType;
/**
* @param gameType the type of the game
*/
public CoreGameStopEvent(GameType gameType)
{
_gameType = gameType;
}
public GameType getGameType()
{
return _gameType;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
}

View File

@ -51,6 +51,7 @@ import com.mojang.authlib.GameProfile;
import mineplex.core.Managers;
import mineplex.core.antihack.AntiHack;
import mineplex.core.arcadeevents.CoreGameStartEvent;
import mineplex.core.arcadeevents.CoreGameStopEvent;
import mineplex.core.command.CommandCenter;
import mineplex.core.common.Rank;
import mineplex.core.common.util.C;
@ -745,13 +746,19 @@ public abstract class Game extends ListenerComponent implements Lifetimed
UtilServer.getServer().getPluginManager().callEvent(stateEvent);
System.out.println(GetName() + " state set to " + state.toString());
if (state.equals(GameState.Prepare))
{
mineplex.core.arcadeevents.GameType gameType = mineplex.core.arcadeevents.GameType.valueOf(GetType().toString().toUpperCase());;
CoreGameStartEvent coreGameStartEvent = new CoreGameStartEvent(gameType);
UtilServer.getServer().getPluginManager().callEvent(coreGameStartEvent);
}
else if (state.equals(GameState.End))
{
mineplex.core.arcadeevents.GameType gameType = mineplex.core.arcadeevents.GameType.valueOf(GetType().toString().toUpperCase());;
CoreGameStopEvent coreGameStopEvent = new CoreGameStopEvent(gameType);
UtilServer.getServer().getPluginManager().callEvent(coreGameStopEvent);
}
}
public void SetStateTime(long time)