Added /mcstats <player> as a clone of /inspect <player>

This commit is contained in:
Blake Bartenbach 2012-04-23 07:26:58 -05:00
parent 3db83db5d2
commit 680baa6873
7 changed files with 128 additions and 30 deletions

View File

@ -0,0 +1,2 @@
Manifest-Version: 1.0

View File

@ -10,6 +10,8 @@ import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale; import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.skills.Skills; import com.gmail.nossr50.skills.Skills;
import java.util.logging.Logger;
public class CommandHelper { public class CommandHelper {
/** /**
@ -46,7 +48,6 @@ public class CommandHelper {
* *
* @param inspect The player to retrieve stats for * @param inspect The player to retrieve stats for
* @param display The sender to display stats to * @param display The sender to display stats to
* @param online true if the player to retrieve stats for is online, false otherwise
*/ */
public static void printGatheringSkills(Player inspect, CommandSender display) { public static void printGatheringSkills(Player inspect, CommandSender display) {
if (Skills.hasGatheringSkills(inspect)) { if (Skills.hasGatheringSkills(inspect)) {
@ -85,7 +86,6 @@ public class CommandHelper {
* *
* @param inspect The player to retrieve stats for * @param inspect The player to retrieve stats for
* @param display The sender to display stats to * @param display The sender to display stats to
* @param online true if the player to retrieve stats for is online, false otherwise
*/ */
public static void printCombatSkills(Player inspect, CommandSender display) { public static void printCombatSkills(Player inspect, CommandSender display) {
if (Skills.hasCombatSkills(inspect)) { if (Skills.hasCombatSkills(inspect)) {
@ -124,7 +124,6 @@ public class CommandHelper {
* *
* @param inspect The player to retrieve stats for * @param inspect The player to retrieve stats for
* @param display The sender to display stats to * @param display The sender to display stats to
* @param online true if the player to retrieve stats for is online, false otherwise
*/ */
public static void printMiscSkills(Player inspect, CommandSender display) { public static void printMiscSkills(Player inspect, CommandSender display) {
if (Skills.hasMiscSkills(inspect)) { if (Skills.hasMiscSkills(inspect)) {

View File

@ -1,5 +1,9 @@
package com.gmail.nossr50.commands.general; package com.gmail.nossr50.commands.general;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender; import org.bukkit.command.CommandSender;
@ -12,24 +16,100 @@ import com.gmail.nossr50.locale.mcLocale;
public class McstatsCommand implements CommandExecutor { public class McstatsCommand implements CommandExecutor {
private mcMMO instance;
public McstatsCommand(mcMMO instance) {
this.instance = instance;
}
@Override @Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
Player player = (Player) sender; PlayerProfile PP;
PlayerProfile PP = Users.getProfile(player); Player player;
player.sendMessage(mcLocale.getString("mcPlayerListener.YourStats")); switch (args.length) {
player.sendMessage(mcLocale.getString("mcPlayerListener.NoSkillNote")); case 0:
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
CommandHelper.printGatheringSkills(player); player = (Player) sender;
CommandHelper.printCombatSkills(player); PP = Users.getProfile(player);
CommandHelper.printMiscSkills(player);
player.sendMessage(mcLocale.getString("mcPlayerListener.PowerLevel", new Object[] { PP.getPowerLevel() })); player.sendMessage(mcLocale.getString("mcPlayerListener.YourStats"));
player.sendMessage(mcLocale.getString("mcPlayerListener.NoSkillNote"));
CommandHelper.printGatheringSkills(player);
CommandHelper.printCombatSkills(player);
CommandHelper.printMiscSkills(player);
player.sendMessage(mcLocale.getString("mcPlayerListener.PowerLevel", new Object[] { PP.getPowerLevel() }));
return true;
case 1:
OfflinePlayer target;
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.inspect")) {
return true;
}
target = instance.getServer().getOfflinePlayer(args[0]);
PP = Users.getProfile(target);
if (target.isOnline()) {
player = (Player) target;
if (sender instanceof Player && !sender.isOp() && !m.isNear(((Player) sender).getLocation(), player.getLocation(), 5.0)
&& !sender.hasPermission("mcmmo.commands.inspect.all")) {
//
sender.sendMessage(mcLocale.getString("Inspect.TooFar"));
return true;
}
sender.sendMessage(mcLocale.getString("Inspect.Stats", new Object[] { target.getName() }));
CommandHelper.printGatheringSkills(player, sender);
CommandHelper.printCombatSkills(player, sender);
CommandHelper.printMiscSkills(player, sender);
sender.sendMessage(mcLocale.getString("mcPlayerListener.PowerLevel", new Object[] { PP.getPowerLevel() }));
return true;
} else {
if (sender instanceof Player && !sender.isOp() && !sender.hasPermission("mcmmo.commands.inspect.offline")) {
sender.sendMessage(mcLocale.getString("Inspect.Offline"));
return true;
}
if (!PP.isLoaded()) {
sender.sendMessage(mcLocale.getString("Commands.DoesNotExist"));
return true;
}
sender.sendMessage(mcLocale.getString("Inspect.OfflineStats", new Object[] { args[0] }));
sender.sendMessage(mcLocale.getString("Stats.GatheringHeader"));
sender.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.ExcavationSkill"), PP.getSkillLevel(SkillType.EXCAVATION), PP.getSkillXpLevel(SkillType.EXCAVATION), PP.getXpToLevel(SkillType.EXCAVATION) }));
sender.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.FishingSkill"), PP.getSkillLevel(SkillType.FISHING), PP.getSkillXpLevel(SkillType.FISHING), PP.getXpToLevel(SkillType.FISHING) }));
sender.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.HerbalismSkill"), PP.getSkillLevel(SkillType.HERBALISM), PP.getSkillXpLevel(SkillType.HERBALISM), PP.getXpToLevel(SkillType.HERBALISM) }));
sender.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.MiningSkill"), PP.getSkillLevel(SkillType.MINING), PP.getSkillXpLevel(SkillType.MINING), PP.getXpToLevel(SkillType.MINING) }));
sender.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.WoodcuttingSkill"), PP.getSkillLevel(SkillType.WOODCUTTING), PP.getSkillXpLevel(SkillType.WOODCUTTING), PP.getXpToLevel(SkillType.WOODCUTTING) }));
sender.sendMessage(mcLocale.getString("Stats.CombatHeader"));
sender.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.AxesSkill"), PP.getSkillLevel(SkillType.AXES), PP.getSkillXpLevel(SkillType.AXES), PP.getXpToLevel(SkillType.AXES) }));
sender.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.ArcherySkill"), PP.getSkillLevel(SkillType.ARCHERY), PP.getSkillXpLevel(SkillType.ARCHERY), PP.getXpToLevel(SkillType.ARCHERY) }));
sender.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.SwordsSkill"), PP.getSkillLevel(SkillType.SWORDS), PP.getSkillXpLevel(SkillType.SWORDS), PP.getXpToLevel(SkillType.SWORDS) }));
sender.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.TamingSkill"), PP.getSkillLevel(SkillType.TAMING), PP.getSkillXpLevel(SkillType.TAMING), PP.getXpToLevel(SkillType.TAMING) }));
sender.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.UnarmedSkill"), PP.getSkillLevel(SkillType.UNARMED), PP.getSkillXpLevel(SkillType.UNARMED), PP.getXpToLevel(SkillType.UNARMED) }));
sender.sendMessage(mcLocale.getString("Stats.MiscHeader"));
sender.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.AcrobaticsSkill"), PP.getSkillLevel(SkillType.ACROBATICS), PP.getSkillXpLevel(SkillType.ACROBATICS), PP.getXpToLevel(SkillType.ACROBATICS) }));
sender.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.RepairSkill"), PP.getSkillLevel(SkillType.REPAIR), PP.getSkillXpLevel(SkillType.REPAIR), PP.getXpToLevel(SkillType.REPAIR) }));
}
}
return true; return true;
}
} }
}

View File

@ -173,7 +173,7 @@ public class mcMMO extends JavaPlugin {
* </br> * </br>
* This function is designed for API usage. * This function is designed for API usage.
* *
* @param player Name of player whose profile to get * @param playerName Name of player whose profile to get
* @return the PlayerProfile object * @return the PlayerProfile object
*/ */
public PlayerProfile getPlayerProfileByName(String playerName) { public PlayerProfile getPlayerProfileByName(String playerName) {
@ -271,7 +271,7 @@ public class mcMMO extends JavaPlugin {
} }
if (LoadProperties.mcstatsEnable) { if (LoadProperties.mcstatsEnable) {
getCommand("mcstats").setExecutor(new McstatsCommand()); getCommand("mcstats").setExecutor(new McstatsCommand(this));
} }
//Party commands //Party commands

View File

@ -259,11 +259,11 @@ Experience:
Multiplier: Multiplier:
Animals: 1.0 Animals: 1.0
Creeper: 4.0 Creeper: 4.0
Skeleton: 2.0 Skeleton: 3.0
Spider: 3.0 Spider: 2.0
Zombie: 2.0 Zombie: 2.0
Pig_Zombie: 3.0 Pig_Zombie: 3.0
Enderman: 2.0 Enderman: 4.0
Cave_Spider: 3.0 Cave_Spider: 3.0
Silverfish: 3.0 Silverfish: 3.0
Blaze: 3.0 Blaze: 3.0

View File

@ -141,8 +141,9 @@ m.EffectsMining1_0=Super Breaker (ABILITY)
m.EffectsMining1_1=Speed+, Triple Drop Chance m.EffectsMining1_1=Speed+, Triple Drop Chance
m.EffectsMining2_0=Double Drops m.EffectsMining2_0=Double Drops
m.EffectsMining2_1=Double the normal loot m.EffectsMining2_1=Double the normal loot
m.EffectsMining2_0=Double Drops //Duplicates
m.EffectsMining2_1=Double the normal loot //m.EffectsMining2_0=Double Drops
//m.EffectsMining2_1=Double the normal loot
m.MiningDoubleDropChance=[[RED]]Double Drop Chance: [[YELLOW]]{0}% m.MiningDoubleDropChance=[[RED]]Double Drop Chance: [[YELLOW]]{0}%
m.MiningSuperBreakerLength=[[RED]]Super Breaker Length: [[YELLOW]]{0}s m.MiningSuperBreakerLength=[[RED]]Super Breaker Length: [[YELLOW]]{0}s
m.SkillRepair=REPAIR m.SkillRepair=REPAIR
@ -331,6 +332,8 @@ Commands.xplock.locked=[[GOLD]]Your XP BAR is now locked to {0}!
Commands.xplock.unlocked=[[GOLD]]Your XP BAR is now [[GREEN]]UNLOCKED[[GOLD]]! Commands.xplock.unlocked=[[GOLD]]Your XP BAR is now [[GREEN]]UNLOCKED[[GOLD]]!
Commands.xplock.invalid=[[RED]]That is not a valid skillname! Try /xplock mining Commands.xplock.invalid=[[RED]]That is not a valid skillname! Try /xplock mining
m.SkillFishing=FISHING m.SkillFishing=FISHING
//Duplicate
//m.SkillFishing=FISHING
mcPlayerListener.FishingSkill=Fishing: mcPlayerListener.FishingSkill=Fishing:
Skills.FishingUp=[[YELLOW]]Fishing skill increased by {0}. Total ({1}) Skills.FishingUp=[[YELLOW]]Fishing skill increased by {0}. Total ({1})
Repair.LostEnchants=[[RED]]You were not skilled enough to keep any enchantments. Repair.LostEnchants=[[RED]]You were not skilled enough to keep any enchantments.
@ -344,7 +347,6 @@ m.ArcaneEnchantKeepChance=[[GRAY]]AF Success Rate: [[YELLOW]]{0}%
m.ArcaneEnchantDowngradeChance=[[GRAY]]AF Downgrade Chance: [[YELLOW]]{0}% m.ArcaneEnchantDowngradeChance=[[GRAY]]AF Downgrade Chance: [[YELLOW]]{0}%
Fishing.MagicFound=[[GRAY]]You feel a touch of magic with this catch... Fishing.MagicFound=[[GRAY]]You feel a touch of magic with this catch...
Fishing.ItemFound=[[GRAY]]Treasure found! Fishing.ItemFound=[[GRAY]]Treasure found!
m.SkillFishing=FISHING
m.XPGainFishing=Fishing (Go figure!) m.XPGainFishing=Fishing (Go figure!)
m.EffectsFishing1_0=Treasure Hunter (Passive) m.EffectsFishing1_0=Treasure Hunter (Passive)
m.EffectsFishing1_1=Fish up misc objects m.EffectsFishing1_1=Fish up misc objects
@ -433,7 +435,7 @@ m.EffectsTaming7_2=[[GRAY]]COTW HOW-TO: Crouch and right click with {0} Bones/Fi
m.EffectsTaming1_1=Bone-whacking inspects wolves/ocelots m.EffectsTaming1_1=Bone-whacking inspects wolves/ocelots
m.SkillStats=[[YELLOW]]{0}[[GREEN]]{1}[[DARK_AQUA]] XP([[GRAY]]{2}[[DARK_AQUA]]/[[GRAY]]{3}[[DARK_AQUA]]) m.SkillStats=[[YELLOW]]{0}[[GREEN]]{1}[[DARK_AQUA]] XP([[GRAY]]{2}[[DARK_AQUA]]/[[GRAY]]{3}[[DARK_AQUA]])
Inspect.TooFar=[[RED]]You are too far away to inspect that player! Inspect.TooFar=[[RED]]You are too far away to inspect that player!
Inspect.Offline = [[RED]]That player is offline, inspecting offline players is limited to Ops! Inspect.Offline = [[RED]]You don't have permission to inspect offline players
Commands.DoesNotExist = [[RED]]Player does not exist in the database! Commands.DoesNotExist = [[RED]]Player does not exist in the database!
Inspect.Stats=[[GREEN]]mcMMO Stats for [[YELLOW]]{0} Inspect.Stats=[[GREEN]]mcMMO Stats for [[YELLOW]]{0}
Inspect.OfflineStats=mcMMO Stats for Offline Player [[YELLOW]]{0} Inspect.OfflineStats=mcMMO Stats for Offline Player [[YELLOW]]{0}

View File

@ -36,7 +36,7 @@ commands:
description: Make yourself invulnerable description: Make yourself invulnerable
permission: mcmmo.tools.mcgod permission: mcmmo.tools.mcgod
mcstats: mcstats:
description: Shows your mcMMO stats and xp description: Shows player mcMMO stats and xp
mcremove: mcremove:
description: Remove a user from the database description: Remove a user from the database
permission: mcmmo.tools.mcremove permission: mcmmo.tools.mcremove
@ -90,6 +90,7 @@ commands:
a: a:
description: Toggle Admin chat or send admin chat messages description: Toggle Admin chat or send admin chat messages
permission: mcmmo.chat.adminchat permission: mcmmo.chat.adminchat
permissions: permissions:
mcmmo.*: mcmmo.*:
description: Implies all mcmmo permissions. description: Implies all mcmmo permissions.
@ -120,6 +121,7 @@ permissions:
description: Allows access to mmoupdate and other sensitive commands description: Allows access to mmoupdate and other sensitive commands
mcmmo.bypass.arcanebypass: mcmmo.bypass.arcanebypass:
description: Allows user to bypass Arcane Repair so he will never lose enchantments description: Allows user to bypass Arcane Repair so he will never lose enchantments
mcmmo.tools.*: mcmmo.tools.*:
description: Implies all mcmmo.tools permissions. description: Implies all mcmmo.tools permissions.
children: children:
@ -135,6 +137,7 @@ permissions:
description: Allows access to mcgod command description: Allows access to mcgod command
mcmmo.tools.mcremove: mcmmo.tools.mcremove:
decription: Allows access to mcremove command decription: Allows access to mcremove command
mcmmo.ability.*: mcmmo.ability.*:
description: Implies all mcmmo.ability permissions. description: Implies all mcmmo.ability permissions.
children: children:
@ -348,6 +351,7 @@ permissions:
description: Allows use of Chimaera Wing item description: Allows use of Chimaera Wing item
mcmmo.motd: mcmmo.motd:
description: Allows access to the motd description: Allows access to the motd
mcmmo.commands.*: mcmmo.commands.*:
description: Implies all mcmmo.commands permissions. description: Implies all mcmmo.commands permissions.
children: children:
@ -355,6 +359,9 @@ permissions:
mcmmo.commands.ptp: true mcmmo.commands.ptp: true
mcmmo.commands.inspect: true mcmmo.commands.inspect: true
mcmmo.commands.party: true mcmmo.commands.party: true
mcmmo.commands.inspect: true
mcmmo.commands.inspect.offline: true
mcmmo.commands.inspect.all: true
mcmmo.commands.ability: mcmmo.commands.ability:
description: Allows access to the mcability command description: Allows access to the mcability command
mcmmo.commands.ptp: mcmmo.commands.ptp:
@ -363,6 +370,13 @@ permissions:
description: Allows access to the inspect command description: Allows access to the inspect command
mcmmo.commands.party: mcmmo.commands.party:
description: Allows acces to the party command description: Allows acces to the party command
mcmmo.commands.inspect:
description: Allows players to view other player's stats
mcmmo.commands.inspect.offline:
description: Allows players to view offline player's stats
mcmmo.commands.inspect.all:
description: Bypasses distance restriction
mcmmo.chat.*: mcmmo.chat.*:
description: Implies all mcmmo.chat permissions. (Warning, contains adminchat) description: Implies all mcmmo.chat permissions. (Warning, contains adminchat)
children: children:
@ -372,6 +386,7 @@ permissions:
description: Allows participation in admin chat description: Allows participation in admin chat
mcmmo.chat.partychat: mcmmo.chat.partychat:
description: Allows participation in party chat description: Allows participation in party chat
mcmmo.skills.*: mcmmo.skills.*:
description: Implies all mcmmo.skills permissions. description: Implies all mcmmo.skills permissions.
children: children: