mirror of
https://github.com/HibiscusMC/HibiscusCommons.git
synced 2025-12-19 15:09:26 +00:00
fix: player info packet errors
This commit is contained in:
@@ -3,6 +3,7 @@ package me.lojosho.hibiscuscommons.nms.v1_20_R4;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import io.papermc.paper.adventure.PaperAdventure;
|
||||
@@ -13,6 +14,7 @@ import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.advancements.AdvancementHolder;
|
||||
import net.minecraft.network.chat.RemoteChatSession;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.game.*;
|
||||
import net.minecraft.network.syncher.EntityDataSerializer;
|
||||
@@ -83,13 +85,21 @@ public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.
|
||||
final List<Player> sendTo
|
||||
) {
|
||||
ServerPlayer player = ((CraftPlayer) skinnedPlayer).getHandle();
|
||||
String name = npcName.substring(0, 15);
|
||||
String name = npcName;
|
||||
if (name.length() > 15) name = name.substring(0, 15);
|
||||
Property property = ((CraftPlayer) skinnedPlayer).getProfile().getProperties().get("textures").stream().findAny().orElse(null);
|
||||
|
||||
GameProfile profile = new GameProfile(uuid, name);
|
||||
profile.getProperties().put("textures", property);
|
||||
|
||||
Component component = AdventureUtils.MINI_MESSAGE.deserialize(name);
|
||||
net.minecraft.network.chat.Component nmsComponent = HibiscusCommonsPlugin.isOnPaper() ? PaperAdventure.asVanilla(component) : net.minecraft.network.chat.Component.literal(name);
|
||||
|
||||
ClientboundPlayerInfoUpdatePacket.Entry entry = new ClientboundPlayerInfoUpdatePacket.Entry(uuid, profile, false, 0, GameType.CREATIVE, nmsComponent, player.getChatSession().asData());
|
||||
RemoteChatSession.Data chatData = null;
|
||||
RemoteChatSession session = player.getChatSession();
|
||||
if (session != null) chatData = player.getChatSession().asData();
|
||||
|
||||
ClientboundPlayerInfoUpdatePacket.Entry entry = new ClientboundPlayerInfoUpdatePacket.Entry(uuid, profile, false, 0, GameType.CREATIVE, nmsComponent, chatData);
|
||||
EnumSet<ClientboundPlayerInfoUpdatePacket.Action> actions = EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER);
|
||||
ClientboundPlayerInfoUpdatePacket packet = new ClientboundPlayerInfoUpdatePacket(actions, entry);
|
||||
for (Player p : sendTo) sendPacket(p, packet);
|
||||
|
||||
@@ -3,6 +3,7 @@ package me.lojosho.hibiscuscommons.nms.v1_21_R1;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import io.papermc.paper.adventure.PaperAdventure;
|
||||
@@ -13,6 +14,7 @@ import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.advancements.AdvancementHolder;
|
||||
import net.minecraft.network.chat.RemoteChatSession;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.game.*;
|
||||
import net.minecraft.network.syncher.EntityDataSerializer;
|
||||
@@ -83,13 +85,21 @@ public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.
|
||||
final List<Player> sendTo
|
||||
) {
|
||||
ServerPlayer player = ((CraftPlayer) skinnedPlayer).getHandle();
|
||||
String name = npcName.substring(0, 15);
|
||||
String name = npcName;
|
||||
if (name.length() > 15) name = name.substring(0, 15);
|
||||
Property property = ((CraftPlayer) skinnedPlayer).getProfile().getProperties().get("textures").stream().findAny().orElse(null);
|
||||
|
||||
GameProfile profile = new GameProfile(uuid, name);
|
||||
profile.getProperties().put("textures", property);
|
||||
|
||||
Component component = AdventureUtils.MINI_MESSAGE.deserialize(name);
|
||||
net.minecraft.network.chat.Component nmsComponent = HibiscusCommonsPlugin.isOnPaper() ? PaperAdventure.asVanilla(component) : net.minecraft.network.chat.Component.literal(name);
|
||||
|
||||
ClientboundPlayerInfoUpdatePacket.Entry entry = new ClientboundPlayerInfoUpdatePacket.Entry(uuid, profile, false, 0, GameType.CREATIVE, nmsComponent, player.getChatSession().asData());
|
||||
RemoteChatSession.Data chatData = null;
|
||||
RemoteChatSession session = player.getChatSession();
|
||||
if (session != null) chatData = player.getChatSession().asData();
|
||||
|
||||
ClientboundPlayerInfoUpdatePacket.Entry entry = new ClientboundPlayerInfoUpdatePacket.Entry(uuid, profile, false, 0, GameType.CREATIVE, nmsComponent, chatData);
|
||||
EnumSet<ClientboundPlayerInfoUpdatePacket.Action> actions = EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER);
|
||||
ClientboundPlayerInfoUpdatePacket packet = new ClientboundPlayerInfoUpdatePacket(actions, entry);
|
||||
for (Player p : sendTo) sendPacket(p, packet);
|
||||
|
||||
@@ -3,6 +3,7 @@ package me.lojosho.hibiscuscommons.nms.v1_21_R2;
|
||||
import com.google.common.collect.ImmutableList;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import io.papermc.paper.adventure.PaperAdventure;
|
||||
@@ -13,6 +14,7 @@ import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.advancements.AdvancementHolder;
|
||||
import net.minecraft.network.chat.RemoteChatSession;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.game.*;
|
||||
import net.minecraft.network.syncher.EntityDataSerializer;
|
||||
@@ -84,13 +86,21 @@ public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.
|
||||
final List<Player> sendTo
|
||||
) {
|
||||
ServerPlayer player = ((CraftPlayer) skinnedPlayer).getHandle();
|
||||
String name = npcName.substring(0, 15);
|
||||
String name = npcName;
|
||||
if (name.length() > 15) name = name.substring(0, 15);
|
||||
Property property = ((CraftPlayer) skinnedPlayer).getProfile().getProperties().get("textures").stream().findAny().orElse(null);
|
||||
|
||||
GameProfile profile = new GameProfile(uuid, name);
|
||||
profile.getProperties().put("textures", property);
|
||||
|
||||
Component component = AdventureUtils.MINI_MESSAGE.deserialize(name);
|
||||
net.minecraft.network.chat.Component nmsComponent = HibiscusCommonsPlugin.isOnPaper() ? PaperAdventure.asVanilla(component) : net.minecraft.network.chat.Component.literal(name);
|
||||
|
||||
ClientboundPlayerInfoUpdatePacket.Entry entry = new ClientboundPlayerInfoUpdatePacket.Entry(uuid, profile, false, 0, GameType.CREATIVE, nmsComponent, player.listOrder, player.getChatSession().asData());
|
||||
RemoteChatSession.Data chatData = null;
|
||||
RemoteChatSession session = player.getChatSession();
|
||||
if (session != null) chatData = player.getChatSession().asData();
|
||||
|
||||
ClientboundPlayerInfoUpdatePacket.Entry entry = new ClientboundPlayerInfoUpdatePacket.Entry(uuid, profile, false, 0, GameType.CREATIVE, nmsComponent, player.listOrder, chatData);
|
||||
EnumSet<ClientboundPlayerInfoUpdatePacket.Action> actions = EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER);
|
||||
ClientboundPlayerInfoUpdatePacket packet = new ClientboundPlayerInfoUpdatePacket(actions, entry);
|
||||
for (Player p : sendTo) sendPacket(p, packet);
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import io.papermc.paper.adventure.PaperAdventure;
|
||||
@@ -14,6 +15,7 @@ import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.advancements.AdvancementHolder;
|
||||
import net.minecraft.network.chat.RemoteChatSession;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.game.*;
|
||||
import net.minecraft.network.syncher.EntityDataSerializer;
|
||||
@@ -87,13 +89,21 @@ public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.
|
||||
final List<Player> sendTo
|
||||
) {
|
||||
ServerPlayer player = ((CraftPlayer) skinnedPlayer).getHandle();
|
||||
String name = npcName.substring(0, 15);
|
||||
String name = npcName;
|
||||
if (name.length() > 15) name = name.substring(0, 15);
|
||||
Property property = ((CraftPlayer) skinnedPlayer).getProfile().getProperties().get("textures").stream().findAny().orElse(null);
|
||||
|
||||
GameProfile profile = new GameProfile(uuid, name);
|
||||
profile.getProperties().put("textures", property);
|
||||
|
||||
Component component = AdventureUtils.MINI_MESSAGE.deserialize(name);
|
||||
net.minecraft.network.chat.Component nmsComponent = HibiscusCommonsPlugin.isOnPaper() ? PaperAdventure.asVanilla(component) : net.minecraft.network.chat.Component.literal(name);
|
||||
|
||||
ClientboundPlayerInfoUpdatePacket.Entry entry = new ClientboundPlayerInfoUpdatePacket.Entry(uuid, profile, false, 0, GameType.CREATIVE, nmsComponent, true, player.listOrder, player.getChatSession().asData());
|
||||
RemoteChatSession.Data chatData = null;
|
||||
RemoteChatSession session = player.getChatSession();
|
||||
if (session != null) chatData = player.getChatSession().asData();
|
||||
|
||||
ClientboundPlayerInfoUpdatePacket.Entry entry = new ClientboundPlayerInfoUpdatePacket.Entry(uuid, profile, false, 0, GameType.CREATIVE, nmsComponent, true, player.listOrder, chatData);
|
||||
EnumSet<ClientboundPlayerInfoUpdatePacket.Action> actions = EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER);
|
||||
ClientboundPlayerInfoUpdatePacket packet = new ClientboundPlayerInfoUpdatePacket(actions, entry);
|
||||
for (Player p : sendTo) sendPacket(p, packet);
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import io.papermc.paper.adventure.AdventureComponent;
|
||||
@@ -17,6 +18,7 @@ import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.advancements.AdvancementHolder;
|
||||
import net.minecraft.core.HolderLookup;
|
||||
import net.minecraft.core.registries.BuiltInRegistries;
|
||||
import net.minecraft.network.chat.RemoteChatSession;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.game.*;
|
||||
import net.minecraft.network.syncher.EntityDataSerializer;
|
||||
@@ -89,13 +91,21 @@ public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.
|
||||
final List<Player> sendTo
|
||||
) {
|
||||
ServerPlayer player = ((CraftPlayer) skinnedPlayer).getHandle();
|
||||
String name = npcName.substring(0, 15);
|
||||
String name = npcName;
|
||||
if (name.length() > 15) name = name.substring(0, 15);
|
||||
Property property = ((CraftPlayer) skinnedPlayer).getProfile().getProperties().get("textures").stream().findAny().orElse(null);
|
||||
|
||||
GameProfile profile = new GameProfile(uuid, name);
|
||||
profile.getProperties().put("textures", property);
|
||||
|
||||
Component component = AdventureUtils.MINI_MESSAGE.deserialize(name);
|
||||
net.minecraft.network.chat.Component nmsComponent = HibiscusCommonsPlugin.isOnPaper() ? PaperAdventure.asVanilla(component) : net.minecraft.network.chat.Component.literal(name);
|
||||
|
||||
ClientboundPlayerInfoUpdatePacket.Entry entry = new ClientboundPlayerInfoUpdatePacket.Entry(uuid, profile, false, 0, GameType.CREATIVE, nmsComponent, true, player.listOrder, player.getChatSession().asData());
|
||||
RemoteChatSession.Data chatData = null;
|
||||
RemoteChatSession session = player.getChatSession();
|
||||
if (session != null) chatData = player.getChatSession().asData();
|
||||
|
||||
ClientboundPlayerInfoUpdatePacket.Entry entry = new ClientboundPlayerInfoUpdatePacket.Entry(uuid, profile, false, 0, GameType.CREATIVE, nmsComponent, true, player.listOrder, chatData);
|
||||
EnumSet<ClientboundPlayerInfoUpdatePacket.Action> actions = EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER);
|
||||
ClientboundPlayerInfoUpdatePacket packet = new ClientboundPlayerInfoUpdatePacket(actions, entry);
|
||||
for (Player p : sendTo) sendPacket(p, packet);
|
||||
|
||||
@@ -4,6 +4,7 @@ import com.google.common.collect.ImmutableList;
|
||||
import com.google.gson.JsonArray;
|
||||
import com.google.gson.JsonObject;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
import io.papermc.paper.adventure.PaperAdventure;
|
||||
@@ -16,6 +17,7 @@ import net.kyori.adventure.text.serializer.gson.GsonComponentSerializer;
|
||||
import net.minecraft.advancements.Advancement;
|
||||
import net.minecraft.advancements.AdvancementHolder;
|
||||
import net.minecraft.commands.arguments.EntityAnchorArgument;
|
||||
import net.minecraft.network.chat.RemoteChatSession;
|
||||
import net.minecraft.network.protocol.Packet;
|
||||
import net.minecraft.network.protocol.game.*;
|
||||
import net.minecraft.network.syncher.EntityDataSerializers;
|
||||
@@ -85,13 +87,21 @@ public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.
|
||||
final List<Player> sendTo
|
||||
) {
|
||||
ServerPlayer player = ((CraftPlayer) skinnedPlayer).getHandle();
|
||||
String name = npcName.substring(0, 15);
|
||||
String name = npcName;
|
||||
if (name.length() > 15) name = name.substring(0, 15);
|
||||
Property property = ((CraftPlayer) skinnedPlayer).getProfile().getProperties().get("textures").stream().findAny().orElse(null);
|
||||
|
||||
GameProfile profile = new GameProfile(uuid, name);
|
||||
profile.getProperties().put("textures", property);
|
||||
|
||||
Component component = AdventureUtils.MINI_MESSAGE.deserialize(name);
|
||||
net.minecraft.network.chat.Component nmsComponent = HibiscusCommonsPlugin.isOnPaper() ? PaperAdventure.asVanilla(component) : net.minecraft.network.chat.Component.literal(name);
|
||||
|
||||
ClientboundPlayerInfoUpdatePacket.Entry entry = new ClientboundPlayerInfoUpdatePacket.Entry(uuid, profile, false, 0, GameType.CREATIVE, nmsComponent, true, player.listOrder, player.getChatSession().asData());
|
||||
RemoteChatSession.Data chatData = null;
|
||||
RemoteChatSession session = player.getChatSession();
|
||||
if (session != null) chatData = player.getChatSession().asData();
|
||||
|
||||
ClientboundPlayerInfoUpdatePacket.Entry entry = new ClientboundPlayerInfoUpdatePacket.Entry(uuid, profile, false, 0, GameType.CREATIVE, nmsComponent, true, player.listOrder, chatData);
|
||||
EnumSet<ClientboundPlayerInfoUpdatePacket.Action> actions = EnumSet.of(ClientboundPlayerInfoUpdatePacket.Action.ADD_PLAYER);
|
||||
ClientboundPlayerInfoUpdatePacket packet = new ClientboundPlayerInfoUpdatePacket(actions, entry);
|
||||
for (Player p : sendTo) sendPacket(p, packet);
|
||||
|
||||
Reference in New Issue
Block a user