mirror of
https://github.com/Minestom/Minestom.git
synced 2024-09-24 20:42:39 +02:00
Use optimized copies
This commit is contained in:
parent
81aa3dde27
commit
bf77918c96
@ -7,7 +7,6 @@ import net.minestom.server.utils.NBTUtils;
|
||||
import org.jetbrains.annotations.NotNull;
|
||||
import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
import java.util.function.Supplier;
|
||||
@ -18,7 +17,7 @@ public class EnchantedBookMeta extends ItemMeta implements ItemMetaBuilder.Provi
|
||||
|
||||
protected EnchantedBookMeta(@NotNull ItemMetaBuilder metaBuilder, Map<Enchantment, Short> storedEnchantmentMap) {
|
||||
super(metaBuilder);
|
||||
this.storedEnchantmentMap = new HashMap<>(storedEnchantmentMap);
|
||||
this.storedEnchantmentMap = Map.copyOf(storedEnchantmentMap);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -28,7 +27,7 @@ public class EnchantedBookMeta extends ItemMeta implements ItemMetaBuilder.Provi
|
||||
* @return an unmodifiable map containing the item stored enchantments
|
||||
*/
|
||||
public @NotNull Map<Enchantment, Short> getStoredEnchantmentMap() {
|
||||
return Collections.unmodifiableMap(storedEnchantmentMap);
|
||||
return storedEnchantmentMap;
|
||||
}
|
||||
|
||||
public static class Builder extends ItemMetaBuilder {
|
||||
|
@ -9,8 +9,6 @@ import org.jglrxavpok.hephaistos.nbt.NBTCompound;
|
||||
import org.jglrxavpok.hephaistos.nbt.NBTList;
|
||||
import org.jglrxavpok.hephaistos.nbt.NBTType;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.concurrent.CopyOnWriteArrayList;
|
||||
import java.util.function.Supplier;
|
||||
@ -23,12 +21,12 @@ public class FireworkMeta extends ItemMeta implements ItemMetaBuilder.Provider<F
|
||||
protected FireworkMeta(@NotNull ItemMetaBuilder metaBuilder, List<FireworkEffect> effects,
|
||||
byte flightDuration) {
|
||||
super(metaBuilder);
|
||||
this.effects = new ArrayList<>(effects);
|
||||
this.effects = List.copyOf(effects);
|
||||
this.flightDuration = flightDuration;
|
||||
}
|
||||
|
||||
public List<FireworkEffect> getEffects() {
|
||||
return Collections.unmodifiableList(effects);
|
||||
return effects;
|
||||
}
|
||||
|
||||
public byte getFlightDuration() {
|
||||
|
@ -29,7 +29,7 @@ public class PotionMeta extends ItemMeta implements ItemMetaBuilder.Provider<Pot
|
||||
Color color) {
|
||||
super(metaBuilder);
|
||||
this.potionType = potionType;
|
||||
this.customPotionEffects = new ArrayList<>(customPotionEffects);
|
||||
this.customPotionEffects = List.copyOf(customPotionEffects);
|
||||
this.color = color;
|
||||
}
|
||||
|
||||
|
@ -9,7 +9,6 @@ import org.jetbrains.annotations.Nullable;
|
||||
import org.jglrxavpok.hephaistos.nbt.*;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Supplier;
|
||||
@ -26,7 +25,7 @@ public class WritableBookMeta extends ItemMeta implements ItemMetaBuilder.Provid
|
||||
super(metaBuilder);
|
||||
this.author = author;
|
||||
this.title = title;
|
||||
this.pages = new ArrayList<>(pages);
|
||||
this.pages = List.copyOf(pages);
|
||||
}
|
||||
|
||||
public @Nullable String getAuthor() {
|
||||
@ -38,7 +37,7 @@ public class WritableBookMeta extends ItemMeta implements ItemMetaBuilder.Provid
|
||||
}
|
||||
|
||||
public @NotNull List<@NotNull Component> getPages() {
|
||||
return Collections.unmodifiableList(pages);
|
||||
return pages;
|
||||
}
|
||||
|
||||
public static class Builder extends ItemMetaBuilder {
|
||||
|
@ -12,7 +12,10 @@ import org.jetbrains.annotations.NotNull;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.jglrxavpok.hephaistos.nbt.*;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Arrays;
|
||||
import java.util.List;
|
||||
import java.util.Objects;
|
||||
import java.util.function.Supplier;
|
||||
|
||||
public class WrittenBookMeta extends ItemMeta implements ItemMetaBuilder.Provider<WrittenBookMeta.Builder> {
|
||||
@ -32,7 +35,7 @@ public class WrittenBookMeta extends ItemMeta implements ItemMetaBuilder.Provide
|
||||
this.generation = generation;
|
||||
this.author = author;
|
||||
this.title = title;
|
||||
this.pages = new ArrayList<>(pages);
|
||||
this.pages = List.copyOf(pages);
|
||||
}
|
||||
|
||||
public boolean isResolved() {
|
||||
@ -52,7 +55,7 @@ public class WrittenBookMeta extends ItemMeta implements ItemMetaBuilder.Provide
|
||||
}
|
||||
|
||||
public @NotNull List<@NotNull Component> getPages() {
|
||||
return Collections.unmodifiableList(pages);
|
||||
return pages;
|
||||
}
|
||||
|
||||
public enum WrittenBookGeneration {
|
||||
|
Loading…
Reference in New Issue
Block a user