Update for 1.17.1, bumped required PL version
This commit is contained in:
parent
c1afce7378
commit
5eaf7faa1b
@ -741,12 +741,11 @@ public abstract class Disguise {
|
||||
|
||||
if (getInternalArmorstandIds().length > 0) {
|
||||
try {
|
||||
for (PacketContainer packet : DisguiseUtilities.getDestroyPackets(getInternalArmorstandIds())) {
|
||||
for (Player player : getEntity().getWorld().getPlayers()) {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
|
||||
}
|
||||
}
|
||||
PacketContainer packet = DisguiseUtilities.getDestroyPacket(getInternalArmorstandIds());
|
||||
|
||||
for (Player player : getEntity().getWorld().getPlayers()) {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
|
||||
}
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
@ -479,7 +479,7 @@ public class DisguiseUtilities {
|
||||
}
|
||||
|
||||
// If we are on 1.17, future release build or this dev build
|
||||
return new String[]{"4.7.1", "521"};
|
||||
return new String[]{"4.7.1", "528"};
|
||||
}
|
||||
|
||||
public static boolean isProtocolLibOutdated() {
|
||||
@ -1097,14 +1097,16 @@ public class DisguiseUtilities {
|
||||
}
|
||||
|
||||
public static PacketContainer getDestroyPacket(int... ids) {
|
||||
if (NmsVersion.v1_17.isSupported() && ids.length != 1) {
|
||||
throw new IllegalStateException("Should use getDestroyPackets for ints of len " + ids.length);
|
||||
}
|
||||
|
||||
PacketContainer destroyPacket = new PacketContainer(Server.ENTITY_DESTROY);
|
||||
|
||||
if (NmsVersion.v1_17.isSupported()) {
|
||||
destroyPacket.getIntegers().write(0, ids[0]);
|
||||
List<Integer> ints = new ArrayList<>();
|
||||
|
||||
for (int id : ids) {
|
||||
ints.add(id);
|
||||
}
|
||||
|
||||
destroyPacket.getIntLists().write(0, ints);
|
||||
} else {
|
||||
destroyPacket.getIntegerArrays().write(0, ids);
|
||||
}
|
||||
@ -1112,22 +1114,6 @@ public class DisguiseUtilities {
|
||||
return destroyPacket;
|
||||
}
|
||||
|
||||
public static PacketContainer[] getDestroyPackets(int... ids) {
|
||||
if (!NmsVersion.v1_17.isSupported()) {
|
||||
return new PacketContainer[]{getDestroyPacket(ids)};
|
||||
}
|
||||
|
||||
PacketContainer[] packets = new PacketContainer[ids.length];
|
||||
|
||||
for (int i = 0; i < packets.length; i++) {
|
||||
packets[i] = new PacketContainer(Server.ENTITY_DESTROY);
|
||||
|
||||
packets[i].getIntegers().write(0, ids[i]);
|
||||
}
|
||||
|
||||
return packets;
|
||||
}
|
||||
|
||||
public static TargetedDisguise getDisguise(Player observer, Entity entity) {
|
||||
int entityId = entity.getEntityId();
|
||||
|
||||
@ -1837,12 +1823,10 @@ public class DisguiseUtilities {
|
||||
ids[ids.length - 1] = DisguiseAPI.getSelfDisguiseId();
|
||||
|
||||
// Send a packet to destroy the fake entity
|
||||
for (PacketContainer packet : getDestroyPackets(ids)) {
|
||||
try {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
try {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, getDestroyPacket(ids));
|
||||
} catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
|
||||
// player.spigot().setCollidesWithEntities(true);
|
||||
@ -3051,9 +3035,7 @@ public class DisguiseUtilities {
|
||||
}
|
||||
|
||||
if (destroyIds.length > 0) {
|
||||
for (PacketContainer packet : getDestroyPackets(destroyIds)) {
|
||||
packets.add(packet);
|
||||
}
|
||||
packets.add(getDestroyPacket(destroyIds));
|
||||
}
|
||||
|
||||
return packets;
|
||||
|
@ -14,6 +14,7 @@ import org.bukkit.plugin.Plugin;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
|
||||
/**
|
||||
* Created by libraryaddict on 3/05/2020.
|
||||
@ -30,22 +31,19 @@ public class PacketListenerEntityDestroy extends PacketAdapter {
|
||||
}
|
||||
|
||||
if (!NmsVersion.v1_17.isSupported()) {
|
||||
onPre17Packet(event);
|
||||
return;
|
||||
}
|
||||
int[] entityIds = event.getPacket().getIntegerArrays().read(0);
|
||||
|
||||
int[] toAdd = getToRemove(event.getPlayer(), event.getPacket().getIntegers().read(0));
|
||||
|
||||
if (toAdd == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
try {
|
||||
for (PacketContainer container : DisguiseUtilities.getDestroyPackets(toAdd)) {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), container);
|
||||
for (int entityId : entityIds) {
|
||||
handleEntityId(event.getPlayer(), entityId);
|
||||
}
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
List<Integer> entityIds = event.getPacket().getIntLists().read(0);
|
||||
|
||||
for (int entityId : entityIds) {
|
||||
handleEntityId(event.getPlayer(), entityId);
|
||||
}
|
||||
}
|
||||
|
||||
@ -69,23 +67,17 @@ public class PacketListenerEntityDestroy extends PacketAdapter {
|
||||
return disguise.getArmorstandIds();
|
||||
}
|
||||
|
||||
public void onPre17Packet(PacketEvent event) {
|
||||
int[] entityIds = event.getPacket().getIntegerArrays().read(0);
|
||||
private void handleEntityId(Player player, int entityId) {
|
||||
int[] toRemove = getToRemove(player, entityId);
|
||||
|
||||
for (int entityId : entityIds) {
|
||||
int[] toRemove = getToRemove(event.getPlayer(), entityId);
|
||||
if (toRemove == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (toRemove == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
try {
|
||||
for (PacketContainer container : DisguiseUtilities.getDestroyPackets(toRemove)) {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), container);
|
||||
}
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
try {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, DisguiseUtilities.getDestroyPacket(toRemove));
|
||||
} catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user