package com.gmail.nossr50.commands.party;

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.mcMMO;
import com.gmail.nossr50.datatypes.party.Party;
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
import com.gmail.nossr50.locale.LocaleLoader;
import com.gmail.nossr50.party.PartyManager;
import com.gmail.nossr50.util.player.UserManager;

public class PartyKickCommand implements CommandExecutor {
    @Override
    public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
        switch (args.length) {
            case 2:
                Party playerParty = UserManager.getPlayer((Player) sender).getParty();
                OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(args[1]);

                if (!playerParty.getMembers().contains(target.getName())) {
                    sender.sendMessage(LocaleLoader.getString("Party.NotInYourParty", target.getName()));
                    return true;
                }

                if (target.isOnline()) {
                    Player onlineTarget = target.getPlayer();
                    String partyName = playerParty.getName();

                    if (!PartyManager.handlePartyChangeEvent(onlineTarget, partyName, null, EventReason.KICKED_FROM_PARTY)) {
                        return true;
                    }

                    PartyManager.processPartyLeaving(UserManager.getPlayer(onlineTarget));
                    onlineTarget.sendMessage(LocaleLoader.getString("Commands.Party.Kick", partyName));
                }

                PartyManager.removeFromParty(target, playerParty);
                return true;

            default:
                sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "kick", "<" + LocaleLoader.getString("Commands.Usage.Player") + ">"));
                return true;
        }
    }
}

@@ -462,24 +462,77 @@
 rtyManager;%0A
+import com.gmail.nossr50.util.commands.CommandUtils;%0A
 import com.g
@@ -900,67 +900,61 @@
     
-OfflinePlayer target = mcMMO.p.getServer().getOffline
+String targetName = CommandUtils.getMatched
 Player
+Name
 (arg
@@ -1022,26 +1022,20 @@
 s(target
-.get
 Name
-()
 )) %7B%0A   
@@ -1123,26 +1123,20 @@
 , target
-.get
 Name
-()
 ));%0A    
@@ -1175,32 +1175,122 @@
              %7D%0A%0A
+                OfflinePlayer target = mcMMO.p.getServer().getOfflinePlayer(targetName);%0A%0A
                 

Fix /party kick command