Solved scoreboard negative values

Discussion in 'Spigot Plugin Development' started by Nighterance, May 4, 2017.

  1. You can look into the API's code, check where it's possibly doing negative values, and change them ;)
     
  2. I was searching first time but didnt see that, found :D

    Oh, and one more thing, got any idea why my scoreboard is not working with player join event?



    @EventHandler
    public void joinevent(PlayerJoinEvent e){
    Player p = e.getPlayer();
    ScoreboardWrapper sc_wrapper = new ScoreboardWrapper(ChatColor.AQUA + "Player Board");
    sc_wrapper.addLine(ChatColor.AQUA + "1");
    sc_wrapper.addLine(ChatColor.GREEN + "1");
    sc_wrapper.addBlankSpace();
    sc_wrapper.addLine(ChatColor.AQUA + "2");
    sc_wrapper.addLine(ChatColor.GREEN + "2");
    sc_wrapper.addBlankSpace();
    sc_wrapper.addLine("No Group");
    sc_wrapper.addLine(ChatColor.GREEN + "3");
    sc_wrapper.addBlankSpace();
    sc_wrapper.addLine(ChatColor.AQUA + p.getName());
    sc_wrapper.addLine(ChatColor.GREEN + "4");
    p.setScoreboard(sc_wrapper.getScoreboard());
    }

    It works, for example, with other event, as levelchange but not join event. Any idea why?
     
    #3 Nighterance, May 4, 2017
    Last edited: May 4, 2017
  3. Are you registering the event ? :)
     
  4. Yes, I am.
    I made it sendmessage to player when he joins to test it.

    I tryed 2 different things 1) Add that whole bunch of code to xpchange event to test out 2) added it as new launch() and then executed it when joining, but nothing happened.
     
  5. Do you have any other plugins that may be overriding the scoreboard?
     
  6. No, but thats not about that.

    The thing is that scoreboard is working if I launch it with command or other eventhandler(xpchange), but it does not launch with playerjoinevent(altough the event it self triggers)
     
  7. I use that API as well, it's quite useful. The reason that the values are negative is because for the method addLine to work it needs to invert the scores. Else you could just not use the API and you wouldn't have that issue, but it's not a big deal.

    Edit: This is from memory though I may be wrong :p, but I remember having a look at the API thinking the same thing, wondering how to make values not negative, but that's the conclusion I believe I came up with

    Sent from my iPhone using Tapatalk
     
  8. I already made it positive long time ago, if you would have read, I have a problem with that its not beeing launched from playerjoinevent.
     
  9. Try delaying it by a tick (Wrap it in a scheduler)
     
  10. Yes, Thank you!