Compile fixes

This commit is contained in:
Nassim Jahnke 2022-07-28 00:04:27 +02:00
parent 64cb313386
commit 063e6b288c
No known key found for this signature in database
GPG Key ID: 6BE3B555EBC5982B
6 changed files with 71 additions and 26 deletions

View File

@ -1431,7 +1431,7 @@ index 4759a0eceeccf28b62cb8865b423235d47d07443..58aea845e8ce6e46e52fc3bdfa9c6415
// CraftBukkit end
this.chatVisibility = packet.chatVisibility();
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 13f996d163739f419b701854b5248a02edfc93c0..11e4dc3d8fbe48b5ec9d771a851f0ac69694e394 100644
index 13f996d163739f419b701854b5248a02edfc93c0..59932a4f83461280ab3c097add951e5a138eb53d 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -187,6 +187,8 @@ import org.apache.commons.lang3.StringUtils;
@ -1472,7 +1472,7 @@ index 13f996d163739f419b701854b5248a02edfc93c0..11e4dc3d8fbe48b5ec9d771a851f0ac6
@Override
protected Object evaluate() {
- ServerGamePacketListenerImpl.this.disconnect(s);
+ ServerGamePacketListenerImpl.this.disconnect(reason); // Paper - adventure
+ ServerGamePacketListenerImpl.this.disconnect(reason, cause); // Paper - adventure
return null;
}
};

View File

