mirror of
https://github.com/Minestom/Minestom.git
synced 2024-12-27 03:27:56 +01:00
Make ItemAttribute record
This commit is contained in:
parent
6aaf5aa0ce
commit
dd27edee50
@ -125,12 +125,12 @@ public abstract class ItemMetaBuilder implements TagWritable {
|
|||||||
handleCollection(attributes, "AttributeModifiers", () -> NBT.List(NBTType.TAG_Compound,
|
handleCollection(attributes, "AttributeModifiers", () -> NBT.List(NBTType.TAG_Compound,
|
||||||
attributes.stream()
|
attributes.stream()
|
||||||
.map(itemAttribute -> NBT.Compound(Map.of(
|
.map(itemAttribute -> NBT.Compound(Map.of(
|
||||||
"UUID", NBT.IntArray(Utils.uuidToIntArray(itemAttribute.getUuid())),
|
"UUID", NBT.IntArray(Utils.uuidToIntArray(itemAttribute.uuid())),
|
||||||
"Amount", NBT.Double(itemAttribute.getValue()),
|
"Amount", NBT.Double(itemAttribute.amount()),
|
||||||
"Slot", NBT.String(itemAttribute.getSlot().name().toLowerCase()),
|
"Slot", NBT.String(itemAttribute.slot().name().toLowerCase()),
|
||||||
"AttributeName", NBT.String(itemAttribute.getAttribute().key()),
|
"AttributeName", NBT.String(itemAttribute.attribute().key()),
|
||||||
"Operation", NBT.Int(itemAttribute.getOperation().getId()),
|
"Operation", NBT.Int(itemAttribute.operation().getId()),
|
||||||
"Name", NBT.String(itemAttribute.getInternalName()))))
|
"Name", NBT.String(itemAttribute.name()))))
|
||||||
.toList()
|
.toList()
|
||||||
));
|
));
|
||||||
return this;
|
return this;
|
||||||
|
@ -2,48 +2,13 @@ package net.minestom.server.item.attribute;
|
|||||||
|
|
||||||
import net.minestom.server.attribute.Attribute;
|
import net.minestom.server.attribute.Attribute;
|
||||||
import net.minestom.server.attribute.AttributeOperation;
|
import net.minestom.server.attribute.AttributeOperation;
|
||||||
|
import org.jetbrains.annotations.NotNull;
|
||||||
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public class ItemAttribute {
|
public record ItemAttribute(@NotNull UUID uuid,
|
||||||
|
@NotNull String name,
|
||||||
private final UUID uuid;
|
@NotNull Attribute attribute,
|
||||||
private final String internalName;
|
@NotNull AttributeOperation operation, double amount,
|
||||||
private final Attribute attribute;
|
@NotNull AttributeSlot slot) {
|
||||||
private final AttributeOperation operation;
|
|
||||||
private final double value;
|
|
||||||
private final AttributeSlot slot;
|
|
||||||
|
|
||||||
public ItemAttribute(UUID uuid, String internalName, Attribute attribute, AttributeOperation operation, double value, AttributeSlot slot) {
|
|
||||||
this.uuid = uuid;
|
|
||||||
this.internalName = internalName;
|
|
||||||
this.attribute = attribute;
|
|
||||||
this.operation = operation;
|
|
||||||
this.value = value;
|
|
||||||
this.slot = slot;
|
|
||||||
}
|
|
||||||
|
|
||||||
public UUID getUuid() {
|
|
||||||
return uuid;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getInternalName() {
|
|
||||||
return internalName;
|
|
||||||
}
|
|
||||||
|
|
||||||
public Attribute getAttribute() {
|
|
||||||
return attribute;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AttributeOperation getOperation() {
|
|
||||||
return operation;
|
|
||||||
}
|
|
||||||
|
|
||||||
public double getValue() {
|
|
||||||
return value;
|
|
||||||
}
|
|
||||||
|
|
||||||
public AttributeSlot getSlot() {
|
|
||||||
return slot;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user