Skip to content

Commit

Permalink
feat: implement proper player limit
Browse files Browse the repository at this point in the history
- disconnect if player count is over or equal to set limit.
  • Loading branch information
CodeTheDev committed Feb 3, 2023
1 parent 1d9deba commit c49b745
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -27,7 +27,7 @@ To find the compiled server jar, navigate to the `build/libs` directory inside t
| *server-port* | `25565` | Integer | The port of the server. |
| *compression-threshold* | `-1` | Integer | Network Compression (-1 is 0, which means no compression). |
| *view-distance* | `3` | Integer | Player view distance (May cause visual issues if set below 3). |
| *max-players* | `-1` | Integer | Maximum player limit (-1 is unlimited, player limit is only visual). |
| *max-players* | `-1` | Integer | Maximum player limit (-1 is unlimited). |
| *motd* | `<dark_aqua><i>An OverflowLimbo Server</i></dark_aqua>` | String | Server list MOTD (Uses MiniMessage text formatting). |
| *tablist-enabled* | `false` | Boolean | Toggle tablist visibility. |
| *proxy-type* | `none` | String | Specifies the type of proxy being used (velocity, bungeecord, none). |
Expand Down
6 changes: 5 additions & 1 deletion src/main/java/dev/codeerror/overflow/OverflowLimbo.java
Original file line number Diff line number Diff line change
Expand Up @@ -100,7 +100,11 @@ public static void main(String[] args) {
});
events.addListener(AsyncPlayerPreLoginEvent.class, event -> {
Player player = event.getPlayer();
logger.info(player.getUsername() + " [" + player.getPlayerConnection().getRemoteAddress() + "] connected.");
if (world.getPlayers().size() >= config.getPlayerLimit() && config.getPlayerLimit() > -1) {
event.getPlayer().getPlayerConnection().disconnect();
} else {
logger.info(player.getUsername() + " [" + player.getPlayerConnection().getRemoteAddress() + "] connected.");
}
});
events.addListener(PlayerLoginEvent.class, event -> {
Player player = event.getPlayer();
Expand Down

0 comments on commit c49b745

Please sign in to comment.