@ -34,21 +34,23 @@ how PlayerPreLoginEvent interacts with PlayerConnectionCloseEvent
is undefined.
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index 83c5264e4af146d3712cee4550d84c824a3a96d6..66274a749af1e77363190fda99b5999efac40bdb 100644
index 83c5264e4af146d3712cee4550d84c824a3a96d6..f6162d65d341ef3df1a9b3f45d7d0c25d52f35cf 100644
--- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java
@@ -439,6 +439,24 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
@@ -439,6 +439,26 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
this.getPacketListener().onDisconnect(Component.translatable("multiplayer.disconnect.generic"));
}
this.queue.clear(); // Free up packet queue.
+ // Paper start - Add PlayerConnectionCloseEvent
+ final PacketListener packetListener = this.getPacketListener();
+ if (packetListener instanceof net.minecraft.server.network.ServerGamePacketListenerImpl playerConnection) {
+ if (packetListener instanceof net.minecraft.server.network.ServerGamePacketListenerImpl) {
+ /* Player was logged in */
+ final net.minecraft.server.network.ServerGamePacketListenerImpl playerConnection = (net.minecraft.server.network.ServerGamePacketListenerImpl) packetListener;
+ new com.destroystokyo.paper.event.player.PlayerConnectionCloseEvent(playerConnection.player.getUUID(),
+ playerConnection.player.getScoreboardName(), ((java.net.InetSocketAddress)address).getAddress(), false).callEvent();
+ } else if (packetListener instanceof net.minecraft.server.network.ServerLoginPacketListenerImpl loginListener) {
+ } else if (packetListener instanceof net.minecraft.server.network.ServerLoginPacketListenerImpl) {
+ /* Player is login stage */
+ final net.minecraft.server.network.ServerLoginPacketListenerImpl loginListener = (net.minecraft.server.network.ServerLoginPacketListenerImpl) packetListener;
+ switch (loginListener.state) {
+ case READY_TO_ACCEPT:
+ case DELAY_ACCEPT:

View File

@ -28,7 +28,7 @@ and then catch exceptions and close if they fire.
Part of this commit was authored by: Spottedleaf
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index 66274a749af1e77363190fda99b5999efac40bdb..26849a8af6149b710df8a7e0a335d98df2e2a4d2 100644
index f6162d65d341ef3df1a9b3f45d7d0c25d52f35cf..2d1db70456b746c8fab77893cb34240e573b92ca 100644
--- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java
@@ -93,6 +93,10 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
@ -275,7 +275,7 @@ index 66274a749af1e77363190fda99b5999efac40bdb..26849a8af6149b710df8a7e0a335d98d
+ clearPacketQueue(); // Paper
// Paper start - Add PlayerConnectionCloseEvent
final PacketListener packetListener = this.getPacketListener();
if (packetListener instanceof net.minecraft.server.network.ServerGamePacketListenerImpl playerConnection) {
if (packetListener instanceof net.minecraft.server.network.ServerGamePacketListenerImpl) {
diff --git a/src/main/java/net/minecraft/network/protocol/Packet.java b/src/main/java/net/minecraft/network/protocol/Packet.java
index 74bfe0d3942259c45702b099efdc4e101a4e3022..e8fcd56906d26f6dc87959e32c4c7c78cfea9658 100644
--- a/src/main/java/net/minecraft/network/protocol/Packet.java

View File

@ -8,7 +8,7 @@ the world per tick, this attempts to reduce the impact that join floods
has on the server
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index 8440b3d6f9811fa16b10843ada91248e0722acc4..2ed32f8c503b7196abfaa1c1e2456fbd4760eac3 100644
index 7e11d760f84d2cda85e686c5eca764e666e9389f..65c2263f8872fba4f68779e0e90ea5f96aefdfbd 100644
--- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java
@@ -396,8 +396,23 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
@ -26,10 +26,10 @@ index 8440b3d6f9811fa16b10843ada91248e0722acc4..2ed32f8c503b7196abfaa1c1e2456fbd
+ joinAttemptsThisTick = 0;
+ }
+ // Paper end
+ if (this.packetListener instanceof net.minecraft.server.network.ServerLoginPacketListenerImpl serverLoginPacketListener) {
+ if ( serverLoginPacketListener.state != net.minecraft.server.network.ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT // Paper
+ if (this.packetListener instanceof net.minecraft.server.network.ServerLoginPacketListenerImpl) {
+ if ( ((net.minecraft.server.network.ServerLoginPacketListenerImpl) this.packetListener).state != net.minecraft.server.network.ServerLoginPacketListenerImpl.State.READY_TO_ACCEPT // Paper
+ || (joinAttemptsThisTick++ < MAX_PER_TICK)) { // Paper - limit the number of joins which can be processed each tick
+ serverLoginPacketListener.tick();
+ ((net.minecraft.server.network.ServerLoginPacketListenerImpl) this.packetListener).tick();
+ } // Paper
+ }
PacketListener packetlistener = this.packetListener;

View File

@ -11,10 +11,10 @@ Tested-by: Mariell Hoversholm <proximyst@proximyst.com>
Reviewed-by: Mariell Hoversholm <proximyst@proximyst.com>
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index 9c80b1048f7c855c43dc114ffcd94b6f9df74661..25d26ba482edac4158ba247e105d8c5fac0729e4 100644
index 0b62d34d8db4331365f1fc0c703bb8af05d5d12a..ec1fa6b6cb386542d9c83f5c49c1e8e98c87d417 100644
--- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java
@@ -639,6 +639,11 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
@@ -641,6 +641,11 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
// Spigot Start
public SocketAddress getRawAddress()
{

View File

@ -196,25 +196,24 @@ index 0000000000000000000000000000000000000000..dde9d36bf6212196caa18f3c9c535aec
+}
diff --git a/src/main/java/ca/spottedleaf/dataconverter/minecraft/MCVersionRegistry.java b/src/main/java/ca/spottedleaf/dataconverter/minecraft/MCVersionRegistry.java
new file mode 100644
index 0000000000000000000000000000000000000000..31dc32c7464badfd7c6e5a7060b6593539b6ae23
index 0000000000000000000000000000000000000000..b6817eef740b4dd0ebc00857085f7f01e6d2b7aa
--- /dev/null
+++ b/src/main/java/ca/spottedleaf/dataconverter/minecraft/MCVersionRegistry.java
@@ -0,0 +1,363 @@
+package ca.spottedleaf.dataconverter.minecraft;
+
+import ca.spottedleaf.dataconverter.converters.DataConverter;
+import ca.spottedleaf.dataconverter.minecraft.versions.V3093;
+import com.mojang.logging.LogUtils;
+import it.unimi.dsi.fastutil.ints.Int2ObjectLinkedOpenHashMap;
+import it.unimi.dsi.fastutil.ints.IntArrayList;
+import it.unimi.dsi.fastutil.ints.IntLinkedOpenHashSet;
+import it.unimi.dsi.fastutil.ints.IntRBTreeSet;
+import it.unimi.dsi.fastutil.longs.LongArrayList;
+import it.unimi.dsi.fastutil.longs.LongComparator;
+import it.unimi.dsi.fastutil.longs.LongLinkedOpenHashSet;
+import org.slf4j.Logger;
+import java.lang.reflect.Field;
+import java.util.Arrays;
+import java.util.Comparator;
+import java.util.Locale;
+
+public final class MCVersionRegistry {
@ -401,8 +400,9 @@ index 0000000000000000000000000000000000000000..31dc32c7464badfd7c6e5a7060b65935
+ 3090,
+ 3093,
+ 3094,
+ 3097
+ // All up to 1.19-pre1
+ 3097,
+ 3108
+ // All up to 1.19.1-pre2
+ };
+ Arrays.sort(converterVersions);
+
@ -495,7 +495,7 @@ index 0000000000000000000000000000000000000000..31dc32c7464badfd7c6e5a7060b65935
+ }
+ }
+
+ DATA_VERSION_LIST.sort(Comparator.naturalOrder());
+ DATA_VERSION_LIST.sort((LongComparator)null);
+
+ for (final int version : DATACONVERTER_VERSIONS_MAJOR) {
+ DATACONVERTER_VERSIONS.add(DataConverter.encodeVersions(version, 0));
@ -565,10 +565,10 @@ index 0000000000000000000000000000000000000000..31dc32c7464badfd7c6e5a7060b65935
+}
diff --git a/src/main/java/ca/spottedleaf/dataconverter/minecraft/MCVersions.java b/src/main/java/ca/spottedleaf/dataconverter/minecraft/MCVersions.java
new file mode 100644
index 0000000000000000000000000000000000000000..18bcb79899a5ccb63096cba8075d64381c6c8f23
index 0000000000000000000000000000000000000000..51f869ba58b3f113017a3c32f68896b6d572dc7b
--- /dev/null
+++ b/src/main/java/ca/spottedleaf/dataconverter/minecraft/MCVersions.java
@@ -0,0 +1,418 @@
@@ -0,0 +1,423 @@
+package ca.spottedleaf.dataconverter.minecraft;
+
+@SuppressWarnings("unused")
@ -986,6 +986,11 @@ index 0000000000000000000000000000000000000000..18bcb79899a5ccb63096cba8075d6438
+ public static final int V1_19_PRE5 = 3102;
+ public static final int V1_19_RC1 = 3103;
+ public static final int V1_19_RC2 = 3104;
+ public static final int V1_19 = 3105;
+ public static final int V22W24A = 3106;
+ public static final int V1_19_1_PRE1 = 3107;
+ public static final int V1_19_1_RC1 = 3109;
+ public static final int V1_19_1_PRE2 = 3110;
+}
diff --git a/src/main/java/ca/spottedleaf/dataconverter/minecraft/converters/advancements/ConverterAbstractAdvancementsRename.java b/src/main/java/ca/spottedleaf/dataconverter/minecraft/converters/advancements/ConverterAbstractAdvancementsRename.java
new file mode 100644
@ -6548,10 +6553,10 @@ index 0000000000000000000000000000000000000000..76a6e3efa5c69150e8f5e0063cb6357b
+}
diff --git a/src/main/java/ca/spottedleaf/dataconverter/minecraft/datatypes/MCTypeRegistry.java b/src/main/java/ca/spottedleaf/dataconverter/minecraft/datatypes/MCTypeRegistry.java
new file mode 100644
index 0000000000000000000000000000000000000000..efe8161af64277cf7ed9c3af00a34b782d7ed4e3
index 0000000000000000000000000000000000000000..602c210df505613482bb4b1bbb782c0d8d6a32c8
--- /dev/null
+++ b/src/main/java/ca/spottedleaf/dataconverter/minecraft/datatypes/MCTypeRegistry.java
@@ -0,0 +1,235 @@
@@ -0,0 +1,236 @@
+package ca.spottedleaf.dataconverter.minecraft.datatypes;
+
+import ca.spottedleaf.dataconverter.minecraft.versions.*;
@ -6783,6 +6788,7 @@ index 0000000000000000000000000000000000000000..efe8161af64277cf7ed9c3af00a34b78
+ V3093.register();
+ V3094.register();
+ V3097.register();
+ V3108.register();
+ }
+
+ private MCTypeRegistry() {}
@ -17386,10 +17392,10 @@ index 0000000000000000000000000000000000000000..8cc7cadb921d52ebb5b8ed2507814553
+}
diff --git a/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V3088.java b/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V3088.java
new file mode 100644
index 0000000000000000000000000000000000000000..61c1424d8ee55b43d320ea8148d860f089026bb4
index 0000000000000000000000000000000000000000..d21124f6e70c887b9ca67305c8b0c1f4668af8e2
--- /dev/null
+++ b/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V3088.java
@@ -0,0 +1,63 @@
@@ -0,0 +1,67 @@
+package ca.spottedleaf.dataconverter.minecraft.versions;
+
+import ca.spottedleaf.dataconverter.converters.DataConverter;
@ -17431,6 +17437,10 @@ index 0000000000000000000000000000000000000000..61c1424d8ee55b43d320ea8148d860f0
+ @Override
+ public MapType<String> convert(final MapType<String> data, final long sourceVersion, final long toVersion) {
+ data.remove("blending_data");
+ final MapType<String> context = data.getMap("__context");
+ if (!"minecraft:overworld".equals(context == null ? null : context.getString("dimension"))) {
+ return null;
+ }
+
+ final String status = NamespaceUtil.correctNamespace(data.getString("Status"));
+ if (status == null) {
@ -17625,6 +17635,39 @@ index 0000000000000000000000000000000000000000..d5ac17b59c0dcc9baaeff022ecbf827c
+ MCTypeRegistry.POI_CHUNK.addStructureConverter(new ConverterPoiDelete(VERSION, poiRemove::contains));
+ }
+}
diff --git a/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V3108.java b/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V3108.java
new file mode 100644
index 0000000000000000000000000000000000000000..381b49f2c50d46e52f7f9c8f6baede4e72eb343d
--- /dev/null
+++ b/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V3108.java
@@ -0,0 +1,27 @@
+package ca.spottedleaf.dataconverter.minecraft.versions;
+
+import ca.spottedleaf.dataconverter.converters.DataConverter;
+import ca.spottedleaf.dataconverter.minecraft.MCVersions;
+import ca.spottedleaf.dataconverter.minecraft.datatypes.MCTypeRegistry;
+import ca.spottedleaf.dataconverter.types.MapType;
+
+public final class V3108 {
+
+ private static final int VERSION = MCVersions.V1_19_1_PRE1 + 1;
+
+ public static void register() {
+ MCTypeRegistry.CHUNK.addStructureConverter(new DataConverter<>(VERSION) {
+ @Override
+ public MapType<String> convert(final MapType<String> data, final long sourceVersion, final long toVersion) {
+ final MapType<String> context = data.getMap("__context");
+ if ("minecraft:overworld".equals(context == null ? null : context.getString("dimension"))) {
+ return null;
+ }
+
+ data.remove("blending_data");
+
+ return null;
+ }
+ });
+ }
+}
diff --git a/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V501.java b/src/main/java/ca/spottedleaf/dataconverter/minecraft/versions/V501.java
new file mode 100644
index 0000000000000000000000000000000000000000..6ab2bf99d72983fc2742a1f6f2f7fa671611526d