Skip to content

Commit

Permalink
replace with materialtags
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Jan 3, 2024
1 parent 4548bd7 commit c693f21
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 113 deletions.
Original file line number Diff line number Diff line change
@@ -1,10 +1,12 @@
package me.moomoo.anarchyexploitfixes.modules.illegals.items.enchantments;

import com.destroystokyo.paper.MaterialTags;
import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
import me.moomoo.anarchyexploitfixes.AnarchyExploitFixes;
import me.moomoo.anarchyexploitfixes.config.Config;
import me.moomoo.anarchyexploitfixes.modules.AnarchyExploitFixesModule;
import me.moomoo.anarchyexploitfixes.utils.LogUtil;
import me.moomoo.anarchyexploitfixes.utils.MaterialUtil;
import org.bukkit.Material;
import org.bukkit.enchantments.Enchantment;
import org.bukkit.entity.HumanEntity;
Expand All @@ -27,8 +29,6 @@
import java.util.Map;
import java.util.logging.Level;

import static me.moomoo.anarchyexploitfixes.utils.MaterialUtil.*;

public class IncompatibleEnchants implements AnarchyExploitFixesModule, Listener {

private final AnarchyExploitFixes plugin;
Expand Down Expand Up @@ -107,38 +107,38 @@ private void handleIncompatibleEnchantsIfPresent(ItemStack item) {
}

private void filterBasedOnType(ItemStack item) {
if (isArmor(item)) {
if (MaterialTags.ARMOR.isTagged(item)) {
filterProtectionEnchants(item);
filterCurses(item);
if (isBoots(item)) {
if (MaterialTags.BOOTS.isTagged(item)) {
filterBoots(item);
}
return;
}
if (isElytra(item)) {
if (MaterialUtil.isElytra(item)) {
filterCurses(item);
return;
}
if (isTool(item)) {
if (MaterialUtil.isTool(item)) {
filterTools(item);
if (isAxe(item)) {
if (MaterialTags.AXES.isTagged(item)) {
filterSharpnessEnchants(item);
}
return;
}
if (isSword(item)) {
if (MaterialTags.SWORDS.isTagged(item)) {
filterSharpnessEnchants(item);
return;
}
if (isBow(item)) {
if (MaterialUtil.isBow(item)) {
filterBow(item);
return;
}
if (isTrident(item)) {
if (MaterialUtil.isTrident(item)) {
filterTrident(item);
return;
}
if (isCrossbow(item)) {
if (MaterialUtil.isCrossbow(item)) {
filterCrossbow(item);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,96 +61,6 @@ public static boolean isShulkerBox(ItemStack item) {
return MaterialTags.SHULKER_BOXES.isTagged(item);
}

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

public static boolean isHelmet(Material material) {
if (material == null) return false;
return MaterialTags.HELMETS.isTagged(material);
}

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

public static boolean isChestplate(Material material) {
if (material == null) return false;
return MaterialTags.CHESTPLATES.isTagged(material);
}

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

public static boolean isLeggings(Material material) {
if (material == null) return false;
return MaterialTags.LEGGINGS.isTagged(material);
}

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

public static boolean isBoots(Material material) {
if (material == null) return false;
return MaterialTags.BOOTS.isTagged(material);
}

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

public static boolean isAxe(Material material) {
if (material == null) return false;
return MaterialTags.AXES.isTagged(material);
}

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

public static boolean isHoe(Material material) {
if (material == null) return false;
return MaterialTags.HOES.isTagged(material);
}

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

public static boolean isPickaxe(Material material) {
if (material == null) return false;
return MaterialTags.PICKAXES.isTagged(material);
}

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

public static boolean isShovel(Material material) {
if (material == null) return false;
return MaterialTags.SHOVELS.isTagged(material);
}

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

public static boolean isSword(Material material) {
if (material == null) return false;
return MaterialTags.SWORDS.isTagged(material);
}

public static boolean isSpawnEgg(ItemStack item) {
if (item == null) return false;
return MaterialTags.SPAWN_EGGS.isTagged(item);
Expand All @@ -161,24 +71,17 @@ public static boolean isSpawnEgg(Material material) {
return MaterialTags.SPAWN_EGGS.isTagged(material);
}

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

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

public static boolean isTool(ItemStack item) {
if (item == null) return false;
return isAxe(item) || isHoe(item) || isPickaxe(item) || isShovel(item);
return isTool(item.getType());
}

public static boolean isTool(Material material) {
if (material == null) return false;
return isAxe(material) || isHoe(material) || isPickaxe(material) || isShovel(material);
return MaterialTags.AXES.isTagged(material)
|| MaterialTags.HOES.isTagged(material)
|| MaterialTags.PICKAXES.isTagged(material)
|| MaterialTags.SHOVELS.isTagged(material);
}

public static boolean isElytra(ItemStack item) {
Expand Down

0 comments on commit c693f21

Please sign in to comment.