Solved Removing Score From Scoreboard

Discussion in 'Plugin Development' started by ItsMees, Nov 27, 2013.

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

    ItsMees

    Hi GUys,
    I'm working on an project but I have an problem!
    I want it to make that score from an scoreboard get removed from the thirt line of an sign!
    Exaple: I got 1000 score and I right click the sign with 800. 800 will removed from my score so now my score is 200!
    End
    But I did it wrong every time the score will set to: -800!
    I hope someone can help me out!
    My code:
    Code:
    Score score = Bukkit.getScoreboardManager().getMainScoreboard().getObjective("C-Shop").getScore(player);
    score.setScore(- + Integer.parseInt(((Sign) block.getState()).getLine(1)));
    I hope someone can help me out!
    Bye!
     
  2. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı

    Code:java
    1. score.setScore(- + Integer.parseInt(((Sign) block.getState()).getLine(1)));


    What if the first line of the sign doesn't parse and throws an exception?

    Why on earth did you write - + number?
     
  3. Offline

    ItsMees

    I don't no but can you give me the right code to remove an amout from an scoreboard score?
     
  4. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı

    Get the score, set the score to the score minus the amount you'd like to remove.
     
  5. Offline

    ItsMees

    What do you mean? I want it to make that the amout on the 1st line of the sign gets removed from your score!
     
  6. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı

    Set the score to the current score minus that value.
     
  7. Offline

    ItsMees

    Like this:
    Code:java
    1. score.setScore(score.getScore() - Integer.parseInt(((Sign) block.getState()).getLine(1)));
     
  8. Offline

    mbaxter ʇıʞʞnq ɐ sɐɥ ı

    Yup! Except you really should watch out for the NumberFormatException ;)
     
  9. Offline

    ItsMees

    Ok thanks!
     
Thread Status:
Not open for further replies.

Share This Page