mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-23 13:46:46 +01:00
Update /inspect to use Bukkit command API. Addresses #628
This commit is contained in:
parent
49ef013152
commit
0683745dd2
@ -13,6 +13,7 @@ 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;
|
||||||
import com.gmail.nossr50.commands.admin.XprateCommand;
|
import com.gmail.nossr50.commands.admin.XprateCommand;
|
||||||
|
import com.gmail.nossr50.commands.player.InspectCommand;
|
||||||
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;
|
||||||
@ -183,4 +184,13 @@ public final class CommandRegistrationHelper {
|
|||||||
command.setAliases(aliasList);
|
command.setAliases(aliasList);
|
||||||
command.setExecutor(new XprateCommand());
|
command.setExecutor(new XprateCommand());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public static void registerInspectCommand() {
|
||||||
|
PluginCommand command = mcMMO.p.getCommand("inspect");
|
||||||
|
command.setDescription(LocaleLoader.getString("Commands.Description.inspect"));
|
||||||
|
command.setPermission("mcmmo.commands.inspect;mcmmo.commands.inspect.far;mcmmo.commands.inspect.offline");
|
||||||
|
command.setPermissionMessage(permissionsMessage);
|
||||||
|
command.setUsage(LocaleLoader.getString("Commands.Usage.1", "inspect", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
|
||||||
|
command.setExecutor(new InspectCommand());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -17,32 +17,23 @@ import com.gmail.nossr50.util.Users;
|
|||||||
public class InspectCommand implements CommandExecutor {
|
public class InspectCommand implements CommandExecutor {
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
String usage = LocaleLoader.getString("Commands.Usage.1", "inspect", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">");
|
PlayerProfile profile;
|
||||||
|
|
||||||
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.inspect")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
switch (args.length) {
|
switch (args.length) {
|
||||||
case 1:
|
case 1:
|
||||||
McMMOPlayer mcmmoPlayer = Users.getPlayer(args[0]);
|
if (!Permissions.hasPermission(sender, "mcmmo.commands.inspect")) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
if (mcmmoPlayer != null) {
|
|
||||||
Player target = mcmmoPlayer.getPlayer();
|
|
||||||
|
|
||||||
if (sender instanceof Player && !Misc.isNear(((Player) sender).getLocation(), target.getLocation(), 5.0) && !Permissions.inspectFar((Player) sender)) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Inspect.TooFar"));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerProfile profile = mcmmoPlayer.getProfile();
|
McMMOPlayer mcMMOPlayer = Users.getPlayer(args[0]);
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Inspect.Stats", target.getName()));
|
// If the mcMMOPlayer doesn't exist, create a temporary profile and check if it's present in the database. If it's not, abort the process.
|
||||||
CommandHelper.printGatheringSkills(target, profile, sender);
|
if (mcMMOPlayer == null) {
|
||||||
CommandHelper.printCombatSkills(target, profile, sender);
|
profile = new PlayerProfile(args[0], false); //Temporary Profile
|
||||||
CommandHelper.printMiscSkills(target, profile, sender);
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", mcmmoPlayer.getPowerLevel()));
|
|
||||||
|
|
||||||
|
if (!profile.isLoaded()) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -51,13 +42,6 @@ public class InspectCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
PlayerProfile profile = new PlayerProfile(args[0], false); //Temporary Profile
|
|
||||||
|
|
||||||
if (!profile.isLoaded()) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Commands.DoesNotExist"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", args[0]));
|
sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", args[0]));
|
||||||
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Stats.Header.Gathering"));
|
sender.sendMessage(LocaleLoader.getString("Stats.Header.Gathering"));
|
||||||
@ -77,12 +61,31 @@ public class InspectCommand implements CommandExecutor {
|
|||||||
sender.sendMessage(LocaleLoader.getString("Stats.Header.Misc"));
|
sender.sendMessage(LocaleLoader.getString("Stats.Header.Misc"));
|
||||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Acrobatics.Listener"), profile.getSkillLevel(SkillType.ACROBATICS), profile.getSkillXpLevel(SkillType.ACROBATICS), profile.getXpToLevel(SkillType.ACROBATICS)));
|
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Acrobatics.Listener"), profile.getSkillLevel(SkillType.ACROBATICS), profile.getSkillXpLevel(SkillType.ACROBATICS), profile.getXpToLevel(SkillType.ACROBATICS)));
|
||||||
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Repair.Listener"), profile.getSkillLevel(SkillType.REPAIR), profile.getSkillXpLevel(SkillType.REPAIR), profile.getXpToLevel(SkillType.REPAIR)));
|
sender.sendMessage(LocaleLoader.getString("Skills.Stats", LocaleLoader.getString("Repair.Listener"), profile.getSkillLevel(SkillType.REPAIR), profile.getSkillXpLevel(SkillType.REPAIR), profile.getXpToLevel(SkillType.REPAIR)));
|
||||||
|
}
|
||||||
|
else {
|
||||||
|
Player target = mcMMOPlayer.getPlayer();
|
||||||
|
|
||||||
|
if (sender instanceof Player) {
|
||||||
|
Player inspector = (Player) sender;
|
||||||
|
|
||||||
|
if (!Misc.isNear(inspector.getLocation(), target.getLocation(), 5.0) && !Permissions.inspectFar(inspector)) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Inspect.TooFar"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
profile = mcMMOPlayer.getProfile();
|
||||||
|
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Inspect.Stats", target.getName()));
|
||||||
|
CommandHelper.printGatheringSkills(target, profile, sender);
|
||||||
|
CommandHelper.printCombatSkills(target, profile, sender);
|
||||||
|
CommandHelper.printMiscSkills(target, profile, sender);
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", mcMMOPlayer.getPowerLevel()));
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
sender.sendMessage(usage);
|
return false;
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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.player.InspectCommand;
|
|
||||||
import com.gmail.nossr50.commands.player.McabilityCommand;
|
import com.gmail.nossr50.commands.player.McabilityCommand;
|
||||||
import com.gmail.nossr50.commands.player.MccCommand;
|
import com.gmail.nossr50.commands.player.MccCommand;
|
||||||
import com.gmail.nossr50.commands.player.McmmoCommand;
|
import com.gmail.nossr50.commands.player.McmmoCommand;
|
||||||
@ -451,7 +450,7 @@ public class mcMMO extends JavaPlugin {
|
|||||||
CommandRegistrationHelper.registerAddxpCommand();
|
CommandRegistrationHelper.registerAddxpCommand();
|
||||||
CommandRegistrationHelper.registerAddlevelsCommand();
|
CommandRegistrationHelper.registerAddlevelsCommand();
|
||||||
CommandRegistrationHelper.registerMmoeditCommand();
|
CommandRegistrationHelper.registerMmoeditCommand();
|
||||||
getCommand("inspect").setExecutor(new InspectCommand());
|
CommandRegistrationHelper.registerInspectCommand();
|
||||||
CommandRegistrationHelper.registerXprateCommand();
|
CommandRegistrationHelper.registerXprateCommand();
|
||||||
getCommand("mmoupdate").setExecutor(new MmoupdateCommand());
|
getCommand("mmoupdate").setExecutor(new MmoupdateCommand());
|
||||||
CommandRegistrationHelper.registerSkillresetCommand();
|
CommandRegistrationHelper.registerSkillresetCommand();
|
||||||
|
@ -689,6 +689,7 @@ 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.inspect=View detailed mcMMO info on another player
|
||||||
Commands.Description.mcgod=Toggle mcMMO god-mode on/off
|
Commands.Description.mcgod=Toggle mcMMO god-mode on/off
|
||||||
Commands.Description.mcrefresh=Refresh all cooldowns for mcMMO
|
Commands.Description.mcrefresh=Refresh all cooldowns for mcMMO
|
||||||
Commands.Description.mmoedit=Edit mcMMO levels for a user
|
Commands.Description.mmoedit=Edit mcMMO levels for a user
|
||||||
|
@ -66,7 +66,7 @@ commands:
|
|||||||
aliases: []
|
aliases: []
|
||||||
description: Create/join a party
|
description: Create/join a party
|
||||||
inspect:
|
inspect:
|
||||||
aliases: []
|
description: View detailed mcMMO info on another player
|
||||||
mmoupdate:
|
mmoupdate:
|
||||||
aliases: []
|
aliases: []
|
||||||
description: Convert from Flat File to MySQL
|
description: Convert from Flat File to MySQL
|
||||||
|
Loading…
Reference in New Issue
Block a user