diff --git a/Changelog.txt b/Changelog.txt index c225b66c2..3cd478851 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -32,7 +32,8 @@ Version 1.3.06-dev ! Changed party & admin chat handling to be nicer to developers ! Changed /mcrefresh to work from console ! Changed /mcrefresh to work for offline players - ! Changed UpdateXPBar function to hopefully avoid errors + ! Changed UpdateXPBar function to hopefully avoid errors + ! Changed /party to show offline party members Version 1.3.05 + Added Skill Shot to Archery which increases damage dealt by 10% every 50 skill levels (caps at 200%) diff --git a/src/main/java/com/gmail/nossr50/api/PartyAPI.java b/src/main/java/com/gmail/nossr50/api/PartyAPI.java index 2523ca896..4f9f10e99 100644 --- a/src/main/java/com/gmail/nossr50/api/PartyAPI.java +++ b/src/main/java/com/gmail/nossr50/api/PartyAPI.java @@ -89,15 +89,15 @@ public class PartyAPI { } /** - * Get a list of all players in this player's party. + * Get a list of all online players in this player's party. *
* This function is designed for API usage. * * @param player The player to check - * @return all the players in the player's party + * @return all online players in the player's party */ - public ArrayList getPartyMembers(Player player) { - return Party.getInstance().getPartyMembers(player); + public ArrayList getOnlineMembers(Player player) { + return Party.getInstance().getOnlineMembers(player); } /** @@ -122,4 +122,40 @@ public class PartyAPI { public void removeFromParty(Player player) { Party.getInstance().removeFromParty(player, Users.getProfile(player)); } + + /** + * Get the leader of a party. + *
+ * This function is designed for API usage. + * + * @param partyName The party name + * @return the leader of the party + */ + public Player getPartyLeader(String partyName) { + return Party.getInstance().getPartyLeader(partyName); + } + + /** + * Set the leader of a party. + *
+ * This function is designed for API usage. + * + * @param partyName The name of the party to set the leader of + * @param player The player to set as leader + */ + public void setPartyLeader(String partyName, String player) { + Party.getInstance().setPartyLeader(partyName, player); + } + + /** + * Get a list of all players in this player's party. + *
+ * This function is designed for API usage. + * + * @param player The player to check + * @return all the players in the player's party + */ + public ArrayList getAllMembers(Player player) { + return Party.getInstance().getAllMembers(player); + } } diff --git a/src/main/java/com/gmail/nossr50/commands/CommandHelper.java b/src/main/java/com/gmail/nossr50/commands/CommandHelper.java index c463f4e18..5116bfc86 100644 --- a/src/main/java/com/gmail/nossr50/commands/CommandHelper.java +++ b/src/main/java/com/gmail/nossr50/commands/CommandHelper.java @@ -24,7 +24,7 @@ public class CommandHelper { Player player = (Player) sender; if (player != null && !mcPermissions.getInstance().permission(player, permission)) { - player.sendMessage(mcLocale.getString("mcPlayerListener.NoPermission")); + player.sendMessage(mcLocale.getString("mcMMO.NoPermission")); return true; } } @@ -40,7 +40,7 @@ public class CommandHelper { return false; } - + /** * Print out details on Gathering skills. Only for online players. * @@ -52,26 +52,26 @@ public class CommandHelper { if (Skills.hasGatheringSkills(inspect)) { PlayerProfile PP = Users.getProfile(inspect); - display.sendMessage(mcLocale.getString("Stats.GatheringHeader")); + display.sendMessage(mcLocale.getString("Stats.Header.Gathering")); if (mcPermissions.getInstance().excavation(inspect)) { - display.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.ExcavationSkill"), PP.getSkillLevel(SkillType.EXCAVATION), PP.getSkillXpLevel(SkillType.EXCAVATION), PP.getXpToLevel(SkillType.EXCAVATION) })); + display.sendMessage(mcLocale.getString("Skills.Stats", new Object[] { mcLocale.getString("Excavation.Listener"), PP.getSkillLevel(SkillType.EXCAVATION), PP.getSkillXpLevel(SkillType.EXCAVATION), PP.getXpToLevel(SkillType.EXCAVATION) })); } if (mcPermissions.getInstance().fishing(inspect)) { - display.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.FishingSkill"), PP.getSkillLevel(SkillType.FISHING), PP.getSkillXpLevel(SkillType.FISHING), PP.getXpToLevel(SkillType.FISHING) })); + display.sendMessage(mcLocale.getString("Skills.Stats", new Object[] { mcLocale.getString("Fishing.Listener"), PP.getSkillLevel(SkillType.FISHING), PP.getSkillXpLevel(SkillType.FISHING), PP.getXpToLevel(SkillType.FISHING) })); } if (mcPermissions.getInstance().herbalism(inspect)) { - display.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.HerbalismSkill"), PP.getSkillLevel(SkillType.HERBALISM), PP.getSkillXpLevel(SkillType.HERBALISM), PP.getXpToLevel(SkillType.HERBALISM) })); + display.sendMessage(mcLocale.getString("Skills.Stats", new Object[] { mcLocale.getString("Herbalism.Listener"), PP.getSkillLevel(SkillType.HERBALISM), PP.getSkillXpLevel(SkillType.HERBALISM), PP.getXpToLevel(SkillType.HERBALISM) })); } if (mcPermissions.getInstance().mining(inspect)) { - display.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.MiningSkill"), PP.getSkillLevel(SkillType.MINING), PP.getSkillXpLevel(SkillType.MINING), PP.getXpToLevel(SkillType.MINING) })); + display.sendMessage(mcLocale.getString("Skills.Stats", new Object[] { mcLocale.getString("Mining.Listener"), PP.getSkillLevel(SkillType.MINING), PP.getSkillXpLevel(SkillType.MINING), PP.getXpToLevel(SkillType.MINING) })); } if (mcPermissions.getInstance().woodcutting(inspect)) { - display.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.WoodcuttingSkill"), PP.getSkillLevel(SkillType.WOODCUTTING), PP.getSkillXpLevel(SkillType.WOODCUTTING), PP.getXpToLevel(SkillType.WOODCUTTING) })); + display.sendMessage(mcLocale.getString("Skills.Stats", new Object[] { mcLocale.getString("Woodcutting.Listener"), PP.getSkillLevel(SkillType.WOODCUTTING), PP.getSkillXpLevel(SkillType.WOODCUTTING), PP.getXpToLevel(SkillType.WOODCUTTING) })); } } } @@ -91,26 +91,26 @@ public class CommandHelper { if (Skills.hasCombatSkills(inspect)) { PlayerProfile PP = Users.getProfile(inspect); - display.sendMessage(mcLocale.getString("Stats.CombatHeader")); + display.sendMessage(mcLocale.getString("Stats.Header.Combat")); if (mcPermissions.getInstance().axes(inspect)) { - display.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.AxesSkill"), PP.getSkillLevel(SkillType.AXES), PP.getSkillXpLevel(SkillType.AXES), PP.getXpToLevel(SkillType.AXES) })); + display.sendMessage(mcLocale.getString("Skills.Stats", new Object[] { mcLocale.getString("Axes.Listener"), PP.getSkillLevel(SkillType.AXES), PP.getSkillXpLevel(SkillType.AXES), PP.getXpToLevel(SkillType.AXES) })); } if (mcPermissions.getInstance().archery(inspect)) { - display.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.ArcherySkill"), PP.getSkillLevel(SkillType.ARCHERY), PP.getSkillXpLevel(SkillType.ARCHERY), PP.getXpToLevel(SkillType.ARCHERY) })); + display.sendMessage(mcLocale.getString("Skills.Stats", new Object[] { mcLocale.getString("Archery.Listener"), PP.getSkillLevel(SkillType.ARCHERY), PP.getSkillXpLevel(SkillType.ARCHERY), PP.getXpToLevel(SkillType.ARCHERY) })); } if (mcPermissions.getInstance().swords(inspect)) { - display.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.SwordsSkill"), PP.getSkillLevel(SkillType.SWORDS), PP.getSkillXpLevel(SkillType.SWORDS), PP.getXpToLevel(SkillType.SWORDS) })); + display.sendMessage(mcLocale.getString("Skills.Stats", new Object[] { mcLocale.getString("Swords.Listener"), PP.getSkillLevel(SkillType.SWORDS), PP.getSkillXpLevel(SkillType.SWORDS), PP.getXpToLevel(SkillType.SWORDS) })); } if (mcPermissions.getInstance().taming(inspect)) { - display.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.TamingSkill"), PP.getSkillLevel(SkillType.TAMING), PP.getSkillXpLevel(SkillType.TAMING), PP.getXpToLevel(SkillType.TAMING) })); + display.sendMessage(mcLocale.getString("Skills.Stats", new Object[] { mcLocale.getString("Taming.Listener"), PP.getSkillLevel(SkillType.TAMING), PP.getSkillXpLevel(SkillType.TAMING), PP.getXpToLevel(SkillType.TAMING) })); } if (mcPermissions.getInstance().unarmed(inspect)) { - display.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.UnarmedSkill"), PP.getSkillLevel(SkillType.UNARMED), PP.getSkillXpLevel(SkillType.UNARMED), PP.getXpToLevel(SkillType.UNARMED) })); + display.sendMessage(mcLocale.getString("Skills.Stats", new Object[] { mcLocale.getString("Unarmed.Listener"), PP.getSkillLevel(SkillType.UNARMED), PP.getSkillXpLevel(SkillType.UNARMED), PP.getXpToLevel(SkillType.UNARMED) })); } } } @@ -129,14 +129,14 @@ public class CommandHelper { public static void printMiscSkills(Player inspect, CommandSender display) { if (Skills.hasMiscSkills(inspect)) { PlayerProfile PP = Users.getProfile(inspect); - display.sendMessage(mcLocale.getString("Stats.MiscHeader")); + display.sendMessage(mcLocale.getString("Stats.Header.Misc")); if (mcPermissions.getInstance().acrobatics(inspect)) { - display.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.AcrobaticsSkill"), PP.getSkillLevel(SkillType.ACROBATICS), PP.getSkillXpLevel(SkillType.ACROBATICS), PP.getXpToLevel(SkillType.ACROBATICS) })); + display.sendMessage(mcLocale.getString("Skills.Stats", new Object[] { mcLocale.getString("Acrobatics.Listener"), PP.getSkillLevel(SkillType.ACROBATICS), PP.getSkillXpLevel(SkillType.ACROBATICS), PP.getXpToLevel(SkillType.ACROBATICS) })); } if (mcPermissions.getInstance().repair(inspect)) { - display.sendMessage(mcLocale.getString("m.SkillStats", new Object[] { mcLocale.getString("mcPlayerListener.RepairSkill"), PP.getSkillLevel(SkillType.REPAIR), PP.getSkillXpLevel(SkillType.REPAIR), PP.getXpToLevel(SkillType.REPAIR) })); + display.sendMessage(mcLocale.getString("Skills.Stats", new Object[] { mcLocale.getString("Repair.Listener"), PP.getSkillLevel(SkillType.REPAIR), PP.getSkillXpLevel(SkillType.REPAIR), PP.getXpToLevel(SkillType.REPAIR) })); } } } diff --git a/src/main/java/com/gmail/nossr50/commands/general/AddxpCommand.java b/src/main/java/com/gmail/nossr50/commands/general/AddxpCommand.java index 073924daf..a23bb1b4c 100644 --- a/src/main/java/com/gmail/nossr50/commands/general/AddxpCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/general/AddxpCommand.java @@ -27,7 +27,7 @@ public class AddxpCommand implements CommandExecutor { int xp; SkillType skill; String skillName; - String usage = ChatColor.RED + "Proper usage is /addxp [player] "; //TODO: Needs more locale. + String usage = ChatColor.RED + "Proper usage is /addxp [playername] "; //TODO: Needs more locale. if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mmoedit")) { return true; diff --git a/src/main/java/com/gmail/nossr50/commands/general/InspectCommand.java b/src/main/java/com/gmail/nossr50/commands/general/InspectCommand.java index 3d1242818..213d96d11 100644 --- a/src/main/java/com/gmail/nossr50/commands/general/InspectCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/general/InspectCommand.java @@ -25,7 +25,7 @@ public class InspectCommand implements CommandExecutor { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { OfflinePlayer target; PlayerProfile PP; - String usage = "Proper usage is /inspect "; //TODO: Needs more locale. + String usage = "Proper usage is /inspect "; //TODO: Needs more locale. if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.inspect")) { return true; diff --git a/src/main/java/com/gmail/nossr50/commands/general/MmoeditCommand.java b/src/main/java/com/gmail/nossr50/commands/general/MmoeditCommand.java index 7813a8857..e5456faf9 100644 --- a/src/main/java/com/gmail/nossr50/commands/general/MmoeditCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/general/MmoeditCommand.java @@ -30,7 +30,7 @@ public class MmoeditCommand implements CommandExecutor { int newValue; SkillType skill; String skillName; - String usage = ChatColor.RED + "Proper usage is /mmoedit [player] "; //TODO: Needs more locale. + String usage = ChatColor.RED + "Proper usage is /mmoedit [playername] "; //TODO: Needs more locale. if (CommandHelper.noCommandPermissions(sender, "mcmmo.tools.mmoedit")) { return true; diff --git a/src/main/java/com/gmail/nossr50/commands/general/XprateCommand.java b/src/main/java/com/gmail/nossr50/commands/general/XprateCommand.java index 69c4861c2..944e281e5 100644 --- a/src/main/java/com/gmail/nossr50/commands/general/XprateCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/general/XprateCommand.java @@ -22,9 +22,9 @@ public class XprateCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - String usage1 = mcLocale.getString("Commands.xprate.proper"); - String usage2 = mcLocale.getString("Commands.xprate.proper2"); - String usage3 = mcLocale.getString("Commands.xprate.proper3"); + String usage1 = mcLocale.getString("Commands.xprate.proper.0"); + String usage2 = mcLocale.getString("Commands.xprate.proper.1"); + String usage3 = mcLocale.getString("Commands.xprate.proper.2"); if (CommandHelper.noCommandPermissions(sender, "mcmmo.admin")) { return true; @@ -69,8 +69,8 @@ public class XprateCommand implements CommandExecutor { if (xpevent) { for (Player x : plugin.getServer().getOnlinePlayers()) { - x.sendMessage(mcLocale.getString("Commands.xprate.started")); - x.sendMessage(mcLocale.getString("Commands.xprate.started2", new Object[] {LoadProperties.xpGainMultiplier})); + x.sendMessage(mcLocale.getString("Commands.xprate.started.0")); + x.sendMessage(mcLocale.getString("Commands.xprate.started.1", new Object[] {LoadProperties.xpGainMultiplier})); } } else { diff --git a/src/main/java/com/gmail/nossr50/commands/mc/McmmoCommand.java b/src/main/java/com/gmail/nossr50/commands/mc/McmmoCommand.java index ebe38193d..32abace56 100644 --- a/src/main/java/com/gmail/nossr50/commands/mc/McmmoCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/mc/McmmoCommand.java @@ -16,10 +16,7 @@ public class McmmoCommand implements CommandExecutor { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { String description = mcLocale.getString("mcMMO.Description"); String[] mcSplit = description.split(","); - - for (String x : mcSplit) { - sender.sendMessage(x); - } + sender.sendMessage(mcSplit); if (LoadProperties.donateMessage) { if (LoadProperties.spoutEnabled && sender instanceof SpoutPlayer) { diff --git a/src/main/java/com/gmail/nossr50/commands/party/ACommand.java b/src/main/java/com/gmail/nossr50/commands/party/ACommand.java index bd1b1c0c2..f82c9b330 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/ACommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/ACommand.java @@ -9,6 +9,7 @@ import org.bukkit.entity.Player; import com.gmail.nossr50.Users; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.mcPermissions; +import com.gmail.nossr50.commands.CommandHelper; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.events.chat.McMMOAdminChatEvent; import com.gmail.nossr50.locale.mcLocale; @@ -22,72 +23,74 @@ public class ACommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + PlayerProfile PP; + String usage = ChatColor.RED + "Proper usage is /a [message]"; //TODO: Needs more locale. - // Console message? - if (!(sender instanceof Player) && args.length >= 1) { - String aMessage = args[0]; - for (int i = 1; i <= args.length - 1; i++) { - aMessage = aMessage + " " + args[i]; - } - - McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent("Console", aMessage); - plugin.getServer().getPluginManager().callEvent(chatEvent); - - if(chatEvent.isCancelled()) return true; - - aMessage = chatEvent.getMessage(); - - String aPrefix = ChatColor.AQUA + "{" + ChatColor.WHITE + "*Console*" + ChatColor.AQUA + "} "; - - plugin.getLogger().info("[A]<*Console*> " + aMessage); - - for (Player herp : plugin.getServer().getOnlinePlayers()) { - if (mcPermissions.getInstance().adminChat(herp) || herp.isOp()) - herp.sendMessage(aPrefix + aMessage); - } + if (CommandHelper.noCommandPermissions(sender, "mcmmo.chat.adminchat")) { return true; } - Player player = null; - if (sender instanceof Player) { - player = (Player) sender; - } + switch (args.length) { + case 0: + if (sender instanceof Player) { + PP = Users.getProfile((Player) sender); - if (player != null && !mcPermissions.getInstance().adminChat(player) && !player.isOp()) { - player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission")); - return true; - } + if (PP.getPartyChatMode()) { + PP.togglePartyChat(); + } - // Not a toggle, a message + PP.toggleAdminChat(); - if (args.length >= 1) { - String aMessage = args[0]; - for (int i = 1; i <= args.length - 1; i++) { - aMessage = aMessage + " " + args[i]; + if (PP.getAdminChatMode()) { + sender.sendMessage(mcLocale.getString("Commands.AdminChat.On")); + } + else { + sender.sendMessage(mcLocale.getString("Commands.AdminChat.Off")); + } + } + else { + sender.sendMessage(usage); + } + + return true; + + default: + String message = args[0]; + + for (int i = 1; i < args.length; i++) { + message = message + " " + args [i]; + } + + if (sender instanceof Player) { + Player player = (Player) sender; + PP = Users.getProfile(player); + + PP.toggleAdminChat(); + player.chat(message); + PP.toggleAdminChat(); + } + else { + McMMOAdminChatEvent chatEvent = new McMMOAdminChatEvent("Console", message); + plugin.getServer().getPluginManager().callEvent(chatEvent); + + if (chatEvent.isCancelled()) { + return true; + } + + message = chatEvent.getMessage(); + + String prefix = ChatColor.AQUA + "{" + ChatColor.WHITE + "*Console*" + ChatColor.AQUA + "} "; + + plugin.getLogger().info("[A]<*Console*> " + message); + + for (Player player : plugin.getServer().getOnlinePlayers()) { + if (mcPermissions.getInstance().adminChat(player) || player.isOp()) { + player.sendMessage(prefix + message); + } + } } - - Users.getProfile(player).toggleAdminChat(); - player.chat(aMessage); - Users.getProfile(player).toggleAdminChat(); return true; } - - if(player != null) - { - PlayerProfile PP = Users.getProfile(player); - - if (PP.getPartyChatMode()) - PP.togglePartyChat(); - - PP.toggleAdminChat(); - - if (PP.getAdminChatMode()) { - player.sendMessage(mcLocale.getString("mcPlayerListener.AdminChatOn")); - } else { - player.sendMessage(mcLocale.getString("mcPlayerListener.AdminChatOff")); - } - } - return true; } } diff --git a/src/main/java/com/gmail/nossr50/commands/party/InviteCommand.java b/src/main/java/com/gmail/nossr50/commands/party/InviteCommand.java index 340667342..847424e95 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/InviteCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/InviteCommand.java @@ -8,59 +8,62 @@ import org.bukkit.entity.Player; import com.gmail.nossr50.Users; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.mcPermissions; +import com.gmail.nossr50.commands.CommandHelper; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.locale.mcLocale; import com.gmail.nossr50.party.Party; public class InviteCommand implements CommandExecutor { - private final mcMMO plugin; + private final mcMMO plugin; - public InviteCommand(mcMMO instance) { - this.plugin = instance; - } + public InviteCommand(mcMMO instance) { + this.plugin = instance; + } - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + String usage = ChatColor.RED + "Proper usage is /invite "; //TODO: Needs more locale. - if (!(sender instanceof Player)) { - sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale. - return true; - } + if (CommandHelper.noConsoleUsage(sender)) { + return true; + } - Player player = (Player) sender; - PlayerProfile PP = Users.getProfile(player); + if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party")) { + return true; + } - if (!mcPermissions.getInstance().party(player)) { - player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission")); - return true; - } + switch (args.length) { + case 1: + Player player = (Player) sender; + PlayerProfile PP = Users.getProfile(player); - Party Pinstance = Party.getInstance(); + Party partyInstance = Party.getInstance(); - if (!PP.inParty()) { - player.sendMessage(mcLocale.getString("mcPlayerListener.NotInParty")); - return true; - } - if (args.length < 1) { - player.sendMessage(ChatColor.RED + "Usage is /invite "); //TODO: Needs more locale. - return true; - } - if (PP.inParty() && args.length >= 1 && (plugin.getServer().getPlayer(args[0]) != null)) { - if (Pinstance.canInvite(player, PP)) { - Player target = plugin.getServer().getPlayer(args[0]); - PlayerProfile PPt = Users.getProfile(target); - PPt.modifyInvite(PP.getParty()); + if (!PP.inParty()) { + player.sendMessage(mcLocale.getString("Commands.Party.None")); + return true; + } - player.sendMessage(mcLocale.getString("mcPlayerListener.InviteSuccess")); - target.sendMessage(mcLocale.getString("mcPlayerListener.ReceivedInvite1", new Object[] { PPt.getInvite(), player.getName() })); - target.sendMessage(mcLocale.getString("mcPlayerListener.ReceivedInvite2", new Object[] { "accept" })); - } else { - player.sendMessage(mcLocale.getString("Party.Locked")); - return true; - } - } + Player target = plugin.getServer().getPlayer(args[0]); - return true; - } + if (target != null) { + if (partyInstance.canInvite(player, PP)) { + PlayerProfile PPt = Users.getProfile(target); + PPt.modifyInvite(PP.getParty()); + + 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.1")); + } + else { + player.sendMessage(mcLocale.getString("Party.Locked")); + return true; + } + } + + default: + sender.sendMessage(usage); + return true; + } + } } diff --git a/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java b/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java index 6650475f8..315209516 100644 --- a/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/party/PartyCommand.java @@ -8,7 +8,7 @@ import org.bukkit.entity.Player; import com.gmail.nossr50.Users; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.mcPermissions; +import com.gmail.nossr50.commands.CommandHelper; import com.gmail.nossr50.datatypes.PlayerProfile; import com.gmail.nossr50.events.party.McMMOPartyChangeEvent; import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason; @@ -22,254 +22,252 @@ public class PartyCommand implements CommandExecutor { this.plugin = plugin; } - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (!(sender instanceof Player)) { - sender.sendMessage("This command does not support console useage."); //TODO: Needs more locale. - return true; - } + if (CommandHelper.noConsoleUsage(sender)) { + return true; + } - Player player = (Player) sender; - PlayerProfile PP = Users.getProfile(player); + if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.party")) { + return true; + } - if (!mcPermissions.getInstance().party(player)) { - player.sendMessage(ChatColor.YELLOW + "[mcMMO] " + ChatColor.DARK_RED + mcLocale.getString("mcPlayerListener.NoPermission")); - return true; - } + Player player = (Player) sender; + String playerName = player.getName(); + PlayerProfile PP = Users.getProfile(player); - Party Pinstance = Party.getInstance(); + Party partyInstance = Party.getInstance(); + boolean inParty = PP.inParty(); + String partyName = PP.getParty(); + boolean isLeader = partyInstance.isPartyLeader(playerName, partyName); - if (PP.inParty() && (!Pinstance.isParty(PP.getParty()) || !Pinstance.isInParty(player, PP))) { - Pinstance.addToParty(player, PP, PP.getParty(), false, null); - } + if (PP.inParty() && (!partyInstance.isParty(PP.getParty()) || !partyInstance.isInParty(player, PP))) { + partyInstance.addToParty(player, PP, PP.getParty(), false, null); + } - if (args.length == 0 && !PP.inParty()) { - player.sendMessage(mcLocale.getString("Party.Help1", new Object[] { "party "})); - player.sendMessage(mcLocale.getString("Party.Help2", new Object[] { "party "})); - player.sendMessage(mcLocale.getString("Party.Help3", new Object[] { "party " })); - return true; - } else if (args.length == 0 && PP.inParty()) { - String tempList = ""; - int x = 0; - for (Player p : plugin.getServer().getOnlinePlayers()) { - if (PP.getParty().equals(Users.getProfile(p).getParty())) { - if (p != null && x + 1 >= Pinstance.partyCount(player)) { - if (Pinstance.isPartyLeader(p.getName(), PP.getParty())) { - tempList += ChatColor.GOLD + p.getName(); - x++; - } else { - tempList += ChatColor.WHITE + p.getName(); - x++; - } - } - if (p != null && x < Pinstance.partyCount(player)) { - if (Pinstance.isPartyLeader(p.getName(), PP.getParty())) { - tempList += ChatColor.GOLD + p.getName() + ", "; - x++; - } else { - tempList += ChatColor.WHITE + p.getName() + ", "; - x++; - } - } - } - } - player.sendMessage(mcLocale.getString("mcPlayerListener.YouAreInParty", new Object[] { PP.getParty() })); - player.sendMessage(mcLocale.getString("mcPlayerListener.PartyMembers") + " (" + tempList + ChatColor.GREEN + ")"); - - //Master Apprentice Stuff - //Show the player all their bonuses when they type /party - - /* - for(Player a : Party.getInstance().getPartyMembers(player)) - { - if(Party.getInstance().isPartyLeader(a.getName(), PP.getParty()) && !a.getName().equals(player.getName())) - { - PlayerProfile LP = Users.getProfile(a); - for(SkillType type : SkillType.values()) - { - //Skip this one - if(type == SkillType.ALL) - continue; - - if(LP.getSkillLevel(type) > PP.getSkillLevel(type)) - { - //Tell them what their skill bonus is for this skill - int leaderLevel = LP.getSkillLevel(type); - int difference = leaderLevel - PP.getSkillLevel(type); - - double bonusModifier = (difference*0.75D)/100D; - double trueBonus = bonusModifier * 100; - player.sendMessage("You get "+trueBonus+"% more XP from "+type.toString()); - //double percent = (trueBonus/100)*100; - } else - { - //Tell them they have no bonus.. or not - } - } - } else if(Party.getInstance().isPartyLeader(a.getName(), PP.getParty()) && a.getName().equals(player.getName())) - { - //Tell them they are providing bonuses - } - } - */ - - return true; - } else if (args.length == 1) { - if (args[0].equals("q") && PP.inParty()) { + switch (args.length) { + case 0: + if (!inParty) { + player.sendMessage(mcLocale.getString("Party.Help.0")); + player.sendMessage(mcLocale.getString("Party.Help.1")); + player.sendMessage(mcLocale.getString("Party.Help.2")); + } + else { + String tempList = ""; - McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, PP.getParty(), null, EventReason.LEFT_PARTY); - plugin.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { - return true; + for (Player p : partyInstance.getAllMembers(player)) { + if (p.equals(partyInstance.getPartyLeader(partyName))) { + tempList = ChatColor.GOLD + p.getName(); + } + else { + tempList = ChatColor.WHITE + p.getName(); + } } - Pinstance.removeFromParty(player, PP); - player.sendMessage(mcLocale.getString("mcPlayerListener.LeftParty")); - return true; + if (isLeader) { + tempList += ChatColor.GOLD + playerName; + } + else { + tempList += ChatColor.WHITE + playerName; + } - } else if (args[0].equalsIgnoreCase("?")) { - player.sendMessage(mcLocale.getString("Party.Help4", new Object[] { "party " })); - player.sendMessage(mcLocale.getString("Party.Help2", new Object[] { "party " })); - player.sendMessage(mcLocale.getString("Party.Help5", new Object[] { "party " })); - player.sendMessage(mcLocale.getString("Party.Help6", new Object[] { "party " })); - player.sendMessage(mcLocale.getString("Party.Help7", new Object[] { "party " })); - player.sendMessage(mcLocale.getString("Party.Help8", new Object[] { "party " })); - player.sendMessage(mcLocale.getString("Party.Help9", new Object[] { "party " })); - } else if (args[0].equalsIgnoreCase("lock")) { - if (PP.inParty()) { - if (Pinstance.isPartyLeader(player.getName(), PP.getParty())) { - Pinstance.lockParty(PP.getParty()); - player.sendMessage(mcLocale.getString("Party.Locked")); - } else { - player.sendMessage(mcLocale.getString("Party.NotOwner")); - } - } else { - player.sendMessage(mcLocale.getString("Party.InvalidName")); - } - } else if (args[0].equalsIgnoreCase("unlock")) { - if (PP.inParty()) { - if (Pinstance.isPartyLeader(player.getName(), PP.getParty())) { - Pinstance.unlockParty(PP.getParty()); - player.sendMessage(mcLocale.getString("Party.Unlocked")); - } else { - player.sendMessage(mcLocale.getString("Party.NotOwner")); - } - } else { - player.sendMessage(mcLocale.getString("Party.InvalidName")); - } - // Party debugging command. - // } else if (args[0].equalsIgnoreCase("dump")) { - // Pinstance.dump(player); - } else { - if (PP.inParty()) { - McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, PP.getParty(), args[0], EventReason.CHANGED_PARTIES); - plugin.getServer().getPluginManager().callEvent(event); + player.sendMessage(mcLocale.getString("Commands.Party.InParty", new Object[] { partyName })); + player.sendMessage(mcLocale.getString("Commands.Party.Members", new Object[] { tempList })); + } - if (event.isCancelled()) { - return true; - } + return true; - Pinstance.removeFromParty(player, PP); - } - else { + case 1: + if (args[0].equalsIgnoreCase("q")) { + if (inParty) { + McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, partyName, null, EventReason.LEFT_PARTY); + plugin.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return true; + } + + partyInstance.removeFromParty(player, PP); + player.sendMessage(mcLocale.getString("Commands.Party.Leave")); + } + else { + player.sendMessage("Commands.Party.None"); + } + } + else if (args[0].equals("?")) { + player.sendMessage(mcLocale.getString("Party.Help.3")); + player.sendMessage(mcLocale.getString("Party.Help.1")); + player.sendMessage(mcLocale.getString("Party.Help.4")); + player.sendMessage(mcLocale.getString("Party.Help.5")); + player.sendMessage(mcLocale.getString("Party.Help.6")); + player.sendMessage(mcLocale.getString("Party.Help.7")); + } + else if (args[0].equalsIgnoreCase("lock")) { + if (inParty) { + if (isLeader) { + if (partyInstance.isPartyLocked(partyName)) { + player.sendMessage(mcLocale.getString("Party.IsLocked")); + } + else { + partyInstance.lockParty(partyName); + player.sendMessage(mcLocale.getString("Party.Locked")); + } + } + else { + player.sendMessage(mcLocale.getString("Party.NotOwner")); + } + } + else { + player.sendMessage("Commands.Party.None"); + } + } + else if (args[0].equalsIgnoreCase("unlock")) { + if (inParty) { + if (isLeader) { + if (!partyInstance.isPartyLocked(partyName)) { + player.sendMessage(mcLocale.getString("Party.IsntLocked")); + } + else { + partyInstance.unlockParty(partyName); + player.sendMessage(mcLocale.getString("Party.Unlocked")); + } + } + else { + player.sendMessage(mcLocale.getString("Party.NotOwner")); + } + } + else { + player.sendMessage("Commands.Party.None"); + } + } + else { + if (inParty) { + McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, partyName, args[0], EventReason.CHANGED_PARTIES); + plugin.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return true; + } + + partyInstance.removeFromParty(player, PP); + } + else { McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, args[0], EventReason.JOINED_PARTY); plugin.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return true; } - } - Pinstance.addToParty(player, PP, args[0], false, null); - return true; - } - } else if (args.length == 2 && PP.inParty()) { - if (args[0].equalsIgnoreCase("password")) { - if (Pinstance.isPartyLeader(player.getName(), PP.getParty())) { - if (Pinstance.isPartyLocked(PP.getParty())) { - Pinstance.setPartyPassword(PP.getParty(), args[1]); - player.sendMessage(mcLocale.getString("Party.PasswordSet", new Object[] { args[1] })); - } else { - player.sendMessage(mcLocale.getString("Party.IsntLocked")); - } - } else { - player.sendMessage(mcLocale.getString("Party.NotOwner")); - } - } else if (args[0].equalsIgnoreCase("kick")) { - if (Pinstance.isPartyLeader(player.getName(), PP.getParty())) { - if (Pinstance.isPartyLocked(PP.getParty())) { - Player tPlayer = null; - if (plugin.getServer().getPlayer(args[1]) != null) - tPlayer = plugin.getServer().getPlayer(args[1]); - if (tPlayer == null) { - player.sendMessage(mcLocale.getString("Party.CouldNotKick", new Object[] { args[1] })); - } - if (!Pinstance.inSameParty(player, tPlayer)) { - player.sendMessage(mcLocale.getString("Party.NotInYourParty", new Object[] { tPlayer.getName() })); - } else { - // Not an admin - if (!mcPermissions.getInstance().admin(player)) { - // Can't kick an admin - if (mcPermissions.getInstance().admin(tPlayer)) { - player.sendMessage(mcLocale.getString("Party.CouldNotKick", new Object[] { tPlayer.getName() })); - } - } - PlayerProfile tPP = Users.getProfile(tPlayer); + } - McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, tPP.getParty(), null, EventReason.KICKED_FROM_PARTY); - plugin.getServer().getPluginManager().callEvent(event); + partyInstance.addToParty(player, PP, args[0], false, null); + } - if (event.isCancelled()) { - return true; - } + return true; - Pinstance.removeFromParty(tPlayer, tPP); + case 2: + if (PP.inParty()) { + if (args[0].equalsIgnoreCase("password")) { + if (isLeader) { + if (!partyInstance.isPartyLocked(partyName)) { + partyInstance.lockParty(partyName); + } - tPlayer.sendMessage(mcLocale.getString("mcPlayerListener.LeftParty")); - } - } else { - player.sendMessage(mcLocale.getString("Party.IsntLocked")); - } - } else { - player.sendMessage(mcLocale.getString("Party.NotOwner")); - } - } else if (args[0].equalsIgnoreCase("owner")) { - if (Pinstance.isPartyLeader(player.getName(), PP.getParty())) { - Player tPlayer = null; - if (plugin.getServer().getPlayer(args[1]) != null) - tPlayer = plugin.getServer().getPlayer(args[1]); - if (tPlayer == null) { - player.sendMessage(mcLocale.getString("Party.CouldNotSetOwner", new Object[] { args[1] })); - } - if (!Pinstance.inSameParty(player, tPlayer)) { - player.sendMessage(mcLocale.getString("Party.CouldNotSetOwner", new Object[] { tPlayer.getName() })); - } else { - Pinstance.setPartyLeader(PP.getParty(), tPlayer.getName()); - } - } else { - player.sendMessage(mcLocale.getString("Party.NotOwner")); - } - } else { - McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, PP.getParty(), args[0], EventReason.CHANGED_PARTIES); + partyInstance.setPartyPassword(partyName, args[1]); + player.sendMessage(mcLocale.getString("Party.PasswordSet", new Object[] { args[1] })); + } + else { + player.sendMessage(mcLocale.getString("Party.NotOwner")); + } + } + else if (args[0].equalsIgnoreCase("kick")) { + if (isLeader) { + Player target = plugin.getServer().getPlayer(args[1]); + + if (target == null) { + player.sendMessage(mcLocale.getString("Party.CouldNotKick", new Object[] { args[1] })); + return true; + } + + PlayerProfile PPt = Users.getProfile(target); + String targetName = target.getName(); + + if (!partyInstance.inSameParty(player, (Player) target)) { + player.sendMessage(mcLocale.getString("Party.NotInYourParty", new Object[] { targetName })); + return true; + } + + else { + McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, partyName, null, EventReason.KICKED_FROM_PARTY); + plugin.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return true; + } + + partyInstance.removeFromParty(target, PPt); + target.sendMessage(mcLocale.getString("Commands.Party.Kick", new Object[] { partyName })); + } + } + else { + player.sendMessage(mcLocale.getString("Party.NotOwner")); + } + } + else if (args[0].equalsIgnoreCase("owner")) { + if (isLeader) { + Player target = plugin.getServer().getPlayer(args[1]); + + if (target == null) { + player.sendMessage(mcLocale.getString("Party.CouldNotSetOwner")); + return true; + } + + String targetName = target.getName(); + + if (!partyInstance.inSameParty(player, (Player) target)) { + player.sendMessage(mcLocale.getString("Party.NotInYourParty", new Object[] { targetName })); + return true; + } + + else { + partyInstance.setPartyLeader(partyName, targetName); + } + } + else { + player.sendMessage(mcLocale.getString("Party.NotOwner")); + } + } + else { + McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, partyName, args[0], EventReason.CHANGED_PARTIES); + plugin.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return true; + } + + partyInstance.removeFromParty(player, PP); + partyInstance.addToParty(player, PP, args[0], false, args[1]); + } + } + else { + McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, args[0], EventReason.JOINED_PARTY); plugin.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return true; } - Pinstance.removeFromParty(player, PP); - Pinstance.addToParty(player, PP, args[0], false, args[1]); - } - } else if (args.length == 2 && !PP.inParty()) { - McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, args[0], EventReason.JOINED_PARTY); - plugin.getServer().getPluginManager().callEvent(event); - if (event.isCancelled()) { - return true; + partyInstance.addToParty(player, PP, args[0], false, args[1]); } - Pinstance.addToParty(player, PP, args[0], false, args[1]); - } - return true; - } + return true; + + default: + player.sendMessage(mcLocale.getString("Party.Help.0")); + player.sendMessage(mcLocale.getString("Party.Help.1")); + player.sendMessage(mcLocale.getString("Party.Help.2")); + return true; + } + } } diff --git a/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java b/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java index a26f6921a..d7d27e2cd 100644 --- a/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java +++ b/src/main/java/com/gmail/nossr50/datatypes/PlayerProfile.java @@ -90,6 +90,14 @@ public class PlayerProfile { lastlogin = ((Long) (System.currentTimeMillis() / 1000)).intValue(); } + public String getPlayerName() { + return this.playerName; + } + + public Player getPlayer() { + return mcMMO.p.getServer().getPlayer(playerName); + } + public boolean loadMySQL() { int id = 0; id = mcMMO.database.getInt("SELECT id FROM "+LoadProperties.MySQLtablePrefix+"users WHERE user = '" + playerName + "'"); @@ -1168,7 +1176,7 @@ public class PlayerProfile { Player player = mcMMO.p.getServer().getPlayer(playerName); double bonusModifier = 0.0; - for (Player x : Party.getInstance().getPartyMembers(player)) { + for (Player x : Party.getInstance().getOnlineMembers(player)) { if (x.isOnline() && !x.getName().equals(player.getName()) && Party.getInstance().isPartyLeader(x.getName(), this.getParty())) { if (m.isNear(player.getLocation(), x.getLocation(), 25.0)) { PlayerProfile PartyLeader = Users.getProfile(x); diff --git a/src/main/java/com/gmail/nossr50/listeners/mcPlayerListener.java b/src/main/java/com/gmail/nossr50/listeners/mcPlayerListener.java index 37b836b2e..8dd180e97 100644 --- a/src/main/java/com/gmail/nossr50/listeners/mcPlayerListener.java +++ b/src/main/java/com/gmail/nossr50/listeners/mcPlayerListener.java @@ -69,7 +69,7 @@ public class mcPlayerListener implements Listener { if (PP.getGodMode()) { if (!mcPermissions.getInstance().mcgod(player)) { PP.toggleGodMode(); - player.sendMessage(mcLocale.getString("GodMode.Forbidden")); + player.sendMessage(mcLocale.getString("Commands.GodMode.Forbidden")); } } @@ -168,8 +168,8 @@ public class mcPlayerListener implements Listener { Player player = event.getPlayer(); if (mcPermissions.getInstance().motd(player) && LoadProperties.enableMotd) { - player.sendMessage(mcLocale.getString("mcPlayerListener.MOTD", new Object[] {plugin.getDescription().getVersion(), "mcmmo"})); - player.sendMessage(mcLocale.getString("mcPlayerListener.WIKI")); + player.sendMessage(mcLocale.getString("mcMMO.MOTD", new Object[] {plugin.getDescription().getVersion()})); + player.sendMessage(mcLocale.getString("McMMO.Wiki")); } //THIS IS VERY BAD WAY TO DO THINGS, NEED BETTER WAY diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 63b6eb470..899cbdacc 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -219,18 +219,18 @@ public class mcMMO extends JavaPlugin { //Register aliases with the aliasmap (used in the playercommandpreprocessevent to ugly alias them to actual commands) //Skills commands - aliasMap.put(mcLocale.getString("m.SkillAcrobatics").toLowerCase(), "acrobatics"); - aliasMap.put(mcLocale.getString("m.SkillArchery").toLowerCase(), "archery"); - aliasMap.put(mcLocale.getString("m.SkillAxes").toLowerCase(), "axes"); - aliasMap.put(mcLocale.getString("m.SkillExcavation").toLowerCase(), "excavation"); - aliasMap.put(mcLocale.getString("m.SkillFishing").toLowerCase(), "fishing"); - aliasMap.put(mcLocale.getString("m.SkillHerbalism").toLowerCase(), "herbalism"); - aliasMap.put(mcLocale.getString("m.SkillMining").toLowerCase(), "mining"); - aliasMap.put(mcLocale.getString("m.SkillRepair").toLowerCase(), "repair"); - aliasMap.put(mcLocale.getString("m.SkillSwords").toLowerCase(), "swords"); - aliasMap.put(mcLocale.getString("m.SkillTaming").toLowerCase(), "taming"); - aliasMap.put(mcLocale.getString("m.SkillUnarmed").toLowerCase(), "unarmed"); - aliasMap.put(mcLocale.getString("m.SkillWoodCutting").toLowerCase(), "woodcutting"); + aliasMap.put(mcLocale.getString("Acrobatics.SkillName").toLowerCase(), "acrobatics"); + aliasMap.put(mcLocale.getString("Archery.SkillName").toLowerCase(), "archery"); + aliasMap.put(mcLocale.getString("Axes.SkillName").toLowerCase(), "axes"); + aliasMap.put(mcLocale.getString("Excavation.SkillName").toLowerCase(), "excavation"); + aliasMap.put(mcLocale.getString("Fishing.SkillName").toLowerCase(), "fishing"); + aliasMap.put(mcLocale.getString("Herbalism.SkillName").toLowerCase(), "herbalism"); + aliasMap.put(mcLocale.getString("Mining.SkillName").toLowerCase(), "mining"); + aliasMap.put(mcLocale.getString("Repair.SkillName").toLowerCase(), "repair"); + aliasMap.put(mcLocale.getString("Swords.SkillName").toLowerCase(), "swords"); + aliasMap.put(mcLocale.getString("Taming.SkillName").toLowerCase(), "taming"); + aliasMap.put(mcLocale.getString("Unarmed.SkillName").toLowerCase(), "unarmed"); + aliasMap.put(mcLocale.getString("WoodCutting.SkillName").toLowerCase(), "woodcutting"); //Register commands //Skills commands diff --git a/src/main/java/com/gmail/nossr50/party/Party.java b/src/main/java/com/gmail/nossr50/party/Party.java index fbc51b00e..0f0eb8ab4 100644 --- a/src/main/java/com/gmail/nossr50/party/Party.java +++ b/src/main/java/com/gmail/nossr50/party/Party.java @@ -90,13 +90,31 @@ public class Party { private void informPartyMembers(Player player) { String playerName = player.getName(); + if (player != null) { + for (Player p : getOnlineMembers(player)) { + p.sendMessage(mcLocale.getString("Party.InformedOnJoin", new Object[] {playerName})); + } + } + } + + /** + * Get a list of all online players in this player's party. + * + * @param player The player to check + * @return all online players in the player's party + */ + public ArrayList getOnlineMembers(Player player) { + ArrayList players = new ArrayList(); + for (Player p : plugin.getServer().getOnlinePlayers()) { if (player != null && p != null) { - if (inSameParty(player, p) && !p.getName().equals(playerName)) { - p.sendMessage(mcLocale.getString("Party.InformedOnJoin", new Object[] {playerName})); + if (inSameParty(player, p) && !p.getName().equals(player.getName())) { + players.add(p); } } } + + return players; } /** @@ -105,16 +123,19 @@ public class Party { * @param player The player to check * @return all the players in the player's party */ - public ArrayList getPartyMembers(Player player) { + public ArrayList getAllMembers(Player player) { ArrayList players = new ArrayList(); + HashMap profiles = Users.getProfiles(); - for (Player p : plugin.getServer().getOnlinePlayers()) { - if (p.isOnline() && player != null && p != null) { - if (inSameParty(player, p) && !p.getName().equals(player.getName())) { + if (player != null) { + for (String name : profiles.keySet()) { + Player p = profiles.get(name).getPlayer(); + if (inSameParty(p, player)) { players.add(p); } } } + return players; } @@ -126,11 +147,9 @@ public class Party { private void informPartyMembersOwnerChange(String newOwnerName) { Player newOwner = plugin.getServer().getPlayer(newOwnerName); - for (Player p : plugin.getServer().getOnlinePlayers()){ - if (newOwner != null && p != null) { - if (inSameParty(newOwner, p)) { - p.sendMessage(newOwnerName + " is the new party owner."); //TODO: Needs more locale - } + if (newOwner != null) { + for (Player p : getOnlineMembers(newOwner)) { + p.sendMessage(newOwnerName + " is the new party owner."); //TODO: Needs more locale } } } @@ -143,11 +162,9 @@ public class Party { private void informPartyMembersQuit(Player player) { String playerName = player.getName(); - for (Player p : plugin.getServer().getOnlinePlayers()){ - if (player != null && p != null){ - if (inSameParty(player, p) && !p.getName().equals(playerName)) { - p.sendMessage(mcLocale.getString("Party.InformedOnQuit", new Object[] {playerName})); - } + if (player != null) { + for (Player p : getOnlineMembers(player)) { + p.sendMessage(mcLocale.getString("Party.InformedOnQuit", new Object[] {playerName})); } } } @@ -243,10 +260,10 @@ public class Party { informPartyMembers(player); if (!invite) { - player.sendMessage(mcLocale.getString("mcPlayerListener.JoinedParty", new Object[]{ newParty })); + player.sendMessage(mcLocale.getString("Commands.Party.Join", new Object[]{ newParty })); } else { - player.sendMessage(mcLocale.getString("mcPlayerListener.InviteAccepted", new Object[]{ PP.getParty() })); + player.sendMessage(mcLocale.getString("Commands.Invite.Accepted", new Object[]{ PP.getParty() })); } } @@ -308,6 +325,25 @@ public class Party { savePartyFile(partyPasswordsFile, partyPasswords); } + /** + * Get the leader of a party. + * + * @param partyName The party name + * @return the leader of the party + */ + public Player getPartyLeader(String partyName) { + Player leader = null; + + for (String name : partyPlayers.get(partyName).keySet()) { + if (partyPlayers.get(partyName).get(name)) { + leader = plugin.getServer().getPlayer(name); + break; + } + } + + return leader; + } + /** * Set the leader of a party. * diff --git a/src/main/resources/locale/locale_en_us.properties b/src/main/resources/locale/locale_en_us.properties index 86a289879..320403741 100644 --- a/src/main/resources/locale/locale_en_us.properties +++ b/src/main/resources/locale/locale_en_us.properties @@ -393,11 +393,12 @@ Commands.Party.Chat.Off=Party Chat only [[RED]]Off Commands.Party.Chat.On=Party Chat only [[GREEN]]On 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.1=[[YELLOW]]Type [[GREEN]]/{0}[[YELLOW]] to accept the invite +Commands.Party.Invite.1=[[YELLOW]]Type [[GREEN]]/accept[[YELLOW]] to accept the invite Commands.Party.Invite= [[RED]]- Send party invite Commands.Party.Join=Joined Party: {0} +Commands.Party.Kick=[[RED]]You were kicked from party {0}! Commands.Party.Leave=[[RED]]You have left that party -Commands.Party.Members=[[GREEN]]Party Members +Commands.Party.Members=[[GREEN]]Party Members: {0} Commands.Party.None=[[RED]]You are not in a party. Commands.Party.Quit=[[RED]]- Leave your current party Commands.Party.Teleport= [[RED]]- Teleport to party member @@ -410,30 +411,30 @@ Commands.SkillInfo=/ [[RED]]- View detailed information about a skill Commands.Stats.Self=YOUR STATS Commands.Stats=[[RED]]- View your mcMMO stats Commands.ToggleAbility=[[RED]]- Toggle ability activation with right click -mcMMO.MOTD=[[BLUE]]This server is running mcMMO {0} type [[YELLOW]]/{1}[[BLUE]] for help. +mcMMO.MOTD=[[BLUE]]This server is running mcMMO {0}! Type [[YELLOW]]/mcmmo[[BLUE]] for help. mcMMO.NoInvites=[[RED]]You have no invites at this time mcMMO.NoPermission=[[DARK_RED]]Insufficient permissions. mcMMO.NoSkillNote=[[DARK_GRAY]]If you don't have access to a skill it will not be shown here. mcMMO.Wiki=[[GREEN]]http://mcmmo.wikia.com[[BLUE]] - mcMMO Wiki ##party -Commands.Party.InParty=[[GREEN]]You are in party {0} -Party.CouldNotKick=[[DARK_RED]]Could not kick player {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.Help1=[[RED]]Proper usage is [[YELLOW]]/{0} [[WHITE]][[YELLOW]] or [[WHITE]]'q' [[YELLOW]]to quit -Party.Help2=[[RED]]To join a passworded party use [[YELLOW]]/{0} [[WHITE]] -Party.Help3=[[RED]]Consult /{0} ? for more information -Party.Help4=[[RED]]Use [[YELLOW]]/{0} [[WHITE]] [[YELLOW]]to join a party or [[WHITE]]'q' [[YELLOW]]to quit -Party.Help5=[[RED]]To lock your party use [[YELLOW]]/{0} [[WHITE]]lock -Party.Help6=[[RED]]To unlock your party use [[YELLOW]]/{0} [[WHITE]]unlock -Party.Help7=[[RED]]To password protect your party use [[YELLOW]]/{0} [[WHITE]]password -Party.Help8=[[RED]]To kick a player from your party use [[YELLOW]]/{0} [[WHITE]]kick -Party.Help9=[[RED]]To transfer ownership of your party use [[YELLOW]]/{0} [[WHITE]]owner +Party.Help.0=[[RED]]Proper usage is /party to join or /party q to quit +Party.Help.1=[[RED]]To join a passworded party, use /party +Party.Help.2=[[RED]]Consult /party ? for more information +Party.Help.3=[[RED]]Use /party to join or /party q to quit +Party.Help.4=[[RED]]To lock or unlock your party, use /party +Party.Help.5=[[RED]]To password protect your party, use /party password +Party.Help.6=[[RED]]To kick a player from your party, use /party kick +Party.Help.7=[[RED]]To transfer ownership of your party, use /party owner Party.InformedOnJoin={0} [[GREEN]] has joined your party Party.InformedOnQuit={0} [[GREEN]] has left your party Party.InvalidName=[[DARK_RED]]That is not a valid party name -Party.IsntLocked=[[GRAY]]Party is not locked +Party.IsLocked=[[RED]]This party is already locked! +Party.IsntLocked=[[RED]]This party is not locked! Party.Locked=[[RED]]Party is locked, only party leader may invite. Party.NotInYourParty=[[DARK_RED]]{0} is not in your party Party.NotOwner=[[DARK_RED]]You are not the party owner @@ -458,11 +459,11 @@ 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.unlocked=[[GOLD]]Your XP BAR is now [[GREEN]]UNLOCKED[[GOLD]]! Commands.xprate.over=[[RED]]mcMMO XP Rate Event is OVER!! -Commands.xprate.proper=[[RED]]Proper usage to change the XP rate is /xprate -Commands.xprate.proper2=[[RED]]Proper usage to restore the XP rate to default is /xprate reset -Commands.xprate.proper3=[[RED]]Please specify true or false to indicate if this is an xp event or not -Commands.xprate.started=[[GOLD]]XP EVENT FOR mcMMO HAS STARTED! -Commands.xprate.started2=[[GOLD]]mcMMO XP RATE IS NOW {0}x! +Commands.xprate.proper.0=[[RED]]Proper usage to change the XP rate is /xprate +Commands.xprate.proper.1=[[RED]]Proper usage to restore the XP rate to default is /xprate reset +Commands.xprate.proper.2=[[RED]]Please specify true or false to indicate if this is an xp event or not +Commands.xprate.started.0=[[GOLD]]XP EVENT FOR mcMMO HAS STARTED! +Commands.xprate.started.1=[[GOLD]]mcMMO XP RATE IS NOW {0}x! XPRate.Event= [[GOLD]]mcMMO is currently in an XP rate event! XP rate is {0}x! #EFFECTS diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 6b6bdc50f..85d714d69 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -1,94 +1,141 @@ name: mcMMO -website: mcmmo.org -main: com.gmail.nossr50.mcMMO version: ${project.version}-b${BUILD_NUMBER} -softdepend: [Spout] -authors: - - nossr50 - - NuclearW - - gmcferrin description: mcMMO takes core Minecraft game mechanics and expands them to add an extensive RPG experience, the goal of the project has always been a quality RPG experience. Everything in mcMMO is carefully thought out and is constantly improving. mcMMO adds eleven skills to train in and level in, while also offering a high level of customization for server admins. There are countless features, including custom sounds, graphical elements, and more added when running mcMMO in conjunction with Spout. I carefully read feedback and evaluate the mechanics of mcMMO in every update to provide an ever-evolving experience. + +author: nossr50 +authors: [NuclearW, gmcferrin] +website: http://forums.bukkit.org/threads/rpg-mech-mcmmo-v1-3-05-rpg-addiction-redefined-multi-lingual-1-2-5-r1-0.68601/ + +main: com.gmail.nossr50.mcMMO +softdepend: [Spout] + commands: mchud: + aliases: [] description: Change your HUD xplock: + aliases: [mcxplock] description: Lock your xp bar xprate: + aliases: [mcxprate] description: Modify the xp rate or start an event mcc: + aliases: [] description: Lists mcMMO commands mcmmo: + aliases: [] description: Shows a brief mod description mctop: + aliases: [] description: Shows leader boards for mcMMO addxp: + aliases: [] description: Add XP to a user permission: mcmmo.tools.mmoedit addlevels: + aliases: [] description: Add levels to a user permission: mcmmo.tools.mmoedit mcability: + aliases: [] description: Toggle whether or not abilities get readied on right click permission: mcmmo.commands.ability mcrefresh: + aliases: [] description: Refresh all cooldowns for mcMMO permission: mcmmo.tools.mcrefresh mcgod: + aliases: [] description: Make yourself invulnerable permission: mcmmo.tools.mcgod mcstats: + aliases: [] description: Shows your mcMMO stats and xp mcremove: + aliases: [] description: Remove a user from the database permission: mcmmo.tools.mcremove mmoedit: + aliases: [] description: Edit the skill values for a user permission: mcmmo.tools.mmoedit ptp: + aliases: [] description: Teleport to a party member permission: mcmmo.commands.ptp party: + aliases: [] description: Create/join a party permission: mcmmo.commands.party inspect: + aliases: [] description: View mcMMO stats of another player invite: + aliases: [] description: Invite a player into your party permission: mcmmo.chat.partychat accept: + aliases: [] description: Accept a party invite permission: mcmmo.chat.partychat mmoupdate: + aliases: [] description: Convert from Flat File to MySQL permission: mcmmo.admin p: + aliases: [pc] description: Toggle Party chat or send party chat messages permission: mcmmo.chat.partychat excavation: + aliases: [] description: Detailed skill info + permission: mcmmo.skills.excavation herbalism: + aliases: [] description: Detailed skill info + permission: mcmmo.skills.herbalism mining: + aliases: [] description: Detailed skill info + permission: mcmmo.skills.mining woodcutting: + aliases: [] description: Detailed skill info + permission: mcmmo.skills.woodcutting axes: + aliases: [] description: Detailed skill info + permission: mcmmo.skills.axes archery: + aliases: [] description: Detailed skill info + permission: mcmmo.skills.archery swords: + aliases: [] description: Detailed skill info + permission: mcmmo.skills.swords taming: + aliases: [] description: Detailed skill info + permission: mcmmo.skills.taming unarmed: + aliases: [] description: Detailed skill info + permission: mcmmo.skills.unarmed acrobatics: + aliases: [] description: Detailed skill info + permission: mcmmo.skills.acrobatics repair: + aliases: [] description: Detailed skill info + permission: mcmmo.skills.repair fishing: + aliases: [] description: Detailed skill info + permission: mcmmo.skills.fishing a: + aliases: [ac] description: Toggle Admin chat or send admin chat messages permission: mcmmo.chat.adminchat permissions: @@ -118,7 +165,7 @@ permissions: mcmmo.admin: true mcmmo.tools.*: true mcmmo.admin: - description: Allows access to mmoupdate and other sensitive commands + description: All ows 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.*: