Detect items
Is this an NxEquipements item?
if (api.isEquipment(item)) {
// yes
}
Which piece is it?
api.readId(item).ifPresent(id -> {
getLogger().info("set: " + id.setId());
getLogger().info("piece: " + id.pieceKey());
getLogger().info("full: " + id.asString()); // forest_warden:helmet
});
Get the full piece details
api.resolve(item).ifPresent(piece -> {
getLogger().info("Name: " + piece.displayName().orElse(piece.key()));
getLogger().info("Slot: " + piece.slotKey().orElse("?"));
getLogger().info("Model: " + piece.customModelData());
});
Block a specific item from being dropped
@EventHandler
public void onDrop(PlayerDropItemEvent event) {
ItemStack item = event.getItemDrop().getItemStack();
api.readId(item).ifPresent(id -> {
if (id.setId().equals("forest_warden")) {
event.setCancelled(true);
event.getPlayer().sendMessage("You cannot drop that.");
}
});
}
Count how many pieces of a set a player is wearing
public int wornFrom(Player player, String setId) {
int count = 0;
for (ItemStack piece : player.getInventory().getArmorContents()) {
if (piece == null) continue;
if (api.readId(piece).filter(id -> id.setId().equals(setId)).isPresent()) {
count++;
}
}
return count;
}
Reward a full set
if (wornFrom(player, "forest_warden") == 4) {
player.addPotionEffect(new PotionEffect(PotionEffectType.REGENERATION, 100, 0, true, false));
}
NxEquipements gives no set bonus on its own. Wearing four matching pieces does nothing special. If you want a full-set reward, count the pieces yourself — exactly as above.
What EquipmentId gives you
| Call | Returns |
|---|---|
id.setId() | "forest_warden" |
id.pieceKey() | "helmet" |
id.asString() | "forest_warden:helmet" |
EquipmentId.parse(text) | Optional<EquipmentId> from "set:piece" |