Uploaded image for project: 'Spigot'
  1. Spigot
  2. SPIGOT-5554

BossBar returns nullpointer when value is not null

XMLWordPrintable

    • Icon: Bug Bug
    • Resolution: Fixed
    • Icon: Minor Minor
    • None
    • None
    • Windows environment.  Server setup via buildtools, localhost.

    • Spigot 1.15.1
    • CraftBukkit
    • Yes

      Strange NullPointerException being encountered, but participating objects are NOT null. This can be verified via the log & code files provided. Basically, I create a new Bossbar. When a player logs in, I add them to this Bossbar. However, on the .addPlayer(Player p) method is when the NullPointer gets thrown.

       

      This makes no sense, as I know for a fact that all participating objects are not null. I also updated to the latest spigot version & latest build tool versions.

       

      The code:

       

      @Override
      @EventHandler
      public void playerLogin(PlayerLoginEvent event) { 
          Player p = event.getPlayer();
          NationPlayer newPlayer = new NationPlayer(p);         Statics.getPlayerMap().put(newPlayer.getBukkitPlayer().getUniqueId(), newPlayer); 
      System.out.println("getServerBar() returns: " + Statics.getServerBar()); System.out.println(p + " is the value of the bukkit player"); 
      
      BossBar bar = Bukkit.createBossBar(ChatColor.YELLOW + "Nations at War", BarColor.RED, BarStyle.SOLID); System.out.println(p.getUniqueId() + " is the uuid of the player!");
      bar.addPlayer(p);//null every time. p is not null!
      Statics.setServerBar(bar);
      }
      

      I have tested and retested 500 times, but everything points to the add() method, and I know with certainty that the passed values are not null.

       

       

            Unassigned Unassigned
            Maklegend Matthew Arnold
            Votes:
            0 Vote for this issue
            Watchers:
            2 Start watching this issue

              Created:
              Updated:
              Resolved: