Command & locale updates.

This commit is contained in:
GJ 2012-04-22 19:34:34 -04:00
parent 66b4388e64
commit c18b3e9114
15 changed files with 283 additions and 166 deletions

View File

@ -30,7 +30,7 @@ public class AddlevelsCommand implements CommandExecutor{
int levels; int levels;
SkillType skill; SkillType skill;
String skillName; String skillName;
String usage = ChatColor.RED + "Proper usage is /addlevels [playername] <skill> <level>"; //TODO: Needs more locale. String usage = ChatColor.RED + "Proper usage is /addlevels [player] <skill> <level>"; //TODO: Needs more locale.
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mmoedit")) { if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mmoedit")) {
return true; return true;
@ -39,7 +39,12 @@ public class AddlevelsCommand implements CommandExecutor{
switch (args.length) { switch (args.length) {
case 2: case 2:
if (sender instanceof Player) { if (sender instanceof Player) {
if (m.isInt(args[1]) && Skills.isSkill(args[0])) { if (!Skills.isSkill(args[0])) {
sender.sendMessage(mcLocale.getString("Commands.Skill.Invalid"));
return true;
}
if (m.isInt(args[1])) {
modifiedPlayer = (Player) sender; modifiedPlayer = (Player) sender;
levels = Integer.valueOf(args[1]); levels = Integer.valueOf(args[1]);
skill = Skills.getSkillType(args[0]); skill = Skills.getSkillType(args[0]);
@ -72,7 +77,12 @@ public class AddlevelsCommand implements CommandExecutor{
return true; return true;
} }
if (m.isInt(args[2]) && Skills.isSkill(args[1])) { if (!Skills.isSkill(args[1])) {
sender.sendMessage(mcLocale.getString("Commands.Skill.Invalid"));
return true;
}
if (m.isInt(args[2])) {
levels = Integer.valueOf(args[2]); levels = Integer.valueOf(args[2]);
skill = Skills.getSkillType(args[1]); skill = Skills.getSkillType(args[1]);
String message; String message;

View File

@ -11,6 +11,7 @@ import com.gmail.nossr50.m;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper; import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.SkillType; import com.gmail.nossr50.datatypes.SkillType;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.skills.Skills; import com.gmail.nossr50.skills.Skills;
//TODO: Any way we can make this work for offline use? //TODO: Any way we can make this work for offline use?
@ -36,7 +37,12 @@ public class AddxpCommand implements CommandExecutor {
switch (args.length) { switch (args.length) {
case 2: case 2:
if (sender instanceof Player) { if (sender instanceof Player) {
if (m.isInt(args[1]) && Skills.isSkill(args[0])) { if (!Skills.isSkill(args[1])) {
sender.sendMessage(mcLocale.getString("Commands.Skill.Invalid"));
return true;
}
if (m.isInt(args[1])) {
modifiedPlayer = (Player) sender; modifiedPlayer = (Player) sender;
xp = Integer.valueOf(args[1]); xp = Integer.valueOf(args[1]);
skill = Skills.getSkillType(args[0]); skill = Skills.getSkillType(args[0]);
@ -59,6 +65,9 @@ public class AddxpCommand implements CommandExecutor {
Skills.XpCheckSkill(skill, modifiedPlayer); Skills.XpCheckSkill(skill, modifiedPlayer);
} }
} }
else {
sender.sendMessage(usage);
}
} }
else { else {
sender.sendMessage(usage); sender.sendMessage(usage);
@ -70,7 +79,17 @@ public class AddxpCommand implements CommandExecutor {
modifiedPlayer = plugin.getServer().getPlayer(args[0]); modifiedPlayer = plugin.getServer().getPlayer(args[0]);
String playerName = modifiedPlayer.getName(); String playerName = modifiedPlayer.getName();
if (modifiedPlayer != null && m.isInt(args[2]) && Skills.isSkill(args[1])) { if (!Users.getProfile(modifiedPlayer).isLoaded()) {
sender.sendMessage(mcLocale.getString("Commands.DoesNotExist"));
return true;
}
if (!Skills.isSkill(args[1])) {
sender.sendMessage(mcLocale.getString("Commands.Skill.Invalid"));
return true;
}
if (m.isInt(args[2])) {
xp = Integer.valueOf(args[2]); xp = Integer.valueOf(args[2]);
skill = Skills.getSkillType(args[1]); skill = Skills.getSkillType(args[1]);
String message; String message;

View File

@ -25,7 +25,7 @@ public class InspectCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
OfflinePlayer target; OfflinePlayer target;
PlayerProfile PP; PlayerProfile PP;
String usage = "Proper usage is /inspect <playername>"; //TODO: Needs more locale. String usage = "Proper usage is /inspect <player>"; //TODO: Needs more locale.
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.inspect")) { if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.inspect")) {
return true; return true;

View File

@ -30,7 +30,7 @@ public class MmoeditCommand implements CommandExecutor {
int newValue; int newValue;
SkillType skill; SkillType skill;
String skillName; String skillName;
String usage = ChatColor.RED + "Proper usage is /mmoedit [playername] <skill> <level>"; //TODO: Needs more locale. String usage = ChatColor.RED + "Proper usage is /mmoedit [player] <skill> <level>"; //TODO: Needs more locale.
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mmoedit")) { if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mmoedit")) {
return true; return true;
@ -39,7 +39,12 @@ public class MmoeditCommand implements CommandExecutor {
switch (args.length) { switch (args.length) {
case 2: case 2:
if (sender instanceof Player) { if (sender instanceof Player) {
if (m.isInt(args[1]) && Skills.isSkill(args[0])) { if (!Skills.isSkill(args[0])) {
sender.sendMessage(mcLocale.getString("Commands.Skill.Invalid"));
return true;
}
if (m.isInt(args[1])) {
modifiedPlayer = (Player) sender; modifiedPlayer = (Player) sender;
newValue = Integer.valueOf(args[1]); newValue = Integer.valueOf(args[1]);
skill = Skills.getSkillType(args[0]); skill = Skills.getSkillType(args[0]);
@ -55,6 +60,9 @@ public class MmoeditCommand implements CommandExecutor {
PP.modifySkill(skill, newValue); PP.modifySkill(skill, newValue);
sender.sendMessage(ChatColor.GREEN + "Your level in " + skillName + " was set to " + newValue + "!"); //TODO: Needs more locale. sender.sendMessage(ChatColor.GREEN + "Your level in " + skillName + " was set to " + newValue + "!"); //TODO: Needs more locale.
} }
else {
sender.sendMessage(usage);
}
} }
else { else {
sender.sendMessage(usage); sender.sendMessage(usage);
@ -72,7 +80,12 @@ public class MmoeditCommand implements CommandExecutor {
return true; return true;
} }
if (m.isInt(args[2]) && Skills.isSkill(args[1])) { if (!Skills.isSkill(args[1])) {
sender.sendMessage(mcLocale.getString("Commands.Skill.Invalid"));
return true;
}
if (m.isInt(args[2])) {
newValue = Integer.valueOf(args[2]); newValue = Integer.valueOf(args[2]);
skill = Skills.getSkillType(args[1]); skill = Skills.getSkillType(args[1]);
String message; String message;

View File

@ -24,7 +24,7 @@ public class McrefreshCommand implements CommandExecutor {
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
OfflinePlayer player; OfflinePlayer player;
PlayerProfile PP; PlayerProfile PP;
String usage = ChatColor.RED + "Proper usage is /mcrefresh [playername]"; //TODO: Needs more locale String usage = ChatColor.RED + "Proper usage is /mcrefresh [player]"; //TODO: Needs more locale
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mcrefresh")) { if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mcrefresh")) {
return true; return true;

View File

@ -27,7 +27,7 @@ public class McremoveCommand 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 playerName; String playerName;
String usage = ChatColor.RED + "Proper usage is /mcremove <playername>"; //TODO: Needs more locale. String usage = ChatColor.RED + "Proper usage is /mcremove <player>"; //TODO: Needs more locale.
String success; String success;
if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mcremove")) { if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mcremove")) {

View File

@ -18,7 +18,7 @@ public class MctopCommand 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 = ChatColor.RED + "Proper usage is /mctop [skillname] [page]"; //TODO: Needs more locale. String usage = ChatColor.RED + "Proper usage is /mctop [skill] [page]"; //TODO: Needs more locale.
if (!LoadProperties.useMySQL) { if (!LoadProperties.useMySQL) {
switch (args.length) { switch (args.length) {
@ -34,13 +34,18 @@ public class MctopCommand implements CommandExecutor {
flatfileDisplay(1, args[0].toUpperCase(), sender); flatfileDisplay(1, args[0].toUpperCase(), sender);
} }
else { else {
sender.sendMessage(usage); sender.sendMessage(mcLocale.getString("Commands.Skill.Invalid"));
} }
return true; return true;
case 2: case 2:
if (Skills.isSkill(args[0]) && m.isInt(args[1])) { if (!Skills.isSkill(args[0])) {
sender.sendMessage(mcLocale.getString("Commands.Skill.Invalid"));
return true;
}
if (m.isInt(args[1])) {
flatfileDisplay(Integer.valueOf(args[1]), args[0].toUpperCase(), sender); flatfileDisplay(Integer.valueOf(args[1]), args[0].toUpperCase(), sender);
} }
else { else {
@ -70,19 +75,26 @@ public class MctopCommand implements CommandExecutor {
sqlDisplay(1, args[0].toLowerCase(), sender); sqlDisplay(1, args[0].toLowerCase(), sender);
} }
else { else {
sender.sendMessage(usage); sender.sendMessage(mcLocale.getString("Commands.Skill.Invalid"));
} }
return true; return true;
case 2: case 2:
if (Skills.isSkill(args[0]) && m.isInt(args[1])) { if (!Skills.isSkill(args[0])) {
sender.sendMessage(mcLocale.getString("Commands.Skill.Invalid"));
return true;
}
if (m.isInt(args[1])) {
sqlDisplay(Integer.valueOf(args[1]), args[0].toLowerCase(), sender); sqlDisplay(Integer.valueOf(args[1]), args[0].toLowerCase(), sender);
} }
else { else {
sender.sendMessage(usage); sender.sendMessage(usage);
} }
return true;
default: default:
sender.sendMessage(usage); sender.sendMessage(usage);
return true; return true;

View File

@ -13,6 +13,7 @@ import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.mcLocale; import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.party.Party; import com.gmail.nossr50.party.Party;
//TODO: Make this work from console.
public class InviteCommand implements CommandExecutor { public class InviteCommand implements CommandExecutor {
private final mcMMO plugin; private final mcMMO plugin;
@ -22,7 +23,7 @@ public class InviteCommand 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 = ChatColor.RED + "Proper usage is /invite <playername>"; //TODO: Needs more locale. String usage = ChatColor.RED + "Proper usage is /invite <player>"; //TODO: Needs more locale.
if (CommandHelper.noConsoleUsage(sender)) { if (CommandHelper.noConsoleUsage(sender)) {
return true; return true;
@ -52,14 +53,20 @@ public class InviteCommand implements CommandExecutor {
PPt.modifyInvite(PP.getParty()); PPt.modifyInvite(PP.getParty());
player.sendMessage(mcLocale.getString("Commands.Invite.Success")); player.sendMessage(mcLocale.getString("Commands.Invite.Success"));
target.sendMessage(mcLocale.getString("Commands.Party.Invite.0", new Object[] { PPt.getInvite(), player.getName() })); target.sendMessage(mcLocale.getString("Commands.Party.Invite.0", new Object[] { PPt.getInvite(), player.getName() }));
target.sendMessage(mcLocale.getString("Commands.Party.Invite.1")); target.sendMessage(mcLocale.getString("Commands.Party.Invite.1"));
return true;
} }
else { else {
player.sendMessage(mcLocale.getString("Party.Locked")); player.sendMessage(mcLocale.getString("Party.Locked"));
return true; return true;
} }
} }
else {
player.sendMessage(mcLocale.getString("Party.Player.Invalid"));
return true;
}
default: default:
sender.sendMessage(usage); sender.sendMessage(usage);

View File

@ -24,7 +24,7 @@ public class PCommand 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) {
PlayerProfile PP; PlayerProfile PP;
String usage = ChatColor.RED + "Proper usage is /p <partyname> <message>"; //TODO: Needs more locale. String usage = ChatColor.RED + "Proper usage is /p <party-name> <message>"; //TODO: Needs more locale.
if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party")) { if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party")) {
return true; return true;
@ -81,7 +81,7 @@ public class PCommand implements CommandExecutor {
return true; return true;
} }
if (!Party.getInstance().getParties().contains(args[0])) { if (!Party.getInstance().isParty(args[0])) {
sender.sendMessage(mcLocale.getString("Party.InvalidName")); sender.sendMessage(mcLocale.getString("Party.InvalidName"));
return true; return true;
} }

View File

@ -78,6 +78,11 @@ public class PartyCommand implements CommandExecutor {
return true; return true;
case 1: case 1:
if (!partyInstance.isParty(args[0])) {
sender.sendMessage(mcLocale.getString("Party.InvalidName"));
return true;
}
if (args[0].equalsIgnoreCase("q")) { if (args[0].equalsIgnoreCase("q")) {
if (inParty) { if (inParty) {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, partyName, null, EventReason.LEFT_PARTY); McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, partyName, null, EventReason.LEFT_PARTY);
@ -166,6 +171,11 @@ public class PartyCommand implements CommandExecutor {
return true; return true;
case 2: case 2:
if (!partyInstance.isParty(args[0])) {
sender.sendMessage(mcLocale.getString("Party.InvalidName"));
return true;
}
if (PP.inParty()) { if (PP.inParty()) {
if (args[0].equalsIgnoreCase("password")) { if (args[0].equalsIgnoreCase("password")) {
if (isLeader) { if (isLeader) {
@ -185,7 +195,7 @@ public class PartyCommand implements CommandExecutor {
Player target = plugin.getServer().getPlayer(args[1]); Player target = plugin.getServer().getPlayer(args[1]);
if (target == null) { if (target == null) {
player.sendMessage(mcLocale.getString("Party.CouldNotKick", new Object[] { args[1] })); player.sendMessage(mcLocale.getString("Party.Player.Invalid"));
return true; return true;
} }
@ -218,7 +228,7 @@ public class PartyCommand implements CommandExecutor {
Player target = plugin.getServer().getPlayer(args[1]); Player target = plugin.getServer().getPlayer(args[1]);
if (target == null) { if (target == null) {
player.sendMessage(mcLocale.getString("Party.CouldNotSetOwner")); player.sendMessage(mcLocale.getString("Party.Player.Invalid"));
return true; return true;
} }

View File

@ -8,7 +8,7 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.Users; import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.mcPermissions; import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.events.party.McMMOPartyTeleportEvent; import com.gmail.nossr50.events.party.McMMOPartyTeleportEvent;
@ -16,72 +16,73 @@ import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.party.Party; import com.gmail.nossr50.party.Party;
public class PtpCommand implements CommandExecutor { public class PtpCommand implements CommandExecutor {
private final mcMMO plugin; private final mcMMO plugin;
public PtpCommand(mcMMO instance) { public PtpCommand(mcMMO instance) {
this.plugin = instance; this.plugin = 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) {
String usage = ChatColor.RED + "Proper usage is /ptp <player>"; //TODO: Needs more locale.
if (!(sender instanceof Player)) { if (CommandHelper.noConsoleUsage(sender)) {
sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale. return true;
return true; }
}
Player player = (Player) sender; if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.ptp")) {
PlayerProfile PP = Users.getProfile(player); return true;
}
if (!mcPermissions.getInstance().partyTeleport(player)) { switch (args.length) {
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission")); case 1:
return true; Player player = (Player) sender;
} PlayerProfile PP = Users.getProfile(player);
if(!Party.getInstance().isParty(PP.getParty()))
{
player.sendMessage(ChatColor.RED+"You are not in a party!"); //TODO: Needs more locale.
return true;
}
if(PP.getRecentlyHurt()+(LoadProperties.ptpCommandCooldown*1000) > System.currentTimeMillis())
{
player.sendMessage(ChatColor.RED+"You've been hurt in the last " + LoadProperties.ptpCommandCooldown + " seconds and cannnot teleport."); //TODO: Needs more locale.
return true;
}
if (args.length < 1) {
player.sendMessage(ChatColor.RED + "Usage is /ptp <playername>"); //TODO: Needs more locale.
return true;
}
if (plugin.getServer().getPlayer(args[0]) == null) {
player.sendMessage("That is not a valid player"); //TODO: Needs more locale.
}
if (plugin.getServer().getPlayer(args[0]) != null) { if (!Party.getInstance().isInParty(player, PP)) {
Player target = plugin.getServer().getPlayer(args[0]); player.sendMessage(mcLocale.getString("Commands.Party.None"));
PlayerProfile PPt = Users.getProfile(target); return true;
}
if (target.isDead()) {
player.sendMessage(ChatColor.RED + "You can't teleport to dead players."); //TODO: Needs more locale.
return true;
}
if (PP.getParty().equals(PPt.getParty())) {
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, PP.getParty());
plugin.getServer().getPluginManager().callEvent(event);
if (!event.isCancelled()) { if (PP.getRecentlyHurt() + (LoadProperties.ptpCommandCooldown * 1000) > System.currentTimeMillis()) {
player.teleport(target); player.sendMessage(mcLocale.getString("Party.Teleport.Hurt", new Object[] { LoadProperties.ptpCommandCooldown }));
player.sendMessage(ChatColor.GREEN + "You have teleported to " + target.getName()); //TODO: Needs more locale. return true;
target.sendMessage(ChatColor.GREEN + player.getName() + " has teleported to you."); //TODO: Needs more locale. }
}
} else {
player.sendMessage(ChatColor.RED + "That player is in a different party than you."); //TODO: Needs more locale.
}
}
return true; Player target = plugin.getServer().getPlayer(args[0]);
}
if (target == null) {
player.sendMessage(mcLocale.getString("Party.Teleport.Invalid"));
return true;
}
if (target.isDead()) {
player.sendMessage(mcLocale.getString("Party.Teleport.Dead"));
return true;
}
if (Party.getInstance().inSameParty(player, target)) {
McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, PP.getParty());
plugin.getServer().getPluginManager().callEvent(event);
if (event.isCancelled()) {
return true;
}
player.teleport(target);
player.sendMessage(mcLocale.getString("Party.Teleport.Player", new Object[] { target.getName() }));
target.sendMessage(mcLocale.getString("Party.Teleport.Target", new Object[] { player.getName() }));
}
else {
player.sendMessage(mcLocale.getString("Party.NotInYourParty", new Object[] { target.getName() }));
return true;
}
return true;
default:
sender.sendMessage(usage);
return true;
}
}
} }

View File

@ -1,5 +1,6 @@
package com.gmail.nossr50.commands.spout; package com.gmail.nossr50.commands.spout;
import org.bukkit.ChatColor;
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;
@ -7,10 +8,12 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.Users; import com.gmail.nossr50.Users;
import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcMMO;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.HUDType; import com.gmail.nossr50.datatypes.HUDType;
import com.gmail.nossr50.datatypes.HUDmmo; import com.gmail.nossr50.datatypes.HUDmmo;
import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.PlayerProfile;
import com.gmail.nossr50.locale.mcLocale;
import com.gmail.nossr50.spout.SpoutStuff; import com.gmail.nossr50.spout.SpoutStuff;
public class MchudCommand implements CommandExecutor { public class MchudCommand implements CommandExecutor {
@ -20,38 +23,55 @@ public class MchudCommand implements CommandExecutor {
this.plugin = plugin; this.plugin = plugin;
} }
@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 (!LoadProperties.spoutEnabled) { String usage = ChatColor.RED + "Proper usage is /mchud <hud-type>"; //TODO: Locale
sender.sendMessage("This command is not enabled."); //TODO: Needs more locale. String invalid = ChatColor.RED + "That is not a valid HUD type."; //TODO: Locale
return true;
}
if (!(sender instanceof Player)) { if (CommandHelper.noConsoleUsage(sender)) {
sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale. return true;
return true; }
}
Player player = (Player) sender; if (!LoadProperties.spoutEnabled || !LoadProperties.xpbar) {
PlayerProfile PP = Users.getProfile(player); sender.sendMessage(mcLocale.getString("Commands.Disabled"));
return true;
if(args.length >= 1) }
{
for(HUDType x : HUDType.values()) switch (args.length) {
{ case 1:
if(x.toString().toLowerCase().equals(args[0].toLowerCase())) Player player = (Player) sender;
{ PlayerProfile PP = Users.getProfile(player);
if(SpoutStuff.playerHUDs.containsKey(player)) HUDType hud;
{
SpoutStuff.playerHUDs.get(player).resetHUD(); if (args[0].equalsIgnoreCase("disabled")) {
SpoutStuff.playerHUDs.remove(player); hud = HUDType.DISABLED;
PP.setHUDType(x); }
SpoutStuff.playerHUDs.put(player, new HUDmmo(player, plugin)); else if (args[0].equalsIgnoreCase("standard")) {
} hud = HUDType.STANDARD;
} }
} else if (args[0].equalsIgnoreCase("small")) {
} hud = HUDType.SMALL;
}
return true; else if (args[0].equalsIgnoreCase("retro")) {
} hud = HUDType.RETRO;
}
else {
player.sendMessage(invalid);
return true;
}
if (SpoutStuff.playerHUDs.containsKey(player)) {
SpoutStuff.playerHUDs.get(player).resetHUD();
SpoutStuff.playerHUDs.remove(player);
PP.setHUDType(hud);
SpoutStuff.playerHUDs.put(player, new HUDmmo(player, plugin));
}
return true;
default:
sender.sendMessage(usage);
return true;
}
}
} }

View File

@ -9,54 +9,71 @@ import org.bukkit.entity.Player;
import com.gmail.nossr50.Users; import com.gmail.nossr50.Users;
import com.gmail.nossr50.m; import com.gmail.nossr50.m;
import com.gmail.nossr50.mcPermissions; import com.gmail.nossr50.mcPermissions;
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.config.LoadProperties; import com.gmail.nossr50.config.LoadProperties;
import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.datatypes.PlayerProfile;
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 com.gmail.nossr50.spout.SpoutStuff; import com.gmail.nossr50.spout.SpoutStuff;
public class XplockCommand implements CommandExecutor { public class XplockCommand 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) {
if (!LoadProperties.spoutEnabled || !LoadProperties.xpbar || !LoadProperties.xplockEnable) { String usage = ChatColor.RED + "Proper usage is /xplock [skill]";
sender.sendMessage("This command is not enabled."); //TODO: Needs more locale.
return true;
}
if (!(sender instanceof Player)) { if (CommandHelper.noConsoleUsage(sender)) {
sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale. return true;
return true; }
}
Player player = (Player) sender; if (!LoadProperties.spoutEnabled || !LoadProperties.xpbar || !LoadProperties.xplockEnable) {
PlayerProfile PP = Users.getProfile(player); sender.sendMessage(mcLocale.getString("Commands.Disabled"));
return true;
}
if (args.length >= 1 && Skills.isSkill(args[0]) && mcPermissions.getInstance().permission(player, "mcmmo.skills." + Skills.getSkillType(args[0]).toString().toLowerCase())) { Player player = (Player) sender;
if (PP.getXpBarLocked()) { PlayerProfile PP = Users.getProfile(player);
PP.setSkillLock(Skills.getSkillType(args[0]));
player.sendMessage(mcLocale.getString("Commands.xplock.locked", new Object[] { m.getCapitalized(PP.getSkillLock().toString()) }));
} else {
PP.setSkillLock(Skills.getSkillType(args[0]));
PP.toggleXpBarLocked();
player.sendMessage(mcLocale.getString("Commands.xplock.locked", new Object[] { m.getCapitalized(PP.getSkillLock().toString()) }));
}
SpoutStuff.updateXpBar(player);
} else if (args.length < 1) {
if (PP.getXpBarLocked()) {
PP.toggleXpBarLocked();
player.sendMessage(mcLocale.getString("Commands.xplock.unlocked"));
} else if (PP.getLastGained() != null) {
PP.toggleXpBarLocked();
PP.setSkillLock(PP.getLastGained());
player.sendMessage(mcLocale.getString("Commands.xplock.locked", new Object[] { m.getCapitalized(PP.getSkillLock().toString()) }));
}
} else if (args.length >= 1 && !Skills.isSkill(args[0])) {
player.sendMessage("Commands.xplock.invalid");
} else if (args.length >= 2 && Skills.isSkill(args[0]) && !mcPermissions.getInstance().permission(player, "mcmmo.skills." + Skills.getSkillType(args[0]).toString().toLowerCase())) {
player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission"));
return true;
}
return true; switch (args.length) {
} case 0:
if (PP.getXpBarLocked()) {
PP.toggleXpBarLocked();
player.sendMessage(mcLocale.getString("Commands.xplock.unlocked"));
return true;
}
SkillType lastGained = PP.getLastGained();
if (lastGained != null) {
PP.toggleXpBarLocked();
PP.setSkillLock(lastGained);
player.sendMessage(mcLocale.getString("Commands.xplock.locked", new Object[] { m.getCapitalized(lastGained.toString()) }));
return true;
}
case 1:
if (Skills.isSkill(args[0])) {
if (mcPermissions.getInstance().permission(player, "mcmmo.skills." + args[0].toLowerCase())) {
PP.setXpBarLocked(true);
PP.setSkillLock(Skills.getSkillType(args[0]));
SpoutStuff.updateXpBar(player);
player.sendMessage(mcLocale.getString("Commands.xplock.locked", new Object[] { m.getCapitalized(args[0]) }));
return true;
}
else {
player.sendMessage(mcLocale.getString("mcMMO.NoPermission"));
return true;
}
}
else {
player.sendMessage(mcLocale.getString("Commands.Skill.Invalid"));
return true;
}
default:
player.sendMessage(usage);
return true;
}
}
} }

View File

@ -555,6 +555,10 @@ public class PlayerProfile {
save(); save();
} }
public void setXpBarLocked(boolean locked) {
xpbarlocked = locked;
}
public boolean getXpBarLocked() { public boolean getXpBarLocked() {
return xpbarlocked; return xpbarlocked;
} }

View File

@ -375,6 +375,7 @@ Commands.Ability.On=Ability use toggled [[GREEN]]on
Commands.AdminChat.Off=Admin Chat only [[RED]]Off Commands.AdminChat.Off=Admin Chat only [[RED]]Off
Commands.AdminChat.On=Admin Chat only [[GREEN]]On Commands.AdminChat.On=Admin Chat only [[GREEN]]On
Commands.AdminToggle=[[RED]]- Toggle admin chat Commands.AdminToggle=[[RED]]- Toggle admin chat
Commands.Disabled=[[RED]]This command is disabled.
Commands.DoesNotExist= [[RED]]Player does not exist in the database! Commands.DoesNotExist= [[RED]]Player does not exist in the database!
Commands.GodMode.Disabled=[[YELLOW]]mcMMO Godmode Disabled Commands.GodMode.Disabled=[[YELLOW]]mcMMO Godmode Disabled
Commands.GodMode.Enabled=[[YELLOW]]mcMMO Godmode Enabled Commands.GodMode.Enabled=[[YELLOW]]mcMMO Godmode Enabled
@ -382,9 +383,9 @@ Commands.GodMode.Forbidden=[mcMMO] God Mode not permitted on this world (See Per
Commands.Inspect=<player> [[RED]]- View detailed player info Commands.Inspect=<player> [[RED]]- View detailed player info
Commands.Invite.Accepted=[[GREEN]]Invite Accepted. You have joined party {0} Commands.Invite.Accepted=[[GREEN]]Invite Accepted. You have joined party {0}
Commands.Invite.Success=[[GREEN]]Invite sent successfully. Commands.Invite.Success=[[GREEN]]Invite sent successfully.
Commands.Leaderboards=<skillname> <page> [[RED]]- Leaderboards Commands.Leaderboards=<skill> <page> [[RED]]- Leaderboards
Commands.mcgod=[[RED]]- Toggle GodMode Commands.mcgod=[[RED]]- Toggle GodMode
Commands.mmoedit=[playername] <skill> <newvalue> [[RED]] - Modify target Commands.mmoedit=[player] <skill> <newvalue> [[RED]] - Modify target
Commands.ModDescription=[[RED]]- Read brief mod description Commands.ModDescription=[[RED]]- Read brief mod description
Commands.NoConsole=This command does not support console usage. Commands.NoConsole=This command does not support console usage.
Commands.Other=[[GREEN]]--OTHER COMMANDS-- Commands.Other=[[GREEN]]--OTHER COMMANDS--
@ -394,20 +395,21 @@ Commands.Party.Chat.On=Party Chat only [[GREEN]]On
Commands.Party.Commands=[[GREEN]]--PARTY COMMANDS-- Commands.Party.Commands=[[GREEN]]--PARTY COMMANDS--
Commands.Party.Invite.0=[[RED]]ALERT: [[GREEN]]You have received a party invite for {0} from {1} Commands.Party.Invite.0=[[RED]]ALERT: [[GREEN]]You have received a party invite for {0} from {1}
Commands.Party.Invite.1=[[YELLOW]]Type [[GREEN]]/accept[[YELLOW]] to accept the invite Commands.Party.Invite.1=[[YELLOW]]Type [[GREEN]]/accept[[YELLOW]] to accept the invite
Commands.Party.Invite=<playername> [[RED]]- Send party invite Commands.Party.Invite=<player> [[RED]]- Send party invite
Commands.Party.Join=Joined Party: {0} Commands.Party.Join=Joined Party: {0}
Commands.Party.Kick=[[RED]]You were kicked from party {0}! Commands.Party.Kick=[[RED]]You were kicked from party {0}!
Commands.Party.Leave=[[RED]]You have left that party Commands.Party.Leave=[[RED]]You have left that party
Commands.Party.Members=[[GREEN]]Party Members: {0} Commands.Party.Members=[[GREEN]]Party Members: {0}
Commands.Party.None=[[RED]]You are not in a party. Commands.Party.None=[[RED]]You are not in a party.
Commands.Party.Quit=[[RED]]- Leave your current party Commands.Party.Quit=[[RED]]- Leave your current party
Commands.Party.Teleport=<playername> [[RED]]- Teleport to party member Commands.Party.Teleport=<player> [[RED]]- Teleport to party member
Commands.Party.Toggle=[[RED]]- Toggle Party Chat Commands.Party.Toggle=[[RED]]- Toggle Party Chat
Commands.Party=<partyname> [[RED]]- Create/Join designated party Commands.Party=<party-name> [[RED]]- Create/Join designated party
Commands.PowerLevel.Leaderboard=[[YELLOW]]--mcMMO[[BLUE]] Power Level [[YELLOW]]Leaderboard-- Commands.PowerLevel.Leaderboard=[[YELLOW]]--mcMMO[[BLUE]] Power Level [[YELLOW]]Leaderboard--
Commands.PowerLevel=[[DARK_RED]]POWER LEVEL: [[GREEN]]{0} Commands.PowerLevel=[[DARK_RED]]POWER LEVEL: [[GREEN]]{0}
Commands.Skill.Invalid=[[RED]]That is not a valid skillname!
Commands.Skill.Leaderboard=[[YELLOW]]--mcMMO [[BLUE]]{0}[[YELLOW]] Leaderboard-- Commands.Skill.Leaderboard=[[YELLOW]]--mcMMO [[BLUE]]{0}[[YELLOW]] Leaderboard--
Commands.SkillInfo=/<skillname> [[RED]]- View detailed information about a skill Commands.SkillInfo=/<skill> [[RED]]- View detailed information about a skill
Commands.Stats.Self=YOUR STATS Commands.Stats.Self=YOUR STATS
Commands.Stats=[[RED]]- View your mcMMO stats Commands.Stats=[[RED]]- View your mcMMO stats
Commands.ToggleAbility=[[RED]]- Toggle ability activation with right click Commands.ToggleAbility=[[RED]]- Toggle ability activation with right click
@ -419,26 +421,29 @@ mcMMO.Wiki=[[GREEN]]http://mcmmo.wikia.com[[BLUE]] - mcMMO Wiki
##party ##party
Commands.Party.InParty=[[GREEN]]Party: {0} Commands.Party.InParty=[[GREEN]]Party: {0}
Party.CouldNotKick=[[DARK_RED]]Could not kick player {0} from the party
Party.CouldNotSetOwner=[[DARK_RED]]Could not set owner to {0}
Party.Forbidden=[mcMMO] Parties not permitted on this world (See Permissions) Party.Forbidden=[mcMMO] Parties not permitted on this world (See Permissions)
Party.Help.0=[[RED]]Proper usage is /party <partyname> to join or /party q to quit Party.Help.0=[[RED]]Proper usage is /party <party-name> to join or /party q to quit
Party.Help.1=[[RED]]To join a passworded party, use /party <partyname> <password> Party.Help.1=[[RED]]To join a passworded party, use /party <party-name> <password>
Party.Help.2=[[RED]]Consult /party ? for more information Party.Help.2=[[RED]]Consult /party ? for more information
Party.Help.3=[[RED]]Use /party <partyname> to join or /party q to quit Party.Help.3=[[RED]]Use /party <party-name> to join or /party q to quit
Party.Help.4=[[RED]]To lock or unlock your party, use /party <lock/unlock> Party.Help.4=[[RED]]To lock or unlock your party, use /party <lock/unlock>
Party.Help.5=[[RED]]To password protect your party, use /party password <password> Party.Help.5=[[RED]]To password protect your party, use /party password <password>
Party.Help.6=[[RED]]To kick a player from your party, use /party kick <player> Party.Help.6=[[RED]]To kick a player from your party, use /party kick <player>
Party.Help.7=[[RED]]To transfer ownership of your party, use /party owner <player> Party.Help.7=[[RED]]To transfer ownership of your party, use /party owner <player>
Party.InformedOnJoin={0} [[GREEN]] has joined your party Party.InformedOnJoin={0} [[GREEN]] has joined your party
Party.InformedOnQuit={0} [[GREEN]] has left your party Party.InformedOnQuit={0} [[GREEN]] has left your party
Party.InvalidName=[[DARK_RED]]That is not a valid party name Party.InvalidName=[[DARK_RED]]That is not a valid party name.
Party.IsLocked=[[RED]]This party is already locked! Party.IsLocked=[[RED]]This party is already locked!
Party.IsntLocked=[[RED]]This party is not locked! Party.IsntLocked=[[RED]]This party is not locked!
Party.Locked=[[RED]]Party is locked, only party leader may invite. Party.Locked=[[RED]]Party is locked, only party leader may invite.
Party.NotInYourParty=[[DARK_RED]]{0} is not in your party Party.NotInYourParty=[[DARK_RED]]{0} is not in your party
Party.NotOwner=[[DARK_RED]]You are not the party owner Party.NotOwner=[[DARK_RED]]You are not the party owner
Party.PasswordSet=[[GREEN]]Party password set to {0} Party.PasswordSet=[[GREEN]]Party password set to {0}
Party.Player.Invalid=[[RED]]That is not a valid player.
Party.Teleport.Dead=[[RED]]You can't teleport to a dead player.
Party.Teleport.Hurt=[[RED]]You've been hurt in the last {0} seconds and cannnot teleport.
Party.Teleport.Player=[[GREEN]]You have teleported to {0}.
Party.Teleport.Target=[[GREEN]]{0} has teleported to you.
Party.Unlocked=[[GRAY]]Party is unlocked Party.Unlocked=[[GRAY]]Party is unlocked
##xp ##xp
@ -455,7 +460,6 @@ Commands.XPGain.Taming=Animal Taming, or combat w/ your wolves
Commands.XPGain.Unarmed=Attacking Monsters Commands.XPGain.Unarmed=Attacking Monsters
Commands.XPGain.WoodCutting=Chopping down trees Commands.XPGain.WoodCutting=Chopping down trees
Commands.XPGain=[[DARK_GRAY]]XP GAIN: [[WHITE]]{0} Commands.XPGain=[[DARK_GRAY]]XP GAIN: [[WHITE]]{0}
Commands.xplock.invalid=[[RED]]That is not a valid skillname! Try /xplock mining
Commands.xplock.locked=[[GOLD]]Your XP BAR is now locked to {0}! 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.xprate.over=[[RED]]mcMMO XP Rate Event is OVER!! Commands.xprate.over=[[RED]]mcMMO XP Rate Event is OVER!!