3
0
Mirror von https://github.com/Moulberry/AxiomPaperPlugin.git synchronisiert 2024-11-08 17:40:04 +01:00

Protocol: Limit Views ArrayList to 64

Dieser Commit ist enthalten in:
Moulberry 2023-11-11 18:30:28 +08:00
Ursprung 83b60d3c6f
Commit 54564c188b

Datei anzeigen

@ -1,11 +1,15 @@
package com.moulberry.axiom.packet;
import com.google.common.collect.Lists;
import com.google.common.collect.Maps;
import com.moulberry.axiom.AxiomConstants;
import com.moulberry.axiom.AxiomPaper;
import com.moulberry.axiom.View;
import com.moulberry.axiom.persistence.UUIDDataType;
import io.netty.buffer.Unpooled;
import net.minecraft.core.BlockPos;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.world.level.block.state.BlockState;
import org.bukkit.entity.Player;
import org.bukkit.persistence.PersistentDataContainer;
import org.bukkit.persistence.PersistentDataType;
@ -13,7 +17,9 @@ import org.bukkit.plugin.messaging.PluginMessageListener;
import org.jetbrains.annotations.NotNull;
import java.util.List;
import java.util.Map;
import java.util.UUID;
import java.util.function.IntFunction;
public class SetEditorViewsPacketListener implements PluginMessageListener {
@ -30,7 +36,8 @@ public class SetEditorViewsPacketListener implements PluginMessageListener {
FriendlyByteBuf friendlyByteBuf = new FriendlyByteBuf(Unpooled.wrappedBuffer(message));
UUID uuid = friendlyByteBuf.readUUID();
List<View> views = friendlyByteBuf.readList(View::read);
IntFunction<List<View>> listFunction = FriendlyByteBuf.limitValue(Lists::newArrayListWithCapacity, 64);
List<View> views = friendlyByteBuf.readCollection(listFunction, View::read);
PersistentDataContainer container = player.getPersistentDataContainer();
container.set(AxiomConstants.ACTIVE_VIEW, UUIDDataType.INSTANCE, uuid);