mirror of
https://github.com/GeyserMC/Geyser.git
synced 2024-08-14 23:57:35 +00:00
Small set optimization
This commit is contained in:
parent
3ead9e94aa
commit
087322f6cd
1 changed files with 1 additions and 4 deletions
|
@ -66,16 +66,13 @@ public record Enchantment(String identifier,
|
||||||
}
|
}
|
||||||
|
|
||||||
private static Set<EnchantmentComponent> readEnchantmentComponents(NbtMap effects) {
|
private static Set<EnchantmentComponent> readEnchantmentComponents(NbtMap effects) {
|
||||||
if (effects.isEmpty()) {
|
|
||||||
return Collections.emptySet();
|
|
||||||
}
|
|
||||||
Set<EnchantmentComponent> components = new HashSet<>();
|
Set<EnchantmentComponent> components = new HashSet<>();
|
||||||
for (Map.Entry<String, Object> entry : effects.entrySet()) {
|
for (Map.Entry<String, Object> entry : effects.entrySet()) {
|
||||||
switch (entry.getKey()) {
|
switch (entry.getKey()) {
|
||||||
case "minecraft:prevent_armor_change" -> components.add(EnchantmentComponent.PREVENT_ARMOR_CHANGE);
|
case "minecraft:prevent_armor_change" -> components.add(EnchantmentComponent.PREVENT_ARMOR_CHANGE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
return components;
|
return Set.copyOf(components); // Also ensures any empty sets are consolidated
|
||||||
}
|
}
|
||||||
|
|
||||||
private static String readDescription(NbtMap tag) {
|
private static String readDescription(NbtMap tag) {
|
||||||
|
|
Loading…
Reference in a new issue