9
0
mirror of https://github.com/HibiscusMC/HibiscusCommons.git synced 2025-12-19 15:09:26 +00:00

fix: multimap stuff for 1.21.10

This commit is contained in:
Logan
2025-11-10 16:45:20 -06:00
parent 3b72f34747
commit d9fbae1dd4
3 changed files with 32 additions and 4 deletions

View File

@@ -17,5 +17,5 @@ tasks {
} }
dependencies { dependencies {
compileOnly("io.papermc.paper:paper-api:1.21.6-R0.1-SNAPSHOT") compileOnly("io.papermc.paper:paper-api:1.21.10-R0.1-SNAPSHOT")
} }

View File

@@ -2,6 +2,7 @@ package me.lojosho.hibiscuscommons.util.packets;
import it.unimi.dsi.fastutil.ints.IntArrayList; import it.unimi.dsi.fastutil.ints.IntArrayList;
import it.unimi.dsi.fastutil.ints.IntList; import it.unimi.dsi.fastutil.ints.IntList;
import me.lojosho.hibiscuscommons.nms.MinecraftVersion;
import me.lojosho.hibiscuscommons.nms.NMSHandlers; import me.lojosho.hibiscuscommons.nms.NMSHandlers;
import me.lojosho.hibiscuscommons.util.MessagesUtil; import me.lojosho.hibiscuscommons.util.MessagesUtil;
import org.bukkit.GameMode; import org.bukkit.GameMode;
@@ -171,6 +172,26 @@ public class PacketManager {
NMSHandlers.getHandler().getPacketHandler().sendEquipmentSlotUpdate(entityId, equipment, sendTo); NMSHandlers.getHandler().getPacketHandler().sendEquipmentSlotUpdate(entityId, equipment, sendTo);
} }
/**
*
* @param location Location of the fake player.
* @param uuid UUID of the fake player. Should be random.
* @param entityId The entityID that the entity will take on.
* @param sendTo Who should it send the packet to?
*/
public static void sendFakePlayerSpawnPacket(
final @NotNull Location location,
final UUID uuid,
final int entityId,
final @NotNull List<Player> sendTo
) {
sendEntitySpawnPacket(location, entityId, EntityType.PLAYER, uuid, sendTo);
/* Data structure is different for Mannequins
if (NMSHandlers.getVersion().isLower(MinecraftVersion.v1_21_9)) sendEntitySpawnPacket(location, entityId, EntityType.PLAYER, uuid, sendTo);
else sendEntitySpawnPacket(location, entityId, EntityType.MANNEQUIN, uuid, sendTo);
*/
}
private static List<Player> getNearbyPlayers(Location location, int distance) { private static List<Player> getNearbyPlayers(Location location, int distance) {
List<Player> players = new ArrayList<>(); List<Player> players = new ArrayList<>();
for (Entity entity : location.getWorld().getNearbyEntities(location, distance, distance, distance)) { for (Entity entity : location.getWorld().getNearbyEntities(location, distance, distance, distance)) {

View File

@@ -1,10 +1,11 @@
package me.lojosho.hibiscuscommons.nms.v1_21_R6; package me.lojosho.hibiscuscommons.nms.v1_21_R6;
import com.google.common.collect.ImmutableList; import com.google.common.collect.*;
import com.google.gson.JsonArray; import com.google.gson.JsonArray;
import com.google.gson.JsonObject; import com.google.gson.JsonObject;
import com.mojang.authlib.GameProfile; import com.mojang.authlib.GameProfile;
import com.mojang.authlib.properties.Property; import com.mojang.authlib.properties.Property;
import com.mojang.authlib.properties.PropertyMap;
import com.mojang.datafixers.util.Pair; import com.mojang.datafixers.util.Pair;
import com.mojang.serialization.JsonOps; import com.mojang.serialization.JsonOps;
import io.papermc.paper.adventure.PaperAdventure; import io.papermc.paper.adventure.PaperAdventure;
@@ -96,8 +97,14 @@ public class NMSPackets extends NMSCommon implements me.lojosho.hibiscuscommons.
if (name.length() > 15) name = name.substring(0, 15); if (name.length() > 15) name = name.substring(0, 15);
Property property = ((CraftPlayer) skinnedPlayer).getProfile().properties().get("textures").stream().findAny().orElse(null); Property property = ((CraftPlayer) skinnedPlayer).getProfile().properties().get("textures").stream().findAny().orElse(null);
GameProfile profile = new GameProfile(uuid, name); final Multimap<String, Property> multimaps = MultimapBuilder.hashKeys().arrayListValues().build(((CraftPlayer) skinnedPlayer).getProfile().properties());
if (property != null) profile.properties().put("textures", property); if (property != null) {
multimaps.removeAll("textures");
multimaps.put("textures", property);
}
PropertyMap map = new PropertyMap(multimaps);
GameProfile profile = new GameProfile(uuid, name, map);
Component component = AdventureUtils.MINI_MESSAGE.deserialize(name); 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); net.minecraft.network.chat.Component nmsComponent = HibiscusCommonsPlugin.isOnPaper() ? PaperAdventure.asVanilla(component) : net.minecraft.network.chat.Component.literal(name);