Commits

md_5 authored 03a8c14939b
SPIGOT-7993: CustomModelDataComponent assignment doesn't work
No tags

src/main/java/org/bukkit/craftbukkit/inventory/components/CraftCustomModelDataComponent.java

Modified
1 1 package org.bukkit.craftbukkit.inventory.components;
2 2
3 3 import java.util.ArrayList;
4 4 import java.util.Collections;
5 5 import java.util.LinkedHashMap;
6 6 import java.util.List;
7 7 import java.util.Map;
8 8 import java.util.Objects;
9 +import java.util.stream.Collectors;
9 10 import net.minecraft.world.item.component.CustomModelData;
10 11 import org.bukkit.Color;
11 12 import org.bukkit.configuration.serialization.SerializableAs;
12 13 import org.bukkit.craftbukkit.inventory.SerializableMeta;
13 14 import org.bukkit.inventory.meta.components.CustomModelDataComponent;
14 15
15 16 @SerializableAs("CustomModelData")
16 17 public final class CraftCustomModelDataComponent implements CustomModelDataComponent {
17 18
18 19 private CustomModelData handle;
60 61 handle = new CustomModelData(new ArrayList<>(floats), handle.flags(), handle.strings(), handle.colors());
61 62 }
62 63
63 64 @Override
64 65 public List<Boolean> getFlags() {
65 66 return Collections.unmodifiableList(handle.flags());
66 67 }
67 68
68 69 @Override
69 70 public void setFlags(List<Boolean> flags) {
70 - handle = new CustomModelData(handle.floats(), new ArrayList<>(handle.flags()), handle.strings(), handle.colors());
71 + handle = new CustomModelData(handle.floats(), new ArrayList<>(flags), handle.strings(), handle.colors());
71 72 }
72 73
73 74 @Override
74 75 public List<String> getStrings() {
75 76 return Collections.unmodifiableList(handle.strings());
76 77 }
77 78
78 79 @Override
79 80 public void setStrings(List<String> strings) {
80 - handle = new CustomModelData(handle.floats(), handle.flags(), new ArrayList<>(handle.strings()), handle.colors());
81 + handle = new CustomModelData(handle.floats(), handle.flags(), new ArrayList<>(strings), handle.colors());
81 82 }
82 83
83 84 @Override
84 85 public List<Color> getColors() {
85 86 return getHandle().colors().stream().map(Color::fromRGB).toList();
86 87 }
87 88
88 89 @Override
89 90 public void setColors(List<Color> colors) {
90 - handle = new CustomModelData(handle.floats(), handle.flags(), handle.strings(), new ArrayList<>(handle.colors()));
91 + handle = new CustomModelData(handle.floats(), handle.flags(), handle.strings(), colors.stream().map(Color::asRGB).collect(Collectors.toList()));
91 92 }
92 93
93 94 @Override
94 95 public boolean equals(Object obj) {
95 96 if (this == obj) {
96 97 return true;
97 98 }
98 99 if (obj == null) {
99 100 return false;
100 101 }

Everything looks good. We'll let you know here if there's anything you should know about.

Add shortcut