Skip to content

Commit

Permalink
perf: don't update all lines before adding a viewer
Browse files Browse the repository at this point in the history
  • Loading branch information
CatCoderr committed Jun 27, 2023
1 parent 85c2d5d commit 40ed0a2
Show file tree
Hide file tree
Showing 2 changed files with 1 addition and 5 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,7 @@ sidebar.addLine(
Component.text("Just a static line").color(NamedTextColor.GREEN));
// add an empty line
sidebar.addBlankLine();
// also you can add updatable lines which applies to all players
// also you can add updatable lines which applies to all players receiving this sidebar
sidebar.addUpdatableLine(
player -> Component.text("Your Hunger: ")
.append(Component.text(player.getFoodLevel())
Expand Down
4 changes: 0 additions & 4 deletions src/main/java/me/catcoder/sidebar/Sidebar.java
Original file line number Diff line number Diff line change
Expand Up @@ -392,8 +392,6 @@ public void destroy() {
@SneakyThrows
public void addViewer(@NonNull Player player) {
if (!viewers.contains(player.getUniqueId())) {
updateAllLines();

objective.create(player);

for (SidebarLine<R> line : lines) {
Expand Down Expand Up @@ -421,8 +419,6 @@ public void removeViewer(@NonNull Player player) {
}

private void removeViewer0(@NonNull Player player) {
updateAllLines();

lines.forEach(line -> line.removeTeam(player, objective.getName()));
objective.remove(player);
}
Expand Down

0 comments on commit 40ed0a2

Please sign in to comment.