added server shutdown event, along with making the outposts cleanup on server shutdown to prevent debris of currently in-play outposts sticking around.

This commit is contained in:
NewGarbo 2016-01-07 19:36:52 +00:00
parent 90a06d97b5
commit fff6d8e03f
6 changed files with 67 additions and 11 deletions

View File

@ -0,0 +1,33 @@
package mineplex.core.common.events;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.bukkit.plugin.java.JavaPlugin;
public class ServerShutdownEvent extends Event
{
private static final HandlerList handlers = new HandlerList();
private JavaPlugin _plugin;
public ServerShutdownEvent(JavaPlugin plugin)
{
_plugin = plugin;
}
public JavaPlugin getPlugin()
{
return _plugin;
}
public HandlerList getHandlers()
{
return handlers;
}
public static HandlerList getHandlerList()
{
return handlers;
}
}

View File

@ -13,6 +13,7 @@ import mineplex.core.antihack.AntiHack;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.chat.Chat;
import mineplex.core.command.CommandCenter;
import mineplex.core.common.events.ServerShutdownEvent;
import mineplex.core.delayedtask.DelayedTask;
import mineplex.core.donation.DonationManager;
import mineplex.core.explosion.Explosion;
@ -175,5 +176,7 @@ public class Clans extends JavaPlugin
// Need to notify WorldEventManager of server shutdown, this seemed like
// the only decent way to do it
_clansManager.onDisable();
getServer().getPluginManager().callEvent(new ServerShutdownEvent(this));
}
}

View File

@ -109,10 +109,10 @@ public class Outpost implements Listener
_blocks = null;
if (_preHologram != null) _preHologram.stop();
if (_preHologram2 != null) _preHologram2.stop();
if (_preHologram2 != null) _preHologram2.stop();
_preHologram = null;
_preHologram = null;
_preHologram2 = null;
_state = OutpostState.DEAD;
@ -147,6 +147,7 @@ public class Outpost implements Listener
{
if (event.getClickedBlock().getType().equals(Material.NETHERRACK))
{
_origin.getBlock().setType(Material.AIR);
beginConstruction();
}
}
@ -335,6 +336,13 @@ public class Outpost implements Listener
return list;
}
public void instakill()
{
_blocks.values().forEach(OutpostBlock::restore);
cleanup();
}
public void kill()
{
_state = OutpostState.DESTRUCTING;

View File

@ -14,6 +14,7 @@ import org.bukkit.event.block.BlockPlaceEvent;
import org.bukkit.event.entity.EntityChangeBlockEvent;
import mineplex.core.MiniPlugin;
import mineplex.core.common.events.ServerShutdownEvent;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilAlg;
import mineplex.core.common.util.UtilItem;
@ -141,6 +142,15 @@ public class OutpostManager extends MiniPlugin
}
}
@EventHandler
public void onServerShutdown(ServerShutdownEvent event)
{
for (Outpost outpost : _outposts.values())
{
outpost.instakill();
}
}
@EventHandler
public void onClaim(PlayerClaimTerritoryEvent event)
{

View File

@ -13,6 +13,7 @@ import mineplex.core.aprilfools.AprilFoolsManager;
import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.chat.Chat;
import mineplex.core.command.CommandCenter;
import mineplex.core.common.events.ServerShutdownEvent;
import mineplex.core.creature.Creature;
import mineplex.core.customdata.CustomDataManager;
import mineplex.core.disguise.DisguiseManager;
@ -65,7 +66,6 @@ import mineplex.minecraft.game.classcombat.shop.ClassCombatShop;
import mineplex.minecraft.game.classcombat.shop.ClassShopManager;
import mineplex.minecraft.game.core.IRelation;
import mineplex.minecraft.game.core.combat.CombatManager;
import mineplex.minecraft.game.core.condition.ConditionManager;
import mineplex.minecraft.game.core.damage.DamageManager;
import mineplex.minecraft.game.core.fire.Fire;
@ -188,7 +188,7 @@ public class Hub extends JavaPlugin implements IRelation
@Override
public void onDisable()
{
getServer().getPluginManager().callEvent(new ServerShutdownEvent(this));
}
@Override

View File

@ -6,15 +6,9 @@ import org.bukkit.Bukkit;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.CustomTagFix;
import mineplex.core.FoodDupeFix;
import mineplex.core.PacketsInteractionFix;
import mineplex.core.account.CoreClient;
import mineplex.core.customdata.CustomDataManager;
import mineplex.core.giveaway.GiveawayManager;
import mineplex.core.globalpacket.GlobalPacketManager;
import net.minecraft.server.v1_8_R3.BiomeBase;
import net.minecraft.server.v1_8_R3.MinecraftServer;
import mineplex.core.CustomTagFix;
import mineplex.core.account.CoreClientManager;
import mineplex.core.achievement.AchievementManager;
import mineplex.core.antihack.AntiHack;
@ -22,15 +16,19 @@ import mineplex.core.blockrestore.BlockRestore;
import mineplex.core.blood.Blood;
import mineplex.core.chat.Chat;
import mineplex.core.command.CommandCenter;
import mineplex.core.common.events.ServerShutdownEvent;
import mineplex.core.common.util.FileUtil;
import mineplex.core.common.util.UtilServer;
import mineplex.core.cosmetic.CosmeticManager;
import mineplex.core.creature.Creature;
import mineplex.core.customdata.CustomDataManager;
import mineplex.core.disguise.DisguiseManager;
import mineplex.core.donation.DonationManager;
import mineplex.core.friend.FriendManager;
import mineplex.core.gadget.GadgetManager;
import mineplex.core.give.Give;
import mineplex.core.giveaway.GiveawayManager;
import mineplex.core.globalpacket.GlobalPacketManager;
import mineplex.core.hologram.HologramManager;
import mineplex.core.ignore.IgnoreManager;
import mineplex.core.inventory.InventoryManager;
@ -61,6 +59,8 @@ import mineplex.core.visibility.VisibilityManager;
import mineplex.minecraft.game.core.combat.CombatManager;
import mineplex.minecraft.game.core.damage.DamageManager;
import nautilus.game.arcade.game.GameServerConfig;
import net.minecraft.server.v1_8_R3.BiomeBase;
import net.minecraft.server.v1_8_R3.MinecraftServer;
public class Arcade extends JavaPlugin
{
@ -186,6 +186,8 @@ public class Arcade extends JavaPlugin
if (_gameManager.GetGame() != null)
if (_gameManager.GetGame().WorldData != null)
_gameManager.GetGame().WorldData.Uninitialize();
getServer().getPluginManager().callEvent(new ServerShutdownEvent(this));
}
public GameServerConfig ReadServerConfig()