mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 15:16:45 +01:00
Update /mcability to use Bukkit CommandAPI. Addresses #628
This commit is contained in:
parent
0683745dd2
commit
4d93f3271d
@ -14,6 +14,7 @@ import com.gmail.nossr50.commands.admin.MmoeditCommand;
|
||||
import com.gmail.nossr50.commands.admin.SkillresetCommand;
|
||||
import com.gmail.nossr50.commands.admin.XprateCommand;
|
||||
import com.gmail.nossr50.commands.player.InspectCommand;
|
||||
import com.gmail.nossr50.commands.player.McabilityCommand;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.skills.acrobatics.AcrobaticsCommand;
|
||||
import com.gmail.nossr50.skills.archery.ArcheryCommand;
|
||||
@ -193,4 +194,13 @@ public final class CommandRegistrationHelper {
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "inspect", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
|
||||
command.setExecutor(new InspectCommand());
|
||||
}
|
||||
|
||||
public static void registerMcabilityCommand() {
|
||||
PluginCommand command = mcMMO.p.getCommand("mcability");
|
||||
command.setDescription(LocaleLoader.getString("Commands.Description.mcability"));
|
||||
command.setPermission("mcmmo.commands.ability;mcmmo.commands.mcability.others");
|
||||
command.setPermissionMessage(permissionsMessage);
|
||||
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "mcability", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
|
||||
command.setExecutor(new McabilityCommand());
|
||||
}
|
||||
}
|
||||
|
@ -1,26 +1,25 @@
|
||||
package com.gmail.nossr50.commands.player;
|
||||
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.Command;
|
||||
import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import com.gmail.nossr50.mcMMO;
|
||||
import com.gmail.nossr50.commands.CommandHelper;
|
||||
import com.gmail.nossr50.datatypes.McMMOPlayer;
|
||||
import com.gmail.nossr50.datatypes.PlayerProfile;
|
||||
import com.gmail.nossr50.locale.LocaleLoader;
|
||||
import com.gmail.nossr50.util.Permissions;
|
||||
import com.gmail.nossr50.util.Users;
|
||||
|
||||
public class McabilityCommand implements CommandExecutor {
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
PlayerProfile profile;
|
||||
String usage = LocaleLoader.getString("Commands.Usage.1", "mcability", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">");
|
||||
|
||||
switch (args.length) {
|
||||
case 0:
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mcability")) {
|
||||
if (!Permissions.hasPermission(sender, "mcmmo.commands.mcability")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
@ -37,32 +36,37 @@ public class McabilityCommand implements CommandExecutor {
|
||||
return true;
|
||||
|
||||
case 1:
|
||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.mcability.others")) {
|
||||
if (!Permissions.hasPermission(sender, "mcmmo.commands.mcability.others")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
OfflinePlayer modifiedPlayer = mcMMO.p.getServer().getOfflinePlayer(args[0]);
|
||||
profile = Users.getPlayer(args[0]).getProfile();
|
||||
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
||||
|
||||
// TODO:Not sure if we actually need a null check here
|
||||
if (profile == null || !profile.isLoaded()) {
|
||||
if (mcMMOPlayer == null) {
|
||||
profile = new PlayerProfile(args[0], false);
|
||||
|
||||
if (!profile.isLoaded()) {
|
||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||
return true;
|
||||
}
|
||||
|
||||
if (profile.getAbilityUse()) {
|
||||
((Player) modifiedPlayer).sendMessage(LocaleLoader.getString("Commands.Ability.Off"));
|
||||
}
|
||||
else {
|
||||
((Player) modifiedPlayer).sendMessage(LocaleLoader.getString("Commands.Ability.On"));
|
||||
profile = mcMMOPlayer.getProfile();
|
||||
|
||||
if (profile.getAbilityUse()) {
|
||||
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Ability.Off"));
|
||||
}
|
||||
else {
|
||||
mcMMOPlayer.getPlayer().sendMessage(LocaleLoader.getString("Commands.Ability.On"));
|
||||
}
|
||||
}
|
||||
|
||||
profile.toggleAbilityUse();
|
||||
return true;
|
||||
|
||||
default:
|
||||
sender.sendMessage(usage);
|
||||
return true;
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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.PCommand;
|
||||
import com.gmail.nossr50.commands.CommandRegistrationHelper;
|
||||
import com.gmail.nossr50.commands.player.McabilityCommand;
|
||||
import com.gmail.nossr50.commands.player.MccCommand;
|
||||
import com.gmail.nossr50.commands.player.McmmoCommand;
|
||||
import com.gmail.nossr50.commands.player.McrankCommand;
|
||||
@ -431,7 +430,7 @@ public class mcMMO extends JavaPlugin {
|
||||
// mc* commands
|
||||
getCommand("mcpurge").setExecutor(new McpurgeCommand());
|
||||
getCommand("mcremove").setExecutor(new McremoveCommand());
|
||||
getCommand("mcability").setExecutor(new McabilityCommand());
|
||||
CommandRegistrationHelper.registerMcabilityCommand();
|
||||
getCommand("mcc").setExecutor(new MccCommand());
|
||||
CommandRegistrationHelper.registerMcgodCommand();
|
||||
getCommand("mcmmo").setExecutor(new McmmoCommand());
|
||||
|
@ -690,6 +690,7 @@ Smelting.SkillName=SMELTING
|
||||
Commands.Description.addlevels=Add mcMMO levels to a user
|
||||
Commands.Description.addxp=Add mcMMO XP to a user
|
||||
Commands.Description.inspect=View detailed mcMMO info on another player
|
||||
Commands.Description.mcability=Toggle mcMMO abilities being readied on right-click on/off
|
||||
Commands.Description.mcgod=Toggle mcMMO god-mode on/off
|
||||
Commands.Description.mcrefresh=Refresh all cooldowns for mcMMO
|
||||
Commands.Description.mmoedit=Edit mcMMO levels for a user
|
||||
|
@ -45,7 +45,6 @@ commands:
|
||||
addlevels:
|
||||
description: Add mcMMO levels to a user
|
||||
mcability:
|
||||
aliases: []
|
||||
description: Toggle whether or not abilities get readied on right click
|
||||
mcrefresh:
|
||||
description: Refresh all cooldowns for mcMMO
|
||||
|
Loading…
Reference in New Issue
Block a user