From bcd8906315cfdaeeb76f872c5935097e7746ed71 Mon Sep 17 00:00:00 2001 From: NuclearW Date: Mon, 11 Feb 2013 03:08:03 -0500 Subject: [PATCH 01/44] Remove all spaces before newlines in config.yml --- src/main/resources/config.yml | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/resources/config.yml b/src/main/resources/config.yml index c4cf332a2..376734a33 100644 --- a/src/main/resources/config.yml +++ b/src/main/resources/config.yml @@ -118,7 +118,7 @@ Skills: Enabled_For_PVE: true Prevent_AFK_Leveling: true Prevent_Dodge_Lightning: false - Level_Cap: 0 + Level_Cap: 0 Archery: Enabled_For_PVP: true Enabled_For_PVE: true @@ -176,7 +176,7 @@ Skills: Requires_Axe: true # -# Settings for Double Drops +# Settings for Double Drops ### Double_Drops: Herbalism: From 0aeff40aaa84423a4e38952815f589ac5b79b443 Mon Sep 17 00:00:00 2001 From: bm01 Date: Mon, 11 Feb 2013 14:14:43 +0100 Subject: [PATCH 02/44] Made /party kick work on offline players --- Changelog.txt | 1 + .../com/gmail/nossr50/party/PartyManager.java | 2 +- .../party/commands/PartyKickCommand.java | 21 ++++++------------- .../java/com/gmail/nossr50/util/Users.java | 2 +- 4 files changed, 9 insertions(+), 17 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index e0cf3afe0..367ec4751 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -51,6 +51,7 @@ Version 1.4.00-dev = Fixed Experience.Gains.Mobspawners.Enabled not being used correctly (the check was inverted) = Fixed bug where Iron Grip was using the attacker's skill values rather than the defender's. = Fixed a bug where /party kick would trigger the PartyChangeEvent for the wrong player + = Fixed /party kick not working on offline players = Fixed a bug where party join messages weren't displayed = Fixed a bug where Disarm and Deflect had wrong values = Fixed Magic Hunter (Fishing ability) favoring certain enchants diff --git a/src/main/java/com/gmail/nossr50/party/PartyManager.java b/src/main/java/com/gmail/nossr50/party/PartyManager.java index 5c3ac99d3..0de09886e 100644 --- a/src/main/java/com/gmail/nossr50/party/PartyManager.java +++ b/src/main/java/com/gmail/nossr50/party/PartyManager.java @@ -39,7 +39,7 @@ public final class PartyManager { } /** - * Check if two players are in the same party. + * Check if two online players are in the same party. * * @param firstPlayer The first player * @param secondPlayer The second player diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyKickCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyKickCommand.java index 0d21bc3b3..017d93e2a 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyKickCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyKickCommand.java @@ -7,8 +7,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.commands.CommandHelper; -import com.gmail.nossr50.datatypes.McMMOPlayer; import com.gmail.nossr50.events.party.McMMOPartyChangeEvent; import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason; import com.gmail.nossr50.locale.LocaleLoader; @@ -38,32 +36,25 @@ public class PartyKickCommand implements CommandExecutor { return true; } - McMMOPlayer mcMMOTarget = Users.getPlayer(args[1]); + OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(args[1]); - // Would be nice to find a way to check if a player is valid here - this won't work directly because it'll also throw null for an offline player -// if (mcMMOTarget == null) { -// sender.sendMessage(LocaleLoader.getString("Party.Player.Invalid")); -// return false; -// } - - Player target = mcMMOTarget.getPlayer(); - - if (!PartyManager.inSameParty(player, target)) { + if (!playerParty.getMembers().contains(target)) { sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", args[1])); return true; } - if (mcMMO.p.getServer().getOfflinePlayer(args[1]).isOnline()) { + if (target.isOnline()) { + Player onlineTarget = target.getPlayer(); String partyName = playerParty.getName(); - McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(target, partyName, null, EventReason.KICKED_FROM_PARTY); + McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(onlineTarget, partyName, null, EventReason.KICKED_FROM_PARTY); mcMMO.p.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return true; } - target.sendMessage(LocaleLoader.getString("Commands.Party.Kick", partyName)); + onlineTarget.sendMessage(LocaleLoader.getString("Commands.Party.Kick", partyName)); } PartyManager.removeFromParty(target, playerParty); diff --git a/src/main/java/com/gmail/nossr50/util/Users.java b/src/main/java/com/gmail/nossr50/util/Users.java index 570564f1d..445f74eac 100644 --- a/src/main/java/com/gmail/nossr50/util/Users.java +++ b/src/main/java/com/gmail/nossr50/util/Users.java @@ -121,7 +121,7 @@ public final class Users { * @param player The player whose McMMOPlayer to retrieve * @return the player's McMMOPlayer object */ - public static McMMOPlayer getPlayer(Player player) { + public static McMMOPlayer getPlayer(OfflinePlayer player) { return players.get(player.getName()); } } From 59a52a73bb955831326f5240ec48943365dea2df Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 11 Feb 2013 15:17:15 -0500 Subject: [PATCH 03/44] We've got a function, might as well use it. --- .../com/gmail/nossr50/party/commands/PartyKickCommand.java | 6 +----- 1 file changed, 1 insertion(+), 5 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyKickCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyKickCommand.java index 017d93e2a..71e5b3823 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyKickCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyKickCommand.java @@ -7,7 +7,6 @@ import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gmail.nossr50.mcMMO; -import com.gmail.nossr50.events.party.McMMOPartyChangeEvent; import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.party.Party; @@ -47,10 +46,7 @@ public class PartyKickCommand implements CommandExecutor { Player onlineTarget = target.getPlayer(); String partyName = playerParty.getName(); - McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(onlineTarget, partyName, null, EventReason.KICKED_FROM_PARTY); - mcMMO.p.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { + if (!PartyManager.handlePartyChangeEvent(onlineTarget, partyName, null, EventReason.KICKED_FROM_PARTY)) { return true; } From 1c0e3925527acad5e66c8db8b1dfe18e005a6f0c Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 11 Feb 2013 15:19:41 -0500 Subject: [PATCH 04/44] Convert /party disband to a subcommand --- .../nossr50/party/commands/PartyCommand.java | 35 +------------- .../party/commands/PartyDisbandCommand.java | 47 +++++++++++++++++++ 2 files changed, 49 insertions(+), 33 deletions(-) create mode 100644 src/main/java/com/gmail/nossr50/party/commands/PartyDisbandCommand.java diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java index 8dcdedad5..12144ba1b 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java @@ -31,6 +31,7 @@ public class PartyCommand implements CommandExecutor { private CommandExecutor partyItemShareCommand = new PartyItemShareCommand(); private CommandExecutor partyInviteCommand = new PartyInviteCommand(); private CommandExecutor partyKickCommand = new PartyKickCommand(); + private CommandExecutor partyDisbandCommand = new PartyDisbandCommand(); @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { @@ -84,7 +85,7 @@ public class PartyCommand implements CommandExecutor { return partyKickCommand.onCommand(sender, command, label, args); } else if (args[0].equalsIgnoreCase("disband")) { - return disband(); + return partyDisbandCommand.onCommand(sender, command, label, args); } else if (args[0].equalsIgnoreCase("owner")) { return changeOwner(args); @@ -189,38 +190,6 @@ public class PartyCommand implements CommandExecutor { return true; } - /** - * Disband the current party, kicks out all party members. - */ - private boolean disband() { - if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.party.disband")) { - return true; - } - - String playerName = player.getName(); - Party party = mcMMOPlayer.getParty(); - - if (party.getLeader().equals(playerName)) { - for (Player onlineMembers : party.getOnlineMembers()) { - McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(onlineMembers, party.getName(), null, EventReason.KICKED_FROM_PARTY); - mcMMO.p.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { - return true; - } - - onlineMembers.sendMessage(LocaleLoader.getString("Party.Disband")); - } - - PartyManager.disbandParty(party); - } - else { - player.sendMessage(LocaleLoader.getString("Party.NotOwner")); - } - - return true; - } - /** * Change the owner of the current party */ diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyDisbandCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyDisbandCommand.java new file mode 100644 index 000000000..839ca7370 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyDisbandCommand.java @@ -0,0 +1,47 @@ +package com.gmail.nossr50.party.commands; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.party.Party; +import com.gmail.nossr50.party.PartyManager; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.Users; + +public class PartyDisbandCommand implements CommandExecutor { + private Player player; + private Party playerParty; + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (!Permissions.hasPermission(sender, "mcmmo.commands.party.disband")) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + player = (Player) sender; + playerParty = Users.getPlayer(player).getParty(); + + if (!playerParty.getLeader().equals(player.getName())) { + sender.sendMessage(LocaleLoader.getString("Party.NotOwner")); + return true; + } + + for (Player member : playerParty.getOnlineMembers()) { + if (!PartyManager.handlePartyChangeEvent(member, playerParty.getName(), null, EventReason.KICKED_FROM_PARTY)) { + return true; + } + + member.sendMessage(LocaleLoader.getString("Party.Disband")); + } + + PartyManager.disbandParty(playerParty); + return true; + + } + +} From a597a7d281c149b08116cb08f6ac2539b5e0373f Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 11 Feb 2013 15:24:20 -0500 Subject: [PATCH 05/44] Add usage string. --- .../party/commands/PartyDisbandCommand.java | 34 ++++++++++++------- 1 file changed, 21 insertions(+), 13 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyDisbandCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyDisbandCommand.java index 839ca7370..4752d38ec 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyDisbandCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyDisbandCommand.java @@ -23,25 +23,33 @@ public class PartyDisbandCommand implements CommandExecutor { return true; } - player = (Player) sender; - playerParty = Users.getPlayer(player).getParty(); + switch (args.length) { + case 1: + player = (Player) sender; + playerParty = Users.getPlayer(player).getParty(); - if (!playerParty.getLeader().equals(player.getName())) { - sender.sendMessage(LocaleLoader.getString("Party.NotOwner")); - return true; - } - - for (Player member : playerParty.getOnlineMembers()) { - if (!PartyManager.handlePartyChangeEvent(member, playerParty.getName(), null, EventReason.KICKED_FROM_PARTY)) { + if (!playerParty.getLeader().equals(player.getName())) { + sender.sendMessage(LocaleLoader.getString("Party.NotOwner")); return true; } - member.sendMessage(LocaleLoader.getString("Party.Disband")); + for (Player member : playerParty.getOnlineMembers()) { + if (!PartyManager.handlePartyChangeEvent(member, playerParty.getName(), null, EventReason.KICKED_FROM_PARTY)) { + return true; + } + + member.sendMessage(LocaleLoader.getString("Party.Disband")); + } + + PartyManager.disbandParty(playerParty); + return true; + + default: + sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "disband")); + return true; } - PartyManager.disbandParty(playerParty); - return true; - + } } From e8ac3c812f242de5be5e6f868683de337f8e05e4 Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 11 Feb 2013 15:24:38 -0500 Subject: [PATCH 06/44] Fix formatting. --- .../com/gmail/nossr50/party/commands/PartyDisbandCommand.java | 3 --- 1 file changed, 3 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyDisbandCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyDisbandCommand.java index 4752d38ec..2487381e2 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyDisbandCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyDisbandCommand.java @@ -48,8 +48,5 @@ public class PartyDisbandCommand implements CommandExecutor { sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "disband")); return true; } - - } - } From e66ff53ca4f87524e18ba0f61f6650e4cfdc73c9 Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 11 Feb 2013 15:33:25 -0500 Subject: [PATCH 07/44] Convert /party owner to a subcommand. --- .../commands/PartyChangeOwnerCommand.java | 49 +++++++++++++++++++ .../nossr50/party/commands/PartyCommand.java | 31 +----------- 2 files changed, 51 insertions(+), 29 deletions(-) create mode 100644 src/main/java/com/gmail/nossr50/party/commands/PartyChangeOwnerCommand.java diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyChangeOwnerCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyChangeOwnerCommand.java new file mode 100644 index 000000000..1435497be --- /dev/null +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyChangeOwnerCommand.java @@ -0,0 +1,49 @@ +package com.gmail.nossr50.party.commands; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.mcMMO; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.party.Party; +import com.gmail.nossr50.party.PartyManager; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.Users; + +public class PartyChangeOwnerCommand implements CommandExecutor { + private Player player; + private Party playerParty; + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (!Permissions.hasPermission(sender, "mcmmo.commands.party.owner")) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + switch (args.length) { + case 2: + player = (Player) sender; + playerParty = Users.getPlayer(player).getParty(); + + if (!playerParty.getLeader().equals(player.getName())) { + sender.sendMessage(LocaleLoader.getString("Party.NotOwner")); + return true; + } + + if (!playerParty.getMembers().contains(mcMMO.p.getServer().getOfflinePlayer(args[1]))) { + player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", args[1])); + return true; + } + + PartyManager.setPartyLeader(args[1], playerParty); + return true; + + default: + sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "owner", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]")); + return true; + } + } +} diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java index 12144ba1b..7c59f5ee9 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java @@ -32,6 +32,7 @@ public class PartyCommand implements CommandExecutor { private CommandExecutor partyInviteCommand = new PartyInviteCommand(); private CommandExecutor partyKickCommand = new PartyKickCommand(); private CommandExecutor partyDisbandCommand = new PartyDisbandCommand(); + private CommandExecutor partyChangeOwnerCommand = new PartyChangeOwnerCommand(); @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { @@ -88,7 +89,7 @@ public class PartyCommand implements CommandExecutor { return partyDisbandCommand.onCommand(sender, command, label, args); } else if (args[0].equalsIgnoreCase("owner")) { - return changeOwner(args); + return partyChangeOwnerCommand.onCommand(sender, command, label, args); } else if (args[0].equalsIgnoreCase("lock")) { return lock(); @@ -190,34 +191,6 @@ public class PartyCommand implements CommandExecutor { return true; } - /** - * Change the owner of the current party - */ - private boolean changeOwner(String[] args) { - if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.party.owner")) { - return true; - } - - String playerName = player.getName(); - Party party = mcMMOPlayer.getParty(); - - if (args.length < 2) { - player.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "owner", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]")); - return true; - } - - if (party.getLeader().equals(playerName)) { - if (!party.getMembers().contains(mcMMO.p.getServer().getOfflinePlayer(args[1]))) { - player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", args[1])); - return true; - } - - PartyManager.setPartyLeader(args[1], party); - } - - return true; - } - /** * Lock the current party */ From 2d6fb72b9d04f30e6fe73064501528f53ba40d4c Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 11 Feb 2013 15:41:23 -0500 Subject: [PATCH 08/44] Use <>, not [] --- .../gmail/nossr50/party/commands/PartyChangeOwnerCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyChangeOwnerCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyChangeOwnerCommand.java index 1435497be..684bcaa54 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyChangeOwnerCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyChangeOwnerCommand.java @@ -42,7 +42,7 @@ public class PartyChangeOwnerCommand implements CommandExecutor { return true; default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "owner", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]")); + sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "owner", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">")); return true; } } From 98a64a09486028a678091b8014361ed2da3ee226 Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 11 Feb 2013 17:31:09 -0500 Subject: [PATCH 09/44] Convert /party lock & /party unlock to a subcommand. --- .../nossr50/party/commands/PartyCommand.java | 71 +------------ .../party/commands/PartyLockCommand.java | 99 +++++++++++++++++++ 2 files changed, 102 insertions(+), 68 deletions(-) create mode 100644 src/main/java/com/gmail/nossr50/party/commands/PartyLockCommand.java diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java index 7c59f5ee9..53380f291 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java @@ -33,6 +33,7 @@ public class PartyCommand implements CommandExecutor { private CommandExecutor partyKickCommand = new PartyKickCommand(); private CommandExecutor partyDisbandCommand = new PartyDisbandCommand(); private CommandExecutor partyChangeOwnerCommand = new PartyChangeOwnerCommand(); + private CommandExecutor partyLockCommand = new PartyLockCommand(); @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { @@ -91,11 +92,8 @@ public class PartyCommand implements CommandExecutor { else if (args[0].equalsIgnoreCase("owner")) { return partyChangeOwnerCommand.onCommand(sender, command, label, args); } - else if (args[0].equalsIgnoreCase("lock")) { - return lock(); - } - else if (args[0].equalsIgnoreCase("unlock")) { - return unlock(); + else if (args[0].equalsIgnoreCase("lock") || args[0].equalsIgnoreCase("unlock")) { + return partyLockCommand.onCommand(sender, command, label, args); } else if (args[0].equalsIgnoreCase("password")) { return changePassword(args); @@ -191,69 +189,6 @@ public class PartyCommand implements CommandExecutor { return true; } - /** - * Lock the current party - */ - private boolean lock() { - if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.party.lock")) { - return true; - } - - String playerName = player.getName(); - Party party = mcMMOPlayer.getParty(); - - if (party == null) { - player.sendMessage("Commands.Party.None"); - return true; - } - - if (!party.getLeader().equals(playerName)) { - player.sendMessage(LocaleLoader.getString("Party.NotOwner")); - return true; - } - - if (party.isLocked()) { - player.sendMessage(LocaleLoader.getString("Party.IsLocked")); - } - else { - party.setLocked(true); - player.sendMessage(LocaleLoader.getString("Party.Locked")); - } - - return true; - } - - /** - * Unlock the current party - */ - private boolean unlock() { - if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.party.unlock")) { - return true; - } - - String playerName = player.getName(); - Party party = mcMMOPlayer.getParty(); - - if (party == null) { - player.sendMessage("Commands.Party.None"); - return true; - } - - if (!party.getLeader().equals(playerName)) { - player.sendMessage(LocaleLoader.getString("Party.NotOwner")); - return true; - } - - if (!party.isLocked()) { - player.sendMessage(LocaleLoader.getString("Party.IsntLocked")); - } - else { - party.setLocked(false); - player.sendMessage(LocaleLoader.getString("Party.Unlocked")); - } - return true; - } - private boolean changePassword(String[] args) { if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.party.password")) { return true; diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyLockCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyLockCommand.java new file mode 100644 index 000000000..9458af459 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyLockCommand.java @@ -0,0 +1,99 @@ +package com.gmail.nossr50.party.commands; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.party.Party; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.Users; + +public class PartyLockCommand implements CommandExecutor { + private Player player; + private Party playerParty; + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + player = (Player) sender; + playerParty = Users.getPlayer(player).getParty(); + + if (!playerParty.getLeader().equals(player.getName())) { + sender.sendMessage(LocaleLoader.getString("Party.NotOwner")); + return true; + } + + switch (args.length) { + case 1: + if (args[0].equalsIgnoreCase("lock")) { + lockParty(sender, command); + } + else if (args[0].equalsIgnoreCase("unlock")) { + unlockParty(sender, command); + } + + return true; + + case 2: + if (!args[0].equalsIgnoreCase("lock")) { + sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "lock", "[on|off]")); + return true; + } + + if (args[1].equalsIgnoreCase("on") || args[1].equalsIgnoreCase("true")) { + lockParty(sender, command); + } + else if (args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("false")) { + unlockParty(sender, command); + } + else { + sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "lock", "[on|off]")); + } + + return true; + + default: + sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "lock", "[on|off]")); + return true; + } + } + + /** + * Handle locking a party. + */ + private void lockParty(CommandSender sender, Command command) { + if (!Permissions.hasPermission(sender, "mcmmo.commands.party.lock")) { + sender.sendMessage(command.getPermissionMessage()); + return; + } + + if (playerParty.isLocked()) { + sender.sendMessage(LocaleLoader.getString("Party.IsLocked")); + return; + } + + playerParty.setLocked(true); + sender.sendMessage(LocaleLoader.getString("Party.Locked")); + } + + /** + * Handle unlocking a party. + * + * @return true if party is successfully unlocked, false otherwise. + */ + private void unlockParty(CommandSender sender, Command command) { + if (!Permissions.hasPermission(sender, "mcmmo.commands.party.unlock")) { + sender.sendMessage(command.getPermissionMessage()); + return; + } + + if (!playerParty.isLocked()) { + player.sendMessage(LocaleLoader.getString("Party.IsntLocked")); + return; + } + + playerParty.setLocked(false); + player.sendMessage(LocaleLoader.getString("Party.Unlocked")); + } +} From 76523d2988e58091d86497889aed4cf8971b77d9 Mon Sep 17 00:00:00 2001 From: GJ Date: Mon, 11 Feb 2013 17:35:01 -0500 Subject: [PATCH 10/44] 3% != 100% - Fixes #671 --- src/main/java/com/gmail/nossr50/skills/fishing/ShakeMob.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/ShakeMob.java b/src/main/java/com/gmail/nossr50/skills/fishing/ShakeMob.java index 765af8746..584b7cc24 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/ShakeMob.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/ShakeMob.java @@ -148,7 +148,7 @@ public final class ShakeMob { possibleDrops.put(new ItemStack(Material.RED_MUSHROOM, Misc.getRandom().nextInt(3) + 1), 30); break; case PIG: - possibleDrops.put(new ItemStack(Material.PORK), 3); + possibleDrops.put(new ItemStack(Material.PORK), 100); break; case PIG_ZOMBIE: possibleDrops.put(new ItemStack(Material.ROTTEN_FLESH), 50); From 45ebc2b89bd41f964eb78b81f4dfcad97354ac2b Mon Sep 17 00:00:00 2001 From: bm01 Date: Mon, 11 Feb 2013 23:39:41 +0100 Subject: [PATCH 11/44] 3% != 100% --- src/main/java/com/gmail/nossr50/skills/fishing/ShakeMob.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/skills/fishing/ShakeMob.java b/src/main/java/com/gmail/nossr50/skills/fishing/ShakeMob.java index 584b7cc24..e78396965 100644 --- a/src/main/java/com/gmail/nossr50/skills/fishing/ShakeMob.java +++ b/src/main/java/com/gmail/nossr50/skills/fishing/ShakeMob.java @@ -138,7 +138,7 @@ public final class ShakeMob { possibleDrops.put(new ItemStack(Material.RED_ROSE), 85); break; case MAGMA_CUBE: - possibleDrops.put(new ItemStack(Material.MAGMA_CREAM), 3); + possibleDrops.put(new ItemStack(Material.MAGMA_CREAM), 100); break; case MUSHROOM_COW: possibleDrops.put(new ItemStack(Material.MILK_BUCKET), 5); From e5c7e81b08d9c5a140c97c5a55ae415c283ddedd Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 12 Feb 2013 01:41:51 -0500 Subject: [PATCH 12/44] No point in repeating this check over multiple classes. --- .../party/commands/PartyChangeOwnerCommand.java | 13 ++----------- .../gmail/nossr50/party/commands/PartyCommand.java | 8 +++++++- .../nossr50/party/commands/PartyDisbandCommand.java | 11 +---------- .../nossr50/party/commands/PartyKickCommand.java | 12 +----------- .../nossr50/party/commands/PartyLockCommand.java | 13 +++---------- 5 files changed, 14 insertions(+), 43 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyChangeOwnerCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyChangeOwnerCommand.java index 684bcaa54..bcbbd4fa5 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyChangeOwnerCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyChangeOwnerCommand.java @@ -13,9 +13,6 @@ import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Users; public class PartyChangeOwnerCommand implements CommandExecutor { - private Player player; - private Party playerParty; - @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (!Permissions.hasPermission(sender, "mcmmo.commands.party.owner")) { @@ -25,16 +22,10 @@ public class PartyChangeOwnerCommand implements CommandExecutor { switch (args.length) { case 2: - player = (Player) sender; - playerParty = Users.getPlayer(player).getParty(); - - if (!playerParty.getLeader().equals(player.getName())) { - sender.sendMessage(LocaleLoader.getString("Party.NotOwner")); - return true; - } + Party playerParty = Users.getPlayer((Player) sender).getParty(); if (!playerParty.getMembers().contains(mcMMO.p.getServer().getOfflinePlayer(args[1]))) { - player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", args[1])); + sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", args[1])); return true; } diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java index 53380f291..9cfdb81d4 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java @@ -83,7 +83,13 @@ public class PartyCommand implements CommandExecutor { else if (args[0].equalsIgnoreCase("invite")) { return partyInviteCommand.onCommand(sender, command, label, args); } - else if (args[0].equalsIgnoreCase("kick")) { + + if (!mcMMOPlayer.getParty().getLeader().equals(player.getName())) { + sender.sendMessage(LocaleLoader.getString("Party.NotOwner")); + return true; + } + + if (args[0].equalsIgnoreCase("kick")) { return partyKickCommand.onCommand(sender, command, label, args); } else if (args[0].equalsIgnoreCase("disband")) { diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyDisbandCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyDisbandCommand.java index 2487381e2..7dc3f34f5 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyDisbandCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyDisbandCommand.java @@ -13,9 +13,6 @@ import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Users; public class PartyDisbandCommand implements CommandExecutor { - private Player player; - private Party playerParty; - @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (!Permissions.hasPermission(sender, "mcmmo.commands.party.disband")) { @@ -25,13 +22,7 @@ public class PartyDisbandCommand implements CommandExecutor { switch (args.length) { case 1: - player = (Player) sender; - playerParty = Users.getPlayer(player).getParty(); - - if (!playerParty.getLeader().equals(player.getName())) { - sender.sendMessage(LocaleLoader.getString("Party.NotOwner")); - return true; - } + Party playerParty = Users.getPlayer((Player) sender).getParty(); for (Player member : playerParty.getOnlineMembers()) { if (!PartyManager.handlePartyChangeEvent(member, playerParty.getName(), null, EventReason.KICKED_FROM_PARTY)) { diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyKickCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyKickCommand.java index 71e5b3823..faf1f60ac 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyKickCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyKickCommand.java @@ -15,9 +15,6 @@ import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Users; public class PartyKickCommand implements CommandExecutor { - private Player player; - private Party playerParty; - @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { if (!Permissions.hasPermission(sender, "mcmmo.commands.party.kick")) { @@ -27,13 +24,7 @@ public class PartyKickCommand implements CommandExecutor { switch (args.length) { case 2: - player = (Player) sender; - playerParty = Users.getPlayer(player).getParty(); - - if (!playerParty.getLeader().equals(player.getName())) { - sender.sendMessage(LocaleLoader.getString("Party.NotOwner")); - return true; - } + Party playerParty = Users.getPlayer((Player) sender).getParty(); OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(args[1]); @@ -61,5 +52,4 @@ public class PartyKickCommand implements CommandExecutor { return true; } } - } diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyLockCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyLockCommand.java index 9458af459..d6b68e269 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyLockCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyLockCommand.java @@ -11,18 +11,11 @@ import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Users; public class PartyLockCommand implements CommandExecutor { - private Player player; private Party playerParty; @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - player = (Player) sender; - playerParty = Users.getPlayer(player).getParty(); - - if (!playerParty.getLeader().equals(player.getName())) { - sender.sendMessage(LocaleLoader.getString("Party.NotOwner")); - return true; - } + playerParty = Users.getPlayer((Player) sender).getParty(); switch (args.length) { case 1: @@ -89,11 +82,11 @@ public class PartyLockCommand implements CommandExecutor { } if (!playerParty.isLocked()) { - player.sendMessage(LocaleLoader.getString("Party.IsntLocked")); + sender.sendMessage(LocaleLoader.getString("Party.IsntLocked")); return; } playerParty.setLocked(false); - player.sendMessage(LocaleLoader.getString("Party.Unlocked")); + sender.sendMessage(LocaleLoader.getString("Party.Unlocked")); } } From 70f588cce11c3cb318317c9755a229a23551e096 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 12 Feb 2013 01:45:56 -0500 Subject: [PATCH 13/44] Don't print usage here. --- .../java/com/gmail/nossr50/party/commands/PartyCommand.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java index 9cfdb81d4..029784edc 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java @@ -68,7 +68,7 @@ public class PartyCommand implements CommandExecutor { if (!mcMMOPlayer.inParty()) { sender.sendMessage(LocaleLoader.getString("Commands.Party.None")); - return printUsage(); + return true; } if (args[0].equalsIgnoreCase("quit") || args[0].equalsIgnoreCase("q") || args[0].equalsIgnoreCase("leave")) { From c822be4a53400b62f21ed721a5083dafec344b53 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 12 Feb 2013 08:39:45 -0500 Subject: [PATCH 14/44] Add other usage string. --- .../nossr50/party/commands/PartyLockCommand.java | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyLockCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyLockCommand.java index d6b68e269..d20fba6a8 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyLockCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyLockCommand.java @@ -30,7 +30,7 @@ public class PartyLockCommand implements CommandExecutor { case 2: if (!args[0].equalsIgnoreCase("lock")) { - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "lock", "[on|off]")); + sendUsageStrings(sender); return true; } @@ -41,13 +41,13 @@ public class PartyLockCommand implements CommandExecutor { unlockParty(sender, command); } else { - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "lock", "[on|off]")); + sendUsageStrings(sender); } return true; default: - sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "lock", "[on|off]")); + sendUsageStrings(sender); return true; } } @@ -89,4 +89,9 @@ public class PartyLockCommand implements CommandExecutor { playerParty.setLocked(false); sender.sendMessage(LocaleLoader.getString("Party.Unlocked")); } + + private void sendUsageStrings(CommandSender sender) { + sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "lock", "[on|off]")); + sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "unlock")); + } } From 288907cfd42a14a35b1dfaf6c42e644d54da692d Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 12 Feb 2013 08:57:35 -0500 Subject: [PATCH 15/44] Convert /party password to a subcommand. --- .../commands/PartyChangePasswordCommand.java | 55 +++++++++++++++++++ .../nossr50/party/commands/PartyCommand.java | 30 +--------- 2 files changed, 57 insertions(+), 28 deletions(-) create mode 100644 src/main/java/com/gmail/nossr50/party/commands/PartyChangePasswordCommand.java diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyChangePasswordCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyChangePasswordCommand.java new file mode 100644 index 000000000..7f42dfcf8 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyChangePasswordCommand.java @@ -0,0 +1,55 @@ +package com.gmail.nossr50.party.commands; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.party.Party; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.Users; + +public class PartyChangePasswordCommand implements CommandExecutor { + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (!Permissions.hasPermission(sender, "mcmmo.commands.party.password")) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + Party playerParty = Users.getPlayer((Player) sender).getParty(); + switch (args.length) { + case 1: + unprotectParty(sender, playerParty); + return true; + + case 2: + if (args[1].equalsIgnoreCase("clear") || args[1].equalsIgnoreCase("reset")) { + unprotectParty(sender, playerParty); + return true; + } + + protectParty(sender, playerParty, args[1]); + return true; + + default: + sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "password", "[clear|reset]")); + sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "password", "<" + LocaleLoader.getString("Commands.Usage.Password") + ">")); + return true; + } + } + + private void unprotectParty(CommandSender sender, Party playerParty) { + playerParty.setLocked(true); + playerParty.setPassword(null); + sender.sendMessage(LocaleLoader.getString("Party.Password.Removed")); + } + + private void protectParty(CommandSender sender, Party playerParty, String password) { + playerParty.setLocked(true); + playerParty.setPassword(password); + sender.sendMessage(LocaleLoader.getString("Party.Password.Set", password)); + } +} diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java index 029784edc..064ccf349 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java @@ -34,6 +34,7 @@ public class PartyCommand implements CommandExecutor { private CommandExecutor partyDisbandCommand = new PartyDisbandCommand(); private CommandExecutor partyChangeOwnerCommand = new PartyChangeOwnerCommand(); private CommandExecutor partyLockCommand = new PartyLockCommand(); + private CommandExecutor partyChangePasswordCommand = new PartyChangePasswordCommand(); @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { @@ -102,7 +103,7 @@ public class PartyCommand implements CommandExecutor { return partyLockCommand.onCommand(sender, command, label, args); } else if (args[0].equalsIgnoreCase("password")) { - return changePassword(args); + return partyChangePasswordCommand.onCommand(sender, command, label, args); } else if (args[0].equalsIgnoreCase("rename")) { return rename(args); @@ -195,33 +196,6 @@ public class PartyCommand implements CommandExecutor { return true; } - private boolean changePassword(String[] args) { - if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.party.password")) { - return true; - } - - String playerName = player.getName(); - Party party = mcMMOPlayer.getParty(); - - if (!party.getLeader().equals(playerName)) { - player.sendMessage(LocaleLoader.getString("Party.NotOwner")); - return true; - } - - if (args.length < 2) { - party.setLocked(true); - party.setPassword(null); - player.sendMessage(LocaleLoader.getString("Party.Password.Removed")); - return true; - } - - party.setLocked(true); - party.setPassword(args[1]); - player.sendMessage(LocaleLoader.getString("Party.Password.Set", args[1])); - - return true; - } - /** * Rename the current party */ From 200ac53078d0951ab5f85ad7bf5d18262dbe2ad1 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 12 Feb 2013 09:22:36 -0500 Subject: [PATCH 16/44] Add function to get a list of all players in a party to the API. --- src/main/java/com/gmail/nossr50/api/PartyAPI.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/api/PartyAPI.java b/src/main/java/com/gmail/nossr50/api/PartyAPI.java index 9fe7af7f2..b8c540e14 100644 --- a/src/main/java/com/gmail/nossr50/api/PartyAPI.java +++ b/src/main/java/com/gmail/nossr50/api/PartyAPI.java @@ -125,8 +125,7 @@ public final class PartyAPI { * @return all the players in the player's party * @deprecated */ - // TODO: I naively tried to add another getAllMembers that returns a List, but that wasn't possible - // since the return type isn't part of the the method's signature. If anybody has an idea... + @Deprecated public static List getAllMembers(Player player) { List memberNames = new ArrayList(); @@ -137,6 +136,18 @@ public final class PartyAPI { return memberNames; } + /** + * 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 static List getOnlineAndOfflineMembers(Player player) { + return PartyManager.getAllMembers(player); + } + /** * Get a list of all online players in this party. *
From e92c6b8f268c6a317edd6c73342011ecaef0e8d3 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 12 Feb 2013 09:22:57 -0500 Subject: [PATCH 17/44] Convert /party rename to a subcommand --- .../nossr50/party/commands/PartyCommand.java | 61 +---------------- .../party/commands/PartyRenameCommand.java | 65 +++++++++++++++++++ .../resources/locale/locale_en_US.properties | 1 + 3 files changed, 68 insertions(+), 59 deletions(-) create mode 100644 src/main/java/com/gmail/nossr50/party/commands/PartyRenameCommand.java diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java index 064ccf349..29df41f96 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java @@ -7,12 +7,9 @@ import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; -import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.commands.CommandHelper; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.datatypes.McMMOPlayer; -import com.gmail.nossr50.events.party.McMMOPartyChangeEvent; -import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.party.Party; import com.gmail.nossr50.party.PartyManager; @@ -35,6 +32,7 @@ public class PartyCommand implements CommandExecutor { private CommandExecutor partyChangeOwnerCommand = new PartyChangeOwnerCommand(); private CommandExecutor partyLockCommand = new PartyLockCommand(); private CommandExecutor partyChangePasswordCommand = new PartyChangePasswordCommand(); + private CommandExecutor partyRenameCommand = new PartyRenameCommand(); @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { @@ -106,7 +104,7 @@ public class PartyCommand implements CommandExecutor { return partyChangePasswordCommand.onCommand(sender, command, label, args); } else if (args[0].equalsIgnoreCase("rename")) { - return rename(args); + return partyRenameCommand.onCommand(sender, command, label, args); } else { return printUsage(); @@ -195,59 +193,4 @@ public class PartyCommand implements CommandExecutor { player.sendMessage(LocaleLoader.getString("Party.Help.8")); return true; } - - /** - * Rename the current party - */ - private boolean rename(String[] args) { - if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.party.rename")) { - return true; - } - - String playerName = player.getName(); - Party party = mcMMOPlayer.getParty(); - String leader = party.getLeader(); - - if (party.getLeader().equals(playerName)) { - if (args.length < 2) { - player.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "rename", "<" + LocaleLoader.getString("Commands.Usage.PartyName") + ">")); - return true; - } - - String newPartyName = args[1]; - - // This is to prevent party leaders from spamming other players with the rename message - if (!party.getName().equals(newPartyName)) { - Party newParty = PartyManager.getParty(newPartyName); - - // Check to see if the party exists, and if it does cancel renaming the party - if (newParty != null) { - player.sendMessage(LocaleLoader.getString("Commands.Party.AlreadyExists", newPartyName)); - return true; - } - - for (Player onlineMembers : party.getOnlineMembers()) { - McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(onlineMembers, party.getName(), newPartyName, EventReason.CHANGED_PARTIES); - mcMMO.p.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { - return true; - } - - if (!onlineMembers.getName().equals(leader)) { - onlineMembers.sendMessage(LocaleLoader.getString("Party.InformedOnNameChange", leader, newPartyName)); - } - } - - party.setName(newPartyName); - } - - player.sendMessage(LocaleLoader.getString("Commands.Party.Rename", newPartyName)); - } - else { - player.sendMessage(LocaleLoader.getString("Party.NotOwner")); - } - - return true; - } } diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyRenameCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyRenameCommand.java new file mode 100644 index 000000000..9ae2dea45 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyRenameCommand.java @@ -0,0 +1,65 @@ +package com.gmail.nossr50.party.commands; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.party.Party; +import com.gmail.nossr50.party.PartyManager; +import com.gmail.nossr50.util.Permissions; +import com.gmail.nossr50.util.Users; + +public class PartyRenameCommand implements CommandExecutor { + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (!Permissions.hasPermission(sender, "mcmmo.commands.party.rename")) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + Party playerParty = Users.getPlayer((Player) sender).getParty(); + String leaderName = playerParty.getLeader(); + + switch (args.length) { + case 2: + String newPartyName = args[1]; + + // This is to prevent party leaders from spamming other players with the rename message + if (playerParty.getName().equalsIgnoreCase(newPartyName)) { + sender.sendMessage(LocaleLoader.getString("Party.Rename.Same")); + return true; + } + + Party newParty = PartyManager.getParty(newPartyName); + + // Check to see if the party exists, and if it does cancel renaming the party + if (newParty != null) { + sender.sendMessage(LocaleLoader.getString("Commands.Party.AlreadyExists", newPartyName)); + return true; + } + + for (Player member : playerParty.getOnlineMembers()) { + if (!PartyManager.handlePartyChangeEvent(member, playerParty.getName(), newPartyName, EventReason.CHANGED_PARTIES)) { + return true; + } + + if (!member.getName().equals(leaderName)) { + member.sendMessage(LocaleLoader.getString("Party.InformedOnNameChange", leaderName, newPartyName)); + } + } + + playerParty.setName(newPartyName); + + sender.sendMessage(LocaleLoader.getString("Commands.Party.Rename", newPartyName)); + return true; + + default: + sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "rename", "<" + LocaleLoader.getString("Commands.Usage.PartyName") + ">")); + return true; + } + } +} diff --git a/src/main/resources/locale/locale_en_US.properties b/src/main/resources/locale/locale_en_US.properties index 51f719705..c8cf6e036 100644 --- a/src/main/resources/locale/locale_en_US.properties +++ b/src/main/resources/locale/locale_en_US.properties @@ -543,6 +543,7 @@ Party.Teleport.Player=[[GREEN]]You have teleported to {0}. Party.Teleport.Self=[[RED]]You can't teleport to yourself! Party.Teleport.Target=[[GREEN]]{0} has teleported to you. Party.Teleport.Disabled=[[RED]]{0} doesn't allow party teleportation. +Party.Rename.Same=[[RED]]That is already the name of your party! Party.Join.Self=[[RED]]You can't join to yourself! Party.Unlocked=[[GRAY]]Party is unlocked Party.Disband=[[GRAY]]The party has been disbanded From 5a48d5c5f84d24a2cedfbfeb221784f1a33d4236 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 12 Feb 2013 10:42:42 -0500 Subject: [PATCH 18/44] Convert /party info to a subcommand --- .../nossr50/party/commands/PartyCommand.java | 71 +----------- .../party/commands/PartyInfoCommand.java | 108 ++++++++++++++++++ .../resources/locale/locale_en_US.properties | 4 +- 3 files changed, 113 insertions(+), 70 deletions(-) create mode 100644 src/main/java/com/gmail/nossr50/party/commands/PartyInfoCommand.java diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java index 29df41f96..f83202691 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java @@ -33,6 +33,7 @@ public class PartyCommand implements CommandExecutor { private CommandExecutor partyLockCommand = new PartyLockCommand(); private CommandExecutor partyChangePasswordCommand = new PartyChangePasswordCommand(); private CommandExecutor partyRenameCommand = new PartyRenameCommand(); + private CommandExecutor partyInfoCommand = new PartyInfoCommand(); @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { @@ -49,10 +50,9 @@ public class PartyCommand implements CommandExecutor { mcMMOPlayer = Users.getPlayer(player); if (args.length < 1 || args[0].equalsIgnoreCase("info")) { - return party(); + return partyInfoCommand.onCommand(sender, command, label, args); } - - if (args[0].equalsIgnoreCase("join")) { + else if (args[0].equalsIgnoreCase("join")) { return partyJoinCommand.onCommand(sender, command, label, args); } else if (args[0].equalsIgnoreCase("accept")) { @@ -118,71 +118,6 @@ public class PartyCommand implements CommandExecutor { return true; } - private boolean party() { - if (mcMMOPlayer.inParty()) { - Party party = mcMMOPlayer.getParty(); - String leader = party.getLeader(); - StringBuilder tempList = new StringBuilder(); - - int membersNear = PartyManager.getNearMembers(player, party, Config.getInstance().getPartyShareRange()).size(); - int membersOnline = party.getOnlineMembers().size() - 1; - - String ItemShare = ""; - String ExpShare = ""; - String Split = ""; - - for (OfflinePlayer otherMember : party.getMembers()) { - if (leader.equals(otherMember.getName())) { - tempList.append(ChatColor.GOLD); - } - else if (otherMember.isOnline()) { - tempList.append(ChatColor.WHITE); - } - else { - tempList.append(ChatColor.GRAY); - } - - tempList.append(otherMember.getName()).append(" "); - } - - String status = LocaleLoader.getString("Party.Status.Locked"); - if (!party.isLocked()) { - status = LocaleLoader.getString("Party.Status.Unlocked"); - } - - player.sendMessage(LocaleLoader.getString("Commands.Party.Header")); - player.sendMessage(LocaleLoader.getString("Commands.Party.Status", party.getName(), status)); - - boolean xpShareEnabled = Config.getInstance().getExpShareEnabled(); - boolean itemShareEnabled = Config.getInstance().getItemShareEnabled(); - - if (xpShareEnabled) { - ExpShare = LocaleLoader.getString("Commands.Party.ExpShare", party.getXpShareMode().toString()); - } - - if (itemShareEnabled) { - ItemShare = LocaleLoader.getString("Commands.Party.ItemShare", party.getItemShareMode().toString()); - } - - if (xpShareEnabled && itemShareEnabled) { - Split = ChatColor.DARK_GRAY + " || "; - } - - if (xpShareEnabled || itemShareEnabled) { - player.sendMessage(LocaleLoader.getString("Commands.Party.ShareMode") + ExpShare + Split + ItemShare); - } - - player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header")); - player.sendMessage(LocaleLoader.getString("Commands.Party.MembersNear", membersNear, membersOnline)); - player.sendMessage(LocaleLoader.getString("Commands.Party.Members", tempList)); - } - else { - return printUsage(); - } - - return true; - } - private boolean printHelp() { player.sendMessage(LocaleLoader.getString("Party.Help.3")); player.sendMessage(LocaleLoader.getString("Party.Help.1")); diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyInfoCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyInfoCommand.java new file mode 100644 index 000000000..0c4490b9b --- /dev/null +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyInfoCommand.java @@ -0,0 +1,108 @@ +package com.gmail.nossr50.party.commands; + +import org.bukkit.ChatColor; +import org.bukkit.OfflinePlayer; +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; +import org.bukkit.entity.Player; + +import com.gmail.nossr50.config.Config; +import com.gmail.nossr50.datatypes.McMMOPlayer; +import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.party.Party; +import com.gmail.nossr50.party.PartyManager; +import com.gmail.nossr50.util.Users; + +public class PartyInfoCommand implements CommandExecutor { + private Player player; + private Party playerParty; + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + player = (Player) sender; + McMMOPlayer mcMMOPlayer = Users.getPlayer(player); + + if (!mcMMOPlayer.inParty()) { + sendUsageStrings(sender); + } + + playerParty = mcMMOPlayer.getParty(); + + displayPartyHeader(); + displayShareModeInfo(); + displayMemberInfo(); + return true; + } + + private void sendUsageStrings(CommandSender sender) { + sender.sendMessage(LocaleLoader.getString("Party.Help.0", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">", "[" + LocaleLoader.getString("Commands.Usage.Password") + "]")); + sender.sendMessage(LocaleLoader.getString("Party.Help.1", "<" + LocaleLoader.getString("Commands.Usage.PartyName") + ">", "[" + LocaleLoader.getString("Commands.Usage.Password") + "]")); + sender.sendMessage(LocaleLoader.getString("Party.Help.2")); + } + + private String createMembersList() { + StringBuilder memberList = new StringBuilder(); + + for (OfflinePlayer member : playerParty.getMembers()) { + if (playerParty.getLeader().equals(member.getName())) { + memberList.append(ChatColor.GOLD).append(member.getName()).append(" "); + } + else if (member.isOnline()) { + memberList.append(ChatColor.WHITE).append(member.getName()).append(" "); + } + else { + memberList.append(ChatColor.GRAY).append(member.getName()).append(" "); + } + } + + return memberList.toString(); + } + + private void displayShareModeInfo() { + boolean xpShareEnabled = Config.getInstance().getExpShareEnabled(); + boolean itemShareEnabled = Config.getInstance().getItemShareEnabled(); + + if (!xpShareEnabled && !itemShareEnabled) { + return; + } + + String expShareInfo = ""; + String itemShareInfo = ""; + String separator = ""; + + if (xpShareEnabled) { + expShareInfo = LocaleLoader.getString("Commands.Party.ExpShare", playerParty.getXpShareMode().toString()); + } + + if (itemShareEnabled) { + itemShareInfo = LocaleLoader.getString("Commands.Party.ItemShare", playerParty.getItemShareMode().toString()); + } + + if (xpShareEnabled && itemShareEnabled) { + separator = ChatColor.DARK_GRAY + " || "; + } + + player.sendMessage(LocaleLoader.getString("Commands.Party.ShareMode") + expShareInfo + separator + itemShareInfo); + } + + private void displayPartyHeader() { + player.sendMessage(LocaleLoader.getString("Commands.Party.Header")); + + if (playerParty.isLocked()) { + player.sendMessage(LocaleLoader.getString("Commands.Party.Status", playerParty.getName(), LocaleLoader.getString("Party.Status.Locked"))); + } + else { + player.sendMessage(LocaleLoader.getString("Commands.Party.Status", playerParty.getName(), LocaleLoader.getString("Party.Status.Unlocked"))); + } + } + + private void displayMemberInfo() { + int membersNear = PartyManager.getNearMembers(player, playerParty, Config.getInstance().getPartyShareRange()).size(); + int membersOnline = playerParty.getOnlineMembers().size() - 1; + + player.sendMessage(LocaleLoader.getString("Commands.Party.Members.Header")); + player.sendMessage(LocaleLoader.getString("Commands.Party.MembersNear", membersNear, membersOnline)); + player.sendMessage(LocaleLoader.getString("Commands.Party.Members", createMembersList())); + } +} diff --git a/src/main/resources/locale/locale_en_US.properties b/src/main/resources/locale/locale_en_US.properties index c8cf6e036..6c41eabbb 100644 --- a/src/main/resources/locale/locale_en_US.properties +++ b/src/main/resources/locale/locale_en_US.properties @@ -495,7 +495,7 @@ Commands.Usage.3=[[RED]]Proper usage is /{0} {1} {2} {3} Commands.Usage.Level=level Commands.Usage.Message=message Commands.Usage.Page=page -Commands.Usage.PartyName=party-name +Commands.Usage.PartyName=name Commands.Usage.Password=password Commands.Usage.Player=player Commands.Usage.Rate=rate @@ -507,7 +507,7 @@ mcMMO.NoSkillNote=[[DARK_GRAY]]If you don't have access to a skill it will not b ##party Party.Forbidden=[mcMMO] Parties not permitted on this world (See Permissions) -Party.Help.0=[[RED]]Proper usage is [[DARK_AQUA]]/party join [password]. +Party.Help.0=[[RED]]Proper usage is [[DARK_AQUA]]/party join {0} {1}. Party.Help.1=[[RED]]To create a party, use [[DARK_AQUA]]/party create [password] Party.Help.2=[[RED]]Consult [[DARK_AQUA]]/party ? [[RED]]for more information Party.Help.3=[[RED]]Use [[DARK_AQUA]]/party join [[RED]]to join or [[DARK_AQUA]]/party quit [[RED]]to quit From ab731302e068fa7259e5034662ddf5f1742c9295 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 12 Feb 2013 10:42:59 -0500 Subject: [PATCH 19/44] Remove unused imports --- .../java/com/gmail/nossr50/party/commands/PartyCommand.java | 5 ----- 1 file changed, 5 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java index f83202691..db5b71659 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java @@ -1,18 +1,13 @@ package com.gmail.nossr50.party.commands; -import org.bukkit.ChatColor; -import org.bukkit.OfflinePlayer; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import com.gmail.nossr50.commands.CommandHelper; -import com.gmail.nossr50.config.Config; import com.gmail.nossr50.datatypes.McMMOPlayer; import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.party.Party; -import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Users; From 6acfba1315c42d13f86fed1fac8e397bbf93220b Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 12 Feb 2013 11:23:32 -0500 Subject: [PATCH 20/44] Use an enum to handle our subcommands. --- .../nossr50/party/commands/PartyCommand.java | 90 +++++++++++-------- .../party/commands/PartyInfoCommand.java | 11 --- .../party/commands/PartySubcommand.java | 43 +++++++++ 3 files changed, 95 insertions(+), 49 deletions(-) create mode 100644 src/main/java/com/gmail/nossr50/party/commands/PartySubcommand.java diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java index db5b71659..5cb144dff 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java @@ -44,71 +44,85 @@ public class PartyCommand implements CommandExecutor { player = (Player) sender; mcMMOPlayer = Users.getPlayer(player); - if (args.length < 1 || args[0].equalsIgnoreCase("info")) { + if (args.length < 1) { + if (!mcMMOPlayer.inParty()) { + sender.sendMessage(LocaleLoader.getString("Commands.Party.None")); + return printUsage(); + } + return partyInfoCommand.onCommand(sender, command, label, args); } - else if (args[0].equalsIgnoreCase("join")) { - return partyJoinCommand.onCommand(sender, command, label, args); - } - else if (args[0].equalsIgnoreCase("accept")) { - return partyAcceptCommand.onCommand(sender, command, label, args); - } - else if (args[0].equalsIgnoreCase("create")) { - return partyCreateCommand.onCommand(sender, command, label, args); - } - else if (args[0].equalsIgnoreCase("?") || args[0].equalsIgnoreCase("help")) { - return printHelp(); + + PartySubcommand subcommand = PartySubcommand.getSubcommand(args[0]); + + if (subcommand == null) { + return printUsage(); } + switch (subcommand) { + case JOIN: + return partyJoinCommand.onCommand(sender, command, label, args); + case ACCEPT: + return partyAcceptCommand.onCommand(sender, command, label, args); + case CREATE: + return partyCreateCommand.onCommand(sender, command, label, args); + case HELP: + return printHelp(); + default: + break; + } + + // Party member commands if (!mcMMOPlayer.inParty()) { sender.sendMessage(LocaleLoader.getString("Commands.Party.None")); - return true; + return printUsage(); } - if (args[0].equalsIgnoreCase("quit") || args[0].equalsIgnoreCase("q") || args[0].equalsIgnoreCase("leave")) { + switch (subcommand) { + case INFO: + return partyInfoCommand.onCommand(sender, command, label, args); + case QUIT: return partyQuitCommand.onCommand(sender, command, label, args); - } - else if (args[0].equalsIgnoreCase("expshare") || args[0].equalsIgnoreCase("xpshare") || args[0].equalsIgnoreCase("sharexp") || args[0].equalsIgnoreCase("shareexp")) { - return partyExpShareCommand.onCommand(sender, command, label, args); - } - else if (args[0].equalsIgnoreCase("itemshare") || args[0].equalsIgnoreCase("shareitem") || args[0].equalsIgnoreCase("shareitems")) { - return partyItemShareCommand.onCommand(sender, command, label, args); - } - else if (args[0].equalsIgnoreCase("invite")) { + case INVITE: return partyInviteCommand.onCommand(sender, command, label, args); + default: + break; } + // Party leader commands if (!mcMMOPlayer.getParty().getLeader().equals(player.getName())) { sender.sendMessage(LocaleLoader.getString("Party.NotOwner")); return true; } - if (args[0].equalsIgnoreCase("kick")) { + switch (subcommand) { + case EXPSHARE: + return partyExpShareCommand.onCommand(sender, command, label, args); + case ITEMSHARE: + return partyItemShareCommand.onCommand(sender, command, label, args); + case KICK: return partyKickCommand.onCommand(sender, command, label, args); - } - else if (args[0].equalsIgnoreCase("disband")) { + case DISBAND: return partyDisbandCommand.onCommand(sender, command, label, args); - } - else if (args[0].equalsIgnoreCase("owner")) { + case OWNER: return partyChangeOwnerCommand.onCommand(sender, command, label, args); - } - else if (args[0].equalsIgnoreCase("lock") || args[0].equalsIgnoreCase("unlock")) { + case LOCK: + case UNLOCK: return partyLockCommand.onCommand(sender, command, label, args); - } - else if (args[0].equalsIgnoreCase("password")) { + case PASSWORD: return partyChangePasswordCommand.onCommand(sender, command, label, args); - } - else if (args[0].equalsIgnoreCase("rename")) { + case RENAME: return partyRenameCommand.onCommand(sender, command, label, args); + default: + break; } - else { - return printUsage(); - } + + return true; } private boolean printUsage() { - player.sendMessage(LocaleLoader.getString("Party.Help.0")); - player.sendMessage(LocaleLoader.getString("Party.Help.1")); + player.sendMessage(LocaleLoader.getString("Party.Help.0", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">", "[" + LocaleLoader.getString("Commands.Usage.Password") + "]")); + player.sendMessage(LocaleLoader.getString("Party.Help.1", "<" + LocaleLoader.getString("Commands.Usage.PartyName") + ">", "[" + LocaleLoader.getString("Commands.Usage.Password") + "]")); player.sendMessage(LocaleLoader.getString("Party.Help.2")); return true; } diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyInfoCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyInfoCommand.java index 0c4490b9b..f5333109f 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyInfoCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyInfoCommand.java @@ -22,11 +22,6 @@ public class PartyInfoCommand implements CommandExecutor { public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { player = (Player) sender; McMMOPlayer mcMMOPlayer = Users.getPlayer(player); - - if (!mcMMOPlayer.inParty()) { - sendUsageStrings(sender); - } - playerParty = mcMMOPlayer.getParty(); displayPartyHeader(); @@ -35,12 +30,6 @@ public class PartyInfoCommand implements CommandExecutor { return true; } - private void sendUsageStrings(CommandSender sender) { - sender.sendMessage(LocaleLoader.getString("Party.Help.0", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">", "[" + LocaleLoader.getString("Commands.Usage.Password") + "]")); - sender.sendMessage(LocaleLoader.getString("Party.Help.1", "<" + LocaleLoader.getString("Commands.Usage.PartyName") + ">", "[" + LocaleLoader.getString("Commands.Usage.Password") + "]")); - sender.sendMessage(LocaleLoader.getString("Party.Help.2")); - } - private String createMembersList() { StringBuilder memberList = new StringBuilder(); diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartySubcommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartySubcommand.java new file mode 100644 index 000000000..80ae1f495 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/party/commands/PartySubcommand.java @@ -0,0 +1,43 @@ +package com.gmail.nossr50.party.commands; + +public enum PartySubcommand { + JOIN, + ACCEPT, + CREATE, + HELP, + INFO, + QUIT, + EXPSHARE, + ITEMSHARE, + INVITE, + KICK, + DISBAND, + OWNER, + LOCK, + UNLOCK, + PASSWORD, + RENAME; + + public static PartySubcommand getSubcommand(String commandName) { + for (PartySubcommand command : values()) { + if (command.name().equalsIgnoreCase(commandName)) { + return command; + } + } + + if (commandName.equalsIgnoreCase("?")) { + return HELP; + } + else if (commandName.equalsIgnoreCase("q") || commandName.equalsIgnoreCase("leave")) { + return QUIT; + } + else if (commandName.equalsIgnoreCase("xpshare") || commandName.equalsIgnoreCase("shareexp") || commandName.equalsIgnoreCase("sharexp")) { + return EXPSHARE; + } + else if (commandName.equalsIgnoreCase("shareitem") || commandName.equalsIgnoreCase("shareitems")) { + return ITEMSHARE; + } + + return null; + } +} From a60a6355d2c1f12e4dec7df64bd417485a2c58d6 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 12 Feb 2013 11:23:48 -0500 Subject: [PATCH 21/44] We check the leader elsewhere. --- .../gmail/nossr50/party/commands/PartyExpShareCommand.java | 5 ----- .../gmail/nossr50/party/commands/PartyItemShareCommand.java | 5 ----- 2 files changed, 10 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyExpShareCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyExpShareCommand.java index ba18b0bcb..bae7e3850 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyExpShareCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyExpShareCommand.java @@ -29,11 +29,6 @@ public class PartyExpShareCommand implements CommandExecutor { player = (Player) sender; playerParty = Users.getPlayer(player).getParty(); - if (!playerParty.getLeader().equals(player.getName())) { - sender.sendMessage(LocaleLoader.getString("Party.NotOwner")); - return true; - } - if (args[1].equalsIgnoreCase("none") || args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("false")) { handleChangingShareMode(ShareMode.NONE); } diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyItemShareCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyItemShareCommand.java index 4fc4f2c73..7cbd90c2d 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyItemShareCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyItemShareCommand.java @@ -29,11 +29,6 @@ public class PartyItemShareCommand implements CommandExecutor { player = (Player) sender; playerParty = Users.getPlayer(player).getParty(); - if (!playerParty.getLeader().equals(player.getName())) { - sender.sendMessage(LocaleLoader.getString("Party.NotOwner")); - return true; - } - if (args[1].equalsIgnoreCase("none") || args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("false")) { handleChangingShareMode(ShareMode.NONE); } From b2575c9b8fd9c6ae0fd048aad68cc696174d7319 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 12 Feb 2013 11:25:56 -0500 Subject: [PATCH 22/44] Cleanup from removal of leader checks. --- .../gmail/nossr50/party/commands/PartyExpShareCommand.java | 4 +--- .../gmail/nossr50/party/commands/PartyItemShareCommand.java | 4 +--- 2 files changed, 2 insertions(+), 6 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyExpShareCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyExpShareCommand.java index bae7e3850..68d8a0780 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyExpShareCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyExpShareCommand.java @@ -14,7 +14,6 @@ import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Users; public class PartyExpShareCommand implements CommandExecutor { - private Player player; private Party playerParty; @Override @@ -26,8 +25,7 @@ public class PartyExpShareCommand implements CommandExecutor { switch (args.length) { case 2: - player = (Player) sender; - playerParty = Users.getPlayer(player).getParty(); + playerParty = Users.getPlayer((Player) sender).getParty(); if (args[1].equalsIgnoreCase("none") || args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("false")) { handleChangingShareMode(ShareMode.NONE); diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyItemShareCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyItemShareCommand.java index 7cbd90c2d..d204250c3 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyItemShareCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyItemShareCommand.java @@ -14,7 +14,6 @@ import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Users; public class PartyItemShareCommand implements CommandExecutor { - private Player player; private Party playerParty; @Override @@ -26,8 +25,7 @@ public class PartyItemShareCommand implements CommandExecutor { switch (args.length) { case 2: - player = (Player) sender; - playerParty = Users.getPlayer(player).getParty(); + playerParty = Users.getPlayer((Player) sender).getParty(); if (args[1].equalsIgnoreCase("none") || args[1].equalsIgnoreCase("off") || args[1].equalsIgnoreCase("false")) { handleChangingShareMode(ShareMode.NONE); From 8cd9942be6d7deb2f9254d3a173f51c31a4056ba Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 12 Feb 2013 11:37:37 -0500 Subject: [PATCH 23/44] Prevent accidental overtranslation of our commands. --- .../nossr50/party/commands/PartyCommand.java | 20 +++++++++---------- .../resources/locale/locale_en_US.properties | 18 ++++++++--------- 2 files changed, 19 insertions(+), 19 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java index 5cb144dff..6a83d1434 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java @@ -121,20 +121,20 @@ public class PartyCommand implements CommandExecutor { } private boolean printUsage() { - player.sendMessage(LocaleLoader.getString("Party.Help.0", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">", "[" + LocaleLoader.getString("Commands.Usage.Password") + "]")); - player.sendMessage(LocaleLoader.getString("Party.Help.1", "<" + LocaleLoader.getString("Commands.Usage.PartyName") + ">", "[" + LocaleLoader.getString("Commands.Usage.Password") + "]")); - player.sendMessage(LocaleLoader.getString("Party.Help.2")); + player.sendMessage(LocaleLoader.getString("Party.Help.0", "/party join")); + player.sendMessage(LocaleLoader.getString("Party.Help.1", "/party create")); + player.sendMessage(LocaleLoader.getString("Party.Help.2", "/party ?")); return true; } private boolean printHelp() { - player.sendMessage(LocaleLoader.getString("Party.Help.3")); - player.sendMessage(LocaleLoader.getString("Party.Help.1")); - player.sendMessage(LocaleLoader.getString("Party.Help.4")); - player.sendMessage(LocaleLoader.getString("Party.Help.5")); - player.sendMessage(LocaleLoader.getString("Party.Help.6")); - player.sendMessage(LocaleLoader.getString("Party.Help.7")); - player.sendMessage(LocaleLoader.getString("Party.Help.8")); + player.sendMessage(LocaleLoader.getString("Party.Help.3", "/party join", "/party quit")); + player.sendMessage(LocaleLoader.getString("Party.Help.1", "/party create")); + player.sendMessage(LocaleLoader.getString("Party.Help.4", "/party ")); + player.sendMessage(LocaleLoader.getString("Party.Help.5", "/party password")); + player.sendMessage(LocaleLoader.getString("Party.Help.6", "/party kick")); + player.sendMessage(LocaleLoader.getString("Party.Help.7", "/party owner")); + player.sendMessage(LocaleLoader.getString("Party.Help.8", "/party disband")); return true; } } diff --git a/src/main/resources/locale/locale_en_US.properties b/src/main/resources/locale/locale_en_US.properties index 6c41eabbb..a60ce237b 100644 --- a/src/main/resources/locale/locale_en_US.properties +++ b/src/main/resources/locale/locale_en_US.properties @@ -507,15 +507,15 @@ mcMMO.NoSkillNote=[[DARK_GRAY]]If you don't have access to a skill it will not b ##party Party.Forbidden=[mcMMO] Parties not permitted on this world (See Permissions) -Party.Help.0=[[RED]]Proper usage is [[DARK_AQUA]]/party join {0} {1}. -Party.Help.1=[[RED]]To create a party, use [[DARK_AQUA]]/party create [password] -Party.Help.2=[[RED]]Consult [[DARK_AQUA]]/party ? [[RED]]for more information -Party.Help.3=[[RED]]Use [[DARK_AQUA]]/party join [[RED]]to join or [[DARK_AQUA]]/party quit [[RED]]to quit -Party.Help.4=[[RED]]To lock or unlock your party, use [[DARK_AQUA]]/party -Party.Help.5=[[RED]]To password protect your party, use [[DARK_AQUA]]/party password -Party.Help.6=[[RED]]To kick a player from your party, use [[DARK_AQUA]]/party kick -Party.Help.7=[[RED]]To transfer ownership of your party, use [[DARK_AQUA]]/party owner -Party.Help.8=[[RED]]To disband your party, use [[DARK_AQUA]]/party disband +Party.Help.0=[[RED]]Proper usage is [[DARK_AQUA]]{0} [password]. +Party.Help.1=[[RED]]To create a party, use [[DARK_AQUA]]{0} [password]. +Party.Help.2=[[RED]]Consult [[DARK_AQUA]]{0} [[RED]]for more information +Party.Help.3=[[RED]]Use [[DARK_AQUA]]{0} [password] [[RED]]to join or [[DARK_AQUA]]{1} [[RED]]to quit +Party.Help.4=[[RED]]To lock or unlock your party, use [[DARK_AQUA]]{0} +Party.Help.5=[[RED]]To password protect your party, use [[DARK_AQUA]]{0} +Party.Help.6=[[RED]]To kick a player from your party, use [[DARK_AQUA]]{0} +Party.Help.7=[[RED]]To transfer ownership of your party, use [[DARK_AQUA]]{0} +Party.Help.8=[[RED]]To disband your party, use [[DARK_AQUA]]{0} Party.InformedOnJoin={0} [[GREEN]]has joined your party Party.InformedOnQuit={0} [[GREEN]]has left your party Party.InformedOnNameChange=[[GOLD]]{0} [[GREEN]]has set the party name to [[WHITE]]{1} From 5d693c5d8f934ec58b63194e142d2f9c212d1cf9 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 12 Feb 2013 11:42:13 -0500 Subject: [PATCH 24/44] Convert /party help to a subcommand --- .../nossr50/party/commands/PartyCommand.java | 14 ++------- .../party/commands/PartyHelpCommand.java | 30 +++++++++++++++++++ 2 files changed, 32 insertions(+), 12 deletions(-) create mode 100644 src/main/java/com/gmail/nossr50/party/commands/PartyHelpCommand.java diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java index 6a83d1434..1703c272f 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java @@ -29,6 +29,7 @@ public class PartyCommand implements CommandExecutor { private CommandExecutor partyChangePasswordCommand = new PartyChangePasswordCommand(); private CommandExecutor partyRenameCommand = new PartyRenameCommand(); private CommandExecutor partyInfoCommand = new PartyInfoCommand(); + private CommandExecutor partyHelpCommand = new PartyHelpCommand(); @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { @@ -67,7 +68,7 @@ public class PartyCommand implements CommandExecutor { case CREATE: return partyCreateCommand.onCommand(sender, command, label, args); case HELP: - return printHelp(); + return partyHelpCommand.onCommand(sender, command, label, args); default: break; } @@ -126,15 +127,4 @@ public class PartyCommand implements CommandExecutor { player.sendMessage(LocaleLoader.getString("Party.Help.2", "/party ?")); return true; } - - private boolean printHelp() { - player.sendMessage(LocaleLoader.getString("Party.Help.3", "/party join", "/party quit")); - player.sendMessage(LocaleLoader.getString("Party.Help.1", "/party create")); - player.sendMessage(LocaleLoader.getString("Party.Help.4", "/party ")); - player.sendMessage(LocaleLoader.getString("Party.Help.5", "/party password")); - player.sendMessage(LocaleLoader.getString("Party.Help.6", "/party kick")); - player.sendMessage(LocaleLoader.getString("Party.Help.7", "/party owner")); - player.sendMessage(LocaleLoader.getString("Party.Help.8", "/party disband")); - return true; - } } diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyHelpCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyHelpCommand.java new file mode 100644 index 000000000..9e63d4666 --- /dev/null +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyHelpCommand.java @@ -0,0 +1,30 @@ +package com.gmail.nossr50.party.commands; + +import org.bukkit.command.Command; +import org.bukkit.command.CommandExecutor; +import org.bukkit.command.CommandSender; + +import com.gmail.nossr50.locale.LocaleLoader; + +public class PartyHelpCommand implements CommandExecutor { + + @Override + public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + switch (args.length) { + case 1: + sender.sendMessage(LocaleLoader.getString("Party.Help.3", "/party join", "/party quit")); + sender.sendMessage(LocaleLoader.getString("Party.Help.1", "/party create")); + sender.sendMessage(LocaleLoader.getString("Party.Help.4", "/party ")); + sender.sendMessage(LocaleLoader.getString("Party.Help.5", "/party password")); + sender.sendMessage(LocaleLoader.getString("Party.Help.6", "/party kick")); + sender.sendMessage(LocaleLoader.getString("Party.Help.7", "/party owner")); + sender.sendMessage(LocaleLoader.getString("Party.Help.8", "/party disband")); + return true; + + default: + sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "help")); + return true; + } + } + +} From 51493fab487a772452807c664d808e17e4399e66 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 12 Feb 2013 11:44:29 -0500 Subject: [PATCH 25/44] Don't pass the plugin. --- src/main/java/com/gmail/nossr50/mcMMO.java | 2 +- .../com/gmail/nossr50/party/commands/PtpCommand.java | 11 +++-------- 2 files changed, 4 insertions(+), 9 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 35953deda..3ba052fa5 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -290,7 +290,7 @@ public class mcMMO extends JavaPlugin { CommandRegistrationHelper.registerAdminChatCommand(); CommandRegistrationHelper.registerPartyCommand(); CommandRegistrationHelper.registerPartyChatCommand(); - getCommand("ptp").setExecutor(new PtpCommand(this)); + getCommand("ptp").setExecutor(new PtpCommand()); // Other commands CommandRegistrationHelper.registerAddxpCommand(); diff --git a/src/main/java/com/gmail/nossr50/party/commands/PtpCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PtpCommand.java index 990dbdc9e..f9622875d 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PtpCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PtpCommand.java @@ -18,14 +18,9 @@ import com.gmail.nossr50.util.Permissions; import com.gmail.nossr50.util.Users; public class PtpCommand implements CommandExecutor { - private final mcMMO plugin; private Player player; private McMMOPlayer mcMMOPlayer; - public PtpCommand(mcMMO instance) { - this.plugin = instance; - } - @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { String usage = LocaleLoader.getString("Commands.Usage.1", "ptp", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"); @@ -71,7 +66,7 @@ public class PtpCommand implements CommandExecutor { } private boolean sendTeleportRequest(String args) { - Player target = plugin.getServer().getPlayer(args); + Player target = mcMMO.p.getServer().getPlayer(args); if (player.equals(target)) { player.sendMessage(LocaleLoader.getString("Party.Teleport.Self")); @@ -98,7 +93,7 @@ public class PtpCommand implements CommandExecutor { if (!targetMcMMOPlayer.getPtpConfirmRequired()) { McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, mcMMOPlayer.getParty().getName()); - plugin.getServer().getPluginManager().callEvent(event); + mcMMO.p.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return true; @@ -168,7 +163,7 @@ public class PtpCommand implements CommandExecutor { } McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(target, player, mcMMOPlayer.getParty().getName()); - plugin.getServer().getPluginManager().callEvent(event); + mcMMO.p.getServer().getPluginManager().callEvent(event); if (event.isCancelled()) { return true; From bbc2091b77c761af8947ff3f2289932a57aad217 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 12 Feb 2013 12:04:37 -0500 Subject: [PATCH 26/44] Aliased /party chat to work for /partychat and /party teleport to work for /ptp --- .../nossr50/party/commands/PartyCommand.java | 17 +++++++++++++++++ .../nossr50/party/commands/PartySubcommand.java | 4 +++- 2 files changed, 20 insertions(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java index 1703c272f..f5a64cc67 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java @@ -5,6 +5,7 @@ import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import com.gmail.nossr50.chat.commands.PartyChatCommand; import com.gmail.nossr50.commands.CommandHelper; import com.gmail.nossr50.datatypes.McMMOPlayer; import com.gmail.nossr50.locale.LocaleLoader; @@ -30,6 +31,8 @@ public class PartyCommand implements CommandExecutor { private CommandExecutor partyRenameCommand = new PartyRenameCommand(); private CommandExecutor partyInfoCommand = new PartyInfoCommand(); private CommandExecutor partyHelpCommand = new PartyHelpCommand(); + private CommandExecutor partyTeleportCommand = new PtpCommand(); + private CommandExecutor partyChatCommand = new PartyChatCommand(); @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { @@ -86,6 +89,10 @@ public class PartyCommand implements CommandExecutor { return partyQuitCommand.onCommand(sender, command, label, args); case INVITE: return partyInviteCommand.onCommand(sender, command, label, args); + case TELEPORT: + return partyTeleportCommand.onCommand(sender, command, label, extractArgs(args)); + case CHAT: + return partyChatCommand.onCommand(sender, command, label, extractArgs(args)); default: break; } @@ -127,4 +134,14 @@ public class PartyCommand implements CommandExecutor { player.sendMessage(LocaleLoader.getString("Party.Help.2", "/party ?")); return true; } + + private String[] extractArgs(String[] args) { + String[] newArgs = new String[args.length - 1]; + + for (int i = 1; i < args.length; i++) { + newArgs[i - 1] = args[1]; + } + + return newArgs; + } } diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartySubcommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartySubcommand.java index 80ae1f495..87c39c587 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartySubcommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartySubcommand.java @@ -16,7 +16,9 @@ public enum PartySubcommand { LOCK, UNLOCK, PASSWORD, - RENAME; + RENAME, + TELEPORT, + CHAT; public static PartySubcommand getSubcommand(String commandName) { for (PartySubcommand command : values()) { From 56056797bc983205fdd311c894bc455b692852a5 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 12 Feb 2013 12:08:04 -0500 Subject: [PATCH 27/44] Check config values for exp & item sharing. --- .../gmail/nossr50/party/commands/PartyExpShareCommand.java | 6 ++++++ .../gmail/nossr50/party/commands/PartyItemShareCommand.java | 6 ++++++ src/main/resources/locale/locale_en_US.properties | 2 ++ 3 files changed, 14 insertions(+) diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyExpShareCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyExpShareCommand.java index 68d8a0780..668040483 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyExpShareCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyExpShareCommand.java @@ -5,6 +5,7 @@ import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import com.gmail.nossr50.config.Config; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.party.Party; import com.gmail.nossr50.party.ShareHandler; @@ -18,6 +19,11 @@ public class PartyExpShareCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (!Config.getInstance().getExpShareEnabled()) { + sender.sendMessage(LocaleLoader.getString("Party.ExpShare.Disabled")); + return true; + } + if (!Permissions.hasPermission(sender, "mcmmo.commands.party.expshare")) { sender.sendMessage(command.getPermissionMessage()); return true; diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyItemShareCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyItemShareCommand.java index d204250c3..310b2d60f 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyItemShareCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyItemShareCommand.java @@ -5,6 +5,7 @@ import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import com.gmail.nossr50.config.Config; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.party.Party; import com.gmail.nossr50.party.ShareHandler; @@ -18,6 +19,11 @@ public class PartyItemShareCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { + if (!Config.getInstance().getItemShareEnabled()) { + sender.sendMessage(LocaleLoader.getString("Party.ItemShare.Disabled")); + return true; + } + if (!Permissions.hasPermission(sender, "mcmmo.commands.party.itemshare")) { sender.sendMessage(command.getPermissionMessage()); return true; diff --git a/src/main/resources/locale/locale_en_US.properties b/src/main/resources/locale/locale_en_US.properties index a60ce237b..1f7c11acc 100644 --- a/src/main/resources/locale/locale_en_US.properties +++ b/src/main/resources/locale/locale_en_US.properties @@ -554,6 +554,8 @@ Party.ShareType.Item=ITEM Party.ShareMode.None=NONE Party.ShareMode.Equal=EQUAL Party.ShareMode.Random=RANDOM +Party.ExpShare.Disabled=[[RED]]Party experience sharing is disabled. +Party.ItemShare.Disabled=[[RED]]Party item sharing is disabled. ##xp Commands.XPGain.Acrobatics=Falling From 2fac0170e78e19e25ce65553d89c3da2e2c1170b Mon Sep 17 00:00:00 2001 From: bm01 Date: Tue, 12 Feb 2013 19:06:30 +0100 Subject: [PATCH 28/44] Fixed Impact reducing durability of non-armor equipped blocks --- Changelog.txt | 1 + .../gmail/nossr50/skills/axes/AxeManager.java | 5 +- .../skills/axes/ImpactEventHandler.java | 59 ++++++++----------- 3 files changed, 28 insertions(+), 37 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index 367ec4751..f7f3e522b 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -30,6 +30,7 @@ Version 1.4.00-dev + Added Shears, Buckets, Fishing Rods, Flint & Steel, Carrot Sticks, and Bows to the list of items that can be Salvaged + Added the "wait" music disc to the default fishing treasures + Added "Chinese (Taiwan)" localization files (zh_TW) + = Fixed Impact reducing durability of non-armor equipped blocks = Fixed multiple commands not working properly on offline players = Fixed /mmoedit not giving feedback when modifying another players stats = Fixed the guide usage string showing up every time /skillname was called diff --git a/src/main/java/com/gmail/nossr50/skills/axes/AxeManager.java b/src/main/java/com/gmail/nossr50/skills/axes/AxeManager.java index fc6c92ce3..d3bcf5f71 100644 --- a/src/main/java/com/gmail/nossr50/skills/axes/AxeManager.java +++ b/src/main/java/com/gmail/nossr50/skills/axes/AxeManager.java @@ -49,10 +49,7 @@ public class AxeManager extends SkillManager { public void impact(EntityDamageByEntityEvent event, LivingEntity target) { ImpactEventHandler eventHandler = new ImpactEventHandler(this, event, target); - if (Misc.hasArmor(target)) { - eventHandler.damageArmor(); - } - else { + if (!eventHandler.applyImpact()) { eventHandler.applyGreaterImpact(); } } diff --git a/src/main/java/com/gmail/nossr50/skills/axes/ImpactEventHandler.java b/src/main/java/com/gmail/nossr50/skills/axes/ImpactEventHandler.java index 1e3527aaf..fc71ab22b 100644 --- a/src/main/java/com/gmail/nossr50/skills/axes/ImpactEventHandler.java +++ b/src/main/java/com/gmail/nossr50/skills/axes/ImpactEventHandler.java @@ -8,6 +8,7 @@ import org.bukkit.inventory.EntityEquipment; import org.bukkit.inventory.ItemStack; import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.ItemChecks; import com.gmail.nossr50.util.Misc; import com.gmail.nossr50.util.Permissions; @@ -16,38 +17,46 @@ public class ImpactEventHandler { private Player player; private EntityDamageByEntityEvent event; private short durabilityDamage = 1; - private EntityEquipment equipment; - private ItemStack[] armorContents; + private EntityEquipment entityEquipment; protected LivingEntity defender; + boolean impactApplied; public ImpactEventHandler(AxeManager manager, EntityDamageByEntityEvent event, LivingEntity defender) { this.manager = manager; this.player = manager.getMcMMOPlayer().getPlayer(); this.event = event; this.defender = defender; - this.equipment = defender.getEquipment(); - this.armorContents = equipment.getArmorContents(); + this.entityEquipment = defender.getEquipment(); } - protected void damageArmor() { + protected boolean applyImpact() { // Every 50 Skill Levels you gain 1 durability damage (default values) durabilityDamage += (short) (manager.getSkillLevel() / Axes.impactIncreaseLevel); + // getArmorContents.length can't be used because it's always equal to 4 (no armor = air block) + boolean hasArmor = false; - for (ItemStack armor : armorContents) { - if (Misc.getRandom().nextInt(100) > 75) { - - for (int i = 0; i <= durabilityDamage; i++) { - if (armor.containsEnchantment(Enchantment.DURABILITY)) { - handleDurabilityEnchantment(armor); - } - } - - damageValidation(armor); - armor.setDurability((short) (armor.getDurability() + durabilityDamage)); + for (ItemStack itemStack : entityEquipment.getArmorContents()) { + if (ItemChecks.isArmor(itemStack)) { + damageArmor(itemStack); + hasArmor = true; } } - equipment.setArmorContents(armorContents); + return hasArmor; + } + + private void damageArmor(ItemStack armor) { + if (Misc.getRandom().nextInt(100) >= 25) { + return; + } + + float modifier = 1; + + if (armor.containsEnchantment(Enchantment.DURABILITY)) { + modifier /= armor.getEnchantmentLevel(Enchantment.DURABILITY) + 1; + } + + armor.setDurability((short) (durabilityDamage * modifier + armor.getDurability())); } protected void applyGreaterImpact() { @@ -73,20 +82,4 @@ public class ImpactEventHandler { ((Player) defender).sendMessage(LocaleLoader.getString("Axes.Combat.GI.Struck")); } } - - private void handleDurabilityEnchantment(ItemStack armor) { - int enchantmentLevel = armor.getEnchantmentLevel(Enchantment.DURABILITY); - - if (Misc.getRandom().nextInt(enchantmentLevel + 1) > 0) { - durabilityDamage--; - } - } - - private void damageValidation(ItemStack armor) { - short maxDurability = (short) (armor.getType().getMaxDurability() * Axes.impactMaxDurabilityDamageModifier); - - if (durabilityDamage > maxDurability) { - durabilityDamage = maxDurability; - } - } } From 6f1ddee0ac5cfbb8d2fd966e0400a75e123cc2b4 Mon Sep 17 00:00:00 2001 From: bm01 Date: Tue, 12 Feb 2013 19:12:23 +0100 Subject: [PATCH 29/44] ItemChecks.isArmor should check for custom armors --- src/main/java/com/gmail/nossr50/util/ItemChecks.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/util/ItemChecks.java b/src/main/java/com/gmail/nossr50/util/ItemChecks.java index 00305d675..9c7a3bf64 100644 --- a/src/main/java/com/gmail/nossr50/util/ItemChecks.java +++ b/src/main/java/com/gmail/nossr50/util/ItemChecks.java @@ -254,7 +254,7 @@ public class ItemChecks { * @return true if the item is armor, false otherwise */ public static boolean isArmor(ItemStack is) { - return isLeatherArmor(is) || isGoldArmor(is) || isIronArmor(is) || isDiamondArmor(is); + return isHelmet(is) || isChestplate(is) || isPants(is) || isBoots(is); } /** From f486492c3730c32dd5cb80b6be174d352f451734 Mon Sep 17 00:00:00 2001 From: bm01 Date: Tue, 12 Feb 2013 19:13:15 +0100 Subject: [PATCH 30/44] For consistency with Bukkit, ItemChecks.isPants -> ItemChecks.isLeggings --- src/main/java/com/gmail/nossr50/skills/repair/Salvage.java | 2 +- src/main/java/com/gmail/nossr50/util/ItemChecks.java | 4 ++-- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java b/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java index c74069319..af306c063 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java @@ -124,7 +124,7 @@ public class Salvage { else if (ItemChecks.isChestplate(inHand)) { return 8; } - else if (ItemChecks.isPants(inHand)) { + else if (ItemChecks.isLeggings(inHand)) { return 7; } else if (ItemChecks.isBoots(inHand)) { diff --git a/src/main/java/com/gmail/nossr50/util/ItemChecks.java b/src/main/java/com/gmail/nossr50/util/ItemChecks.java index 9c7a3bf64..d341f4c24 100644 --- a/src/main/java/com/gmail/nossr50/util/ItemChecks.java +++ b/src/main/java/com/gmail/nossr50/util/ItemChecks.java @@ -207,7 +207,7 @@ public class ItemChecks { * @param is Item to check * @return true if the item is a pair of pants, false otherwise */ - public static boolean isPants(ItemStack is) { + public static boolean isLeggings(ItemStack is) { switch (is.getType()) { case DIAMOND_LEGGINGS: case GOLD_LEGGINGS: @@ -254,7 +254,7 @@ public class ItemChecks { * @return true if the item is armor, false otherwise */ public static boolean isArmor(ItemStack is) { - return isHelmet(is) || isChestplate(is) || isPants(is) || isBoots(is); + return isHelmet(is) || isChestplate(is) || isLeggings(is) || isBoots(is); } /** From 9f223825067d5a5be7eb72c496a8aebc7a43452c Mon Sep 17 00:00:00 2001 From: bm01 Date: Tue, 12 Feb 2013 19:15:17 +0100 Subject: [PATCH 31/44] Restored original behavior of Salvage.isSalvageable It doesn't check for custom armors, I don't know if it's a bug or not Added isMinecraftTool and isMinecraftArmor for clarity --- .../com/gmail/nossr50/skills/repair/Salvage.java | 4 ++-- src/main/java/com/gmail/nossr50/util/ItemChecks.java | 12 +++++++++++- 2 files changed, 13 insertions(+), 3 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java b/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java index af306c063..dca2bbbc3 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java @@ -141,10 +141,10 @@ public class Salvage { * @return true if the item is salvageable, false otherwise */ public static boolean isSalvageable(final ItemStack is) { - if (configInstance.getSalvageTools() && (ItemChecks.isTool(is) || ItemChecks.isStringTool(is) || is.getType() == Material.BUCKET)) { + if (configInstance.getSalvageTools() && (ItemChecks.isMinecraftArmor(is) || ItemChecks.isStringTool(is) || is.getType() == Material.BUCKET)) { return true; } - if (configInstance.getSalvageArmor() && ItemChecks.isArmor(is)) { + if (configInstance.getSalvageArmor() && ItemChecks.isMinecraftArmor(is)) { return true; } return false; diff --git a/src/main/java/com/gmail/nossr50/util/ItemChecks.java b/src/main/java/com/gmail/nossr50/util/ItemChecks.java index d341f4c24..d74066b93 100644 --- a/src/main/java/com/gmail/nossr50/util/ItemChecks.java +++ b/src/main/java/com/gmail/nossr50/util/ItemChecks.java @@ -257,6 +257,16 @@ public class ItemChecks { return isHelmet(is) || isChestplate(is) || isLeggings(is) || isBoots(is); } + /** + * Checks to see if an item is a wearable armor piece. + * + * @param is Item to check + * @return true if the item is armor, false otherwise + */ + public static boolean isMinecraftArmor(ItemStack is) { + return isDiamondArmor(is) || isGoldArmor(is) || isIronArmor(is) || isDiamondArmor(is); + } + /** * Checks to see if an item is a leather armor piece. * @@ -339,7 +349,7 @@ public class ItemChecks { * @param is Item to check * @return true if the item is a tool, false otherwise */ - public static boolean isTool(ItemStack is) { + public static boolean isMinecraftTool(ItemStack is) { return isStoneTool(is) || isWoodTool(is) || isGoldTool(is) || isIronTool(is) || isDiamondTool(is) || isStringTool(is); } From 505d6e258f9b7f0ee1f5297f4ecc50436cd82ec5 Mon Sep 17 00:00:00 2001 From: bm01 Date: Tue, 12 Feb 2013 19:17:53 +0100 Subject: [PATCH 32/44] Removed no longer needed method (Misc.hasArmor) --- src/main/java/com/gmail/nossr50/util/Misc.java | 16 ---------------- 1 file changed, 16 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/util/Misc.java b/src/main/java/com/gmail/nossr50/util/Misc.java index c2b965ede..dd4e11399 100644 --- a/src/main/java/com/gmail/nossr50/util/Misc.java +++ b/src/main/java/com/gmail/nossr50/util/Misc.java @@ -60,22 +60,6 @@ public final class Misc { return NORMAL_SKILL_ACTIVATION_CHANCE; } - /** - * Check if a LivingEntity has armor. - * - * @param entity LivingEntity whose armor to check - * @return true if the player has armor, false otherwise - */ - public static boolean hasArmor(LivingEntity entity) { - for (ItemStack armor : entity.getEquipment().getArmorContents()) { - if (armor.getType() != Material.AIR) { - return true; - } - } - - return false; - } - public static boolean isFriendlyPet(Player attacker, Tameable pet) { if (pet.isTamed()) { AnimalTamer tamer = pet.getOwner(); From 761fb3b8113fb11050aa0bc69b65eb7ffd065f0b Mon Sep 17 00:00:00 2001 From: bm01 Date: Tue, 12 Feb 2013 19:19:13 +0100 Subject: [PATCH 33/44] Bad copy paste --- src/main/java/com/gmail/nossr50/skills/repair/Salvage.java | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java b/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java index dca2bbbc3..a370ae606 100644 --- a/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java +++ b/src/main/java/com/gmail/nossr50/skills/repair/Salvage.java @@ -141,7 +141,7 @@ public class Salvage { * @return true if the item is salvageable, false otherwise */ public static boolean isSalvageable(final ItemStack is) { - if (configInstance.getSalvageTools() && (ItemChecks.isMinecraftArmor(is) || ItemChecks.isStringTool(is) || is.getType() == Material.BUCKET)) { + if (configInstance.getSalvageTools() && (ItemChecks.isMinecraftTool(is) || ItemChecks.isStringTool(is) || is.getType() == Material.BUCKET)) { return true; } if (configInstance.getSalvageArmor() && ItemChecks.isMinecraftArmor(is)) { From 048a9793759aba9ab4924835513481f044850768 Mon Sep 17 00:00:00 2001 From: bm01 Date: Tue, 12 Feb 2013 19:36:10 +0100 Subject: [PATCH 34/44] Minor ImpactEventHandler cleanup --- .../gmail/nossr50/skills/axes/ImpactEventHandler.java | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/axes/ImpactEventHandler.java b/src/main/java/com/gmail/nossr50/skills/axes/ImpactEventHandler.java index fc71ab22b..be04c0d49 100644 --- a/src/main/java/com/gmail/nossr50/skills/axes/ImpactEventHandler.java +++ b/src/main/java/com/gmail/nossr50/skills/axes/ImpactEventHandler.java @@ -37,8 +37,11 @@ public class ImpactEventHandler { for (ItemStack itemStack : entityEquipment.getArmorContents()) { if (ItemChecks.isArmor(itemStack)) { - damageArmor(itemStack); hasArmor = true; + + if (Misc.getRandom().nextInt(100) < 25) { + damageArmor(itemStack); + } } } @@ -46,10 +49,6 @@ public class ImpactEventHandler { } private void damageArmor(ItemStack armor) { - if (Misc.getRandom().nextInt(100) >= 25) { - return; - } - float modifier = 1; if (armor.containsEnchantment(Enchantment.DURABILITY)) { From 9db2d50676241289827251de4c2c21ab503b42e1 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 12 Feb 2013 14:36:38 -0500 Subject: [PATCH 35/44] These should be under party, not skills. --- src/main/java/com/gmail/nossr50/mcMMO.java | 4 ++-- .../nossr50/{skills => party}/runnables/PartiesLoader.java | 2 +- .../nossr50/{skills => party}/runnables/PartyAutoKick.java | 2 +- 3 files changed, 4 insertions(+), 4 deletions(-) rename src/main/java/com/gmail/nossr50/{skills => party}/runnables/PartiesLoader.java (80%) rename src/main/java/com/gmail/nossr50/{skills => party}/runnables/PartyAutoKick.java (94%) diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 3ba052fa5..e8ccec9af 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -45,6 +45,8 @@ import com.gmail.nossr50.mods.config.CustomEntityConfig; import com.gmail.nossr50.mods.config.CustomToolsConfig; import com.gmail.nossr50.party.PartyManager; import com.gmail.nossr50.party.commands.PtpCommand; +import com.gmail.nossr50.party.runnables.PartiesLoader; +import com.gmail.nossr50.party.runnables.PartyAutoKick; import com.gmail.nossr50.runnables.MobStoreCleaner; import com.gmail.nossr50.runnables.SaveTimer; import com.gmail.nossr50.skills.repair.RepairManager; @@ -52,8 +54,6 @@ import com.gmail.nossr50.skills.repair.RepairManagerFactory; import com.gmail.nossr50.skills.repair.Repairable; import com.gmail.nossr50.skills.repair.config.RepairConfigManager; import com.gmail.nossr50.skills.runnables.BleedTimer; -import com.gmail.nossr50.skills.runnables.PartiesLoader; -import com.gmail.nossr50.skills.runnables.PartyAutoKick; import com.gmail.nossr50.skills.runnables.SkillMonitor; import com.gmail.nossr50.spout.SpoutConfig; import com.gmail.nossr50.spout.SpoutTools; diff --git a/src/main/java/com/gmail/nossr50/skills/runnables/PartiesLoader.java b/src/main/java/com/gmail/nossr50/party/runnables/PartiesLoader.java similarity index 80% rename from src/main/java/com/gmail/nossr50/skills/runnables/PartiesLoader.java rename to src/main/java/com/gmail/nossr50/party/runnables/PartiesLoader.java index ee0b54f95..4cf76741f 100644 --- a/src/main/java/com/gmail/nossr50/skills/runnables/PartiesLoader.java +++ b/src/main/java/com/gmail/nossr50/party/runnables/PartiesLoader.java @@ -1,4 +1,4 @@ -package com.gmail.nossr50.skills.runnables; +package com.gmail.nossr50.party.runnables; import com.gmail.nossr50.party.PartyManager; diff --git a/src/main/java/com/gmail/nossr50/skills/runnables/PartyAutoKick.java b/src/main/java/com/gmail/nossr50/party/runnables/PartyAutoKick.java similarity index 94% rename from src/main/java/com/gmail/nossr50/skills/runnables/PartyAutoKick.java rename to src/main/java/com/gmail/nossr50/party/runnables/PartyAutoKick.java index 5e6c1a331..56e5ebfa0 100644 --- a/src/main/java/com/gmail/nossr50/skills/runnables/PartyAutoKick.java +++ b/src/main/java/com/gmail/nossr50/party/runnables/PartyAutoKick.java @@ -1,4 +1,4 @@ -package com.gmail.nossr50.skills.runnables; +package com.gmail.nossr50.party.runnables; import org.bukkit.OfflinePlayer; From d7e74b9fe0616d86b250a52d54ac102cfd427be5 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 12 Feb 2013 14:38:49 -0500 Subject: [PATCH 36/44] That was poorly named. --- .../java/com/gmail/nossr50/party/commands/PartyCommand.java | 2 +- .../{PartySubcommand.java => PartySubcommandType.java} | 6 +++--- 2 files changed, 4 insertions(+), 4 deletions(-) rename src/main/java/com/gmail/nossr50/party/commands/{PartySubcommand.java => PartySubcommandType.java} (82%) diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java index f5a64cc67..3f62f36b6 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java @@ -57,7 +57,7 @@ public class PartyCommand implements CommandExecutor { return partyInfoCommand.onCommand(sender, command, label, args); } - PartySubcommand subcommand = PartySubcommand.getSubcommand(args[0]); + PartySubcommandType subcommand = PartySubcommandType.getSubcommand(args[0]); if (subcommand == null) { return printUsage(); diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartySubcommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartySubcommandType.java similarity index 82% rename from src/main/java/com/gmail/nossr50/party/commands/PartySubcommand.java rename to src/main/java/com/gmail/nossr50/party/commands/PartySubcommandType.java index 87c39c587..925dd6d63 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartySubcommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartySubcommandType.java @@ -1,6 +1,6 @@ package com.gmail.nossr50.party.commands; -public enum PartySubcommand { +public enum PartySubcommandType { JOIN, ACCEPT, CREATE, @@ -20,8 +20,8 @@ public enum PartySubcommand { TELEPORT, CHAT; - public static PartySubcommand getSubcommand(String commandName) { - for (PartySubcommand command : values()) { + public static PartySubcommandType getSubcommand(String commandName) { + for (PartySubcommandType command : values()) { if (command.name().equalsIgnoreCase(commandName)) { return command; } From 92473cc56d1c15a084ed49704065fa007a92a877 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 12 Feb 2013 15:00:04 -0500 Subject: [PATCH 37/44] True, not false. --- .../com/gmail/nossr50/party/commands/PartyInviteCommand.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyInviteCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyInviteCommand.java index f30255e9b..bf5170ae9 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyInviteCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyInviteCommand.java @@ -32,14 +32,14 @@ public class PartyInviteCommand implements CommandExecutor { case 2: if (!mcMMO.p.getServer().getOfflinePlayer(args[1]).isOnline()) { sender.sendMessage(LocaleLoader.getString("Party.NotOnline", args[1])); - return false; + return true; } mcMMOTarget = Users.getPlayer(args[1]); if (mcMMOTarget == null) { sender.sendMessage(LocaleLoader.getString("Party.Player.Invalid")); - return false; + return true; } target = mcMMOTarget.getPlayer(); From adda85a660326d4a48e8450319dd5da112dda59d Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 12 Feb 2013 15:05:02 -0500 Subject: [PATCH 38/44] Convert /ptp to use Bukkit CommandAPI --- .../commands/CommandRegistrationHelper.java | 11 +++++++ src/main/java/com/gmail/nossr50/mcMMO.java | 2 +- .../nossr50/party/commands/PtpCommand.java | 31 ++++++++++--------- .../resources/locale/locale_en_US.properties | 1 + 4 files changed, 29 insertions(+), 16 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java b/src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java index ef4ed8022..9625f097d 100644 --- a/src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java +++ b/src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java @@ -27,6 +27,7 @@ import com.gmail.nossr50.database.commands.McremoveCommand; import com.gmail.nossr50.database.commands.MmoupdateCommand; import com.gmail.nossr50.locale.LocaleLoader; import com.gmail.nossr50.party.commands.PartyCommand; +import com.gmail.nossr50.party.commands.PtpCommand; import com.gmail.nossr50.skills.acrobatics.AcrobaticsCommand; import com.gmail.nossr50.skills.archery.ArcheryCommand; import com.gmail.nossr50.skills.axes.AxesCommand; @@ -324,4 +325,14 @@ public final class CommandRegistrationHelper { command.setPermissionMessage(permissionsMessage); command.setExecutor(new PartyCommand()); } + + public static void registerPtpCommand() { + PluginCommand command = mcMMO.p.getCommand("ptp"); + command.setDescription(LocaleLoader.getString("Commands.Description.ptp")); + command.setPermission("mcmmo.commands.ptp;mcmmo.commands.ptp.accept;mcmmo.commands.ptp.acceptall;mcmmo.commands.ptp.toggle"); + command.setPermissionMessage(permissionsMessage); + command.setUsage(LocaleLoader.getString("Commands.Usage.1", "ptp", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">")); + command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "ptp", "")); + command.setExecutor(new PtpCommand()); + } } diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index e8ccec9af..41b08f3a8 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -290,7 +290,7 @@ public class mcMMO extends JavaPlugin { CommandRegistrationHelper.registerAdminChatCommand(); CommandRegistrationHelper.registerPartyCommand(); CommandRegistrationHelper.registerPartyChatCommand(); - getCommand("ptp").setExecutor(new PtpCommand()); + CommandRegistrationHelper.registerPtpCommand(); // Other commands CommandRegistrationHelper.registerAddxpCommand(); diff --git a/src/main/java/com/gmail/nossr50/party/commands/PtpCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PtpCommand.java index f9622875d..66e89245e 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PtpCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PtpCommand.java @@ -23,16 +23,10 @@ public class PtpCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - String usage = LocaleLoader.getString("Commands.Usage.1", "ptp", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"); - if (CommandHelper.noConsoleUsage(sender)) { return true; } - if (CommandHelper.noCommandPermissions(sender, "mcmmo.commands.ptp")) { - return true; - } - switch (args.length) { case 1: player = (Player) sender; @@ -42,7 +36,8 @@ public class PtpCommand implements CommandExecutor { if (args[0].equalsIgnoreCase("toggle")) { return togglePartyTeleportation(); } - else if (args[0].equalsIgnoreCase("acceptany") || args[0].equalsIgnoreCase("acceptall")) { + + if (args[0].equalsIgnoreCase("acceptany") || args[0].equalsIgnoreCase("acceptall")) { return acceptAnyTeleportRequest(); } @@ -60,24 +55,30 @@ public class PtpCommand implements CommandExecutor { return sendTeleportRequest(args[0]); default: - sender.sendMessage(usage); - return true; + return false; } } - private boolean sendTeleportRequest(String args) { - Player target = mcMMO.p.getServer().getPlayer(args); - - if (player.equals(target)) { - player.sendMessage(LocaleLoader.getString("Party.Teleport.Self")); + private boolean sendTeleportRequest(String playerName) { + if (!mcMMO.p.getServer().getOfflinePlayer(playerName).isOnline()) { + player.sendMessage(LocaleLoader.getString("Party.NotOnline", playerName)); return true; } - if (target == null) { + McMMOPlayer mcMMOTarget = Users.getPlayer(playerName); + + if (mcMMOTarget == null) { player.sendMessage(LocaleLoader.getString("Party.Player.Invalid")); return true; } + Player target = mcMMOTarget.getPlayer(); + + if (player.equals(target)) { + player.sendMessage(LocaleLoader.getString("Party.Teleport.Self")); + return true; + } + if (target.isDead()) { player.sendMessage(LocaleLoader.getString("Party.Teleport.Dead")); return true; diff --git a/src/main/resources/locale/locale_en_US.properties b/src/main/resources/locale/locale_en_US.properties index 1f7c11acc..3de265043 100644 --- a/src/main/resources/locale/locale_en_US.properties +++ b/src/main/resources/locale/locale_en_US.properties @@ -709,6 +709,7 @@ Commands.Description.mmoedit=Edit mcMMO levels for a user Commands.Description.mmoupdate=Convert mcMMO database from Flatfile to MySQL Commands.Description.party=Control various mcMMO party settings Commands.Description.partychat=Toggle mcMMO party chat on/off or send party chat messages +Commands.Description.ptp=Teleport to an mcMMO party member Commands.Description.Skill=Display detailed mcMMO skill info for {0} Commands.Description.skillreset=Reset mcMMO levels for a user Commands.Description.xplock=Lock your mcMMO XP bar to a specific mcMMO skill From 574770c2896dd68312642ad67f6f66910a93908c Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 12 Feb 2013 15:05:23 -0500 Subject: [PATCH 39/44] Remove unused imports. --- src/main/java/com/gmail/nossr50/mcMMO.java | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 41b08f3a8..3641e100f 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -44,7 +44,6 @@ import com.gmail.nossr50.mods.config.CustomBlocksConfig; import com.gmail.nossr50.mods.config.CustomEntityConfig; import com.gmail.nossr50.mods.config.CustomToolsConfig; import com.gmail.nossr50.party.PartyManager; -import com.gmail.nossr50.party.commands.PtpCommand; import com.gmail.nossr50.party.runnables.PartiesLoader; import com.gmail.nossr50.party.runnables.PartyAutoKick; import com.gmail.nossr50.runnables.MobStoreCleaner; From b21d5bdcc48b5dd65d58b0e3b4218736f2efbce2 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 12 Feb 2013 15:08:07 -0500 Subject: [PATCH 40/44] Inviting yourself is bad. --- .../com/gmail/nossr50/party/commands/PartyInviteCommand.java | 5 +++++ src/main/resources/locale/locale_en_US.properties | 1 + 2 files changed, 6 insertions(+) diff --git a/src/main/java/com/gmail/nossr50/party/commands/PartyInviteCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PartyInviteCommand.java index bf5170ae9..bb36b99ea 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PartyInviteCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PartyInviteCommand.java @@ -46,6 +46,11 @@ public class PartyInviteCommand implements CommandExecutor { mcMMOPlayer = Users.getPlayer((Player) sender); player = mcMMOPlayer.getPlayer(); + if (player.equals(target)) { + sender.sendMessage(LocaleLoader.getString("Party.Invite.Self")); + return true; + } + if (PartyManager.inSameParty(player, target)) { sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", target.getName())); return true; diff --git a/src/main/resources/locale/locale_en_US.properties b/src/main/resources/locale/locale_en_US.properties index 3de265043..809adc2c6 100644 --- a/src/main/resources/locale/locale_en_US.properties +++ b/src/main/resources/locale/locale_en_US.properties @@ -520,6 +520,7 @@ Party.InformedOnJoin={0} [[GREEN]]has joined your party Party.InformedOnQuit={0} [[GREEN]]has left your party Party.InformedOnNameChange=[[GOLD]]{0} [[GREEN]]has set the party name to [[WHITE]]{1} Party.InvalidName=[[DARK_RED]]That is not a valid party name. +Party.Invite.Self=[[RED]]You can't invite yourself! 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. From b66c5d7023ac9b47cd2e150be9326ea41be9f297 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 12 Feb 2013 16:24:17 -0500 Subject: [PATCH 41/44] Clean up /ptp. Also fix bug where teleportation happened backwards when accepting. --- Changelog.txt | 1 + .../nossr50/party/commands/PtpCommand.java | 178 +++++++++--------- 2 files changed, 91 insertions(+), 88 deletions(-) diff --git a/Changelog.txt b/Changelog.txt index f7f3e522b..7b5608034 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -30,6 +30,7 @@ Version 1.4.00-dev + Added Shears, Buckets, Fishing Rods, Flint & Steel, Carrot Sticks, and Bows to the list of items that can be Salvaged + Added the "wait" music disc to the default fishing treasures + Added "Chinese (Taiwan)" localization files (zh_TW) + = Fixed /ptp telporting the target to the player, rather than the other way around. = Fixed Impact reducing durability of non-armor equipped blocks = Fixed multiple commands not working properly on offline players = Fixed /mmoedit not giving feedback when modifying another players stats diff --git a/src/main/java/com/gmail/nossr50/party/commands/PtpCommand.java b/src/main/java/com/gmail/nossr50/party/commands/PtpCommand.java index 66e89245e..d87236f99 100644 --- a/src/main/java/com/gmail/nossr50/party/commands/PtpCommand.java +++ b/src/main/java/com/gmail/nossr50/party/commands/PtpCommand.java @@ -20,6 +20,10 @@ import com.gmail.nossr50.util.Users; public class PtpCommand implements CommandExecutor { private Player player; private McMMOPlayer mcMMOPlayer; + private PlayerProfile playerProfile; + + private Player target; + private McMMOPlayer mcMMOTarget; @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { @@ -31,13 +35,23 @@ public class PtpCommand implements CommandExecutor { case 1: player = (Player) sender; mcMMOPlayer = Users.getPlayer(player); - PlayerProfile playerProfile = mcMMOPlayer.getProfile(); + playerProfile = mcMMOPlayer.getProfile(); if (args[0].equalsIgnoreCase("toggle")) { + if (!Permissions.hasPermission(sender, "mcmmo.commands.ptp.toggle")) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + return togglePartyTeleportation(); } if (args[0].equalsIgnoreCase("acceptany") || args[0].equalsIgnoreCase("acceptall")) { + if (!Permissions.hasPermission(sender, "mcmmo.commands.ptp.acceptall")) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + return acceptAnyTeleportRequest(); } @@ -49,6 +63,11 @@ public class PtpCommand implements CommandExecutor { } if (args[0].equalsIgnoreCase("accept")) { + if (!Permissions.hasPermission(sender, "mcmmo.commands.ptp.accept")) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + return acceptTeleportRequest(); } @@ -59,64 +78,22 @@ public class PtpCommand implements CommandExecutor { } } - private boolean sendTeleportRequest(String playerName) { - if (!mcMMO.p.getServer().getOfflinePlayer(playerName).isOnline()) { - player.sendMessage(LocaleLoader.getString("Party.NotOnline", playerName)); + private boolean sendTeleportRequest(String targetName) { + if (!canTeleport(targetName)) { return true; } - McMMOPlayer mcMMOTarget = Users.getPlayer(playerName); - - if (mcMMOTarget == null) { - player.sendMessage(LocaleLoader.getString("Party.Player.Invalid")); - return true; + if (!mcMMOTarget.getPtpConfirmRequired()) { + return handlePartyTeleportEvent(); } - Player target = mcMMOTarget.getPlayer(); + mcMMOTarget.setPtpRequest(player); + mcMMOTarget.actualizePtpTimeout(); + player.sendMessage(LocaleLoader.getString("Commands.Invite.Success")); - if (player.equals(target)) { - player.sendMessage(LocaleLoader.getString("Party.Teleport.Self")); - return true; - } - - if (target.isDead()) { - player.sendMessage(LocaleLoader.getString("Party.Teleport.Dead")); - return true; - } - - if (PartyManager.inSameParty(player, target)) { - McMMOPlayer targetMcMMOPlayer = Users.getPlayer(target); - - if (!targetMcMMOPlayer.getPtpEnabled()) { - player.sendMessage(LocaleLoader.getString("Party.Teleport.Disabled", target.getName())); - return true; - } - - if (!targetMcMMOPlayer.getPtpConfirmRequired()) { - McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, mcMMOPlayer.getParty().getName()); - mcMMO.p.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { - return true; - } - - player.teleport(target); - player.sendMessage(LocaleLoader.getString("Party.Teleport.Player", player.getName())); - target.sendMessage(LocaleLoader.getString("Party.Teleport.Target", target.getName())); - mcMMOPlayer.getProfile().setRecentlyHurt(System.currentTimeMillis()); - } else { - targetMcMMOPlayer.setPtpRequest(player); - targetMcMMOPlayer.actualizePtpTimeout(); - player.sendMessage(LocaleLoader.getString("Commands.Invite.Success")); - - int ptpRequestExpire = Config.getInstance().getPTPCommandTimeout(); - target.sendMessage(LocaleLoader.getString("Commands.ptp.Request1", player.getName())); - target.sendMessage(LocaleLoader.getString("Commands.ptp.Request2", ptpRequestExpire)); - } - } - else { - player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", target.getName())); - } + int ptpRequestExpire = Config.getInstance().getPTPCommandTimeout(); + target.sendMessage(LocaleLoader.getString("Commands.ptp.Request1", player.getName())); + target.sendMessage(LocaleLoader.getString("Commands.ptp.Request2", ptpRequestExpire)); return true; } @@ -126,10 +103,6 @@ public class PtpCommand implements CommandExecutor { return true; } - if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.ptp.accept")) { - return true; - } - int ptpRequestExpire = Config.getInstance().getPTPCommandTimeout(); if ((mcMMOPlayer.getPtpTimeout() + ptpRequestExpire) * Misc.TIME_CONVERSION_FACTOR < System.currentTimeMillis()) { @@ -140,48 +113,28 @@ public class PtpCommand implements CommandExecutor { Player target = mcMMOPlayer.getPtpRequest(); - if (target == null) { - player.sendMessage(LocaleLoader.getString("Party.Player.Invalid")); + if (!canTeleport(target.getName())) { return true; } - if (target.isDead()) { - player.sendMessage(LocaleLoader.getString("Party.Teleport.Dead")); - return true; - } - - if(Config.getInstance().getPTPCommandWorldPermissions()) { + //TODO: Someone want to clarify what's going on with these dynamic permissions? + if (Config.getInstance().getPTPCommandWorldPermissions()) { String perm = "mcmmo.commands.ptp.world."; - if(!Permissions.hasDynamicPermission(target, perm + "all", "op")) { - if(!Permissions.hasDynamicPermission(target, perm + target.getWorld().getName(), "op")) { + if (!Permissions.hasDynamicPermission(target, perm + "all", "op")) { + if (!Permissions.hasDynamicPermission(target, perm + target.getWorld().getName(), "op")) { return true; } - else if(target.getWorld() != player.getWorld() && !Permissions.hasDynamicPermission(target, perm + player.getWorld().getName(), "op")) { + else if (target.getWorld() != player.getWorld() && !Permissions.hasDynamicPermission(target, perm + player.getWorld().getName(), "op")) { return true; } } } - McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(target, player, mcMMOPlayer.getParty().getName()); - mcMMO.p.getServer().getPluginManager().callEvent(event); - - if (event.isCancelled()) { - return true; - } - - target.teleport(player); - target.sendMessage(LocaleLoader.getString("Party.Teleport.Player", player.getName())); - player.sendMessage(LocaleLoader.getString("Party.Teleport.Target", target.getName())); - mcMMOPlayer.getProfile().setRecentlyHurt(System.currentTimeMillis()); - return true; + return handlePartyTeleportEvent(); } private boolean acceptAnyTeleportRequest() { - if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.ptp.acceptall")) { - return true; - } - if (mcMMOPlayer.getPtpConfirmRequired()) { player.sendMessage(LocaleLoader.getString("Commands.ptp.AcceptAny.Disabled")); } @@ -194,10 +147,6 @@ public class PtpCommand implements CommandExecutor { } private boolean togglePartyTeleportation() { - if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.ptp.toggle")) { - return true; - } - if (mcMMOPlayer.getPtpEnabled()) { player.sendMessage(LocaleLoader.getString("Commands.ptp.Disabled")); } @@ -208,4 +157,57 @@ public class PtpCommand implements CommandExecutor { mcMMOPlayer.togglePtpUse(); return true; } + + private boolean canTeleport(String targetName) { + if (!mcMMO.p.getServer().getOfflinePlayer(targetName).isOnline()) { + player.sendMessage(LocaleLoader.getString("Party.NotOnline", targetName)); + return false; + } + + mcMMOTarget = Users.getPlayer(targetName); + + if (mcMMOTarget == null) { + player.sendMessage(LocaleLoader.getString("Party.Player.Invalid")); + return false; + } + + target = mcMMOTarget.getPlayer(); + + if (player.equals(target)) { + player.sendMessage(LocaleLoader.getString("Party.Teleport.Self")); + return false; + } + + if (!PartyManager.inSameParty(player, target)) { + player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", targetName)); + return false; + } + + if (!mcMMOTarget.getPtpEnabled()) { + player.sendMessage(LocaleLoader.getString("Party.Teleport.Disabled", target.getName())); + return false; + } + + if (target.isDead()) { + player.sendMessage(LocaleLoader.getString("Party.Teleport.Dead")); + return false; + } + + return true; + } + + private boolean handlePartyTeleportEvent() { + McMMOPartyTeleportEvent event = new McMMOPartyTeleportEvent(player, target, mcMMOPlayer.getParty().getName()); + mcMMO.p.getServer().getPluginManager().callEvent(event); + + if (event.isCancelled()) { + return true; + } + + player.teleport(target); + player.sendMessage(LocaleLoader.getString("Party.Teleport.Player", player.getName())); + target.sendMessage(LocaleLoader.getString("Party.Teleport.Target", target.getName())); + playerProfile.setRecentlyHurt(System.currentTimeMillis()); + return true; + } } From 2160eef1aff39259dcf86f7525df51477aa0a963 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 12 Feb 2013 16:26:08 -0500 Subject: [PATCH 42/44] Update plugin.yml --- src/main/resources/plugin.yml | 1 - 1 file changed, 1 deletion(-) diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 7b0664e2e..902569546 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -55,7 +55,6 @@ commands: mmoedit: description: Edit the mcMMO skill values for a user ptp: - aliases: [] description: Teleport to a party member party: description: Create/join a party From 8f4d5442b16d432108326ef1528835de9acb6100 Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 12 Feb 2013 16:47:11 -0500 Subject: [PATCH 43/44] Better than looping. --- src/main/java/com/gmail/nossr50/skills/SkillGuide.java | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/src/main/java/com/gmail/nossr50/skills/SkillGuide.java b/src/main/java/com/gmail/nossr50/skills/SkillGuide.java index 99d65c26b..7c1f9fe8d 100644 --- a/src/main/java/com/gmail/nossr50/skills/SkillGuide.java +++ b/src/main/java/com/gmail/nossr50/skills/SkillGuide.java @@ -50,9 +50,7 @@ public final class SkillGuide { } public static void clearChat(Player player) { - for (int x = 0; x < 20; x++) { - player.sendMessage(""); - } + player.sendMessage("\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n\n"); } public static boolean grabGuidePageForSkill(SkillType skilltype, Player player, String[] args) { From e9b016903b82b85e457ef4df98f1f3c0a3b5cdde Mon Sep 17 00:00:00 2001 From: GJ Date: Tue, 12 Feb 2013 18:30:03 -0500 Subject: [PATCH 44/44] Removed /mcc command. Replaced with /mcmmo help. NOTE: /mcmmo help seems to be having formatting issues currently - we're looking into it. --- Changelog.txt | 1 + .../commands/CommandRegistrationHelper.java | 4 +- .../nossr50/commands/player/MccCommand.java | 79 ------------------- .../nossr50/commands/player/McmmoCommand.java | 73 ++++++++++++++++- src/main/java/com/gmail/nossr50/mcMMO.java | 2 - .../resources/locale/locale_en_US.properties | 2 +- src/main/resources/plugin.yml | 15 ++-- 7 files changed, 83 insertions(+), 93 deletions(-) delete mode 100644 src/main/java/com/gmail/nossr50/commands/player/MccCommand.java diff --git a/Changelog.txt b/Changelog.txt index 7b5608034..2081dc5ee 100644 --- a/Changelog.txt +++ b/Changelog.txt @@ -77,6 +77,7 @@ Version 1.4.00-dev - Removed unused "healthbar" files from the resources - Removed config options for disabling commands from the config.yml. This should instead be done through permissions. - Removed Chimaera Wing + - Removed /mcc command. Replaced with /mcmmo [?|help|commands] Version 1.3.14 + Added new Hylian Luck skill to Herbalism. diff --git a/src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java b/src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java index 9625f097d..bd43f8f20 100644 --- a/src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java +++ b/src/main/java/com/gmail/nossr50/commands/CommandRegistrationHelper.java @@ -212,10 +212,10 @@ public final class CommandRegistrationHelper { public static void registerMcmmoCommand() { PluginCommand command = mcMMO.p.getCommand("mcmmo"); command.setDescription(LocaleLoader.getString("Commands.Description.mcmmo")); - command.setPermission("mcmmo.commands.mcmmo"); + command.setPermission("mcmmo.commands.mcmmo;mcmmo.commands.mcmmo.help"); command.setPermissionMessage(permissionsMessage); command.setUsage(LocaleLoader.getString("Commands.Usage.0", "mcmmo")); - command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "mcmmo", "?")); + command.setUsage(command.getUsage() + "\n" + LocaleLoader.getString("Commands.Usage.1", "mcmmo", "help")); command.setExecutor(new McmmoCommand()); } diff --git a/src/main/java/com/gmail/nossr50/commands/player/MccCommand.java b/src/main/java/com/gmail/nossr50/commands/player/MccCommand.java deleted file mode 100644 index 56cc1f761..000000000 --- a/src/main/java/com/gmail/nossr50/commands/player/MccCommand.java +++ /dev/null @@ -1,79 +0,0 @@ -package com.gmail.nossr50.commands.player; - -import org.bukkit.command.Command; -import org.bukkit.command.CommandExecutor; -import org.bukkit.command.CommandSender; -import org.bukkit.entity.Player; - -import com.gmail.nossr50.commands.CommandHelper; -import com.gmail.nossr50.locale.LocaleLoader; -import com.gmail.nossr50.util.Permissions; - -//TODO: Rework this whole thing. It's ugly. Also is missing all the admin & spout commands. -public class MccCommand implements CommandExecutor { - @Override - public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (CommandHelper.noConsoleUsage(sender)) { - return true; - } - - if (!Permissions.hasPermission(sender, "mcmmo.commands.mcc")) { - return true; - } - - Player player = (Player) sender; - - player.sendMessage(LocaleLoader.getString("Commands.mcc.Header")); - - if (Permissions.party(player)) { - player.sendMessage(LocaleLoader.getString("Commands.Party.Commands")); - player.sendMessage("/party create <" + LocaleLoader.getString("Commands.Usage.PartyName") + "> " + LocaleLoader.getString("Commands.Party1")); - player.sendMessage("/party join <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party2")); - player.sendMessage("/party quit " + LocaleLoader.getString("Commands.Party.Quit")); - - if (Permissions.partyChat(player)) { - player.sendMessage("/p " + LocaleLoader.getString("Commands.Party.Toggle")); - } - - player.sendMessage("/party invite <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party.Invite")); - player.sendMessage("/party accept " + LocaleLoader.getString("Commands.Party.Accept")); - - if (Permissions.partyTeleport(player)) { - player.sendMessage("/ptp " + LocaleLoader.getString("Commands.Party.Teleport")); - } - } - - player.sendMessage(LocaleLoader.getString("Commands.Other")); - player.sendMessage("/mcstats " + LocaleLoader.getString("Commands.Stats")); - player.sendMessage("/mctop " + LocaleLoader.getString("Commands.Leaderboards")); - - if (Permissions.skillReset(player)) { - player.sendMessage("/skillreset " + LocaleLoader.getString("Commands.Reset")); - } - - if (Permissions.mcAbility(player)) { - player.sendMessage("/mcability " + LocaleLoader.getString("Commands.ToggleAbility")); - } - - if (Permissions.adminChat(player)) { - player.sendMessage("/a " + LocaleLoader.getString("Commands.AdminToggle")); - } - - if (Permissions.inspect(player)) { - player.sendMessage("/inspect " + LocaleLoader.getString("Commands.Inspect")); - } - - if (Permissions.mmoedit(player)) { - player.sendMessage("/mmoedit " + LocaleLoader.getString("Commands.mmoedit")); - } - - if (Permissions.mcgod(player)) { - player.sendMessage("/mcgod " + LocaleLoader.getString("Commands.mcgod")); - } - - player.sendMessage(LocaleLoader.getString("Commands.SkillInfo")); - player.sendMessage("/mcmmo " + LocaleLoader.getString("Commands.ModDescription")); - - return true; - } -} diff --git a/src/main/java/com/gmail/nossr50/commands/player/McmmoCommand.java b/src/main/java/com/gmail/nossr50/commands/player/McmmoCommand.java index 2429feb81..c64677786 100644 --- a/src/main/java/com/gmail/nossr50/commands/player/McmmoCommand.java +++ b/src/main/java/com/gmail/nossr50/commands/player/McmmoCommand.java @@ -10,12 +10,14 @@ import org.getspout.spoutapi.player.SpoutPlayer; import com.gmail.nossr50.mcMMO; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.locale.LocaleLoader; +import com.gmail.nossr50.util.Permissions; public class McmmoCommand implements CommandExecutor { @Override public boolean onCommand(CommandSender sender, Command command, String label, String[] args) { - if (args.length == 0 || (args.length == 1 && args[0].equals("?"))) { + switch (args.length) { + case 0: String description = LocaleLoader.getString("mcMMO.Description"); String[] mcSplit = description.split(","); sender.sendMessage(mcSplit); @@ -32,8 +34,75 @@ public class McmmoCommand implements CommandExecutor { sender.sendMessage(LocaleLoader.getString("MOTD.Version", mcMMO.p.getDescription().getVersion())); return true; + + case 1: + if (args[0].equalsIgnoreCase("?") || args[0].equalsIgnoreCase("help") || args[0].equalsIgnoreCase("commands")) { + if (!Permissions.hasPermission(sender, "mcmmo.commands.mcmmo.help")) { + sender.sendMessage(command.getPermissionMessage()); + return true; + } + + sender.sendMessage(LocaleLoader.getString("Commands.mcc.Header")); + displayPartyCommands(sender); + displayOtherCommands(sender); + + } + return true; + + default: + return false; + } + } + + private void displayPartyCommands(CommandSender sender) { + if (sender.hasPermission("mcmmo.commands.party")) { + sender.sendMessage(LocaleLoader.getString("Commands.Party.Commands")); + sender.sendMessage("/party create <" + LocaleLoader.getString("Commands.Usage.PartyName") + "> " + LocaleLoader.getString("Commands.Party1")); + sender.sendMessage("/party join <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party2")); + sender.sendMessage("/party quit " + LocaleLoader.getString("Commands.Party.Quit")); + + if (sender.hasPermission("mcmmo.chat.party")) { + sender.sendMessage("/party chat " + LocaleLoader.getString("Commands.Party.Toggle")); + } + + sender.sendMessage("/party invite <" + LocaleLoader.getString("Commands.Usage.Player") + "> " + LocaleLoader.getString("Commands.Party.Invite")); + sender.sendMessage("/party accept " + LocaleLoader.getString("Commands.Party.Accept")); + + if (sender.hasPermission("mcmmo.commands.ptp")) { + sender.sendMessage("/party teleport " + LocaleLoader.getString("Commands.Party.Teleport")); + } + } + } + + private void displayOtherCommands(CommandSender sender) { + sender.sendMessage(LocaleLoader.getString("Commands.Other")); + sender.sendMessage("/mcstats " + LocaleLoader.getString("Commands.Stats")); + sender.sendMessage("/mctop " + LocaleLoader.getString("Commands.Leaderboards")); + + if (sender.hasPermission("mcmmo.commands.skillreset")) { + sender.sendMessage("/skillreset " + LocaleLoader.getString("Commands.Reset")); } - return false; + if (sender.hasPermission("mcmmo.commands.mcability")) { + sender.sendMessage("/mcability " + LocaleLoader.getString("Commands.ToggleAbility")); + } + + if (sender.hasPermission("mcmmo.chat.admin")) { + sender.sendMessage("/adminchat " + LocaleLoader.getString("Commands.AdminToggle")); + } + + if (sender.hasPermission("mcmmo.commands.inspect")) { + sender.sendMessage("/inspect " + LocaleLoader.getString("Commands.Inspect")); + } + + if (sender.hasPermission("mcmmo.commands.mmoedit")) { + sender.sendMessage("/mmoedit " + LocaleLoader.getString("Commands.mmoedit")); + } + + if (sender.hasPermission("mcmmo.commands.mcgod")) { + sender.sendMessage("/mcgod " + LocaleLoader.getString("Commands.mcgod")); + } + + sender.sendMessage(LocaleLoader.getString("Commands.SkillInfo")); } } diff --git a/src/main/java/com/gmail/nossr50/mcMMO.java b/src/main/java/com/gmail/nossr50/mcMMO.java index 3641e100f..3c5befbca 100644 --- a/src/main/java/com/gmail/nossr50/mcMMO.java +++ b/src/main/java/com/gmail/nossr50/mcMMO.java @@ -23,7 +23,6 @@ import org.mcstats.Metrics.Graph; import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManager; import com.gmail.nossr50.util.blockmeta.chunkmeta.ChunkManagerFactory; import com.gmail.nossr50.commands.CommandRegistrationHelper; -import com.gmail.nossr50.commands.player.MccCommand; import com.gmail.nossr50.config.AdvancedConfig; import com.gmail.nossr50.config.Config; import com.gmail.nossr50.config.HiddenConfig; @@ -277,7 +276,6 @@ public class mcMMO extends JavaPlugin { CommandRegistrationHelper.registerMcpurgeCommand(); CommandRegistrationHelper.registerMcremoveCommand(); CommandRegistrationHelper.registerMcabilityCommand(); - getCommand("mcc").setExecutor(new MccCommand()); CommandRegistrationHelper.registerMcgodCommand(); CommandRegistrationHelper.registerMcmmoCommand(); CommandRegistrationHelper.registerMcrefreshCommand(); diff --git a/src/main/resources/locale/locale_en_US.properties b/src/main/resources/locale/locale_en_US.properties index 809adc2c6..0bf32b421 100644 --- a/src/main/resources/locale/locale_en_US.properties +++ b/src/main/resources/locale/locale_en_US.properties @@ -394,7 +394,7 @@ Combat.TouchedFuzzy=[[DARK_RED]]Touched Fuzzy. Felt Dizzy. #COMMANDS ##generic -mcMMO.Description=[[DARK_AQUA]]About the [[YELLOW]]mcMMO[[DARK_AQUA]] Project:,[[GOLD]]mcMMO is an [[RED]]open source[[GOLD]] RPG mod created in February 2011,[[GOLD]]by [[BLUE]]nossr50[[GOLD]]. The goal is to provide a quality RPG experience.,[[DARK_AQUA]]Tips:,[[GOLD]] - [[GREEN]]Use [[RED]]/mcc[[GREEN]] to see commands,[[GOLD]] - [[GREEN]]Type [[RED]]/SKILLNAME[[GREEN]] to see detailed skill info,[[DARK_AQUA]]Developers:,[[GOLD]] - [[GREEN]]nossr50 [[BLUE]](Founder),[[GOLD]] - [[GREEN]]GJ [[BLUE]](Project Lead),[[GOLD]] - [[GREEN]]NuclearW [[BLUE]](Developer),[[GOLD]] - [[GREEN]]bm01 [[BLUE]](Developer),[[GOLD]] - [[GREEN]]TfT_02 [[BLUE]](Developer),[[GOLD]] - [[GREEN]]Glitchfinder [[BLUE]](Developer),[[GOLD]] - [[GREEN]]toothplck1 [[BLUE]](Developer),[[DARK_AQUA]]Useful Links:,[[GOLD]] - [[GREEN]]https://github.com/mcMMO-Dev/mcMMO/issues[[GOLD]] Bug Reporting,[[GOLD]] - [[GREEN]]#mcmmo @ irc.esper.net[[GOLD]] IRC Chat,[[GOLD]] - [[GREEN]]http://bit.ly/H6XwFb[[GOLD]] Bukkit Forum Thread +mcMMO.Description=[[DARK_AQUA]]About the [[YELLOW]]mcMMO[[DARK_AQUA]] Project:,[[GOLD]]mcMMO is an [[RED]]open source[[GOLD]] RPG mod created in February 2011,[[GOLD]]by [[BLUE]]nossr50[[GOLD]]. The goal is to provide a quality RPG experience.,[[DARK_AQUA]]Tips:,[[GOLD]] - [[GREEN]]Use [[RED]]/mcmmo help[[GREEN]] to see commands,[[GOLD]] - [[GREEN]]Type [[RED]]/SKILLNAME[[GREEN]] to see detailed skill info,[[DARK_AQUA]]Developers:,[[GOLD]] - [[GREEN]]nossr50 [[BLUE]](Founder),[[GOLD]] - [[GREEN]]GJ [[BLUE]](Project Lead),[[GOLD]] - [[GREEN]]NuclearW [[BLUE]](Developer),[[GOLD]] - [[GREEN]]bm01 [[BLUE]](Developer),[[GOLD]] - [[GREEN]]TfT_02 [[BLUE]](Developer),[[GOLD]] - [[GREEN]]Glitchfinder [[BLUE]](Developer),[[GOLD]] - [[GREEN]]toothplck1 [[BLUE]](Developer),[[DARK_AQUA]]Useful Links:,[[GOLD]] - [[GREEN]]https://github.com/mcMMO-Dev/mcMMO/issues[[GOLD]] Bug Reporting,[[GOLD]] - [[GREEN]]#mcmmo @ irc.esper.net[[GOLD]] IRC Chat, Commands.addlevels.AwardAll.1=[[GREEN]]You were awarded {0} levels in all skills! Commands.addlevels.AwardAll.2=[[RED]]All skills have been modified for {0}. Commands.addlevels.AwardSkill.1=[[GREEN]]You were awarded {0} levels in {1}! diff --git a/src/main/resources/plugin.yml b/src/main/resources/plugin.yml index 902569546..01be21eaf 100644 --- a/src/main/resources/plugin.yml +++ b/src/main/resources/plugin.yml @@ -28,9 +28,6 @@ commands: xprate: aliases: [mcxprate] description: Modify the xp rate or start an event - mcc: - aliases: [] - description: Lists mcMMO commands mcmmo: description: Shows a brief mod description mctop: @@ -564,9 +561,8 @@ permissions: mcmmo.commands.herbalism: true mcmmo.commands.inspect: true mcmmo.commands.mcability: true - mcmmo.commands.mcc: true mcmmo.commands.mchud: true - mcmmo.commands.mcmmo: true + mcmmo.commands.mcmmo.all: true mcmmo.commands.mcrank: true mcmmo.commands.mcstats: true mcmmo.commands.mctop.all: true @@ -651,16 +647,21 @@ permissions: description: Allows access to the mcability command mcmmo.commands.mcability.others: description: Allows access to the mcability command for other players - mcmmo.commands.mcc: - description: Allows access to the mcc command mcmmo.commands.mcgod: description: Allows access to the mcgod command mcmmo.commands.mcgod.others: description: Allows access to the mcgod command for other players mcmmo.commands.mchud: description: Allows access to the mchud command + mcmmo.commands.mcmmo.all: + description: Implies access to all mcmmo.commands.mcmmo permissions. + children: + mcmmo.commands.mcmmo: true + mcmmo.commands.mcmmo.help: true mcmmo.commands.mcmmo: description: Allows access to the mcmmo command + mcmmo.commands.mcmmo.help: + description: Allows access to the mcmmo help command mcmmo.commands.mcpurge: default: false description: Allows access to the mcpurge command