mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-11-23 11:06:51 +01:00
43f2b8b2ea
api refactor to that domain is coming in next major release
98 lines
4.7 KiB
Diff
98 lines
4.7 KiB
Diff
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
From: Ivan Pekov <ivan@mrivanplays.com>
|
|
Date: Mon, 17 Aug 2020 19:16:39 +0300
|
|
Subject: [PATCH] Use offline uuids if we need to
|
|
|
|
By default, the user cache falls back to requests to mojang if it wasn't able to find a player.
|
|
This is completely fine if we're running an online mode server, however proxies require the
|
|
server to run in offline mode, which makes mojang's default commands to not work properly
|
|
( say if we want to ban a player which has never joined the server, he wouldn't get banned )
|
|
|
|
What our change does is make use of already existing options in paper.yml and spigot.yml to check
|
|
if the server is running behind a proxy and if the proxy is running online mode. If admins fail to
|
|
configure it properly, their mistake!
|
|
|
|
Furthermore, my research on the issue shows that this behavior also can be seen if we're not running
|
|
behind a proxy at all! I try to whitelist any of my staff, and they get whitelisted with online mode
|
|
UUIDs, while they should get whitelisted with offline mode ones.
|
|
|
|
Thanks to Gabriele C <sgdc3.mail@gmail.com> for pointing this issue to us, as he said paper doesn't
|
|
have any interest fixing this.
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
|
|
index a52c0391b171c8a57de75f87c534ce1e0e78c44a..6ae35c96978b6d16bc45d3eff435f35647fd1555 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityHuman.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
|
|
@@ -1923,7 +1923,7 @@ public abstract class EntityHuman extends EntityLiving {
|
|
public static UUID a(GameProfile gameprofile) {
|
|
UUID uuid = gameprofile.getId();
|
|
|
|
- if (uuid == null) {
|
|
+ if (net.yatopia.server.YatopiaConfig.shouldUseOfflineUUID() || uuid == null) { // Yatopia
|
|
uuid = getOfflineUUID(gameprofile.getName());
|
|
}
|
|
|
|
diff --git a/src/main/java/net/minecraft/server/UserCache.java b/src/main/java/net/minecraft/server/UserCache.java
|
|
index 1496c43fc9487caf6ddb3782a9d1c79ef6ca1e94..7e486c0f326449a10700efcec7ed3d9da5222615 100644
|
|
--- a/src/main/java/net/minecraft/server/UserCache.java
|
|
+++ b/src/main/java/net/minecraft/server/UserCache.java
|
|
@@ -82,6 +82,11 @@ public class UserCache {
|
|
|
|
@Nullable
|
|
private static GameProfile a(GameProfileRepository gameprofilerepository, String s) {
|
|
+ // Yatopia start
|
|
+ if (net.yatopia.server.YatopiaConfig.shouldUseOfflineUUID() && net.yatopia.server.YatopiaConfig.isProxy()) {
|
|
+ return new GameProfile(EntityHuman.getOfflineUUID(s), s);
|
|
+ }
|
|
+ // Yatopia end
|
|
final AtomicReference<GameProfile> atomicreference = new AtomicReference();
|
|
ProfileLookupCallback profilelookupcallback = new ProfileLookupCallback() {
|
|
public void onProfileLookupSucceeded(GameProfile gameprofile) {
|
|
@@ -102,6 +107,15 @@ public class UserCache {
|
|
gameprofile = new GameProfile(uuid, s);
|
|
}
|
|
|
|
+ // Yatopia start
|
|
+ if (net.yatopia.server.YatopiaConfig.shouldUseOfflineUUID() && !net.yatopia.server.YatopiaConfig.isProxy()) {
|
|
+ GameProfile newProfile = new GameProfile(EntityHuman.getOfflineUUID(s), s);
|
|
+ if (gameprofile == null || gameprofile.getProperties().isEmpty()) return newProfile;
|
|
+ newProfile.getProperties().putAll(gameprofile.getProperties());
|
|
+ return newProfile;
|
|
+ }
|
|
+ // Yatopia end
|
|
+
|
|
return gameprofile;
|
|
}
|
|
|
|
diff --git a/src/main/java/net/yatopia/server/YatopiaConfig.java b/src/main/java/net/yatopia/server/YatopiaConfig.java
|
|
index 349834a9b367f00478448c5be8216a856b4b21c4..7c1b4ebf3a067045461782840566319191984f72 100644
|
|
--- a/src/main/java/net/yatopia/server/YatopiaConfig.java
|
|
+++ b/src/main/java/net/yatopia/server/YatopiaConfig.java
|
|
@@ -231,4 +231,26 @@ public class YatopiaConfig {
|
|
private static void fixFallDistance() {
|
|
fixFallDistance = getBoolean("settings.fixFallDistance", false);
|
|
}
|
|
+
|
|
+ public static boolean shouldUseOfflineUUID() {
|
|
+ if (org.spigotmc.SpigotConfig.bungee && com.destroystokyo.paper.PaperConfig.bungeeOnlineMode) {
|
|
+ return false;
|
|
+ }
|
|
+ if (org.spigotmc.SpigotConfig.bungee) {
|
|
+ return true;
|
|
+ }
|
|
+ if (com.destroystokyo.paper.PaperConfig.velocitySupport &&
|
|
+ com.destroystokyo.paper.PaperConfig.velocityOnlineMode) {
|
|
+ return false;
|
|
+ }
|
|
+ if (com.destroystokyo.paper.PaperConfig.velocitySupport) {
|
|
+ return true;
|
|
+ }
|
|
+
|
|
+ return !MinecraftServer.getServer().getOnlineMode();
|
|
+ }
|
|
+
|
|
+ public static boolean isProxy() {
|
|
+ return org.spigotmc.SpigotConfig.bungee || com.destroystokyo.paper.PaperConfig.velocitySupport;
|
|
+ }
|
|
}
|