Added auto restart for Dominate if startup errored.

Added extra check for <= 1 players in Dom game to shutdown.
Added 5 second delay to Dom kick after game finish.
This commit is contained in:
Jonathan Williams 2014-02-12 02:31:35 -08:00
parent a75ced170c
commit 95210de788
5 changed files with 726 additions and 178 deletions

View File

@ -49,6 +49,7 @@ import mineplex.minecraft.game.core.mechanics.PistonJump;
import mineplex.minecraft.game.core.mechanics.Weapon; import mineplex.minecraft.game.core.mechanics.Weapon;
import nautilus.game.core.util.NullChunkGenerator; import nautilus.game.core.util.NullChunkGenerator;
import org.bukkit.Bukkit;
import org.bukkit.Location; import org.bukkit.Location;
import org.bukkit.generator.ChunkGenerator; import org.bukkit.generator.ChunkGenerator;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -83,68 +84,83 @@ public abstract class GamePlugin extends JavaPlugin implements IRelation
@Override @Override
public void onEnable() public void onEnable()
{ {
getConfig().addDefault(WEB_CONFIG, "http://api.mineplex.com/"); try
getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG)); {
saveConfig(); getConfig().addDefault(WEB_CONFIG, "http://api.mineplex.com/");
getConfig().set(WEB_CONFIG, getConfig().getString(WEB_CONFIG));
saveConfig();
_spawnLocation = new Location(getServer().getWorlds().get(0), -7.5, 18.5, 24.5, 90, 0); _spawnLocation = new Location(getServer().getWorlds().get(0), -7.5, 18.5, 24.5, 90, 0);
ClientManager = CoreClientManager.Initialize(this, GetWebServerAddress()); ClientManager = CoreClientManager.Initialize(this, GetWebServerAddress());
CommandCenter.Initialize(this, ClientManager); CommandCenter.Initialize(this, ClientManager);
FakeEntityManager.Initialize(this); FakeEntityManager.Initialize(this);
ItemStackFactory.Initialize(this, true); ItemStackFactory.Initialize(this, true);
Recharge.Initialize(this); Recharge.Initialize(this);
_moduleManager = new ModuleManager(); _moduleManager = new ModuleManager();
Updater updater = new Updater(this); Updater updater = new Updater(this);
_creature = new Creature(this); _creature = new Creature(this);
Energy = new Energy(this); Energy = new Energy(this);
DonationManager = new DonationManager(this, GetWebServerAddress()); DonationManager = new DonationManager(this, GetWebServerAddress());
ConditionManager = new SkillConditionManager(this); ConditionManager = new SkillConditionManager(this);
CombatManager = new CombatManager(this); CombatManager = new CombatManager(this);
_blockRestore = new BlockRestore(this); _blockRestore = new BlockRestore(this);
_throw = new ProjectileManager(this); _throw = new ProjectileManager(this);
_spawn = new Spawn(this); _spawn = new Spawn(this);
_teleport = new Teleport(this, ClientManager, _spawn); _teleport = new Teleport(this, ClientManager, _spawn);
NpcManager = new NpcManager(this, _creature); NpcManager = new NpcManager(this, _creature);
PacketHandler = new PacketHandler(this); PacketHandler = new PacketHandler(this);
_damage = new DamageManager(this, CombatManager, NpcManager, new DisguiseManager(this, PacketHandler)); _damage = new DamageManager(this, CombatManager, NpcManager, new DisguiseManager(this, PacketHandler));
_fire = new Fire(this, ConditionManager, _damage); _fire = new Fire(this, ConditionManager, _damage);
new Punish(this, GetWebServerAddress(), ClientManager); new Punish(this, GetWebServerAddress(), ClientManager);
new ServerStatusManager(this, new LagMeter(this, ClientManager)); new ServerStatusManager(this, new LagMeter(this, ClientManager));
SkillManager = new SkillFactory(this, _damage, this, CombatManager, ConditionManager, _throw, _blockRestore, _fire, new Movement(this), _teleport, Energy, GetWebServerAddress()); SkillManager = new SkillFactory(this, _damage, this, CombatManager, ConditionManager, _throw, _blockRestore, _fire, new Movement(this), _teleport, Energy, GetWebServerAddress());
ClassManager = new ClassManager(this, ClientManager, DonationManager, SkillManager, GetWebServerAddress()); ClassManager = new ClassManager(this, ClientManager, DonationManager, SkillManager, GetWebServerAddress());
new ItemFactory(this, _blockRestore, ClassManager, ConditionManager, _damage, Energy, _fire, _throw, GetWebServerAddress(), new HashSet<String>()); new ItemFactory(this, _blockRestore, ClassManager, ConditionManager, _damage, Energy, _fire, _throw, GetWebServerAddress(), new HashSet<String>());
new MessageManager(this, ClientManager); new MessageManager(this, ClientManager);
new Blood(this); new Blood(this);
new JoinQuit(); new JoinQuit();
new Server(); new Server();
new AntiStack(this); new AntiStack(this);
new MemoryFix(this); new MemoryFix(this);
new PistonJump(this); new PistonJump(this);
new Weapon(this, Energy); new Weapon(this, Energy);
new FileUpdater(this, new Portal(this)); new FileUpdater(this, new Portal(this));
getServer().getScheduler().scheduleSyncRepeatingTask(this, updater, 1, 1); getServer().getScheduler().scheduleSyncRepeatingTask(this, updater, 1, 1);
// _serverListener = new ServerListener(GetWebServerAddress(), getServer().getIp(), getServer().getPort() + 1); // _serverListener = new ServerListener(GetWebServerAddress(), getServer().getIp(), getServer().getPort() + 1);
// _serverListener.start(); // _serverListener.start();
//HubConnection = new ServerTalker(getConfig().getString(HUB_SERVER)); //HubConnection = new ServerTalker(getConfig().getString(HUB_SERVER));
// HubConnection.start(); // HubConnection.start();
//HubConnection.QueuePacket(new ServerReadyPacket(getServer().getIp() + ":" + getServer().getPort())); //HubConnection.QueuePacket(new ServerReadyPacket(getServer().getIp() + ":" + getServer().getPort()));
ClassShopManager shopManager = new ClassShopManager(this, ClassManager, SkillManager, null); ClassShopManager shopManager = new ClassShopManager(this, ClassManager, SkillManager, null);
new ClassCombatShop(shopManager, ClientManager, DonationManager, "Select Class Here"); new ClassCombatShop(shopManager, ClientManager, DonationManager, "Select Class Here");
new ClassCombatPurchaseShop(shopManager, ClientManager, DonationManager, "Skill Shop"); new ClassCombatPurchaseShop(shopManager, ClientManager, DonationManager, "Skill Shop");
new ClassCombatCustomBuildShop(shopManager, ClientManager, DonationManager, "Class Setup"); new ClassCombatCustomBuildShop(shopManager, ClientManager, DonationManager, "Class Setup");
}
catch (Exception exception)
{
System.out.println("Exception during startup. Restarting in 15 seconds.");
getServer().getScheduler().scheduleSyncDelayedTask(this, new Runnable()
{
public void run()
{
Bukkit.shutdown();
}
}, 300L);
}
} }
protected abstract String GetServerName(); protected abstract String GetServerName();

