SteamWar/BauSystem2.0
Archiviert
12
0

Yeet validator
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
zOnlyKroks 2023-10-07 16:05:46 +02:00
Ursprung d9f0ca901d
Commit 9faa238f7d

Datei anzeigen

@ -30,7 +30,6 @@ import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockPlaceEvent; import org.bukkit.event.block.BlockPlaceEvent;
import java.util.regex.Matcher;
import java.util.regex.Pattern; import java.util.regex.Pattern;
@Linked @Linked
@ -46,7 +45,7 @@ public class AutoDustCommand extends SWCommand implements Listener {
} }
@Register() @Register()
public void genericCommand(@Validator Player p) { public void genericCommand(Player p) {
boolean autoDust = Config.getInstance().get(p).getPlainValueOrDefault("autodust", false); boolean autoDust = Config.getInstance().get(p).getPlainValueOrDefault("autodust", false);
Config.getInstance().get(p).put("autodust", !autoDust); 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); Location dustLocation = placedOn.getLocation().add(0,1,0);
Material materialOnDustLocation = dustLocation.getBlock().getType(); 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()); p.getWorld().setBlockData(dustLocation,Material.REDSTONE_WIRE.createBlockData());
} }
public boolean isColoredBlock(Block block) {
Matcher matcher = COLORED_BLOCK_REGEX.matcher(block.getTranslationKey());
return matcher.matches();
}
} }