Cleanup, fix a bug
This commit is contained in:
parent
986dfe6246
commit
eff6dc3025
@ -446,13 +446,24 @@ public class DisguiseUtilities
|
||||
{
|
||||
continue;
|
||||
}
|
||||
try
|
||||
{
|
||||
|
||||
int chunkX = (int) Math.floor(loc.getX() / 16D) - 17, chunkZ = (int) Math.floor(loc.getZ() / 16D) - 17;
|
||||
|
||||
chunkX -= chunkX % 8;
|
||||
chunkZ -= chunkZ % 8;
|
||||
|
||||
// Make unload packets
|
||||
|
||||
packets[i] = ProtocolLibrary.getProtocolManager().createPacketConstructor(Server.UNLOAD_CHUNK, chunkX, chunkZ)
|
||||
.createPacket(bedChunk, 0);
|
||||
|
||||
i++;
|
||||
|
||||
// Make load packets
|
||||
if (oldLoc == null || i > 1)
|
||||
{
|
||||
try
|
||||
{
|
||||
xChunk.set(bedChunk, chunkX);
|
||||
zChunk.set(bedChunk, chunkZ);
|
||||
}
|
||||
@ -461,6 +472,10 @@ public class DisguiseUtilities
|
||||
ex.printStackTrace(System.out);
|
||||
}
|
||||
|
||||
// MAP_CHUNK_BULK was replaced in 1.9 with several seperated chunk packets
|
||||
// packets[i] = ProtocolLibrary.getProtocolManager()
|
||||
// .createPacketConstructor(Server.MAP_CHUNK_BULK, Arrays.asList(bedChunk))
|
||||
// .createPacket(Arrays.asList(bedChunk));
|
||||
// Make unload packets
|
||||
try
|
||||
{
|
||||
@ -468,30 +483,12 @@ public class DisguiseUtilities
|
||||
.createPacket(bedChunk, 0);
|
||||
}
|
||||
catch (IllegalArgumentException ex)
|
||||
{
|
||||
try
|
||||
{
|
||||
packets[i] = ProtocolLibrary.getProtocolManager()
|
||||
.createPacketConstructor(Server.MAP_CHUNK, bedChunk, true, 0, 40).createPacket(bedChunk, true, 0, 48);
|
||||
}
|
||||
catch (IllegalArgumentException ex1)
|
||||
{
|
||||
packets[i] = ProtocolLibrary.getProtocolManager().createPacketConstructor(Server.MAP_CHUNK, bedChunk, true, 0)
|
||||
.createPacket(bedChunk, true, 0);
|
||||
}
|
||||
}
|
||||
|
||||
i++;
|
||||
// Make load packets
|
||||
if (oldLoc == null || i > 1)
|
||||
{
|
||||
// MAP_CHUNK_BULK was replaced in 1.9 with several seperated chunk packets
|
||||
// packets[i] = ProtocolLibrary.getProtocolManager()
|
||||
// .createPacketConstructor(Server.MAP_CHUNK_BULK, Arrays.asList(bedChunk))
|
||||
// .createPacket(Arrays.asList(bedChunk));
|
||||
packets[i] = ProtocolLibrary.getProtocolManager().createPacketConstructor(Server.MAP_CHUNK, bedChunk, true, 0)
|
||||
.createPacket(bedChunk, true, 0);
|
||||
i++;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -53,14 +53,19 @@ public class PacketListenerClientInteract extends PacketAdapter
|
||||
event.setCancelled(true);
|
||||
}
|
||||
|
||||
ItemStack item = observer.getItemInHand();
|
||||
|
||||
if (item != null && item.getType() == Material.INK_SACK)
|
||||
for (ItemStack item : new ItemStack[]
|
||||
{
|
||||
observer.getInventory().getItemInMainHand(), observer.getInventory().getItemInOffHand()
|
||||
})
|
||||
{
|
||||
if (item == null || item.getType() != Material.INK_SACK)
|
||||
continue;
|
||||
|
||||
Disguise disguise = DisguiseAPI.getDisguise(observer, entity);
|
||||
|
||||
if (disguise != null && (disguise.getType() == DisguiseType.SHEEP || disguise.getType() == DisguiseType.WOLF))
|
||||
{
|
||||
if (disguise == null || (disguise.getType() != DisguiseType.SHEEP && disguise.getType() != DisguiseType.WOLF))
|
||||
continue;
|
||||
|
||||
AnimalColor color = AnimalColor.getColor(item.getDurability());
|
||||
|
||||
if (disguise.getType() == DisguiseType.SHEEP)
|
||||
@ -77,7 +82,6 @@ public class PacketListenerClientInteract extends PacketAdapter
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
|
@ -41,8 +41,11 @@ public class PacketListenerInventory extends PacketAdapter
|
||||
if (event.getPlayer().getName().contains("UNKNOWN[")) // If the player is temporary
|
||||
return;
|
||||
|
||||
if (!(event.getPlayer() instanceof com.comphenix.net.sf.cglib.proxy.Factory) && event.getPlayer().getVehicle() == null)
|
||||
if (event.getPlayer() instanceof com.comphenix.net.sf.cglib.proxy.Factory || event.getPlayer().getVehicle() != null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Disguise disguise = DisguiseAPI.getDisguise(event.getPlayer(), event.getPlayer());
|
||||
|
||||
// If player is disguised, views self disguises and has a inventory modifier
|
||||
@ -265,23 +268,29 @@ public class PacketListenerInventory extends PacketAdapter
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketSending(PacketEvent event)
|
||||
{
|
||||
// If the inventory is the players inventory
|
||||
if (!(event.getPlayer() instanceof com.comphenix.net.sf.cglib.proxy.Factory) && event.getPlayer().getVehicle() == null
|
||||
&& event.getPacket().getIntegers().read(0) == 0)
|
||||
if (event.getPlayer() instanceof com.comphenix.net.sf.cglib.proxy.Factory || event.getPlayer().getVehicle() != null
|
||||
|| event.getPacket().getIntegers().read(0) != 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Disguise disguise = DisguiseAPI.getDisguise(event.getPlayer(), event.getPlayer());
|
||||
|
||||
// If the player is disguised, views self disguises and is hiding a item.
|
||||
if (disguise != null && disguise.isSelfDisguiseVisible()
|
||||
&& (disguise.isHidingArmorFromSelf() || disguise.isHidingHeldItemFromSelf()))
|
||||
if (disguise == null || !disguise.isSelfDisguiseVisible()
|
||||
|| (!disguise.isHidingArmorFromSelf() && !disguise.isHidingHeldItemFromSelf()))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// If the player is disguised, views self disguises and is hiding a item.
|
||||
|
||||
// If the server is setting the slot
|
||||
// Need to set it to air if its in a place it shouldn't be.
|
||||
// Things such as picking up a item, spawned in item. Plugin sets the item. etc. Will fire this
|
||||
@ -351,8 +360,7 @@ public class PacketListenerInventory extends PacketAdapter
|
||||
// Get the bukkit armor slot!
|
||||
int armorSlot = Math.abs((slot - 5) - 3);
|
||||
|
||||
org.bukkit.inventory.ItemStack item = event.getPlayer().getInventory()
|
||||
.getArmorContents()[armorSlot];
|
||||
org.bukkit.inventory.ItemStack item = event.getPlayer().getInventory().getArmorContents()[armorSlot];
|
||||
|
||||
if (item != null && item.getType() != Material.AIR)
|
||||
{
|
||||
@ -384,7 +392,5 @@ public class PacketListenerInventory extends PacketAdapter
|
||||
mods.write(0, items);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -53,8 +53,11 @@ public class PacketListenerMain extends PacketAdapter
|
||||
|
||||
PacketContainer[][] packets = PacketsManager.transformPacket(event.getPacket(), event.getPlayer(), entity);
|
||||
|
||||
if (packets != null)
|
||||
if (packets == null)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
event.setCancelled(true);
|
||||
|
||||
try
|
||||
@ -66,8 +69,11 @@ public class PacketListenerMain extends PacketAdapter
|
||||
|
||||
final PacketContainer[] delayed = packets[1];
|
||||
|
||||
if (delayed.length > 0)
|
||||
if (delayed.length == 0)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable()
|
||||
{
|
||||
public void run()
|
||||
@ -86,12 +92,11 @@ public class PacketListenerMain extends PacketAdapter
|
||||
}
|
||||
}, 2);
|
||||
}
|
||||
}
|
||||
catch (InvocationTargetException ex)
|
||||
{
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -286,8 +286,11 @@ public class PacketListenerSounds extends PacketAdapter
|
||||
}
|
||||
else if (event.getPacketType() == Server.ENTITY_STATUS)
|
||||
{
|
||||
if ((byte) mods.read(1) == 2)
|
||||
if ((byte) mods.read(1) != 2)
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// It made a damage animation
|
||||
Entity entity = event.getPacket().getEntityModifier(observer.getWorld()).read(0);
|
||||
|
||||
@ -403,4 +406,3 @@ public class PacketListenerSounds extends PacketAdapter
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -47,10 +47,16 @@ public class PacketListenerViewDisguises extends PacketAdapter
|
||||
if (observer.getName().contains("UNKNOWN[")) // If the player is temporary
|
||||
return;
|
||||
|
||||
if (event.getPacket().getIntegers().read(0) == observer.getEntityId())
|
||||
if (event.getPacket().getIntegers().read(0) != observer.getEntityId())
|
||||
{
|
||||
if (DisguiseAPI.isSelfDisguised(observer))
|
||||
return;
|
||||
}
|
||||
|
||||
if (!DisguiseAPI.isSelfDisguised(observer))
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
// Here I grab the packets to convert them to, So I can display them as if the disguise sent them.
|
||||
PacketContainer[][] transformed = PacketsManager.transformPacket(event.getPacket(), observer, observer);
|
||||
|
||||
@ -184,5 +190,3 @@ public class PacketListenerViewDisguises extends PacketAdapter
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user