Skip to content

Commit

Permalink
Fix and optimize tpsbar
Browse files Browse the repository at this point in the history
  • Loading branch information
MrHua269 committed Nov 29, 2023
1 parent 5619ee8 commit bad6740
Showing 1 changed file with 12 additions and 8 deletions.
20 changes: 12 additions & 8 deletions patches/server/0015-Add-a-simple-tpsbar.patch
Original file line number Diff line number Diff line change
Expand Up @@ -109,10 +109,10 @@ index 0000000000000000000000000000000000000000..3f74f748501d2f915869e9077dd2f220
+}
diff --git a/src/main/java/me/earthme/luminol/functions/GlobalServerTpsBar.java b/src/main/java/me/earthme/luminol/functions/GlobalServerTpsBar.java
new file mode 100644
index 0000000000000000000000000000000000000000..98505b8ba09b93534eaa1b400d0c244ecb66e0ea
index 0000000000000000000000000000000000000000..6a9919d8aec5e49df0dd13380cc7d8792ef7b228
--- /dev/null
+++ b/src/main/java/me/earthme/luminol/functions/GlobalServerTpsBar.java
@@ -0,0 +1,206 @@
@@ -0,0 +1,210 @@
+package me.earthme.luminol.functions;
+
+import com.google.common.collect.Lists;
Expand Down Expand Up @@ -186,11 +186,9 @@ index 0000000000000000000000000000000000000000..98505b8ba09b93534eaa1b400d0c244e
+ final UUID uuid = bossBarEntry.getKey();
+ boolean shouldRemove = true;
+
+ for (Player player : Bukkit.getOnlinePlayers()){
+ if (player.getUniqueId() == uuid){
+ shouldRemove = !isPlayerVisible(player);
+ break;
+ }
+ final Player target = Bukkit.getPlayer(uuid);
+ if (target != null){
+ shouldRemove = !isPlayerVisible(target);
+ }
+
+ if (shouldRemove){
Expand All @@ -199,7 +197,13 @@ index 0000000000000000000000000000000000000000..98505b8ba09b93534eaa1b400d0c244e
+ }
+
+ for (UUID uuid : toRemove){
+ uuid2Bossbars.remove(uuid);
+ final BossBar removed = uuid2Bossbars.remove(uuid);
+ if (removed != null){
+ final Player targetPlayer = Bukkit.getPlayer(uuid);
+ if (targetPlayer != null){
+ targetPlayer.showBossBar(removed);
+ }
+ }
+ }
+ }
+
Expand Down

0 comments on commit bad6740

Please sign in to comment.