Is it possible to allow non-premium clients from a certain IP?

Discussion in 'Server & Community Management' started by QuarkTheAwesome, Jan 22, 2015.

  1. Hi guys!

    I was just wondering if it's possible to accept connections from a cracked client IF they are using a certain IP.
    I'd like to do this so I can do a real-world test of what my staff do when a rule-breaker comes. If I can use a cracked client or something I can do this without borrowing a friends account and possibly having him banned or whatever.
    The trouble is, I want to keep my server in online mode so other people (not me) can only join with premium accounts.
    I was thinking a plugin or something might be able to achieve this. If there isn't a plugin already, if someone can tell me what the Java methods for skipping the Mojang auth system is, that would be helpful too. (I can handle the rest)

    Thanks guys!

    P.S Yes, I have read the other thread on a similar topic, and no, an IP whitelist would not work for me. I still want this to be a public server, I just want to do some tests while nobody's around.
     
    • Friendly Friendly x 1
  2. Not sure if this is possible while your server is in online mode.
     
  3. It is, in BungeeCord easily, in Spigot i'm not sure.
    You just have to set the OnlineMode in the PreJoinEvent (in BungeeCord) for this user.
     
  4. I had a look at Spigot's AsyncPlayerPreJoinEvent and I'm thinking .allow() might be what I want (although I can't find much on this). I'll try it in a bit.
     
  5. I've just now PM'ed you a small list of alts to use so you don't have to go through that trouble. BTW, I have no idea which ones work, so if some don't work I'm sorry :D
     
  6. Yeah, I would go with something like an alt account, but I don't know why, I just don't like the idea. Anyway, whipping up a plugin yourself is much more fun. ;3
     
    • Friendly Friendly x 1
  7. One of the owners of gontroller mentioned in a Q&A that they managed to setup their factions server so they could join as anyone. Not sure how they did it though.
     
  8. Oh, I remember that :D
     
  9. Hmm, I tried doing this with AsyncPlayerPreLoginEvent, but it seems that cracked clients are rejected by authlib even before the event fires.
    Argh!

    Here's my code:
    Code (Text):
        @EventHandler
        public void login(AsyncPlayerPreLoginEvent e) {
            try {
                ip = InetAddress.getByName(this.getConfig().getString("allowed-ip"));
                if (e.getAddress().equals(ip)) {
                    //Allow player through!!! PLEASE!
                    this.getLogger().info("Attempting to allow player on IP address whitelist");
                    e.allow();
                    e.setLoginResult(AsyncPlayerPreLoginEvent.Result.ALLOWED);
                } else {
                    this.getLogger().info("Player is not on list - Config= '" + this.getConfig().getString("allowed-ip") + "' Event= '" + e.getAddress().toString() + "'");
                }
            } catch (Exception e2){
                this.getLogger().warning("Can't preprocess player login event! OH NO!");
                e2.printStackTrace();
            }
        }
    I'm not sure why I posted it, it's rejected immediately:

    Code (Text):
    [email protected][id=<null>,name=bob,properties={},legacy=false] (/127.0.0.1:51523) lost connection: Disconnected
     
    • Winner Winner x 1
  10. joehot200

    Supporter

    I won't bore you with details, since someone already posted an existing plugin which you'll use. But, what made you think .allow() or .setResult() would work? I don't understand why setting the result or allowing the player would change the packet sent out to the player when they first click the join button asking for the auth information.
     
  11. This looks like a great plugin (and I'll definitely keep it in mind) but it only works on BungeeCord - I'm looking for a Spigot solution.

    I figured since the event was called AsyncPlayerPreLoginEvent, it would execute before the login to Mojang. I admit, it was a shot in the dark. I only posted the code in case there was a syntax error or something (maybe it needs eventpriority set?) but yes, I didn't really think it would work.

    Worst comes to worst, I may have to start a BungeeCord server, or worse, modify Spigot myself.
     
  12. joehot200

    Supporter

    Just use ProtocolLib to modify the packet sent to the client when he joins.

    PM aandk about it, he'll be helpful.