mirror of
https://github.com/YatopiaMC/Yatopia.git
synced 2025-02-18 21:32:06 +01:00
This is now for sure going to fix hoppers entirely, except speeds which we should see in other patch. Apparently caching the inventory doesn't work for composters as they're constantly updating their block state. The code now makes it so that we only cache if the block is NOT a composter. This is also fixing a bug with offline mode servers and proxies for vanilla commands. Read the new patch's patch notes to see what I'm talking about.
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/dev/tr7zw/yatopia/YatopiaConfig.java b/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
|
|
index 0543de8ea80322028729723fd2b500ee7921ffd5..74bff3264d50d5352398d94526239c3c7507a5e4 100644
|
|
--- a/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
|
|
+++ b/src/main/java/dev/tr7zw/yatopia/YatopiaConfig.java
|
|
@@ -233,4 +233,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;
|
|
+ }
|
|
}
|
|
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
|
|
index a52c0391b171c8a57de75f87c534ce1e0e78c44a..bc46685716865927cec193c67a14f3edcf5ffc2e 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 (dev.tr7zw.yatopia.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..ca15524a0687197905ea940190ac4c547b609542 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 (dev.tr7zw.yatopia.YatopiaConfig.shouldUseOfflineUUID() && dev.tr7zw.yatopia.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 (dev.tr7zw.yatopia.YatopiaConfig.shouldUseOfflineUUID() && !dev.tr7zw.yatopia.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;
|
|
}
|
|
|