Skip to content

Commit

Permalink
replace what we can with MaterialTags
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Jan 3, 2024
1 parent d412559 commit 63c5ba1
Showing 1 changed file with 22 additions and 134 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -36,214 +36,102 @@ public static boolean isBook(Material material) {

public static boolean isShulkerBox(ItemStack item) {
if (item == null) return false;
return isShulkerBox(item.getType());
return MaterialTags.SHULKER_BOXES.isTagged(item);
}

public static boolean isShulkerBox(Material material) {
if (material == null) return false;
return switch (material) {
case
SHULKER_BOX,
BLACK_SHULKER_BOX,
BLUE_SHULKER_BOX,
BROWN_SHULKER_BOX,
CYAN_SHULKER_BOX,
GRAY_SHULKER_BOX,
GREEN_SHULKER_BOX,
LIGHT_BLUE_SHULKER_BOX,
LIGHT_GRAY_SHULKER_BOX,
LIME_SHULKER_BOX,
MAGENTA_SHULKER_BOX,
ORANGE_SHULKER_BOX,
PINK_SHULKER_BOX,
PURPLE_SHULKER_BOX,
RED_SHULKER_BOX,
WHITE_SHULKER_BOX,
YELLOW_SHULKER_BOX
-> true;
default -> false;
};
return MaterialTags.SHULKER_BOXES.isTagged(material);
}

public static boolean isHelmet(ItemStack item) {
if (item == null) return false;
return isHelmet(item.getType());
return MaterialTags.HELMETS.isTagged(item);
}

public static boolean isHelmet(Material material) {
if (material == null) return false;
return switch (material) {
case
CHAINMAIL_HELMET,
DIAMOND_HELMET,
GOLDEN_HELMET,
IRON_HELMET,
LEATHER_HELMET,
NETHERITE_HELMET,
TURTLE_HELMET
-> true;
default -> false;
};
return MaterialTags.HELMETS.isTagged(material);
}

public static boolean isChestplate(ItemStack item) {
if (item == null) return false;
return isChestplate(item.getType());
return MaterialTags.CHESTPLATES.isTagged(item);
}

public static boolean isChestplate(Material material) {
if (material == null) return false;
return switch (material) {
case
CHAINMAIL_CHESTPLATE,
DIAMOND_CHESTPLATE,
GOLDEN_CHESTPLATE,
IRON_CHESTPLATE,
LEATHER_CHESTPLATE,
NETHERITE_CHESTPLATE
-> true;
default -> false;
};
return MaterialTags.CHESTPLATES.isTagged(material);
}

public static boolean isLeggings(ItemStack item) {
if (item == null) return false;
return isLeggings(item.getType());
return MaterialTags.LEGGINGS.isTagged(item);
}

public static boolean isLeggings(Material material) {
if (material == null) return false;
return switch (material) {
case
CHAINMAIL_LEGGINGS,
DIAMOND_LEGGINGS,
GOLDEN_LEGGINGS,
IRON_LEGGINGS,
LEATHER_LEGGINGS,
NETHERITE_LEGGINGS
-> true;
default -> false;
};
return MaterialTags.LEGGINGS.isTagged(material);
}

public static boolean isBoots(ItemStack item) {
if (item == null) return false;
return isBoots(item.getType());
return MaterialTags.BOOTS.isTagged(item);
}

public static boolean isBoots(Material material) {
if (material == null) return false;
return switch (material) {
case
CHAINMAIL_BOOTS,
DIAMOND_BOOTS,
GOLDEN_BOOTS,
IRON_BOOTS,
LEATHER_BOOTS,
NETHERITE_BOOTS
-> true;
default -> false;
};
return MaterialTags.BOOTS.isTagged(material);
}

public static boolean isAxe(ItemStack item) {
if (item == null) return false;
return isAxe(item.getType());
return MaterialTags.AXES.isTagged(item);
}

public static boolean isAxe(Material material) {
if (material == null) return false;
return switch (material) {
case
NETHERITE_AXE,
DIAMOND_AXE,
GOLDEN_AXE,
IRON_AXE,
STONE_AXE,
WOODEN_AXE
-> true;
default -> false;
};
return MaterialTags.AXES.isTagged(material);
}

public static boolean isHoe(ItemStack item) {
if (item == null) return false;
return isHoe(item.getType());
return MaterialTags.HOES.isTagged(item);
}

public static boolean isHoe(Material material) {
if (material == null) return false;
return switch (material) {
case
NETHERITE_HOE,
DIAMOND_HOE,
GOLDEN_HOE,
IRON_HOE,
STONE_HOE,
WOODEN_HOE
-> true;
default -> false;
};
return MaterialTags.HOES.isTagged(material);
}

public static boolean isPickaxe(ItemStack item) {
if (item == null) return false;
return isPickaxe(item.getType());
return MaterialTags.PICKAXES.isTagged(item);
}

public static boolean isPickaxe(Material material) {
if (material == null) return false;
return switch (material) {
case
NETHERITE_PICKAXE,
DIAMOND_PICKAXE,
GOLDEN_PICKAXE,
IRON_PICKAXE,
STONE_PICKAXE,
WOODEN_PICKAXE
-> true;
default -> false;
};
return MaterialTags.PICKAXES.isTagged(material);
}

public static boolean isShovel(ItemStack item) {
if (item == null) return false;
return isShovel(item.getType());
return MaterialTags.SHOVELS.isTagged(item);
}

public static boolean isShovel(Material material) {
if (material == null) return false;
return switch (material) {
case
NETHERITE_SHOVEL,
DIAMOND_SHOVEL,
GOLDEN_SHOVEL,
IRON_SHOVEL,
STONE_SHOVEL,
WOODEN_SHOVEL
-> true;
default -> false;
};
return MaterialTags.SHOVELS.isTagged(material);
}

public static boolean isSword(ItemStack item) {
if (item == null) return false;
return isSword(item.getType());
return MaterialTags.SWORDS.isTagged(item);
}

public static boolean isSword(Material material) {
if (material == null) return false;
return switch (material) {
case
NETHERITE_SWORD,
DIAMOND_SWORD,
GOLDEN_SWORD,
IRON_SWORD,
STONE_SWORD,
WOODEN_SWORD
-> true;
default -> false;
};
return MaterialTags.SWORDS.isTagged(material);
}

public static boolean isSpawnEgg(ItemStack item) {
Expand All @@ -258,12 +146,12 @@ public static boolean isSpawnEgg(Material material) {

public static boolean isArmor(ItemStack item) {
if (item == null) return false;
return isHelmet(item) || isChestplate(item) || isLeggings(item) || isBoots(item);
return MaterialTags.ARMOR.isTagged(item);
}

public static boolean isArmor(Material material) {
if (material == null) return false;
return isHelmet(material) || isChestplate(material) || isLeggings(material) || isBoots(material);
return MaterialTags.ARMOR.isTagged(material);
}

public static boolean isTool(ItemStack item) {
Expand Down

0 comments on commit 63c5ba1

Please sign in to comment.