SCOREBOARD!

Discussion in 'Plugin Development' started by Dannyboy3422, Aug 8, 2015.

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

    Dannyboy3422

    Hi!

    I need a plugin to set a SCOREBOARD in the lobby world that shows the number of players playing in each world.

    Something like:

    Server
    Lobby 5
    Hg 14
    PvP 27

    and so on.

    Thanks! :):)
     
  2. Offline

    567legodude

    @Dannyboy3422 I will assume you know how to make a scoreboard.
    Code:
    for (World w : Bukkit.getWorlds()) {
        objective.getScore(w.getName()).setScore(w.getPlayers().size());
    }
     
  3. Offline

    Cycryl

    @567legodude lets not assume here :p
    Code:
    Scoreboard sb = Bukkit.getScoreBoardManager.getNewScoreboard();
    for(Player p : w.getPlayers()){
      p.setScoreboard(sb);
    }
     
  4. Offline

    HenkDeKipGaming

    um i am doing this from my head, so i hope this is good xD
    Code:
    int Lobby = getServer().getWorld("Lobby").getPlayers().size();
    int hg = getServer().getWorld("hg").getPlayers().size();
    int pvp = getServer().getWorld("pvp").getPlayers().size();
    
    public void ScoreBoardUpdate(Player p) {
        ScoreboardManager manager = Bukkit.getScoreboardManager();
        Scoreboard scoreboard = manager.getNewScoreboard();
        Objective obj = scoreboard.registerNewObjective("Board", "dummy");
        obj.setDisplaySlot(DisplaySlot.SIDEBAR);
        obj.setDisplayName("Server");
        Score space = obj.getScore(ChatColor.BLUE + "Lobby: " + ChatColor.RED + pvp);
        space.setScore(3);
        Score space = obj.getScore(ChatColor.BLUE + "hg: + ChatColor.RED + hg");
        space.setScore(2);
        Score space = obj.getScore(ChatColor.BLUE + "pvp: " + ChatColor.RED + Lobby);
        space.setScore(1);
    p.setScoreboard(scoreboard);
    }
    
    //then when a player joins a world, you should do this:
    for(Player p : getServer().getOnlinePlayers()) {
                ScoreBoardUpdate(p);
            }
    
    
    I hope i helped :)
     
    ChipDev likes this.
  5. Offline

    ChipDev

    Sadly, I have never gotten a scoreboard to work.
    Although i work with NMS..
    STEWPED MEH
     
  6. Offline

    HenkDeKipGaming

    haha nice xD
    does it work now?

    ps: ben je nederlands? :D
    translation: are you dutch? :D
     
  7. Offline

    ChipDev

    No
    @HenkDeKipGaming but I know Netherlands would translate into Dutch!
    I'm away crntly, not programming scoreboards lol
     
  8. Offline

    Jakeeeee

    In
    Code:
      Score space = obj.getScore(ChatColor.BLUE + "hg: + ChatColor.RED + hg");
        space.setScore(2);
        Score space = obj.getScore(ChatColor.BLUE + "pvp: " + ChatColor.RED + Lobby);
        space.setScore(1);
    
    I wouldn't repeat a variable and set it as a sore. I would make each new like a different variable...
     
  9. Offline

    HenkDeKipGaming

    oops little mistake xD i did it from my head so yeah xD that scould be:

    Code:
    Score lobby = obj.getScore(ChatColor.BLUE + "lobby: + ChatColor.RED + Lobby");
        lobby.setScore(3);
      Score hg = obj.getScore(ChatColor.BLUE + "hg: + ChatColor.RED + hg");
        hg.setScore(2);
        Score pvp = obj.getScore(ChatColor.BLUE + "pvp: " + ChatColor.RED + pvp);
        pvp.setScore(1);
    
    also i fucky up the names, so i fixed that too
     
Thread Status:
Not open for further replies.

Share This Page