2013-05-03 22:14:03 +02:00
|
|
|
package com.gmail.nossr50.commands;
|
|
|
|
|
|
|
|
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;
|
|
|
|
import com.google.common.collect.ImmutableList;
|
2019-01-15 07:11:58 +01:00
|
|
|
import org.bukkit.command.Command;
|
|
|
|
import org.bukkit.command.CommandSender;
|
|
|
|
import org.bukkit.command.TabExecutor;
|
|
|
|
import org.bukkit.util.StringUtil;
|
|
|
|
|
|
|
|
import java.util.ArrayList;
|
|
|
|
import java.util.List;
|
2013-05-03 22:14:03 +02:00
|
|
|
|
|
|
|
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;
|
|
|
|
}
|
|
|
|
|
2014-08-20 06:23:19 +02:00
|
|
|
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:
|
2014-02-28 21:55:32 +01:00
|
|
|
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();
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|