Replacing Whois command with Inspect command

This commit is contained in:
nossr50 2012-02-29 09:20:58 -08:00
parent f2fccd4a64
commit 0b43dd2747
6 changed files with 100 additions and 102 deletions

View File

@ -0,0 +1,93 @@
package com.gmail.nossr50.commands.general;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.skills.Skills;
public class InspectCommand implements CommandExecutor {
private final mcMMO plugin;
public InspectCommand(mcMMO instance) {
this.plugin = instance;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = null;
if (sender instanceof Player) {
player = (Player) sender;
}
if (player != null && !mcPermissions.getInstance().whois(player)) {
sender.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
return true;
}
if (args.length < 1) {
sender.sendMessage(ChatColor.RED + "Proper usage is /whois <playername>");
return true;
}
// if split[1] is a player
if (plugin.getServer().getPlayer(args[0]) != null)
{
Player target = plugin.getServer().getPlayer(args[0]);
PlayerProfile PPt = Users.getProfile(target);
//If they are not an Op they have to be close
if(sender instanceof Player && !player.isOp() && !m.isNear(player.getLocation(), target.getLocation(), 5))
{
sender.sendMessage("You are too far away to inspect that player!");
}
sender.sendMessage(ChatColor.GREEN + "mcMMO Stats for " + ChatColor.YELLOW + target.getName());
sender.sendMessage(ChatColor.GOLD + "-=GATHERING SKILLS=-");
if (mcPermissions.getInstance().excavation(target))
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.ExcavationSkill"), PPt.getSkillLevel(SkillType.EXCAVATION), PPt.getSkillXpLevel(SkillType.EXCAVATION), PPt.getXpToLevel(SkillType.EXCAVATION)));
if (mcPermissions.getInstance().fishing(target))
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.FishingSkill"), PPt.getSkillLevel(SkillType.FISHING), PPt.getSkillXpLevel(SkillType.FISHING), PPt.getXpToLevel(SkillType.FISHING)));
if (mcPermissions.getInstance().herbalism(target))
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.HerbalismSkill"), PPt.getSkillLevel(SkillType.HERBALISM), PPt.getSkillXpLevel(SkillType.HERBALISM), PPt.getXpToLevel(SkillType.HERBALISM)));
if (mcPermissions.getInstance().mining(target))
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.MiningSkill"), PPt.getSkillLevel(SkillType.MINING), PPt.getSkillXpLevel(SkillType.MINING), PPt.getXpToLevel(SkillType.MINING)));
if (mcPermissions.getInstance().woodcutting(target))
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.WoodcuttingSkill"), PPt.getSkillLevel(SkillType.WOODCUTTING), PPt.getSkillXpLevel(SkillType.WOODCUTTING), PPt.getXpToLevel(SkillType.WOODCUTTING)));
sender.sendMessage(ChatColor.GOLD + "-=COMBAT SKILLS=-");
if (mcPermissions.getInstance().axes(target))
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.AxesSkill"), PPt.getSkillLevel(SkillType.AXES), PPt.getSkillXpLevel(SkillType.AXES), PPt.getXpToLevel(SkillType.AXES)));
if (mcPermissions.getInstance().archery(player))
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.ArcherySkill"), PPt.getSkillLevel(SkillType.ARCHERY), PPt.getSkillXpLevel(SkillType.ARCHERY), PPt.getXpToLevel(SkillType.ARCHERY)));
if (mcPermissions.getInstance().swords(target))
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.SwordsSkill"), PPt.getSkillLevel(SkillType.SWORDS), PPt.getSkillXpLevel(SkillType.SWORDS), PPt.getXpToLevel(SkillType.SWORDS)));
if (mcPermissions.getInstance().taming(target))
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.TamingSkill"), PPt.getSkillLevel(SkillType.TAMING), PPt.getSkillXpLevel(SkillType.TAMING), PPt.getXpToLevel(SkillType.TAMING)));
if (mcPermissions.getInstance().unarmed(target))
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.UnarmedSkill"), PPt.getSkillLevel(SkillType.UNARMED), PPt.getSkillXpLevel(SkillType.UNARMED), PPt.getXpToLevel(SkillType.UNARMED)));
sender.sendMessage(ChatColor.GOLD + "-=MISC SKILLS=-");
if (mcPermissions.getInstance().acrobatics(target))
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.AcrobaticsSkill"), PPt.getSkillLevel(SkillType.ACROBATICS), PPt.getSkillXpLevel(SkillType.ACROBATICS), PPt.getXpToLevel(SkillType.ACROBATICS)));
if (mcPermissions.getInstance().repair(target))
sender.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.RepairSkill"), PPt.getSkillLevel(SkillType.REPAIR), PPt.getSkillXpLevel(SkillType.REPAIR), PPt.getXpToLevel(SkillType.REPAIR)));
sender.sendMessage(mcLocale.getString("mcPlayerListener.PowerLevel") + ChatColor.GREEN + (m.getPowerLevel(target)));
} else {
sender.sendMessage("That is not a valid player!");
}
return true;
}
}

