From 680baa68733ee3ea89b350d0e8cd277cedbea529 Mon Sep 17 00:00:00 2001 From: Blake Bartenbach Date: Mon, 23 Apr 2012 07:26:58 -0500 Subject: [PATCH] Added /mcstats as a clone of /inspect --- src/main/META-INF/MANIFEST.MF | 2 + .../gmail/nossr50/commands/CommandHelper.java | 5 +- .../commands/general/McstatsCommand.java | 104 ++++++++++++++++-- src/main/java/com/gmail/nossr50/mcMMO.java | 4 +- src/main/resources/config.yml | 6 +- .../resources/locale/locale_en_us.properties | 14 ++- src/main/resources/plugin.yml | 23 +++- 7 files changed, 128 insertions(+), 30 deletions(-) create mode 100644 src/main/META-INF/MANIFEST.MF diff --git a/src/main/META-INF/MANIFEST.MF b/src/main/META-INF/MANIFEST.MF new file mode 100644 index 000000000..58630c02e --- /dev/null +++ b/src/main/META-INF/MANIFEST.MF @@ -0,0 +1,2 @@ +Manifest-Version: 1.0 + diff --git a/src/main/java/com/gmail/nossr50/commands/CommandHelper.java b/src/main/java/com/gmail/nossr50/commands/CommandHelper.java index c463f4e18..13faec5fe 100644 --- a/src/main/java/com/gmail/nossr50/commands/CommandHelper.java +++ b/src/main/java/com/gmail/nossr50/commands/CommandHelper.java @@ -10,6 +10,8 @@ import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.locale.mcLocale; import com.gmail.nossr50.skills.Skills; +import java.util.logging.Logger; + public class CommandHelper { /** @@ -46,7 +48,6 @@ public class CommandHelper { * * @param inspect The player to retrieve stats for * @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) { if (Skills.hasGatheringSkills(inspect)) { @@ -85,7 +86,6 @@ public class CommandHelper { * * @param inspect The player to retrieve stats for * @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) { if (Skills.hasCombatSkills(inspect)) { @@ -124,7 +124,6 @@ public class CommandHelper { * * @param inspect The player to retrieve stats for * @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) { if (Skills.hasMiscSkills(inspect)) { diff --git a/src/main/java/com/gmail/nossr50/commands/general/McstatsCommand.java b/src/main/java/com/gmail/nossr50/commands/general/McstatsCommand.java index 8127a7dd7..833a4d72e 100644 --- a/src/main/java/com/gmail/nossr50/commands/general/McstatsCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/general/McstatsCommand.java @@ -1,5 +1,9 @@ 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.CommandExecutor; import org.bukkit.command.CommandSender; @@ -12,24 +16,100 @@ import com.gmail.nossr50.locale.mcLocale; public class McstatsCommand implements CommandExecutor { + + private mcMMO instance; + + + public McstatsCommand(mcMMO instance) { + this.instance = instance; + } + + + @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (CommandHelper.noConsoleUsage(sender)) { - return true; - } - Player player = (Player) sender; - PlayerProfile PP = Users.getProfile(player); + PlayerProfile PP; + Player player; - player.sendMessage(mcLocale.getString("mcPlayerListener.YourStats")); - player.sendMessage(mcLocale.getString("mcPlayerListener.NoSkillNote")); + switch (args.length) { + case 0: + if (CommandHelper.noConsoleUsage(sender)) { + return true; + } - CommandHelper.printGatheringSkills(player); - CommandHelper.printCombatSkills(player); - CommandHelper.printMiscSkills(player); + player = (Player) sender; + PP = Users.getProfile(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; + } } -} diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index f09d04075..d222d3474 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -173,7 +173,7 @@ public class mcMMO extends JavaPlugin { *
* 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 */ public PlayerProfile getPlayerProfileByName(String playerName) { @@ -271,7 +271,7 @@ public class mcMMO extends JavaPlugin { } if (LoadProperties.mcstatsEnable) { - getCommand("mcstats").setExecutor(new McstatsCommand()); + getCommand("mcstats").setExecutor(new McstatsCommand(this)); } //Party commands diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index f42ddf16c..bcea298c8 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -259,11 +259,11 @@ Experience: Multiplier: Animals: 1.0 Creeper: 4.0 - Skeleton: 2.0 - Spider: 3.0 + Skeleton: 3.0 + Spider: 2.0 Zombie: 2.0 Pig_Zombie: 3.0 - Enderman: 2.0 + Enderman: 4.0 Cave_Spider: 3.0 Silverfish: 3.0 Blaze: 3.0 diff --git a/src/main/resources/locale/locale_en_us.properties b/src/main/resources/locale/locale_en_us.properties index 9bf29c668..f9d3b8ae6 100644 --- a/src/main/resources/locale/locale_en_us.properties +++ b/src/main/resources/locale/locale_en_us.properties @@ -141,8 +141,9 @@ m.EffectsMining1_0=Super Breaker (ABILITY) m.EffectsMining1_1=Speed+, Triple Drop Chance m.EffectsMining2_0=Double Drops m.EffectsMining2_1=Double the normal loot -m.EffectsMining2_0=Double Drops -m.EffectsMining2_1=Double the normal loot +//Duplicates +//m.EffectsMining2_0=Double Drops +//m.EffectsMining2_1=Double the normal loot m.MiningDoubleDropChance=[[RED]]Double Drop Chance: [[YELLOW]]{0}% m.MiningSuperBreakerLength=[[RED]]Super Breaker Length: [[YELLOW]]{0}s 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.invalid=[[RED]]That is not a valid skillname! Try /xplock mining m.SkillFishing=FISHING +//Duplicate +//m.SkillFishing=FISHING mcPlayerListener.FishingSkill=Fishing: Skills.FishingUp=[[YELLOW]]Fishing skill increased by {0}. Total ({1}) 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}% Fishing.MagicFound=[[GRAY]]You feel a touch of magic with this catch... Fishing.ItemFound=[[GRAY]]Treasure found! -m.SkillFishing=FISHING m.XPGainFishing=Fishing (Go figure!) m.EffectsFishing1_0=Treasure Hunter (Passive) m.EffectsFishing1_1=Fish up misc objects @@ -401,7 +403,7 @@ Skills.GigaDrillBreakerPlayerOff=[[RED]]Giga Drill Breaker[[GREEN]] has worn off Skills.SerratedStrikesPlayerOff=[[RED]]Serrated Strikes[[GREEN]] has worn off for [[YELLOW]]{0} Skills.BlastMiningPlayer=[[GREEN]]{0}[[DARK_GREEN]] has used [[RED]]Blast Mining! Skills.YourBlastMining=[[GREEN]]Your [[YELLOW]]Blast Mining [[GREEN]]ability is refreshed! -TreeFeller.AxeSplinters=[[RED]]YOUR AXE SPLINTERS INTO DOZENS OF PIECES +TreeFeller.AxeSplinters=[[RED]]YOUR AXE SPLINTERS INTO DOZENS OF PIECES Acrobatics.GracefulRoll=[[GREEN]]**GRACEFUL ROLL** Acrobatics.Dodge=[[GREEN]]**DODGE** Acrobatics.Roll=**ROLL** @@ -433,12 +435,12 @@ m.EffectsTaming7_2=[[GRAY]]COTW HOW-TO: Crouch and right click with {0} Bones/Fi 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]]) 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! Inspect.Stats=[[GREEN]]mcMMO Stats for [[YELLOW]]{0} Inspect.OfflineStats=mcMMO Stats for Offline Player [[YELLOW]]{0} Stats.GatheringHeader=[[GOLD]]-=GATHERING SKILLS=- Stats.CombatHeader=[[GOLD]]-=COMBAT SKILLS=- -Stats.MiscHeader=[[GOLD]]-=MISC SKILLS=- +Stats.MiscHeader=[[GOLD]]-=MISC SKILLS=- m.ArcherySkillShot=[[RED]]Skill Shot Bonus Damage: [[YELLOW]]{0}% Commands.NoConsole=This command does not support console usage. \ No newline at end of file diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index d2b56fe81..c4b122d05 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -36,7 +36,7 @@ commands: description: Make yourself invulnerable permission: mcmmo.tools.mcgod mcstats: - description: Shows your mcMMO stats and xp + description: Shows player mcMMO stats and xp mcremove: description: Remove a user from the database permission: mcmmo.tools.mcremove @@ -90,6 +90,7 @@ commands: a: description: Toggle Admin chat or send admin chat messages permission: mcmmo.chat.adminchat + permissions: mcmmo.*: description: Implies all mcmmo permissions. @@ -120,6 +121,7 @@ permissions: description: Allows access to mmoupdate and other sensitive commands mcmmo.bypass.arcanebypass: description: Allows user to bypass Arcane Repair so he will never lose enchantments + mcmmo.tools.*: description: Implies all mcmmo.tools permissions. children: @@ -135,6 +137,7 @@ permissions: description: Allows access to mcgod command mcmmo.tools.mcremove: decription: Allows access to mcremove command + mcmmo.ability.*: description: Implies all mcmmo.ability permissions. children: @@ -347,14 +350,18 @@ permissions: mcmmo.item.chimaerawing: description: Allows use of Chimaera Wing item mcmmo.motd: - description: Allows access to the motd + description: Allows access to the motd + mcmmo.commands.*: description: Implies all mcmmo.commands permissions. children: mcmmo.commands.ability: true mcmmo.commands.ptp: 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: description: Allows access to the mcability command mcmmo.commands.ptp: @@ -362,7 +369,14 @@ permissions: mcmmo.commands.inspect: description: Allows access to the inspect command 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.*: description: Implies all mcmmo.chat permissions. (Warning, contains adminchat) children: @@ -372,6 +386,7 @@ permissions: description: Allows participation in admin chat mcmmo.chat.partychat: description: Allows participation in party chat + mcmmo.skills.*: description: Implies all mcmmo.skills permissions. children: