Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -0,0 +1,40 @@
package com.earth2me.essentials.commands;

import com.earth2me.essentials.CommandSource;
import org.bukkit.Server;

import java.util.List;

public class Commandsetmaxplayers extends EssentialsCommand {
public Commandsetmaxplayers() {
super("setmaxplayers");
}

@Override
public void run(final Server server, final CommandSource sender, final String commandLabel, final String[] args) throws Exception {
if (args.length == 0) {
throw new NotEnoughArgumentsException();
}

try {
final int maxPlayers = Integer.parseInt(args[0]);
if (maxPlayers < 0) {
throw new Exception("The player limit cannot be set below 0.");
}

server.setMaxPlayers(maxPlayers);
sender.sendMessage("Player limit updated to " + maxPlayers + ".");
} catch (NumberFormatException e) {
throw new Exception("Invalid number.");
}
}

@Override
protected List<String> getTabCompleteOptions(final Server server, final CommandSource sender, final String commandLabel, final String[] args) {
if (args.length == 1) {
return getPlayers(sender);
} else {
return COMMON_DATE_DIFFS;
}
}
}
4 changes: 4 additions & 0 deletions Essentials/src/main/resources/messages.properties
Original file line number Diff line number Diff line change
Expand Up @@ -1162,6 +1162,10 @@ setjailCommandDescription=Creates a jail where you specified named [jailname].
setjailCommandUsage=/<command> <jailname>
setjailCommandUsage1=/<command> <jailname>
setjailCommandUsage1Description=Sets the jail with the specified name to your location
setmaxplayersCommandDescription=Set the max player limit
setmaxplayersCommandUsage=/<command> <number>
setmaxplayersCommandUsage1=/<command> <number>
setmaxplayersCommandUsage1Description=Sets the max player limit to the specified number
settprCommandDescription=Set the random teleport location and parameters.
settprCommandUsage=/<command> <world> [center|minrange|maxrange] [value]
settprCommandUsage1=/<command> <world> center
Expand Down
6 changes: 6 additions & 0 deletions Essentials/src/main/resources/plugin.yml
Original file line number Diff line number Diff line change
Expand Up @@ -431,6 +431,10 @@ commands:
description: Creates a jail where you specified named [jailname].
usage: /<command> <jailname>
aliases: [esetjail,createjail,ecreatejail]
setmaxplayers:
description: Set the max player limit
usage: /<command> <number>
aliases: [esetmaxplayers]
settpr:
description: Set the random teleport location and parameters.
usage: /<command> [center|minrange|maxrange] [value]
Expand Down Expand Up @@ -1209,6 +1213,8 @@ permissions:
description: Allows access to delete other players homes with the /delhome command
essentials.setjail:
description: Allows access to the /setjail command
essentials.setmaxplayers:
description: Allows access to the /setmaxplayers command
essentials.setwarp:
description: Allows access to the /setwarp command
essentials.setworth:
Expand Down
Loading