Need help for a scoreboard !

Discussion in 'Plugin Development' started by xFoundation, Jun 12, 2015.

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

    xFoundation

    Hey everyone,

    Today, i'm developping a new custom minigame bukkit plugin

    I want to create a custom scoreboard with stats (Kills Coins and shot fired)

    That is good now but there are always erros when i code an @EventHandler to add +1.

    I want to add +1 kills to the killer when he kill a HOSTILE mob.

    That is the code :

    Code:
    package fr.hugo.cks;
    
    import java.util.HashMap;
    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.OfflinePlayer;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.scoreboard.DisplaySlot;
    import org.bukkit.scoreboard.Objective;
    import org.bukkit.scoreboard.Score;
    import org.bukkit.scoreboard.Scoreboard;
    
    public class Main extends JavaPlugin implements Listener {
        private Scoreboard board;
        private Objective o;
        @SuppressWarnings("unused")
        private HashMap<OfflinePlayer, Score> kills = new HashMap<OfflinePlayer, Score>();
    
        public void onEnable() {
                Bukkit.getServer().getPluginManager().registerEvents(this, this);
               
                board = Bukkit.getServer().getScoreboardManager().getNewScoreboard();
            
                o = board.registerNewObjective("test", "dummy");
                o.setDisplayName(ChatColor.WHITE + "Stats");
                o.setDisplaySlot(DisplaySlot.SIDEBAR);
              
                Score score = o.getScore(ChatColor.WHITE + "Kills:");
                Score score1 = o.getScore(ChatColor.WHITE + "Coins:");
                Score score11 = o.getScore(ChatColor.WHITE + "Shots:");
                score.setScore(413040);
                score1.setScore(992754);
                score11.setScore(6300161);
        }
              
        @EventHandler
        public void onPlayerJoin(PlayerJoinEvent playerJoinEvent) {
              
            Player eventPlayer = playerJoinEvent.getPlayer();
              
            eventPlayer.setScoreboard(board);
        }
    }
     
  2. Offline

    TomTheDeveloper

    You need a scoreboard register a scoreboard for every player apart... There is also a tutorial on this in the resource section
     
  3. Offline

    xFoundation

    What code i must add and where please ?
     
Thread Status:
Not open for further replies.

Share This Page