Skip to content

Commit

Permalink
Illegal block check should be illegal item check
Browse files Browse the repository at this point in the history
To fix some bypass
  • Loading branch information
Dreeam-qwq committed Oct 27, 2024
1 parent a88a834 commit b8b9642
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,6 @@
import cn.dreeam.surf.config.Config;
import cn.dreeam.surf.util.ItemUtil;
import cn.dreeam.surf.util.MessageUtil;
import cn.dreeam.surf.util.Util;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
Expand All @@ -16,7 +15,7 @@ public class IllegalBlockCheck implements Listener {
public void onBlockPlace(BlockPlaceEvent event) {
if (!Config.antiIllegalCheckIllegalBlockEnabled) return;

if (ItemUtil.isIllegalBlock(event.getItemInHand())) {
if (ItemUtil.isIllegalItem(event.getItemInHand())) {
Player player = event.getPlayer();

event.setCancelled(true);
Expand Down
8 changes: 4 additions & 4 deletions src/main/java/cn/dreeam/surf/util/ItemUtil.java
Original file line number Diff line number Diff line change
Expand Up @@ -69,8 +69,8 @@ public static boolean isIllegalTotem(ItemStack i) {
return i.getType().equals(XMaterial.TOTEM_OF_UNDYING.parseMaterial()) && i.getAmount() > i.getMaxStackSize();
}

public static boolean isIllegalBlock(ItemStack i) {
return i.getType().isBlock() && Config.antiIllegalIllegalBlockList.contains(i.getType().toString());
public static boolean isIllegalItem(ItemStack i) {
return Config.antiIllegalIllegalBlockList.contains(i.getType().toString());
}

public static boolean isEnchantedBlock(ItemStack i) {
Expand Down Expand Up @@ -168,7 +168,7 @@ public static boolean hasIllegalTag(ItemStack i) {
}

public static boolean isIllegal(ItemStack i) {
return isIllegalBlock(i) || isEnchantedBlock(i) || isIllegalPotion(i) || hasIllegalDurability(i)
return isIllegalItem(i) || isEnchantedBlock(i) || isIllegalPotion(i) || hasIllegalDurability(i)
|| isUnbreakable(i) || hasIllegalEnchants(i) || hasIllegalItemFlag(i) || hasIllegalAttributes(i);
}

Expand Down Expand Up @@ -197,7 +197,7 @@ public static void cleanIllegals(Inventory inventory) {

private static ItemStack cleanIllegals(ItemStack i) {
if (i == null || isAir(i)) return ItemStack.empty();
if (isIllegalBlock(i) || isIllegalPotion(i)) return ItemStack.empty();
if (isIllegalItem(i) || isIllegalPotion(i)) return ItemStack.empty();

if (Config.antiIllegalDeleteIllegalsWhenFoundEnabled && isIllegal(i)) {
return ItemStack.empty();
Expand Down

0 comments on commit b8b9642

Please sign in to comment.