Error with Bukkit.getOfflinePlayer()

Discussion in 'Plugin Development' started by KraZ__, Apr 17, 2014.

Thread Status:
Not open for further replies.
  1. Offline

    KraZ__

    So here is my stack trace, It's a modular plugin so I'd prefer not to send code. But here is the method where the error occurs and the stack trace.

    Code:
    7.04 16:01:40 [Server] Startup Done (2.253s)! For help, type "help" or "?"
    17.04 16:01:40 [Server] INFO Server permissions file permissions.yml is empty, ignoring it
    17.04 16:01:40 [Server] INFO Enabling SabreLib v1.0
    17.04 16:01:40 [Server] INFO at net.minecraft.server.v1_7_R3.ThreadServerApplication.run(SourceFile:628) [craftbukkit_dev_3046.jar:git-Bukkit-1.7.2-R0.3-18-g3c3980f-b3046jnks]
    17.04 16:01:40 [Server] INFO at net.minecraft.server.v1_7_R3.MinecraftServer.run(MinecraftServer.java:436) [craftbukkit_dev_3046.jar:git-Bukkit-1.7.2-R0.3-18-g3c3980f-b3046jnks]
    17.04 16:01:40 [Server] INFO at net.minecraft.server.v1_7_R3.DedicatedServer.init(DedicatedServer.java:182) [craftbukkit_dev_3046.jar:git-Bukkit-1.7.2-R0.3-18-g3c3980f-b3046jnks]
    17.04 16:01:40 [Server] INFO at net.minecraft.server.v1_7_R3.MinecraftServer.a(MinecraftServer.java:282) [craftbukkit_dev_3046.jar:git-Bukkit-1.7.2-R0.3-18-g3c3980f-b3046jnks]
    17.04 16:01:40 [Server] INFO at net.minecraft.server.v1_7_R3.MinecraftServer.g(MinecraftServer.java:326) [craftbukkit_dev_3046.jar:git-Bukkit-1.7.2-R0.3-18-g3c3980f-b3046jnks]
    17.04 16:01:40 [Server] INFO at net.minecraft.server.v1_7_R3.MinecraftServer.n(MinecraftServer.java:352) [craftbukkit_dev_3046.jar:git-Bukkit-1.7.2-R0.3-18-g3c3980f-b3046jnks]
    17.04 16:01:40 [Server] INFO at org.bukkit.craftbukkit.v1_7_R3.CraftServer.enablePlugins(CraftServer.java:375) [craftbukkit_dev_3046.jar:git-Bukkit-1.7.2-R0.3-18-g3c3980f-b3046jnks]
    17.04 16:01:40 [Server] INFO at org.bukkit.craftbukkit.v1_7_R3.CraftServer.loadPlugin(CraftServer.java:441) [craftbukkit_dev_3046.jar:git-Bukkit-1.7.2-R0.3-18-g3c3980f-b3046jnks]
    17.04 16:01:40 [Server] INFO at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:404) [craftbukkit_dev_3046.jar:git-Bukkit-1.7.2-R0.3-18-g3c3980f-b3046jnks]
    17.04 16:01:40 [Server] INFO at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:324) [craftbukkit_dev_3046.jar:git-Bukkit-1.7.2-R0.3-18-g3c3980f-b3046jnks]
    17.04 16:01:40 [Server] INFO at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:250) ~[craftbukkit_dev_3046.jar:git-Bukkit-1.7.2-R0.3-18-g3c3980f-b3046jnks]
    17.04 16:01:40 [Server] INFO at com.kieronwiltshire.koth.KingOfTheHill.onEnable(KingOfTheHill.java:45) ~[?:?]
    17.04 16:01:40 [Server] INFO at com.kieronwiltshire.koth.KingOfTheHill.load(KingOfTheHill.java:86) ~[?:?]
    17.04 16:01:40 [Server] INFO at com.kieronwiltshire.koth.KingOfTheHill.generateGameBoard(KingOfTheHill.java:136) ~[?:?]
    17.04 16:01:40 [Server] INFO at com.kieronwiltshire.sabrelib.modules.NotificationModule.<init>(NotificationModule.java:25) ~[?:?]
    17.04 16:01:40 [Server] INFO at com.kieronwiltshire.sabrelib.modules.NotificationModule.update(NotificationModule.java:68) ~[?:?]
    17.04 16:01:40 [Server] INFO at com.kieronwiltshire.sabrelib.modules.ScoreboardModule.createInformationBoard(ScoreboardModule.java:94) ~[?:?]
    17.04 16:01:40 [Server] INFO at org.bukkit.Bukkit.getOfflinePlayer(Bukkit.java:422) ~[craftbukkit_dev_3046.jar:git-Bukkit-1.7.2-R0.3-18-g3c3980f-b3046jnks]
    17.04 16:01:40 [Server] INFO at org.bukkit.craftbukkit.v1_7_R3.CraftServer.getOfflinePlayer(CraftServer.java:1266) ~[craftbukkit_dev_3046.jar:git-Bukkit-1.7.2-R0.3-18-g3c3980f-b3046jnks]
    17.04 16:01:40 [Server] INFO at net.minecraft.server.v1_7_R3.UserCache.a(SourceFile:118) ~[craftbukkit_dev_3046.jar:git-Bukkit-1.7.2-R0.3-18-g3c3980f-b3046jnks]
    17.04 16:01:40 [Server] INFO at net.minecraft.server.v1_7_R3.UserCache.a(SourceFile:59) ~[craftbukkit_dev_3046.jar:git-Bukkit-1.7.2-R0.3-18-g3c3980f-b3046jnks]
    17.04 16:01:40 [Server] INFO at net.minecraft.util.com.mojang.authlib.yggdrasil.YggdrasilGameProfileRepository.findProfilesByNames(YggdrasilGameProfileRepository.java:90) ~[craftbukkit_dev_3046.jar:git-Bukkit-1.7.2-R0.3-18-g3c3980f-b3046jnks]
    17.04 16:01:40 [Server] INFO at net.minecraft.util.com.mojang.authlib.GameProfile.<init>(GameProfile.java:25) ~[craftbukkit_dev_3046.jar:git-Bukkit-1.7.2-R0.3-18-g3c3980f-b3046jnks]
    17.04 16:01:40 [Server] INFO java.lang.IllegalArgumentException: Name and ID cannot both be blank
    17.04 16:01:40 [Server] ERROR Error occurred while enabling KingOfTheHill v1.0 (Is it up to date?)
    
    Code:
    /**
    * Create an information board
    */
    public void createInformationBoard(String name, String[] lines) {
     
    if(sidebar != null)
    sidebar.unregister();
     
    sidebar = board.registerNewObjective(name, "dummy");
    sidebar.setDisplaySlot(DisplaySlot.SIDEBAR);
     
            int spaceCounter = 0;
            for(int i = 0; i < lines.length; i++) {
                String content = lines[i];
                if(content == null || content.equalsIgnoreCase("")) {
                    content = StringUtils.repeat(" ", 16 - spaceCounter);
    92)              spaceCounter++;
    93)          }
    94)      Score line = sidebar.getScore(Bukkit.getOfflinePlayer(content)); //Error occurs here,
    95)      line.setScore(lines.length - i);
    96)      if(i >= 15) {
                    break;
                }
            }
        }
    
     
  2. Offline

    StaticJava

    Could we have the respective line numbers the errors occur at?
     
  3. Offline

    KraZ__

    StaticJava
    I put a comment to where the error occurs.

    bump

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: Jun 7, 2016
  4. Offline

    Jozeth

    Bumping is only allowed every 24 hours.
     
  5. Offline

    HON95

    Code:java
    1. //class net.minecraft.util.com.mojang.authlib.GameProfile
    2. public GameProfile(UUID id, String name)
    3. {
    4. if ((id == null) && (StringUtils.isBlank(name))) throw new IllegalArgumentException("Name and ID cannot both be blank");
    5.  
    6. this.id = id;
    7. this.name = name;
    8. }


    The error «java.lang.IllegalArgumentException: Name and ID cannot both be blank» occurs because the method above doesn't like player names consisting of only spaces. Why are you even doing this (below)?

    Code:java
    1. if(content == null || content.equalsIgnoreCase("")) {
    2. content = StringUtils.repeat(" ", 16 - spaceCounter);
    3. spaceCounter++;
    4. }
    5. Score line = sidebar.getScore(Bukkit.getOfflinePlayer(content));
     
  6. Offline

    KraZ__


    It's to add spaces within the scoreboard, The thing is.. I only recieve these errors on my hosted server, on my pc. No errors, works fine!
     
  7. Offline

    Garris0n

  8. Offline

    KraZ__

  9. Offline

    Garris0n

    Its terrible design is unfortunate, but it's not really something Bukkit can fix. The way Mojang designed it was to be very client-oriented, which sucks for server modders.
     
Thread Status:
Not open for further replies.

Share This Page