Scoreboard help

Discussion in 'Plugin Development' started by thecreator153, May 20, 2014.

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

    thecreator153

    Hey, fellow developers! I decided after 5 days of me being stubborn and refusing to ask for help, that maybe help was the way to go. I need to create a simple scoreboard stats plugin for a private server, on 1.7.9. Now usually, for custom scoreboard scores, i would do this:
    Code:java
    1. k.getScore(Bukkit.getOfflinePlayer("Kills:")).setScore(5);

    But in Bukkit 1.7.9, this is deprecated. I've tried using the other method:
    Code:java
    1. k.getScore("Kills:").setScore(5);

    which takes a String entry as a parameter. However, if i try the above, I get a NoSuchMethodError in my server console. I just can't figure out the way to do scoreboards ever since Player UUIDs were implemented, and any help would be appreciated. What I'm mostly struggling with is the String entry parameter. The JavaDocs say that this parameter is
    but ican't quite figure out what an entry is. ANY help at all will be appreciated, and thanks for taking your time to listen to me ramble.
     
  2. Offline

    mrkirby153

    thecreator153

    First of all, wrong section. Second of all, any method involving the player's name is deprecated to raise awareness that you should be using UUIDs whenever possible. As per this article, when 1.8 comes around, those will be undeprecated.

    In short, the deprecated methods involving the player's name will still be there even though they are deprecated
     
  3. thecreator153 Are you sure that you're running a version of craftbukkit that has that update?
     
  4. Offline

    fireblast709

    mrkirby153 last time I checked this was the development section, so I don't see how a development question is not supposed to be here
    thecreator153 an entry is simply the score name, your implementation seems correct to me, most likely the server is outdated as AdamQpzm suggested
     
  5. Offline

    mrkirby153

    fireblast709

    That was originally in the Bukkit help section. It was moved there.

    Also fireblast709 AdamQpzm thecreator153 Scoreboard.getScore(Bukkit.getOfflinePlayer()); will still be available after the 1.8 update and undepercated. Just USE THEM FOR NOW and if it really bugs you
    Code:java
    1. @SuppressWarnings("deprecation")
    will solve your problem.

    Reference
     
  6. Offline

    fireblast709

    mrkirby153 Objective.getScore(String) is not even deprecated. In fact, it is more efficient than using OfflinePlayer (which in the worst case can block the main thread)
     
  7. Offline

    xTigerRebornx

  8. Offline

    metalhedd

    line 1281:

    Code:java
    1.  
    2. OfflinePlayer result = getPlayerExact(name);
    3. if (result == null) {
    4. // This is potentially blocking :(
    5. GameProfile profile = MinecraftServer.getServer().getUserCache().a(name);
    6.  
     
  9. Offline

    xTigerRebornx

    metalhedd
    Line 1276:
    Code:
    // If the name given cannot ever be a valid username give a dummy return, for scoreboard plugins
            if (!validUserPattern.matcher(name).matches()) {
                return new CraftOfflinePlayer(this, new GameProfile(invalidUserUUID, name));
            }
     
  10. Offline

    metalhedd

    "Kills:" is fine in this case, but there are a lot of things you might want to put on a scoreboard that would also qualify as 'valid' player names. like: "____________" or "PLAYERS" or "123456789"
     
  11. Offline

    xTigerRebornx

    metalhedd Yeah, its valid in this case (I misread worse case as this case), I could see it blocking if a valid username was passed (but generally this won't happen when using OfflinePlayer for a scoreboard, unless your scoreboard is just extremely bland)
     
  12. mrkirby153 I didn't say it wouldn't work, I just said that he probably isn't running the same version.
     
  13. Offline

    mrkirby153

    AdamQpzm

    Oh, I see now :D
    thecreator153 Update the server to Bukkit 1.7.9-R0.2-SNAPSHOT. :D Completely glossed over the other getScore method in the javadocs
     
Thread Status:
Not open for further replies.

Share This Page