View File

@ -1,95 +0,0 @@
package com.gmail.nossr50.commands.general;
import org.bukkit.ChatColor;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
import com.gmail.nossr50.Users;
import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.skills.Skills;
public class WhoisCommand implements CommandExecutor {
private final mcMMO plugin;
public WhoisCommand(mcMMO instance) {
this.plugin = instance;
}
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
Player player = null;
if (sender instanceof Player) {
player = (Player) sender;
}
if (player != null && !mcPermissions.getInstance().whois(player)) {
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
return true;
}
if (!(sender instanceof Player)) {
sender.sendMessage("This command does not support console useage.");
return true;
}
if (args.length < 1) {
player.sendMessage(ChatColor.RED + "Proper usage is /whois <playername>");
return true;
}
// if split[1] is a player
if (plugin.getServer().getPlayer(args[0]) != null) {
Player target = plugin.getServer().getPlayer(args[0]);
PlayerProfile PPt = Users.getProfile(target);
player.sendMessage(ChatColor.GREEN + "~~WHOIS RESULTS~~");
player.sendMessage(target.getName());
if (PPt.inParty())
player.sendMessage("Party: " + PPt.getParty());
player.sendMessage("Health: " + target.getHealth() + ChatColor.GRAY + " (20 is full health)");
player.sendMessage("OP: " + target.isOp());
player.sendMessage(ChatColor.GREEN + "mcMMO Stats for " + ChatColor.YELLOW + target.getName());
player.sendMessage(ChatColor.GOLD + "-=GATHERING SKILLS=-");
if (mcPermissions.getInstance().excavation(target))
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.ExcavationSkill"), PPt.getSkillLevel(SkillType.EXCAVATION), PPt.getSkillXpLevel(SkillType.EXCAVATION), PPt.getXpToLevel(SkillType.EXCAVATION)));
if (mcPermissions.getInstance().fishing(target))
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.FishingSkill"), PPt.getSkillLevel(SkillType.FISHING), PPt.getSkillXpLevel(SkillType.FISHING), PPt.getXpToLevel(SkillType.FISHING)));
if (mcPermissions.getInstance().herbalism(target))
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.HerbalismSkill"), PPt.getSkillLevel(SkillType.HERBALISM), PPt.getSkillXpLevel(SkillType.HERBALISM), PPt.getXpToLevel(SkillType.HERBALISM)));
if (mcPermissions.getInstance().mining(target))
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.MiningSkill"), PPt.getSkillLevel(SkillType.MINING), PPt.getSkillXpLevel(SkillType.MINING), PPt.getXpToLevel(SkillType.MINING)));
if (mcPermissions.getInstance().woodcutting(target))
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.WoodcuttingSkill"), PPt.getSkillLevel(SkillType.WOODCUTTING), PPt.getSkillXpLevel(SkillType.WOODCUTTING), PPt.getXpToLevel(SkillType.WOODCUTTING)));
player.sendMessage(ChatColor.GOLD + "-=COMBAT SKILLS=-");
if (mcPermissions.getInstance().axes(target))
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.AxesSkill"), PPt.getSkillLevel(SkillType.AXES), PPt.getSkillXpLevel(SkillType.AXES), PPt.getXpToLevel(SkillType.AXES)));
if (mcPermissions.getInstance().archery(player))
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.ArcherySkill"), PPt.getSkillLevel(SkillType.ARCHERY), PPt.getSkillXpLevel(SkillType.ARCHERY), PPt.getXpToLevel(SkillType.ARCHERY)));
if (mcPermissions.getInstance().swords(target))
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.SwordsSkill"), PPt.getSkillLevel(SkillType.SWORDS), PPt.getSkillXpLevel(SkillType.SWORDS), PPt.getXpToLevel(SkillType.SWORDS)));
if (mcPermissions.getInstance().taming(target))
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.TamingSkill"), PPt.getSkillLevel(SkillType.TAMING), PPt.getSkillXpLevel(SkillType.TAMING), PPt.getXpToLevel(SkillType.TAMING)));
if (mcPermissions.getInstance().unarmed(target))
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.UnarmedSkill"), PPt.getSkillLevel(SkillType.UNARMED), PPt.getSkillXpLevel(SkillType.UNARMED), PPt.getXpToLevel(SkillType.UNARMED)));
player.sendMessage(ChatColor.GOLD + "-=MISC SKILLS=-");
if (mcPermissions.getInstance().acrobatics(target))
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.AcrobaticsSkill"), PPt.getSkillLevel(SkillType.ACROBATICS), PPt.getSkillXpLevel(SkillType.ACROBATICS), PPt.getXpToLevel(SkillType.ACROBATICS)));
if (mcPermissions.getInstance().repair(target))
player.sendMessage(Skills.getSkillStats(mcLocale.getString("mcPlayerListener.RepairSkill"), PPt.getSkillLevel(SkillType.REPAIR), PPt.getSkillXpLevel(SkillType.REPAIR), PPt.getXpToLevel(SkillType.REPAIR)));
player.sendMessage(mcLocale.getString("mcPlayerListener.PowerLevel") + ChatColor.GREEN + (m.getPowerLevel(target)));
}
return true;
}
}

