Use the builder methods instead of fields

This commit is contained in:
TheMode 2021-04-10 00:01:06 +02:00
parent d6e7c9a635
commit 64e70c3b64
2 changed files with 8 additions and 6 deletions

View File

@ -85,18 +85,17 @@ public class CompassMeta extends ItemMeta implements ItemMetaBuilder.Provider<Co
@Override
public void read(@NotNull NBTCompound nbtCompound) {
if (nbtCompound.containsKey("LodestoneTracked")) {
this.lodestoneTracked = nbtCompound.getByte("LodestoneTracked") == 1;
lodestoneTracked(nbtCompound.getByte("LodestoneTracked") == 1);
}
if (nbtCompound.containsKey("LodestoneDimension")) {
this.lodestoneDimension = nbtCompound.getString("LodestoneDimension");
lodestoneDimension(nbtCompound.getString("LodestoneDimension"));
}
if (nbtCompound.containsKey("LodestonePos")) {
final NBTCompound posCompound = nbtCompound.getCompound("LodestonePos");
final int x = posCompound.getInt("X");
final int y = posCompound.getInt("Y");
final int z = posCompound.getInt("Z");
this.lodestonePosition = new Position(x, y, z);
lodestonePosition(new Position(x, y, z));
}
}

View File

@ -11,6 +11,7 @@ import org.jglrxavpok.hephaistos.nbt.NBTCompound;
import org.jglrxavpok.hephaistos.nbt.NBTList;
import org.jglrxavpok.hephaistos.nbt.NBTTypes;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.CopyOnWriteArrayList;
import java.util.function.Supplier;
@ -151,6 +152,7 @@ public class MapMeta extends ItemMeta {
if (compound.containsKey("Decorations")) {
final NBTList<NBTCompound> decorationsList = compound.getList("Decorations");
List<MapDecoration> mapDecorations = new ArrayList<>();
for (NBTCompound decorationCompound : decorationsList) {
final String id = decorationCompound.getString("id");
final byte type = decorationCompound.getAsByte("type");
@ -170,14 +172,15 @@ public class MapMeta extends ItemMeta {
rotation = decorationCompound.getAsDouble("rot");
}
this.decorations.add(new MapDecoration(id, type, x, z, rotation));
mapDecorations.add(new MapDecoration(id, type, x, z, rotation));
}
decorations(mapDecorations);
}
if (compound.containsKey("display")) {
final NBTCompound displayCompound = compound.getCompound("display");
if (displayCompound.containsKey("MapColor")) {
this.mapColor = new Color(displayCompound.getAsInt("MapColor"));
mapColor(new Color(displayCompound.getAsInt("MapColor")));
}
}
}