From 051ed97668829bfde3d9e08403bbdc92b764e241 Mon Sep 17 00:00:00 2001 From: MrHua269 Date: Mon, 19 Aug 2024 10:14:42 +0800 Subject: [PATCH] Use LogUtils in tpsbar and membar --- patches/server/0009-Add-a-simple-tpsbar.patch | 17 ++++++++--------- patches/server/0010-Add-a-simple-membar.patch | 14 +++++++------- ...-API-and-display-of-chunkhot-in-tpsbar.patch | 8 ++++---- 3 files changed, 19 insertions(+), 20 deletions(-) diff --git a/patches/server/0009-Add-a-simple-tpsbar.patch b/patches/server/0009-Add-a-simple-tpsbar.patch index f214600..9c641a7 100644 --- a/patches/server/0009-Add-a-simple-tpsbar.patch +++ b/patches/server/0009-Add-a-simple-tpsbar.patch @@ -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; @@ -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 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(); @@ -159,7 +158,7 @@ index 0000000000000000000000000000000000000000..e456c54b4ac3906a0a0310bdfba5ef39 + try { + update(); + }catch (Exception e){ -+ logger.error(e); ++ logger.error(e.getLocalizedMessage()); + } + },1,TpsBarConfig.updateInterval); + } @@ -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 @@ -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 { diff --git a/patches/server/0010-Add-a-simple-membar.patch b/patches/server/0010-Add-a-simple-membar.patch index 3aba254..a887c6c 100644 --- a/patches/server/0010-Add-a-simple-membar.patch +++ b/patches/server/0010-Add-a-simple-membar.patch @@ -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; @@ -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; @@ -147,7 +147,7 @@ index 0000000000000000000000000000000000000000..8c98e26667465d2976751b01d5e0bb14 + protected static final NullPlugin NULL_PLUGIN = new NullPlugin(); + protected static final Map 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(); @@ -157,7 +157,7 @@ index 0000000000000000000000000000000000000000..8c98e26667465d2976751b01d5e0bb14 + try { + update(); + }catch (Exception e){ -+ logger.error(e); ++ logger.error(e.getLocalizedMessage()); + } + },1, MembarConfig.updateInterval); + } @@ -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 @@ -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 { diff --git a/patches/server/0053-KioCG-Chunk-API-and-display-of-chunkhot-in-tpsbar.patch b/patches/server/0053-KioCG-Chunk-API-and-display-of-chunkhot-in-tpsbar.patch index 9a90397..9988ad3 100644 --- a/patches/server/0053-KioCG-Chunk-API-and-display-of-chunkhot-in-tpsbar.patch +++ b/patches/server/0053-KioCG-Chunk-API-and-display-of-chunkhot-in-tpsbar.patch @@ -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)), @@ -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))); } @@ -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