Skip to content

Commit

Permalink
merge 1.20.4 support
Browse files Browse the repository at this point in the history
  • Loading branch information
LordTuxn committed Jan 6, 2024
1 parent f322007 commit 5e3df88
Show file tree
Hide file tree
Showing 4 changed files with 21 additions and 5 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import io.papermc.paper.adventure.PaperAdventure;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import me.dave.chatcolorhandler.ModernChatColorHandler;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.game.*;
Expand Down Expand Up @@ -188,7 +189,9 @@ public void update(Player player) {

team.setColor(PaperAdventure.asVanilla(data.getGlowingColor()));

net.kyori.adventure.text.Component displayName = ModernChatColorHandler.translate(data.getDisplayName(), serverPlayer.getBukkitEntity());
net.kyori.adventure.text.Component displayName;
if (data.getDisplayName().equalsIgnoreCase("<empty>")) displayName = MiniMessage.miniMessage().deserialize("<white>NPC</white>");
else displayName = ModernChatColorHandler.translate(data.getDisplayName(), serverPlayer.getBukkitEntity());
Component vanillaComponent = PaperAdventure.asVanilla(displayName);
if (!(npc instanceof ServerPlayer)) {
npc.setCustomName(vanillaComponent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import io.papermc.paper.adventure.PaperAdventure;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import me.dave.chatcolorhandler.ModernChatColorHandler;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.chat.Component;
import net.minecraft.network.protocol.game.*;
Expand Down Expand Up @@ -190,7 +191,9 @@ public void update(Player player) {

team.setColor(PaperAdventure.asVanilla(data.getGlowingColor()));

net.kyori.adventure.text.Component displayName = ModernChatColorHandler.translate(data.getDisplayName(), serverPlayer.getBukkitEntity());
net.kyori.adventure.text.Component displayName;
if (data.getDisplayName().equalsIgnoreCase("<empty>")) displayName = MiniMessage.miniMessage().deserialize("<white>NPC</white>");
else displayName = ModernChatColorHandler.translate(data.getDisplayName(), serverPlayer.getBukkitEntity());
Component vanillaComponent = PaperAdventure.asVanilla(displayName);
if (!(npc instanceof ServerPlayer)) {
npc.setCustomName(vanillaComponent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import io.papermc.paper.adventure.PaperAdventure;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import me.dave.chatcolorhandler.ModernChatColorHandler;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.minecraft.Optionull;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.chat.Component;
Expand Down Expand Up @@ -191,7 +192,9 @@ public void update(Player player) {

team.setColor(PaperAdventure.asVanilla(data.getGlowingColor()));

net.kyori.adventure.text.Component displayName = ModernChatColorHandler.translate(data.getDisplayName(), serverPlayer.getBukkitEntity());
net.kyori.adventure.text.Component displayName;
if (data.getDisplayName().equalsIgnoreCase("<empty>")) displayName = MiniMessage.miniMessage().deserialize("<white>NPC</white>");
else displayName = ModernChatColorHandler.translate(data.getDisplayName(), serverPlayer.getBukkitEntity());
Component vanillaComponent = PaperAdventure.asVanilla(displayName);
if (!(npc instanceof ServerPlayer)) {
npc.setCustomName(vanillaComponent);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
import io.papermc.paper.adventure.PaperAdventure;
import it.unimi.dsi.fastutil.ints.Int2ObjectMap;
import me.dave.chatcolorhandler.ModernChatColorHandler;
import net.kyori.adventure.text.minimessage.MiniMessage;
import net.minecraft.Optionull;
import net.minecraft.core.registries.BuiltInRegistries;
import net.minecraft.network.chat.Component;
Expand Down Expand Up @@ -88,6 +89,10 @@ public void spawn(Player player) {
return;
}

if (data.isOnlyVisibleToEnabled() && !data.getOnlyVisibleToPlayers().contains(player.getUniqueId().toString())) {
return;
}

if (!data.getLocation().getWorld().getName().equalsIgnoreCase(serverPlayer.level().getWorld().getName())) {
return;
}
Expand Down Expand Up @@ -142,7 +147,7 @@ public void remove(Player player) {
serverPlayer.connection.send(removeSittingVehiclePacket);
}

isVisibleForPlayer.put(serverPlayer.getUUID(), false);
isVisibleForPlayer.remove(player.getUniqueId());
}

@Override
Expand Down Expand Up @@ -187,7 +192,9 @@ public void update(Player player) {

team.setColor(PaperAdventure.asVanilla(data.getGlowingColor()));

net.kyori.adventure.text.Component displayName = ModernChatColorHandler.translate(data.getDisplayName(), serverPlayer.getBukkitEntity());
net.kyori.adventure.text.Component displayName;
if (data.getDisplayName().equalsIgnoreCase("<empty>")) displayName = MiniMessage.miniMessage().deserialize("<white>NPC</white>");
else displayName = ModernChatColorHandler.translate(data.getDisplayName(), serverPlayer.getBukkitEntity());
Component vanillaComponent = PaperAdventure.asVanilla(displayName);
if (!(npc instanceof ServerPlayer)) {
npc.setCustomName(vanillaComponent);
Expand Down

0 comments on commit 5e3df88

Please sign in to comment.