001 package org.bukkit.command.defaults; 002 003 import java.util.List; 004 005 import org.apache.commons.lang.StringUtils; 006 import org.apache.commons.lang.Validate; 007 008 import org.bukkit.Bukkit; 009 import org.bukkit.command.Command; 010 import org.bukkit.command.CommandSender; 011 import org.bukkit.entity.Player; 012 013 import com.google.common.collect.ImmutableList; 014 015 public class StopCommand extends VanillaCommand { 016 public StopCommand() { 017 super("stop"); 018 this.description = "Stops the server with optional reason"; 019 this.usageMessage = "/stop [reason]"; 020 this.setPermission("bukkit.command.stop"); 021 } 022 023 @Override 024 public boolean execute(CommandSender sender, String currentAlias, String[] args) { 025 if (!testPermission(sender)) return true; 026 027 Command.broadcastCommandMessage(sender, "Stopping the server.."); 028 Bukkit.shutdown(); 029 030 String reason = this.createString(args, 0); 031 if (StringUtils.isNotEmpty(reason)) { 032 for (Player player : Bukkit.getOnlinePlayers()) { 033 player.kickPlayer(reason); 034 } 035 } 036 037 return true; 038 } 039 040 @Override 041 public List<String> tabComplete(CommandSender sender, String alias, String[] args) throws IllegalArgumentException { 042 Validate.notNull(sender, "Sender cannot be null"); 043 Validate.notNull(args, "Arguments cannot be null"); 044 Validate.notNull(alias, "Alias cannot be null"); 045 046 return ImmutableList.of(); 047 } 048 }