package de.iani.cubequest.commands;

import de.iani.cubequest.CubeQuest;
import de.iani.cubequest.PlayerData;
import de.iani.cubequest.util.ChatAndTextUtil;
import java.util.Collections;
import java.util.List;
import org.bukkit.OfflinePlayer;
import org.bukkit.command.Command;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

public class ShowLevelCommand extends SubCommand {
    
    @Override
    public boolean onCommand(CommandSender sender, Command command, String alias,
            String commandString, ArgsParser args) {
        
        OfflinePlayer player;
        if (args.hasNext()) {
            String playerName = args.next();
            player = CubeQuest.getInstance().getPlayerUUIDCache().getPlayer(playerName);
            
            if (player == null) {
                ChatAndTextUtil.sendWarningMessage(sender,
                        "Spieler " + playerName + " nicht gefunden.");
                return true;
            }
        } else if (!(sender instanceof Player)) {
            ChatAndTextUtil.sendErrorMessage(sender, "Diesen Befehl können nur Spieler ausführen!");
            return true;
        } else {
            player = (Player) sender;
        }
        
        PlayerData data = CubeQuest.getInstance().getPlayerData(player);
        
        int level = data.getLevel();
        int xp = data.getXp();
        int requiredXp = PlayerData.getXpRequiredForLevel(level + 1);
        
        ChatAndTextUtil.sendNormalMessage(sender,
                (sender == player ? "Du hast " : (player.getName() + " hat ")) + xp
                        + " Quest-XP und damit Level " + level + ".");
        
        if (player == sender || sender.hasPermission(CubeQuest.SEE_PLAYER_INFO_PERMISSION)) {
            ChatAndTextUtil.sendNormalMessage(sender,
                    (player == sender ? "Dir" : player.getName()) + " fehl"
                            + (requiredXp - xp == 1 ? "t" : "en") + " noch " + (requiredXp - xp)
                            + " Quest-XP zum nächsten Level.");
            ChatAndTextUtil.sendNormalMessage(sender,
                    (sender == player ? "Du hast " : (player.getName() + " hat "))
                            + data.getQuestPoints() + " Quest-Punkt"
                            + (data.getQuestPoints() == 1 ? "" : "e") + ".");
        }
        
        return true;
    }
    
    @Override
    public String getRequiredPermission() {
        return CubeQuest.ACCEPT_QUESTS_PERMISSION;
    }
    
    @Override
    public boolean requiresPlayer() {
        return true;
    }
    
    @Override
    public List<String> onTabComplete(CommandSender sender, Command command, String alias,
            ArgsParser args) {
        return Collections.emptyList();
    }
    
    @Override
    public String getUsage() {
        return "(zeigt dein aktuelles Quest-Level, deine Quest-XP und deine Quest-Punkte an)";
    }
    
}

@@ -1089,13 +1089,15 @@
 send
-Error
+Warning
 Mess
@@ -1113,51 +1113,35 @@
 r, %22
-Diesen Befehl k%C3%B6nnen nur Spieler ausf%C3%BChren!
+Bitte gib einen Spieler an.
 %22);%0D
@@ -2576,97 +2576,8 @@
 de%0D%0A
-    public boolean requiresPlayer() %7B%0D%0A        return true;%0D%0A    %7D%0D%0A    %0D%0A    @Override%0D%0A
     

Fix quest level for console.