Merge branch 'ver/1.16.5' of github.com:YatopiaMC/Yatopia into dev/ver/1.16.5

This commit is contained in:
Simon Gardling 2021-01-24 13:46:59 -05:00
commit 413c82b484
49 changed files with 314 additions and 958 deletions

View File

@ -17,14 +17,6 @@ on:
paths-ignore: paths-ignore:
- '*.md' - '*.md'
- 'Jenkinsfile' - 'Jenkinsfile'
branches:
- ver/1.16.5
- ver/1.16.4
- ver/1.16.3
- ver/1.16.1
- ver/1.16.2
- leaflight/ver/1.16.4
- leaflight/ver/1.16.5
jobs: jobs:
build: build:

1
.gitignore vendored
View File

@ -60,3 +60,4 @@ yatopia-launcher.jar
last-paper last-paper
!upstreamConfig/* !upstreamConfig/*
!upstreamCommits/* !upstreamCommits/*
testserver/

View File

@ -26,7 +26,6 @@ # Patches
| server | Add StructureGenerateEvent | Nahuel | Mariell Hoversholm | | server | Add StructureGenerateEvent | Nahuel | Mariell Hoversholm |
| api | Add StructureGenerateEvent | Nahuel | Mariell Hoversholm | | api | Add StructureGenerateEvent | Nahuel | Mariell Hoversholm |
| server | Add Velocity natives for encryption and compression | Andrew Steinborn | | | server | Add Velocity natives for encryption and compression | Andrew Steinborn | |
| server | Add a special case for floodgate and offline uuids | Ivan Pekov | |
| server | Add adjustable breeding cooldown to config | montlikadani | | | server | Add adjustable breeding cooldown to config | montlikadani | |
| server | Add allow water in end world option | William Blake Galbreath | | | server | Add allow water in end world option | William Blake Galbreath | |
| server | Add boat fall damage config | BillyGalbreath | | | server | Add boat fall damage config | BillyGalbreath | |
@ -297,8 +296,6 @@ # Patches
| server | Prevent long map entry creation in light engine | Spottedleaf | | | server | Prevent long map entry creation in light engine | Spottedleaf | |
| server | Prevent unload() calls removing tickets for sync loads | Spottedleaf | | | server | Prevent unload() calls removing tickets for sync loads | Spottedleaf | |
| server | Properly handle cancellation of projectile hit event | Spottedleaf | | | server | Properly handle cancellation of projectile hit event | Spottedleaf | |
| server | ProxyForwardDataEvent | Ivan Pekov | |
| api | ProxyForwardDataEvent | Ivan Pekov | |
| server | Purpur config files | William Blake Galbreath | | | server | Purpur config files | William Blake Galbreath | |
| api | Purpur config files | William Blake Galbreath | | | api | Purpur config files | William Blake Galbreath | |
| server | Queue lighting update only once | Paul Sauve | | | server | Queue lighting update only once | Paul Sauve | |
@ -356,7 +353,6 @@ # Patches
| server | Update version fetcher repo | JRoy | | | server | Update version fetcher repo | JRoy | |
| server | Use configured height for nether surface builders | William Blake Galbreath | | | server | Use configured height for nether surface builders | William Blake Galbreath | |
| server | Use entity ticking chunk map for entity tracker | Spottedleaf | | | server | Use entity ticking chunk map for entity tracker | Spottedleaf | |
| server | Use offline uuids if we need to | Ivan Pekov | |
| server | Use unmodifiableMap instead of making copy | Paul Sauve | | | server | Use unmodifiableMap instead of making copy | Paul Sauve | |
| server | Util patch | Spottedleaf | | | server | Util patch | Spottedleaf | |
| server | Utilities | YatopiaMC | Mykyta Komarnytskyy, Ivan Pekov | | server | Utilities | YatopiaMC | Mykyta Komarnytskyy, Ivan Pekov |

View File

@ -1,137 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Ivan Pekov <ivan@mrivanplays.com>
Date: Wed, 9 Sep 2020 16:14:00 +0300
Subject: [PATCH] ProxyForwardDataEvent
diff --git a/src/main/java/net/yatopia/api/event/ProxyForwardDataEvent.java b/src/main/java/net/yatopia/api/event/ProxyForwardDataEvent.java
new file mode 100644
index 0000000000000000000000000000000000000000..d3780d965bdd491425a92bf5e554f7def6e0ecf0
--- /dev/null
+++ b/src/main/java/net/yatopia/api/event/ProxyForwardDataEvent.java
@@ -0,0 +1,125 @@
+package net.yatopia.api.event;
+
+import com.google.common.base.Preconditions;
+import com.google.common.collect.ImmutableList;
+import com.mojang.authlib.properties.Property;
+import java.util.List;
+import java.util.UUID;
+import org.bukkit.event.Event;
+import org.bukkit.event.HandlerList;
+import org.jetbrains.annotations.NotNull;
+import org.jetbrains.annotations.Nullable;
+
+/**
+ * Called when a proxy such as BungeeCord or Velocity forwards player data to the server.
+ */
+public class ProxyForwardDataEvent extends Event {
+
+ private final UUID uuid;
+ private final String name;
+ private List<Property> properties;
+
+ public ProxyForwardDataEvent(boolean async, @NotNull UUID uuid, @NotNull String name, @NotNull List<Property> properties) {
+ super(async);
+ this.uuid = uuid;
+ this.name = name;
+ this.properties = properties;
+ }
+
+ /**
+ * Returns the unique id of the profile forwarded.
+ *
+ * @return unique id
+ */
+ @NotNull
+ public UUID getUuid() {
+ return uuid;
+ }
+
+ /**
+ * Returns the name of the profile forwarded.
+ *
+ * @return name
+ */
+ @NotNull
+ public String getName() {
+ return name;
+ }
+
+ /**
+ * Returns an immutable copy of the forwarded properties.
+ * <p>
+ * If there were no properties, it would return an empty list.
+ *
+ * @return properties
+ */
+ @NotNull
+ public List<Property> getProperties() {
+ return ImmutableList.copyOf(properties);
+ }
+
+ /**
+ * Adds a property to this game profile. If the property already exists, it overrides it.
+ *
+ * @param property property
+ */
+ public void addProperty(@NotNull Property property) {
+ Preconditions.checkNotNull(property, "property");
+ if (hasProperty(property.getName())) {
+ removeProperty(property.getName());
+ }
+ properties.add(property);
+ }
+
+ /**
+ * Returns the property with the specified name.
+ *
+ * @param property the property's name you want to get
+ * @return property if present
+ */
+ @Nullable
+ public Property getProperty(@NotNull String property) {
+ Preconditions.checkNotNull(property, "property");
+ for (Property prop : properties) {
+ if (prop.getName().equalsIgnoreCase(property)) {
+ return prop;
+ }
+ }
+ return null;
+ }
+
+ /**
+ * Returns whether or not there's a property with the specified name.
+ *
+ * @param property the name of the property you want to check if exists
+ * @return boolean value
+ */
+ public boolean hasProperty(@NotNull String property) {
+ return getProperty(property) != null;
+ }
+
+ /**
+ * Removes the specified property if present
+ *
+ * @param property the property's name you want to remove
+ */
+ public void removeProperty(@NotNull String property) {
+ properties.removeIf(prop -> prop.getName().equalsIgnoreCase(property));
+ }
+
+ /**
+ * Removes the specified property if present
+ *
+ * @param property the property you want to remove
+ */
+ public void removeProperty(@NotNull Property property) {
+ Preconditions.checkNotNull(property, "property");
+ properties.remove(property);
+ }
+
+ //
+ private static final HandlerList handlers = new HandlerList();
+ @NotNull @Override public HandlerList getHandlers() { return handlers; }
+ @NotNull public static HandlerList getHandlerList() { return handlers; }
+ //
+}

View File

