Bukkit-API  1.7.9-R0.2
The inofficial Bukkit-API
SetIdleTimeoutCommand.java
1 package org.bukkit.command.defaults;
2 
3 import com.google.common.collect.ImmutableList;
4 
5 import org.apache.commons.lang.Validate;
6 import org.bukkit.Bukkit;
7 import org.bukkit.ChatColor;
10 
11 import java.util.List;
12 
13 public class SetIdleTimeoutCommand extends VanillaCommand {
14 
15  public SetIdleTimeoutCommand() {
16  super("setidletimeout");
17  this.description = "Sets the server's idle timeout";
18  this.usageMessage = "/setidletimeout <Minutes until kick>";
19  this.setPermission("bukkit.command.setidletimeout");
20  }
21 
22  @Override
23  public boolean execute(CommandSender sender, String currentAlias, String[] args) {
24  if (!testPermission(sender)) return true;
25 
26  if (args.length == 1) {
27  int minutes;
28 
29  try {
30  minutes = getInteger(sender, args[0], 0, Integer.MAX_VALUE, true);
31  } catch (NumberFormatException ex) {
32  sender.sendMessage(ex.getMessage());
33  return true;
34  }
35 
36  Bukkit.getServer().setIdleTimeout(minutes);
37 
38  Command.broadcastCommandMessage(sender, "Successfully set the idle timeout to " + minutes + " minutes.");
39  return true;
40  }
41  sender.sendMessage(ChatColor.RED + "Usage: " + usageMessage);
42  return false;
43  }
44 
45  @Override
46  public List<String> tabComplete(CommandSender sender, String alias, String[] args) {
47  Validate.notNull(sender, "Sender cannot be null");
48  Validate.notNull(args, "Arguments cannot be null");
49  Validate.notNull(alias, "Alias cannot be null");
50 
51  return ImmutableList.of();
52  }
53 }
boolean testPermission(CommandSender target)
void sendMessage(String message)
void setPermission(String permission)
static Server getServer()
Definition: Bukkit.java:50
void setIdleTimeout(int threshold)