mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2024-11-29 14:15:43 +01:00
37e61be6c2
Closes #289 Also dropped some patches which are useless. Changes in Purpur: Paper upstream updates Changes in Tuinity: Paper updated
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 caaa01b20e5b7430b809477022f8ab35f3c5bf20..b5dd5f44dc6583559b9cb5803af15e9a040cf7ea 100644
|
|
--- a/src/main/java/net/minecraft/server/EntityHuman.java
|
|
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
|
|
@@ -1914,7 +1914,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 b0dac509dddd576742308b687048e432fcf0484f..0237e91512dd15dae1597f1cbb37b0fb178ae35e 100644
|
|
--- a/src/main/java/net/yatopia/server/YatopiaConfig.java
|
|
+++ b/src/main/java/net/yatopia/server/YatopiaConfig.java
|
|
@@ -212,4 +212,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;
|
|
+ }
|
|
}
|