Commits
md_5 authored 03a8c14939b
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 | "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 | |
64 65 | public List<Boolean> getFlags() { |
65 66 | return Collections.unmodifiableList(handle.flags()); |
66 67 | } |
67 68 | |
68 69 | |
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 | |
74 75 | public List<String> getStrings() { |
75 76 | return Collections.unmodifiableList(handle.strings()); |
76 77 | } |
77 78 | |
78 79 | |
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 | |
84 85 | public List<Color> getColors() { |
85 86 | return getHandle().colors().stream().map(Color::fromRGB).toList(); |
86 87 | } |
87 88 | |
88 89 | |
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 | |
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 | } |