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.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) {
        
        Player 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,
                "Du hast " + xp + " Quest-XP und damit Level " + level + ".");
        ChatAndTextUtil.sendNormalMessage(sender, "Dir fehl" + (requiredXp - xp == 1 ? "t" : "en")
                + " noch " + (requiredXp - xp) + " Quest-XP zum nächsten Level.");
        ChatAndTextUtil.sendNormalMessage(sender, "Du hast " + 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)";
    }
    
}

@@ -206,24 +206,58 @@
 util.List;%0D%0A
+import org.bukkit.OfflinePlayer;%0D%0A
 import org.b
@@ -582,24 +582,31 @@
   %0D%0A        
+Offline
 Player playe
@@ -610,455 +610,1368 @@
 ayer
- = (Player) sender;%0D%0A        PlayerData data = CubeQuest.getInstance().getPlayerData(player);%0D%0A        %0D%0A        int level = data.getLevel();%0D%0A        int xp = data.getXp();%0D%0A        int requiredXp = PlayerData.getXpRequiredForLevel(level + 1);%0D%0A        %0D%0A        ChatAndTextUtil.sendNormalMessage(sender,%0D%0A                %22Du hast %22 + xp + %22 Quest-XP und damit Level %22 + level + %22.%22);%0D%0A        ChatAndTextUtil.sendNormalMessage(sender, %22Dir fehl%22
+;%0D%0A        if (args.hasNext()) %7B%0D%0A            String playerName = args.next();%0D%0A            player = CubeQuest.getInstance().getPlayerUUIDCache().getPlayer(playerName);%0D%0A            %0D%0A            if (player == null) %7B%0D%0A                ChatAndTextUtil.sendWarningMessage(sender,%0D%0A                        %22Spieler %22 + playerName + %22 nicht gefunden.%22);%0D%0A                return true;%0D%0A            %7D%0D%0A        %7D else if (!(sender instanceof Player)) %7B%0D%0A            ChatAndTextUtil.sendErrorMessage(sender, %22Diesen Befehl k%C3%B6nnen nur Spieler ausf%C3%BChren!%22);%0D%0A            return true;%0D%0A        %7D else %7B%0D%0A            player = (Player) sender;%0D%0A        %7D%0D%0A        %0D%0A        PlayerData data = CubeQuest.getInstance().getPlayerData(player);%0D%0A        %0D%0A        int level = data.getLevel();%0D%0A        int xp = data.getXp();%0D%0A        int requiredXp = PlayerData.getXpRequiredForLevel(level + 1);%0D%0A        %0D%0A        ChatAndTextUtil.sendNormalMessage(sender,%0D%0A                (sender == player ? %22Du hast %22 : (player.getName() + %22 hat %22)) + xp%0D%0A                        + %22 Quest-XP und damit Level %22 + level + %22.%22);%0D%0A        %0D%0A        if (player == sender %7C%7C sender.hasPermission(CubeQuest.SEE_PLAYER_INFO_PERMISSION)) %7B%0D%0A            ChatAndTextUtil.sendNormalMessage(sender,%0D%0A                    (player == sender ? %22Dir%22 : player.getName()) + %22 fehl%22%0D%0A                           
  + (
@@ -2004,33 +2004,16 @@
  : %22en%22)
-%0D%0A               
  + %22 noc
@@ -2035,16 +2035,45 @@
 Xp - xp)
+%0D%0A                           
  + %22 Que
@@ -2102,32 +2102,36 @@
 el.%22);%0D%0A        
+    
 ChatAndTextUtil.
@@ -2159,77 +2159,191 @@
 der,
- %22Du hast %22 + data.getQuestPoints()%0D%0A                + %22 Quest-Punkt%22
+%0D%0A                    (sender == player ? %22Du hast %22 : (player.getName() + %22 hat %22))%0D%0A                            + data.getQuestPoints() + %22 Quest-Punkt%22%0D%0A                           
  + (
@@ -2382,32 +2382,43 @@
 : %22e%22) + %22.%22);%0D%0A
+        %7D%0D%0A
         %0D%0A      

Allow level lookup for other players.