From 9faa238f7d5b377bf73570169c3edd13115824ae Mon Sep 17 00:00:00 2001 From: zOnlyKroks Date: Sat, 7 Oct 2023 16:05:46 +0200 Subject: [PATCH] Yeet validator --- .../bausystem/features/autodust/AutoDustCommand.java | 11 +++-------- 1 file changed, 3 insertions(+), 8 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/autodust/AutoDustCommand.java b/BauSystem_Main/src/de/steamwar/bausystem/features/autodust/AutoDustCommand.java index b66892dc..854ee495 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/autodust/AutoDustCommand.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/autodust/AutoDustCommand.java @@ -30,7 +30,6 @@ import org.bukkit.event.EventHandler; import org.bukkit.event.Listener; import org.bukkit.event.block.BlockPlaceEvent; -import java.util.regex.Matcher; import java.util.regex.Pattern; @Linked @@ -46,7 +45,7 @@ public class AutoDustCommand extends SWCommand implements Listener { } @Register() - public void genericCommand(@Validator Player p) { + public void genericCommand(Player p) { boolean autoDust = Config.getInstance().get(p).getPlainValueOrDefault("autodust", false); Config.getInstance().get(p).put("autodust", !autoDust); } @@ -61,13 +60,9 @@ public class AutoDustCommand extends SWCommand implements Listener { Location dustLocation = placedOn.getLocation().add(0,1,0); Material materialOnDustLocation = dustLocation.getBlock().getType(); - if(materialOnDustLocation.equals(Material.AIR) || !isColoredBlock(placedOn)) return; + if(materialOnDustLocation.equals(Material.AIR) || + COLORED_BLOCK_REGEX.matcher(placedOn.getTranslationKey()).matches()) return; p.getWorld().setBlockData(dustLocation,Material.REDSTONE_WIRE.createBlockData()); } - - public boolean isColoredBlock(Block block) { - Matcher matcher = COLORED_BLOCK_REGEX.matcher(block.getTranslationKey()); - return matcher.matches(); - } }