From 6648f2dab2f07049d8d8cac5fc3c33f2e9e84471 Mon Sep 17 00:00:00 2001 From: Tofaa <82680183+Tofaa2@users.noreply.github.com> Date: Thu, 14 Dec 2023 16:17:58 +0300 Subject: [PATCH] update to pe 2.2.0 --- .idea/misc.xml | 1 - build.gradle | 2 +- src/main/java/me/tofaa/entitylib/EntityLib.java | 1 - .../java/me/tofaa/entitylib/MetaConverterRegistry.java | 2 +- .../java/me/tofaa/entitylib/entity/WrapperEntity.java | 5 +---- src/main/java/me/tofaa/entitylib/extras/Rotation.java | 4 ++-- src/main/java/me/tofaa/entitylib/meta/EntityMeta.java | 8 +++++++- .../main/java/me/tofaa/entitylib/TestEntityCommand.java | 8 ++------ 8 files changed, 14 insertions(+), 17 deletions(-) diff --git a/.idea/misc.xml b/.idea/misc.xml index 4a4c03e..a58e41d 100644 --- a/.idea/misc.xml +++ b/.idea/misc.xml @@ -1,4 +1,3 @@ - diff --git a/build.gradle b/build.gradle index 39741a5..3699205 100644 --- a/build.gradle +++ b/build.gradle @@ -36,6 +36,6 @@ allprojects { dependencies { - compileOnlyApi("com.github.retrooper.packetevents:spigot:2.1.0") + compileOnlyApi("com.github.retrooper.packetevents:spigot:2.2.0") } diff --git a/src/main/java/me/tofaa/entitylib/EntityLib.java b/src/main/java/me/tofaa/entitylib/EntityLib.java index 01237f4..0c9be28 100644 --- a/src/main/java/me/tofaa/entitylib/EntityLib.java +++ b/src/main/java/me/tofaa/entitylib/EntityLib.java @@ -6,7 +6,6 @@ import com.github.retrooper.packetevents.manager.server.ServerVersion; import com.github.retrooper.packetevents.protocol.entity.type.EntityType; import com.github.retrooper.packetevents.protocol.packettype.PacketType; -import com.github.retrooper.packetevents.protocol.packettype.PacketTypeCommon; import com.github.retrooper.packetevents.wrapper.PacketWrapper; import com.github.retrooper.packetevents.wrapper.play.client.WrapperPlayClientInteractEntity; import me.tofaa.entitylib.entity.EntityInteractionProcessor; diff --git a/src/main/java/me/tofaa/entitylib/MetaConverterRegistry.java b/src/main/java/me/tofaa/entitylib/MetaConverterRegistry.java index 5ac8839..676e251 100644 --- a/src/main/java/me/tofaa/entitylib/MetaConverterRegistry.java +++ b/src/main/java/me/tofaa/entitylib/MetaConverterRegistry.java @@ -1,7 +1,6 @@ package me.tofaa.entitylib; import com.github.retrooper.packetevents.protocol.entity.type.EntityType; -import com.sun.org.apache.bcel.internal.generic.PUTFIELD; import me.tofaa.entitylib.meta.EntityMeta; import me.tofaa.entitylib.meta.Metadata; import me.tofaa.entitylib.meta.mobs.*; @@ -39,6 +38,7 @@ import static com.github.retrooper.packetevents.protocol.entity.type.EntityTypes.*; +@SuppressWarnings("unchecked") final class MetaConverterRegistry { private final Map> converters = new HashMap<>(); diff --git a/src/main/java/me/tofaa/entitylib/entity/WrapperEntity.java b/src/main/java/me/tofaa/entitylib/entity/WrapperEntity.java index bcaa565..d0838af 100644 --- a/src/main/java/me/tofaa/entitylib/entity/WrapperEntity.java +++ b/src/main/java/me/tofaa/entitylib/entity/WrapperEntity.java @@ -61,7 +61,6 @@ public void rotateHead(Location location) { rotateHead(location.getYaw(), location.getPitch()); } - public void remove() { if (!spawned) return; spawned = false; @@ -85,9 +84,7 @@ public void teleport(Location location) { } public void sendPacketToViewers(PacketWrapper packet) { - viewers.forEach(uuid -> { - EntityLib.sendPacket(uuid, packet); - }); + viewers.forEach(uuid -> EntityLib.sendPacket(uuid, packet)); } public boolean addViewer(UUID uuid) { diff --git a/src/main/java/me/tofaa/entitylib/extras/Rotation.java b/src/main/java/me/tofaa/entitylib/extras/Rotation.java index d79110d..b05b61e 100644 --- a/src/main/java/me/tofaa/entitylib/extras/Rotation.java +++ b/src/main/java/me/tofaa/entitylib/extras/Rotation.java @@ -19,11 +19,11 @@ public enum Rotation { */ CLOCKWISE_135, /** - * Flipped upside-down, a 180 degree rotation + * Flipped upside-down, a 180-degree rotation */ FLIPPED, /** - * Flipped upside-down + 45 degree rotation + * Flipped upside-down + 45-degree rotation */ FLIPPED_45, /** diff --git a/src/main/java/me/tofaa/entitylib/meta/EntityMeta.java b/src/main/java/me/tofaa/entitylib/meta/EntityMeta.java index dfee9c4..f52d151 100644 --- a/src/main/java/me/tofaa/entitylib/meta/EntityMeta.java +++ b/src/main/java/me/tofaa/entitylib/meta/EntityMeta.java @@ -6,6 +6,7 @@ import com.github.retrooper.packetevents.protocol.entity.data.EntityDataTypes; import com.github.retrooper.packetevents.protocol.entity.data.EntityMetadataProvider; import com.github.retrooper.packetevents.protocol.entity.pose.EntityPose; +import com.github.retrooper.packetevents.protocol.player.ClientVersion; import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityMetadata; import me.tofaa.entitylib.EntityLib; import me.tofaa.entitylib.exception.InvalidVersionException; @@ -200,11 +201,16 @@ protected void setMaskBit(int index, byte bit, boolean value) { if (value) { mask |= bit; } else { - mask &= ~bit; + mask &= (byte) ~bit; } setMask((byte)index, mask); } + @Override + public List entityData(ClientVersion clientVersion) { + return metadata.getEntries(); // TODO: Atm this is useless cause of the way the api works. Might change in the future + } + @Override public List entityData() { return metadata.getEntries(); diff --git a/test-plugin/src/main/java/me/tofaa/entitylib/TestEntityCommand.java b/test-plugin/src/main/java/me/tofaa/entitylib/TestEntityCommand.java index 7d44661..d4fe719 100644 --- a/test-plugin/src/main/java/me/tofaa/entitylib/TestEntityCommand.java +++ b/test-plugin/src/main/java/me/tofaa/entitylib/TestEntityCommand.java @@ -33,10 +33,10 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return false; } entity.addViewer(player.getUniqueId()); - entity.spawn(fromBukkit(player.getLocation())); + entity.spawn(SpigotConversionUtil.fromBukkitLocation(player.getLocation())); } ItemStack held = player.getInventory().getItemInMainHand(); - if (held != null && held.getType() != Material.AIR) { + if (held != null && !held.getType().isAir()) { entity.getEquipment().setBoots(SpigotConversionUtil.fromBukkitItemStack(held)); } EntityMeta meta = entity.getMeta(); @@ -49,8 +49,4 @@ public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command return false; } - public static Location fromBukkit(org.bukkit.Location location) { - return new Location(location.getX(), location.getY(), location.getZ(), location.getYaw(), location.getPitch()); - } - }