Skip to content

Commit

Permalink
Fix unused node detection not working on kits (#1372)
Browse files Browse the repository at this point in the history
Signed-off-by: Pablo Herrera <[email protected]>
  • Loading branch information
Pablete1234 authored Jul 27, 2024
1 parent a2d5767 commit 726c9ff
Showing 1 changed file with 11 additions and 17 deletions.
28 changes: 11 additions & 17 deletions core/src/main/java/tc/oc/pgm/kits/KitParser.java
Original file line number Diff line number Diff line change
Expand Up @@ -65,11 +65,14 @@
import tc.oc.pgm.util.material.ItemMaterialData;
import tc.oc.pgm.util.material.MaterialData;
import tc.oc.pgm.util.material.Materials;
import tc.oc.pgm.util.xml.InheritingElement;
import tc.oc.pgm.util.xml.InvalidXMLException;
import tc.oc.pgm.util.xml.Node;
import tc.oc.pgm.util.xml.XMLUtils;

public abstract class KitParser {
private static final Set<String> ITEM_TYPES = Set.of("item", "book", "head", "firework");

protected final MapFactory factory;
protected final Set<Kit> kits = new HashSet<>();

Expand Down Expand Up @@ -244,7 +247,7 @@ public ItemKit parseItemKit(Element el) throws InvalidXMLException {
Map<Slot, ItemStack> slotItems = Maps.newHashMap();
List<ItemStack> freeItems = new ArrayList<>();

for (Element itemEl : el.getChildren()) {
for (Element itemEl : ((InheritingElement) el).getChildren(ITEM_TYPES)) {
ItemStack item = this.parseItemStack(itemEl);

if (item != null) {
Expand All @@ -271,22 +274,13 @@ public ItemKit parseItemKit(Element el) throws InvalidXMLException {
}

public @Nullable ItemStack parseItemStack(Element el) throws InvalidXMLException {
switch (el.getName()) {
case "item":
return parseItem(el, true);

case "book":
return parseBook(el);

case "head":
return parseHead(el);

case "firework":
return parseFirework(el);

default:
return null;
}
return switch (el.getName()) {
case "item" -> parseItem(el, true);
case "book" -> parseBook(el);
case "head" -> parseHead(el);
case "firework" -> parseFirework(el);
default -> null;
};
}

public Slot parseInventorySlot(Node node) throws InvalidXMLException {
Expand Down

0 comments on commit 726c9ff

Please sign in to comment.