mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-12-02 01:46:45 +01:00
Rearrange checks in PartyInviteCommand
This commit is contained in:
parent
31e04a2d91
commit
13f0f396d7
@ -9,34 +9,23 @@ import com.gmail.nossr50.datatypes.party.Party;
|
|||||||
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
|
||||||
import com.gmail.nossr50.locale.LocaleLoader;
|
import com.gmail.nossr50.locale.LocaleLoader;
|
||||||
import com.gmail.nossr50.party.PartyManager;
|
import com.gmail.nossr50.party.PartyManager;
|
||||||
import com.gmail.nossr50.util.Misc;
|
|
||||||
import com.gmail.nossr50.util.commands.CommandUtils;
|
import com.gmail.nossr50.util.commands.CommandUtils;
|
||||||
import com.gmail.nossr50.util.player.UserManager;
|
import com.gmail.nossr50.util.player.UserManager;
|
||||||
|
|
||||||
public class PartyInviteCommand implements CommandExecutor {
|
public class PartyInviteCommand implements CommandExecutor {
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
switch (args.length) {
|
if (CommandUtils.noConsoleUsage(sender)) {
|
||||||
case 2:
|
|
||||||
String targetName = Misc.getMatchedPlayerName(args[1]);
|
|
||||||
McMMOPlayer mcMMOTarget = UserManager.getPlayer(targetName, true);
|
|
||||||
|
|
||||||
if (!CommandUtils.checkPlayerExistence(sender, targetName, mcMMOTarget)) {
|
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
switch (args.length) {
|
||||||
Player target = mcMMOTarget.getPlayer();
|
case 2:
|
||||||
Player player = (Player) sender;
|
Player player = (Player) sender;
|
||||||
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(player);
|
||||||
String playerName = player.getName();
|
String playerName = player.getName();
|
||||||
|
|
||||||
if (player.equals(target)) {
|
if (playerName.equalsIgnoreCase(args[1])) {
|
||||||
sender.sendMessage(LocaleLoader.getString("Party.Invite.Self"));
|
player.sendMessage(LocaleLoader.getString("Party.Invite.Self"));
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (PartyManager.inSameParty(player, target)) {
|
|
||||||
sender.sendMessage(LocaleLoader.getString("Party.Player.InSameParty", targetName));
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -45,6 +34,20 @@ public class PartyInviteCommand implements CommandExecutor {
|
|||||||
return true;
|
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();
|
Party playerParty = mcMMOPlayer.getParty();
|
||||||
mcMMOTarget.setPartyInvite(playerParty);
|
mcMMOTarget.setPartyInvite(playerParty);
|
||||||
|
|
||||||
|
@ -38,7 +38,7 @@ public class PtpAcceptCommand implements CommandExecutor {
|
|||||||
Player target = mcMMOPlayer.getPtpRequest();
|
Player target = mcMMOPlayer.getPtpRequest();
|
||||||
mcMMOPlayer.removePtpRequest();
|
mcMMOPlayer.removePtpRequest();
|
||||||
|
|
||||||
if (!PtpCommand.canTeleport(sender, player, target.getName())) {
|
if (!PtpCommand.canTeleport(player, target.getName())) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user