2013-02-11 21:19:41 +01:00
|
|
|
package com.gmail.nossr50.party.commands;
|
|
|
|
|
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandExecutor;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.entity.Player;
|
|
|
|
|
|
|
|
import com.gmail.nossr50.events.party.McMMOPartyChangeEvent.EventReason;
|
|
|
|
import com.gmail.nossr50.locale.LocaleLoader;
|
|
|
|
import com.gmail.nossr50.party.Party;
|
|
|
|
import com.gmail.nossr50.party.PartyManager;
|
|
|
|
import com.gmail.nossr50.util.Permissions;
|
|
|
|
import com.gmail.nossr50.util.Users;
|
|
|
|
|
|
|
|
public class PartyDisbandCommand implements CommandExecutor {
|
|
|
|
@Override
|
|
|
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
|
|
|
if (!Permissions.hasPermission(sender, "mcmmo.commands.party.disband")) {
|
|
|
|
sender.sendMessage(command.getPermissionMessage());
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
2013-02-11 21:24:20 +01:00
|
|
|
switch (args.length) {
|
|
|
|
case 1:
|
2013-02-12 07:41:51 +01:00
|
|
|
Party playerParty = Users.getPlayer((Player) sender).getParty();
|
2013-02-11 21:19:41 +01:00
|
|
|
|
2013-02-11 21:24:20 +01:00
|
|
|
for (Player member : playerParty.getOnlineMembers()) {
|
|
|
|
if (!PartyManager.handlePartyChangeEvent(member, playerParty.getName(), null, EventReason.KICKED_FROM_PARTY)) {
|
|
|
|
return true;
|
|
|
|
}
|
|
|
|
|
|
|
|
member.sendMessage(LocaleLoader.getString("Party.Disband"));
|
|
|
|
}
|
|
|
|
|
|
|
|
PartyManager.disbandParty(playerParty);
|
|
|
|
return true;
|
2013-02-11 21:19:41 +01:00
|
|
|
|
2013-02-11 21:24:20 +01:00
|
|
|
default:
|
|
|
|
sender.sendMessage(LocaleLoader.getString("Commands.Usage.1", "party", "disband"));
|
|
|
|
return true;
|
|
|
|
}
|
2013-02-11 21:19:41 +01:00
|
|
|
}
|
|
|
|
}
|