diff --git a/Essentials/src/main/java/com/earth2me/essentials/commands/Commandsetmaxplayers.java b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandsetmaxplayers.java new file mode 100644 index 00000000000..48c0da98440 --- /dev/null +++ b/Essentials/src/main/java/com/earth2me/essentials/commands/Commandsetmaxplayers.java @@ -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 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; + } + } +} diff --git a/Essentials/src/main/resources/messages.properties b/Essentials/src/main/resources/messages.properties index bc243b36b8e..2f357c803f8 100644 --- a/Essentials/src/main/resources/messages.properties +++ b/Essentials/src/main/resources/messages.properties @@ -1162,6 +1162,10 @@ setjailCommandDescription=Creates a jail where you specified named [jailname]. setjailCommandUsage=/ setjailCommandUsage1=/ setjailCommandUsage1Description=Sets the jail with the specified name to your location +setmaxplayersCommandDescription=Set the max player limit +setmaxplayersCommandUsage=/ +setmaxplayersCommandUsage1=/ +setmaxplayersCommandUsage1Description=Sets the max player limit to the specified number settprCommandDescription=Set the random teleport location and parameters. settprCommandUsage=/ [center|minrange|maxrange] [value] settprCommandUsage1=/ center diff --git a/Essentials/src/main/resources/plugin.yml b/Essentials/src/main/resources/plugin.yml index 68496ebbbdf..835c40004f5 100644 --- a/Essentials/src/main/resources/plugin.yml +++ b/Essentials/src/main/resources/plugin.yml @@ -431,6 +431,10 @@ commands: description: Creates a jail where you specified named [jailname]. usage: / aliases: [esetjail,createjail,ecreatejail] + setmaxplayers: + description: Set the max player limit + usage: / + aliases: [esetmaxplayers] settpr: description: Set the random teleport location and parameters. usage: / [center|minrange|maxrange] [value] @@ -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: