cn.nukkit.level.terra.delegate.PNXItemMeta Maven / Gradle / Ivy
package cn.nukkit.level.terra.delegate;
import cn.nukkit.api.PowerNukkitXOnly;
import cn.nukkit.api.Since;
import cn.nukkit.item.Item;
import com.dfsek.terra.api.inventory.item.Enchantment;
import com.dfsek.terra.api.inventory.item.ItemMeta;
import java.util.HashMap;
import java.util.Map;
@PowerNukkitXOnly
@Since("1.6.0.0-PNX")
public record PNXItemMeta(cn.nukkit.item.Item innerItem) implements ItemMeta {
@Override
public void addEnchantment(Enchantment enchantment, int i) {
final var enc = ((PNXEnchantmentDelegate) enchantment).innerEnchantment();
enc.setLevel(i, false);
innerItem.addEnchantment(enc);
}
@Override
public Map getEnchantments() {
final var map = new HashMap();
for (final var each : innerItem.getEnchantments()) {
map.put(new PNXEnchantmentDelegate(each), each.getLevel());
}
return map;
}
@Override
public Item getHandle() {
return innerItem;
}
}
© 2015 - 2024 Weber Informatics LLC | Privacy Policy