2013-02-01 19:41:26 +01:00
|
|
|
package com.gmail.nossr50.commands.player;
|
2012-02-29 18:20:58 +01:00
|
|
|
|
2013-03-28 17:57:49 +01:00
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
|
|
|
import java.util.Set;
|
|
|
|
|
2012-02-29 18:20:58 +01:00
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
2013-03-28 17:57:49 +01:00
|
|
|
import org.bukkit.command.TabExecutor;
|
2012-02-29 18:20:58 +01:00
|
|
|
import org.bukkit.entity.Player;
|
2013-03-28 17:57:49 +01:00
|
|
|
import org.bukkit.util.StringUtil;
|
2012-02-29 18:20:58 +01:00
|
|
|
|
2013-06-29 00:02:58 +02:00
|
|
|
import com.gmail.nossr50.mcMMO;
|
mcMMO - Now with 100% more scoreboards!
mcMMO now allows for the use of scoreboards to display information in
several instances. By default, all scoreboards are enabled in the config,
and will only display for 10 seconds. After 10 seconds, the scoreboard
will go away and revert to the previously displayed scoreboard, if one
exists.
A global scoreboard now exists for tracking all player stats, and will be
displayed when /mctop is used. Your name will be highlighted in gold when
looking through the scoreboard. Additionally, the scoreboard will display
players in groups of 15, rather than groups of 10 like in chat.
Unfortunately, due to the limitations of scoreboards, the player's rank
will not be displayed in front of their name.
The scoreboard area is now also used for displaying data for /mcrank,
/inspect. and /mcstats. Due to the way scoreboards are handled, the power
level is not guarenteed to show up at any given location in the
scoreboard, but is instead displayed in gold so that it can be easily
found.
Lastly, the scoreboard area is also now used for displaying current data
on skills when the relevant /<skillname> command is used. The effects and
ability stats will still be shown in chat, but the current level, xp, and
remaining xp will be shown in the scoreboard.
2013-04-14 05:16:25 +02:00
|
|
|
import com.gmail.nossr50.config.Config;
|
2013-03-01 06:52:01 +01:00
|
|
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
|
|
|
import com.gmail.nossr50.datatypes.player.PlayerProfile;
|
|
|
|
import com.gmail.nossr50.datatypes.skills.SkillType;
|
2012-04-27 11:47:11 +02:00
|
|
|
import com.gmail.nossr50.locale.LocaleLoader;
|
2013-08-19 10:37:04 +02:00
|
|
|
import com.gmail.nossr50.util.Misc;
|
2013-02-19 06:56:25 +01:00
|
|
|
import com.gmail.nossr50.util.Permissions;
|
2013-03-01 06:52:01 +01:00
|
|
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
|
|
|
import com.gmail.nossr50.util.player.UserManager;
|
mcMMO - Now with 100% more scoreboards!
mcMMO now allows for the use of scoreboards to display information in
several instances. By default, all scoreboards are enabled in the config,
and will only display for 10 seconds. After 10 seconds, the scoreboard
will go away and revert to the previously displayed scoreboard, if one
exists.
A global scoreboard now exists for tracking all player stats, and will be
displayed when /mctop is used. Your name will be highlighted in gold when
looking through the scoreboard. Additionally, the scoreboard will display
players in groups of 15, rather than groups of 10 like in chat.
Unfortunately, due to the limitations of scoreboards, the player's rank
will not be displayed in front of their name.
The scoreboard area is now also used for displaying data for /mcrank,
/inspect. and /mcstats. Due to the way scoreboards are handled, the power
level is not guarenteed to show up at any given location in the
scoreboard, but is instead displayed in gold so that it can be easily
found.
Lastly, the scoreboard area is also now used for displaying current data
on skills when the relevant /<skillname> command is used. The effects and
ability stats will still be shown in chat, but the current level, xp, and
remaining xp will be shown in the scoreboard.
2013-04-14 05:16:25 +02:00
|
|
|
import com.gmail.nossr50.util.scoreboards.ScoreboardManager;
|
2012-02-29 18:20:58 +01:00
|
|
|
|
2013-03-28 17:57:49 +01:00
|
|
|
import com.google.common.collect.ImmutableList;
|
|
|
|
|
|
|
|
public class InspectCommand implements TabExecutor {
|
2012-02-29 18:20:58 +01:00
|
|
|
@Override
|
|
|
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
2012-04-03 21:26:19 +02:00
|
|
|
switch (args.length) {
|
2013-03-01 06:52:01 +01:00
|
|
|
case 1:
|
mcMMO - Now with 100% more scoreboards!
mcMMO now allows for the use of scoreboards to display information in
several instances. By default, all scoreboards are enabled in the config,
and will only display for 10 seconds. After 10 seconds, the scoreboard
will go away and revert to the previously displayed scoreboard, if one
exists.
A global scoreboard now exists for tracking all player stats, and will be
displayed when /mctop is used. Your name will be highlighted in gold when
looking through the scoreboard. Additionally, the scoreboard will display
players in groups of 15, rather than groups of 10 like in chat.
Unfortunately, due to the limitations of scoreboards, the player's rank
will not be displayed in front of their name.
The scoreboard area is now also used for displaying data for /mcrank,
/inspect. and /mcstats. Due to the way scoreboards are handled, the power
level is not guarenteed to show up at any given location in the
scoreboard, but is instead displayed in gold so that it can be easily
found.
Lastly, the scoreboard area is also now used for displaying current data
on skills when the relevant /<skillname> command is used. The effects and
ability stats will still be shown in chat, but the current level, xp, and
remaining xp will be shown in the scoreboard.
2013-04-14 05:16:25 +02:00
|
|
|
if (sender instanceof Player && Config.getInstance().getInspectScoreboardEnabled()) {
|
|
|
|
ScoreboardManager.setupPlayerScoreboard(sender.getName());
|
|
|
|
}
|
|
|
|
|
2013-08-19 10:37:04 +02:00
|
|
|
String playerName = Misc.getMatchedPlayerName(args[0]);
|
|
|
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayerExact(playerName);
|
2012-04-03 21:26:19 +02:00
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
// 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.
|
|
|
|
if (mcMMOPlayer == null) {
|
2013-08-19 10:37:04 +02:00
|
|
|
PlayerProfile profile = mcMMO.getDatabaseManager().loadPlayerProfile(playerName, false); // Temporary Profile
|
2012-04-04 16:34:35 +02:00
|
|
|
|
2013-03-12 21:25:42 +01:00
|
|
|
if (CommandUtils.inspectOffline(sender, profile, Permissions.inspectOffline(sender))) {
|
2013-02-04 22:43:37 +01:00
|
|
|
return true;
|
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
|
mcMMO - Now with 100% more scoreboards!
mcMMO now allows for the use of scoreboards to display information in
several instances. By default, all scoreboards are enabled in the config,
and will only display for 10 seconds. After 10 seconds, the scoreboard
will go away and revert to the previously displayed scoreboard, if one
exists.
A global scoreboard now exists for tracking all player stats, and will be
displayed when /mctop is used. Your name will be highlighted in gold when
looking through the scoreboard. Additionally, the scoreboard will display
players in groups of 15, rather than groups of 10 like in chat.
Unfortunately, due to the limitations of scoreboards, the player's rank
will not be displayed in front of their name.
The scoreboard area is now also used for displaying data for /mcrank,
/inspect. and /mcstats. Due to the way scoreboards are handled, the power
level is not guarenteed to show up at any given location in the
scoreboard, but is instead displayed in gold so that it can be easily
found.
Lastly, the scoreboard area is also now used for displaying current data
on skills when the relevant /<skillname> command is used. The effects and
ability stats will still be shown in chat, but the current level, xp, and
remaining xp will be shown in the scoreboard.
2013-04-14 05:16:25 +02:00
|
|
|
if (sender instanceof Player && Config.getInstance().getInspectScoreboardEnabled()) {
|
|
|
|
ScoreboardManager.enablePlayerInspectScoreboardOffline((Player) sender, profile);
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-08-19 10:37:04 +02:00
|
|
|
sender.sendMessage(LocaleLoader.getString("Inspect.OfflineStats", playerName));
|
2013-03-01 06:52:01 +01:00
|
|
|
|
|
|
|
sender.sendMessage(LocaleLoader.getString("Stats.Header.Gathering"));
|
2013-03-12 21:25:42 +01:00
|
|
|
CommandUtils.displaySkill(sender, profile, SkillType.EXCAVATION);
|
|
|
|
CommandUtils.displaySkill(sender, profile, SkillType.FISHING);
|
|
|
|
CommandUtils.displaySkill(sender, profile, SkillType.HERBALISM);
|
|
|
|
CommandUtils.displaySkill(sender, profile, SkillType.MINING);
|
|
|
|
CommandUtils.displaySkill(sender, profile, SkillType.WOODCUTTING);
|
2013-03-01 06:52:01 +01:00
|
|
|
|
|
|
|
sender.sendMessage(LocaleLoader.getString("Stats.Header.Combat"));
|
2013-03-12 21:25:42 +01:00
|
|
|
CommandUtils.displaySkill(sender, profile, SkillType.AXES);
|
|
|
|
CommandUtils.displaySkill(sender, profile, SkillType.ARCHERY);
|
|
|
|
CommandUtils.displaySkill(sender, profile, SkillType.SWORDS);
|
|
|
|
CommandUtils.displaySkill(sender, profile, SkillType.TAMING);
|
|
|
|
CommandUtils.displaySkill(sender, profile, SkillType.UNARMED);
|
2013-03-01 06:52:01 +01:00
|
|
|
|
|
|
|
sender.sendMessage(LocaleLoader.getString("Stats.Header.Misc"));
|
2013-03-12 21:25:42 +01:00
|
|
|
CommandUtils.displaySkill(sender, profile, SkillType.ACROBATICS);
|
|
|
|
CommandUtils.displaySkill(sender, profile, SkillType.REPAIR);
|
2013-02-04 22:43:37 +01:00
|
|
|
}
|
2013-03-01 06:52:01 +01:00
|
|
|
else {
|
|
|
|
Player target = mcMMOPlayer.getPlayer();
|
|
|
|
|
2013-06-03 15:33:23 +02:00
|
|
|
if (CommandUtils.hidden(sender, target, Permissions.inspectHidden(sender))) {
|
|
|
|
if (!Permissions.inspectOffline(sender)) {
|
|
|
|
sender.sendMessage(LocaleLoader.getString("Inspect.Offline"));
|
|
|
|
return true;
|
|
|
|
}
|
mcMMO - Now with 100% more scoreboards!
mcMMO now allows for the use of scoreboards to display information in
several instances. By default, all scoreboards are enabled in the config,
and will only display for 10 seconds. After 10 seconds, the scoreboard
will go away and revert to the previously displayed scoreboard, if one
exists.
A global scoreboard now exists for tracking all player stats, and will be
displayed when /mctop is used. Your name will be highlighted in gold when
looking through the scoreboard. Additionally, the scoreboard will display
players in groups of 15, rather than groups of 10 like in chat.
Unfortunately, due to the limitations of scoreboards, the player's rank
will not be displayed in front of their name.
The scoreboard area is now also used for displaying data for /mcrank,
/inspect. and /mcstats. Due to the way scoreboards are handled, the power
level is not guarenteed to show up at any given location in the
scoreboard, but is instead displayed in gold so that it can be easily
found.
Lastly, the scoreboard area is also now used for displaying current data
on skills when the relevant /<skillname> command is used. The effects and
ability stats will still be shown in chat, but the current level, xp, and
remaining xp will be shown in the scoreboard.
2013-04-14 05:16:25 +02:00
|
|
|
}
|
2013-06-03 15:33:23 +02:00
|
|
|
else if (CommandUtils.tooFar(sender, target, Permissions.inspectFar(sender))) {
|
2013-06-02 12:42:18 +02:00
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
mcMMO - Now with 100% more scoreboards!
mcMMO now allows for the use of scoreboards to display information in
several instances. By default, all scoreboards are enabled in the config,
and will only display for 10 seconds. After 10 seconds, the scoreboard
will go away and revert to the previously displayed scoreboard, if one
exists.
A global scoreboard now exists for tracking all player stats, and will be
displayed when /mctop is used. Your name will be highlighted in gold when
looking through the scoreboard. Additionally, the scoreboard will display
players in groups of 15, rather than groups of 10 like in chat.
Unfortunately, due to the limitations of scoreboards, the player's rank
will not be displayed in front of their name.
The scoreboard area is now also used for displaying data for /mcrank,
/inspect. and /mcstats. Due to the way scoreboards are handled, the power
level is not guarenteed to show up at any given location in the
scoreboard, but is instead displayed in gold so that it can be easily
found.
Lastly, the scoreboard area is also now used for displaying current data
on skills when the relevant /<skillname> command is used. The effects and
ability stats will still be shown in chat, but the current level, xp, and
remaining xp will be shown in the scoreboard.
2013-04-14 05:16:25 +02:00
|
|
|
if (sender instanceof Player && Config.getInstance().getInspectScoreboardEnabled()) {
|
|
|
|
ScoreboardManager.enablePlayerInspectScoreboardOnline((Player) sender, mcMMOPlayer);
|
|
|
|
return true;
|
2013-03-01 06:52:01 +01:00
|
|
|
}
|
|
|
|
|
|
|
|
sender.sendMessage(LocaleLoader.getString("Inspect.Stats", target.getName()));
|
2013-03-12 21:25:42 +01:00
|
|
|
CommandUtils.printGatheringSkills(target, sender);
|
|
|
|
CommandUtils.printCombatSkills(target, sender);
|
|
|
|
CommandUtils.printMiscSkills(target, sender);
|
2013-03-01 06:52:01 +01:00
|
|
|
sender.sendMessage(LocaleLoader.getString("Commands.PowerLevel", mcMMOPlayer.getPowerLevel()));
|
|
|
|
}
|
2012-04-27 11:47:11 +02:00
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
return true;
|
2012-04-03 22:13:16 +02:00
|
|
|
|
2013-03-01 06:52:01 +01:00
|
|
|
default:
|
|
|
|
return false;
|
2012-04-03 21:26:19 +02:00
|
|
|
}
|
2012-02-29 18:20:58 +01:00
|
|
|
}
|
2013-03-28 17:57:49 +01:00
|
|
|
|
|
|
|
@Override
|
|
|
|
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
|
|
|
|
switch (args.length) {
|
|
|
|
case 1:
|
2013-07-15 15:14:23 +02:00
|
|
|
Set<String> playerNames = UserManager.getPlayerNames();
|
2013-03-28 17:57:49 +01:00
|
|
|
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
|
|
|
default:
|
|
|
|
return ImmutableList.of();
|
|
|
|
}
|
|
|
|
}
|
2012-02-29 18:20:58 +01:00
|
|
|
}
|