9
0
mirror of https://github.com/HibiscusMC/HMCCosmetics.git synced 2025-12-30 04:19:28 +00:00

feat: full 1.19.4 support

This commit is contained in:
LoJoSho
2023-04-02 12:00:31 -05:00
parent 879a58d1f4
commit ca01a94502
4 changed files with 13 additions and 11 deletions

View File

@@ -156,7 +156,7 @@ public class UserWardrobeManager {
List<Player> outsideViewers = PacketManager.getViewers(viewingLocation);
outsideViewers.remove(player);
MessagesUtil.sendMessage(player, "closed-wardrobe");
if (player != null) MessagesUtil.sendMessage(player, "closed-wardrobe");
Runnable run = () -> {
this.active = false;

View File

@@ -7,6 +7,7 @@ import org.bukkit.entity.Player;
public class BasePacket {
public static void sendPacket(Player player, PacketContainer packet) {
if (player == null) return;
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet, false);
}
}

View File

@@ -135,7 +135,8 @@ public class PacketManager extends BasePacket {
packet.getModifier().writeDefaults();
packet.getIntegers().write(0, entityId);
WrappedDataWatcher wrapper = new WrappedDataWatcher();
if (!NMSHandlers.getVersion().contains("v1_19_R2")) {
if (NMSHandlers.getVersion().contains("v1_17_R1") || NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1")) {
wrapper.setObject(new WrappedDataWatcher.WrappedDataWatcherObject(0, WrappedDataWatcher.Registry.get(Byte.class)), (byte) 0x20);
packet.getWatchableCollectionModifier().write(0, wrapper.getWatchableObjects());
} else {
@@ -305,19 +306,17 @@ public class PacketManager extends BasePacket {
WrappedGameProfile wrappedGameProfile = new WrappedGameProfile(uuid, name);
WrappedSignedProperty skinData = PlayerUtils.getSkin(skinnedPlayer);
if (skinData != null) wrappedGameProfile.getProperties().put("textures", skinData);
if (!NMSHandlers.getVersion().contains("v1_19_R2")) {
info.setData(List.of(new PlayerInfoData(wrappedGameProfile, 0, EnumWrappers.NativeGameMode.CREATIVE, WrappedChatComponent.fromText(name))));
} else {
if (NMSHandlers.getVersion().contains("v1_17_R1") || NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1") || NMSHandlers.getVersion().contains("v1_19_R3")) {
info.getHandle().getPlayerInfoDataLists().write(1, Collections.singletonList(new PlayerInfoData(
wrappedGameProfile,
0,
EnumWrappers.NativeGameMode.CREATIVE,
WrappedChatComponent.fromText(name)
)));
} else {
info.setData(List.of(new PlayerInfoData(wrappedGameProfile, 0, EnumWrappers.NativeGameMode.CREATIVE, WrappedChatComponent.fromText(name))));
}
for (final Player p : sendTo) sendPacket(p, info.getHandle());
return;
}
/**
@@ -364,7 +363,7 @@ public class PacketManager extends BasePacket {
final UUID uuid,
final List<Player> sendTo
) {
if (!NMSHandlers.getVersion().contains("v1_19_R2")) {
if (NMSHandlers.getVersion().contains("v1_17_R1") || NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1")) {
WrapperPlayServerPlayerInfo info = new WrapperPlayServerPlayerInfo();
info.setAction(EnumWrappers.PlayerInfoAction.REMOVE_PLAYER);
@@ -377,6 +376,7 @@ public class PacketManager extends BasePacket {
for (final Player p : sendTo) sendPacket(p, info.getHandle());
return;
}
PacketContainer packet = new PacketContainer(PacketType.Play.Server.PLAYER_INFO_REMOVE);
packet.getUUIDLists().write(0, List.of(uuid));
for (final Player p : sendTo) sendPacket(p, packet);

View File

@@ -26,11 +26,12 @@ public class WrapperPlayServerPlayerInfo extends AbstractPacket {
}
public void setAction(PlayerInfoAction value) {
if (!NMSHandlers.getVersion().contains("v1_19_R2")) {
if (NMSHandlers.getVersion().contains("v1_17_R1") || NMSHandlers.getVersion().contains("v1_18_R2") || NMSHandlers.getVersion().contains("v1_19_R1")) {
handle.getPlayerInfoAction().write(0, value);
} else {
handle.getPlayerInfoActions().write(0, Set.of(value));
return;
}
// New way of handling it 1.19.3+
handle.getPlayerInfoActions().write(0, Set.of(value));
}
public List<PlayerInfoData> getData() {