mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-26 15:16:45 +01:00
Convert /party owner to a subcommand.
This commit is contained in:
parent
e8ac3c812f
commit
e66ff53ca4
@ -0,0 +1,49 @@
|
|||||||
|
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.mcMMO;
|
||||||
|
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 PartyChangeOwnerCommand 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.owner")) {
|
||||||
|
sender.sendMessage(command.getPermissionMessage());
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (args.length) {
|
||||||
|
case 2:
|
||||||
|
player = (Player) sender;
|
||||||
|
playerParty = Users.getPlayer(player).getParty();
|
||||||
|
|
||||||
|
if (!playerParty.getLeader().equals(player.getName())) {
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Party.NotOwner"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!playerParty.getMembers().contains(mcMMO.p.getServer().getOfflinePlayer(args[1]))) {
|
||||||
|
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", args[1]));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
PartyManager.setPartyLeader(args[1], playerParty);
|
||||||
|
return true;
|
||||||
|
|
||||||
|
default:
|
||||||
|
sender.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "owner", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]"));
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
@ -32,6 +32,7 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
private CommandExecutor partyInviteCommand = new PartyInviteCommand();
|
private CommandExecutor partyInviteCommand = new PartyInviteCommand();
|
||||||
private CommandExecutor partyKickCommand = new PartyKickCommand();
|
private CommandExecutor partyKickCommand = new PartyKickCommand();
|
||||||
private CommandExecutor partyDisbandCommand = new PartyDisbandCommand();
|
private CommandExecutor partyDisbandCommand = new PartyDisbandCommand();
|
||||||
|
private CommandExecutor partyChangeOwnerCommand = new PartyChangeOwnerCommand();
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
|
||||||
@ -88,7 +89,7 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
return partyDisbandCommand.onCommand(sender, command, label, args);
|
return partyDisbandCommand.onCommand(sender, command, label, args);
|
||||||
}
|
}
|
||||||
else if (args[0].equalsIgnoreCase("owner")) {
|
else if (args[0].equalsIgnoreCase("owner")) {
|
||||||
return changeOwner(args);
|
return partyChangeOwnerCommand.onCommand(sender, command, label, args);
|
||||||
}
|
}
|
||||||
else if (args[0].equalsIgnoreCase("lock")) {
|
else if (args[0].equalsIgnoreCase("lock")) {
|
||||||
return lock();
|
return lock();
|
||||||
@ -190,34 +191,6 @@ public class PartyCommand implements CommandExecutor {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Change the owner of the current party
|
|
||||||
*/
|
|
||||||
private boolean changeOwner(String[] args) {
|
|
||||||
if (CommandHelper.noCommandPermissions(player, "mcmmo.commands.party.owner")) {
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
String playerName = player.getName();
|
|
||||||
Party party = mcMMOPlayer.getParty();
|
|
||||||
|
|
||||||
if (args.length < 2) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Commands.Usage.2", "party", "owner", "[" + LocaleLoader.getString("Commands.Usage.Player") + "]"));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (party.getLeader().equals(playerName)) {
|
|
||||||
if (!party.getMembers().contains(mcMMO.p.getServer().getOfflinePlayer(args[1]))) {
|
|
||||||
player.sendMessage(LocaleLoader.getString("Party.NotInYourParty", args[1]));
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
PartyManager.setPartyLeader(args[1], party);
|
|
||||||
}
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Lock the current party
|
* Lock the current party
|
||||||
*/
|
*/
|
||||||
|
Loading…
Reference in New Issue
Block a user