A A A
Plain text Report abuse
Well, here is the problem. I have this jabber bot, running as a plugin to as online-game-watcher. I want to be able, through jabber, to issue commands to the bot, see the result, etc, and also that the commands would be reflected to the game. To issue the commands, I need to get the "player entity" generated by the game-watcher. I have a factory method that returns a "Player" object (I cannot modify the object or the factory). The `message()` method of this object, by default, sends a message in-game. However, jabber clients are obviously not in the game. So if I want to use the already-coded functions that issue warnings / bans etc. (and use the `message()` method), I would have to rewrite them, because `message()` works pretty bad if the player is not online. So instead, what I did is that when I get the player through the factory, I change the `message()` method to send the message to the corresponding jabber client (there is an internal attribute that already exists in the object and contains the jabber address of the player, if any). That way, I just call the already existing functions to administrate the server, and all output is sent via jabber instead of in-game. I don't think it's "magic". I just think it's a simple way of redirecting the output :). But maybe I'm still wrong... I would be happy to know why if it's the case :).