[TUTORIAL] How to create a scoreboard?

Discussion in 'Spigot Discussion' started by Whirss, Oct 15, 2016.

  1. Step 1: Create a class called "SimpleScoreboard"
    Step 2: Add the following


    Step 3: Go to your class or create main class
    Step 4: and here I leave an example




        1. @EventHandler
        2. public void OnJoin(PlayerJoinEvent e) {
        3. Main.sendScoreboard(e.getPlayer());
        4. new BukkitRunnable() {
        5. public void run() {
        6. if(e.getPlayer().isOnline()) {
        7. Main.sendScoreboard(e.getPlayer());
        8. } else {
        9. cancel();
        10. }
        11. }
        12. }.runTaskTimer(instance, 100L, 100L);
        13. }
        14. @SuppressWarnings("deprecation")
        15. public static void sendScoreboard(Player p) {
        16. SimpleScoreboard board = new SimpleScoreboard("§a§lSKYWARS");
        17. board.blankLine();
        18. board.add("§ePlayers Online: §a" + Bukkit.getOnlinePlayers().size() + "§7/" + Bukkit.getMaxPlayers());
        19. board.add("§eName: §a" + p.getName());
        20. board.add("§ePoints: §aComing Soon");
        21. board.add("§eServer: §a" + Bukkit.getServerName());
        22. board.blankLine();
        23. board.add("play.myserver.net");
        24. board.build();
        25. board.send(p);
        26. }
        27. }

    Step 5: Enjoy the code :D

    If you have any questions add me to skype: chuky0251

    Tutorial in Spanish:

     
    #1 Whirss, Oct 15, 2016
    Last edited: Oct 16, 2016
  2. Can you put the code in 'Code' Tags
     
  3. or upload the code anywhere ?