diff --git a/src/main/java/com/mattmx/nametags/OutgoingPacketListener.java b/src/main/java/com/mattmx/nametags/OutgoingPacketListener.java index aa83d81..b703cc4 100644 --- a/src/main/java/com/mattmx/nametags/OutgoingPacketListener.java +++ b/src/main/java/com/mattmx/nametags/OutgoingPacketListener.java @@ -4,13 +4,12 @@ import com.github.retrooper.packetevents.event.PacketSendEvent; import com.github.retrooper.packetevents.protocol.packettype.PacketType; import com.github.retrooper.packetevents.protocol.potion.PotionTypes; -import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerDestroyEntities; -import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerEntityEffect; -import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerRemoveEntityEffect; -import com.github.retrooper.packetevents.wrapper.play.server.WrapperPlayServerSpawnEntity; +import com.github.retrooper.packetevents.wrapper.play.server.*; import com.mattmx.nametags.entity.NameTagEntity; import org.jetbrains.annotations.NotNull; +import java.util.Arrays; + public class OutgoingPacketListener extends PacketListenerAbstract { private final @NotNull NameTags plugin; @@ -77,6 +76,22 @@ public void onPacketSend(@NotNull PacketSendEvent event) { nameTagEntity.updateVisibility(false); } +// case PacketType.Play.Server.SET_PASSENGERS -> { +// final WrapperPlayServerSetPassengers packet = new WrapperPlayServerSetPassengers(event); +// +// final NameTagEntity nameTagEntity = plugin.getEntityManager().getNameTagEntityById(packet.getEntityId()); +// +// if (nameTagEntity == null) return; +// +// if (Arrays.stream(packet.getPassengers()).noneMatch((i) -> nameTagEntity.getPassenger().getEntityId() == i)) { +// +// // Add our entity +// int[] passengers = Arrays.copyOf(packet.getPassengers(), packet.getPassengers().length + 1); +// passengers[passengers.length - 1] = nameTagEntity.getPassenger().getEntityId(); +// +// packet.setPassengers(passengers); +// } +// } default -> { } } diff --git a/src/main/java/com/mattmx/nametags/config/TextDisplayMetaConfiguration.java b/src/main/java/com/mattmx/nametags/config/TextDisplayMetaConfiguration.java index 905610c..3585217 100644 --- a/src/main/java/com/mattmx/nametags/config/TextDisplayMetaConfiguration.java +++ b/src/main/java/com/mattmx/nametags/config/TextDisplayMetaConfiguration.java @@ -6,6 +6,7 @@ import me.tofaa.entitylib.meta.display.AbstractDisplayMeta; import me.tofaa.entitylib.meta.display.TextDisplayMeta; import net.kyori.adventure.text.Component; +import net.kyori.adventure.text.TextComponent; import net.kyori.adventure.text.format.NamedTextColor; import net.kyori.adventure.text.minimessage.MiniMessage; import org.bukkit.Bukkit; @@ -27,7 +28,7 @@ public static boolean applyTextMeta(@NotNull ConfigurationSection section, @NotN // TODO(matt): Test if (NameTags.getInstance().getConfig().getBoolean("defaults.remove-empty-lines", false)) { - stream = stream.filter((line) -> line != Component.empty() && !line.children().stream().allMatch((c) -> c == Component.empty())); + stream = stream.filter(TextComponent.IS_NOT_EMPTY); } Component text = stream diff --git a/src/main/java/com/mattmx/nametags/entity/NameTagEntity.java b/src/main/java/com/mattmx/nametags/entity/NameTagEntity.java index a6c7316..bee6465 100644 --- a/src/main/java/com/mattmx/nametags/entity/NameTagEntity.java +++ b/src/main/java/com/mattmx/nametags/entity/NameTagEntity.java @@ -87,6 +87,7 @@ public void sendPassengerPacket(Player target) { } public PacketWrapper getPassengersPacket() { + // TODO(Matt): track previous passengers return new WrapperPlayServerSetPassengers(bukkitEntity.getEntityId(), new int[]{this.passenger.getEntityId()}); }