mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-28 03:57:50 +01:00
Use collection copies
This commit is contained in:
parent
ba8667a361
commit
089a90df52
@ -20,7 +20,7 @@ final class BlockImpl implements Block {
|
|||||||
private static final ObjectArray<Block> BLOCK_STATE_MAP = new ObjectArray<>();
|
private static final ObjectArray<Block> BLOCK_STATE_MAP = new ObjectArray<>();
|
||||||
private static final Registry.Container<Block> CONTAINER = new Registry.Container<>(Registry.Resource.BLOCKS,
|
private static final Registry.Container<Block> CONTAINER = new Registry.Container<>(Registry.Resource.BLOCKS,
|
||||||
(container, namespace, object) -> {
|
(container, namespace, object) -> {
|
||||||
final var stateObject = (Map<String, Object>) object.remove("states");
|
final var stateObject = (Map<String, Object>) object.get("states");
|
||||||
// Loop each state
|
// Loop each state
|
||||||
var propertyEntry = new HashMap<Map<String, String>, Block>();
|
var propertyEntry = new HashMap<Map<String, String>, Block>();
|
||||||
var unmodifiableEntries = Collections.unmodifiableMap(propertyEntry);
|
var unmodifiableEntries = Collections.unmodifiableMap(propertyEntry);
|
||||||
|
@ -537,15 +537,14 @@ public final class Registry {
|
|||||||
reader.beginArray();
|
reader.beginArray();
|
||||||
while (reader.hasNext()) list.add(readObject(reader));
|
while (reader.hasNext()) list.add(readObject(reader));
|
||||||
reader.endArray();
|
reader.endArray();
|
||||||
list.trimToSize();
|
yield List.copyOf(list);
|
||||||
yield list;
|
|
||||||
}
|
}
|
||||||
case BEGIN_OBJECT -> {
|
case BEGIN_OBJECT -> {
|
||||||
Map<String, Object> map = new HashMap<>();
|
Map<String, Object> map = new HashMap<>();
|
||||||
reader.beginObject();
|
reader.beginObject();
|
||||||
while (reader.hasNext()) map.put(reader.nextName().intern(), readObject(reader));
|
while (reader.hasNext()) map.put(reader.nextName().intern(), readObject(reader));
|
||||||
reader.endObject();
|
reader.endObject();
|
||||||
yield map;
|
yield Map.copyOf(map);
|
||||||
}
|
}
|
||||||
case STRING -> reader.nextString().intern();
|
case STRING -> reader.nextString().intern();
|
||||||
case NUMBER -> ToNumberPolicy.LONG_OR_DOUBLE.readNumber(reader);
|
case NUMBER -> ToNumberPolicy.LONG_OR_DOUBLE.readNumber(reader);
|
||||||
|
Loading…
Reference in New Issue
Block a user