Jump to content

Server-side hook request: ShouldLogin


Recommended Posts

Hey there, I'm trying to write a server-side mod for hardcore servers that will restrict the players' ability to log into the server while dead.  Currently I'm booting the player in the onLogin hook on the IConnectionHandler if they attempt to log in while dead.  However, I've found that some mods which do more substantive actions during login (TerraFirmaCraft) will crash the client if they're booted at this point.  I believe that it's because even if I boot the player, I can't really stop the rest of the login sequence from trying to run unless I throw an exception to stop it.  I don't really want to clog up the server logs with stack traces, though.  Would it be possible to get a hook added to IConnectionHandler which can be used to restrict players from logging in more safely?  Something that'd allow me to return a boot message if the player needs to be kicked or null if they should be let in?  Just a thought, thanks!

Link to comment
Share on other sites

I assume by "a" whitelist/blacklist, you mean "the" whitelist/blacklist, in which case the message the user receives while dead would not be controllable, it'd be, "you can't log into this server" or "you are banned" rather than "you are dead".  I wouldn't be able to tell the user how long they have left.  I also would have to check the entire death list very frequently to clear living players off it- depending on how large the server is, that's a lot of wasted CPU cycles for something that's constant-time to check on login.  It seems like a lot of downsides, especially since there are other systems that might take advantage of similar functionality.

Link to comment
Share on other sites

The onLogin hook runs after the user's already been let through all the login checks- I could make sure the whitelist/blacklist is right in onConnect but again, we'd be doing a linear time operation every time a user connects when a hook that lets me boot whoever I want would be constant time, since you don't have the connecting username in onConnect.  For other reasons why that's a bad idea, read the thread.


EDIT:  Also, asking if there's an onLogin hook in a thread where the OP has the phrase "Currently I'm booting the player in the onLogin hook" is, uh.

Link to comment
Share on other sites

import java.util.SentenceFinisher;



uh, a sign of temporary idiocy

Yes, that was dumb.

And I am no expert on mp, so if I make any gaffes, just ignore me.

So, what would happen if I did push that shiny red button over there? ... Really? ... Can I try it? ... Damn.

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.


  • Create New...

Important Information

By using this site, you agree to our Terms of Use.