Bukkit - How can I differentiate from the Console?
Bukkit - How can I differentiate from the Console?
I noticed on the plugin tutorial page (on bukkit) that to make sure that a command is or isn't sent by the console, you just check to see if it is/isn't an instance of a Player. Makes enough sense to me, but while I was working on my plugin, I didn't want the console to be able to use the command to view it's own IP, and I tried to use the "sender instanceof Player", but it still ignored it, as in, the console and players were still able to use the command as if the console was emulating a Player instance. So as a temporary fix, I just had it check if the getName() is "Console" (since as to date, I don't believe any player has registered with the name "Console", surprisingly enough. Of course this isn't intended to be a permanent fix, so how can I go about doing this in a better fashion? Thank in advance!
Re: Bukkit - How can I differentiate from the Console?
I think the instanceof Player should work :s But the console is a ConsoleCommandSender so
if (sender instanceof ConsoleCommandSender){ // Hi I'm the console }Should definitely work.
Re: Bukkit - How can I differentiate from the Console?
Thanks! This seems to work perfectly XD