Rearrange checks in PartyInviteCommand

This commit is contained in:
riking 2013-10-28 13:31:22 -07:00
parent 31e04a2d91
commit 13f0f396d7
2 changed files with 20 additions and 17 deletions

View File

@ -9,34 +9,23 @@ import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.Misc;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
public class PartyInviteCommand implements CommandExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandUtils.noConsoleUsage(sender)) {
return false;
}
switch (args.length) {
case 2:
String targetName = Misc.getMatchedPlayerName(args[1]);
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName, true);
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
return false;
}
Player target = mcMMOTarget.getPlayer();
Player player = (Player) sender;
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
String playerName = player.getName();
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", targetName));
if (playerName.equalsIgnoreCase(args[1])) {
player.sendMessage(LocaleLoader.getString("Party.Invite.Self"));
return true;
}
@ -45,6 +34,20 @@ public class PartyInviteCommand implements CommandExecutor {
return true;
}
McMMOPlayer mcMMOTarget = UserManager.getPlayer(args[1], true);
if (mcMMOTarget == null) {
player.sendMessage(LocaleLoader.getString("Commands.Offline"));
return true;
}
Player target = mcMMOTarget.getPlayer();
if (PartyManager.inSameParty(player, target)) {
sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", target.getName()));
return true;
}
Party playerParty = mcMMOPlayer.getParty();
mcMMOTarget.setPartyInvite(playerParty);

View File

@ -38,7 +38,7 @@ public class PtpAcceptCommand implements CommandExecutor {
Player target = mcMMOPlayer.getPtpRequest();
mcMMOPlayer.removePtpRequest();
if (!PtpCommand.canTeleport(sender, player, target.getName())) {
if (!PtpCommand.canTeleport(player, target.getName())) {
return true;
}