mcMMO/src/main/java/com/gmail/nossr50/party/commands/PartyCommand.java

141 lines
5.7 KiB
Java
Raw Normal View History

package com.gmail.nossr50.party.commands;
2012-01-09 20:00:13 +01:00
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
2012-04-22 08:55:58 +02:00
import com.gmail.nossr50.commands.CommandHelper;
import com.gmail.nossr50.datatypes.McMMOPlayer;
2012-04-27 11:47:11 +02:00
import com.gmail.nossr50.locale.LocaleLoader;
2013-02-08 17:12:32 +01:00
import com.gmail.nossr50.util.Permissions;
2012-04-27 11:47:11 +02:00
import com.gmail.nossr50.util.Users;
2012-01-09 20:00:13 +01:00
public class PartyCommand implements CommandExecutor {
private McMMOPlayer mcMMOPlayer;
private Player player;
2013-02-08 03:46:12 +01:00
private CommandExecutor partyJoinCommand = new PartyJoinCommand();
private CommandExecutor partyAcceptCommand = new PartyAcceptCommand();
private CommandExecutor partyCreateCommand = new PartyCreateCommand();
2013-02-08 16:26:59 +01:00
private CommandExecutor partyQuitCommand = new PartyQuitCommand();
private CommandExecutor partyExpShareCommand = new PartyExpShareCommand();
private CommandExecutor partyItemShareCommand = new PartyItemShareCommand();
2013-02-08 22:56:54 +01:00
private CommandExecutor partyInviteCommand = new PartyInviteCommand();
2013-02-11 06:25:03 +01:00
private CommandExecutor partyKickCommand = new PartyKickCommand();
2013-02-11 21:19:41 +01:00
private CommandExecutor partyDisbandCommand = new PartyDisbandCommand();
2013-02-11 21:33:25 +01:00
private CommandExecutor partyChangeOwnerCommand = new PartyChangeOwnerCommand();
private CommandExecutor partyLockCommand = new PartyLockCommand();
private CommandExecutor partyChangePasswordCommand = new PartyChangePasswordCommand();
2013-02-12 15:22:57 +01:00
private CommandExecutor partyRenameCommand = new PartyRenameCommand();
2013-02-12 16:42:42 +01:00
private CommandExecutor partyInfoCommand = new PartyInfoCommand();
2013-02-08 03:46:12 +01:00
2012-04-22 08:55:58 +02:00
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
if (CommandHelper.noConsoleUsage(sender)) {
return true;
}
2013-02-08 17:12:32 +01:00
if (!Permissions.hasPermission(sender, "mcmmo.commands.party")) {
sender.sendMessage(command.getPermissionMessage());
2012-04-22 08:55:58 +02:00
return true;
}
player = (Player) sender;
mcMMOPlayer = Users.getPlayer(player);
2013-02-12 17:23:32 +01:00
if (args.length < 1) {
if (!mcMMOPlayer.inParty()) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
return printUsage();
}
2013-02-12 16:42:42 +01:00
return partyInfoCommand.onCommand(sender, command, label, args);
2013-01-26 23:01:55 +01:00
}
2013-02-12 17:23:32 +01:00
PartySubcommand subcommand = PartySubcommand.getSubcommand(args[0]);
if (subcommand == null) {
return printUsage();
2013-01-26 23:01:55 +01:00
}
2013-02-12 17:23:32 +01:00
switch (subcommand) {
case JOIN:
return partyJoinCommand.onCommand(sender, command, label, args);
case ACCEPT:
2013-02-08 04:09:43 +01:00
return partyAcceptCommand.onCommand(sender, command, label, args);
2013-02-12 17:23:32 +01:00
case CREATE:
return partyCreateCommand.onCommand(sender, command, label, args);
2013-02-12 17:23:32 +01:00
case HELP:
return printHelp();
2013-02-12 17:23:32 +01:00
default:
break;
2013-01-26 23:01:55 +01:00
}
2013-02-12 17:23:32 +01:00
// Party member commands
2013-02-08 17:12:32 +01:00
if (!mcMMOPlayer.inParty()) {
sender.sendMessage(LocaleLoader.getString("Commands.Party.None"));
2013-02-12 17:23:32 +01:00
return printUsage();
2013-01-26 23:01:55 +01:00
}
2013-02-12 17:23:32 +01:00
switch (subcommand) {
case INFO:
return partyInfoCommand.onCommand(sender, command, label, args);
case QUIT:
2013-02-08 17:12:32 +01:00
return partyQuitCommand.onCommand(sender, command, label, args);
2013-02-12 17:23:32 +01:00
case INVITE:
2013-02-08 22:56:54 +01:00
return partyInviteCommand.onCommand(sender, command, label, args);
2013-02-12 17:23:32 +01:00
default:
break;
2013-02-08 17:12:32 +01:00
}
2013-02-12 17:23:32 +01:00
// Party leader commands
if (!mcMMOPlayer.getParty().getLeader().equals(player.getName())) {
sender.sendMessage(LocaleLoader.getString("Party.NotOwner"));
return true;
}
2013-02-12 17:23:32 +01:00
switch (subcommand) {
case EXPSHARE:
return partyExpShareCommand.onCommand(sender, command, label, args);
case ITEMSHARE:
return partyItemShareCommand.onCommand(sender, command, label, args);
case KICK:
2013-02-11 06:25:03 +01:00
return partyKickCommand.onCommand(sender, command, label, args);
2013-02-12 17:23:32 +01:00
case DISBAND:
2013-02-11 21:19:41 +01:00
return partyDisbandCommand.onCommand(sender, command, label, args);
2013-02-12 17:23:32 +01:00
case OWNER:
2013-02-11 21:33:25 +01:00
return partyChangeOwnerCommand.onCommand(sender, command, label, args);
2013-02-12 17:23:32 +01:00
case LOCK:
case UNLOCK:
return partyLockCommand.onCommand(sender, command, label, args);
2013-02-12 17:23:32 +01:00
case PASSWORD:
return partyChangePasswordCommand.onCommand(sender, command, label, args);
2013-02-12 17:23:32 +01:00
case RENAME:
2013-02-12 15:22:57 +01:00
return partyRenameCommand.onCommand(sender, command, label, args);
2013-02-12 17:23:32 +01:00
default:
break;
2013-02-08 17:12:32 +01:00
}
2013-02-12 17:23:32 +01:00
return true;
}
private boolean printUsage() {
player.sendMessage(LocaleLoader.getString("Party.Help.0", "/party join"));
player.sendMessage(LocaleLoader.getString("Party.Help.1", "/party create"));
player.sendMessage(LocaleLoader.getString("Party.Help.2", "/party ?"));
return true;
}
private boolean printHelp() {
player.sendMessage(LocaleLoader.getString("Party.Help.3", "/party join", "/party quit"));
player.sendMessage(LocaleLoader.getString("Party.Help.1", "/party create"));
player.sendMessage(LocaleLoader.getString("Party.Help.4", "/party <lock|unlock>"));
player.sendMessage(LocaleLoader.getString("Party.Help.5", "/party password"));
player.sendMessage(LocaleLoader.getString("Party.Help.6", "/party kick"));
player.sendMessage(LocaleLoader.getString("Party.Help.7", "/party owner"));
player.sendMessage(LocaleLoader.getString("Party.Help.8", "/party disband"));
return true;
}
2012-01-09 20:00:13 +01:00
}