From 40ed0a2be99631b04dd8db02d073a850d8d22e3f Mon Sep 17 00:00:00 2001 From: CatCoderr Date: Tue, 27 Jun 2023 22:44:11 +0300 Subject: [PATCH] perf: don't update all lines before adding a viewer --- README.md | 2 +- src/main/java/me/catcoder/sidebar/Sidebar.java | 4 ---- 2 files changed, 1 insertion(+), 5 deletions(-) diff --git a/README.md b/README.md index 971136f..ee1e2a3 100644 --- a/README.md +++ b/README.md @@ -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()) diff --git a/src/main/java/me/catcoder/sidebar/Sidebar.java b/src/main/java/me/catcoder/sidebar/Sidebar.java index 4273091..5c57cf1 100644 --- a/src/main/java/me/catcoder/sidebar/Sidebar.java +++ b/src/main/java/me/catcoder/sidebar/Sidebar.java @@ -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 line : lines) { @@ -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); }