mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-01 16:19:53 +01:00
Convert /party disband to a subcommand
This commit is contained in:
parent
59a52a73bb
commit
1c0e392552
@ -31,6 +31,7 @@ public class PartyCommand implements CommandExecutor {
|
||||
private CommandExecutor partyItemShareCommand = new PartyItemShareCommand();
|
||||
private CommandExecutor partyInviteCommand = new PartyInviteCommand();
|
||||
private CommandExecutor partyKickCommand = new PartyKickCommand();
|
||||
private CommandExecutor partyDisbandCommand = new PartyDisbandCommand();
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||
@ -84,7 +85,7 @@ public class PartyCommand implements CommandExecutor {
|
||||
return partyKickCommand.onCommand(sender, command, label, args);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("disband")) {
|
||||
return disband();
|
||||
return partyDisbandCommand.onCommand(sender, command, label, args);
|
||||
}
|
||||
else if (args[0].equalsIgnoreCase("owner")) {
|
||||
return changeOwner(args);
|
||||
@ -189,38 +190,6 @@ public class PartyCommand implements CommandExecutor {
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Disband the current party, kicks out all party members.
|
||||
*/
|
||||
private boolean disband() {
|
||||
if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.party.disband")) {
|
||||
return true;
|
||||
}
|
||||
|
||||
String playerName = player.getName();
|
||||
Party party = mcMMOPlayer.getParty();
|
||||
|
||||
if (party.getLeader().equals(playerName)) {
|
||||
for (Player onlineMembers : party.getOnlineMembers()) {
|
||||
McMMOPartyChangeEvent event = new McMMOPartyChangeEvent(onlineMembers, party.getName(), null, EventReason.KICKED_FROM_PARTY);
|
||||
mcMMO.p.getServer().getPluginManager().callEvent(event);
|
||||
|
||||
if (event.isCancelled()) {
|
||||
return true;
|
||||
}
|
||||
|
||||
onlineMembers.sendMessage(LocaleLoader.getString("Party.Disband"));
|
||||
}
|
||||
|
||||
PartyManager.disbandParty(party);
|
||||
}
|
||||
else {
|
||||
player.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
||||
}
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
/**
|
||||
* Change the owner of the current party
|
||||
*/
|
||||
|
@ -0,0 +1,47 @@
|
||||
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 {
|
||||
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")) {
|
||||
sender.sendMessage(command.getPermissionMessage());
|
||||
return true;
|
||||
}
|
||||
|
||||
player = (Player) sender;
|
||||
playerParty = Users.getPlayer(player).getParty();
|
||||
|
||||
if (!playerParty.getLeader().equals(player.getName())) {
|
||||
sender.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
||||
return true;
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
}
|
||||
|
||||
}
|
Loading…
Reference in New Issue
Block a user