Merge pull request #39 in MIN/mineplex from DeadBodies to master
* commit 'bad339cf04ead2e63800b0bb41870b9df73ab4de': Tweak dead bodies more Dead bodies: Change to Item from disguised arrow, fix body positioning, move to Game.java to enable in all games
This commit is contained in:
commit
2fe188ac0c
@ -442,7 +442,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
|
||||
return new PacketPlayOutMapChunk(_bedChunk, true, 0, UtilPlayer.is1_8(player) ? 48 : 0);
|
||||
}
|
||||
|
||||
private Packet[] getBedPackets(Location recieving, DisguisePlayer playerDisguise)
|
||||
private Packet[] getBedPackets(Location recieving, DisguisePlayer playerDisguise, boolean is18)
|
||||
{
|
||||
try
|
||||
{
|
||||
@ -458,7 +458,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
|
||||
|
||||
PacketPlayOutEntityTeleport teleportPacket = new PacketPlayOutEntityTeleport(playerDisguise.GetEntity());
|
||||
|
||||
teleportPacket.c += (int) (0.35D * 32);
|
||||
teleportPacket.c += (int) ((is18 ? 0.07D : 0.25D) * 32);
|
||||
|
||||
return new Packet[]
|
||||
{
|
||||
@ -502,7 +502,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
|
||||
&& ((DisguisePlayer) entry.getKey()).getSleepingDirection() != null)
|
||||
{
|
||||
|
||||
packets.addAll(Arrays.asList(getBedPackets(newLoc, (DisguisePlayer) entry.getKey())));
|
||||
packets.addAll(Arrays.asList(getBedPackets(newLoc, (DisguisePlayer) entry.getKey(), UtilPlayer.is1_8(player))));
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -853,7 +853,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
|
||||
|
||||
if (pDisguise.getSleepingDirection() != null)
|
||||
{
|
||||
for (Packet packet : getBedPackets(player.getLocation(), pDisguise))
|
||||
for (Packet packet : getBedPackets(player.getLocation(), pDisguise, UtilPlayer.is1_8(player)))
|
||||
{
|
||||
handlePacket(packet, packetVerifier);
|
||||
}
|
||||
|
@ -5,30 +5,44 @@ import java.util.ArrayList;
|
||||
import java.util.Collection;
|
||||
import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.Sound;
|
||||
import org.bukkit.block.Block;
|
||||
import org.bukkit.block.BlockFace;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftHumanEntity;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftEntity;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftItem;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Hanging;
|
||||
import org.bukkit.entity.Item;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.EventPriority;
|
||||
import org.bukkit.event.HandlerList;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.entity.EntityDamageEvent;
|
||||
import org.bukkit.event.entity.FoodLevelChangeEvent;
|
||||
import org.bukkit.event.entity.ItemSpawnEvent;
|
||||
import org.bukkit.event.hanging.HangingBreakEvent;
|
||||
import org.bukkit.event.hanging.HangingPlaceEvent;
|
||||
import org.bukkit.event.player.PlayerJoinEvent;
|
||||
import org.bukkit.event.player.PlayerLoginEvent;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
import org.bukkit.event.world.WorldLoadEvent;
|
||||
import org.bukkit.scoreboard.Objective;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
import org.bukkit.scoreboard.TeamNameTagVisibility;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
@ -40,10 +54,15 @@ import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTabTitle;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilTextMiddle;
|
||||
import mineplex.core.disguise.disguises.DisguisePlayer;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.packethandler.IPacketHandler;
|
||||
import mineplex.core.packethandler.PacketInfo;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
import mineplex.core.updater.event.UpdateEvent;
|
||||
import mineplex.minecraft.game.classcombat.event.ClassCombatCreatureAllowSpawnEvent;
|
||||
import mineplex.minecraft.game.core.combat.DeathMessageType;
|
||||
import mineplex.minecraft.game.core.combat.event.CombatDeathEvent;
|
||||
import nautilus.game.arcade.ArcadeFormat;
|
||||
import nautilus.game.arcade.ArcadeManager;
|
||||
import nautilus.game.arcade.GameType;
|
||||
@ -58,7 +77,11 @@ import nautilus.game.arcade.managers.GameLobbyManager;
|
||||
import nautilus.game.arcade.scoreboard.GameScoreboard;
|
||||
import nautilus.game.arcade.stats.*;
|
||||
import nautilus.game.arcade.world.WorldData;
|
||||
import net.minecraft.server.v1_7_R4.EntityHuman;
|
||||
import net.minecraft.server.v1_7_R4.EntityItem;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayInUseEntity;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutScoreboardTeam;
|
||||
import net.minecraft.server.v1_7_R4.ScoreboardTeam;
|
||||
import net.minecraft.server.v1_7_R4.WorldServer;
|
||||
import net.minecraft.util.com.mojang.authlib.GameProfile;
|
||||
|
||||
public abstract class Game implements Listener
|
||||
@ -271,6 +294,18 @@ public abstract class Game implements Listener
|
||||
|
||||
public boolean VersionRequire1_8 = false;
|
||||
|
||||
public boolean DeadBodies = false;
|
||||
public boolean DeadBodiesQuit = true;
|
||||
public boolean DeadBodiesDeath = true;
|
||||
public int DeadBodiesExpire = -1;
|
||||
|
||||
private IPacketHandler _useEntityPacketHandler;
|
||||
protected Field NameTagVisibility;
|
||||
protected Field PacketTeam;
|
||||
private int _deadBodyCount;
|
||||
private NautHashMap<String, Entity> _deadBodies = new NautHashMap<String, Entity>();
|
||||
private NautHashMap<String, Long> _deadBodiesExpire = new NautHashMap<String, Long>();
|
||||
|
||||
public ArrayList<String> GemBoosters = new ArrayList<String>();
|
||||
private final Set<StatTracker<? extends Game>> _statTrackers = new HashSet<>();
|
||||
|
||||
@ -346,6 +381,41 @@ public abstract class Game implements Listener
|
||||
|
||||
Manager.setResourcePack(gameType.getResourcePackUrl(), gameType.isEnforceResourcePack());
|
||||
|
||||
try
|
||||
{
|
||||
PacketTeam = Class.forName(
|
||||
"org.bukkit.craftbukkit.v1_7_R4.scoreboard.CraftTeam")
|
||||
.getDeclaredField("team");
|
||||
PacketTeam.setAccessible(true);
|
||||
|
||||
NameTagVisibility = PacketPlayOutScoreboardTeam.class
|
||||
.getDeclaredField("_nameTagVisibility");
|
||||
NameTagVisibility.setAccessible(true);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
_useEntityPacketHandler = new IPacketHandler()
|
||||
{
|
||||
@Override
|
||||
public void handle(PacketInfo packetInfo)
|
||||
{
|
||||
if (packetInfo.getPacket() instanceof PacketPlayInUseEntity)
|
||||
{
|
||||
net.minecraft.server.v1_7_R4.Entity entity = ((PacketPlayInUseEntity) packetInfo
|
||||
.getPacket()).a(((CraftWorld) packetInfo
|
||||
.getPlayer().getWorld()).getHandle());
|
||||
|
||||
if (entity instanceof EntityItem)
|
||||
{
|
||||
packetInfo.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
System.out.println("Loading " + GetName() + "...");
|
||||
}
|
||||
|
||||
@ -1449,5 +1519,265 @@ public abstract class Game implements Listener
|
||||
//End
|
||||
SetState(GameState.End);
|
||||
}
|
||||
|
||||
|
||||
@EventHandler
|
||||
public void handleInteractEntityPacket(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() == GameState.Live)
|
||||
{
|
||||
getArcadeManager().getPacketHandler().addPacketHandler(
|
||||
_useEntityPacketHandler);
|
||||
}
|
||||
else if (event.GetState() == GameState.Dead)
|
||||
{
|
||||
getArcadeManager().getPacketHandler().removePacketHandler(
|
||||
_useEntityPacketHandler);
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDeadBodyJoin(PlayerJoinEvent event)
|
||||
{
|
||||
for (int i = 0; i < _deadBodyCount; i++)
|
||||
{
|
||||
String name = "";
|
||||
|
||||
for (char c : ("" + i).toCharArray())
|
||||
{
|
||||
name += "§" + c;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Team team = Scoreboard.GetScoreboard().getTeam(name);
|
||||
|
||||
if (team == null)
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
PacketPlayOutScoreboardTeam packet = new PacketPlayOutScoreboardTeam(
|
||||
(ScoreboardTeam) PacketTeam.get(team), 2);
|
||||
|
||||
UtilPlayer.sendPacket(event.getPlayer(), packet);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDeadBodyDeath(CombatDeathEvent event)
|
||||
{
|
||||
if (!IsLive())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.GetEvent().getEntity() instanceof Player))
|
||||
return;
|
||||
|
||||
if (!DeadBodiesDeath)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
spawnDeadBody((Player) event.GetEvent().getEntity());
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.LOW)
|
||||
public void onDeadBodyQuit(PlayerQuitEvent event)
|
||||
{
|
||||
if (!IsLive())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!IsAlive(event.getPlayer()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
if (!DeadBodiesQuit)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
spawnDeadBody(event.getPlayer());
|
||||
}
|
||||
|
||||
private void spawnDeadBody(Player player)
|
||||
{
|
||||
if (!DeadBodies)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
String name = "";
|
||||
|
||||
for (char c : ("" + _deadBodyCount++).toCharArray())
|
||||
{
|
||||
name += "§" + c;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
Team team = Scoreboard.GetScoreboard().registerNewTeam(name);
|
||||
|
||||
team.setNameTagVisibility(TeamNameTagVisibility.NEVER);
|
||||
team.addEntry(name);
|
||||
|
||||
PacketPlayOutScoreboardTeam packet = new PacketPlayOutScoreboardTeam(
|
||||
(ScoreboardTeam) PacketTeam.get(team), 2);
|
||||
|
||||
for (Player alive : GetPlayers(false))
|
||||
{
|
||||
UtilPlayer.sendPacket(alive, packet);
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
GameProfile newProfile = new GameProfile(UUID.randomUUID(), name);
|
||||
|
||||
newProfile.getProperties()
|
||||
.putAll(((CraftPlayer) player).getHandle().getProfile()
|
||||
.getProperties());
|
||||
|
||||
DisguisePlayer disguise = new DisguisePlayer(null, newProfile);
|
||||
|
||||
disguise.setSleeping(getSleepingFace(player.getLocation()));
|
||||
|
||||
getArcadeManager().GetDisguise().addFutureDisguise(disguise);
|
||||
|
||||
Location loc = player.getLocation();
|
||||
WorldServer world = ((CraftWorld) loc.getWorld()).getHandle();
|
||||
|
||||
EntityItem nmsItem = new EntityItem(world, loc.getX(),
|
||||
loc.getY() + 0.5, loc.getZ(),
|
||||
CraftItemStack.asNMSCopy(new ItemBuilder(Material.STONE)
|
||||
.setTitle(System.currentTimeMillis() + "").build()));
|
||||
|
||||
nmsItem.motX = 0;
|
||||
nmsItem.motY = 0;
|
||||
nmsItem.motZ = 0;
|
||||
nmsItem.yaw = 0;
|
||||
|
||||
world.addEntity(nmsItem);
|
||||
|
||||
Item entity = new CraftItem(world.getServer(), nmsItem);
|
||||
|
||||
entity.setPickupDelay(Integer.MAX_VALUE);
|
||||
|
||||
_deadBodies.put(player.getName(), entity);
|
||||
|
||||
if (DeadBodiesExpire > 0)
|
||||
{
|
||||
_deadBodiesExpire.put(player.getName(), System.currentTimeMillis()
|
||||
+ (DeadBodiesExpire * 1000));
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler(priority = EventPriority.HIGHEST)
|
||||
public void onDeadBodyItemSpawn(ItemSpawnEvent event)
|
||||
{
|
||||
if (_deadBodies.containsValue(event.getEntity()))
|
||||
{
|
||||
event.setCancelled(false);
|
||||
|
||||
((CraftEntity) event.getEntity()).getHandle().dead = false;
|
||||
}
|
||||
}
|
||||
|
||||
public NautHashMap<String, Entity> getDeadBodies()
|
||||
{
|
||||
return _deadBodies;
|
||||
}
|
||||
|
||||
public void cleanDeadBodies()
|
||||
{
|
||||
for (Entity entity : _deadBodies.values())
|
||||
{
|
||||
entity.remove();
|
||||
}
|
||||
|
||||
_deadBodies.clear();
|
||||
_deadBodiesExpire.clear();
|
||||
_deadBodyCount = 0;
|
||||
}
|
||||
|
||||
private BlockFace getSleepingFace(Location loc)
|
||||
{
|
||||
Block block = loc.getBlock();
|
||||
|
||||
while (block.getY() > 0
|
||||
&& !UtilBlock.fullSolid(block.getRelative(BlockFace.DOWN))
|
||||
&& !UtilBlock.solid(block.getRelative(BlockFace.DOWN)))
|
||||
{
|
||||
block = block.getRelative(BlockFace.DOWN);
|
||||
}
|
||||
|
||||
BlockFace proper = BlockFace.values()[Math.round(loc.getYaw() / 90F) & 0x3]
|
||||
.getOppositeFace();
|
||||
|
||||
// A complicated way to get the face the dead body should be towards.
|
||||
for (HashSet<Byte> validBlocks : new HashSet[]
|
||||
{
|
||||
UtilBlock.blockAirFoliageSet, UtilBlock.blockPassSet
|
||||
})
|
||||
{
|
||||
|
||||
if (validBlocks.contains((byte) block.getRelative(proper)
|
||||
.getTypeId()))
|
||||
{
|
||||
return proper;
|
||||
}
|
||||
|
||||
for (BlockFace face : new BlockFace[]
|
||||
{
|
||||
BlockFace.EAST, BlockFace.SOUTH, BlockFace.NORTH,
|
||||
BlockFace.WEST
|
||||
})
|
||||
{
|
||||
if (validBlocks.contains((byte) block.getRelative(face)
|
||||
.getTypeId()))
|
||||
{
|
||||
return face;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return proper;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void onDeadBodiesExpire(UpdateEvent event)
|
||||
{
|
||||
if (event.getType() != UpdateType.SEC)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Iterator<Entry<String, Long>> itel = _deadBodiesExpire.entrySet()
|
||||
.iterator();
|
||||
|
||||
while (itel.hasNext())
|
||||
{
|
||||
Entry<String, Long> entry = itel.next();
|
||||
|
||||
if (entry.getValue() < System.currentTimeMillis())
|
||||
{
|
||||
if (_deadBodies.containsKey(entry.getKey()))
|
||||
{
|
||||
_deadBodies.remove(entry.getKey()).remove();
|
||||
}
|
||||
|
||||
itel.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -13,9 +13,7 @@ import org.bukkit.block.Chest;
|
||||
import org.bukkit.block.DoubleChest;
|
||||
import org.bukkit.block.Furnace;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.CraftWorld;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftArrow;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftLargeFireball;
|
||||
import org.bukkit.craftbukkit.v1_7_R4.entity.CraftPlayer;
|
||||
import org.bukkit.entity.Boat;
|
||||
import org.bukkit.entity.Egg;
|
||||
import org.bukkit.entity.Entity;
|
||||
@ -56,7 +54,6 @@ import org.bukkit.inventory.meta.FireworkMeta;
|
||||
import org.bukkit.scheduler.BukkitRunnable;
|
||||
import org.bukkit.scoreboard.Scoreboard;
|
||||
import org.bukkit.scoreboard.Team;
|
||||
import org.bukkit.scoreboard.TeamNameTagVisibility;
|
||||
import org.bukkit.util.Vector;
|
||||
|
||||
import mineplex.core.common.util.C;
|
||||
@ -74,16 +71,11 @@ import mineplex.core.common.util.UtilParticle;
|
||||
import mineplex.core.common.util.UtilPlayer;
|
||||
import mineplex.core.common.util.UtilParticle.ParticleType;
|
||||
import mineplex.core.common.util.UtilParticle.ViewDist;
|
||||
import mineplex.core.common.util.UtilTime.TimeUnit;
|
||||
import mineplex.core.common.util.UtilServer;
|
||||
import mineplex.core.common.util.UtilTime;
|
||||
import mineplex.core.common.util.UtilWorld;
|
||||
import mineplex.core.disguise.disguises.DisguisePlayer;
|
||||
import mineplex.core.itemstack.ItemBuilder;
|
||||
import mineplex.core.itemstack.ItemStackFactory;
|
||||
import mineplex.core.loot.*;
|
||||
import mineplex.core.packethandler.IPacketHandler;
|
||||
import mineplex.core.packethandler.PacketInfo;
|
||||
import mineplex.core.packethandler.PacketPlayOutWorldBorder;
|
||||
import mineplex.core.recharge.Recharge;
|
||||
import mineplex.core.updater.UpdateType;
|
||||
@ -97,22 +89,18 @@ import nautilus.game.arcade.GameType;
|
||||
import nautilus.game.arcade.events.GameStateChangeEvent;
|
||||
import nautilus.game.arcade.game.Game;
|
||||
import nautilus.game.arcade.game.GameTeam;
|
||||
import nautilus.game.arcade.game.SoloGame;
|
||||
import nautilus.game.arcade.game.games.survivalgames.kit.*;
|
||||
import nautilus.game.arcade.kit.Kit;
|
||||
import nautilus.game.arcade.stats.FirstSupplyDropOpenStatTracker;
|
||||
import nautilus.game.arcade.stats.KillsWithinTimeLimitStatTracker;
|
||||
import nautilus.game.arcade.stats.SimultaneousSkeletonStatTracker;
|
||||
import nautilus.game.arcade.stats.WinWithoutWearingArmorStatTracker;
|
||||
import net.minecraft.server.v1_7_R4.EntityArrow;
|
||||
import net.minecraft.server.v1_7_R4.EntityLargeFireball;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayInUseEntity;
|
||||
import net.minecraft.server.v1_7_R4.PacketPlayOutScoreboardTeam;
|
||||
import net.minecraft.server.v1_7_R4.ScoreboardTeam;
|
||||
import net.minecraft.server.v1_7_R4.TileEntity;
|
||||
import net.minecraft.server.v1_7_R4.TileEntityChest;
|
||||
import net.minecraft.server.v1_7_R4.WorldServer;
|
||||
import net.minecraft.util.com.mojang.authlib.GameProfile;
|
||||
|
||||
public abstract class SurvivalGames extends Game
|
||||
{
|
||||
@ -156,8 +144,6 @@ public abstract class SurvivalGames extends Game
|
||||
|
||||
private Field _nameTagVisibility;
|
||||
private Field _packetTeam;
|
||||
private IPacketHandler _useEntityPacketHandler;
|
||||
private int _deadBodyCount;
|
||||
|
||||
private int _chestRefillTime = 60 * 7;
|
||||
private NautHashMap<TileEntityChest, Integer> _openedChests = new NautHashMap<TileEntityChest, Integer>();
|
||||
@ -239,6 +225,7 @@ public abstract class SurvivalGames extends Game
|
||||
PrepareTime = 15000;
|
||||
|
||||
VersionRequire1_8 = true;
|
||||
DeadBodies = true;
|
||||
|
||||
BlockBreakAllow.add(Material.WEB.getId()); // Web
|
||||
BlockPlaceAllow.add(Material.WEB.getId());
|
||||
@ -285,24 +272,6 @@ public abstract class SurvivalGames extends Game
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
_useEntityPacketHandler = new IPacketHandler()
|
||||
{
|
||||
@Override
|
||||
public void handle(PacketInfo packetInfo)
|
||||
{
|
||||
if (packetInfo.getPacket() instanceof PacketPlayInUseEntity)
|
||||
{
|
||||
net.minecraft.server.v1_7_R4.Entity entity = ((PacketPlayInUseEntity) packetInfo.getPacket())
|
||||
.a(((CraftWorld) packetInfo.getPlayer().getWorld()).getHandle());
|
||||
|
||||
if (entity instanceof EntityArrow)
|
||||
{
|
||||
packetInfo.setCancelled(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
||||
registerStatTrackers(new WinWithoutWearingArmorStatTracker(this), new KillsWithinTimeLimitStatTracker(this, 3, 60,
|
||||
"Bloodlust"), new FirstSupplyDropOpenStatTracker(this), new SimultaneousSkeletonStatTracker(this, 5));
|
||||
}
|
||||
@ -788,126 +757,6 @@ public abstract class SurvivalGames extends Game
|
||||
}
|
||||
}
|
||||
|
||||
private BlockFace getFace(Location loc)
|
||||
{
|
||||
Block block = loc.getBlock();
|
||||
|
||||
while (block.getY() > 0 && !UtilBlock.fullSolid(block.getRelative(BlockFace.DOWN))
|
||||
&& !UtilBlock.solid(block.getRelative(BlockFace.DOWN)))
|
||||
{
|
||||
block = block.getRelative(BlockFace.DOWN);
|
||||
}
|
||||
|
||||
BlockFace proper = BlockFace.values()[Math.round(loc.getYaw() / 90F) & 0x3].getOppositeFace();
|
||||
|
||||
// A complicated way to get the face the dead body should be towards.
|
||||
for (HashSet<Byte> validBlocks : new HashSet[]
|
||||
{
|
||||
UtilBlock.blockAirFoliageSet, UtilBlock.blockPassSet
|
||||
})
|
||||
{
|
||||
|
||||
if (validBlocks.contains((byte) block.getRelative(proper).getTypeId()))
|
||||
{
|
||||
return proper;
|
||||
}
|
||||
|
||||
for (BlockFace face : new BlockFace[]
|
||||
{
|
||||
BlockFace.EAST, BlockFace.SOUTH, BlockFace.NORTH, BlockFace.WEST
|
||||
})
|
||||
{
|
||||
if (validBlocks.contains((byte) block.getRelative(face).getTypeId()))
|
||||
{
|
||||
return face;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return proper;
|
||||
}
|
||||
|
||||
private void deathOrQuit(Player player)
|
||||
{
|
||||
String name = "";
|
||||
|
||||
for (char c : ("" + _deadBodyCount++).toCharArray())
|
||||
{
|
||||
name += "§" + c;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
|
||||
Team team = Scoreboard.GetScoreboard().registerNewTeam(name);
|
||||
|
||||
if (!_hiddenNames.get(player).isEmpty())
|
||||
{
|
||||
ScoreboardTeam nmsTeam = (ScoreboardTeam) _packetTeam.get(team);
|
||||
|
||||
PacketPlayOutScoreboardTeam packet = new PacketPlayOutScoreboardTeam(nmsTeam, 2);
|
||||
|
||||
Field teamName = PacketPlayOutScoreboardTeam.class.getDeclaredField("a");
|
||||
teamName.setAccessible(true);
|
||||
Field displayName = PacketPlayOutScoreboardTeam.class.getDeclaredField("b");
|
||||
displayName.setAccessible(true);
|
||||
|
||||
for (Player alive : GetPlayers(true))
|
||||
{
|
||||
if (_hiddenNames.get(player).contains(alive.getName()))
|
||||
{
|
||||
teamName.set(packet, alive.getName());
|
||||
displayName.set(packet, alive.getName());
|
||||
|
||||
UtilPlayer.sendPacket(player, packet);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
_hiddenNames.remove(player);
|
||||
|
||||
team.setNameTagVisibility(TeamNameTagVisibility.NEVER);
|
||||
team.addEntry(name);
|
||||
|
||||
PacketPlayOutScoreboardTeam packet = new PacketPlayOutScoreboardTeam((ScoreboardTeam) _packetTeam.get(team), 2);
|
||||
|
||||
for (Player alive : GetPlayers(false))
|
||||
{
|
||||
UtilPlayer.sendPacket(alive, packet);
|
||||
}
|
||||
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
GameProfile newProfile = new GameProfile(UUID.randomUUID(), name);
|
||||
|
||||
newProfile.getProperties().putAll(((CraftPlayer) player).getHandle().getProfile().getProperties());
|
||||
|
||||
DisguisePlayer disguise = new DisguisePlayer(null, newProfile);
|
||||
|
||||
disguise.setSleeping(getFace(player.getLocation()));
|
||||
|
||||
getArcadeManager().GetDisguise().addFutureDisguise(disguise);
|
||||
|
||||
Entity entity = player.getWorld().spawnEntity(player.getLocation(), EntityType.ARROW);
|
||||
|
||||
try
|
||||
{
|
||||
EntityArrow entityArrow = ((CraftArrow) entity).getHandle();
|
||||
|
||||
Field at = EntityArrow.class.getDeclaredField("at");
|
||||
at.setAccessible(true);
|
||||
at.set(entityArrow, Integer.MIN_VALUE); // Despawn time
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void DisableDamageLevel(CustomDamageEvent event)
|
||||
{
|
||||
@ -1028,19 +877,6 @@ public abstract class SurvivalGames extends Game
|
||||
return 12;
|
||||
}
|
||||
|
||||
@EventHandler
|
||||
public void handleEntityPacket(GameStateChangeEvent event)
|
||||
{
|
||||
if (event.GetState() == GameState.Live)
|
||||
{
|
||||
getArcadeManager().getPacketHandler().addPacketHandler(_useEntityPacketHandler);
|
||||
}
|
||||
else if (event.GetState() == GameState.Dead)
|
||||
{
|
||||
getArcadeManager().getPacketHandler().removePacketHandler(_useEntityPacketHandler);
|
||||
}
|
||||
}
|
||||
|
||||
// If an item spawns and no one is there to see it, does it really spawn? No.
|
||||
@EventHandler
|
||||
public void ItemSpawn(ItemSpawnEvent event)
|
||||
@ -1543,8 +1379,6 @@ public abstract class SurvivalGames extends Game
|
||||
|
||||
Player player = (Player) event.GetEvent().getEntity();
|
||||
|
||||
deathOrQuit(player);
|
||||
|
||||
FireworkEffect effect = FireworkEffect.builder().flicker(false).withColor(Color.RED).with(Type.BALL_LARGE).trail(false)
|
||||
.build();
|
||||
for (int i = 0; i < 3; i++)
|
||||
@ -1673,8 +1507,7 @@ public abstract class SurvivalGames extends Game
|
||||
return;
|
||||
}
|
||||
|
||||
deathOrQuit(event.getPlayer());
|
||||
|
||||
_hiddenNames.remove(event.getPlayer());
|
||||
}
|
||||
|
||||
private void setBorder()
|
||||
|
Loading…
Reference in New Issue
Block a user