Block Hunt Update (#604)

This commit is contained in:
Sam 2018-04-12 08:37:41 +01:00 committed by Alexander Meech
parent 0154c4d1c4
commit 6d42c5c075
4 changed files with 347 additions and 243 deletions

View File

@ -120,7 +120,15 @@ public enum AchievementCategory
Material.EGG, 0, GameCategory.CLASSICS, null, false, GameDisplay.BawkBawkBattles.getGameId()), Material.EGG, 0, GameCategory.CLASSICS, null, false, GameDisplay.BawkBawkBattles.getGameId()),
BLOCK_HUNT("Block Hunt", null, BLOCK_HUNT("Block Hunt", null,
new StatDisplay[] { StatDisplay.WINS, StatDisplay.GAMES_PLAYED, StatDisplay.KILLS, StatDisplay.DEATHS, StatDisplay.GEMS_EARNED }, new StatDisplay[]
{
StatDisplay.fromGame("Hider Wins", GameDisplay.HideSeek, "Wins"),
StatDisplay.fromGame("Hunter Wins", GameDisplay.HideSeek, "HunterWins"),
StatDisplay.fromGame("Games Played", GameDisplay.HideSeek, "Wins", "HunterWins", "Losses"),
StatDisplay.KILLS,
StatDisplay.DEATHS,
StatDisplay.GEMS_EARNED
},
Material.GRASS, 0, GameCategory.CLASSICS, "Infestor Kit", false, GameDisplay.HideSeek.getGameId()), Material.GRASS, 0, GameCategory.CLASSICS, "Infestor Kit", false, GameDisplay.HideSeek.getGameId()),
SMASH_MOBS("Super Smash Mobs", null, SMASH_MOBS("Super Smash Mobs", null,

View File

@ -6,6 +6,7 @@ import java.util.HashSet;
import java.util.Iterator; import java.util.Iterator;
import java.util.List; import java.util.List;
import java.util.Map.Entry; import java.util.Map.Entry;
import java.util.Set;
import net.minecraft.server.v1_8_R3.EntityCreature; import net.minecraft.server.v1_8_R3.EntityCreature;
import net.minecraft.server.v1_8_R3.NavigationAbstract; import net.minecraft.server.v1_8_R3.NavigationAbstract;
@ -44,10 +45,12 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.HandlerList; import org.bukkit.event.HandlerList;
import org.bukkit.event.block.Action; import org.bukkit.event.block.Action;
import org.bukkit.event.block.BlockDamageEvent; import org.bukkit.event.block.BlockDamageEvent;
import org.bukkit.event.block.BlockPhysicsEvent;
import org.bukkit.event.entity.EntityChangeBlockEvent; import org.bukkit.event.entity.EntityChangeBlockEvent;
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.EntityDamageEvent.DamageCause; import org.bukkit.event.entity.EntityDamageEvent.DamageCause;
import org.bukkit.event.entity.EntityExplodeEvent;
import org.bukkit.event.entity.EntityShootBowEvent; import org.bukkit.event.entity.EntityShootBowEvent;
import org.bukkit.event.entity.ItemSpawnEvent; import org.bukkit.event.entity.ItemSpawnEvent;
import org.bukkit.event.entity.PlayerDeathEvent; import org.bukkit.event.entity.PlayerDeathEvent;
@ -55,7 +58,6 @@ import org.bukkit.event.player.PlayerEvent;
import org.bukkit.event.player.PlayerInteractEntityEvent; import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerInteractEvent; import org.bukkit.event.player.PlayerInteractEvent;
import org.bukkit.event.player.PlayerQuitEvent; import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.vehicle.VehicleExitEvent;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.FireworkMeta; import org.bukkit.inventory.meta.FireworkMeta;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
@ -79,9 +81,10 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer; import mineplex.core.common.util.UtilServer;
import mineplex.core.common.util.UtilTime; import mineplex.core.common.util.UtilTime;
import mineplex.core.disguise.disguises.DisguiseBase; import mineplex.core.disguise.disguises.DisguiseBase;
import mineplex.core.disguise.disguises.DisguiseLiving;
import mineplex.core.itemstack.ItemStackFactory; import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.packethandler.IPacketHandler; import mineplex.core.packethandler.IPacketHandler;
import mineplex.core.packethandler.PacketInfo; import mineplex.core.packethandler.PacketHandler;
import mineplex.core.recharge.Recharge; import mineplex.core.recharge.Recharge;
import mineplex.core.updater.UpdateType; import mineplex.core.updater.UpdateType;
import mineplex.core.updater.event.UpdateEvent; import mineplex.core.updater.event.UpdateEvent;
@ -134,7 +137,7 @@ public class HideSeek extends TeamGame
return getHandlerList(); return getHandlerList();
} }
public MeowEvent(Player who) MeowEvent(Player who)
{ {
super(who); super(who);
} }
@ -191,7 +194,7 @@ public class HideSeek extends TeamGame
} }
} }
public static final ItemStack PLAYER_ITEM = ItemStackFactory.Instance.CreateStack(Material.SLIME_BALL, (byte) 0, 1, C.cYellow + C.Bold + "Click Block" + C.cWhite + C.Bold + " - " + C.cGreen + C.Bold + "Change Form"); public static final ItemStack PLAYER_ITEM = ItemStackFactory.Instance.CreateStack(Material.SLIME_BALL, (byte) 0, 1, C.cYellowB + "Click Block" + C.cWhiteB + " - " + C.cGreenB + "Change Form");
private GameTeam _hiders; private GameTeam _hiders;
private GameTeam _seekers; private GameTeam _seekers;
@ -204,21 +207,20 @@ public class HideSeek extends TeamGame
private boolean _started = false; private boolean _started = false;
private HashMap<Player, Integer> _arrowHits = new HashMap<Player, Integer>(); private final HashMap<Player, Integer> _arrowHits = new HashMap<>();
private HashMap<Player, Form> _forms = new HashMap<Player, Form>(); private final HashMap<Player, Form> _forms = new HashMap<>();
private HashMap<Player, InfestedData> _infested = new HashMap<Player, InfestedData>(); private final HashMap<Player, InfestedData> _infested = new HashMap<>();
private HashSet<LivingEntity> _infestDeny = new HashSet<LivingEntity>(); private final HashSet<LivingEntity> _infestDeny = new HashSet<>();
private HashMap<Creature, Location> _mobs = new HashMap<Creature, Location>(); private final HashMap<Creature, Location> _mobs = new HashMap<>();
private ArrayList<Material> _allowedBlocks; private ArrayList<Material> _allowedBlocks;
private ArrayList<EntityType> _allowedEnts; private ArrayList<EntityType> _allowedEnts;
private IPacketHandler _useEntity = new IPacketHandler() private final Set<Player> _startingHunters = new HashSet<>();
{
@Override private final IPacketHandler _useEntity = packetInfo ->
public void handle(PacketInfo packetInfo)
{ {
if (packetInfo.getPacket() instanceof PacketPlayInUseEntity) if (packetInfo.getPacket() instanceof PacketPlayInUseEntity)
{ {
@ -232,20 +234,15 @@ public class HideSeek extends TeamGame
if (blockForm.getBlockId() == id) if (blockForm.getBlockId() == id)
{ {
((PacketPlayInUseEntity) packetInfo.getPacket()).a = blockForm.Player ((PacketPlayInUseEntity) packetInfo.getPacket()).a = blockForm.Player.getEntityId();
.getEntityId();
break; break;
} }
} }
} }
} }
}
}; };
private IPacketHandler _blockDisguise = new IPacketHandler() private final IPacketHandler _blockDisguise = packetInfo ->
{
@Override
public void handle(PacketInfo packetInfo)
{ {
if (packetInfo.getPacket() instanceof PacketPlayOutSpawnEntityLiving) if (packetInfo.getPacket() instanceof PacketPlayOutSpawnEntityLiving)
{ {
@ -264,14 +261,7 @@ public class HideSeek extends TeamGame
final Player player = packetInfo.getPlayer(); final Player player = packetInfo.getPlayer();
Bukkit.getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), new Runnable() Bukkit.getScheduler().scheduleSyncDelayedTask(Manager.getPlugin(), () -> UtilPlayer.sendPacket(player, blockForm.getBlockPackets(UtilPlayer.is1_9(player))));
{
public void run()
{
UtilPlayer.sendPacket(player, blockForm.getBlockPackets(UtilPlayer.is1_9(player)));
}
});
break; break;
} }
} }
@ -296,7 +286,6 @@ public class HideSeek extends TeamGame
} }
} }
} }
}
}; };
public HideSeek(ArcadeManager manager) public HideSeek(ArcadeManager manager)
@ -304,7 +293,7 @@ public class HideSeek extends TeamGame
this(manager, this(manager,
new Kit[] new Kit[]
{ {
new KitHiderQuick(manager), new KitHiderSwapper(manager), new KitHiderInfestor(manager), new KitHiderSwapper(manager), new KitHiderQuick(manager), new KitHiderInfestor(manager),
new KitHiderShocker(manager), new NullKit(manager), new KitSeekerLeaper(manager), new KitHiderShocker(manager), new NullKit(manager), new KitSeekerLeaper(manager),
new KitSeekerTNT(manager), new KitSeekerRadar(manager), new KitSeekerTNT(manager), new KitSeekerRadar(manager),
}); });
@ -323,17 +312,17 @@ public class HideSeek extends TeamGame
C.cRed + "Seekers" + C.cWhite + " Find and kill the Hiders!", C.cRed + "Seekers" + C.cWhite + " Find and kill the Hiders!",
}); });
this.DamageSelf = false; DamageSelf = false;
this.DeathOut = false; DeathOut = false;
this.HungerSet = 20; HungerSet = 20;
this.PrepareFreeze = false; PrepareFreeze = false;
this.SplitKitXP = true; SplitKitXP = true;
this.AllowParticles = false; AllowParticles = false;
DeathSpectateSecs = 1;
_allowedBlocks = new ArrayList<Material>(); _allowedBlocks = new ArrayList<>();
_allowedBlocks.add(Material.TNT); _allowedBlocks.add(Material.TNT);
_allowedBlocks.add(Material.BOOKSHELF); _allowedBlocks.add(Material.BOOKSHELF);
_allowedBlocks.add(Material.WORKBENCH);
_allowedBlocks.add(Material.FURNACE); _allowedBlocks.add(Material.FURNACE);
_allowedBlocks.add(Material.MELON_BLOCK); _allowedBlocks.add(Material.MELON_BLOCK);
_allowedBlocks.add(Material.CAULDRON); _allowedBlocks.add(Material.CAULDRON);
@ -342,7 +331,7 @@ public class HideSeek extends TeamGame
_allowedBlocks.add(Material.HAY_BLOCK); _allowedBlocks.add(Material.HAY_BLOCK);
_allowedBlocks.add(Material.CAKE_BLOCK); _allowedBlocks.add(Material.CAKE_BLOCK);
_allowedEnts = new ArrayList<EntityType>(); _allowedEnts = new ArrayList<>();
_allowedEnts.add(EntityType.PIG); _allowedEnts.add(EntityType.PIG);
_allowedEnts.add(EntityType.COW); _allowedEnts.add(EntityType.COW);
_allowedEnts.add(EntityType.CHICKEN); _allowedEnts.add(EntityType.CHICKEN);
@ -377,6 +366,8 @@ public class HideSeek extends TeamGame
@EventHandler @EventHandler
public void onceReady(GamePrepareCountdownCommence event) public void onceReady(GamePrepareCountdownCommence event)
{ {
_startingHunters.addAll(_seekers.GetPlayers(false));
List<Player> hiders = _hiders.GetPlayers(false); List<Player> hiders = _hiders.GetPlayers(false);
for (Player player : hiders) for (Player player : hiders)
@ -402,15 +393,17 @@ public class HideSeek extends TeamGame
@EventHandler @EventHandler
public void onGameEndStart(GameStateChangeEvent event) public void onGameEndStart(GameStateChangeEvent event)
{ {
PacketHandler packetHandler = getArcadeManager().getPacketHandler();
if (event.GetState() == GameState.Prepare) if (event.GetState() == GameState.Prepare)
{ {
this.getArcadeManager().getPacketHandler().addPacketHandler(_blockDisguise, PacketPlayOutSpawnEntityLiving.class, PacketPlayOutEntityDestroy.class); packetHandler.addPacketHandler(_blockDisguise, PacketPlayOutSpawnEntityLiving.class, PacketPlayOutEntityDestroy.class);
this.getArcadeManager().getPacketHandler().addPacketHandler(_useEntity, true, PacketPlayInUseEntity.class); packetHandler.addPacketHandler(_useEntity, true, PacketPlayInUseEntity.class);
} }
else if (event.GetState() == GameState.Dead) else if (event.GetState() == GameState.Dead)
{ {
this.getArcadeManager().getPacketHandler().removePacketHandler(_blockDisguise); packetHandler.removePacketHandler(_blockDisguise);
this.getArcadeManager().getPacketHandler().removePacketHandler(_useEntity); packetHandler.removePacketHandler(_useEntity);
} }
} }
@ -429,28 +422,32 @@ public class HideSeek extends TeamGame
@Override @Override
public void ParseData() public void ParseData()
{ {
int i = 0; WorldData.GetAllCustomLocs().keySet().forEach(key ->
for (ArrayList<Location> locs : WorldData.GetAllCustomLocs().values())
{ {
for (Location loc : locs) if (!key.startsWith("IDS"))
{ {
if (Math.random() > 0.25) return;
continue;
if (loc.getBlock().getRelative(BlockFace.UP).getType() != Material.AIR)
continue;
loc.getBlock().setType(Material.AIR);
i++;
}
} }
System.out.println("Removed " + i + " Random Blocks."); String[] split = key.split(" ");
for (int i = 1; i < split.length; i++)
{
try
{
int id = Integer.parseInt(split[i]);
_allowedBlocks.add(Material.getMaterial(id));
}
catch (NumberFormatException ex)
{
}
}
});
for (Location loc : WorldData.GetDataLocs("BLACK")) for (Location loc : WorldData.GetDataLocs("BLACK"))
{
loc.getBlock().setType(Material.FENCE); loc.getBlock().setType(Material.FENCE);
}
} }
@EventHandler @EventHandler
@ -481,7 +478,8 @@ public class HideSeek extends TeamGame
{ {
if (kit.GetName().contains("Hider")) if (kit.GetName().contains("Hider"))
team.GetRestrictedKits().add(kit); team.GetRestrictedKits().add(kit);
} else }
else
{ {
if (kit.GetName().contains("Hunter")) if (kit.GetName().contains("Hunter"))
team.GetRestrictedKits().add(kit); team.GetRestrictedKits().add(kit);
@ -521,7 +519,8 @@ public class HideSeek extends TeamGame
bow.addEnchantment(Enchantment.ARROW_INFINITE, 1); bow.addEnchantment(Enchantment.ARROW_INFINITE, 1);
player.getInventory().setItem(1, bow); player.getInventory().setItem(1, bow);
player.getInventory().setItem(28, ItemStackFactory.Instance.CreateStack(Material.ARROW)); player.getInventory().setItem(28, ItemStackFactory.Instance.CreateStack(Material.ARROW));
} else }
else
{ {
// Axe // Axe
player.getInventory().setItem(0, player.getInventory().setItem(0,
@ -555,14 +554,11 @@ public class HideSeek extends TeamGame
@EventHandler @EventHandler
public void ChangeDisguise(PlayerInteractEvent event) public void ChangeDisguise(PlayerInteractEvent event)
{ {
if (event.getAction() == Action.PHYSICAL) if (event.getAction() == Action.PHYSICAL || event.getClickedBlock() == null)
{ {
return; return;
} }
if (event.getClickedBlock() == null)
return;
Player player = event.getPlayer(); Player player = event.getPlayer();
if (!UtilGear.isMat(player.getItemInHand(), Material.SLIME_BALL)) if (!UtilGear.isMat(player.getItemInHand(), Material.SLIME_BALL))
@ -575,7 +571,13 @@ public class HideSeek extends TeamGame
F.main("Game", F.main("Game",
"You cannot morph into " "You cannot morph into "
+ F.elem(ItemStackFactory.Instance + F.elem(ItemStackFactory.Instance
.GetName(event.getClickedBlock().getType(), (byte) 0, false) + " Block") + ".")); .GetName(event.getClickedBlock().getType(), (byte) 0, false)) + "."));
return;
}
if (UtilBlock.liquid(player.getLocation().getBlock()))
{
player.sendMessage(F.main("Game", "You cannot morph while in water."));
return; return;
} }
@ -586,9 +588,14 @@ public class HideSeek extends TeamGame
UtilInv.remove(player, Material.SLIME_BALL, (byte) 0, 1); UtilInv.remove(player, Material.SLIME_BALL, (byte) 0, 1);
// Remove Old // Remove Old
_forms.get(player).Remove(); Form form = _forms.get(player);
Form form = new BlockForm(this, player, event.getClickedBlock().getType()); if (form != null)
{
form.Remove();
}
form = new BlockForm(this, player, event.getClickedBlock().getType());
// Set New // Set New
_forms.put(player, form); _forms.put(player, form);
@ -773,7 +780,8 @@ public class HideSeek extends TeamGame
{ {
proj = (Projectile) eventEE.getDamager(); proj = (Projectile) eventEE.getDamager();
damager = (LivingEntity) proj.getShooter(); damager = (LivingEntity) proj.getShooter();
} else if (eventEE.getDamager() instanceof LivingEntity) }
else if (eventEE.getDamager() instanceof LivingEntity)
{ {
damager = (LivingEntity) eventEE.getDamager(); damager = (LivingEntity) eventEE.getDamager();
} }
@ -865,15 +873,16 @@ public class HideSeek extends TeamGame
if (!_hiders.HasPlayer(shooter)) if (!_hiders.HasPlayer(shooter))
return; return;
Arrow arrow = shooter.getWorld().spawnArrow( Location location = shooter.getEyeLocation();
shooter.getEyeLocation().add(shooter.getLocation().getDirection().multiply(1.5)),
shooter.getLocation().getDirection(), (float) event.getProjectile().getVelocity().length(), 0f); Vector direction = location.getDirection();
Arrow arrow = shooter.getWorld().spawnArrow(location.add(direction.clone().multiply(1.5)).add(new Vector(Math.random() * 0.5 - 0.25, Math.random() * 0.5 - 0.25, Math.random() * 0.5 - 0.25)), direction, (float) event.getProjectile().getVelocity().length(), 0f);
arrow.setShooter(shooter); arrow.setShooter(shooter);
event.setCancelled(true); event.setCancelled(true);
} }
@EventHandler @EventHandler(priority = EventPriority.HIGHEST)
public void ArrowHit(CustomDamageEvent event) public void ArrowHit(CustomDamageEvent event)
{ {
if (event.IsCancelled()) if (event.IsCancelled())
@ -896,9 +905,8 @@ public class HideSeek extends TeamGame
if (!_hiders.HasPlayer(damager)) if (!_hiders.HasPlayer(damager))
return; return;
event.AddMod("Hide & Seek", "Negate", -event.GetDamageInitial(), false); event.AddMod(GetName(), "Constant Damage", -event.GetDamage() + 2, false);
event.AddMod("Hide & Seek", "Damage Set", 2, false); event.AddKnockback(GetName(), 2);
event.AddKnockback("Hide & Seek", 2);
Powerup(damager); Powerup(damager);
} }
@ -922,7 +930,8 @@ public class HideSeek extends TeamGame
// Inform // Inform
UtilPlayer.message(player, F.main("Game", "You upgraded to " + F.elem("Super Axe") + "!")); UtilPlayer.message(player, F.main("Game", "You upgraded to " + F.elem("Super Axe") + "!"));
} else if (count == 8) }
else if (count == 8)
{ {
player.getInventory().remove(Material.STONE_AXE); player.getInventory().remove(Material.STONE_AXE);
player.getInventory().addItem( player.getInventory().addItem(
@ -933,7 +942,8 @@ public class HideSeek extends TeamGame
// Inform // Inform
UtilPlayer.message(player, F.main("Game", "You upgraded to " + F.elem("Ultra Axe") + "!")); UtilPlayer.message(player, F.main("Game", "You upgraded to " + F.elem("Ultra Axe") + "!"));
} else if (count == 12) }
else if (count == 12)
{ {
player.getInventory().remove(Material.IRON_AXE); player.getInventory().remove(Material.IRON_AXE);
player.getInventory().addItem( player.getInventory().addItem(
@ -944,7 +954,8 @@ public class HideSeek extends TeamGame
// Inform // Inform
UtilPlayer.message(player, F.main("Game", "You upgraded to " + F.elem("Hyper Axe") + "!")); UtilPlayer.message(player, F.main("Game", "You upgraded to " + F.elem("Hyper Axe") + "!"));
} else if (count < 12) }
else if (count < 12)
{ {
// Sound // Sound
player.playSound(player.getLocation(), Sound.ORB_PICKUP, 1f, 1f); player.playSound(player.getLocation(), Sound.ORB_PICKUP, 1f, 1f);
@ -983,7 +994,8 @@ public class HideSeek extends TeamGame
// Sound // Sound
player.getWorld().playSound(player.getLocation(), Sound.BLAZE_BREATH, 1f, 1f); player.getWorld().playSound(player.getLocation(), Sound.BLAZE_BREATH, 1f, 1f);
} else if (UtilGear.isMat(player.getItemInHand(), Material.STONE_AXE)) }
else if (UtilGear.isMat(player.getItemInHand(), Material.STONE_AXE))
{ {
Manager.GetCondition().Factory().Speed("Boost", player, player, 4, 1, false, false, false); Manager.GetCondition().Factory().Speed("Boost", player, player, 4, 1, false, false, false);
@ -992,7 +1004,8 @@ public class HideSeek extends TeamGame
// Sound // Sound
player.getWorld().playSound(player.getLocation(), Sound.BLAZE_BREATH, 1f, 1f); player.getWorld().playSound(player.getLocation(), Sound.BLAZE_BREATH, 1f, 1f);
} else if (UtilGear.isMat(player.getItemInHand(), Material.IRON_AXE)) }
else if (UtilGear.isMat(player.getItemInHand(), Material.IRON_AXE))
{ {
Manager.GetCondition().Factory().Speed("Boost", player, player, 4, 1, false, false, false); Manager.GetCondition().Factory().Speed("Boost", player, player, 4, 1, false, false, false);
Manager.GetCondition().Factory().Regen("Boost", player, player, 4, 0, false, false, false); Manager.GetCondition().Factory().Regen("Boost", player, player, 4, 0, false, false, false);
@ -1002,7 +1015,8 @@ public class HideSeek extends TeamGame
// Sound // Sound
player.getWorld().playSound(player.getLocation(), Sound.BLAZE_BREATH, 1f, 1f); player.getWorld().playSound(player.getLocation(), Sound.BLAZE_BREATH, 1f, 1f);
} else if (UtilGear.isMat(player.getItemInHand(), Material.DIAMOND_AXE)) }
else if (UtilGear.isMat(player.getItemInHand(), Material.DIAMOND_AXE))
{ {
Manager.GetCondition().Factory().Speed("Boost", player, player, 4, 2, false, false, false); Manager.GetCondition().Factory().Speed("Boost", player, player, 4, 2, false, false, false);
Manager.GetCondition().Factory().Regen("Boost", player, player, 4, 1, false, false, false); Manager.GetCondition().Factory().Regen("Boost", player, player, 4, 1, false, false, false);
@ -1101,21 +1115,11 @@ public class HideSeek extends TeamGame
while (_seekers.GetPlayers(true).size() < req && _hiders.GetPlayers(true).size() > 0) while (_seekers.GetPlayers(true).size() < req && _hiders.GetPlayers(true).size() > 0)
{ {
Player player = _hiders.GetPlayers(true).get(UtilMath.r(_hiders.GetPlayers(true).size())); Player player = UtilAlg.Random(_hiders.GetPlayers(true));
SetSeeker(player, true); SetSeeker(player, true);
} }
} }
@EventHandler
public void WaterDamage(UpdateEvent event)
{
if (!IsLive())
return;
if (event.getType() != UpdateType.FAST)
return;
}
@EventHandler @EventHandler
public void WorldWaterDamage(UpdateEvent event) public void WorldWaterDamage(UpdateEvent event)
{ {
@ -1142,6 +1146,8 @@ public class HideSeek extends TeamGame
Form form = _forms.remove(event.getPlayer()); Form form = _forms.remove(event.getPlayer());
if (form != null) if (form != null)
form.Remove(); form.Remove();
_startingHunters.remove(event.getPlayer());
} }
@EventHandler @EventHandler
@ -1154,11 +1160,19 @@ public class HideSeek extends TeamGame
public void SetSeeker(Player player, boolean forced) public void SetSeeker(Player player, boolean forced)
{ {
GameTeam pastTeam = GetTeam(player); GameTeam pastTeam = GetTeam(player);
if (pastTeam != null && pastTeam.equals(_hiders)) if (pastTeam != null && pastTeam.equals(_hiders))
{
pastTeam.SetPlacement(player, PlayerState.OUT); pastTeam.SetPlacement(player, PlayerState.OUT);
}
SetPlayerTeam(player, _seekers, true); SetPlayerTeam(player, _seekers, true);
if (IsInfesting(player))
{
InfestEnd(player);
}
// Remove Form // Remove Form
Form form = _forms.remove(player); Form form = _forms.remove(player);
if (form != null) if (form != null)
@ -1170,9 +1184,9 @@ public class HideSeek extends TeamGame
{ {
Manager.GetDisguise().undisguise(disguise); Manager.GetDisguise().undisguise(disguise);
} }
// Kit // Kit
SetKit(player, GetKits()[5], false); SetKit(player, GetKits()[5], false);
GetKits()[5].ApplyKit(player);
// Refresh // Refresh
VisibilityManager vm = Managers.require(VisibilityManager.class); VisibilityManager vm = Managers.require(VisibilityManager.class);
@ -1182,19 +1196,14 @@ public class HideSeek extends TeamGame
{ {
AddGems(player, 10, "Forced Seeker", false, false); AddGems(player, 10, "Forced Seeker", false, false);
Announce(F.main("Game", Announce(F.main("Game", F.elem(_hiders.GetColor() + player.getName()) + " was moved to " + F.elem(C.cRedB + "Hunters") + "."));
F.elem(_hiders.GetColor() + player.getName()) + " was moved to " + F.elem(C.cRed + C.Bold + "Hunters") + "."));
_startingHunters.add(player);
player.getWorld().strikeLightningEffect(player.getLocation()); player.getWorld().strikeLightningEffect(player.getLocation());
RespawnPlayer(player);
player.damage(1000);
} }
UtilPlayer.message(player, C.cRed + C.Bold + "You are now a Hunter!"); UtilPlayer.message(player, C.cRedB + "You are now a Hunter!");
player.eject();
player.leaveVehicle();
player.teleport(_seekers.GetSpawn());
} }
@Override @Override
@ -1214,6 +1223,8 @@ public class HideSeek extends TeamGame
ArrayList<Player> places = _hiders.GetPlacements(true); ArrayList<Player> places = _hiders.GetPlacements(true);
AnnounceEnd(_hiders.GetPlacements(true)); AnnounceEnd(_hiders.GetPlacements(true));
// Need to manually set the WinnerTeam otherwise no one gets XP
WinnerTeam = _hiders;
// Gems // Gems
if (places.size() >= 1) if (places.size() >= 1)
@ -1230,6 +1241,12 @@ public class HideSeek extends TeamGame
AddGems(player, 10, "Participation", false, false); AddGems(player, 10, "Participation", false, false);
SetState(GameState.End); SetState(GameState.End);
_startingHunters.forEach(player ->
{
AddStat(player, "HunterWins", 1, true, false);
GetStats().get(player).remove(GetName() + ".Losses");
});
} }
} }
@ -1256,7 +1273,7 @@ public class HideSeek extends TeamGame
if (event.GetState() != GameState.Live) if (event.GetState() != GameState.Live)
return; return;
Announce(C.cAqua + C.Bold + "Hiders have 20 Seconds to hide!"); Announce(C.cAquaB + "Hiders have 20 Seconds to hide!");
} }
@EventHandler @EventHandler
@ -1346,14 +1363,15 @@ public class HideSeek extends TeamGame
Scoreboard.writeNewLine(); Scoreboard.writeNewLine();
Scoreboard.write(C.cYellow + C.Bold + "Hide Time"); Scoreboard.write(C.cYellow + C.Bold + "Hide Time");
Scoreboard.write(UtilTime.MakeStr(Math.max(0, timeLeft), 0)); Scoreboard.write(UtilTime.MakeStr(Math.max(0, timeLeft)));
} else }
else
{ {
long timeLeft = _gameTime - (System.currentTimeMillis() - GetStateTime() - _hideTime); long timeLeft = _gameTime - (System.currentTimeMillis() - GetStateTime() - _hideTime);
Scoreboard.writeNewLine(); Scoreboard.writeNewLine();
Scoreboard.write(C.cYellow + C.Bold + "Seek Time"); Scoreboard.write(C.cYellow + C.Bold + "Seek Time");
Scoreboard.write(UtilTime.MakeStr(Math.max(0, timeLeft), 0)); Scoreboard.write(UtilTime.MakeStr(Math.max(0, timeLeft)));
} }
Scoreboard.draw(); Scoreboard.draw();
@ -1379,16 +1397,6 @@ public class HideSeek extends TeamGame
return true; return true;
} }
@Override
public boolean CanThrowTNT(Location location)
{
for (Location loc : _seekers.GetSpawns())
if (UtilMath.offset(loc, location) < 24)
return false;
return true;
}
@Override @Override
public DeathMessageType GetDeathMessageType() public DeathMessageType GetDeathMessageType()
{ {
@ -1398,16 +1406,78 @@ public class HideSeek extends TeamGame
@EventHandler @EventHandler
public void UsableCancel(PlayerInteractEvent event) public void UsableCancel(PlayerInteractEvent event)
{ {
if (event.getClickedBlock() == null) if (event.getClickedBlock() == null || UtilPlayer.isSpectator(event.getPlayer()))
{
return; return;
}
if (UtilBlock.usable(event.getClickedBlock()))
event.setCancelled(true);
if (event.getClickedBlock().getType() == Material.WOODEN_DOOR) if (event.getClickedBlock().getType() == Material.WOODEN_DOOR)
{ {
event.setCancelled(false); event.setCancelled(false);
} }
else if (UtilBlock.usable(event.getClickedBlock()))
{
event.setCancelled(true);
}
}
@EventHandler
public void updateSuffocation(UpdateEvent event)
{
if (event.getType() != UpdateType.FAST || !IsLive())
{
return;
}
for (Player player : _hiders.GetPlayers(true))
{
if (player.getVehicle() != null)
{
continue;
}
Location location = player.getLocation();
Block block = location.getBlock();
// % 1 gets the decimal reminder of the height so we can work out if they are on a slab or farmland
if (UtilBlock.fullSolid(block) && location.getY() % 1 < 0.5)
{
Manager.GetDamage().NewDamageEvent(player, null, null, DamageCause.SUFFOCATION, 1, false, true, true, GetName(), "Suffocation");
}
}
}
@EventHandler(priority = EventPriority.LOWEST)
public void explosion(EntityExplodeEvent event)
{
if (!IsLive())
{
return;
}
Location location = UtilAlg.getAverageLocation(_seekers.GetSpawns());
event.blockList().removeIf(block ->
{
Material material = block.getType();
return material == Material.LADDER || material == Material.WOODEN_DOOR || material == Material.CHEST || UtilBlock.liquid(material) || UtilMath.offset2dSquared(location, block.getLocation()) < 225;
});
}
@EventHandler
public void blockPhysics(BlockPhysicsEvent event)
{
if (!IsLive())
{
return;
}
Material material = event.getChangedType();
if (material == Material.LADDER || material == Material.WOODEN_DOOR || UtilBlock.liquid(material))
{
event.setCancelled(true);
}
} }
public GameTeam getHiders() public GameTeam getHiders()
@ -1423,8 +1493,10 @@ public class HideSeek extends TeamGame
@EventHandler @EventHandler
public void InfestDisguise(PlayerInteractEvent event) public void InfestDisguise(PlayerInteractEvent event)
{ {
if (event.getClickedBlock() == null) if (event.getAction() == Action.PHYSICAL || event.getClickedBlock() == null)
{
return; return;
}
final Player player = event.getPlayer(); final Player player = event.getPlayer();
@ -1439,7 +1511,7 @@ public class HideSeek extends TeamGame
player, player,
F.main("Game", F.main("Game",
"You cannot infest " "You cannot infest "
+ F.elem(ItemStackFactory.Instance.GetName(block.getType(), (byte) 0, false) + " Block") + F.elem(ItemStackFactory.Instance.GetName(block.getType(), (byte) 0, false))
+ ".")); + "."));
return; return;
} }
@ -1560,26 +1632,30 @@ public class HideSeek extends TeamGame
public void InfectDamageShuffleUp(CustomDamageEvent event) public void InfectDamageShuffleUp(CustomDamageEvent event)
{ {
if (!IsLive()) if (!IsLive())
{
return; return;
}
if (event.GetDamageePlayer() == null) LivingEntity damagee = event.GetDamageeEntity();
if (damagee instanceof Player && IsInfesting(damagee))
{ {
if (event.GetDamageeEntity().getPassenger() != null InfestEnd(event.GetDamageeEntity());
&& event.GetDamageeEntity().getPassenger() instanceof LivingEntity) }
if (damagee.getPassenger() != null && damagee.getPassenger() instanceof Player)
{ {
LivingEntity passenger = (LivingEntity) event.GetDamageeEntity().getPassenger(); LivingEntity passenger = (LivingEntity) damagee.getPassenger();
// Leave // Leave
event.GetDamageeEntity().eject(); damagee.eject();
passenger.leaveVehicle(); passenger.leaveVehicle();
// End // End
InfestEnd(passenger); InfestEnd(passenger);
// Damage Event // Damage Event
Manager.GetDamage().NewDamageEvent(passenger, event.GetDamagerEntity(true), null, DamageCause.CUSTOM, 4, true, Manager.GetDamage().NewDamageEvent(passenger, event.GetDamagerEntity(true), null, DamageCause.CUSTOM, 4, true, true, false, UtilEnt.getName(event.GetDamagerEntity(true)), null);
true, false, UtilEnt.getName(event.GetDamagerEntity(true)), null);
}
} }
} }
@ -1606,20 +1682,13 @@ public class HideSeek extends TeamGame
} }
} }
@EventHandler
public void InfestLeave(VehicleExitEvent event)
{
if (!IsLive())
return;
InfestEnd(event.getExited());
}
@EventHandler @EventHandler
public void InfestLeave(UpdateEvent event) public void InfestLeave(UpdateEvent event)
{ {
if (event.getType() != UpdateType.TICK) if (event.getType() != UpdateType.TICK || !IsLive())
{
return; return;
}
// Block Leave // Block Leave
Iterator<Player> infestIterator = _infested.keySet().iterator(); Iterator<Player> infestIterator = _infested.keySet().iterator();
@ -1650,25 +1719,30 @@ public class HideSeek extends TeamGame
} }
} }
// Invisible for (Player player : _hiders.GetPlayers(true))
for (Player player : GetPlayers(true)) {
if (!_infestDeny.contains(player) || _infested.containsKey(player) || player.getVehicle() != null)
{ {
if (!(GetKit(player) instanceof KitHiderInfestor))
continue; continue;
}
if (_infested.containsKey(player) || player.getVehicle() != null) InfestEnd(player);
Manager.GetCondition().Factory().Cloak("Infest", player, player, 1.9, false, false);
} }
} }
public void InfestStart(LivingEntity ent) public void InfestStart(LivingEntity ent)
{ {
UtilParticle.PlayParticle(ParticleType.SLIME, ent.getLocation().add(0, 0.6, 0), 0.3f, 0.3f, 0.3f, 0, 24, UtilParticle.PlayParticleToAll(ParticleType.SLIME, ent.getLocation().add(0, 0.6, 0), 0.3f, 0.3f, 0.3f, 0, 24, ViewDist.NORMAL);
ViewDist.MAX, UtilServer.getPlayers());
ent.getWorld().playSound(ent.getLocation(), Sound.SLIME_ATTACK, 2f, 1f);
ent.getWorld().playSound(ent.getLocation(), Sound.SLIME_ATTACK, 2f, 1f); ent.getWorld().playSound(ent.getLocation(), Sound.SLIME_ATTACK, 2f, 1f);
ent.getWorld().playSound(ent.getLocation(), Sound.SLIME_ATTACK, 2f, 1.2f);
Manager.GetCondition().Factory().Cloak("Infest", ent, ent, 1.9, false, false); DisguiseBase disguise = Manager.GetDisguise().getActiveDisguise(ent);
if (disguise != null && disguise instanceof DisguiseLiving)
{
((DisguiseLiving) disguise).setInvisible(true);
Manager.GetDisguise().updateDisguise(disguise);
}
// Gets rid of timer, not needed until end // Gets rid of timer, not needed until end
Recharge.Instance.recharge((Player) ent, "Infest"); Recharge.Instance.recharge((Player) ent, "Infest");
@ -1678,8 +1752,15 @@ public class HideSeek extends TeamGame
public void InfestEnd(LivingEntity ent) public void InfestEnd(LivingEntity ent)
{ {
Manager.GetCondition().EndCondition(ent, null, "Infest"); DisguiseBase disguise = Manager.GetDisguise().getActiveDisguise(ent);
if (disguise != null && disguise instanceof DisguiseLiving)
{
((DisguiseLiving) disguise).setInvisible(false);
Manager.GetDisguise().updateDisguise(disguise);
}
ent.leaveVehicle();
ent.getWorld().playSound(ent.getLocation(), Sound.SLIME_ATTACK, 2f, 0.6f); ent.getWorld().playSound(ent.getLocation(), Sound.SLIME_ATTACK, 2f, 0.6f);
if (ent instanceof Player) if (ent instanceof Player)
@ -1692,10 +1773,20 @@ public class HideSeek extends TeamGame
public boolean IsInfesting(LivingEntity ent) public boolean IsInfesting(LivingEntity ent)
{ {
if (_infested.containsKey(ent)) return _infested.containsKey(ent) || ent.getVehicle() != null;
return true; }
return ent.getVehicle() != null; @Override
public void disqualify(Player player)
{
Form form = _forms.remove(player);
if (form != null)
{
form.Remove();
}
super.disqualify(player);
} }
public HashMap<Player, Form> getForms() public HashMap<Player, Form> getForms()

View File

@ -2,30 +2,16 @@ package nautilus.game.arcade.game.games.hideseek.forms;
import java.util.UUID; import java.util.UUID;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.disguise.disguises.DisguiseCat;
import mineplex.core.disguise.disguises.DisguiseChicken;
import mineplex.core.itemstack.ItemStackFactory;
import mineplex.core.recharge.Recharge;
import nautilus.game.arcade.game.games.hideseek.HideSeek;
import nautilus.game.arcade.game.games.hideseek.kits.KitHiderQuick;
import net.minecraft.server.v1_8_R3.DataWatcher; import net.minecraft.server.v1_8_R3.DataWatcher;
import net.minecraft.server.v1_8_R3.Entity; import net.minecraft.server.v1_8_R3.Entity;
import net.minecraft.server.v1_8_R3.EntityPlayer; import net.minecraft.server.v1_8_R3.EntityPlayer;
import net.minecraft.server.v1_8_R3.EntityTrackerEntry; import net.minecraft.server.v1_8_R3.EntityTrackerEntry;
import net.minecraft.server.v1_8_R3.Packet; import net.minecraft.server.v1_8_R3.Packet;
import net.minecraft.server.v1_8_R3.PacketPlayOutAttachEntity; import net.minecraft.server.v1_8_R3.PacketPlayOutAttachEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutNewAttachEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntity.PacketPlayOutRelEntityMove; import net.minecraft.server.v1_8_R3.PacketPlayOutEntity.PacketPlayOutRelEntityMove;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityDestroy;
import net.minecraft.server.v1_8_R3.PacketPlayOutEntityTeleport; import net.minecraft.server.v1_8_R3.PacketPlayOutEntityTeleport;
import net.minecraft.server.v1_8_R3.PacketPlayOutNewAttachEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntity;
import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving; import net.minecraft.server.v1_8_R3.PacketPlayOutSpawnEntityLiving;
import net.minecraft.server.v1_8_R3.WorldServer; import net.minecraft.server.v1_8_R3.WorldServer;
@ -38,20 +24,32 @@ import org.bukkit.Sound;
import org.bukkit.block.Block; import org.bukkit.block.Block;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftEntity;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftFallingSand;
import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer; import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
import org.bukkit.entity.FallingBlock;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector; import org.bukkit.util.Vector;
import mineplex.core.common.util.C;
import mineplex.core.common.util.F;
import mineplex.core.common.util.MapUtil;
import mineplex.core.common.util.UtilBlock;
import mineplex.core.common.util.UtilEnt;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilPlayer;
import mineplex.core.common.util.UtilServer;
import mineplex.core.disguise.disguises.DisguiseCat;
import mineplex.core.disguise.disguises.DisguiseChicken;
import mineplex.core.itemstack.ItemStackFactory;
import nautilus.game.arcade.game.games.hideseek.HideSeek;
import nautilus.game.arcade.game.games.hideseek.kits.KitHiderQuick;
public class BlockForm extends Form public class BlockForm extends Form
{ {
private Material _mat; private Material _mat;
private Block _block; private Block _block;
private int _entityId;
private Location _loc; private Location _loc;
private int _fakeSilverfishId; private int _fakeSilverfishId;
@ -77,8 +75,14 @@ public class BlockForm extends Form
// Remove Old // Remove Old
if (Player.getPassenger() != null) if (Player.getPassenger() != null)
{ {
Player.getPassenger().remove();
Player.eject(); Player.eject();
Player.getPassenger().remove();
}
// If a player is in a cauldron and morphs they get stuck in it
if (Player.getLocation().getBlock().getType() == Material.CAULDRON)
{
Player.teleport(Player.getEyeLocation());
} }
EntityPlayer player = ((CraftPlayer) Player).getHandle(); EntityPlayer player = ((CraftPlayer) Player).getHandle();
@ -144,7 +148,7 @@ public class BlockForm extends Form
+ F.elem(ItemStackFactory.Instance.GetName(_mat, (byte) 0, false) + " Block") + "!")); + F.elem(ItemStackFactory.Instance.GetName(_mat, (byte) 0, false) + " Block") + "!"));
else else
UtilPlayer.message(Player, F.main("Game", UtilPlayer.message(Player, F.main("Game",
C.cWhite + "You are now a " + F.elem(ItemStackFactory.Instance.GetName(_mat, (byte) 0, false)) + "!")); C.cWhite + "You are now a " + blockName + "!"));
// Give Item // Give Item
Player.getInventory().setItem(8, new ItemStack(Host.GetItemEquivilent(_mat))); Player.getInventory().setItem(8, new ItemStack(Host.GetItemEquivilent(_mat)));
@ -203,6 +207,13 @@ public class BlockForm extends Form
_blockId _blockId
})); }));
Packet destroyPacket = new PacketPlayOutEntityDestroy(new int[]{getBlockId()});
for (Player player : Player.getWorld().getPlayers())
{
UtilPlayer.sendPacket(player, destroyPacket);
}
((CraftEntity) Player).getHandle().getDataWatcher().watch(0, (byte) 0, Entity.META_ENTITYDATA, (byte) 0); ((CraftEntity) Player).getHandle().getDataWatcher().watch(0, (byte) 0, Entity.META_ENTITYDATA, (byte) 0);
} }
@ -236,7 +247,7 @@ public class BlockForm extends Form
Block block = Player.getLocation().getBlock(); Block block = Player.getLocation().getBlock();
// Not Able // Not Able
if (block.getType() != Material.AIR || !UtilBlock.solid(block.getRelative(BlockFace.DOWN))) if (block.getType() != Material.AIR || !UtilBlock.solid(block.getRelative(BlockFace.DOWN)) || UtilEnt.getPlayersInsideEntity(Player).size() > 1)
{ {
UtilPlayer.message(Player, F.main("Game", "You cannot become a Solid Block here.")); UtilPlayer.message(Player, F.main("Game", "You cannot become a Solid Block here."));
Player.setExp(0f); Player.setExp(0f);
@ -432,9 +443,4 @@ public class BlockForm extends Form
{ {
return _block; return _block;
} }
public int getEntityId()
{
return _entityId;
}
} }

View File

@ -34,7 +34,6 @@ public class KitHiderInfestor extends Kit
DisguiseSlime slime = new DisguiseSlime(player); DisguiseSlime slime = new DisguiseSlime(player);
slime.SetSize(2); slime.SetSize(2);
slime.setName(C.cAqua + player.getName());
Manager.GetDisguise().disguise(slime); Manager.GetDisguise().disguise(slime);
} }
} }