Fix a handful of 1.19.3 compile issues (#8615)

This commit is contained in:
Noah van der Aa 2022-12-07 22:36:56 +01:00 committed by GitHub
parent 4710881e40
commit f207880ec8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
8 changed files with 49 additions and 100 deletions

View File

@ -934,7 +934,7 @@ index 0000000000000000000000000000000000000000..69add4a7f1147015806bc9b63a8340d1
+}
diff --git a/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
new file mode 100644
index 0000000000000000000000000000000000000000..e731de3ac158c5a4cff236c6f5001674cd488a77
index 0000000000000000000000000000000000000000..9db94ec0cd508a13e86c56e991b9c853a103520d
--- /dev/null
+++ b/src/main/java/io/papermc/paper/configuration/PaperConfigurations.java
@@ -0,0 +1,435 @@
@ -969,7 +969,7 @@ index 0000000000000000000000000000000000000000..e731de3ac158c5a4cff236c6f5001674
+import it.unimi.dsi.fastutil.objects.Reference2IntOpenHashMap;
+import it.unimi.dsi.fastutil.objects.Reference2LongMap;
+import it.unimi.dsi.fastutil.objects.Reference2LongOpenHashMap;
+import net.minecraft.core.Registry;
+import net.minecraft.core.registries.Registries;
+import net.minecraft.resources.ResourceLocation;
+import net.minecraft.server.MinecraftServer;
+import net.minecraft.server.level.ServerLevel;
@ -1151,10 +1151,10 @@ index 0000000000000000000000000000000000000000..e731de3ac158c5a4cff236c6f5001674
+ .register(Duration.SERIALIZER)
+ .register(EngineMode.SERIALIZER)
+ .register(FallbackValueSerializer.create(contextMap.require(SPIGOT_WORLD_CONFIG_CONTEXT_KEY).get(), MinecraftServer::getServer))
+ .register(new RegistryValueSerializer<>(new TypeToken<EntityType<?>>() {}, Registry.ENTITY_TYPE_REGISTRY, true))
+ .register(new RegistryValueSerializer<>(Item.class, Registry.ITEM_REGISTRY, true))
+ .register(new RegistryHolderSerializer<>(new TypeToken<ConfiguredFeature<?, ?>>() {}, Registry.CONFIGURED_FEATURE_REGISTRY, false))
+ .register(new RegistryHolderSerializer<>(Item.class, Registry.ITEM_REGISTRY, true))
+ .register(new RegistryValueSerializer<>(new TypeToken<EntityType<?>>() {}, Registries.ENTITY_TYPE, true))
+ .register(new RegistryValueSerializer<>(Item.class, Registries.ITEM, true))
+ .register(new RegistryHolderSerializer<>(new TypeToken<ConfiguredFeature<?, ?>>() {}, Registries.CONFIGURED_FEATURE, false))
+ .register(new RegistryHolderSerializer<>(Item.class, Registries.ITEM, true))
+ )
+ );
+ }
@ -1444,7 +1444,7 @@ index 0000000000000000000000000000000000000000..1bb16fc7598cd53e822d84b69d6a9727
+}
diff --git a/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
new file mode 100644
index 0000000000000000000000000000000000000000..5982dda61e07f1661b0a68d0ba1fcc1122e8d428
index 0000000000000000000000000000000000000000..7e1add0f18da3ac2d93b084979d419cf45d2bca3
--- /dev/null
+++ b/src/main/java/io/papermc/paper/configuration/WorldConfiguration.java
@@ -0,0 +1,471 @@
@ -1477,7 +1477,7 @@ index 0000000000000000000000000000000000000000..5982dda61e07f1661b0a68d0ba1fcc11
+import java.util.stream.Collectors;
+import net.minecraft.Util;
+import net.minecraft.core.Holder;
+import net.minecraft.core.Registry;
+import net.minecraft.core.registries.BuiltInRegistries;
+import net.minecraft.resources.ResourceLocation;
+import net.minecraft.world.Difficulty;
+import net.minecraft.world.entity.EntityType;
@ -1857,7 +1857,7 @@ index 0000000000000000000000000000000000000000..5982dda61e07f1661b0a68d0ba1fcc11
+ public int fixedChunkInhabitedTime = -1;
+ public boolean preventMovingIntoUnloadedChunks = false;
+ public Duration delayChunkUnloadsBy = Duration.of("10s");
+ public Reference2IntMap<EntityType<?>> entityPerChunkSaveLimit = Util.make(new Reference2IntOpenHashMap<>(Registry.ENTITY_TYPE.size()), map -> {
+ public Reference2IntMap<EntityType<?>> entityPerChunkSaveLimit = Util.make(new Reference2IntOpenHashMap<>(BuiltInRegistries.ENTITY_TYPE.size()), map -> {
+ map.defaultReturnValue(-1);
+ map.put(EntityType.EXPERIENCE_ORB, -1);
+ map.put(EntityType.SNOWBALL, -1);

View File

@ -3113,7 +3113,7 @@ index 446fdca49a5a6999626a7ee3a1d5c168b15a09dd..f9863e138994f6c7a7975a852f106faa
public boolean isOp() {
return true;
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index d2be98416529aea3bdbedd0ea7131bd8de2a0162..bcfa8474413a5c149c126f53a446422b4fa540fa 100644
index d2be98416529aea3bdbedd0ea7131bd8de2a0162..e12b4ec0d14901a0246cfea16c65fb046c7a4f6c 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -277,14 +277,39 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
@ -3136,7 +3136,7 @@ index d2be98416529aea3bdbedd0ea7131bd8de2a0162..bcfa8474413a5c149c126f53a446422b
+ getHandle().listName = name == null ? null : io.papermc.paper.adventure.PaperAdventure.asVanilla(name);
+ for (ServerPlayer player : server.getHandle().players) {
+ if (player.getBukkitEntity().canSee(this)) {
+ player.connection.send(new ClientboundPlayerInfoPacket(ClientboundPlayerInfoPacket.Action.UPDATE_DISPLAY_NAME, getHandle()));
+ player.connection.send(new ClientboundPlayerInfoUpdatePacket(ClientboundPlayerInfoUpdatePacket.Action.UPDATE_DISPLAY_NAME, getHandle()));
+ }
+ }
+ }
@ -3358,7 +3358,7 @@ index d2be98416529aea3bdbedd0ea7131bd8de2a0162..bcfa8474413a5c149c126f53a446422b
+ @Override
+ public void sendMessage(final net.kyori.adventure.identity.Identity identity, final net.kyori.adventure.text.Component message, final net.kyori.adventure.audience.MessageType type) {
+ if (getHandle().connection == null) return;
+ final net.minecraft.core.Registry<net.minecraft.network.chat.ChatType> chatTypeRegistry = this.getHandle().level.registryAccess().registryOrThrow(net.minecraft.core.Registry.CHAT_TYPE_REGISTRY);
+ final net.minecraft.core.Registry<net.minecraft.network.chat.ChatType> chatTypeRegistry = this.getHandle().level.registryAccess().registryOrThrow(net.minecraft.core.registries.Registries.CHAT_TYPE);
+ this.getHandle().connection.send(new net.minecraft.network.protocol.game.ClientboundSystemChatPacket(message, false));
+ }
+
@ -3465,11 +3465,11 @@ index d2be98416529aea3bdbedd0ea7131bd8de2a0162..bcfa8474413a5c149c126f53a446422b
+ @Override
+ public void playSound(final net.kyori.adventure.sound.Sound sound, final double x, final double y, final double z) {
+ final ResourceLocation name = io.papermc.paper.adventure.PaperAdventure.asVanilla(sound.name());
+ final java.util.Optional<net.minecraft.sounds.SoundEvent> event = net.minecraft.core.Registry.SOUND_EVENT.getOptional(name);
+ final java.util.Optional<net.minecraft.sounds.SoundEvent> event = BuiltInRegistries.SOUND_EVENT.getOptional(name);
+ if (event.isPresent()) {
+ this.getHandle().connection.send(new ClientboundSoundPacket(event.get(), io.papermc.paper.adventure.PaperAdventure.asVanilla(sound.source()), x, y, z, sound.volume(), sound.pitch(), this.getHandle().getRandom().nextLong())); // TODO adventure sound seed
+ this.getHandle().connection.send(new ClientboundSoundEntityPacket(BuiltInRegistries.SOUND_EVENT.wrapAsHolder(event.get()), io.papermc.paper.adventure.PaperAdventure.asVanilla(sound.source()), entity, sound.volume(), sound.pitch(), this.getHandle().getRandom().nextLong())); // TODO adventure sound seed
+ } else {
+ this.getHandle().connection.send(new ClientboundCustomSoundPacket(name, io.papermc.paper.adventure.PaperAdventure.asVanilla(sound.source()), new Vec3(x, y, z), sound.volume(), sound.pitch(), this.getHandle().getRandom().nextLong())); // TODO adventure sound seed
+ this.getHandle().connection.send(new ClientboundSoundPacket(Holder.direct(SoundEvent.createVariableRangeEvent(name)), io.papermc.paper.adventure.PaperAdventure.asVanilla(sound.source()), x, y, z, sound.volume(), sound.pitch(), this.getHandle().getRandom().nextLong())); // TODO adventure sound seed
+ }
+ }
+
@ -3485,11 +3485,11 @@ index d2be98416529aea3bdbedd0ea7131bd8de2a0162..bcfa8474413a5c149c126f53a446422b
+ }
+
+ final ResourceLocation name = io.papermc.paper.adventure.PaperAdventure.asVanilla(sound.name());
+ final java.util.Optional<net.minecraft.sounds.SoundEvent> event = net.minecraft.core.Registry.SOUND_EVENT.getOptional(name);
+ final java.util.Optional<net.minecraft.sounds.SoundEvent> event = BuiltInRegistries.SOUND_EVENT.getOptional(name);
+ if (event.isPresent()) {
+ this.getHandle().connection.send(new net.minecraft.network.protocol.game.ClientboundSoundEntityPacket(event.get(), io.papermc.paper.adventure.PaperAdventure.asVanilla(sound.source()), entity, sound.volume(), sound.pitch(), this.getHandle().getRandom().nextLong())); // TODO adventure sound seed
+ this.getHandle().connection.send(new net.minecraft.network.protocol.game.ClientboundSoundEntityPacket(BuiltInRegistries.SOUND_EVENT.wrapAsHolder(event.get()), io.papermc.paper.adventure.PaperAdventure.asVanilla(sound.source()), entity, sound.volume(), sound.pitch(), this.getHandle().getRandom().nextLong())); // TODO adventure sound seed
+ } else {
+ this.getHandle().connection.send(new ClientboundCustomSoundPacket(name, io.papermc.paper.adventure.PaperAdventure.asVanilla(sound.source()), entity.position(), sound.volume(), sound.pitch(), this.getHandle().getRandom().nextLong())); // TODO adventure sound seed
+ this.getHandle().connection.send(new ClientboundSoundPacket(Holder.direct(SoundEvent.createVariableRangeEvent(name)), io.papermc.paper.adventure.PaperAdventure.asVanilla(sound.source()), entity.position().x(), entity.position().y(), entity.position().z(), sound.volume(), sound.pitch(), this.getHandle().getRandom().nextLong())); // TODO adventure sound seed
+ }
+ }
+

View File

@ -5031,15 +5031,13 @@ index 80b98e6667f1a0c21d019c58a8a0d4cc5b0f48e1..8033c8741a0f73919a357893652592b3
super(wrapped.getPos(), UpgradeData.EMPTY, wrapped.levelHeightAccessor, wrapped.getLevel().registryAccess().registryOrThrow(Registries.BIOME), wrapped.getBlendingData());
this.wrapped = wrapped;
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
index 49f091183111958ebd3fb56964fc5d728c16755c..6f99f4acfdac5516dac07a6c9af220eed5c5358e 100644
index 49f091183111958ebd3fb56964fc5d728c16755c..be181106a223f6bb824ddf58690674617c6dacb5 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -92,7 +92,11 @@ public class LevelChunk extends ChunkAccess {
}
@@ -93,6 +93,10 @@ public class LevelChunk extends ChunkAccess {
public LevelChunk(Level world, ChunkPos pos, UpgradeData upgradeData, LevelChunkTicks<Block> blockTickScheduler, LevelChunkTicks<Fluid> fluidTickScheduler, long inhabitedTime, @Nullable LevelChunkSection[] sectionArrayInitializer, @Nullable LevelChunk.PostLoadProcessor entityLoader, @Nullable BlendingData blendingData) {
- super(pos, upgradeData, world, world.registryAccess().registryOrThrow(Registries.BIOME), inhabitedTime, sectionArrayInitializer, blendingData);
+ super(pos, upgradeData, world, world.registryAccess().registryOrThrow(Registries.BIOME)), inhabitedTime, sectionArrayInitializer, blendingData);
super(pos, upgradeData, world, world.registryAccess().registryOrThrow(Registries.BIOME), inhabitedTime, sectionArrayInitializer, blendingData);
+ // Paper start - rewrite light engine
+ this.setBlockNibbles(ca.spottedleaf.starlight.common.light.StarLightEngine.getFilledEmptyLight(world));
+ this.setSkyNibbles(ca.spottedleaf.starlight.common.light.StarLightEngine.getFilledEmptyLight(world));

View File

@ -6883,7 +6883,7 @@ index 0000000000000000000000000000000000000000..53ddd7e9ac05e6a9eb809f329796e6d4
+}
diff --git a/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkLoadTask.java b/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkLoadTask.java
new file mode 100644
index 0000000000000000000000000000000000000000..2410210739420ca7b384633dd7560759f04743c7
index 0000000000000000000000000000000000000000..3df793f7e6bb67f40e7387a72fdafb912a7b1373
--- /dev/null
+++ b/src/main/java/io/papermc/paper/chunk/system/scheduling/ChunkLoadTask.java
@@ -0,0 +1,499 @@
@ -6898,7 +6898,7 @@ index 0000000000000000000000000000000000000000..2410210739420ca7b384633dd7560759
+import io.papermc.paper.chunk.system.io.RegionFileIOThread;
+import io.papermc.paper.chunk.system.poi.PoiChunk;
+import net.minecraft.SharedConstants;
+import net.minecraft.core.Registry;
+import net.minecraft.core.registries.Registries;
+import net.minecraft.nbt.CompoundTag;
+import net.minecraft.server.level.ChunkMap;
+import net.minecraft.server.level.ServerLevel;
@ -7220,7 +7220,7 @@ index 0000000000000000000000000000000000000000..2410210739420ca7b384633dd7560759
+ private ProtoChunk getEmptyChunk() {
+ return new ProtoChunk(
+ new ChunkPos(this.chunkX, this.chunkZ), UpgradeData.EMPTY, this.world,
+ this.world.registryAccess().registryOrThrow(Registry.BIOME_REGISTRY), (BlendingData)null
+ this.world.registryAccess().registryOrThrow(Registries.BIOME), (BlendingData)null
+ );
+ }
+
@ -12730,7 +12730,7 @@ index b7399e29094c66c88a6f4c0e996a906bcaa3b4ca..e600563a9d2ddbfa37c106481decb13e
DedicatedServer dedicatedserver1 = new DedicatedServer(optionset, worldLoader.get(), thread, convertable_conversionsession, resourcepackrepository, worldstem, dedicatedserversettings, DataFixers.getDataFixer(), services, LoggerChunkProgressListener::new);
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index ea35461400b55243a46989f1bbd57b428298e7a1..11fd961b2b522920ceb5cde7dbf5cc197044836a 100644
index 2737dfbf4d978f2bb118cb996ea5c6920decab90..e9f4ffec4b659f3300daa0138f6e955a8d97786d 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -298,7 +298,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
@ -16702,7 +16702,7 @@ index bf66cdb94daa6657e9415adfa16d16983b258ee3..d3fe4f948d7ad8268f143c98211ef89b
public int getIndex() {
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
index 6f99f4acfdac5516dac07a6c9af220eed5c5358e..652da141c3ae19c4de790dea1477f9c3f4c0dee1 100644
index be181106a223f6bb824ddf58690674617c6dacb5..8c2b562e46a35369389da453012b7af570145380 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -183,6 +183,43 @@ public class LevelChunk extends ChunkAccess {
@ -16919,7 +16919,7 @@ index 6f99f4acfdac5516dac07a6c9af220eed5c5358e..652da141c3ae19c4de790dea1477f9c3
public void setFullStatus(Supplier<ChunkHolder.FullChunkStatus> levelTypeProvider) {
diff --git a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
index 942f8db571cf87d0e9614bdc7dd9525068cf1001..40cde4021c585aee4a4d7ac39e7ab043aba51418 100644
index a3c14a470ac7055abd00ac6f4f1c02065a485d3b..b8cf01fbfc3293bf78b1094a90da3594fa2067b4 100644
--- a/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
+++ b/src/main/java/net/minecraft/world/level/chunk/storage/ChunkSerializer.java
@@ -94,7 +94,31 @@ public class ChunkSerializer {
@ -18004,7 +18004,7 @@ index e91305263fcf6929fe62e5e8da46721707b51517..3ad15c0909d14c6f974e9bf82055c3c3
// Spigot start
private final org.bukkit.World.Spigot spigot = new org.bukkit.World.Spigot()
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index a41b9663c2ec5a5ec9fc593531141edc7c48751e..af45674e2aff3756813834e866a0e4f9e4b361f5 100644
index 091346c2cbe7f7cf0173072343f796afe2a0f4c5..ae51e7bbbded0f317fc344a6f0fe9cb1451f5649 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -176,6 +176,81 @@ public class CraftPlayer extends CraftHumanEntity implements Player {

View File

@ -27,7 +27,7 @@ index bb5c4ecd43aa344dfe9cca8ab7c2ebf9760e94cf..203786383387765d1f5a2d2ccce79d79
playerName = gameProfile.getName();
uniqueId = gameProfile.getId();
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 865ba836d8a62fa08786e41f8434eb322885e965..32170da591ac2430ac08e327d759e3d7ea70f2df 100644
index fb1e740b2a44c5f4b2d638303fc4f30b6aac08a2..b4a511c8c701949c614a7fd5a7b3e51d278dc27a 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -81,6 +81,7 @@ import net.minecraft.world.entity.ai.attributes.Attributes;
@ -132,7 +132,7 @@ index 865ba836d8a62fa08786e41f8434eb322885e965..32170da591ac2430ac08e327d759e3d7
+
+ //Respawn the player then update their position and selected slot
+ ServerLevel worldserver = handle.getLevel();
+ connection.send(new net.minecraft.network.protocol.game.ClientboundRespawnPacket(worldserver.dimensionTypeId(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), handle.gameMode.getGameModeForPlayer(), handle.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), true, this.getHandle().getLastDeathLocation()));
+ connection.send(new net.minecraft.network.protocol.game.ClientboundRespawnPacket(worldserver.dimensionTypeId(), worldserver.dimension(), BiomeManager.obfuscateSeed(worldserver.getSeed()), handle.gameMode.getGameModeForPlayer(), handle.gameMode.getPreviousGameModeForPlayer(), worldserver.isDebug(), worldserver.isFlat(), (byte) 1, this.getHandle().getLastDeathLocation()));
+ handle.onUpdateAbilities();
+ connection.internalTeleport(loc.getX(), loc.getY(), loc.getZ(), loc.getYaw(), loc.getPitch(), java.util.Collections.emptySet(), false);
+ net.minecraft.server.MinecraftServer.getServer().getPlayerList().sendAllPlayerInfo(handle);

View File

@ -1178,14 +1178,14 @@ index 508c2fff8d8e0c6f37b6c4e3b72ba772c2ab2ee5..e254b2d04e4fc1dc76c26f61ea38aeb2
}
diff --git a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
index ef0be4f5ce7f07e38dea9eb356e049bd121c82dd..7b28537fda4187036b15ecc04f68ac1c9bf5f67f 100644
index b4c76e53eef8dc0efec98848352a243931ffc1f3..7b28537fda4187036b15ecc04f68ac1c9bf5f67f 100644
--- a/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
+++ b/src/main/java/net/minecraft/world/level/chunk/LevelChunk.java
@@ -93,7 +93,7 @@ public class LevelChunk extends ChunkAccess {
}
public LevelChunk(Level world, ChunkPos pos, UpgradeData upgradeData, LevelChunkTicks<Block> blockTickScheduler, LevelChunkTicks<Fluid> fluidTickScheduler, long inhabitedTime, @Nullable LevelChunkSection[] sectionArrayInitializer, @Nullable LevelChunk.PostLoadProcessor entityLoader, @Nullable BlendingData blendingData) {
- super(pos, upgradeData, world, world.registryAccess().registryOrThrow(Registries.BIOME)), inhabitedTime, sectionArrayInitializer, blendingData);
- super(pos, upgradeData, world, world.registryAccess().registryOrThrow(Registries.BIOME), inhabitedTime, sectionArrayInitializer, blendingData);
+ super(pos, upgradeData, world, net.minecraft.server.MinecraftServer.getServer().registryAccess().registryOrThrow(Registries.BIOME), inhabitedTime, sectionArrayInitializer, blendingData); // Paper - Anti-Xray - The world isn't ready yet, use server singleton for registry
// Paper start - rewrite light engine
this.setBlockNibbles(ca.spottedleaf.starlight.common.light.StarLightEngine.getFilledEmptyLight(world));

View File

@ -57,7 +57,7 @@ index 65637a33ba171a4b598f70cd943d24b0ee44a69f..57a9146bf2dee7a60aab16716e25348f
}
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 96f6eb2b152d1183ee45cb0b77c9c77ae8e03950..5567689b642ca591bacd47d5d613191caee97e3d 100644
index 96f6eb2b152d1183ee45cb0b77c9c77ae8e03950..647be350a7fcd74b1ae82811e6977c9899ce9543 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -362,7 +362,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@ -115,13 +115,13 @@ index 96f6eb2b152d1183ee45cb0b77c9c77ae8e03950..5567689b642ca591bacd47d5d613191c
public void disconnect(final Component reason) {
- this.disconnect(PaperAdventure.asAdventure(reason));
+ this.disconnect(PaperAdventure.asAdventure(reason), org.bukkit.event.player.PlayerKickEvent.Cause.UNKNOWN);
+ }
+
+ public void disconnect(final Component reason, PlayerKickEvent.Cause cause) {
+ this.disconnect(PaperAdventure.asAdventure(reason), cause);
}
- public void disconnect(net.kyori.adventure.text.Component reason) {
+ public void disconnect(final Component reason, PlayerKickEvent.Cause cause) {
+ this.disconnect(PaperAdventure.asAdventure(reason), cause);
+ }
+
+ public void disconnect(net.kyori.adventure.text.Component reason, org.bukkit.event.player.PlayerKickEvent.Cause cause) {
// Paper end
// CraftBukkit start - fire PlayerKickEvent
@ -267,40 +267,7 @@ index 96f6eb2b152d1183ee45cb0b77c9c77ae8e03950..5567689b642ca591bacd47d5d613191c
return Optional.empty();
} else if (this.player.isRemoved() || this.player.getChatVisibility() == ChatVisiblity.HIDDEN) { // CraftBukkit - dead men tell no tales
this.send(new ClientboundSystemChatPacket(Component.translatable("chat.disabled.options").withStyle(ChatFormatting.RED), false));
@@ -2428,6 +2438,32 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
this.detectRateSpam(s); // Spigot
}
+<<<<<<< HEAD
+=======
+ private boolean verifyChatMessage(PlayerChatMessage message) {
+ ChatSender chatsender = this.player.asChatSender();
+ ProfilePublicKey profilepublickey = chatsender.profilePublicKey();
+
+ if (profilepublickey != null) {
+ if (profilepublickey.data().hasExpired()) {
+ this.player.sendSystemMessage(Component.translatable("chat.disabled.expiredProfileKey").withStyle(ChatFormatting.RED));
+ return false;
+ }
+
+ if (!message.verify(chatsender)) {
+ this.disconnect(Component.translatable("multiplayer.disconnect.unsigned_chat"), org.bukkit.event.player.PlayerKickEvent.Cause.UNSIGNED_CHAT); // Paper - kick event cause
+ return false;
+ }
+ }
+
+ if (message.hasExpiredServer(Instant.now())) {
+ ServerGamePacketListenerImpl.LOGGER.warn("{} sent expired chat: '{}'. Is the client/server system time unsynchronized?", this.player.getName().getString(), message.signedContent().plain());
+ }
+
+ return true;
+ }
+
+>>>>>>> Add PlayerKickEvent causes
// Spigot start - spam exclusions
private void detectRateSpam(String s) {
// CraftBukkit start - replaced with thread safe throttle
@@ -2444,7 +2480,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@@ -2444,7 +2454,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
// this.chatSpamTickCount += 20;
if (this.chatSpamTickCount.addAndGet(20) > 200 && !this.server.getPlayerList().isOp(this.player.getGameProfile())) {
// CraftBukkit end
@ -309,23 +276,7 @@ index 96f6eb2b152d1183ee45cb0b77c9c77ae8e03950..5567689b642ca591bacd47d5d613191c
}
}
@@ -2460,6 +2496,15 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
}
}
+<<<<<<< HEAD
+=======
+
+ }
+
+ private void handleValidationFailure(Set<LastSeenMessagesValidator.ErrorCondition> reasons) {
+ ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message from {}, reasons: {}", this.player.getName().getString(), reasons.stream().map(LastSeenMessagesValidator.ErrorCondition::message).collect(Collectors.joining(",")));
+ this.disconnect(Component.translatable("multiplayer.disconnect.chat_validation_failed"), org.bukkit.event.player.PlayerKickEvent.Cause.CHAT_VALIDATION_FAILED); // Paper - kick event cause
+>>>>>>> Add PlayerKickEvent causes
}
@Override
@@ -2597,7 +2642,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@@ -2597,7 +2607,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
}
if (i > 4096) {
@ -334,7 +285,7 @@ index 96f6eb2b152d1183ee45cb0b77c9c77ae8e03950..5567689b642ca591bacd47d5d613191c
}
}
@@ -2621,7 +2666,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@@ -2621,7 +2631,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
// Spigot Start
if ( entity == this.player && !this.player.isSpectator() )
{
@ -343,7 +294,7 @@ index 96f6eb2b152d1183ee45cb0b77c9c77ae8e03950..5567689b642ca591bacd47d5d613191c
return;
}
// Spigot End
@@ -2718,7 +2763,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@@ -2718,7 +2728,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
// CraftBukkit end
}
} else {
@ -352,7 +303,7 @@ index 96f6eb2b152d1183ee45cb0b77c9c77ae8e03950..5567689b642ca591bacd47d5d613191c
ServerGamePacketListenerImpl.LOGGER.warn("Player {} tried to attack an invalid entity", ServerGamePacketListenerImpl.this.player.getName().getString());
}
}
@@ -3126,7 +3171,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@@ -3126,7 +3136,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
// Paper start
if (!org.bukkit.Bukkit.isPrimaryThread()) {
if (recipeSpamPackets.addAndGet(io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.recipeSpamIncrement) > io.papermc.paper.configuration.GlobalConfiguration.get().spamLimiter.recipeSpamLimit) {
@ -361,7 +312,7 @@ index 96f6eb2b152d1183ee45cb0b77c9c77ae8e03950..5567689b642ca591bacd47d5d613191c
return;
}
}
@@ -3334,7 +3379,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@@ -3334,7 +3344,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
} else if (!this.isSingleplayerOwner()) {
// Paper start - This needs to be handled on the main thread for plugins
server.submit(() -> {
@ -370,7 +321,7 @@ index 96f6eb2b152d1183ee45cb0b77c9c77ae8e03950..5567689b642ca591bacd47d5d613191c
});
// Paper end
}
@@ -3380,7 +3425,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@@ -3380,7 +3390,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
}
} catch (Exception ex) {
ServerGamePacketListenerImpl.LOGGER.error("Couldn\'t register custom payload", ex);
@ -379,7 +330,7 @@ index 96f6eb2b152d1183ee45cb0b77c9c77ae8e03950..5567689b642ca591bacd47d5d613191c
}
} else if (packet.identifier.equals(CUSTOM_UNREGISTER)) {
try {
@@ -3390,7 +3435,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@@ -3390,7 +3400,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
}
} catch (Exception ex) {
ServerGamePacketListenerImpl.LOGGER.error("Couldn\'t unregister custom payload", ex);
@ -388,7 +339,7 @@ index 96f6eb2b152d1183ee45cb0b77c9c77ae8e03950..5567689b642ca591bacd47d5d613191c
}
} else {
try {
@@ -3408,7 +3453,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@@ -3408,7 +3418,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
this.cserver.getMessenger().dispatchIncomingMessage(this.player.getBukkitEntity(), packet.identifier.toString(), data);
} catch (Exception ex) {
ServerGamePacketListenerImpl.LOGGER.error("Couldn\'t dispatch custom payload", ex);
@ -422,7 +373,7 @@ index 16210f30249ecc83c92e0374f7821693a9fd27c1..20598ef01293d8889145921cb3c5a9c7
// CraftBukkit end
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 45ad8545b5b8bf5b1ba0eb5ee2c602b34fc6a138..49501e3cb2e604655f0c6eba38d07855b7632cbf 100644
index 9ad9ef67eb6e8ef9bde99882839c0d5518651147..99d4f032418cfc3e1cf836f1c68717ad414809a3 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -599,7 +599,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {

View File

@ -5,10 +5,10 @@ Subject: [PATCH] Adds PlayerArmSwingEvent
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index cdbab53cff509b308ab8dfc4c70f27037bbbe948..bf11a9ad6d777c7634b5c02b0122528c9c05302a 100644
index 92198b4546ef0d90fc9bf8e493914bc1e57a7741..10e58f9bbd8e695859bc1477a863d2df36c33912 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -2529,7 +2529,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@@ -2494,7 +2494,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
}
// Arm swing animation