Merge branch 'master' of ssh://184.154.0.242:7999/min/Mineplex

This commit is contained in:
Jonathan Williams 2015-08-23 16:26:02 -07:00
commit 6d3c965f14
10 changed files with 455 additions and 200 deletions

View File

@ -0,0 +1,24 @@
package mineplex.core.common.structs;
import org.bukkit.Material;
public class ItemContainer
{
public Material Type;
public byte Data;
public String Name;
public ItemContainer(Material type, byte data, String name)
{
Type = type;
Data = data;
Name = name;
}
public ItemContainer(int id, byte data, String name)
{
Type = Material.getMaterial(id);
Data = data;
Name = name;
}
}

View File

@ -4,22 +4,24 @@ import java.util.AbstractMap;
import java.util.LinkedList;
import java.util.Map.Entry;
import mineplex.core.common.structs.ItemContainer;
import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class UtilItem
{
public static LinkedList<Entry<Material, Byte>> matchItem(Player caller, String items, boolean inform)
public static LinkedList<ItemContainer> matchItem(Player caller, String items, boolean inform)
{
LinkedList<Entry<Material, Byte>> matchList = new LinkedList<Entry<Material, Byte>>();
LinkedList<ItemContainer> matchList = new LinkedList<ItemContainer>();
String failList = "";
//Mass Search
for (String cur : items.split(","))
{
Entry<Material, Byte> match = searchItem(caller, cur, inform);
ItemContainer match = searchItem(caller, cur, inform);
if (match != null)
matchList.add(match);
@ -40,21 +42,27 @@ public class UtilItem
return matchList;
}
public static Entry<Material, Byte> searchItem(Player caller, String args, boolean inform)
public static ItemContainer searchItem(Player caller, String args, boolean inform)
{
LinkedList<Entry<Material, Byte>> matchList = new LinkedList<Entry<Material, Byte>>();
LinkedList<ItemContainer> matchList = new LinkedList<ItemContainer>();
for (Material cur : Material.values())
{
String[] arg = args.split(":");
//Get Selected Name
String name = null;
if (arg.length > 2)
name = arg[2].replaceAll("_", " ");
//By Name
if (cur.toString().equalsIgnoreCase(args))
return new AbstractMap.SimpleEntry<Material, Byte>(cur, (byte)0);
return new ItemContainer(cur, (byte)0, name);
if (cur.toString().toLowerCase().contains(args.toLowerCase()))
matchList.add(new AbstractMap.SimpleEntry<Material, Byte>(cur, (byte)0));
matchList.add(new ItemContainer(cur, (byte)0, name));
//By ID:Data
String[] arg = args.split(":");
//By ID:Data:Name
//ID
int id = 0;
@ -82,8 +90,8 @@ public class UtilItem
{
continue;
}
return new AbstractMap.SimpleEntry<Material, Byte>(cur, data);
return new ItemContainer(cur, data, name);
}
//No / Non-Unique
@ -102,8 +110,9 @@ public class UtilItem
if (matchList.size() > 0)
{
String matchString = "";
for (Entry<Material, Byte> cur : matchList)
matchString += F.elem(cur.getKey().toString()) + ", ";
for (ItemContainer cur : matchList)
matchString += F.elem(cur.Type.toString()) + ", ";
if (matchString.length() > 1)
matchString = matchString.substring(0 , matchString.length() - 2);

View File

@ -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);
}

View File

@ -11,6 +11,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.plugin.java.JavaPlugin;
import mineplex.core.MiniPlugin;
import mineplex.core.common.structs.ItemContainer;
import mineplex.core.common.util.F;
import mineplex.core.common.util.UtilInv;
import mineplex.core.common.util.UtilItem;
@ -65,7 +66,7 @@ public class Give extends MiniPlugin
public void give(Player player, String target, String itemNames, String amount, String enchants)
{
//Item
LinkedList<Entry<Material, Byte>> itemList = new LinkedList<Entry<Material, Byte>>();
LinkedList<ItemContainer> itemList = new LinkedList<ItemContainer>();
itemList = UtilItem.matchItem(player, itemNames, true);
if (itemList.isEmpty())
return;
@ -128,11 +129,15 @@ public class Give extends MiniPlugin
if (givenList.length() > 0)
givenList = givenList.substring(0, givenList.length()-1);
for (Entry<Material, Byte> curItem : itemList)
for (ItemContainer curItem : itemList)
{
for (Player cur : giveList)
{
ItemStack stack = ItemStackFactory.Instance.CreateStack(curItem.getKey(), curItem.getValue(), count);
ItemStack stack;
if (curItem.Name == null)
stack = ItemStackFactory.Instance.CreateStack(curItem.Type, curItem.Data, count);
else
stack = ItemStackFactory.Instance.CreateStack(curItem.Type, curItem.Data, count, curItem.Name);
//Enchants
stack.addUnsafeEnchantments(enchs);
@ -142,18 +147,18 @@ public class Give extends MiniPlugin
{
//Inform
if (!cur.equals(player))
UtilPlayer.message(cur, F.main("Give", "You received " + F.item(count + " " + ItemStackFactory.Instance.GetName(curItem.getKey(), curItem.getValue(), false)) + " from " + F.elem(player.getName()) + "."));
UtilPlayer.message(cur, F.main("Give", "You received " + F.item(count + " " + ItemStackFactory.Instance.GetName(curItem.Type, curItem.Data, false)) + " from " + F.elem(player.getName()) + "."));
}
}
if (target.equalsIgnoreCase("all"))
UtilPlayer.message(player, F.main("Give", "You gave " + F.item(count + " " + ItemStackFactory.Instance.GetName(curItem.getKey(), curItem.getValue(), false)) + " to " + F.elem("ALL")) + ".");
UtilPlayer.message(player, F.main("Give", "You gave " + F.item(count + " " + ItemStackFactory.Instance.GetName(curItem.Type, curItem.Data, false)) + " to " + F.elem("ALL")) + ".");
else if (giveList.size() > 1)
UtilPlayer.message(player, F.main("Give", "You gave " + F.item(count + " " + ItemStackFactory.Instance.GetName(curItem.getKey(), curItem.getValue(), false)) + " to " + F.elem(givenList) + "."));
UtilPlayer.message(player, F.main("Give", "You gave " + F.item(count + " " + ItemStackFactory.Instance.GetName(curItem.Type, curItem.Data, false)) + " to " + F.elem(givenList) + "."));
else
UtilPlayer.message(player, F.main("Give", "You gave " + F.item(count + " " + ItemStackFactory.Instance.GetName(curItem.getKey(), curItem.getValue(), false)) + " to " + F.elem(giveList.getFirst().getName()) + "."));
UtilPlayer.message(player, F.main("Give", "You gave " + F.item(count + " " + ItemStackFactory.Instance.GetName(curItem.Type, curItem.Data, false)) + " to " + F.elem(giveList.getFirst().getName()) + "."));
}
}
}

View File

@ -50,7 +50,8 @@ public class PacketHandler extends MiniPlugin
Method method = ProtocolInjector.class.getDeclaredMethod("addPacket", EnumProtocol.class,boolean.class, int.class, Class.class);
method.setAccessible(true);
method.invoke(null, EnumProtocol.PLAY, true, 67, PacketPlayOutCamera.class);
method.invoke(null, EnumProtocol.PLAY, true, 68, PacketPlayOutWorldBorder.class);
// EnumProtocol.PLAY.b().put(68, PacketPlayOutWorldBorder.class);

View File

@ -0,0 +1,44 @@
package mineplex.core.packethandler;
import org.bukkit.entity.Entity;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketDataSerializer;
import net.minecraft.server.v1_7_R4.PacketListener;
public class PacketPlayOutCamera extends Packet
{
public int a;
public PacketPlayOutCamera()
{
}
public PacketPlayOutCamera(int id)
{
a = id;
}
public PacketPlayOutCamera(Entity paramEntity)
{
this.a = paramEntity.getEntityId();
}
public void a(PacketDataSerializer paramPacketDataSerializer)
{
}
public void b(PacketDataSerializer paramPacketDataSerializer)
{
paramPacketDataSerializer.b(this.a);
}
public void a(PacketListener paramPacketListenerPlayOut)
{
}
@Override
public void handle(PacketListener arg0)
{
}
}

View File

@ -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();
}
}
}
}

View File

@ -964,8 +964,13 @@ public abstract class Skywars extends Game
if (event.GetDamage() >= 1)
return;
if(GetTeam(event.GetDamagerPlayer(true)) == GetTeam(event.GetDamageePlayer()))
return;
if(this instanceof TeamSkywars)
{
if(GetTeam(event.GetDamagerPlayer(true)) == GetTeam(event.GetDamageePlayer()))
{
return;
}
}
if (event.GetProjectile() instanceof Egg || event.GetProjectile() instanceof Snowball)
{
@ -998,6 +1003,10 @@ public abstract class Skywars extends Game
{
if(event.getEntity() instanceof Player)
{
if(this instanceof SoloSkywars)
return;
if(GetTeam((Player) prj.getShooter()) == GetTeam((Player) event.getEntity()))
{
event.setCancelled(true);

View File

@ -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()

View File

@ -151,7 +151,7 @@ public class WorldData
File = Host.GetFiles().get(game).get(map);
//Don't allow repeat maps.
if (Host.GetFiles().size() > 1)
if (Host.GetFiles().get(game).size() > 1)
{
while (File.equals(Host.Manager.GetGameCreationManager().GetLastMap()))
{