Skip to content

Commit

Permalink
replace method
Browse files Browse the repository at this point in the history
  • Loading branch information
xGinko committed Jan 3, 2024
1 parent 2e18493 commit 4548bd7
Show file tree
Hide file tree
Showing 22 changed files with 69 additions and 32 deletions.
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.moomoo.anarchyexploitfixes.modules.illegals.items;

import com.destroystokyo.paper.MaterialTags;
import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
import me.moomoo.anarchyexploitfixes.AnarchyExploitFixes;
import me.moomoo.anarchyexploitfixes.config.Config;
Expand Down Expand Up @@ -238,7 +239,7 @@ private void onPlayerPickupItem(PlayerAttemptPickupItemEvent event) {
private void onBlockPlace(BlockPlaceEvent event) {
if (removeIllegalShulkers) {
Block placedBlock = event.getBlockPlaced();
if (isShulkerBox(placedBlock.getType()) && shulkerContainsOverstacked((ShulkerBox) placedBlock.getState())) {
if (MaterialTags.SHULKER_BOXES.isTagged(placedBlock) && shulkerContainsOverstacked((ShulkerBox) placedBlock.getState())) {
placedBlock.setType(Material.AIR);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.moomoo.anarchyexploitfixes.modules.illegals.items;

import com.destroystokyo.paper.MaterialTags;
import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
import me.moomoo.anarchyexploitfixes.AnarchyExploitFixes;
import me.moomoo.anarchyexploitfixes.config.Config;
Expand Down Expand Up @@ -271,7 +272,7 @@ private void onPlayerPickupItem(PlayerAttemptPickupItemEvent event) {
private void onBlockPlace(BlockPlaceEvent event) {
if (removeIllegalShulkers) {
Block placedBlock = event.getBlockPlaced();
if (isShulkerBox(placedBlock.getType()) && shulkerContainsUnbreakable((ShulkerBox) placedBlock.getState())) {
if (MaterialTags.SHULKER_BOXES.isTagged(placedBlock) && shulkerContainsUnbreakable((ShulkerBox) placedBlock.getState())) {
placedBlock.setType(Material.AIR);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.moomoo.anarchyexploitfixes.modules.illegals.items.bannedblocks;

import com.destroystokyo.paper.MaterialTags;
import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
import me.moomoo.anarchyexploitfixes.AnarchyExploitFixes;
import me.moomoo.anarchyexploitfixes.config.Config;
Expand Down Expand Up @@ -176,7 +177,7 @@ private void onPlayerPickupItem(PlayerAttemptPickupItemEvent event) {
private void onBlockPlace(BlockPlaceEvent event) {
if (removeIllegalShulkers) {
Block placedBlock = event.getBlockPlaced();
if (isShulkerBox(placedBlock.getType()) && shulkerContainsBannedBlock((ShulkerBox) placedBlock.getState())) {
if (MaterialTags.SHULKER_BOXES.isTagged(placedBlock) && shulkerContainsBannedBlock((ShulkerBox) placedBlock.getState())) {
placedBlock.setType(Material.AIR);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
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;
Expand Down Expand Up @@ -251,7 +252,7 @@ private void onPlayerPickupItem(PlayerAttemptPickupItemEvent event) {
private void onBlockPlace(BlockPlaceEvent event) {
if (removeIllegalShulkers) {
Block placedBlock = event.getBlockPlaced();
if (isShulkerBox(placedBlock.getType()) && shulkerContainsHigherEnchant((ShulkerBox) placedBlock.getState())) {
if (MaterialTags.SHULKER_BOXES.isTagged(placedBlock) && shulkerContainsHigherEnchant((ShulkerBox) placedBlock.getState())) {
placedBlock.setType(Material.AIR);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
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;
Expand Down Expand Up @@ -216,7 +217,7 @@ private void onPlayerPickupItem(PlayerAttemptPickupItemEvent event) {
private void onBlockPlace(BlockPlaceEvent event) {
if (removeIllegalShulkers) {
Block placedBlock = event.getBlockPlaced();
if (isShulkerBox(placedBlock.getType()) && shulkerContainsInapplicableEnchant((ShulkerBox) placedBlock.getState())) {
if (MaterialTags.SHULKER_BOXES.isTagged(placedBlock) && shulkerContainsInapplicableEnchant((ShulkerBox) placedBlock.getState())) {
placedBlock.setType(Material.AIR);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
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;
Expand Down Expand Up @@ -266,9 +267,9 @@ private void onPlayerPickupItem(PlayerAttemptPickupItemEvent event) {

@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
private void onBlockPlace(BlockPlaceEvent event) {
Block placedBlock = event.getBlockPlaced();
if (removeIllegalShulkers) {
if (isShulkerBox(placedBlock.getType()) && shulkerContainsSpecificHigherEnchanted((ShulkerBox) placedBlock.getState())) {
Block placedBlock = event.getBlockPlaced();
if (MaterialTags.SHULKER_BOXES.isTagged(placedBlock) && shulkerContainsSpecificHigherEnchanted((ShulkerBox) placedBlock.getState())) {
placedBlock.setType(Material.AIR);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.moomoo.anarchyexploitfixes.modules.illegals.items.nbt;

import com.destroystokyo.paper.MaterialTags;
import de.tr7zw.changeme.nbtapi.NBTItem;
import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
import me.moomoo.anarchyexploitfixes.AnarchyExploitFixes;
Expand Down Expand Up @@ -250,7 +251,7 @@ private void onPlayerPickupItem(PlayerAttemptPickupItemEvent event) {
private void onBlockPlace(BlockPlaceEvent event) {
if (removeIllegalShulkers) {
Block placedBlock = event.getBlockPlaced();
if (isShulkerBox(placedBlock.getType()) && shulkerContainsIllegalDamageModifier((ShulkerBox) placedBlock.getState())) {
if (MaterialTags.SHULKER_BOXES.isTagged(placedBlock) && shulkerContainsIllegalDamageModifier((ShulkerBox) placedBlock.getState())) {
placedBlock.setType(Material.AIR);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.moomoo.anarchyexploitfixes.modules.illegals.items.nbt;

import com.destroystokyo.paper.MaterialTags;
import de.tr7zw.changeme.nbtapi.NBTItem;
import me.moomoo.anarchyexploitfixes.AnarchyExploitFixes;
import me.moomoo.anarchyexploitfixes.config.Config;
Expand Down Expand Up @@ -152,7 +153,7 @@ && new NBTItem(event.getItemInHand()).getKeys().contains(STORED_ITEMS_TAG)

if (
shouldCheckShulker
&& isShulkerBox(placedBlock.getType())
&& MaterialTags.SHULKER_BOXES.isTagged(placedBlock)
&& shulkerContainsImpossibleStorageItem((ShulkerBox) placedBlock.getState())
) {
placedBlock.setType(Material.AIR);
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.moomoo.anarchyexploitfixes.modules.illegals.items.playerheads;

import com.destroystokyo.paper.MaterialTags;
import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
import me.moomoo.anarchyexploitfixes.AnarchyExploitFixes;
import me.moomoo.anarchyexploitfixes.config.Config;
Expand Down Expand Up @@ -147,7 +148,7 @@ private void onPlayerPickupItem(PlayerAttemptPickupItemEvent event) {
private void onBlockPlace(BlockPlaceEvent event) {
if (!removeIllegalShulkers) return;
Block placedBlock = event.getBlockPlaced();
if (isShulkerBox(placedBlock.getType()) && shulkerContainsIllegalHead((ShulkerBox) placedBlock.getState())) {
if (MaterialTags.SHULKER_BOXES.isTagged(placedBlock) && shulkerContainsIllegalHead((ShulkerBox) placedBlock.getState())) {
placedBlock.setType(Material.AIR);
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package me.moomoo.anarchyexploitfixes.modules.illegals.items.spawneggs;

import com.destroystokyo.paper.MaterialTags;
import me.moomoo.anarchyexploitfixes.AnarchyExploitFixes;
import me.moomoo.anarchyexploitfixes.config.Config;
import me.moomoo.anarchyexploitfixes.modules.AnarchyExploitFixesModule;
Expand Down Expand Up @@ -129,7 +130,7 @@ private void onPlayerPickupItem(PlayerAttemptPickupItemEvent event) {
private void onBlockPlace(BlockPlaceEvent event) {
if (removeIllegalShulkers) {
Block placedBlock = event.getBlockPlaced();
if (isShulkerBox(placedBlock.getType()) && shulkerContainsSpawnEgg((ShulkerBox) placedBlock.getState())) {
if (MaterialTags.SHULKER_BOXES.isTagged(placedBlock) && shulkerContainsSpawnEgg((ShulkerBox) placedBlock.getState())) {
placedBlock.setType(Material.AIR);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -61,11 +61,6 @@ public static boolean isShulkerBox(ItemStack item) {
return MaterialTags.SHULKER_BOXES.isTagged(item);
}

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

public static boolean isHelmet(ItemStack item) {
if (item == null) return false;
return MaterialTags.HELMETS.isTagged(item);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
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.block.Block;
import org.bukkit.block.ShulkerBox;
Expand Down Expand Up @@ -206,7 +207,10 @@ private void onPlayerPickupItem(PlayerAttemptPickupItemEvent event) {
private void onBlockPlace(BlockPlaceEvent event) {
if (removeIllegalShulkers) {
Block placedBlock = event.getBlockPlaced();
if (isShulkerBox(placedBlock.getType()) && shulkerContainsOverstacked((ShulkerBox) placedBlock.getState())) {
if (
MaterialUtil.SHULKER_BOXES.contains(placedBlock.getType())
&& shulkerContainsOverstacked((ShulkerBox) placedBlock.getState())
) {
placedBlock.setType(Material.AIR);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
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.block.Block;
import org.bukkit.block.ShulkerBox;
Expand Down Expand Up @@ -236,7 +237,10 @@ private void onPlayerPickupItem(PlayerAttemptPickupItemEvent event) {
private void onBlockPlace(BlockPlaceEvent event) {
if (removeIllegalShulkers) {
Block placedBlock = event.getBlockPlaced();
if (isShulkerBox(placedBlock.getType()) && shulkerContainsUnbreakable((ShulkerBox) placedBlock.getState())) {
if (
MaterialUtil.SHULKER_BOXES.contains(placedBlock.getType())
&& shulkerContainsUnbreakable((ShulkerBox) placedBlock.getState())
) {
placedBlock.setType(Material.AIR);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
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.block.Block;
import org.bukkit.block.ShulkerBox;
Expand Down Expand Up @@ -167,7 +168,10 @@ private void onPlayerPickupItem(PlayerAttemptPickupItemEvent event) {
private void onBlockPlace(BlockPlaceEvent event) {
if (removeIllegalShulkers) {
Block placedBlock = event.getBlockPlaced();
if (isShulkerBox(placedBlock.getType()) && shulkerContainsBannedBlock((ShulkerBox) placedBlock.getState())) {
if (
MaterialUtil.SHULKER_BOXES.contains(placedBlock.getType())
&& shulkerContainsBannedBlock((ShulkerBox) placedBlock.getState())
) {
placedBlock.setType(air);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
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.block.Block;
import org.bukkit.block.ShulkerBox;
Expand Down Expand Up @@ -221,7 +222,10 @@ private void onPlayerPickupItem(PlayerAttemptPickupItemEvent event) {
private void onBlockPlace(BlockPlaceEvent event) {
if (removeIllegalShulkers) {
Block placedBlock = event.getBlockPlaced();
if (isShulkerBox(placedBlock.getType()) && shulkerContainsHigherEnchant((ShulkerBox) placedBlock.getState())) {
if (
MaterialUtil.SHULKER_BOXES.contains(placedBlock.getType())
&& shulkerContainsHigherEnchant((ShulkerBox) placedBlock.getState())
) {
placedBlock.setType(air);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
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.block.Block;
import org.bukkit.block.ShulkerBox;
Expand Down Expand Up @@ -215,7 +216,10 @@ private void onPlayerPickupItem(PlayerAttemptPickupItemEvent event) {
private void onBlockPlace(BlockPlaceEvent event) {
if (removeIllegalShulkers) {
Block placedBlock = event.getBlockPlaced();
if (isShulkerBox(placedBlock.getType()) && shulkerContainsInapplicableEnchant((ShulkerBox) placedBlock.getState())) {
if (
MaterialUtil.SHULKER_BOXES.contains(placedBlock.getType())
&& shulkerContainsInapplicableEnchant((ShulkerBox) placedBlock.getState())
) {
placedBlock.setType(air);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
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.block.Block;
import org.bukkit.block.ShulkerBox;
Expand Down Expand Up @@ -232,9 +233,12 @@ private void onPlayerPickupItem(PlayerAttemptPickupItemEvent event) {

@EventHandler(priority = EventPriority.NORMAL, ignoreCancelled = true)
private void onBlockPlace(BlockPlaceEvent event) {
Block placedBlock = event.getBlockPlaced();
if (removeIllegalShulkers) {
if (isShulkerBox(placedBlock.getType()) && shulkerContainsSpecificHigherEnchanted((ShulkerBox) placedBlock.getState())) {
Block placedBlock = event.getBlockPlaced();
if (
MaterialUtil.SHULKER_BOXES.contains(placedBlock.getType())
&& shulkerContainsSpecificHigherEnchanted((ShulkerBox) placedBlock.getState())
) {
placedBlock.setType(air);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
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.block.Block;
import org.bukkit.block.ShulkerBox;
Expand Down Expand Up @@ -216,7 +217,10 @@ private void onPlayerPickupItem(PlayerAttemptPickupItemEvent event) {
private void onBlockPlace(BlockPlaceEvent event) {
if (removeIllegalShulkers) {
Block placedBlock = event.getBlockPlaced();
if (isShulkerBox(placedBlock.getType()) && shulkerContainsIllegalDamageModifier((ShulkerBox) placedBlock.getState())) {
if (
MaterialUtil.SHULKER_BOXES.contains(placedBlock.getType())
&& shulkerContainsIllegalDamageModifier((ShulkerBox) placedBlock.getState())
) {
placedBlock.setType(air);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
import me.moomoo.anarchyexploitfixes.AnarchyExploitFixes;
import me.moomoo.anarchyexploitfixes.config.Config;
import me.moomoo.anarchyexploitfixes.modules.AnarchyExploitFixesModule;
import me.moomoo.anarchyexploitfixes.utils.MaterialUtil;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.ShulkerBox;
Expand Down Expand Up @@ -144,7 +145,7 @@ private void onBlockPlace(BlockPlaceEvent event) {
Block placedBlock = event.getBlockPlaced();
if (
removeIllegalShulkers
&& isShulkerBox(placedBlock.getType())
&& MaterialUtil.SHULKER_BOXES.contains(placedBlock.getType())
&& shulkerContainsImpossibleStorageItem((ShulkerBox) placedBlock.getState())
) {
placedBlock.setType(air);
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import me.moomoo.anarchyexploitfixes.AnarchyExploitFixes;
import me.moomoo.anarchyexploitfixes.config.Config;
import me.moomoo.anarchyexploitfixes.modules.AnarchyExploitFixesModule;
import me.moomoo.anarchyexploitfixes.utils.MaterialUtil;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.ShulkerBox;
Expand Down Expand Up @@ -146,7 +147,10 @@ private void onPlayerPickupItem(PlayerAttemptPickupItemEvent event) {
private void onBlockPlace(BlockPlaceEvent event) {
if (removeIllegalShulkers) {
Block placedBlock = event.getBlockPlaced();
if (isShulkerBox(placedBlock.getType()) && shulkerContainsIllegalHead((ShulkerBox) placedBlock.getState())) {
if (
MaterialUtil.SHULKER_BOXES.contains(placedBlock.getType())
&& shulkerContainsIllegalHead((ShulkerBox) placedBlock.getState())
) {
placedBlock.setType(air);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
import me.moomoo.anarchyexploitfixes.AnarchyExploitFixes;
import me.moomoo.anarchyexploitfixes.config.Config;
import me.moomoo.anarchyexploitfixes.modules.AnarchyExploitFixesModule;
import me.moomoo.anarchyexploitfixes.utils.MaterialUtil;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.block.ShulkerBox;
Expand Down Expand Up @@ -125,7 +126,10 @@ private void onPlayerPickupItem(PlayerAttemptPickupItemEvent event) {
private void onBlockPlace(BlockPlaceEvent event) {
if (removeIllegalShulkers) {
Block placedBlock = event.getBlockPlaced();
if (isShulkerBox(placedBlock.getType()) && shulkerContainsSpawnEgg((ShulkerBox) placedBlock.getState())) {
if (
MaterialUtil.SHULKER_BOXES.contains(placedBlock.getType())
&& shulkerContainsSpawnEgg((ShulkerBox) placedBlock.getState())
) {
placedBlock.setType(air);
}
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,6 @@ public static boolean isShulkerBox(ItemStack item) {
return SHULKER_BOXES.contains(item.getType());
}

public static boolean isShulkerBox(Material material) {
if (material == null) return false;
return SHULKER_BOXES.contains(material);
}

public static final HashSet<Material> HELMETS = Stream.of(
XMaterial.NETHERITE_HELMET,
XMaterial.DIAMOND_HELMET,
Expand Down

0 comments on commit 4548bd7

Please sign in to comment.