Skip to content

Commit

Permalink
Use LogUtils in tpsbar and membar
Browse files Browse the repository at this point in the history
  • Loading branch information
MrHua269 committed Aug 19, 2024
1 parent 4918bb9 commit 051ed97
Show file tree
Hide file tree
Showing 3 changed files with 19 additions and 20 deletions.
17 changes: 8 additions & 9 deletions patches/server/0009-Add-a-simple-tpsbar.patch
Original file line number Diff line number Diff line change
Expand Up @@ -117,12 +117,13 @@ index 0000000000000000000000000000000000000000..aafb2f5052c7c8e5971a47308253badb
+}
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..e456c54b4ac3906a0a0310bdfba5ef39dc02c4ef
index 0000000000000000000000000000000000000000..026807e0851d67c6d57e81f573ac1bf8fedc6109
--- /dev/null
+++ b/src/main/java/me/earthme/luminol/functions/GlobalServerTpsBar.java
@@ -0,0 +1,225 @@
@@ -0,0 +1,224 @@
+package me.earthme.luminol.functions;
+
+import com.mojang.logging.LogUtils;
+import io.papermc.paper.threadedregions.ThreadedRegionizer;
+import io.papermc.paper.threadedregions.TickData;
+import io.papermc.paper.threadedregions.TickRegions;
Expand All @@ -135,21 +136,19 @@ index 0000000000000000000000000000000000000000..e456c54b4ac3906a0a0310bdfba5ef39
+import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
+import net.minecraft.server.level.ServerLevel;
+import net.minecraft.server.level.ServerPlayer;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.bukkit.Bukkit;
+import org.bukkit.craftbukkit.entity.CraftPlayer;
+import org.bukkit.entity.Player;
+import org.jetbrains.annotations.NotNull;
+import org.slf4j.Logger;
+
+import java.util.*;
+import java.util.concurrent.TimeUnit;
+
+public class GlobalServerTpsBar {
+ protected static final NullPlugin NULL_PLUGIN = new NullPlugin();
+ protected static final Map<UUID,BossBar> uuid2Bossbars = new HashMap<>();
+ protected static volatile ScheduledTask tpsbarTask = null;
+ private static final Logger logger = LogManager.getLogger();
+ private static final Logger logger = LogUtils.getLogger();
+
+ public static void init(){
+ cancelBarUpdateTask();
Expand All @@ -159,7 +158,7 @@ index 0000000000000000000000000000000000000000..e456c54b4ac3906a0a0310bdfba5ef39
+ try {
+ update();
+ }catch (Exception e){
+ logger.error(e);
+ logger.error(e.getLocalizedMessage());
+ }
+ },1,TpsBarConfig.updateInterval);
+ }
Expand Down Expand Up @@ -359,7 +358,7 @@ index 0755e8f460f59e2dbc00cac73026bb441c04e9ea..690d0f59daf8c4630c3d70b6fb690c2e
//Util.shutdownExecutors(); // Paper - moved into super
SkullBlockEntity.clear();
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 2480166aa0f7acefc1302bc44bc31b6ad48c0711..466928317a9777318aeb08e38d2bcf4c49de4cd8 100644
index d681ec617590a3718f926cd5a9749952d5ac52bd..d9907ab4161f65328b989cd41564ec34f6ffcb14 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -303,7 +303,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
Expand All @@ -372,7 +371,7 @@ index 2480166aa0f7acefc1302bc44bc31b6ad48c0711..466928317a9777318aeb08e38d2bcf4c
private ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.PlayerChunkLoaderData chunkLoader;
private final ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.ViewDistanceHolder viewDistanceHolder = new ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.ViewDistanceHolder();
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index eb1e14be98b3731e0557726324593dee2eadd31b..e77b7d98f53676010b2b7d91eeab2addaca1241a 100644
index 28c6923c90ca106256ca75769828cd62d5542ca7..dcee0b573f952f2b5c80e9c164724964d42577d8 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -2389,6 +2389,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
Expand Down
14 changes: 7 additions & 7 deletions patches/server/0010-Add-a-simple-membar.patch
Original file line number Diff line number Diff line change
Expand Up @@ -115,12 +115,13 @@ index 0000000000000000000000000000000000000000..b632c4a636974535bf001f010de1dcb6
+}
diff --git a/src/main/java/me/earthme/luminol/functions/GlobalServerMemoryBar.java b/src/main/java/me/earthme/luminol/functions/GlobalServerMemoryBar.java
new file mode 100644
index 0000000000000000000000000000000000000000..8c98e26667465d2976751b01d5e0bb1458e3d996
index 0000000000000000000000000000000000000000..47809d78392fe0cb30ad68ca1c331784f1843269
--- /dev/null
+++ b/src/main/java/me/earthme/luminol/functions/GlobalServerMemoryBar.java
@@ -0,0 +1,186 @@
+package me.earthme.luminol.functions;
+
+import com.mojang.logging.LogUtils;
+import io.papermc.paper.threadedregions.ThreadedRegionizer;
+import io.papermc.paper.threadedregions.TickRegions;
+import io.papermc.paper.threadedregions.scheduler.ScheduledTask;
Expand All @@ -132,12 +133,11 @@ index 0000000000000000000000000000000000000000..8c98e26667465d2976751b01d5e0bb14
+import net.kyori.adventure.text.minimessage.tag.resolver.Placeholder;
+import net.minecraft.server.level.ServerLevel;
+import net.minecraft.server.level.ServerPlayer;
+import org.apache.logging.log4j.LogManager;
+import org.apache.logging.log4j.Logger;
+import org.bukkit.Bukkit;
+import org.bukkit.craftbukkit.entity.CraftPlayer;
+import org.bukkit.entity.Player;
+import org.jetbrains.annotations.NotNull;
+import org.slf4j.Logger;
+
+import java.lang.management.ManagementFactory;
+import java.lang.management.MemoryUsage;
Expand All @@ -147,7 +147,7 @@ index 0000000000000000000000000000000000000000..8c98e26667465d2976751b01d5e0bb14
+ protected static final NullPlugin NULL_PLUGIN = new NullPlugin();
+ protected static final Map<UUID, BossBar> uuid2Bossbars = new HashMap<>();
+ protected static volatile ScheduledTask membarTask = null;
+ private static final Logger logger = LogManager.getLogger();
+ private static final Logger logger = LogUtils.getLogger();
+
+ public static void init(){
+ cancelBarUpdateTask();
Expand All @@ -157,7 +157,7 @@ index 0000000000000000000000000000000000000000..8c98e26667465d2976751b01d5e0bb14
+ try {
+ update();
+ }catch (Exception e){
+ logger.error(e);
+ logger.error(e.getLocalizedMessage());
+ }
+ },1, MembarConfig.updateInterval);
+ }
Expand Down Expand Up @@ -318,7 +318,7 @@ index 690d0f59daf8c4630c3d70b6fb690c2e1cedd402..8bd9baba560051e681277b8cea9d1374
//Util.shutdownExecutors(); // Paper - moved into super
SkullBlockEntity.clear();
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 466928317a9777318aeb08e38d2bcf4c49de4cd8..dc95bd8ed9db016f8d5419f832b11e0b77097c0b 100644
index d9907ab4161f65328b989cd41564ec34f6ffcb14..a737fb8dac485303d2ee7399d4dae8dbbff2f7fe 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -304,6 +304,7 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
Expand All @@ -330,7 +330,7 @@ index 466928317a9777318aeb08e38d2bcf4c49de4cd8..dc95bd8ed9db016f8d5419f832b11e0b
private ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.PlayerChunkLoaderData chunkLoader;
private final ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.ViewDistanceHolder viewDistanceHolder = new ca.spottedleaf.moonrise.patches.chunk_system.player.RegionizedPlayerChunkLoader.ViewDistanceHolder();
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index e77b7d98f53676010b2b7d91eeab2addaca1241a..61683135b0462770cfe93e16fd0d0c1bca13e045 100644
index dcee0b573f952f2b5c80e9c164724964d42577d8..f13128a9e5462ae1047987ad29d35c72f74c5412 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -2392,6 +2392,9 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -132,10 +132,10 @@ index aafb2f5052c7c8e5971a47308253badb3027093c..9fe7ac7ba83bbcc9a2a851a5cace4764
public static int updateInterval = 15;