View File

@ -28,7 +28,7 @@ public class LoadProperties {
xplockEnable, xpbar, xpicon, partybar, xprateEnable, spoutEnabled,
donateMessage, chimaeraWingEnable, xpGainsMobSpawners,
mccEnable, mcmmoEnable, partyEnable, inviteEnable, acceptEnable,
whoisEnable, mcstatsEnable, addxpEnable, ptpEnable, mmoeditEnable, mcremoveEnable,
inspectEnable, mcstatsEnable, addxpEnable, ptpEnable, mmoeditEnable, mcremoveEnable,
mcgodEnable, mcabilityEnable, mctopEnable,
addlevelsEnable, mcrefreshEnable, aEnable, pEnable, enableMotd,
enableCobbleToMossy, useMySQL, toolsLoseDurabilityFromAbilities,
@ -381,7 +381,7 @@ public class LoadProperties {
mcremoveEnable = readBoolean("Commands.mcremove.Enable", true);
ptpEnable = readBoolean("Commands.ptp.Enabled", true);
partyEnable = readBoolean("Commands.party.Enabled", true);
whoisEnable = readBoolean("Commands.whois.Enabled", true);
inspectEnable = readBoolean("Commands.inspect.Enabled", true);
inviteEnable = readBoolean("Commands.invite.Enabled", true);
acceptEnable = readBoolean("Commands.accept.Enabled", true);
aEnable = readBoolean("Commands.a.Enabled", true);

View File

@ -325,7 +325,7 @@ public class mcMMO extends JavaPlugin
if(LoadProperties.mmoeditEnable) getCommand("mmoedit").setExecutor(new MmoeditCommand(this));
getCommand("mmoupdate").setExecutor(new MmoupdateCommand());
if(LoadProperties.mcstatsEnable) getCommand("mcstats").setExecutor(new McstatsCommand(this));
if(LoadProperties.whoisEnable) getCommand("whois").setExecutor(new WhoisCommand(this));
if(LoadProperties.inspectEnable) getCommand("inspect").setExecutor(new InspectCommand(this));
if(LoadProperties.xprateEnable) getCommand("xprate").setExecutor(new XprateCommand());
//Spout commands

View File

@ -259,7 +259,7 @@ Commands:
Enabled: true
xplock:
Enabled: true
whois:
inspect:
Enabled: true
mcc:
Enabled: true

View File

@ -49,7 +49,7 @@ commands:
party:
description: Create/join a party
permission: mcmmo.commands.party
whois:
inspect:
description: View mcMMO stats of another player
invite:
description: Invite a player into your party
@ -172,13 +172,13 @@ permissions:
children:
mcmmo.commands.ability: true
mcmmo.commands.ptp: true
mcmmo.commands.whois: true
mcmmo.commands.inspect: true
mcmmo.commands.party: true
mcmmo.commands.ability:
description:
mcmmo.commands.ptp:
description:
mcmmo.commands.whois:
mcmmo.commands.inspect:
description:
mcmmo.commands.party:
description: