Jump to content

Recommended Posts

Posted (edited)

Hello, 

I'm trying to retrieve scorboard infos.

Here is what I tried :

public static void getSB() {
        Scoreboard scoreboard = mc.getWorld().getScoreboard();
        if (scoreboard == null) {
            System.out.println("no sb");
            return;
        }


        List<String> sidebarScores = getSidebarScores(scoreboard);
        for (String sidebarScore : sidebarScores) {
            System.out.println(sidebarScores);
        }
	}

public static List<String> getSidebarScores(Scoreboard scoreboard) {
        List<String> found = new ArrayList<>();

        ScoreObjective sidebar = scoreboard.getObjectiveInDisplaySlot(1);
        if (sidebar != null) {
            List<Score> scores = new ArrayList<>(scoreboard.getScores());
            scores.sort(Comparator.comparingInt(Score::getScorePoints));
            
            
            found = scores.stream()
                    .filter(score -> score.getObjective().getName().equals(sidebar.getName()))
                    .map(score -> score.getPlayerName() + getSuffixFromContainingTeam(scoreboard, score.getPlayerName()))
                    .collect(Collectors.toList());

        }
        return found;
    }

    private static String getSuffixFromContainingTeam(Scoreboard scoreboard, String member) {
        String suffix = null;
        for (ScorePlayerTeam team : scoreboard.getTeams()) {
            if (team.getMembershipCollection().contains(member)) {
                suffix = team.getSuffix();
                break;
            }
        }
        return (suffix == null ? "" : suffix);
    }

 

But it only print random info from the scoreboard.

 

I have no idea how to fix this problem

Maybe there is a simpler way, anyone knows how to grab scoreboard infos ?

Edited by McPqndq

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Unfortunately, your content contains terms that we do not allow. Please edit your content to remove the highlighted words below.
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

Announcements



×
×
  • Create New...

Important Information

By using this site, you agree to our Terms of Use.