-
Notifications
You must be signed in to change notification settings - Fork 14
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
2 changed files
with
33 additions
and
0 deletions.
There are no files selected for viewing
32 changes: 32 additions & 0 deletions
32
server/src/main/java/org/allaymc/server/command/defaults/SetMaxPlayersCommand.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
package org.allaymc.server.command.defaults; | ||
|
||
import org.allaymc.api.command.SimpleCommand; | ||
import org.allaymc.api.command.tree.CommandTree; | ||
import org.allaymc.api.i18n.TrKeys; | ||
import org.allaymc.api.server.Server; | ||
|
||
/** | ||
* @author daoge_cmd | ||
*/ | ||
public class SetMaxPlayersCommand extends SimpleCommand { | ||
|
||
public SetMaxPlayersCommand() { | ||
super("setmaxplayers", TrKeys.M_COMMANDS_SETMAXPLAYERS_DESCRIPTION); | ||
} | ||
|
||
@Override | ||
public void prepareCommandTree(CommandTree tree) { | ||
tree.getRoot() | ||
.intNum("maxPlayers") | ||
.exec(context -> { | ||
int maxPlayers = context.getResult(0); | ||
maxPlayers = Math.max(Server.getInstance().getOnlinePlayerCount(), maxPlayers); | ||
|
||
Server.SETTINGS.genericSettings().maxClientCount(maxPlayers); | ||
Server.getInstance().getNetworkServer().setMaxPlayerCount(maxPlayers); | ||
context.addOutput(TrKeys.M_COMMANDS_SETMAXPLAYERS_SUCCESS, maxPlayers); | ||
|
||
return context.success(); | ||
}); | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters