Attempt to catch broken command blocks

This commit is contained in:
mathias 2019-07-24 19:12:04 +03:00
parent 3a0946054d
commit 1e4a8b4fdb

View file

@ -21,6 +21,8 @@ import org.bukkit.block.BlockFace;
import org.bukkit.block.CreatureSpawner; import org.bukkit.block.CreatureSpawner;
import org.bukkit.block.data.Levelled; import org.bukkit.block.data.Levelled;
import org.bukkit.command.BlockCommandSender;
import org.bukkit.entity.EnderDragon; import org.bukkit.entity.EnderDragon;
import org.bukkit.entity.Entity; import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType; import org.bukkit.entity.EntityType;
@ -633,6 +635,15 @@ class Events implements Listener {
final String[] arr = event.getCommand().split(" "); final String[] arr = event.getCommand().split(" ");
final String command = event.getCommand(); 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())) { if (main.consoleCommandBlacklist.contains(arr[0].toLowerCase())) {
event.setCancelled(true); event.setCancelled(true);
} else if (("minecraft:gamerule".equals(arr[0].toLowerCase()) || } else if (("minecraft:gamerule".equals(arr[0].toLowerCase()) ||