@ -1,105 +0,0 @@
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 91c2756a8708a2f4154905baec20b9ae484fea0d..a191693b754724f2a5a3cd2a39e5b2171bddb6a8 100644
--- a/src/main/java/net/minecraft/server/EntityHuman.java
+++ b/src/main/java/net/minecraft/server/EntityHuman.java
@@ -1954,7 +1954,7 @@ public abstract class EntityHuman extends EntityLiving {
public static UUID a(GameProfile gameprofile) {
UUID uuid = gameprofile.getId();
- if (uuid == null) {
+ if (org.yatopiamc.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..d3ffbd5247b3a9b2a046d6696c959e834dff7ef4 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 (org.yatopiamc.yatopia.server.YatopiaConfig.shouldUseOfflineUUID() && org.yatopiamc.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 (org.yatopiamc.yatopia.server.YatopiaConfig.shouldUseOfflineUUID() && !org.yatopiamc.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/org/yatopiamc/yatopia/server/YatopiaConfig.java b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
index 003a024da8ab877895244ff9e4e4ff62288622ff..eb5f7172829037862c20bb7527badaa589f50cc7 100644
--- a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
+++ b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
@@ -10,6 +10,7 @@ import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.regex.Pattern;
+import net.minecraft.server.MinecraftServer;
import org.bukkit.Bukkit;
import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration;
@@ -211,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;
+ }
}

View File

@ -1,96 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Ivan Pekov <ivan@mrivanplays.com>
Date: Wed, 9 Sep 2020 16:15:22 +0300
Subject: [PATCH] ProxyForwardDataEvent
diff --git a/src/main/java/net/minecraft/server/HandshakeListener.java b/src/main/java/net/minecraft/server/HandshakeListener.java
index 79f726ef43e70b8882890007146df199824d14e3..edb7a9de55718d9c860c82580aca78c3d254ad57 100644
--- a/src/main/java/net/minecraft/server/HandshakeListener.java
+++ b/src/main/java/net/minecraft/server/HandshakeListener.java
@@ -92,6 +92,7 @@ public class HandshakeListener implements PacketHandshakingInListener {
if (event.getSocketAddressHostname() != null) this.getNetworkManager().socketAddress = new java.net.InetSocketAddress(event.getSocketAddressHostname(), ((java.net.InetSocketAddress) this.getNetworkManager().getSocketAddress()).getPort());
this.getNetworkManager().spoofedUUID = event.getUniqueId();
this.getNetworkManager().spoofedProfile = gson.fromJson(event.getPropertiesJson(), com.mojang.authlib.properties.Property[].class);
+ if (proxyLogicEnabled) c.proxyProfileSpoof = true; // Yatopia
handledByEvent = true; // Hooray, we did it!
}
}
@@ -105,6 +106,7 @@ public class HandshakeListener implements PacketHandshakingInListener {
packethandshakinginsetprotocol.hostname = split[0];
c.socketAddress = new java.net.InetSocketAddress(split[1], ((java.net.InetSocketAddress) c.getSocketAddress()).getPort());
c.spoofedUUID = com.mojang.util.UUIDTypeAdapter.fromString( split[2] );
+ c.proxyProfileSpoof = true; // Yatopia
} else
{
ChatMessage chatmessage = new ChatMessage("If you wish to use IP forwarding, please enable it in your BungeeCord config as well!");
diff --git a/src/main/java/net/minecraft/server/LoginListener.java b/src/main/java/net/minecraft/server/LoginListener.java
index d987483255195c0bde713a92676baced1eaff2b3..bb45fc83d81948c84bc721961474e5e806ab404a 100644
--- a/src/main/java/net/minecraft/server/LoginListener.java
+++ b/src/main/java/net/minecraft/server/LoginListener.java
@@ -125,6 +125,23 @@ public class LoginListener implements PacketLoginInListener {
this.i = new GameProfile( uuid, this.i.getName() );
+ // Yatopia start - situate this around an event
+ if (networkManager.proxyProfileSpoof) {
+ java.util.List<com.mojang.authlib.properties.Property> properties;
+ if (networkManager.spoofedProfile != null) {
+ properties = new java.util.ArrayList<>(Arrays.asList(networkManager.spoofedProfile));
+ } else {
+ properties = java.util.Collections.emptyList();
+ }
+ net.yatopia.api.event.ProxyForwardDataEvent event = new net.yatopia.api.event.ProxyForwardDataEvent(
+ !org.bukkit.Bukkit.isPrimaryThread(), uuid, i.getName(), properties
+ );
+ if (event.callEvent()) {
+ for (com.mojang.authlib.properties.Property property : event.getProperties()) {
+ i.getProperties().put(property.getName(), property);
+ }
+ }
+ } else {
if (networkManager.spoofedProfile != null)
{
for ( com.mojang.authlib.properties.Property property : networkManager.spoofedProfile )
@@ -132,6 +149,7 @@ public class LoginListener implements PacketLoginInListener {
this.i.getProperties().put( property.getName(), property );
}
}
+ } // Yatopia end
}
// Spigot end
@@ -365,11 +383,20 @@ public class LoginListener implements PacketLoginInListener {
this.networkManager.socketAddress = new java.net.InetSocketAddress(com.destroystokyo.paper.proxy.VelocityProxy.readAddress(buf), ((java.net.InetSocketAddress) this.networkManager.getSocketAddress()).getPort());
- this.setGameProfile(com.destroystokyo.paper.proxy.VelocityProxy.createProfile(buf));
+ // Yatopia start - how about spoofed uuid and profile
+ //this.setGameProfile(com.destroystokyo.paper.proxy.VelocityProxy.createProfile(buf));
+ com.mojang.authlib.GameProfile profile = com.destroystokyo.paper.proxy.VelocityProxy.createProfile(buf);
+ networkManager.spoofedUUID = profile.getId();
+ if (!profile.getProperties().isEmpty()) {
+ networkManager.spoofedProfile = profile.getProperties().values().toArray(new com.mojang.authlib.properties.Property[0]);
+ }
+ networkManager.proxyProfileSpoof = true;
+ // Yatopia end
// Proceed with login
authenticatorPool.execute(() -> {
try {
+ initUUID(); // Yatopia
new LoginHandler().fireEvents();
} catch (Exception ex) {
disconnect("Failed to verify username!");
diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java
index 548c62a838848a9183e14f91b21a9dc309d8a3b2..08227ab446d6332af76491a063653f7f13f43560 100644
--- a/src/main/java/net/minecraft/server/NetworkManager.java
+++ b/src/main/java/net/minecraft/server/NetworkManager.java
@@ -51,6 +51,7 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
// Spigot Start
public java.util.UUID spoofedUUID;
public com.mojang.authlib.properties.Property[] spoofedProfile;
+ public boolean proxyProfileSpoof = false; // Yatopia
public boolean preparing = true;
// Spigot End
private PacketListener packetListener;

View File

@ -111,7 +111,7 @@ index 893d2c1c74ed28dcdb83b71762ccdcbfd50a8f9d..107091a4cae0e4eaba93f69ae91239ab
private static int b(CommandListenerWrapper commandlistenerwrapper) throws CommandSyntaxException { private static int b(CommandListenerWrapper commandlistenerwrapper) throws CommandSyntaxException {
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
index a191693b754724f2a5a3cd2a39e5b2171bddb6a8..434cfd0a224a8dc1f13809edcd4b98f0c7aa0899 100644 index 91c2756a8708a2f4154905baec20b9ae484fea0d..7a6d5521e42a31723b4f006d0fcf618fd42050e4 100644
--- a/src/main/java/net/minecraft/server/EntityHuman.java --- a/src/main/java/net/minecraft/server/EntityHuman.java
+++ b/src/main/java/net/minecraft/server/EntityHuman.java +++ b/src/main/java/net/minecraft/server/EntityHuman.java
@@ -78,6 +78,7 @@ public abstract class EntityHuman extends EntityLiving { @@ -78,6 +78,7 @@ public abstract class EntityHuman extends EntityLiving {

View File

@ -6,7 +6,7 @@ Subject: [PATCH] PlayerAttackEntityEvent
Added per request Added per request
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
index 434cfd0a224a8dc1f13809edcd4b98f0c7aa0899..d2b3db34d69269a220185d203bc1232042a9e437 100644 index 7a6d5521e42a31723b4f006d0fcf618fd42050e4..9689ebc0089f7586bad4ce4958cd792ddde50334 100644
--- a/src/main/java/net/minecraft/server/EntityHuman.java --- a/src/main/java/net/minecraft/server/EntityHuman.java
+++ b/src/main/java/net/minecraft/server/EntityHuman.java +++ b/src/main/java/net/minecraft/server/EntityHuman.java
@@ -1071,12 +1071,50 @@ public abstract class EntityHuman extends EntityLiving { @@ -1071,12 +1071,50 @@ public abstract class EntityHuman extends EntityLiving {

View File

@ -7,7 +7,7 @@ If only 1 non-daemon thread is left to run when the server is shutting down, the
This patche ensures that executors make daemon threads. This patche ensures that executors make daemon threads.
diff --git a/src/main/java/net/minecraft/server/LoginListener.java b/src/main/java/net/minecraft/server/LoginListener.java diff --git a/src/main/java/net/minecraft/server/LoginListener.java b/src/main/java/net/minecraft/server/LoginListener.java
index bb45fc83d81948c84bc721961474e5e806ab404a..847122f76f6d951b24b22c86276140e02aaf37d6 100644 index d987483255195c0bde713a92676baced1eaff2b3..e081905af0abbad0cf9011075a6380ef652924a7 100644
--- a/src/main/java/net/minecraft/server/LoginListener.java --- a/src/main/java/net/minecraft/server/LoginListener.java
+++ b/src/main/java/net/minecraft/server/LoginListener.java +++ b/src/main/java/net/minecraft/server/LoginListener.java
@@ -108,7 +108,11 @@ public class LoginListener implements PacketLoginInListener { @@ -108,7 +108,11 @@ public class LoginListener implements PacketLoginInListener {

View File

@ -94,10 +94,10 @@ index 0000000000000000000000000000000000000000..e6eaa07c57e04bbfba9e4aa8e0e939f8
+ } + }
+} +}
diff --git a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java diff --git a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
index eb5f7172829037862c20bb7527badaa589f50cc7..b358aacce7b8e1282d721ae1077b888239ec6b39 100644 index 003a024da8ab877895244ff9e4e4ff62288622ff..f6a8f3c4e92455eff806978d503751b6723ea858 100644
--- a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java --- a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
+++ b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java +++ b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
@@ -6,12 +6,15 @@ import java.io.IOException; @@ -6,11 +6,14 @@ import java.io.IOException;
import java.lang.reflect.InvocationTargetException; import java.lang.reflect.InvocationTargetException;
import java.lang.reflect.Method; import java.lang.reflect.Method;
import java.lang.reflect.Modifier; import java.lang.reflect.Modifier;
@ -107,13 +107,12 @@ index eb5f7172829037862c20bb7527badaa589f50cc7..b358aacce7b8e1282d721ae1077b8882
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.regex.Pattern; import java.util.regex.Pattern;
import net.minecraft.server.MinecraftServer;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
+import org.bukkit.command.Command; +import org.bukkit.command.Command;
import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.InvalidConfigurationException;
import org.bukkit.configuration.file.YamlConfiguration; import org.bukkit.configuration.file.YamlConfiguration;
@@ -25,6 +28,7 @@ public class YatopiaConfig { @@ -24,6 +27,7 @@ public class YatopiaConfig {
public static YamlConfiguration config; public static YamlConfiguration config;
public static int version; // since we're remapping sidestreams' configs we need this public public static int version; // since we're remapping sidestreams' configs we need this public
public static boolean verbose; // since we're remapping sidestreams' configs we need this public public static boolean verbose; // since we're remapping sidestreams' configs we need this public
@ -121,7 +120,7 @@ index eb5f7172829037862c20bb7527badaa589f50cc7..b358aacce7b8e1282d721ae1077b8882
/*========================================================================*/ /*========================================================================*/
public static void init(File configFile) { public static void init(File configFile) {
@@ -40,6 +44,8 @@ public class YatopiaConfig { @@ -39,6 +43,8 @@ public class YatopiaConfig {
config.options().header(HEADER); config.options().header(HEADER);
config.options().copyDefaults(true); config.options().copyDefaults(true);
verbose = getBoolean("verbose", false); verbose = getBoolean("verbose", false);
@ -130,13 +129,13 @@ index eb5f7172829037862c20bb7527badaa589f50cc7..b358aacce7b8e1282d721ae1077b8882
version = getInt("config-version", 1); version = getInt("config-version", 1);
set("config-version", 1); set("config-version", 1);
@@ -47,6 +53,12 @@ public class YatopiaConfig { @@ -46,6 +52,12 @@ public class YatopiaConfig {
readConfig(YatopiaConfig.class, null); readConfig(YatopiaConfig.class, null);
} }
+ public static void registerCommands() { + public static void registerCommands() {
+ for (Map.Entry<String, Command> entry : commands.entrySet()) { + for (Map.Entry<String, Command> entry : commands.entrySet()) {
+ MinecraftServer.getServer().server.getCommandMap().register(entry.getKey(), "Yatopia", entry.getValue()); + net.minecraft.server.MinecraftServer.getServer().server.getCommandMap().register(entry.getKey(), "Yatopia", entry.getValue());
+ } + }
+ } + }
+ +

View File

@ -27,12 +27,12 @@ index 41f4528cbcf5e5f98b1fba1cd6bae0987405cc21..540d16cb01e70fe46bce3a3bb4cdfd18
this.disconnect(com.destroystokyo.paper.PaperConfig.flyingKickVehicleMessage); // Paper - use configurable kick message this.disconnect(com.destroystokyo.paper.PaperConfig.flyingKickVehicleMessage); // Paper - use configurable kick message
return; return;
diff --git a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java diff --git a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
index b358aacce7b8e1282d721ae1077b888239ec6b39..26bd1fc5b348cc16ca29f66eead2ca42bd4258a8 100644 index f6a8f3c4e92455eff806978d503751b6723ea858..81ab5afa7bd397266d2afe77426d2e629529aa1a 100644
--- a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java --- a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
+++ b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java +++ b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
@@ -246,4 +246,11 @@ public class YatopiaConfig { @@ -223,4 +223,11 @@ public class YatopiaConfig {
public static boolean isProxy() { private static void fixFallDistance() {
return org.spigotmc.SpigotConfig.bungee || com.destroystokyo.paper.PaperConfig.velocitySupport; fixFallDistance = getBoolean("settings.fixFallDistance", false);
} }
+ +
+ public static boolean checkFlying = true; + public static boolean checkFlying = true;

View File

@ -8,7 +8,7 @@ In vanilla, statistics that count time spent for an action (i.e. time played or
With an interval of 20, this patch saves roughly 3ms per tick on a server w/ 80 players online. With an interval of 20, this patch saves roughly 3ms per tick on a server w/ 80 players online.
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
index d2b3db34d69269a220185d203bc1232042a9e437..c9f490e4e4e7a5a3a9ad99f864ff8fb2acc5b5b2 100644 index 9689ebc0089f7586bad4ce4958cd792ddde50334..aa54fcc5ae3b33587278df2a3fa089af38b5552d 100644
--- a/src/main/java/net/minecraft/server/EntityHuman.java --- a/src/main/java/net/minecraft/server/EntityHuman.java
+++ b/src/main/java/net/minecraft/server/EntityHuman.java +++ b/src/main/java/net/minecraft/server/EntityHuman.java
@@ -175,18 +175,23 @@ public abstract class EntityHuman extends EntityLiving { @@ -175,18 +175,23 @@ public abstract class EntityHuman extends EntityLiving {
@ -40,10 +40,10 @@ index d2b3db34d69269a220185d203bc1232042a9e437..c9f490e4e4e7a5a3a9ad99f864ff8fb2
int i = 29999999; int i = 29999999;
diff --git a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java diff --git a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
index 26bd1fc5b348cc16ca29f66eead2ca42bd4258a8..2e08558eef23d40b3a704250dfe12bb7f4b660f3 100644 index 81ab5afa7bd397266d2afe77426d2e629529aa1a..045ace1444b4db8fa5fab09f970de7a696c56ab8 100644
--- a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java --- a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
+++ b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java +++ b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
@@ -253,4 +253,9 @@ public class YatopiaConfig { @@ -230,4 +230,9 @@ public class YatopiaConfig {
checkFlying = getBoolean("settings.checks.flight", checkFlying); checkFlying = getBoolean("settings.checks.flight", checkFlying);
checkVehicleFlying = getBoolean("settings.checks.vehicle-flight", checkVehicleFlying); checkVehicleFlying = getBoolean("settings.checks.vehicle-flight", checkVehicleFlying);
} }

View File

@ -27,10 +27,10 @@ index 7596eaf605bf73dd44c06b66bcc0e5a36242fe7a..46813a0a65977233acdabb225552e8cf
} }
diff --git a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java diff --git a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
index 2e08558eef23d40b3a704250dfe12bb7f4b660f3..5578f5784a87019d3f091173b25b5ec1cc059fd6 100644 index 045ace1444b4db8fa5fab09f970de7a696c56ab8..2100ac9c1f4d0df75347579cc5d58255b77ec252 100644
--- a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java --- a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
+++ b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java +++ b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
@@ -258,4 +258,14 @@ public class YatopiaConfig { @@ -235,4 +235,14 @@ public class YatopiaConfig {
private static void intervals() { private static void intervals() {
playerTimeStatisticsInterval = Math.max(1, getInt("settings.intervals.player-time-statistics", 1)); playerTimeStatisticsInterval = Math.max(1, getInt("settings.intervals.player-time-statistics", 1));
} }

View File

@ -21,10 +21,10 @@ index 9a6bb7b6cb4d4aabae6f7e7915f993e4ebd6f77f..954462353d35c06b0568c56669e31d0a
worldserver.hasRidableMoveEvent = net.pl3x.purpur.event.entity.RidableMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Purpur worldserver.hasRidableMoveEvent = net.pl3x.purpur.event.entity.RidableMoveEvent.getHandlerList().getRegisteredListeners().length > 0; // Purpur
TileEntityHopper.skipHopperEvents = worldserver.paperConfig.disableHopperMoveEvents || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper TileEntityHopper.skipHopperEvents = worldserver.paperConfig.disableHopperMoveEvents || org.bukkit.event.inventory.InventoryMoveItemEvent.getHandlerList().getRegisteredListeners().length == 0; // Paper
diff --git a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java diff --git a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
index 5578f5784a87019d3f091173b25b5ec1cc059fd6..4f99aa4b578333795296da2424f38aae65a808a3 100644 index 2100ac9c1f4d0df75347579cc5d58255b77ec252..4d6410401457afe91457ae72df14bf687e9c62fd 100644
--- a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java --- a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
+++ b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java +++ b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
@@ -268,4 +268,8 @@ public class YatopiaConfig { @@ -245,4 +245,8 @@ public class YatopiaConfig {
criterionTriggerTick = getBoolean("settings.criterion-triggers.tick", true); criterionTriggerTick = getBoolean("settings.criterion-triggers.tick", true);
} }

View File

@ -5,7 +5,7 @@ Subject: [PATCH] Infinity No Arrows
diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java diff --git a/src/main/java/net/minecraft/server/EntityHuman.java b/src/main/java/net/minecraft/server/EntityHuman.java
index c9f490e4e4e7a5a3a9ad99f864ff8fb2acc5b5b2..b3c76fcf65b028e4aa53699ee93a5c3ba59981f2 100644 index aa54fcc5ae3b33587278df2a3fa089af38b5552d..81cb94e3a4fd26bba47d96bbd35be110765934c3 100644
--- a/src/main/java/net/minecraft/server/EntityHuman.java --- a/src/main/java/net/minecraft/server/EntityHuman.java
+++ b/src/main/java/net/minecraft/server/EntityHuman.java +++ b/src/main/java/net/minecraft/server/EntityHuman.java
@@ -2179,7 +2179,7 @@ public abstract class EntityHuman extends EntityLiving { @@ -2179,7 +2179,7 @@ public abstract class EntityHuman extends EntityLiving {

View File

@ -45,10 +45,10 @@ index 540d16cb01e70fe46bce3a3bb4cdfd1841b3d155..4b0b4c2c9af4c0a43b30f84a87cb1539
PlayerConnection.LOGGER.warn("{} moved wrongly! ({})", this.player.getDisplayName().getString(), d11); // Purpur PlayerConnection.LOGGER.warn("{} moved wrongly! ({})", this.player.getDisplayName().getString(), d11); // Purpur
} }
diff --git a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java diff --git a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
index 4f99aa4b578333795296da2424f38aae65a808a3..34b5a087d1d5d84b193adbd756add060a2d49354 100644 index 4d6410401457afe91457ae72df14bf687e9c62fd..78decc9c7483f42acb65f342f12fc1d644440822 100644
--- a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java --- a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
+++ b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java +++ b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
@@ -272,4 +272,15 @@ public class YatopiaConfig { @@ -249,4 +249,15 @@ public class YatopiaConfig {
private static void fireBlockPhysicsEvent() { private static void fireBlockPhysicsEvent() {
fireBlockPhysicsEvent = getBoolean("settings.fire-block-physics-event", true); fireBlockPhysicsEvent = getBoolean("settings.fire-block-physics-event", true);
} }

View File

@ -31,10 +31,10 @@ index 9b0c75332d9815657d96183e51e40cf14ee3ed75..e3de65b58a599b375b3be7470d918038
this.l = this.k; this.l = this.k;
EntityHuman entityhuman = this.world.a((double) this.position.getX() + 0.5D, (double) this.position.getY() + 0.5D, (double) this.position.getZ() + 0.5D, 3.0D, false); EntityHuman entityhuman = this.world.a((double) this.position.getX() + 0.5D, (double) this.position.getY() + 0.5D, (double) this.position.getZ() + 0.5D, 3.0D, false);
diff --git a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java diff --git a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
index 34b5a087d1d5d84b193adbd756add060a2d49354..2d4fb0a4664578f8d5c23db854eb8f2764724940 100644 index 78decc9c7483f42acb65f342f12fc1d644440822..890247fadf69dabce6d1c23ba887f93ae5121e1e 100644
--- a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java --- a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
+++ b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java +++ b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
@@ -283,4 +283,9 @@ public class YatopiaConfig { @@ -260,4 +260,9 @@ public class YatopiaConfig {
checkVehicleMovedQuickly = getBoolean("settings.checks.vehicle-moved-quickly", checkVehicleMovedQuickly); checkVehicleMovedQuickly = getBoolean("settings.checks.vehicle-moved-quickly", checkVehicleMovedQuickly);
checkVehicleMovedWrongly = getBoolean("settings.checks.vehicle-moved-wrongly", checkVehicleMovedWrongly); checkVehicleMovedWrongly = getBoolean("settings.checks.vehicle-moved-wrongly", checkVehicleMovedWrongly);
} }

View File

@ -1,29 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Ivan Pekov <ivan@mrivanplays.com>
Date: Tue, 29 Dec 2020 08:47:43 +0200
Subject: [PATCH] Add a special case for floodgate and offline uuids
floodgate spoofs uuids, but plugins such as luckperms get the uuid that the server uses, causing problems
if this option is configured properly, such things won't happen
diff --git a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
index 2d4fb0a4664578f8d5c23db854eb8f2764724940..00c600d74ba84cb564b9b22f53f279a93839d71f 100644
--- a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
+++ b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
@@ -225,7 +225,16 @@ public class YatopiaConfig {
fixFallDistance = getBoolean("settings.fixFallDistance", false);
}
+ public static boolean usingFloodgate = false;
+ private static void usingFloodgate() {
+ usingFloodgate = getBoolean("settings.using-floodgate", false);
+ }
+
public static boolean shouldUseOfflineUUID() {
+ if (usingFloodgate) {
+ // never cuz floodgate spoofs an uuid
+ return false;
+ }
if (org.spigotmc.SpigotConfig.bungee && com.destroystokyo.paper.PaperConfig.bungeeOnlineMode) {
return false;
}

View File

@ -24,10 +24,10 @@ index 7e42654873195d17c9a5a2a718216a943533e658..fd2fe2f5e53f34957f80223e1694a573
public void sendScoreboard(ScoreboardServer scoreboardserver, EntityPlayer entityplayer) { public void sendScoreboard(ScoreboardServer scoreboardserver, EntityPlayer entityplayer) {
diff --git a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java diff --git a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
index 00c600d74ba84cb564b9b22f53f279a93839d71f..35f212c2ac43ebea6ce9c4a333738c7a869ebc18 100644 index 890247fadf69dabce6d1c23ba887f93ae5121e1e..c2dc5265552ebd429111253c70481003a4be29dd 100644
--- a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java --- a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
+++ b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java +++ b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
@@ -297,4 +297,10 @@ public class YatopiaConfig { @@ -265,4 +265,10 @@ public class YatopiaConfig {
private static void tickEnchantingTables() { private static void tickEnchantingTables() {
shouldTickEnchantingTables = getBoolean("settings.tick.enchanting-tables", shouldTickEnchantingTables); shouldTickEnchantingTables = getBoolean("settings.tick.enchanting-tables", shouldTickEnchantingTables);
} }

View File

@ -41,7 +41,7 @@ index 87cf9cd88d1fb5ae70d19e5618ebfb67d281304a..a1c2bea7c93433434b4e4dfd0bb4b962
public boolean getPVP() { public boolean getPVP() {
diff --git a/src/main/java/net/minecraft/server/ServerConnection.java b/src/main/java/net/minecraft/server/ServerConnection.java diff --git a/src/main/java/net/minecraft/server/ServerConnection.java b/src/main/java/net/minecraft/server/ServerConnection.java
index 0668d383db1f3a81d1053954d72678c7ac5aecec..f20be527bec58bad8e4a5bb7bb887949cb6d1d99 100644 index 0668d383db1f3a81d1053954d72678c7ac5aecec..d22f0ee3f7f2daa8323d454aca1f94733b249333 100644
--- a/src/main/java/net/minecraft/server/ServerConnection.java --- a/src/main/java/net/minecraft/server/ServerConnection.java
+++ b/src/main/java/net/minecraft/server/ServerConnection.java +++ b/src/main/java/net/minecraft/server/ServerConnection.java
@@ -11,6 +11,7 @@ import io.netty.channel.ChannelInitializer; @@ -11,6 +11,7 @@ import io.netty.channel.ChannelInitializer;
@ -52,7 +52,7 @@ index 0668d383db1f3a81d1053954d72678c7ac5aecec..f20be527bec58bad8e4a5bb7bb887949
import io.netty.channel.epoll.EpollEventLoopGroup; import io.netty.channel.epoll.EpollEventLoopGroup;
import io.netty.channel.epoll.EpollServerSocketChannel; import io.netty.channel.epoll.EpollServerSocketChannel;
import io.netty.channel.nio.NioEventLoopGroup; import io.netty.channel.nio.NioEventLoopGroup;
@@ -26,16 +27,20 @@ import java.util.List; @@ -26,6 +27,7 @@ import java.util.List;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import org.apache.logging.log4j.LogManager; import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger; import org.apache.logging.log4j.Logger;
@ -60,20 +60,7 @@ index 0668d383db1f3a81d1053954d72678c7ac5aecec..f20be527bec58bad8e4a5bb7bb887949
public class ServerConnection { public class ServerConnection {
private static final Logger LOGGER = LogManager.getLogger(); @@ -52,15 +54,29 @@ public class ServerConnection {
+ /* // Yatopia Start - New network system - Remove unused fields
public static final LazyInitVar<NioEventLoopGroup> a = new LazyInitVar<>(() -> {
return new NioEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Server IO #%d").setDaemon(true).build());
});
public static final LazyInitVar<EpollEventLoopGroup> b = new LazyInitVar<>(() -> {
return new EpollEventLoopGroup(0, (new ThreadFactoryBuilder()).setNameFormat("Netty Epoll Server IO #%d").setDaemon(true).build());
});
+ */
+ // Yatopia end
private final MinecraftServer e;
public volatile boolean c;
private final List<ChannelFuture> listeningChannels = Collections.synchronizedList(Lists.newArrayList());
@@ -52,15 +57,29 @@ public class ServerConnection {
} }
// Paper end // Paper end
@ -87,7 +74,7 @@ index 0668d383db1f3a81d1053954d72678c7ac5aecec..f20be527bec58bad8e4a5bb7bb887949
this.c = true; this.c = true;
+ +
+ // Yatopia start - New network system + // Yatopia start - New network system
+ this.networkType = NetworkType.bestType(minecraftserver); + this.networkType = NetworkType.bestType(minecraftserver, LOGGER);
+ this.boss = networkType.createEventLoopGroup(NetworkType.LoopGroupType.BOSS); + this.boss = networkType.createEventLoopGroup(NetworkType.LoopGroupType.BOSS);
+ this.worker = networkType.createEventLoopGroup(NetworkType.LoopGroupType.WORKER); + this.worker = networkType.createEventLoopGroup(NetworkType.LoopGroupType.WORKER);
+ // Yatopia end + // Yatopia end
@ -103,7 +90,7 @@ index 0668d383db1f3a81d1053954d72678c7ac5aecec..f20be527bec58bad8e4a5bb7bb887949
Class oclass; Class oclass;
LazyInitVar lazyinitvar; LazyInitVar lazyinitvar;
@@ -73,16 +92,25 @@ public class ServerConnection { @@ -73,16 +89,25 @@ public class ServerConnection {
lazyinitvar = ServerConnection.a; lazyinitvar = ServerConnection.a;
ServerConnection.LOGGER.info("Using default channel type"); ServerConnection.LOGGER.info("Using default channel type");
} }
@ -130,7 +117,7 @@ index 0668d383db1f3a81d1053954d72678c7ac5aecec..f20be527bec58bad8e4a5bb7bb887949
} catch (ChannelException channelexception) { } catch (ChannelException channelexception) {
; ;
} }
@@ -97,7 +125,8 @@ public class ServerConnection { @@ -97,7 +122,8 @@ public class ServerConnection {
channel.pipeline().addLast("packet_handler", (ChannelHandler) object); channel.pipeline().addLast("packet_handler", (ChannelHandler) object);
((NetworkManager) object).setPacketListener(new HandshakeListener(ServerConnection.this.e, (NetworkManager) object)); ((NetworkManager) object).setPacketListener(new HandshakeListener(ServerConnection.this.e, (NetworkManager) object));
} }
@ -141,18 +128,24 @@ index 0668d383db1f3a81d1053954d72678c7ac5aecec..f20be527bec58bad8e4a5bb7bb887949
} }
diff --git a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java diff --git a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
index 35f212c2ac43ebea6ce9c4a333738c7a869ebc18..c4d0dabd408c7a943dafd6ca89b598cb4afb440e 100644 index c2dc5265552ebd429111253c70481003a4be29dd..c67654e8701b9da6499d442048429149daae7150 100644
--- a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java --- a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
+++ b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java +++ b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
@@ -303,4 +303,11 @@ public class YatopiaConfig { @@ -271,4 +271,17 @@ public class YatopiaConfig {
logPlayerLoginLoc = getBoolean("settings.log-player-login-location", logPlayerLoginLoc); logPlayerLoginLoc = getBoolean("settings.log-player-login-location", logPlayerLoginLoc);
} }
+ public static boolean ioUringBeta = false; + public static boolean ioUringBeta = false;
+ public static boolean tcpFastOpen = false; + public static boolean tcpFastOpen = false;
+ public static boolean debugNetwork = false;
+ private static void newNetworkSystem() { + private static void newNetworkSystem() {
+ ioUringBeta = getBoolean("network.io-uring", ioUringBeta); + ioUringBeta = getBoolean("network.io-uring", ioUringBeta);
+ tcpFastOpen = getBoolean("network.ftcp-fastopen", tcpFastOpen); + if (config.get("network.ftcp-fastopen") != null) {
+ config.set("network.tcp-fastopen", getBoolean("network.ftcp-fastopen", tcpFastOpen));
+ config.set("network.ftcp-fastopen", null);
+ }
+ tcpFastOpen = getBoolean("network.tcp-fastopen", tcpFastOpen);
+ debugNetwork = getBoolean("network.debug", debugNetwork);
+ } + }
+ +
} }
@ -191,10 +184,10 @@ index 0000000000000000000000000000000000000000..3e74e23f3cc44b7547d9f8575b411059
+} +}
diff --git a/src/main/java/org/yatopiamc/yatopia/server/network/NetworkType.java b/src/main/java/org/yatopiamc/yatopia/server/network/NetworkType.java diff --git a/src/main/java/org/yatopiamc/yatopia/server/network/NetworkType.java b/src/main/java/org/yatopiamc/yatopia/server/network/NetworkType.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..6b9d788dfef2c51111e9f2129a04fce7754c51ba index 0000000000000000000000000000000000000000..6c387f29e4db7e1574a2bbb119465c48b8ed2f90
--- /dev/null --- /dev/null
+++ b/src/main/java/org/yatopiamc/yatopia/server/network/NetworkType.java +++ b/src/main/java/org/yatopiamc/yatopia/server/network/NetworkType.java
@@ -0,0 +1,110 @@ @@ -0,0 +1,129 @@
+package org.yatopiamc.yatopia.server.network; +package org.yatopiamc.yatopia.server.network;
+ +
+import io.netty.channel.ChannelFactory; +import io.netty.channel.ChannelFactory;
@ -216,6 +209,8 @@ index 0000000000000000000000000000000000000000..6b9d788dfef2c51111e9f2129a04fce7
+import java.util.function.BiFunction; +import java.util.function.BiFunction;
+ +
+import net.minecraft.server.MinecraftServer; +import net.minecraft.server.MinecraftServer;
+import org.apache.logging.log4j.Level;
+import org.apache.logging.log4j.Logger;
+import org.spigotmc.SpigotConfig; +import org.spigotmc.SpigotConfig;
+import org.yatopiamc.yatopia.server.YatopiaConfig; +import org.yatopiamc.yatopia.server.YatopiaConfig;
+ +
@ -264,7 +259,7 @@ index 0000000000000000000000000000000000000000..6b9d788dfef2c51111e9f2129a04fce7
+ return new NettyThreadFactory(name, type.toString()); + return new NettyThreadFactory(name, type.toString());
+ } + }
+ +
+ public static NetworkType bestType(MinecraftServer minecraftServer) { + public static NetworkType bestType(MinecraftServer minecraftServer, Logger logger) {
+ if (!minecraftServer.isUsingNativeTransport()) { + if (!minecraftServer.isUsingNativeTransport()) {
+ return NIO; + return NIO;
+ } + }
@ -275,20 +270,37 @@ index 0000000000000000000000000000000000000000..6b9d788dfef2c51111e9f2129a04fce7
+ if (!SpigotConfig.bungee && YatopiaConfig.ioUringBeta && MinecraftServer.getServer().ax() < 0) { + if (!SpigotConfig.bungee && YatopiaConfig.ioUringBeta && MinecraftServer.getServer().ax() < 0) {
+ if (IOUring.isAvailable()) { + if (IOUring.isAvailable()) {
+ return IOURING; + return IOURING;
+ } else if (YatopiaConfig.debugNetwork) {
+ logger.log(Level.ERROR, "IOUring is not working: {}", exceptionMessage(IOUring.unavailabilityCause()));
+ } + }
+ } + }
+ +
+ if (Epoll.isAvailable()) { + if (Epoll.isAvailable()) {
+ return EPOLL; + return EPOLL;
+ } else if (YatopiaConfig.debugNetwork) {
+ logger.log(Level.ERROR, "Epoll is not working: {}", exceptionMessage(Epoll.unavailabilityCause()));
+ } + }
+ +
+ if (KQueue.isAvailable()) { + if (KQueue.isAvailable()) {
+ return KQUEUE; + return KQUEUE;
+ } else if (YatopiaConfig.debugNetwork) {
+ logger.log(Level.ERROR, "KQueue is not working: {}", exceptionMessage(KQueue.unavailabilityCause()));
+ } + }
+ +
+ return NIO; + return NIO;
+ } + }
+ +
+ private static String exceptionMessage(Throwable throwable) {
+ StackTraceElement[] trace = throwable.getStackTrace();
+ return getClassNameFromString(throwable.getClass().getName()) + " : " + throwable.getMessage() +
+ ((trace.length > 0) ? " @ " + throwable.getStackTrace()[0].getClassName() + ":" + throwable.getStackTrace()[0].getLineNumber() : "");
+ }
+
+ private static String getClassNameFromString(String className) {
+ int i = className.lastIndexOf('.');
+ return i > 0 ? className.substring(i + 1) : className;
+ }
+
+ public enum LoopGroupType { + public enum LoopGroupType {
+ BOSS("Boss"), + BOSS("Boss"),
+ WORKER("Worker"); + WORKER("Worker");

View File

@ -0,0 +1,245 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Andrew Steinborn <git@steinborn.me>
Date: Thu, 21 Jan 2021 00:40:24 +0100
Subject: [PATCH] Port krypton
Co-authored-by: Hugo Planque <hookwood01@gmail.com>
diff --git a/src/main/java/me/steinborn/krypton/mod/shared/network/VarintByteDecoder.java b/src/main/java/me/steinborn/krypton/mod/shared/network/VarintByteDecoder.java
new file mode 100644
index 0000000000000000000000000000000000000000..cdf5a3b1f7ec27171f3825f89cfb8d398fb3fd79
--- /dev/null
+++ b/src/main/java/me/steinborn/krypton/mod/shared/network/VarintByteDecoder.java
@@ -0,0 +1,47 @@
+package me.steinborn.krypton.mod.shared.network;
+
+import io.netty.util.ByteProcessor;
+
+public class VarintByteDecoder implements ByteProcessor {
+ private int readVarint;
+ private int bytesRead;
+ private DecodeResult result = DecodeResult.TOO_SHORT;
+
+ @Override
+ public boolean process(byte k) {
+ readVarint |= (k & 0x7F) << bytesRead++ * 7;
+ if (bytesRead > 3) {
+ result = DecodeResult.TOO_BIG;
+ return false;
+ }
+ if ((k & 0x80) != 128) {
+ result = DecodeResult.SUCCESS;
+ return false;
+ }
+ return true;
+ }
+
+ public int readVarint() {
+ return readVarint;
+ }
+
+ public int varintBytes() {
+ return bytesRead;
+ }
+
+ public DecodeResult getResult() {
+ return result;
+ }
+
+ public void reset() {
+ readVarint = 0;
+ bytesRead = 0;
+ result = DecodeResult.TOO_SHORT;
+ }
+
+ public enum DecodeResult {
+ SUCCESS,
+ TOO_SHORT,
+ TOO_BIG
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/net/minecraft/server/LegacyPingHandler.java b/src/main/java/net/minecraft/server/LegacyPingHandler.java
index 4a49fe4cc600e2b70963302ddae0c4479849f3f5..3abc3869b8012f060e1997822ffdb321f4884929 100644
--- a/src/main/java/net/minecraft/server/LegacyPingHandler.java
+++ b/src/main/java/net/minecraft/server/LegacyPingHandler.java
@@ -23,6 +23,11 @@ public class LegacyPingHandler extends ChannelInboundHandlerAdapter {
}
public void channelRead(ChannelHandlerContext channelhandlercontext, Object object) throws Exception {
+ // Yatopia start - New network system
+ if (!channelhandlercontext.channel().isActive()) {
+ ((ByteBuf) object).clear();
+ return;
+ } // Yatopia end
ByteBuf bytebuf = (ByteBuf) object;
// Paper start - Make legacy ping handler more reliable
diff --git a/src/main/java/net/minecraft/server/LoginListener.java b/src/main/java/net/minecraft/server/LoginListener.java
index e081905af0abbad0cf9011075a6380ef652924a7..c3240607b23ccaa6743c013251e1e45a67072441 100644
--- a/src/main/java/net/minecraft/server/LoginListener.java
+++ b/src/main/java/net/minecraft/server/LoginListener.java
@@ -8,6 +8,7 @@ import java.math.BigInteger;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
+import java.security.GeneralSecurityException; // Yatopia
import java.security.PrivateKey;
import java.util.Arrays;
import java.util.Random;
diff --git a/src/main/java/net/minecraft/server/PacketDataSerializer.java b/src/main/java/net/minecraft/server/PacketDataSerializer.java
index f43193c1090238f2241b878120247d1b3d0d4e57..7dc31ee3211a895993c522a7155a0d8641fd442c 100644
--- a/src/main/java/net/minecraft/server/PacketDataSerializer.java
+++ b/src/main/java/net/minecraft/server/PacketDataSerializer.java
@@ -7,6 +7,7 @@ import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import io.netty.buffer.ByteBufInputStream;
import io.netty.buffer.ByteBufOutputStream;
+import io.netty.buffer.ByteBufUtil; // Yatopia
import io.netty.handler.codec.DecoderException;
import io.netty.handler.codec.EncoderException;
import io.netty.util.ByteProcessor;
@@ -30,7 +31,7 @@ import org.bukkit.craftbukkit.inventory.CraftItemStack; // CraftBukkit
public class PacketDataSerializer extends ByteBuf {
- private final ByteBuf a;
+ private final ByteBuf a; private final ByteBuf getParent() { return a; } // Yatopia - OBFHELPER
public PacketDataSerializer(ByteBuf bytebuf) {
this.a = bytebuf;
@@ -210,6 +211,7 @@ public class PacketDataSerializer extends ByteBuf {
return new UUID(this.readLong(), this.readLong());
}
+ public PacketDataSerializer writeVarInt(int i){ return d(i); } // Yatopia - OBFHELPER
public PacketDataSerializer d(int i) {
while ((i & -128) != 0) {
this.writeByte(i & 127 | 128);
@@ -358,6 +360,8 @@ public class PacketDataSerializer extends ByteBuf {
}
public PacketDataSerializer a(String s, int i) {
+ // Yatopia start - New network system
+ /*
byte[] abyte = s.getBytes(StandardCharsets.UTF_8);
if (abyte.length > i) {
@@ -367,6 +371,16 @@ public class PacketDataSerializer extends ByteBuf {
this.writeBytes(abyte);
return this;
}
+ */
+ int utf8Bytes = ByteBufUtil.utf8Bytes(s);
+ if (utf8Bytes > i) {
+ throw new EncoderException("String too big (was " + utf8Bytes + " bytes encoded, max " + i + ")");
+ } else {
+ this.writeVarInt(utf8Bytes);
+ this.writeCharSequence(s, StandardCharsets.UTF_8);
+ return new PacketDataSerializer(getParent());
+ }
+ // Yatopia end
}
public MinecraftKey p() {
diff --git a/src/main/java/net/minecraft/server/PacketSplitter.java b/src/main/java/net/minecraft/server/PacketSplitter.java
index 2aaa8770edfd8acc6861c23176e405863858b275..b1e1aa95b5d7a1555428327f2e7fd0eafc679dc1 100644
--- a/src/main/java/net/minecraft/server/PacketSplitter.java
+++ b/src/main/java/net/minecraft/server/PacketSplitter.java
@@ -5,14 +5,20 @@ import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import io.netty.handler.codec.CorruptedFrameException;
+// Yatopia start
+import io.netty.handler.codec.DecoderException;
+import me.steinborn.krypton.mod.shared.network.VarintByteDecoder;
+// Yatopia end
import java.util.List;
public class PacketSplitter extends ByteToMessageDecoder {
+ private final VarintByteDecoder reader = new VarintByteDecoder(); // Yatopia
private final byte[] lenBuf = new byte[3]; // Paper
public PacketSplitter() {}
protected void decode(ChannelHandlerContext channelhandlercontext, ByteBuf bytebuf, List<Object> list) throws Exception {
+ /* // Yatopia start - New network system
// Paper start - if channel is not active just discard the packet
if (!channelhandlercontext.channel().isActive()) {
bytebuf.skipBytes(bytebuf.readableBytes());
@@ -53,5 +59,38 @@ public class PacketSplitter extends ByteToMessageDecoder {
}
throw new CorruptedFrameException("length wider than 21-bit");
+ */
+ if (!channelhandlercontext.channel().isActive()) {
+ bytebuf.clear();
+ return;
+ }
+
+ reader.reset();
+
+ int varintEnd = bytebuf.forEachByte(reader);
+ if (varintEnd == -1) {
+ // We tried to go beyond the end of the buffer. This is probably a good sign that the
+ // buffer was too short to hold a proper varint.
+ return;
+ }
+
+ if (reader.getResult() == VarintByteDecoder.DecodeResult.SUCCESS) {
+ int readLen = reader.readVarint();
+ if (readLen < 0) {
+ throw new DecoderException("Bad packet length");
+ } else if (readLen == 0) {
+ // skip over the empty packet and ignore it
+ bytebuf.readerIndex(varintEnd + 1);
+ } else {
+ int minimumRead = reader.varintBytes() + readLen;
+ if (bytebuf.isReadable(minimumRead)) {
+ list.add(bytebuf.retainedSlice(varintEnd + 1, readLen));
+ bytebuf.skipBytes(minimumRead);
+ }
+ }
+ } else if (reader.getResult() == VarintByteDecoder.DecodeResult.TOO_BIG) {
+ throw new DecoderException("Varint too big");
+ }
+ // Yatopia end
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
index 756be0886856aabc31e436f82948d3d069f66fef..c1dd04b57e8ffeb343b0efdec36d6fb36c16884f 100644
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -10,6 +10,7 @@ import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
+import io.netty.util.ResourceLeakDetector; // Yatopia
import joptsimple.OptionParser;
import joptsimple.OptionSet;
import net.minecrell.terminalconsole.TerminalConsoleAppender; // Paper
@@ -289,6 +290,24 @@ public class Main {
// Paper End
}
}
+ // Yatopia start - New network system
+ // By default, Netty allocates 16MiB arenas for the PooledByteBufAllocator. This is too much
+ // memory for Minecraft, which imposes a maximum packet size of 2MiB! We'll use 4MiB as a more
+ // sane default.
+ //
+ // Note: io.netty.allocator.pageSize << io.netty.allocator.maxOrder is the formula used to
+ // compute the chunk size. We lower maxOrder from its default of 11 to 9. (We also use a null
+ // check, so that the user is free to choose another setting if need be.)
+ if (System.getProperty("io.netty.allocator.maxOrder") == null) {
+ System.setProperty("io.netty.allocator.maxOrder", "9");
+ }
+
+ // Disable the resource leak detector by default as it reduces performance. Allow the user to
+ // override this if desired.
+ if (System.getProperty("io.netty.leakDetection.level") == null) {
+ ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.DISABLED);
+ }
+ // Yatopia end
// Paper start - Log Java and OS versioning to help with debugging plugin issues
java.lang.management.RuntimeMXBean runtimeMX = java.lang.management.ManagementFactory.getRuntimeMXBean();

View File

@ -27,11 +27,11 @@ index 76aac1b131f314775e418339e434f4f2da2ad619..46aef6e142c7ec0cf2d4ac53a2db4987
} }
// Paper end - fix sand duping // Paper end - fix sand duping
diff --git a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java diff --git a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
index c4d0dabd408c7a943dafd6ca89b598cb4afb440e..37b17d05646839569830dd3610afdc78a1d69ab9 100644 index c67654e8701b9da6499d442048429149daae7150..ac73a0629347a3d5842f00ee8d28c288acdec375 100644
--- a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java --- a/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
+++ b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java +++ b/src/main/java/org/yatopiamc/yatopia/server/YatopiaConfig.java
@@ -310,4 +310,8 @@ public class YatopiaConfig { @@ -284,4 +284,8 @@ public class YatopiaConfig {
tcpFastOpen = getBoolean("network.ftcp-fastopen", tcpFastOpen); debugNetwork = getBoolean("network.debug", debugNetwork);
} }
+ public static boolean allowSandDupe = false; + public static boolean allowSandDupe = false;

View File

@ -1,522 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Andrew Steinborn <git@steinborn.me>
Date: Thu, 21 Jan 2021 00:40:24 +0100
Subject: [PATCH] Port krypton
Co-authored-by: Hugo Planque <hookwood01@gmail.com>
diff --git a/src/main/java/me/steinborn/krypton/mod/shared/network/VarintByteDecoder.java b/src/main/java/me/steinborn/krypton/mod/shared/network/VarintByteDecoder.java
new file mode 100644
index 0000000000000000000000000000000000000000..cdf5a3b1f7ec27171f3825f89cfb8d398fb3fd79
--- /dev/null
+++ b/src/main/java/me/steinborn/krypton/mod/shared/network/VarintByteDecoder.java
@@ -0,0 +1,47 @@
+package me.steinborn.krypton.mod.shared.network;
+
+import io.netty.util.ByteProcessor;
+
+public class VarintByteDecoder implements ByteProcessor {
+ private int readVarint;
+ private int bytesRead;
+ private DecodeResult result = DecodeResult.TOO_SHORT;
+
+ @Override
+ public boolean process(byte k) {
+ readVarint |= (k & 0x7F) << bytesRead++ * 7;
+ if (bytesRead > 3) {
+ result = DecodeResult.TOO_BIG;
+ return false;
+ }
+ if ((k & 0x80) != 128) {
+ result = DecodeResult.SUCCESS;
+ return false;
+ }
+ return true;
+ }
+
+ public int readVarint() {
+ return readVarint;
+ }
+
+ public int varintBytes() {
+ return bytesRead;
+ }
+
+ public DecodeResult getResult() {
+ return result;
+ }
+
+ public void reset() {
+ readVarint = 0;
+ bytesRead = 0;
+ result = DecodeResult.TOO_SHORT;
+ }
+
+ public enum DecodeResult {
+ SUCCESS,
+ TOO_SHORT,
+ TOO_BIG
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/me/steinborn/krypton/mod/shared/network/compression/MinecraftCompressDecoder.java b/src/main/java/me/steinborn/krypton/mod/shared/network/compression/MinecraftCompressDecoder.java
new file mode 100644
index 0000000000000000000000000000000000000000..e9a51c71e136be14ebe8a240c4b21205079fc71b
--- /dev/null
+++ b/src/main/java/me/steinborn/krypton/mod/shared/network/compression/MinecraftCompressDecoder.java
@@ -0,0 +1,68 @@
+package me.steinborn.krypton.mod.shared.network.compression;
+
+import com.velocitypowered.natives.compression.VelocityCompressor;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.CorruptedFrameException;
+import io.netty.handler.codec.MessageToMessageDecoder;
+import net.minecraft.server.PacketDataSerializer;
+
+import java.util.List;
+
+import static com.velocitypowered.natives.util.MoreByteBufUtils.ensureCompatible;
+import static com.velocitypowered.natives.util.MoreByteBufUtils.preferredBuffer;
+
+public class MinecraftCompressDecoder extends MessageToMessageDecoder<ByteBuf> {
+
+ private static final int VANILLA_MAXIMUM_UNCOMPRESSED_SIZE = 2 * 1024 * 1024; // 2MiB
+ private static final int HARD_MAXIMUM_UNCOMPRESSED_SIZE = 16 * 1024 * 1024; // 16MiB
+
+ private static final int UNCOMPRESSED_CAP =
+ Boolean.getBoolean("velocity.increased-compression-cap")
+ ? HARD_MAXIMUM_UNCOMPRESSED_SIZE : VANILLA_MAXIMUM_UNCOMPRESSED_SIZE;
+
+ private final int threshold;
+ private final VelocityCompressor compressor;
+
+ public MinecraftCompressDecoder(int threshold, VelocityCompressor compressor) {
+ this.threshold = threshold;
+ this.compressor = compressor;
+ }
+
+ @Override
+ protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
+ PacketDataSerializer wrappedBuf = new PacketDataSerializer(in);
+ int claimedUncompressedSize = wrappedBuf.readVarInt();
+ if (claimedUncompressedSize == 0) {
+ // This message is not compressed.
+ out.add(in.retainedSlice());
+ return;
+ }
+
+ if (claimedUncompressedSize < threshold) {
+ throw new CorruptedFrameException("Uncompressed size " + claimedUncompressedSize + " is less than"
+ + " threshold " + threshold);
+ }
+ if (claimedUncompressedSize > UNCOMPRESSED_CAP) {
+ throw new CorruptedFrameException("Uncompressed size " + claimedUncompressedSize + " exceeds hard " +
+ "threshold of " + UNCOMPRESSED_CAP);
+ }
+
+ ByteBuf compatibleIn = ensureCompatible(ctx.alloc(), compressor, in);
+ ByteBuf uncompressed = preferredBuffer(ctx.alloc(), compressor, claimedUncompressedSize);
+ try {
+ compressor.inflate(compatibleIn, uncompressed, claimedUncompressedSize);
+ out.add(uncompressed);
+ } catch (Exception e) {
+ uncompressed.release();
+ throw e;
+ } finally {
+ compatibleIn.release();
+ }
+ }
+
+ @Override
+ public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
+ compressor.close();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/me/steinborn/krypton/mod/shared/network/compression/MinecraftCompressEncoder.java b/src/main/java/me/steinborn/krypton/mod/shared/network/compression/MinecraftCompressEncoder.java
new file mode 100644
index 0000000000000000000000000000000000000000..1114e1db59476353ad609a519b71479438db7b0c
--- /dev/null
+++ b/src/main/java/me/steinborn/krypton/mod/shared/network/compression/MinecraftCompressEncoder.java
@@ -0,0 +1,59 @@
+package me.steinborn.krypton.mod.shared.network.compression;
+
+
+import com.velocitypowered.natives.compression.VelocityCompressor;
+import com.velocitypowered.natives.util.MoreByteBufUtils;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.MessageToByteEncoder;
+import net.minecraft.server.PacketDataSerializer;
+
+public class MinecraftCompressEncoder extends MessageToByteEncoder<ByteBuf> {
+
+ private final int threshold;
+ private final VelocityCompressor compressor;
+
+ public MinecraftCompressEncoder(int threshold, VelocityCompressor compressor) {
+ this.threshold = threshold;
+ this.compressor = compressor;
+ }
+
+ @Override
+ protected void encode(ChannelHandlerContext ctx, ByteBuf msg, ByteBuf out) throws Exception {
+ PacketDataSerializer wrappedBuf = new PacketDataSerializer(out);
+ int uncompressed = msg.readableBytes();
+ if (uncompressed < threshold) {
+ // Under the threshold, there is nothing to do.
+ wrappedBuf.writeVarInt(0);
+ out.writeBytes(msg);
+ } else {
+ wrappedBuf.writeVarInt(uncompressed);
+ ByteBuf compatibleIn = MoreByteBufUtils.ensureCompatible(ctx.alloc(), compressor, msg);
+ try {
+ compressor.deflate(compatibleIn, out);
+ } finally {
+ compatibleIn.release();
+ }
+ }
+ }
+
+ @Override
+ protected ByteBuf allocateBuffer(ChannelHandlerContext ctx, ByteBuf msg, boolean preferDirect)
+ throws Exception {
+ // We allocate bytes to be compressed plus 1 byte. This covers two cases:
+ //
+ // - Compression
+ // According to https://github.com/ebiggers/libdeflate/blob/master/libdeflate.h#L103,
+ // if the data compresses well (and we do not have some pathological case) then the maximum
+ // size the compressed size will ever be is the input size minus one.
+ // - Uncompressed
+ // This is fairly obvious - we will then have one more than the uncompressed size.
+ int initialBufferSize = msg.readableBytes() + 1;
+ return MoreByteBufUtils.preferredBuffer(ctx.alloc(), compressor, initialBufferSize);
+ }
+
+ @Override
+ public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
+ compressor.close();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/me/steinborn/krypton/mod/shared/network/pipeline/MinecraftCipherDecoder.java b/src/main/java/me/steinborn/krypton/mod/shared/network/pipeline/MinecraftCipherDecoder.java
new file mode 100644
index 0000000000000000000000000000000000000000..2612c350446b172629b8030602ed812fa69f24a4
--- /dev/null
+++ b/src/main/java/me/steinborn/krypton/mod/shared/network/pipeline/MinecraftCipherDecoder.java
@@ -0,0 +1,36 @@
+package me.steinborn.krypton.mod.shared.network.pipeline;
+
+import com.google.common.base.Preconditions;
+import com.velocitypowered.natives.encryption.VelocityCipher;
+import com.velocitypowered.natives.util.MoreByteBufUtils;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.MessageToMessageDecoder;
+
+import java.util.List;
+
+public class MinecraftCipherDecoder extends MessageToMessageDecoder<ByteBuf> {
+
+ private final VelocityCipher cipher;
+
+ public MinecraftCipherDecoder(VelocityCipher cipher) {
+ this.cipher = Preconditions.checkNotNull(cipher, "cipher");
+ }
+
+ @Override
+ protected void decode(ChannelHandlerContext ctx, ByteBuf in, List<Object> out) throws Exception {
+ ByteBuf compatible = MoreByteBufUtils.ensureCompatible(ctx.alloc(), cipher, in).slice();
+ try {
+ cipher.process(compatible);
+ out.add(compatible);
+ } catch (Exception e) {
+ compatible.release(); // compatible will never be used if we throw an exception
+ throw e;
+ }
+ }
+
+ @Override
+ public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
+ cipher.close();
+ }
+}
diff --git a/src/main/java/me/steinborn/krypton/mod/shared/network/pipeline/MinecraftCipherEncoder.java b/src/main/java/me/steinborn/krypton/mod/shared/network/pipeline/MinecraftCipherEncoder.java
new file mode 100644
index 0000000000000000000000000000000000000000..068b0d51daf11045a5054cddd53897ecdd117a37
--- /dev/null
+++ b/src/main/java/me/steinborn/krypton/mod/shared/network/pipeline/MinecraftCipherEncoder.java
@@ -0,0 +1,36 @@
+package me.steinborn.krypton.mod.shared.network.pipeline;
+
+import com.google.common.base.Preconditions;
+import com.velocitypowered.natives.encryption.VelocityCipher;
+import com.velocitypowered.natives.util.MoreByteBufUtils;
+import io.netty.buffer.ByteBuf;
+import io.netty.channel.ChannelHandlerContext;
+import io.netty.handler.codec.MessageToMessageEncoder;
+
+import java.util.List;
+
+public class MinecraftCipherEncoder extends MessageToMessageEncoder<ByteBuf> {
+
+ private final VelocityCipher cipher;
+
+ public MinecraftCipherEncoder(VelocityCipher cipher) {
+ this.cipher = Preconditions.checkNotNull(cipher, "cipher");
+ }
+
+ @Override
+ protected void encode(ChannelHandlerContext ctx, ByteBuf msg, List<Object> out) throws Exception {
+ ByteBuf compatible = MoreByteBufUtils.ensureCompatible(ctx.alloc(), cipher, msg);
+ try {
+ cipher.process(compatible);
+ out.add(compatible);
+ } catch (Exception e) {
+ compatible.release(); // compatible will never be used if we throw an exception
+ throw e;
+ }
+ }
+
+ @Override
+ public void handlerRemoved(ChannelHandlerContext ctx) throws Exception {
+ cipher.close();
+ }
+}
\ No newline at end of file
diff --git a/src/main/java/net/minecraft/server/LegacyPingHandler.java b/src/main/java/net/minecraft/server/LegacyPingHandler.java
index 4a49fe4cc600e2b70963302ddae0c4479849f3f5..3abc3869b8012f060e1997822ffdb321f4884929 100644
--- a/src/main/java/net/minecraft/server/LegacyPingHandler.java
+++ b/src/main/java/net/minecraft/server/LegacyPingHandler.java
@@ -23,6 +23,11 @@ public class LegacyPingHandler extends ChannelInboundHandlerAdapter {
}
public void channelRead(ChannelHandlerContext channelhandlercontext, Object object) throws Exception {
+ // Yatopia start - New network system
+ if (!channelhandlercontext.channel().isActive()) {
+ ((ByteBuf) object).clear();
+ return;
+ } // Yatopia end
ByteBuf bytebuf = (ByteBuf) object;
// Paper start - Make legacy ping handler more reliable
diff --git a/src/main/java/net/minecraft/server/LoginListener.java b/src/main/java/net/minecraft/server/LoginListener.java
index 847122f76f6d951b24b22c86276140e02aaf37d6..174197f41bedab6a45e96323adff4f3f6238cef2 100644
--- a/src/main/java/net/minecraft/server/LoginListener.java
+++ b/src/main/java/net/minecraft/server/LoginListener.java
@@ -8,6 +8,7 @@ import java.math.BigInteger;
import java.net.InetAddress;
import java.net.InetSocketAddress;
import java.net.SocketAddress;
+import java.security.GeneralSecurityException; // Yatopia
import java.security.PrivateKey;
import java.util.Arrays;
import java.util.Random;
@@ -256,8 +257,8 @@ public class LoginListener implements PacketLoginInListener {
s = (new BigInteger(MinecraftEncryption.a("", this.server.getKeyPair().getPublic(), this.loginKey))).toString(16);
this.g = LoginListener.EnumProtocolState.AUTHENTICATING;
- this.networkManager.a(this.loginKey); // Tuinity
- } catch (CryptographyException cryptographyexception) {
+ this.networkManager.setupEncryption(this.loginKey); // Tuinity // Yatopia - New network system
+ } catch (CryptographyException | GeneralSecurityException cryptographyexception) { // Yatopia
throw new IllegalStateException("Protocol error", cryptographyexception);
}
diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java
index 08227ab446d6332af76491a063653f7f13f43560..a6890caa3c78dea773a7f71e919d5f352db02e1b 100644
--- a/src/main/java/net/minecraft/server/NetworkManager.java
+++ b/src/main/java/net/minecraft/server/NetworkManager.java
@@ -21,6 +21,17 @@ import java.net.SocketAddress;
import java.util.Queue;
import javax.annotation.Nullable;
import javax.crypto.Cipher;
+// Yatopia start
+import javax.crypto.SecretKey;
+import me.steinborn.krypton.mod.shared.network.compression.MinecraftCompressDecoder;
+import me.steinborn.krypton.mod.shared.network.compression.MinecraftCompressEncoder;
+import me.steinborn.krypton.mod.shared.network.pipeline.MinecraftCipherDecoder;
+import me.steinborn.krypton.mod.shared.network.pipeline.MinecraftCipherEncoder;
+import com.velocitypowered.natives.compression.VelocityCompressor;
+import com.velocitypowered.natives.encryption.VelocityCipher;
+import com.velocitypowered.natives.util.Natives;
+import java.security.GeneralSecurityException;
+// Yatopia end
import org.apache.commons.lang3.Validate;
import org.apache.logging.log4j.LogManager;
import org.apache.logging.log4j.Logger;
@@ -107,6 +118,17 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
}
// Tuinity end - allow controlled flushing
+ // Yatopia start
+ public void setupEncryption(SecretKey key) throws GeneralSecurityException {
+ VelocityCipher decryption = Natives.cipher.get().forDecryption(key);
+ VelocityCipher encryption = Natives.cipher.get().forEncryption(key);
+
+ this.n = true;
+ this.channel.pipeline().addBefore("splitter", "decrypt", new MinecraftCipherDecoder(decryption));
+ this.channel.pipeline().addBefore("prepender", "encrypt", new MinecraftCipherEncoder(encryption));
+ }
+ // Yatopia end
+
public NetworkManager(EnumProtocolDirection enumprotocoldirection) {
this.h = enumprotocoldirection;
}
diff --git a/src/main/java/net/minecraft/server/PacketDataSerializer.java b/src/main/java/net/minecraft/server/PacketDataSerializer.java
index f43193c1090238f2241b878120247d1b3d0d4e57..7dc31ee3211a895993c522a7155a0d8641fd442c 100644
--- a/src/main/java/net/minecraft/server/PacketDataSerializer.java
+++ b/src/main/java/net/minecraft/server/PacketDataSerializer.java
@@ -7,6 +7,7 @@ import io.netty.buffer.ByteBuf;
import io.netty.buffer.ByteBufAllocator;
import io.netty.buffer.ByteBufInputStream;
import io.netty.buffer.ByteBufOutputStream;
+import io.netty.buffer.ByteBufUtil; // Yatopia
import io.netty.handler.codec.DecoderException;
import io.netty.handler.codec.EncoderException;
import io.netty.util.ByteProcessor;
@@ -30,7 +31,7 @@ import org.bukkit.craftbukkit.inventory.CraftItemStack; // CraftBukkit
public class PacketDataSerializer extends ByteBuf {
- private final ByteBuf a;
+ private final ByteBuf a; private final ByteBuf getParent() { return a; } // Yatopia - OBFHELPER
public PacketDataSerializer(ByteBuf bytebuf) {
this.a = bytebuf;
@@ -210,6 +211,7 @@ public class PacketDataSerializer extends ByteBuf {
return new UUID(this.readLong(), this.readLong());
}
+ public PacketDataSerializer writeVarInt(int i){ return d(i); } // Yatopia - OBFHELPER
public PacketDataSerializer d(int i) {
while ((i & -128) != 0) {
this.writeByte(i & 127 | 128);
@@ -358,6 +360,8 @@ public class PacketDataSerializer extends ByteBuf {
}
public PacketDataSerializer a(String s, int i) {
+ // Yatopia start - New network system
+ /*
byte[] abyte = s.getBytes(StandardCharsets.UTF_8);
if (abyte.length > i) {
@@ -367,6 +371,16 @@ public class PacketDataSerializer extends ByteBuf {
this.writeBytes(abyte);
return this;
}
+ */
+ int utf8Bytes = ByteBufUtil.utf8Bytes(s);
+ if (utf8Bytes > i) {
+ throw new EncoderException("String too big (was " + utf8Bytes + " bytes encoded, max " + i + ")");
+ } else {
+ this.writeVarInt(utf8Bytes);
+ this.writeCharSequence(s, StandardCharsets.UTF_8);
+ return new PacketDataSerializer(getParent());
+ }
+ // Yatopia end
}
public MinecraftKey p() {
diff --git a/src/main/java/net/minecraft/server/PacketSplitter.java b/src/main/java/net/minecraft/server/PacketSplitter.java
index 2aaa8770edfd8acc6861c23176e405863858b275..b1e1aa95b5d7a1555428327f2e7fd0eafc679dc1 100644
--- a/src/main/java/net/minecraft/server/PacketSplitter.java
+++ b/src/main/java/net/minecraft/server/PacketSplitter.java
@@ -5,14 +5,20 @@ import io.netty.buffer.Unpooled;
import io.netty.channel.ChannelHandlerContext;
import io.netty.handler.codec.ByteToMessageDecoder;
import io.netty.handler.codec.CorruptedFrameException;
+// Yatopia start
+import io.netty.handler.codec.DecoderException;
+import me.steinborn.krypton.mod.shared.network.VarintByteDecoder;
+// Yatopia end
import java.util.List;
public class PacketSplitter extends ByteToMessageDecoder {
+ private final VarintByteDecoder reader = new VarintByteDecoder(); // Yatopia
private final byte[] lenBuf = new byte[3]; // Paper
public PacketSplitter() {}
protected void decode(ChannelHandlerContext channelhandlercontext, ByteBuf bytebuf, List<Object> list) throws Exception {
+ /* // Yatopia start - New network system
// Paper start - if channel is not active just discard the packet
if (!channelhandlercontext.channel().isActive()) {
bytebuf.skipBytes(bytebuf.readableBytes());
@@ -53,5 +59,38 @@ public class PacketSplitter extends ByteToMessageDecoder {
}
throw new CorruptedFrameException("length wider than 21-bit");
+ */
+ if (!channelhandlercontext.channel().isActive()) {
+ bytebuf.clear();
+ return;
+ }
+
+ reader.reset();
+
+ int varintEnd = bytebuf.forEachByte(reader);
+ if (varintEnd == -1) {
+ // We tried to go beyond the end of the buffer. This is probably a good sign that the
+ // buffer was too short to hold a proper varint.
+ return;
+ }
+
+ if (reader.getResult() == VarintByteDecoder.DecodeResult.SUCCESS) {
+ int readLen = reader.readVarint();
+ if (readLen < 0) {
+ throw new DecoderException("Bad packet length");
+ } else if (readLen == 0) {
+ // skip over the empty packet and ignore it
+ bytebuf.readerIndex(varintEnd + 1);
+ } else {
+ int minimumRead = reader.varintBytes() + readLen;
+ if (bytebuf.isReadable(minimumRead)) {
+ list.add(bytebuf.retainedSlice(varintEnd + 1, readLen));
+ bytebuf.skipBytes(minimumRead);
+ }
+ }
+ } else if (reader.getResult() == VarintByteDecoder.DecodeResult.TOO_BIG) {
+ throw new DecoderException("Varint too big");
+ }
+ // Yatopia end
}
}
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
index 756be0886856aabc31e436f82948d3d069f66fef..c1dd04b57e8ffeb343b0efdec36d6fb36c16884f 100644
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -10,6 +10,7 @@ import java.util.List;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
import java.util.logging.Logger;
+import io.netty.util.ResourceLeakDetector; // Yatopia
import joptsimple.OptionParser;
import joptsimple.OptionSet;
import net.minecrell.terminalconsole.TerminalConsoleAppender; // Paper
@@ -289,6 +290,24 @@ public class Main {
// Paper End
}
}
+ // Yatopia start - New network system
+ // By default, Netty allocates 16MiB arenas for the PooledByteBufAllocator. This is too much
+ // memory for Minecraft, which imposes a maximum packet size of 2MiB! We'll use 4MiB as a more
+ // sane default.
+ //
+ // Note: io.netty.allocator.pageSize << io.netty.allocator.maxOrder is the formula used to
+ // compute the chunk size. We lower maxOrder from its default of 11 to 9. (We also use a null
+ // check, so that the user is free to choose another setting if need be.)
+ if (System.getProperty("io.netty.allocator.maxOrder") == null) {
+ System.setProperty("io.netty.allocator.maxOrder", "9");
+ }
+
+ // Disable the resource leak detector by default as it reduces performance. Allow the user to
+ // override this if desired.
+ if (System.getProperty("io.netty.leakDetection.level") == null) {
+ ResourceLeakDetector.setLevel(ResourceLeakDetector.Level.DISABLED);
+ }
+ // Yatopia end
// Paper start - Log Java and OS versioning to help with debugging plugin issues
java.lang.management.RuntimeMXBean runtimeMX = java.lang.management.ManagementFactory.getRuntimeMXBean();