I didn't get much (if any) further with this problem. To find a possible solution/workaround I made the task a bit more abstract, so maybe you can give me more ideas, because I'm running out of them.
When a player connects to a game (on a remote or the integrated server), I'd like to open (or at least get a path to) one or more files which should be unique to that server/sp world. Also, when the player disconnects (for whatever reason) I'd like to close these files (if any of them are open), or "forget" about their paths.
The problems I have encountered:
- during ClientConnectedToServerEvent, I cannot get a reference to the name of the current SP world
- my ClientConnectedToServerEvent handler is not called when connecting to a default bukkit server running on the same machine, due to some error in FML/Forge (I did not test this with a vanilla server) I don't have the error log right now, but I can attach it later if necessary.
- my ClientDisconnectionFromServerEvent handler never gets called, ever
- while trying to work around these with WorldEvent.Load, I have found that that event is fired variable number of times (some of those I could make some sense of and for some I couldn't)
Technically I could get a reference to the necessary files when things of interest happen, but that just seems like such a waste of computation power to "calculate" these things frequently when in theory I would only need to do it on connection. And with this method I still wouldn't know when to close/"forget about" these files.
TL;DR
- when joining a game, I would like to know the server IP (and possibly other data about it)[solved for remote servers, unsolved for local bukkit server] or the sp world name [unsolved]
- I would like to be notified, when a disconnect happens for whatever reason [unsolved]