Solved Array List in Abstract Class uneditable

Discussion in 'Plugin Development' started by AlfieJay, Mar 25, 2020.

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


    So I've been working on a plugin, this specific part of it stores players who have joined and lets you view the players who are currently playing by storing them in an ArrayList<Player>. Below is the code and the error message I get from the playerjoin command. Thanks for any help you're able to give :D

        public void playerjoinCommand(Player p) {
            if (p.hasPermission("timereapers.join")) {
                if (data.gameOpenBOO) {
                    if (!(data.playerLST.contains(p))) {
                        p.sendMessage(config.pluginTag + "You have successfully joined the game!");
                    } else p.sendMessage(config.pluginTag + "It appears you have already joined the game!");
                } else p.sendMessage(config.pluginTag + "The game is not currently open to join!");
            } else p.sendMessage(config.nopermsMSG);
        public void listplayersCommand(Player p) {
            if (p.hasPermission("timereapers.listplayers")) {
                if (!(data.playerLST.isEmpty())) {
                    p.sendMessage(config.pluginTag + "The following players are in the game:");
                    for (Player x : data.playerLST) {
                        p.sendMessage(ChatColor.GRAY + "- " + x);
                } else p.sendMessage(config.pluginTag + "It appears there aren't any players!");
            } else p.sendMessage(config.nopermsMSG);
    public abstract class data {
        static ArrayList<Player> playerLST = null;
        static Boolean gameOpenBOO = true;
    Error message:

    [19:38:00 ERROR]: null
    org.bukkit.command.CommandException: Unhandled exception executing command 'tr' in plugin TimeReapers v1.0
        at org.bukkit.command.PluginCommand.execute( ~[Paper-1.12.2-b1574.jar:git-Paper-1574]
        at org.bukkit.command.SimpleCommandMap.dispatch( ~[Paper-1.12.2-b1574.jar:git-Paper-1574]
        at org.bukkit.craftbukkit.v1_12_R1.CraftServer.dispatchCommand( ~[Paper-1.12.2-b1574.jar:git-Paper-1574]
        at net.minecraft.server.v1_12_R1.PlayerConnection.handleCommand( ~[Paper-1.12.2-b1574.jar:git-Paper-1574]
        at net.minecraft.server.v1_12_R1.PlayerConnection.a( ~[Paper-1.12.2-b1574.jar:git-Paper-1574]
        at net.minecraft.server.v1_12_R1.PacketPlayInChat.a( ~[Paper-1.12.2-b1574.jar:git-Paper-1574]
        at net.minecraft.server.v1_12_R1.PacketPlayInChat.a( ~[Paper-1.12.2-b1574.jar:git-Paper-1574]
        at net.minecraft.server.v1_12_R1.PlayerConnectionUtils.lambda$ensureMainThread$0( ~[Paper-1.12.2-b1574.jar:git-Paper-1574]
        at java.util.concurrent.Executors$ ~[?:?]
        at ~[?:?]
        at net.minecraft.server.v1_12_R1.SystemUtils.a(SourceFile:46) ~[Paper-1.12.2-b1574.jar:git-Paper-1574]
        at net.minecraft.server.v1_12_R1.MinecraftServer.D( ~[Paper-1.12.2-b1574.jar:git-Paper-1574]
        at net.minecraft.server.v1_12_R1.DedicatedServer.D( ~[Paper-1.12.2-b1574.jar:git-Paper-1574]
        at net.minecraft.server.v1_12_R1.MinecraftServer.C( ~[Paper-1.12.2-b1574.jar:git-Paper-1574]
        at ~[Paper-1.12.2-b1574.jar:git-Paper-1574]
        at [?:?]
    Caused by: java.lang.NullPointerException
        at jay.plugin.timereapers.main.playerjoinCommand( ~[?:?]
        at jay.plugin.timereapers.main.onCommand( ~[?:?]
        at org.bukkit.command.PluginCommand.execute( ~[Paper-1.12.2-b1574.jar:git-Paper-1574]
        ... 15 more
  2. Offline

    timtower Moderator Moderator

  3. Offline


    Oooh, that fixed it. Thanks :D
Thread Status:
Not open for further replies.

Share This Page