View File

@ -1088,7 +1088,7 @@ public abstract class GameEngine<GameType extends IGame<ArenaType, PlayerType>,
GameType game = GetGameForPlayer(player); GameType game = GetGameForPlayer(player);
PlayerType gamePlayer = game.GetPlayer(player); PlayerType gamePlayer = game.GetPlayer(player);
if (ActiveGames.contains(game) || GamesInSetup.contains(game)) if (game.IsActive() || GamesInSetup.contains(game))
{ {
GamePlayerQuitEvent<GameType, PlayerType> customEvent = new GamePlayerQuitEvent<GameType, PlayerType>(game, gamePlayer); GamePlayerQuitEvent<GameType, PlayerType> customEvent = new GamePlayerQuitEvent<GameType, PlayerType>(game, gamePlayer);
Plugin.getServer().getPluginManager().callEvent(customEvent); Plugin.getServer().getPluginManager().callEvent(customEvent);
@ -1109,7 +1109,7 @@ public abstract class GameEngine<GameType extends IGame<ArenaType, PlayerType>,
} }
} }
if (!online) if (!online || Bukkit.getOnlinePlayers().length <= 1)
Plugin.getServer().shutdown(); Plugin.getServer().shutdown();
} }
else else

View File

@ -526,12 +526,18 @@ public abstract class TeamGameEngine<GameType extends ITeamGame<ArenaType, Playe
} }
@EventHandler(priority = EventPriority.HIGHEST) @EventHandler(priority = EventPriority.HIGHEST)
public void onGameFinished(TeamGameFinishedEvent<GameType, PlayerTeamType, PlayerType> event) public void onGameFinished(final TeamGameFinishedEvent<GameType, PlayerTeamType, PlayerType> event)
{ {
for (PlayerType player : event.GetGame().GetPlayers()) Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Plugin, new GenericRunnable<GameType>(event.GetGame())
{ {
Portal.SendPlayerToServer(player.GetPlayer(), "Lobby"); public void run()
} {
for (PlayerType player : event.GetGame().GetPlayers())
{
Portal.SendPlayerToServer(player.GetPlayer(), "Lobby");
}
}
}, 100L);
Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Plugin, new GenericRunnable<GameType>(event.GetGame()) Bukkit.getServer().getScheduler().scheduleSyncDelayedTask(Plugin, new GenericRunnable<GameType>(event.GetGame())
{ {

File diff suppressed because it is too large Load Diff

Binary file not shown.