ProtocolLib fix + Implement log player login location & hide player ips
This commit is contained in:
@@ -0,0 +1,95 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Etil <81570777+etil2jz@users.noreply.github.com>
|
||||
Date: Sat, 18 Sep 2021 14:25:19 +0200
|
||||
Subject: [PATCH] (Yatopia) Preload ProtocolLib EnumWrappers
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
index 03315bf6e95145bd91ea0ebfc1c416b76434f5a5..cc4b83b8d8f532fd1015a9259b67de6e34f242d7 100644
|
||||
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
|
||||
@@ -1226,6 +1226,8 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
|
||||
String doneTime = String.format(java.util.Locale.ROOT, "%.3fs", (double) (Util.getNanos() - serverStartTime) / 1.0E9D);
|
||||
LOGGER.info("Done ({})! For help, type \"help\"", doneTime);
|
||||
// Paper end
|
||||
+
|
||||
+ if (xyz.arthurb.mirai.MiraiConfig.fixProtocolLib) xyz.arthurb.mirai.server.util.YatopiaPreloadProtocolLib.run(); // Yatopia - Preload ProtocolLib's Enum Wrappers
|
||||
|
||||
org.spigotmc.WatchdogThread.tick(); // Paper
|
||||
org.spigotmc.WatchdogThread.hasStarted = true; // Paper
|
||||
diff --git a/src/main/java/xyz/arthurb/mirai/MiraiConfig.java b/src/main/java/xyz/arthurb/mirai/MiraiConfig.java
|
||||
index 126d74b4b5964b0a3e3b09abd456d27466242c40..9c55b553418796761554ca32b843a5b2df72e755 100644
|
||||
--- a/src/main/java/xyz/arthurb/mirai/MiraiConfig.java
|
||||
+++ b/src/main/java/xyz/arthurb/mirai/MiraiConfig.java
|
||||
@@ -113,18 +113,11 @@ public class MiraiConfig {
|
||||
num = 0D;
|
||||
}
|
||||
switch (unit) {
|
||||
- case 'd':
|
||||
- num *= (double) 60 * 60 * 24;
|
||||
- break;
|
||||
- case 'h':
|
||||
- num *= (double) 60 * 60;
|
||||
- break;
|
||||
- case 'm':
|
||||
- num *= (double) 60;
|
||||
- break;
|
||||
- default:
|
||||
- case 's':
|
||||
- break;
|
||||
+ case 'd': num *= (double) 60 * 60 * 24;
|
||||
+ case 'h': num *= (double) 60 * 60;
|
||||
+ case 'm': num *= 60;
|
||||
+ case 's': break;
|
||||
+ default: break;
|
||||
}
|
||||
return (int) num;
|
||||
}
|
||||
@@ -199,5 +192,11 @@ public class MiraiConfig {
|
||||
private static void brandName() {
|
||||
brandName = getString("settings.brand-name", brandName);
|
||||
}
|
||||
+
|
||||
+ public static boolean fixProtocolLib = true;
|
||||
+
|
||||
+ private static void protocolLib() {
|
||||
+ fixProtocolLib = getBoolean("settings.fix-protocollib", fixProtocolLib);
|
||||
+ }
|
||||
|
||||
}
|
||||
\ No newline at end of file
|
||||
diff --git a/src/main/java/xyz/arthurb/mirai/server/util/YatopiaPreloadProtocolLib.java b/src/main/java/xyz/arthurb/mirai/server/util/YatopiaPreloadProtocolLib.java
|
||||
new file mode 100644
|
||||
index 0000000000000000000000000000000000000000..3dd76ced1dd4d82d96bbdd448c7d8e194779d44f
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/xyz/arthurb/mirai/server/util/YatopiaPreloadProtocolLib.java
|
||||
@@ -0,0 +1,28 @@
|
||||
+package xyz.arthurb.mirai.server.util;
|
||||
+
|
||||
+import net.minecraft.server.MinecraftServer;
|
||||
+import org.bukkit.Bukkit;
|
||||
+import org.bukkit.plugin.Plugin;
|
||||
+import org.bukkit.plugin.SimplePluginManager;
|
||||
+
|
||||
+import java.lang.reflect.Method;
|
||||
+
|
||||
+public class YatopiaPreloadProtocolLib {
|
||||
+
|
||||
+ public synchronized static void run() {
|
||||
+ try {
|
||||
+ final SimplePluginManager pluginManager = (SimplePluginManager) Bukkit.getPluginManager();
|
||||
+ final Plugin protocolLib = pluginManager.getPlugin("ProtocolLib");
|
||||
+ if(protocolLib != null && protocolLib.isEnabled()) {
|
||||
+ MinecraftServer.LOGGER.info("Mirai: Attempting to fix ProtocolLib");
|
||||
+ final Method initialize = Class.forName("com.comphenix.protocol.wrappers.EnumWrappers", true, protocolLib.getClass().getClassLoader()).getDeclaredMethod("initialize");
|
||||
+ initialize.setAccessible(true);
|
||||
+ initialize.invoke(null);
|
||||
+ synchronized (YatopiaPreloadProtocolLib.class) {
|
||||
+ }
|
||||
+ }
|
||||
+ } catch (Throwable t) {
|
||||
+ MinecraftServer.LOGGER.warn("Mirai: Unable to fix ProtocolLib", t);
|
||||
+ }
|
||||
+ }
|
||||
+}
|
||||
\ No newline at end of file
|
||||
43
patches/server/0009-Yatopia-Log-player-login-location.patch
Normal file
43
patches/server/0009-Yatopia-Log-player-login-location.patch
Normal file
@@ -0,0 +1,43 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Etil <81570777+etil2jz@users.noreply.github.com>
|
||||
Date: Sat, 18 Sep 2021 15:49:16 +0200
|
||||
Subject: [PATCH] (Yatopia) Log player login location
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index 4cd38de09c25ef77adf86636ae4d133c070771c9..08352cd0e6cc0cbd15aa894353b7e099216b9825 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -484,7 +484,14 @@ public abstract class PlayerList {
|
||||
}
|
||||
// Paper end
|
||||
// CraftBukkit - Moved from above, added world
|
||||
- PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ([{}]{}, {}, {})", player.getName().getString(), s1, player.getId(), worldserver1.serverLevelData.getLevelName(), player.getX(), player.getY(), player.getZ());
|
||||
+
|
||||
+ // Yatopia start - log player login location
|
||||
+ if (xyz.arthurb.mirai.server.YatopiaConfig.logPlayerLoginLoc) {
|
||||
+ PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ([{}]{}, {}, {})", player.getName().getString(), s1, player.getId(), worldserver1.serverLevelData.getLevelName(), player.getX(), player.getY(), player.getZ());
|
||||
+ } else {
|
||||
+ PlayerList.LOGGER.info("{}[{}] logged in with entity id {}", player.getName().getString(), s1, player.getId());
|
||||
+ }
|
||||
+ // Yatopia end - log player login location
|
||||
}
|
||||
|
||||
public void updateEntireScoreboard(ServerScoreboard scoreboard, ServerPlayer player) {
|
||||
diff --git a/src/main/java/xyz/arthurb/mirai/MiraiConfig.java b/src/main/java/xyz/arthurb/mirai/MiraiConfig.java
|
||||
index 9c55b553418796761554ca32b843a5b2df72e755..50392b3056d1cc10d9c59353bfa8edda3bab85f4 100644
|
||||
--- a/src/main/java/xyz/arthurb/mirai/MiraiConfig.java
|
||||
+++ b/src/main/java/xyz/arthurb/mirai/MiraiConfig.java
|
||||
@@ -181,6 +181,12 @@ public class MiraiConfig {
|
||||
hidePlayerIps = getBoolean("settings.hide-player-ips", hidePlayerIps);
|
||||
}
|
||||
|
||||
+ public static boolean logPlayerLoginLoc = true;
|
||||
+
|
||||
+ private static void general() {
|
||||
+ logPlayerLoginLoc = getBoolean("settings.log-player-login-location", logPlayerLoginLoc);
|
||||
+ }
|
||||
+
|
||||
public static boolean disableEntityStuckChecks = false;
|
||||
|
||||
private static void disableEntityStuckChecks() {
|
||||
67
patches/server/0010-Hide-player-IPs.patch
Normal file
67
patches/server/0010-Hide-player-IPs.patch
Normal file
@@ -0,0 +1,67 @@
|
||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
||||
From: Etil <81570777+etil2jz@users.noreply.github.com>
|
||||
Date: Sat, 18 Sep 2021 16:03:10 +0200
|
||||
Subject: [PATCH] Hide player IPs
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
index 01fee879c946b6640da34d5890d686f0152437dc..76c2f4b24e16c7d641ae1945b0ef94a6e854b342 100644
|
||||
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
|
||||
@@ -10,12 +10,14 @@ import java.net.InetSocketAddress;
|
||||
import java.net.SocketAddress;
|
||||
import java.security.PrivateKey;
|
||||
import java.util.Arrays;
|
||||
+import java.util.Objects;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.atomic.AtomicInteger;
|
||||
import javax.annotation.Nullable;
|
||||
import javax.crypto.Cipher;
|
||||
import javax.crypto.SecretKey;
|
||||
+import xyz.arthurb.mirai.MiraiConfig;
|
||||
import net.minecraft.DefaultUncaughtExceptionHandler;
|
||||
import net.minecraft.network.Connection;
|
||||
import net.minecraft.network.FriendlyByteBuf;
|
||||
@@ -223,6 +225,10 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener
|
||||
}
|
||||
|
||||
public String getUserName() {
|
||||
+ // Mirai start
|
||||
+ if (MiraiConfig.hidePlayerIps) {
|
||||
+ return Objects.toString(this.gameProfile);
|
||||
+ }
|
||||
return this.gameProfile != null ? this.gameProfile + " (" + this.connection.getRemoteAddress() + ")" : String.valueOf(this.connection.getRemoteAddress());
|
||||
}
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
index 08352cd0e6cc0cbd15aa894353b7e099216b9825..6d860e769eacfc78ca513ee787072d1762c02053 100644
|
||||
--- a/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java
|
||||
@@ -7,6 +7,7 @@ import com.google.common.collect.Sets;
|
||||
import com.mojang.authlib.GameProfile;
|
||||
import com.mojang.serialization.DataResult;
|
||||
import com.mojang.serialization.Dynamic;
|
||||
+import xyz.arthurb.mirai.MiraiConfig;
|
||||
import io.netty.buffer.Unpooled;
|
||||
import io.papermc.paper.adventure.PaperAdventure;
|
||||
import java.io.File;
|
||||
@@ -486,11 +487,17 @@ public abstract class PlayerList {
|
||||
// CraftBukkit - Moved from above, added world
|
||||
|
||||
// Yatopia start - log player login location
|
||||
- if (xyz.arthurb.mirai.server.MiraiConfig.logPlayerLoginLoc) {
|
||||
+ // Mirai start - hide player ips
|
||||
+ if (xyz.arthurb.mirai.server.MiraiConfig.logPlayerLoginLoc && MiraiConfig.hidePlayerIps) {
|
||||
+ PlayerList.LOGGER.info("{} logged in with entity id {} at ([{}]{}, {}, {})", player.getName().getString(), player.getId(), worldserver1.serverLevelData.getLevelName(), player.getX(), player.getY(), player.getZ());
|
||||
+ } else if (xyz.arthurb.mirai.server.MiraiConfig.logPlayerLoginLoc) {
|
||||
PlayerList.LOGGER.info("{}[{}] logged in with entity id {} at ([{}]{}, {}, {})", player.getName().getString(), s1, player.getId(), worldserver1.serverLevelData.getLevelName(), player.getX(), player.getY(), player.getZ());
|
||||
+ } else if (MiraiConfig.hidePlayerIps) {
|
||||
+ PlayerList.LOGGER.info("{} logged in with entity id {}", player.getName().getString(), player.getId());
|
||||
} else {
|
||||
PlayerList.LOGGER.info("{}[{}] logged in with entity id {}", player.getName().getString(), s1, player.getId());
|
||||
}
|
||||
+ // Mirai end - hide player ips
|
||||
// Yatopia end - log player login location
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user