From d8fe269327a1a51f2588a3573a4764613da16388 Mon Sep 17 00:00:00 2001 From: Trumeet Date: Tue, 26 Jul 2022 19:06:11 -0700 Subject: Move the mod to mod/ --- .../moe/ymc/acron/mixin/MinecraftServerMixin.java | 33 ++++++++++++++++++++++ 1 file changed, 33 insertions(+) create mode 100644 mod/src/main/java/moe/ymc/acron/mixin/MinecraftServerMixin.java (limited to 'mod/src/main/java/moe/ymc/acron/mixin/MinecraftServerMixin.java') diff --git a/mod/src/main/java/moe/ymc/acron/mixin/MinecraftServerMixin.java b/mod/src/main/java/moe/ymc/acron/mixin/MinecraftServerMixin.java new file mode 100644 index 0000000..cb813b4 --- /dev/null +++ b/mod/src/main/java/moe/ymc/acron/mixin/MinecraftServerMixin.java @@ -0,0 +1,33 @@ +package moe.ymc.acron.mixin; + +import moe.ymc.acron.s2c.EventQueue; +import moe.ymc.acron.s2c.event.EventLagging; +import net.minecraft.server.MinecraftServer; +import org.apache.logging.log4j.LogManager; +import org.apache.logging.log4j.Logger; +import org.spongepowered.asm.mixin.Mixin; +import org.spongepowered.asm.mixin.injection.At; +import org.spongepowered.asm.mixin.injection.Redirect; + +@Mixin(MinecraftServer.class) +public class MinecraftServerMixin { + private static final Logger AC_LOGGER = LogManager.getLogger(); + + @Redirect(method = "runServer()V", + remap = false, + at = @At(value = "INVOKE", + target = "Lorg/apache/logging/log4j/Logger;warn(Ljava/lang/String;Ljava/lang/Object;Ljava/lang/Object;)V")) + private void startServer(Logger instance, String s, Object o1, Object o2) { + instance.warn(s, o1, o2); + if (s.equals("Can't keep up! " + + "Is the server overloaded? " + + "Running {}ms or {} ticks behind") && + o1 instanceof Long && + o2 instanceof Long) { + AC_LOGGER.debug("Lag: {}ms, {} ticks", + o1, + o2); + EventQueue.enqueue(new EventLagging((long) o1, (long) o2)); + } + } +} -- cgit v1.2.3