From 1e4a8b4fdb5306b67a9db4855ca51c04bf6019bd Mon Sep 17 00:00:00 2001 From: mathias Date: Wed, 24 Jul 2019 19:12:04 +0300 Subject: [PATCH] Attempt to catch broken command blocks --- src/main/java/pw/kaboom/extras/Events.java | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/src/main/java/pw/kaboom/extras/Events.java b/src/main/java/pw/kaboom/extras/Events.java index 8bbfaf5..4f9b769 100644 --- a/src/main/java/pw/kaboom/extras/Events.java +++ b/src/main/java/pw/kaboom/extras/Events.java @@ -21,6 +21,8 @@ import org.bukkit.block.BlockFace; import org.bukkit.block.CreatureSpawner; import org.bukkit.block.data.Levelled; +import org.bukkit.command.BlockCommandSender; + import org.bukkit.entity.EnderDragon; import org.bukkit.entity.Entity; import org.bukkit.entity.EntityType; @@ -633,6 +635,15 @@ class Events implements Listener { final String[] arr = event.getCommand().split(" "); final String command = event.getCommand(); + if (event.getSender() instanceof BlockCommandSender) { + try { + ((BlockCommandSender)event.getSender()).getBlock().getState(); + } catch (Exception exception) { + event.setCancelled(true); + return; + } + } + if (main.consoleCommandBlacklist.contains(arr[0].toLowerCase())) { event.setCancelled(true); } else if (("minecraft:gamerule".equals(arr[0].toLowerCase()) ||