Skip to content

Commit

Permalink
Added reload command
Browse files Browse the repository at this point in the history
  • Loading branch information
Chipley committed Sep 13, 2013
1 parent d878206 commit 94a1295
Showing 1 changed file with 29 additions and 25 deletions.
54 changes: 29 additions & 25 deletions src/com/Chipmunk9998/Spectate/SpectateCommandExecutor.java
Original file line number Diff line number Diff line change
Expand Up @@ -22,30 +22,45 @@ public SpectateCommandExecutor(Spectate plugin) {

public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args) {

if (!(sender instanceof Player)) {

sender.sendMessage(ChatColor.RED + "You can't execute this command from the console.");
return true;
if (cmd.getName().equalsIgnoreCase("spectate")) {

}
if (args.length == 0 || args[0].equalsIgnoreCase("help")) {

Player cmdsender = (Player) sender;
if (!sender.hasPermission("spectate.help") && !sender.hasPermission("spectate.on") && !sender.hasPermission("spectate.off")) {

if (cmd.getName().equalsIgnoreCase("spectate")) {
sender.sendMessage(ChatColor.RED + "You do not have permission.");
return true;

if (args.length == 0) {
}

if (!cmdsender.hasPermission("spectate.help") && !cmdsender.hasPermission("spectate.on") && !cmdsender.hasPermission("spectate.off")) {
showHelp(sender);
return true;

cmdsender.sendMessage(ChatColor.RED + "You do not have permission.");
}

if (args[0].equalsIgnoreCase("reload")) {

if (!sender.isOp()) {

sender.sendMessage(ChatColor.RED + "You do not have permission.");
return true;

}

plugin.loadConfig();
sender.sendMessage(ChatColor.GRAY + "Spectate config reloaded.");
return true;

}

if (!(sender instanceof Player)) {

showHelp(cmdsender);
sender.sendMessage(ChatColor.RED + "You can't execute this command from the console.");
return true;

}

Player cmdsender = (Player) sender;

if (args[0].equalsIgnoreCase("off")) {

Expand Down Expand Up @@ -245,18 +260,6 @@ public boolean onCommand(CommandSender sender, Command cmd, String commandLabel,
Spectate.getAPI().startScanning(cmdsender, interval);
return true;

}else if (args[0].equalsIgnoreCase("help")) {

if (!cmdsender.hasPermission("spectate.help") && !cmdsender.hasPermission("spectate.on") && !cmdsender.hasPermission("spectate.off")) {

cmdsender.sendMessage(ChatColor.RED + "You do not have permission.");
return true;

}

showHelp(cmdsender);
return true;

}

if (!cmdsender.hasPermission("spectate.on")) {
Expand Down Expand Up @@ -332,14 +335,15 @@ public boolean onCommand(CommandSender sender, Command cmd, String commandLabel,

}

public void showHelp(Player cmdsender) {
public void showHelp(CommandSender cmdsender) {

cmdsender.sendMessage(ChatColor.RED + "Commands for Spectate:");
cmdsender.sendMessage(ChatColor.RED + "/spectate [PlayerName]: " + ChatColor.GRAY + "Puts you into spectate mode and lets you see what the target sees.");
cmdsender.sendMessage(ChatColor.RED + "/spectate off : " + ChatColor.GRAY + "Takes you out of spectate mode.");
cmdsender.sendMessage(ChatColor.RED + "/spectate scan [interval] : " + ChatColor.GRAY + "Starts the scanning mode with the specified interval.");
cmdsender.sendMessage(ChatColor.RED + "/spectate mode [1 | default]: " + ChatColor.GRAY + "Puts you into the default spectate mode.");
cmdsender.sendMessage(ChatColor.RED + "/spectate mode [2 | scroll]: " + ChatColor.GRAY + "Puts you into scroll style mode with left click and right click controls.");
cmdsender.sendMessage(ChatColor.RED + "/spectate reload : " + ChatColor.GRAY + "Reloads the config.");
cmdsender.sendMessage(ChatColor.RED + "/spectate help : " + ChatColor.GRAY + "Shows this help page.");

}
Expand Down

0 comments on commit 94a1295

Please sign in to comment.