| HELP | Working with ScoreBoards

Discussion in 'Plugin Development' started by CaLxCyMru, Aug 13, 2013.

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

    CaLxCyMru

    Hello there, I am trying to make a plugin that when a player kills someone, It adds a number to a scoreboard variable
    Here is my code:
    Code:java
    1.  
    2. @EventHandler
    3. public void killStreakTHREE(PlayerDeathEvent event){
    4. ScoreboardManager manager = Bukkit.getScoreboardManager();
    5. Scoreboard board = manager.getNewScoreboard();
    6. Objective streak = board.registerNewObjective("killStreak", "PlayerKillCount");
    7. Player player = event.getEntity();
    8. Player killer = player.getKiller();
    9. if(killer instanceof Player){
    10. Score killerS = streak.getScore(killer);
    11. int kills = killerS.getScore();
    12. int add = 1;
    13. int killsTotal = kills+add;
    14. killerS.setScore(killsTotal);
    15. killer.sendMessage(ChatColor.BLUE + "You are on a kill streak of " + ChatColor.GREEN + killsTotal +"" + ChatColor.BLUE + "!");
    16. killer.setScoreboard(board);
    17. }
    18. }


    If someone can help me in anyway I will be very thankful.

    Question - Should I use a different event? Maybe that would be the problem?
     
  2. Offline

    Shinxs


    you create a new scoreboard every time someone dies so you should make it in another class or in a method that only be called once
     
  3. Offline

    CaLxCyMru

    Okay. So how can I make it create this, It is possible to create the Scoreboared on join? or onEnabe()? If so could you show a example if possible?
     
  4. Offline

    Shinxs

    you should make a method in the main class and do it in that and call it from the onenable and create a variable for it and the on join set teh scoreboard of too the player like player.setscoreboard(scoreboard);
     
  5. Offline

    CaLxCyMru

    How do I call from the onEnable() I have never had to use this method before.

    I apologize if I seem like a noob :p
     
  6. Offline

    Shinxs

    make a method with a name like createScoreboard and from the onEnable call createScoreboard by doing createScoreboard();
     
  7. Offline

    CaLxCyMru

    So I use make the method in Streak.Class and then use createScoreboard() in the Main.class onEnable?
     
  8. Offline

    Shinxs

    thats a way to do it yea
     
  9. Offline

    CaLxCyMru

    Can you please show a example of this please because I do not understand how to do it.

    Sorry if im being a noob.
     
Thread Status:
Not open for further replies.

Share This Page