Allow command blocks to run once

This commit is contained in:
mathiascode 2020-02-27 00:42:17 +02:00
parent 78f105fd2b
commit ea854450ad
2 changed files with 5 additions and 379 deletions

View file

@ -30,376 +30,6 @@ public final class Main extends JavaPlugin {
@Override
public void onLoad() {
/* Fill lists */
Collections.addAll(
ServerCommand.consoleCommandBlacklist,
"bukkit:about",
"bukkit:ver",
"bukkit:version",
"about",
"icanhasbukkit",
"ver",
"version",
"essentials:action",
"essentials:adventure",
"essentials:adventuremode",
"essentials:afk",
"essentials:amsg",
"essentials:away",
"essentials:ban",
"essentials:banip",
"essentials:bc",
"essentials:bcast",
"essentials:bcastw",
"essentials:bcw",
"essentials:broadcast",
"essentials:broadcastworld",
"essentials:ci",
"essentials:clean",
"essentials:clear",
"essentials:clearinvent",
"essentials:clearinventory",
"essentials:creative",
"essentials:creativemode",
"essentials:describe",
"essentials:feed",
"essentials:gamemode",
"essentials:gm",
"essentials:gma",
"essentials:gmc",
"essentials:gms",
"essentials:gmsp",
"essentials:gmt",
"essentials:heal",
"essentials:helpop",
"essentials:jail",
"essentials:kick",
"essentials:kill",
"essentials:m",
"essentials:mail",
"essentials:me",
"essentials:memo",
"essentials:mute",
"essentials:msg",
"essentials:nuke",
"essentials:pardon",
"essentials:pardonip",
"essentials:pm",
"essentials:shoutworld",
"essentials:silence",
"essentials:sp",
"essentials:spec",
"essentials:spectator",
"essentials:sudo",
"essentials:survival",
"essentials:survivalmode",
"essentials:t",
"essentials:tele",
"essentials:teleport",
"essentials:tell",
"essentials:tempban",
"essentials:tjail",
"essentials:togglejail",
"essentials:tp",
"essentials:tp2p",
"essentials:tpaall",
"essentials:tpall",
"essentials:tppos",
"essentials:tptoggle",
"essentials:unban",
"essentials:unbanip",
"essentials:v",
"essentials:vanish",
"essentials:w",
"essentials:warp",
"essentials:warps",
"essentials:whisper",
"essentials:world",
"action",
"adventure",
"adventuremode",
"afk",
"amsg",
"away",
"ban",
"banip",
"bc",
"bcast",
"bcastw",
"bcw",
"broadcast",
"broadcastworld",
"ci",
"clean",
"clearinvent",
"clearinventory",
"creative",
"creativemode",
"describe",
"feed",
"gm",
"gma",
"gmc",
"gms",
"gmsp",
"gmt",
"heal",
"helpop",
"jail",
"kill",
"m",
"mail",
"memo",
"mute",
"nuke",
"pardon",
"pardonip",
"pm",
"shoutworld",
"silence",
"sp",
"spec",
"spectator",
"sudo",
"survival",
"survivalmode",
"t",
"tele",
"teleport",
"tempban",
"tjail",
"togglejail",
"tp2p",
"tpaall",
"tpall",
"tppos",
"tptoggle",
"unban",
"unbanip",
"v",
"vanish",
"w",
"warp",
"warps",
"whisper",
"world",
"essentials:eaction",
"essentials:eadventure",
"essentials:eadventuremode",
"essentials:eafk",
"essentials:eat",
"essentials:eamsg",
"essentials:eaway",
"essentials:eban",
"essentials:ebanip",
"essentials:ebc",
"essentials:ebcast",
"essentials:ebcastw",
"essentials:ebcw",
"essentials:ebroadcast",
"essentials:ebroadcastworld",
"essentials:eci",
"essentials:eco",
"essentials:economy",
"essentials:eclean",
"essentials:eclear",
"essentials:eclearinvent",
"essentials:eclearinventory",
"essentials:ecreative",
"essentials:ecreativemode",
"essentials:edescribe",
"essentials:eeat",
"essentials:eeco",
"essentials:eeconomy",
"essentials:eemail",
"essentials:efeed",
"essentials:egamemode",
"essentials:egm",
"essentials:egma",
"essentials:egmc",
"essentials:egms",
"essentials:egmsp",
"essentials:egmt",
"essentials:eheal",
"essentials:ehelpop",
"essentials:ejail",
"essentials:ekick",
"essentials:ekill",
"essentials:email",
"essentials:eme",
"essentials:ememo",
"essentials:emute",
"essentials:emsg",
"essentials:enuke",
"essentials:epardon",
"essentials:epardonip",
"essentials:epm",
"essentials:eshoutworld",
"essentials:esilence",
"essentials:esudo",
"essentials:esurvival",
"essentials:esurvivalmode",
"essentials:etele",
"essentials:eteleport",
"essentials:etell",
"essentials:etempban",
"essentials:etjail",
"essentials:etogglejail",
"essentials:etp",
"essentials:etp2p",
"essentials:etpaall",
"essentials:etpall",
"essentials:etppos",
"essentials:etptoggle",
"essentials:eunban",
"essentials:eunbanip",
"essentials:ev",
"essentials:evanish",
"essentials:ewarp",
"essentials:ewarps",
"essentials:ewhisper",
"essentials:eworld",
"eaction",
"eadventure",
"eadventuremode",
"eafk",
"eamsg",
"eat",
"eaway",
"eban",
"ebanip",
"ebc",
"ebcast",
"ebcastw",
"ebcw",
"ebroadcast",
"ebroadcastworld",
"eci",
"eclean",
"eclear",
"eclearinvent",
"eclearinventory",
"ecreativemode",
"eco",
"economy",
"edescribe",
"eeat",
"eeco",
"eeconomy",
"eecreative",
"eemail",
"efeed",
"egamemode",
"egm",
"egma",
"egmc",
"egms",
"egmsp",
"egmt",
"eheal",
"ehelpop",
"ejail",
"ekick",
"ekill",
"email",
"eme",
"ememo",
"emute",
"emsg",
"enuke",
"epardon",
"epardonip",
"epm",
"eshoutworld",
"esilence",
"esudo",
"esurvival",
"esurvivalmode",
"etele",
"eteleport",
"etell",
"etempban",
"etjail",
"etogglejail",
"etp",
"etp2p",
"etpaall",
"etpall",
"etppos",
"etptoggle",
"eunban",
"eunbanip",
"ev",
"evanish",
"ewarp",
"ewarps",
"ewhisper",
"eworld",
"extras:bcraw",
"extras:broadcastraw",
"extras:cc",
"extras:clearchat",
"extras:console",
"extras:jumpscare",
"extras:scare",
"extras:tellraw",
"bcraw",
"broadcastraw",
"cc",
"clearchat",
"console",
"jumpscare",
"scare",
"tellraw",
"minecraft:clear",
"minecraft:clone",
"minecraft:datapack",
"minecraft:effect",
"minecraft:execute",
"minecraft:gamemode",
"minecraft:gamerule",
"minecraft:me",
"minecraft:msg",
"minecraft:say",
"minecraft:spreadplayers",
"minecraft:tell",
"minecraft:tellraw",
"minecraft:title",
"minecraft:tp",
"minecraft:worldborder",
"clear",
"clone",
"datapack",
"effect",
"execute",
"gamemode",
"gamerule",
"me",
"msg",
"say",
"spreadplayers",
"tell",
"title",
"tp",
"worldborder",
"paper:paper",
"paper",
"spigot:spigot",
"spigot",
"viaversion:viaver",
"viaversion:viaversion",
"viaversion:vvbukkit",
"viaver",
"viaversion",
"vvbukkit"
);
Collections.addAll(
BlockPhysics.blockFaces,
BlockFace.NORTH,

View file

@ -1,8 +1,6 @@
package pw.kaboom.extras.modules.server;
import java.util.HashSet;
import org.bukkit.ChatColor;
import org.bukkit.block.CommandBlock;
import org.bukkit.command.BlockCommandSender;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
@ -11,8 +9,6 @@ import org.bukkit.event.Listener;
import org.bukkit.event.server.ServerCommandEvent;
public final class ServerCommand implements Listener {
public static HashSet<String> consoleCommandBlacklist = new HashSet<String>();
public static String checkCommand(final CommandSender sender, final String command, final boolean isConsoleCommand) {
final String[] arr = command.split(" ");
String commandName = arr[0].toLowerCase();
@ -124,12 +120,12 @@ public final class ServerCommand implements Listener {
@EventHandler
void onServerCommand(final ServerCommandEvent event) {
final CommandSender sender = event.getSender();
final String[] arr = event.getCommand().split(" ");
if (sender instanceof BlockCommandSender) {
if (consoleCommandBlacklist.contains(arr[0].toLowerCase())) {
event.setCancelled(true);
}
final CommandBlock commandBlock = (CommandBlock) ((BlockCommandSender) sender).getBlock().getState();
commandBlock.setCommand("");
commandBlock.update();
}
final String command = event.getCommand();