mirror of
https://github.com/mcMMO-Dev/mcMMO.git
synced 2024-11-24 06:06:45 +01:00
69 lines
2.3 KiB
Java
69 lines
2.3 KiB
Java
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;
|
|
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;
|
|
|
|
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;
|
|
}
|
|
|
|
UserManager.getPlayer(sender.getName()).getFishingManager().unleashTheKraken();
|
|
return true;
|
|
|
|
case 1:
|
|
if (!Permissions.krakenOthers(sender)) {
|
|
sender.sendMessage(command.getPermissionMessage());
|
|
return true;
|
|
}
|
|
|
|
String playerName = CommandUtils.getMatchedPlayerName(args[0]);
|
|
McMMOPlayer mcMMOPlayer = UserManager.getPlayer(playerName);
|
|
|
|
if (!CommandUtils.checkPlayerExistence(sender, playerName, mcMMOPlayer)) {
|
|
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);
|
|
return StringUtil.copyPartialMatches(args[0], playerNames, new ArrayList<String>(playerNames.size()));
|
|
default:
|
|
return ImmutableList.of();
|
|
}
|
|
}
|
|
}
|