Fix names

This commit is contained in:
git 2016-03-08 09:52:30 +13:00
parent 496983ee04
commit 280d03daa7

View File

@ -265,7 +265,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
_entityNameMap.get(owner.getName()).put(spawnPacket.a, entityName); _entityNameMap.get(owner.getName()).put(spawnPacket.a, entityName);
_entityMap.get(owner.getName()).put(spawnPacket.a, ids); _entityMap.get(owner.getName()).put(spawnPacket.a, ids);
sendProtocolPackets(owner, spawnPacket.a, ids[1], entityName, verifier, true, ids[0]); sendProtocolPackets(owner, spawnPacket.a, entityName, verifier, true, ids);
break; break;
} }
} }
@ -302,17 +302,16 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
return; return;
} }
int newId = UtilEnt.getNewEntityId(); Integer[] ids = new Integer[]
int newId2 = UtilEnt.getNewEntityId(); {
UtilEnt.getNewEntityId(),
UtilEnt.getNewEntityId()
};
_entityNameMap.get(owner.getName()).put(spawnPacket.a, entityName); _entityNameMap.get(owner.getName()).put(spawnPacket.a, entityName);
_entityMap.get(owner.getName()).put(spawnPacket.a, new Integer[] _entityMap.get(owner.getName()).put(spawnPacket.a, ids);
{
newId,
newId2
});
sendProtocolPackets(owner, spawnPacket.a, newId2, entityName, verifier, true, newId); sendProtocolPackets(owner, spawnPacket.a, entityName, verifier, true, ids);
break; break;
} }
} }
@ -372,8 +371,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
} }
_entityNameMap.get(owner.getName()).put(metaPacket.a, newName); _entityNameMap.get(owner.getName()).put(metaPacket.a, newName);
sendProtocolPackets(owner, metaPacket.a, newId[1], newName, verifier, !isDisplaying, sendProtocolPackets(owner, metaPacket.a, newName, verifier, !isDisplaying, newId);
!isDisplaying ? newId[0] : -1);
} }
else else
{ // Lets delete it { // Lets delete it
@ -486,14 +484,14 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
_entityRiding.get(owner.getName()).remove(attachPacket.b); _entityRiding.get(owner.getName()).remove(attachPacket.b);
sendProtocolPackets(owner, vehicleId, ids[1], _entityNameMap.get(owner.getName()).get(vehicleId), verifier, sendProtocolPackets(owner, vehicleId, _entityNameMap.get(owner.getName()).get(vehicleId), verifier, true,
true, ids[0]); ids);
} }
else else
{ {
Integer[] ids = _entityMap.get(owner.getName()).get(attachPacket.c); Integer[] ids = _entityMap.get(owner.getName()).get(attachPacket.c);
if (ids != null && ids[0] != attachPacket.b) if (ids != null && ids[1] != attachPacket.b)
{ {
_entityRiding.get(owner.getName()).put(attachPacket.b, attachPacket.c); _entityRiding.get(owner.getName()).put(attachPacket.b, attachPacket.c);
@ -511,8 +509,8 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
} }
} }
private void sendProtocolPackets(final Player owner, final int entityId, final int newEntityId, String entityName, private void sendProtocolPackets(final Player owner, final int entityId, String entityName, final PacketVerifier packetList,
final PacketVerifier packetList, final boolean newPacket, final int squidId) final boolean newPacket, final Integer[] entityIds)
{ {
CustomTagEvent event = new CustomTagEvent(owner, entityId, entityName); CustomTagEvent event = new CustomTagEvent(owner, entityId, entityName);
_plugin.getServer().getPluginManager().callEvent(event); _plugin.getServer().getPluginManager().callEvent(event);
@ -532,7 +530,6 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
if (newPacket) if (newPacket)
{ {
if (squidId >= 0)
{ {
watcher.watch(10, (byte) 16, EntityArmorStand.META_ARMOR_OPTION, (byte) 16); watcher.watch(10, (byte) 16, EntityArmorStand.META_ARMOR_OPTION, (byte) 16);
@ -540,7 +537,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
squidWatcher.a(0, (byte) (0 | 1 << 5), Entity.META_ENTITYDATA, (byte) (0 | 1 << 5)); squidWatcher.a(0, (byte) (0 | 1 << 5), Entity.META_ENTITYDATA, (byte) (0 | 1 << 5));
PacketPlayOutSpawnEntityLiving spawnPacket = new PacketPlayOutSpawnEntityLiving(); PacketPlayOutSpawnEntityLiving spawnPacket = new PacketPlayOutSpawnEntityLiving();
spawnPacket.a = squidId; spawnPacket.a = entityIds[1];
spawnPacket.b = (byte) EntityType.SQUID.getTypeId(); spawnPacket.b = (byte) EntityType.SQUID.getTypeId();
spawnPacket.c = 1000000; spawnPacket.c = 1000000;
@ -558,7 +555,7 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
} }
PacketPlayOutSpawnEntityLiving spawnPacket = new PacketPlayOutSpawnEntityLiving(); PacketPlayOutSpawnEntityLiving spawnPacket = new PacketPlayOutSpawnEntityLiving();
spawnPacket.a = newEntityId; spawnPacket.a = entityIds[0];
spawnPacket.b = (byte) 30; spawnPacket.b = (byte) 30;
spawnPacket.c = 1000000; spawnPacket.c = 1000000;
@ -569,15 +566,15 @@ public class CustomTagFix extends MiniPlugin implements IPacketHandler, NCPHook
PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity(); PacketPlayOutAttachEntity vehiclePacket = new PacketPlayOutAttachEntity();
vehiclePacket.a = 0; vehiclePacket.a = 0;
vehiclePacket.b = spawnPacket.a; vehiclePacket.b = entityIds[0];
vehiclePacket.c = squidId >= 0 ? squidId : entityId; vehiclePacket.c = entityIds[1];
UtilPlayer.sendPacket(owner, vehiclePacket); UtilPlayer.sendPacket(owner, vehiclePacket);
} }
else else
{ {
PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata(); PacketPlayOutEntityMetadata entityMetadata = new PacketPlayOutEntityMetadata();
entityMetadata.a = newEntityId; entityMetadata.a = entityIds[0];
entityMetadata.b = watcher.c(); entityMetadata.b = watcher.c();
packetList.bypassProcess(entityMetadata); packetList.bypassProcess(entityMetadata);