11-01-2015, 04:10 AM
What about the way, how Bukkit handles the commands.
Bukkit uses an abstract class called CommandSender, which is implemented by every entity, which can send commands.
It has some basic commands(https://hub.spigotmc.org/javadocs/bukkit...ender.html) to allow sending messages back to the command sender and to check permissions of the command sender. These are then properly overloaded(console has all permissions, command block messages are lost...) and send to the Command handeling routine.
The effect is, that you only have one command handeling routine, which can decide, if it threads console commands different than player commands:
The nice thing about this is, that a lot of commands don't need to have a player. Also most command block commands behave exactly, as if they were executed on a command block(only certain commands differ, like /ban or /op).
Also you can write little wrapper functions, which wrap a command handler and check for a player executing a command.
P.S. @xoft Have you thought about the Mincarts with command blocks inside ? (see http://minecraft.gamepedia.com/Command_block_minecart)
Bukkit uses an abstract class called CommandSender, which is implemented by every entity, which can send commands.
It has some basic commands(https://hub.spigotmc.org/javadocs/bukkit...ender.html) to allow sending messages back to the command sender and to check permissions of the command sender. These are then properly overloaded(console has all permissions, command block messages are lost...) and send to the Command handeling routine.
The effect is, that you only have one command handeling routine, which can decide, if it threads console commands different than player commands:
Code:
function HandleCommand(a_CommandSender, a_Split, a_EntireCmd)
if(a_CommandSender:GetType() != SenderType:Player && a_Split.length == 0) then
-- No playername to kill and no player has send this command
a_CommandSender:sendMessage("I don't know, who I should kill...")
return
end
-- Kill the given player or the player itself, if it is a player
end
The nice thing about this is, that a lot of commands don't need to have a player. Also most command block commands behave exactly, as if they were executed on a command block(only certain commands differ, like /ban or /op).
Also you can write little wrapper functions, which wrap a command handler and check for a player executing a command.
P.S. @xoft Have you thought about the Mincarts with command blocks inside ? (see http://minecraft.gamepedia.com/Command_block_minecart)