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:
@@ -17,5 +17,5 @@ tasks {
|
||||
}
|
||||
|
||||
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")
|
||||
}
|
||||
@@ -2,6 +2,7 @@ package me.lojosho.hibiscuscommons.util.packets;
|
||||
|
||||
import it.unimi.dsi.fastutil.ints.IntArrayList;
|
||||
import it.unimi.dsi.fastutil.ints.IntList;
|
||||
import me.lojosho.hibiscuscommons.nms.MinecraftVersion;
|
||||
import me.lojosho.hibiscuscommons.nms.NMSHandlers;
|
||||
import me.lojosho.hibiscuscommons.util.MessagesUtil;
|
||||
import org.bukkit.GameMode;
|
||||
@@ -171,6 +172,26 @@ public class PacketManager {
|
||||
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) {
|
||||
List<Player> players = new ArrayList<>();
|
||||
for (Entity entity : location.getWorld().getNearbyEntities(location, distance, distance, distance)) {
|
||||
|
||||
@@ -1,10 +1,11 @@
|
||||
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.JsonObject;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.authlib.properties.Property;
|
||||
import com.mojang.authlib.properties.PropertyMap;
|
||||
import com.mojang.datafixers.util.Pair;
|
||||
import com.mojang.serialization.JsonOps;
|
||||
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);
|
||||
Property property = ((CraftPlayer) skinnedPlayer).getProfile().properties().get("textures").stream().findAny().orElse(null);
|
||||
|
||||
GameProfile profile = new GameProfile(uuid, name);
|
||||
if (property != null) profile.properties().put("textures", property);
|
||||
final Multimap<String, Property> multimaps = MultimapBuilder.hashKeys().arrayListValues().build(((CraftPlayer) skinnedPlayer).getProfile().properties());
|
||||
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);
|
||||
net.minecraft.network.chat.Component nmsComponent = HibiscusCommonsPlugin.isOnPaper() ? PaperAdventure.asVanilla(component) : net.minecraft.network.chat.Component.literal(name);
|
||||
|
||||
Reference in New Issue
Block a user