Update command registration for /mcgod

This commit is contained in:
GJ 2013-02-02 21:25:16 -05:00
parent a67e0c1433
commit 2e3c1d53f5
4 changed files with 16 additions and 7 deletions

View File

@ -8,6 +8,7 @@ import org.bukkit.command.PluginCommand;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.admin.AddlevelsCommand; import com.gmail.nossr50.commands.admin.AddlevelsCommand;
import com.gmail.nossr50.commands.admin.AddxpCommand; import com.gmail.nossr50.commands.admin.AddxpCommand;
import com.gmail.nossr50.commands.admin.McgodCommand;
import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.skills.acrobatics.AcrobaticsCommand; import com.gmail.nossr50.skills.acrobatics.AcrobaticsCommand;
import com.gmail.nossr50.skills.archery.ArcheryCommand; import com.gmail.nossr50.skills.archery.ArcheryCommand;
@ -131,4 +132,13 @@ public final class CommandRegistrationHelper {
command.setUsage(LocaleLoader.getString("Commands.Usage.3", "addxp", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.XP") + ">")); command.setUsage(LocaleLoader.getString("Commands.Usage.3", "addxp", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]", "<" + LocaleLoader.getString("Commands.Usage.Skill") + ">", "<" + LocaleLoader.getString("Commands.Usage.XP") + ">"));
command.setExecutor(new AddxpCommand()); command.setExecutor(new AddxpCommand());
} }
public static void registerMcgodCommand() {
PluginCommand command = mcMMO.p.getCommand("mcgod");
command.setDescription(LocaleLoader.getString("Commands.Description.mcgod"));
command.setPermission("mcmmo.commands.mcgod");
command.setPermissionMessage(permissionsMessage);
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcgod", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]"));
command.setExecutor(new McgodCommand());
}
} }

View File

@ -23,11 +23,7 @@ public class McgodCommand implements CommandExecutor {
return true; return true;
} }
if (!Permissions.mcgodCommand(sender)) { profile = Users.getPlayer((Player) sender).getProfile();
return true;
}
profile = Users.getProfile((Player) sender);
if (profile == null) { if (profile == null) {
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist")); sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
@ -43,11 +39,13 @@ public class McgodCommand implements CommandExecutor {
profile.toggleGodMode(); profile.toggleGodMode();
return true; return true;
case 1: case 1:
if (!Permissions.hasPermission(sender, "mcmmo.commands.mcgod.others")) { if (!Permissions.hasPermission(sender, "mcmmo.commands.mcgod.others")) {
sender.sendMessage(command.getPermissionMessage()); sender.sendMessage(command.getPermissionMessage());
return true; return true;
} }
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]); McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
// If the mcMMOPlayer doesn't exist, create a temporary profile and // If the mcMMOPlayer doesn't exist, create a temporary profile and
@ -77,6 +75,7 @@ public class McgodCommand implements CommandExecutor {
profile.toggleGodMode(); profile.toggleGodMode();
return true; return true;
default: default:
return false; return false;
} }

View File

@ -25,7 +25,6 @@ import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory;
import com.gmail.nossr50.chat.commands.ACommand; import com.gmail.nossr50.chat.commands.ACommand;
import com.gmail.nossr50.chat.commands.PCommand; import com.gmail.nossr50.chat.commands.PCommand;
import com.gmail.nossr50.commands.CommandRegistrationHelper; import com.gmail.nossr50.commands.CommandRegistrationHelper;
import com.gmail.nossr50.commands.admin.McgodCommand;
import com.gmail.nossr50.commands.admin.McrefreshCommand; import com.gmail.nossr50.commands.admin.McrefreshCommand;
import com.gmail.nossr50.commands.admin.MmoeditCommand; import com.gmail.nossr50.commands.admin.MmoeditCommand;
import com.gmail.nossr50.commands.admin.SkillResetCommand; import com.gmail.nossr50.commands.admin.SkillResetCommand;
@ -397,7 +396,7 @@ public class mcMMO extends JavaPlugin {
getCommand("mcremove").setExecutor(new McremoveCommand()); getCommand("mcremove").setExecutor(new McremoveCommand());
getCommand("mcability").setExecutor(new McabilityCommand()); getCommand("mcability").setExecutor(new McabilityCommand());
getCommand("mcc").setExecutor(new MccCommand()); getCommand("mcc").setExecutor(new MccCommand());
getCommand("mcgod").setExecutor(new McgodCommand()); CommandRegistrationHelper.registerMcgodCommand();
getCommand("mcmmo").setExecutor(new McmmoCommand()); getCommand("mcmmo").setExecutor(new McmmoCommand());
getCommand("mcrefresh").setExecutor(new McrefreshCommand()); getCommand("mcrefresh").setExecutor(new McrefreshCommand());
getCommand("mctop").setExecutor(new MctopCommand()); getCommand("mctop").setExecutor(new MctopCommand());

View File

@ -688,4 +688,5 @@ Smelting.SkillName=SMELTING
#COMMAND DESCRIPTIONS #COMMAND DESCRIPTIONS
Commands.Description.addlevels=Add mcMMO levels to a user Commands.Description.addlevels=Add mcMMO levels to a user
Commands.Description.addxp=Add mcMMO XP to a user Commands.Description.addxp=Add mcMMO XP to a user
Commands.Description.mcgod=Toggles mcMMO god-mode on/off
Commands.Description.Skill=Detailed mcMMO skill info for {0} Commands.Description.Skill=Detailed mcMMO skill info for {0}