mcMMO/src/main/java/com/gmail/nossr50/commands/KrakenCommand.java

71 lines
2.3 KiB
Java
Raw Normal View History

2013-05-03 22:14:03 +02:00
package com.gmail.nossr50.commands;
import java.util.ArrayList;
import java.util.List;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.command.TabExecutor;
import org.bukkit.util.StringUtil;
import com.gmail.nossr50.datatypes.player.McMMOPlayer;
import com.gmail.nossr50.util.Permissions;
import com.gmail.nossr50.util.commands.CommandUtils;
import com.gmail.nossr50.util.player.UserManager;
2013-09-10 15:28:07 +02:00
2013-05-03 22:14:03 +02:00
import com.google.common.collect.ImmutableList;
public class KrakenCommand implements TabExecutor {
@Override
public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
switch (args.length) {
case 0:
if (CommandUtils.noConsoleUsage(sender)) {
return true;
}
if (!Permissions.kraken(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
if (!CommandUtils.hasPlayerDataKey(sender)) {
return true;
}
2013-10-29 20:38:20 +01:00
UserManager.getPlayer(sender.getName()).getFishingManager().unleashTheKraken();
2013-05-03 22:14:03 +02:00
return true;
case 1:
if (!Permissions.krakenOthers(sender)) {
sender.sendMessage(command.getPermissionMessage());
return true;
}
2014-01-03 17:07:13 +01:00
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
2013-08-20 20:10:49 +02:00
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName);
2013-05-03 22:14:03 +02:00
2013-08-20 20:10:49 +02:00
if (!CommandUtils.checkPlayerExistence(sender, playerName, mcMMOPlayer)) {
2013-05-03 22:14:03 +02:00
return true;
}
mcMMOPlayer.getFishingManager().unleashTheKraken();
return true;
default:
return false;
}
}
@Override
public List<String> onTabComplete(CommandSender sender, Command command, String alias, String[] args) {
switch (args.length) {
case 1:
List<String> playerNames = CommandUtils.getOnlinePlayerNames(sender);
2013-05-03 22:14:03 +02:00
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
default:
return ImmutableList.of();
}
}
}