001 package org.bukkit.command.defaults; 002 003 import com.google.common.collect.ImmutableList; 004 005 import org.apache.commons.lang.Validate; 006 import org.bukkit.Bukkit; 007 import org.bukkit.ChatColor; 008 import org.bukkit.command.Command; 009 import org.bukkit.command.CommandSender; 010 011 import java.util.List; 012 013 public class SetIdleTimeoutCommand extends VanillaCommand { 014 015 public SetIdleTimeoutCommand() { 016 super("setidletimeout"); 017 this.description = "Sets the server's idle timeout"; 018 this.usageMessage = "/setidletimeout <Minutes until kick>"; 019 this.setPermission("bukkit.command.setidletimeout"); 020 } 021 022 @Override 023 public boolean execute(CommandSender sender, String currentAlias, String[] args) { 024 if (!testPermission(sender)) return true; 025 026 if (args.length == 1) { 027 int minutes; 028 029 try { 030 minutes = getInteger(sender, args[0], 0, Integer.MAX_VALUE, true); 031 } catch (NumberFormatException ex) { 032 sender.sendMessage(ex.getMessage()); 033 return true; 034 } 035 036 Bukkit.getServer().setIdleTimeout(minutes); 037 038 Command.broadcastCommandMessage(sender, "Successfully set the idle timeout to " + minutes + " minutes."); 039 return true; 040 } 041 sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage); 042 return false; 043 } 044 045 @Override 046 public List<String> tabComplete(CommandSender sender, String alias, String[] args) { 047 Validate.notNull(sender, "Sender cannot be null"); 048 Validate.notNull(args, "Arguments cannot be null"); 049 Validate.notNull(alias, "Alias cannot be null"); 050 051 return ImmutableList.of(); 052 } 053 }