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

This commit is contained in:
Cheese 2015-07-05 15:13:33 +10:00
commit 7182205fde
5 changed files with 261 additions and 41 deletions

View File

@ -64,6 +64,7 @@ import mineplex.core.common.util.UtilPlayer;
import mineplex.core.disguise.disguises.DisguiseBase;
import mineplex.core.disguise.disguises.DisguiseBlock;
import mineplex.core.disguise.disguises.DisguiseInsentient;
import mineplex.core.disguise.disguises.DisguiseLiving;
import mineplex.core.disguise.disguises.DisguisePlayer;
import mineplex.core.disguise.disguises.DisguiseRabbit;
import mineplex.core.packethandler.IPacketHandler;
@ -863,6 +864,11 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
handlePacket(new PacketPlayOutEntityTeleport(pDisguise.GetEntity()), packetVerifier);
}
for (Packet packet : pDisguise.getEquipmentPackets())
{
handlePacket(packet, packetVerifier);
}
handlePacket(pDisguise.GetMetaDataPacket(), packetVerifier);
Bukkit.getScheduler().scheduleSyncDelayedTask(getPlugin(), new Runnable()
@ -876,6 +882,16 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
else
{
handlePacket(disguise.GetSpawnPacket(), packetVerifier);
if (disguise instanceof DisguiseLiving)
{
ArrayList<Packet> packets = ((DisguiseLiving) disguise).getEquipmentPackets();
for (Packet packet : packets)
{
handlePacket(packet, packetVerifier);
}
}
}
}
@ -1125,7 +1141,7 @@ public class DisguiseManager extends MiniPlugin implements IPacketHandler
if (!(disguise.GetEntity() instanceof EntityPlayer))
continue;
EntityPlayer disguisedPlayer = (EntityPlayer)disguise.GetEntity();
EntityPlayer disguisedPlayer = (EntityPlayer) disguise.GetEntity();
if (Bukkit.getPlayerExact(disguisedPlayer.getName()) == null || !disguisedPlayer.isAlive() || !disguisedPlayer.valid)
disguiseIterator.remove();

View File

@ -1,20 +0,0 @@
package mineplex.core.disguise;
public enum DisguiseType
{
Zombie,
PigZombie,
Cow,
Pig,
Horse,
Wolf,
Ocelot,
Sheep,
Chicken,
Slime,
Blaze,
IronGolem,
Skeleton,
WitherSkeleton,
Wither
}

View File

@ -0,0 +1,146 @@
package mineplex.core.disguise.disguises;
import org.bukkit.util.Vector;
import net.minecraft.server.v1_7_R4.EnumEntitySize;
import net.minecraft.server.v1_7_R4.MathHelper;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutSpawnEntityLiving;
public class DisguiseArmorStand extends DisguiseInsentient
{
private Vector _headPosition;
public DisguiseArmorStand(org.bukkit.entity.Entity entity)
{
super(entity);
DataWatcher.a(10, (byte) 0);
for (int i = 11; i < 17; i++)
{
DataWatcher.a(i, new Vector(0, 0, 0));
}
// Rotations are from -360 to 360
}
public Vector getHeadPosition()
{
return _headPosition.clone();
}
protected String getHurtSound()
{
return null;
}
@Override
public Packet GetSpawnPacket()
{
PacketPlayOutSpawnEntityLiving packet = new PacketPlayOutSpawnEntityLiving();
packet.a = Entity.getId();
packet.b = (byte) 30;
packet.c = (int) EnumEntitySize.SIZE_2.a(Entity.locX);
packet.d = (int) MathHelper.floor(Entity.locY * 32.0D);
packet.e = (int) EnumEntitySize.SIZE_2.a(Entity.locZ);
packet.i = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
packet.j = (byte) ((int) (Entity.pitch * 256.0F / 360.0F));
packet.k = (byte) ((int) (Entity.yaw * 256.0F / 360.0F));
double var2 = 3.9D;
double var4 = 0;
double var6 = 0;
double var8 = 0;
if (var4 < -var2)
{
var4 = -var2;
}
if (var6 < -var2)
{
var6 = -var2;
}
if (var8 < -var2)
{
var8 = -var2;
}
if (var4 > var2)
{
var4 = var2;
}
if (var6 > var2)
{
var6 = var2;
}
if (var8 > var2)
{
var8 = var2;
}
packet.f = (int) (var4 * 8000.0D);
packet.g = (int) (var6 * 8000.0D);
packet.h = (int) (var8 * 8000.0D);
packet.l = DataWatcher;
packet.m = DataWatcher.b();
return packet;
}
public void setBodyPosition(Vector vector)
{
DataWatcher.watch(12, vector);
}
public void setHasArms()
{
DataWatcher.watch(10, (byte) DataWatcher.getByte(10) | 4);
}
public void setHeadPosition(Vector vector)
{
_headPosition = vector;
DataWatcher.watch(11, vector);
}
public void setLeftArmPosition(Vector vector)
{
DataWatcher.watch(13, vector);
}
public void setLeftLegPosition(Vector vector)
{
DataWatcher.watch(15, vector);
}
public void setRemoveBase()
{
DataWatcher.watch(10, (byte) DataWatcher.getByte(10) | 8);
}
public void setRightArmPosition(Vector vector)
{
DataWatcher.watch(14, vector);
}
public void setRightLegPosition(Vector vector)
{
DataWatcher.watch(16, vector);
}
public void setSmall()
{
DataWatcher.watch(10, (byte) DataWatcher.getByte(10) | 1);
}
public void setGravityEffected()
{
DataWatcher.watch(10, (byte) DataWatcher.getByte(10) | 2);
}
}

View File

@ -1,11 +1,6 @@
package mineplex.core.disguise.disguises;
import java.util.ArrayList;
import java.util.List;
import mineplex.core.common.*;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityEquipment;
import org.bukkit.*;
public abstract class DisguiseInsentient extends DisguiseLiving
@ -16,10 +11,14 @@ public abstract class DisguiseInsentient extends DisguiseLiving
{
super(entity);
DataWatcher.a(11, Byte.valueOf((byte)0));
DataWatcher.a(10, "");
DataWatcher.a(3, Byte.valueOf((byte) 0));
DataWatcher.a(2, "");
DataWatcher.a(3, Byte.valueOf((byte) 0));
DataWatcher.a(2, "");
if (!(this instanceof DisguiseArmorStand))
{
DataWatcher.a(11, Byte.valueOf((byte) 0));
DataWatcher.a(10, "");
}
}
public void setName(String name)

View File

@ -1,13 +1,21 @@
package mineplex.core.disguise.disguises;
import java.util.ArrayList;
import java.util.Random;
import org.bukkit.Material;
import org.bukkit.craftbukkit.v1_7_R4.inventory.CraftItemStack;
import org.bukkit.inventory.ItemStack;
import net.minecraft.server.v1_7_R4.EntityLiving;
import net.minecraft.server.v1_7_R4.Packet;
import net.minecraft.server.v1_7_R4.PacketPlayOutEntityEquipment;
public abstract class DisguiseLiving extends DisguiseBase
{
private static Random _random = new Random();
private boolean _invisible;
private ItemStack[] _equipment = new ItemStack[5];
public DisguiseLiving(org.bukkit.entity.Entity entity)
{
@ -19,6 +27,79 @@ public abstract class DisguiseLiving extends DisguiseBase
DataWatcher.a(9, Byte.valueOf((byte) 0));
}
public ItemStack[] getEquipment()
{
return _equipment;
}
public void setEquipment(ItemStack[] equipment)
{
_equipment = equipment;
}
public void setHelmet(ItemStack item)
{
_equipment[3] = item;
}
public void setChestplate(ItemStack item)
{
_equipment[2] = item;
}
public void setLeggings(ItemStack item)
{
_equipment[1] = item;
}
public void setBoots(ItemStack item)
{
_equipment[0] = item;
}
public void setHeldItem(ItemStack item)
{
_equipment[4] = item;
}
public ArrayList<Packet> getEquipmentPackets()
{
ArrayList<Packet> packets = new ArrayList<Packet>();
for (int nmsSlot = 0; nmsSlot < 5; nmsSlot++)
{
int armorSlot = nmsSlot - 1;
if (armorSlot < 0)
armorSlot = 4;
ItemStack itemstack = _equipment[armorSlot];
if (itemstack != null && itemstack.getType() != Material.AIR)
{
ItemStack item = null;
if (Entity instanceof EntityLiving)
{
item = CraftItemStack.asBukkitCopy(((EntityLiving) Entity).getEquipment()[nmsSlot]);
}
if (item == null || item.getType() == Material.AIR)
{
PacketPlayOutEntityEquipment packet = new PacketPlayOutEntityEquipment();
packet.a = GetEntityId();
packet.b = nmsSlot;
packet.c = CraftItemStack.asNMSCopy(itemstack);
packets.add(packet);
}
}
}
return packets;
}
public void UpdateDataWatcher()
{
super.UpdateDataWatcher();
@ -38,8 +119,6 @@ public abstract class DisguiseLiving extends DisguiseBase
}
}
public boolean isInvisible()
{
return _invisible;