Skip to content

Commit

Permalink
Fixed a couple bugs in the armor fixer.
Browse files Browse the repository at this point in the history
  • Loading branch information
rayzr522 committed Mar 10, 2018
1 parent 471a085 commit 4e2f3eb
Showing 1 changed file with 10 additions and 1 deletion.
11 changes: 10 additions & 1 deletion src/main/java/me/rayzr522/ocmfixer/ArmorFixListener.java
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ private void cleanInventory(Inventory inv) {
return;
}


ItemStack[] items = inv.getContents();
inv.setContents(cleanItems(items));
}
Expand All @@ -50,6 +51,10 @@ private ItemStack removeAttributes(ItemStack item) {
NbtFactory.NbtCompound root = NbtFactory.fromItemTag(item);
NbtFactory.NbtList attributes = root.getList("AttributeModifiers", false);

if (attributes == null) {
return item;
}

// Dirty check to prevent extra work...
int origSize = attributes.size();

Expand All @@ -64,7 +69,11 @@ private ItemStack removeAttributes(ItemStack item) {

// ... so we know if they removed any elements.
if (attributes.size() != origSize) {
root.put("AttributeModifiers", attributes);
if (attributes.size() == 0) {
root.remove("AttributeModifiers");
} else {
root.put("AttributeModifiers", attributes);
}
NbtFactory.setItemTag(item, root);
}

Expand Down

0 comments on commit 4e2f3eb

Please sign in to comment.