HOOK_EXECUTE_COMMAND
Index: Articles Classes Hooks Quick navigation: BLOCK_SPREAD BLOCK_TO_PICKUPS BREWING_COMPLETED BREWING_COMPLETING CHAT CHUNK_AVAILABLE CHUNK_GENERATED CHUNK_GENERATING CHUNK_UNLOADED CHUNK_UNLOADING COLLECTING_PICKUP CRAFTING_NO_RECIPE DISCONNECT ENTITY_ADD_EFFECT ENTITY_CHANGED_WORLD ENTITY_CHANGING_WORLD ENTITY_TELEPORT EXECUTE_COMMAND EXPLODED EXPLODING HANDSHAKE HOPPER_PULLING_ITEM HOPPER_PUSHING_ITEM KILLED KILLING LOGIN PLAYER_ANIMATION PLAYER_BREAKING_BLOCK PLAYER_BROKEN_BLOCK PLAYER_DESTROYED PLAYER_EATING PLAYER_FISHED PLAYER_FISHING PLAYER_FOOD_LEVEL_CHANGE PLAYER_JOINED PLAYER_LEFT_CLICK PLAYER_MOVING PLAYER_PLACED_BLOCK PLAYER_PLACING_BLOCK PLAYER_RIGHT_CLICK PLAYER_RIGHT_CLICKING_ENTITY PLAYER_SHOOTING PLAYER_SPAWNED PLAYER_TOSSING_ITEM PLAYER_USED_BLOCK PLAYER_USED_ITEM PLAYER_USING_BLOCK PLAYER_USING_ITEM PLUGINS_LOADED PLUGIN_MESSAGE POST_CRAFTING PRE_CRAFTING PROJECTILE_HIT_BLOCK PROJECTILE_HIT_ENTITY SERVER_PING SPAWNED_ENTITY SPAWNED_MONSTER SPAWNING_ENTITY SPAWNING_MONSTER TAKE_DAMAGE TICK UPDATED_SIGN UPDATING_SIGN WEATHER_CHANGED WEATHER_CHANGING WORLD_STARTED WORLD_TICK | A plugin may implement a callback for this hook to intercept both in-game commands executed by the players and console commands executed by the server admin. The function is called for every in-game command sent from any player and for those server console commands that are not built in in the server. If the command is in-game, the first parameter to the hook function is the player who's executing the command. If the command comes from the server console, the first parameter is nil. The server calls this hook even for unregistered (unknown) console commands. It also calls the hook for unknown in-game commands, as long as they begin with a slash ('/'). If a plugin needs to intercept in-game chat messages not beginning with a slash, it should use the HOOK_CHAT hook. Callback functionThe default name for the callback function is OnExecuteCommand. It has the following signature: function OnExecuteCommand(Player, CommandSplit, EntireCommand) Parameters:
If the plugin returns false, Cuberite calls all the remaining hook handlers and finally the command will be executed. If the plugin returns true, the none of the remaining hook handlers will be called. In this case the plugin can return a second value, specifying whether what the command result should be set to, one of the CommandResult constants. If not provided, the value defaults to crBlocked. Code examplesRegistering the callbackcPluginManager:AddHook(cPluginManager.HOOK_EXECUTE_COMMAND, MyOnExecuteCommand); |