Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

🔥 Switch to provided predicate for empty Components. #18 #20

Merged
merged 1 commit into from
Oct 9, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 19 additions & 4 deletions src/main/java/com/mattmx/nametags/OutgoingPacketListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -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 -> {
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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()});
}

Expand Down
Loading