Merge pull request #387 from dualspiral/EventFix

Don't fire Party Change event if player can't change parties
This commit is contained in:
TfT_02 2012-12-29 13:12:10 -08:00
commit 5e9c483892
2 changed files with 22 additions and 1 deletions

View File

@ -137,6 +137,13 @@ public class PartyCommand implements CommandExecutor {
} }
} }
else { else {
Party newParty = partyManagerInstance.getParty(args[0]);
// Check to see if the party exists, and if it does, can the player join it?
if (newParty != null && !partyManagerInstance.checkJoinability(player, playerProfile, newParty, null)) {
return true; // End before any event is fired.
}
if (party != null) { if (party != null) {
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), args[0], EventReason.CHANGED_PARTIES); McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), args[0], EventReason.CHANGED_PARTIES);
plugin.getServer().getPluginManager().callEvent(event); plugin.getServer().getPluginManager().callEvent(event);
@ -208,6 +215,13 @@ public class PartyCommand implements CommandExecutor {
} }
} }
else { else {
Party newParty = partyManagerInstance.getParty(args[0]);
// Check to see if the party exists, and if it does, can the player join it?
if (newParty != null && !partyManagerInstance.checkJoinability(player, playerProfile, newParty, args[1])) {
return true; // End before any event is fired.
}
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), args[0], EventReason.CHANGED_PARTIES); McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, party.getName(), args[0], EventReason.CHANGED_PARTIES);
plugin.getServer().getPluginManager().callEvent(event); plugin.getServer().getPluginManager().callEvent(event);
@ -220,6 +234,13 @@ public class PartyCommand implements CommandExecutor {
} }
} }
else { else {
Party newParty = partyManagerInstance.getParty(args[0]);
// Check to see if the party exists, and if it does, can the player join it?
if (newParty != null && !partyManagerInstance.checkJoinability(player, playerProfile, newParty, args[1])) {
return true; // End before any event is fired.
}
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, args[0], EventReason.JOINED_PARTY); McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(player, null, args[0], EventReason.JOINED_PARTY);
plugin.getServer().getPluginManager().callEvent(event); plugin.getServer().getPluginManager().callEvent(event);

View File

@ -241,7 +241,7 @@ public class PartyManager {
* @param password The password provided by the player * @param password The password provided by the player
* @return true if the player can join the party * @return true if the player can join the party
*/ */
private boolean checkJoinability(Player player, PlayerProfile playerProfile, Party party, String password) { public boolean checkJoinability(Player player, PlayerProfile playerProfile, Party party, String password) {
//Don't care about passwords if it isn't locked //Don't care about passwords if it isn't locked
if (party.isLocked()) { if (party.isLocked()) {
String partyPassword = party.getPassword(); String partyPassword = party.getPassword();