No point in repeating this check over multiple classes.

This commit is contained in:
GJ 2013-02-12 01:41:51 -05:00
parent 45ebc2b89b
commit e5c7e81b08
5 changed files with 14 additions and 43 deletions

View File

@ -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;
}

View File

@ -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")) {

View File

@ -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)) {

View File

@ -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;
}
}
}

View File

@ -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"));
}
}