I need help with a scoreboard fast!

Discussion in 'Spigot Plugin Development' started by Bjarge, May 30, 2018.

  1. Hey, so I have till 7 to finish this plugin because then I'm leaving for Washington D.C and I'm working on almost no sleep so I need help here.

    I'm using a scoreboardAPI and getting this error:
    Code (Text):
    [15:48:22 ERROR]: Could not pass event PlayerJoinEvent to Hub v1.6.7
    org.bukkit.event.EventException
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:297) ~[Server.jar:git-PaperSpigot-a925999]
            at org.bukkit.plugin.RegisteredListener.callEvent(RegisteredListener.java:62) ~[Server.jar:git-PaperSpigot-a925999]
            at org.bukkit.plugin.SimplePluginManager.fireEvent(SimplePluginManager.java:513) [Server.jar:git-PaperSpigot-a925999]
            at org.bukkit.plugin.SimplePluginManager.callEvent(SimplePluginManager.java:498) [Server.jar:git-PaperSpigot-a925999]
            at net.minecraft.server.v1_7_R4.PlayerList.c(PlayerList.java:305) [Server.jar:git-PaperSpigot-a925999]
            at net.minecraft.server.v1_7_R4.PlayerList.a(PlayerList.java:192) [Server.jar:git-PaperSpigot-a925999]
            at net.minecraft.server.v1_7_R4.LoginListener.c(LoginListener.java:119) [Server.jar:git-PaperSpigot-a925999]
            at net.minecraft.server.v1_7_R4.LoginListener.a(LoginListener.java:44) [Server.jar:git-PaperSpigot-a925999]
            at net.minecraft.server.v1_7_R4.NetworkManager.a(NetworkManager.java:192) [Server.jar:git-PaperSpigot-a925999]
            at net.minecraft.server.v1_7_R4.ServerConnection.c(ServerConnection.java:103) [Server.jar:git-PaperSpigot-a925999]
            at net.minecraft.server.v1_7_R4.MinecraftServer.v(MinecraftServer.java:801) [Server.jar:git-PaperSpigot-a925999]
            at net.minecraft.server.v1_7_R4.DedicatedServer.v(DedicatedServer.java:286) [Server.jar:git-PaperSpigot-a925999]
            at net.minecraft.server.v1_7_R4.MinecraftServer.u(MinecraftServer.java:651) [Server.jar:git-PaperSpigot-a925999]
            at net.minecraft.server.v1_7_R4.MinecraftServer.run(MinecraftServer.java:557) [Server.jar:git-PaperSpigot-a925999]
            at net.minecraft.server.v1_7_R4.ThreadServerApplication.run(SourceFile:628) [Server.jar:git-PaperSpigot-a925999]
    Caused by: java.lang.NullPointerException
            at site.solenxia.scoreboard.Sc.getTitle(Sc.java:26) ~[?:?]
            at site.solenxia.scoreboard.PlayerScoreboard.update(PlayerScoreboard.java:37) ~[?:?]
            at site.solenxia.scoreboard.PlayerScoreboard.<init>(PlayerScoreboard.java:29) ~[?:?]
            at site.solenxia.scoreboard.ScoreboardManager.onJoin(ScoreboardManager.java:35) ~[?:?]
            at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:1.8.0_171]
            at sun.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_171]
            at sun.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:1.8.0_171]
            at java.lang.reflect.Method.invoke(Unknown Source) ~[?:1.8.0_171]
            at org.bukkit.plugin.java.JavaPluginLoader$1.execute(JavaPluginLoader.java:293) ~[Server.jar:git-PaperSpigot-a925999]
            ... 14 more
    Here is the class Sc:
    Code (Text):
    package site.solenxia.scoreboard;

    import java.util.ArrayList;
    import java.util.List;

    import org.bukkit.ChatColor;
    import org.bukkit.craftbukkit.v1_8_R3.entity.CraftPlayer;
    import org.bukkit.entity.Player;

    import me.signatured.ezqueuespigot.EzQueueAPI;
    import site.solenxia.Hub;

    public class Sc implements ScoreboardProvider {
       
        private Hub plugin = Hub.getInstance();
       
        public Sc() {
            this.plugin = plugin;
        }
       
        private ScoreboardWrapper wrapper;
       
        @Override
        public String getTitle(Player player) {
            return ChatColor.translateAlternateColorCodes('&',
                    this.plugin.getConfig().getString("SCOREBOARD_TITLE"));
        }
           
        @Override
        public List<String> getLines(Player player) {
            List<String> lines = new ArrayList<>();
            for (String string : this.plugin.getConfig().getStringList("SCOREBOARD_LINES")) {
                if (string.contains("%queue%") || string.contains("%queue_position%") || string.contains("%queue_size%")) {
                    if (EzQueueAPI.getQueue(player) != null) {
                        lines.add(ChatColor.translateAlternateColorCodes('&', string)
                                .replace("%line%",
                                        ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + "-----------------------")
                                .replace("%rank%", Hub.getInstance().getPermissions().getPrimaryGroup(player))
                                .replace("%online%", String.valueOf(this.plugin.getOnlineCount("ALL")))
                                .replace("%queue%", EzQueueAPI.getQueue(player))
                                .replace("%queue_position%", String.valueOf(EzQueueAPI.getPosition(player)))
                                .replace("%queue_size%",
                                        String.valueOf(EzQueueAPI.getQueueSize(EzQueueAPI.getQueue(player))))
                                .replace("%ping%", Integer.toString(((CraftPlayer) player).getHandle().ping)));
                        if (string.contains("%queue_size%")) {
                            lines.add("");
                        }
                    }
                } else {
                    lines.add(ChatColor.translateAlternateColorCodes('&', string)
                            .replace("%line%",
                                    ChatColor.GRAY.toString() + ChatColor.STRIKETHROUGH + "-----------------------")
                            .replace("%rank%", Hub.getInstance().getPermissions().getPrimaryGroup(player))
                            .replace("%online%", String.valueOf(this.plugin.getOnlineCount("ALL"))));
    }
            }
            return lines;
        }
    }

    If you need any other info, just tell me. Thanks!
     
  2. Caused by: java.lang.NullPointerException
    at site.solenxia.scoreboard.Sc.getTitle(Sc.java:26)

    this.plugin.getConfig().getString("SCOREBOARD_TITLE"));
     
  3. this.plugin.getConfig().getString("SCOREBOARD_TITLE"));

    Something here is null.
    Broadcast each part and see if its null.

    Probs be the config.. Paste your config.
     
  4. I know but it should be reading the config. I'll send you the scoreboard part.
    Code (Text):
    SCOREBOARD_TITLE: '&6&lSolenxia Site'
    SCOREBOARD_LINES:
      - '%line%'
      - '&6&lOnline Players'
      - '%online%'
      - ''
      - '&6&lCurrent Rank'
      - '%rank%'
      - ''
      - '&e&l%queue% Information'
      - '&f%queue_position% out of %queue_size%'
      - '&9discord.solenxia.site'
      - '%line%'
     
     
  5. Try this
    Make this this.plugin.getConfig().getString("SCOREBOARD_TITLE"));

    Like this in your IDE
    this.
    plugin.
    getConfig().
    getString("SCOREBOARD_TITLE"));

    And make the error again.. Should point to a more accurate line number.
     
    • Agree Agree x 1
  6. Alrighty, just did it. The error is grabbing the config.
     
    • Winner Winner x 1
  7. Any idea to what could cause this?
     
  8. Do you have the updated error ?
     
  9. Then, plugin is equal to null, be sure to set it
     
  10. It's the same error.