Util Change max player ammount on a server!

Discussion in 'Resources' started by mine-care, Apr 8, 2015.

Thread Status:
Not open for further replies.
  1. Offline


    It has been asked quite a few times "how to change the max players allowed ingame" and thats for instance because Hosting companies limit server slots, or because someone wants to set the player slots plugin-wise.

    Ok so the following feature involves basic reflection in order to change the "maxPlayers" field of the PlayerList class.

    Use under your own risk, Be carefull of Terms Of Service in hosting companies.

    NOTE: The method below is not enhanced or made efficient, it will be done some time...

    Read the warning before opening (open)

        public static void setMaxPlayers(int maxPlayers)
                throws ReflectiveOperationException {
            String bukkitversion = Bukkit.getServer().getClass().getPackage()
            Object playerlist = Class.forName("org.bukkit.craftbukkit." + bukkitversion    + ".CraftServer")
                    .getDeclaredMethod("getHandle", null).invoke(Bukkit.getServer(), null);
            Field maxplayers = playerlist.getClass().getSuperclass()
            maxplayers.set(playerlist, maxplayers);

    But.. why this method and not setting the display-slots onServerListPingEvent and allow players on PlayerLoginEvent?
    Well the method with the use of the second layer (Bukkit API) is ok but the only problem is that if a plugin (like essentials) with a command like/list displays currentPlayers/MaxPlayers then your cover is blown :p Also the method above automatically resizes the tab list that is visible on clients < 1.8 so if you set it to 32 players, it will have 32 player slots.
    With this method you can set max players to negative values although you will need to allow the clients to join manually.
    Last edited: Apr 17, 2015
    ChipDev likes this.
  2. Offline


    Ooooohh! Sweet.. I've hacked my hosting company already, But didn't use this yet!
    Thanks :p
    Does this allow more people to come on? Or is it just cosmetic?
    mine-care likes this.
  3. Offline


    Can't you use
    and use event.setMaxPlayers(int maxPlayers); ?
    Or does this do something different? Like, for example, I do this:

    public class motdSet implements Listener {

    public void ping(ServerListPingEvent e) {
    e.setMaxPlayers(e.getNumPlayers() + 1);
    Stringmessages Main.getMain().getConfig().getStringList("Motd");
    Random random = new Random();
    int index random.nextInt(messages.size());
    messages.get(index)) );
    System.out.println(e.getAddress() + " might join!");

    I'm sorry.. I need to read better. I have been sick lately so my head is messed up.. Sorry again :p
    Totom3 and mine-care like this.
  4. Offline


    @sgavster No worries! Oh and something i noticed, please follow java naming conventions :3
  5. @mine-care Since when did Bukkit invent the player limit feature? I always thought that was a vanilla feature. Also, this is hardly a Bukkit resource, it's more of a "how to cheat your hosting company". By the way, this is technically illegal. If you only pay to have 5 players, but you have 10 players, you're still breaking their conditions of sale, which you're not allowed to do. Regardless of how stupid the slot limit is.

    Edit @mine-care You're also supporting multiple versions incorrectly :) http://bukkit.org/threads/support-multiple-minecraft-versions-with-abstraction-maven.115810/
    mine-care likes this.
  6. Offline


    @mine-care I actually just fixed the names..
    I hadn't coded in a while, this was one of the first classes so I really just named it randomly lol.
    @AdamQpzm Most hosting companies allow you to change them; you just have to go through a ticket and things (for example, BeastNode, which I love) but it is a pain to wait. They usually don't care.
  7. Offline


    @AdamQpzm mhm, you're right, it is vanila feature, Still it is a bukkit resource as with many others, this might not be its only purpose. i provided it as an example. Another idea of use is when you make a minigame plugin and you want to limit slots for the server. Yep, it is not under the TOS of the hosting company, i dont think it is ilegual though, it just goes beyond terms of servce. Edited post and added this warning.
    I have looked onto the link provided in the past, but mabe i haven't payed nessesary attention, ill revise it.
    Thanks for your comment, it was valuable actually to save me from trouble =)
  8. @mine-care @sgavster If your host is charging per player, and you allow more players than you have paid for, I guarantee that is illegal. If you sell me 5 chocolate bars, and I take 10, 5 of those are stolen. It's no different for players. Now, whether or not it's worth them trying to press it in court (it definitely isn't) is another question. Either way, I don't think it's a good idea to encourage someone to willingly break their hosts rules, is it? Those who realise what you're doing and care absolutely will cancel your service with no notice.
  9. Offline


    @AdamQpzm Well in the removed example i was mainly focusing to hosts that allow you up to 6 players lets say, they wont allow you to change it and you cannot buy an extra feature allowing you to change it but only if you buy premium package (double money, minimal hardware changes) in order to enable that for you.
    The hosting company i had in mind DOES NOT mention anywhere in the terms of service anything about that ^ but that was just a fail example :p
    After your post, the example was removed :- )
    Also keeping in mind that if a customer buys the 1gb ram package with 30 players max, then it is purely an aesthetical change since with 30 players on the 1GB server will be short lived...
    Lets stay on the minigame example instead :oops:
    TigerHix and sgavster like this.
  10. Offline


    @AdamQpzm I see this on most hosting sights:

    Also this:
    mine-care likes this.
  11. @mine-care You're still doing multiple versions wrong ;) And I would definitely recommend the option of "changing the properties file" unless there was any specific need to have it done without server restart.

    @shavster I was under the impression that this post was originally aimed at hosts that didn't allow you to edit the players in the properties, not ones that recommended you didn't :)
  12. Offline


    @AdamQpzm Oh, alright. Just wanted to show that.
    Sorry! I understand.
    TigerHix and AdamQpzm like this.
  13. Offline


    @AdamQpzm Umm i am not in a position to read it now and make changes, i had 6 hours of physics revision so i see stars going round and round and round my head atm.:rolleyes:
    TigerHix likes this.
  14. Offline


    Can someone please show me a company that actually limits player slots? I've never come across one that does...
    sgavster likes this.
  15. Offline


    you can allow player to join over limit by canceling kick event without any reflection
    xTrollxDudex and Phasesaber like this.
  16. Offline


    Virtual gladiators?
    mine-care likes this.
  17. Offline


    This is why I host my server on my home computer.

    Edit: I've also never seen an instance where max players needs to be changed. It's usually spoofing the amount of players online.
  18. Offline


    @xTrollxDudex About homehost, i would have done it too but my region network is SO slow and after calculating the power the server consumes per day i end up with like 2 or 3$ so it is way better to host in a company for my case...

    :- )

    <Edit by mrCookieSlime: Merged posts. Please don't double post. There is an Edit Button right next to the Date.>
    Last edited by a moderator: Apr 9, 2015
Thread Status:
Not open for further replies.

Share This Page