diff --git a/src/main/java/me/earthme/luminol/functions/GlobalServerTpsBar.java b/src/main/java/me/earthme/luminol/functions/GlobalServerTpsBar.java
index e456c54b4ac3906a0a0310bdfba5ef39dc02c4ef..0c6ae960cc1d1a39f625295f649169d3381f3b2d 100644
index 026807e0851d67c6d57e81f573ac1bf8fedc6109..c45f6bd60d1cf7a915aa6ceea07c0929507b86e2 100644
--- a/src/main/java/me/earthme/luminol/functions/GlobalServerTpsBar.java
+++ b/src/main/java/me/earthme/luminol/functions/GlobalServerTpsBar.java
@@ -139,7 +139,8 @@ public class GlobalServerTpsBar {
@@ -138,7 +138,8 @@ public class GlobalServerTpsBar {
TpsBarConfig.tpsBarFormat,
Placeholder.component("tps",getTpsComponent(tps)),
Placeholder.component("mspt",getMsptComponent(mspt)),
Expand All @@ -145,7 +145,7 @@ index e456c54b4ac3906a0a0310bdfba5ef39dc02c4ef..0c6ae960cc1d1a39f625295f649169d3
));
bar.color(barColorFromTps(tps));
bar.progress((float) Math.min((float)1,Math.max(mspt / 50,0)));
@@ -181,6 +182,32 @@ public class GlobalServerTpsBar {
@@ -180,6 +181,32 @@ public class GlobalServerTpsBar {
return MiniMessage.miniMessage().deserialize(replaced,Placeholder.parsed("text", String.format("%.2f", mspt)));
}

Expand Down Expand Up @@ -272,7 +272,7 @@ index 80123dd30328336b02a5e2e3414ece44ba040ad2..6f4d5312c8140e0a49646e4f069b027a
} else {
passenger.stopRiding();
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 4242fe25e36e45b0a54d3aa7e72fc181728cff74..8c14833675e64548c9c60aa2d07cf5066ba59d3b 100644
index 23541e9c5734334a1cd6e7730288d6dd6028efb0..26fce0d5804db517db08a308abc1cd902060f6ab 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -339,6 +339,26 @@ public class ServerPlayer extends net.minecraft.world.entity.player.Player imple
Expand Down

0 comments on commit 051ed97

Please sign in to comment.