Remove all chickens on game state change and stop chickens spawning in any UHC type

This commit is contained in:
AlexTheCoder 2016-11-25 00:36:24 -05:00 committed by Shaun Bennett
parent 26262479f6
commit 6fefd71bb8

View File

@ -4,9 +4,6 @@ import java.util.EnumMap;
import java.util.HashSet; import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.PacketPlayOutBlockAction;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Color; import org.bukkit.Color;
import org.bukkit.Effect; import org.bukkit.Effect;
@ -18,13 +15,13 @@ import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_8_R3.util.CraftMagicNumbers; import org.bukkit.craftbukkit.v1_8_R3.util.CraftMagicNumbers;
import org.bukkit.entity.Chicken; import org.bukkit.entity.Chicken;
import org.bukkit.entity.Entity;
import org.bukkit.entity.Item; import org.bukkit.entity.Item;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.entity.EntityDamageByEntityEvent; import org.bukkit.event.entity.EntityDamageByEntityEvent;
import org.bukkit.event.entity.EntityDamageEvent; import org.bukkit.event.entity.EntityDamageEvent;
import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.player.PlayerCommandPreprocessEvent; import org.bukkit.event.player.PlayerCommandPreprocessEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerPickupItemEvent; import org.bukkit.event.player.PlayerPickupItemEvent;
@ -53,13 +50,14 @@ import mineplex.core.reward.RewardRarity;
import mineplex.core.treasure.TreasureType; import mineplex.core.treasure.TreasureType;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
import nautilus.game.arcade.ArcadeManager; import nautilus.game.arcade.ArcadeManager;
import nautilus.game.arcade.GameType;
import nautilus.game.arcade.events.GameStateChangeEvent; import nautilus.game.arcade.events.GameStateChangeEvent;
import nautilus.game.arcade.game.Game; import nautilus.game.arcade.game.Game;
import nautilus.game.arcade.game.Game.GameState; import nautilus.game.arcade.game.Game.GameState;
import nautilus.game.arcade.game.games.uhc.UHC;
import nautilus.game.arcade.managers.events.SpecialEntityDeathEvent; import nautilus.game.arcade.managers.events.SpecialEntityDeathEvent;
import net.minecraft.server.v1_8_R3.BlockPosition;
import net.minecraft.server.v1_8_R3.PacketPlayOutBlockAction;
public class HolidayManager implements Listener public class HolidayManager implements Listener
{ {
@ -105,7 +103,7 @@ public class HolidayManager implements Listener
private EternalGiveawayManager _eternalGiveawayManager; private EternalGiveawayManager _eternalGiveawayManager;
public HashSet<Block> _active = new HashSet<>(); public HashSet<Block> _active = new HashSet<>();
public HashSet<org.bukkit.entity.Entity> _activeEntities = new HashSet<>(); public HashSet<Entity> _activeEntities = new HashSet<>();
private HashSet<Item> _items = new HashSet<>(); private HashSet<Item> _items = new HashSet<>();
@ -139,6 +137,8 @@ public class HolidayManager implements Listener
public void reset(GameStateChangeEvent event) public void reset(GameStateChangeEvent event)
{ {
_active.clear(); _active.clear();
_activeEntities.forEach(entity -> entity.remove());
_activeEntities.clear();
_lastSpawn = System.currentTimeMillis(); _lastSpawn = System.currentTimeMillis();
} }
@ -254,7 +254,7 @@ public class HolidayManager implements Listener
if (game.GetState() != GameState.Live) if (game.GetState() != GameState.Live)
return; return;
if (game.GetType().equals(GameType.UHC)) if (game instanceof UHC)
return; return;
if (!UtilTime.elapsed(_lastSpawn, 90000)) if (!UtilTime.elapsed(_lastSpawn, 90000))