patches and patches

This commit is contained in:
Jason Penilla 2021-06-13 01:26:58 -07:00
parent 9a7acfee26
commit 4ec60d8958
33 changed files with 126 additions and 202 deletions

View file

@ -1,44 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Aikar <aikar@aikar.co>
Date: Thu, 28 Feb 2019 00:15:28 -0500
Subject: [PATCH] Fix sign edit memory leak
when a player edits a sign, a reference to their Entity is never cleand up.
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
SignBlockEntity tileentitysign = (SignBlockEntity) tileentity;
- if (!tileentitysign.isEditable() || tileentitysign.getPlayerWhoMayEdit() != this.player) {
+ if (!tileentitysign.isEditable() || tileentitysign.signEditor == null || !tileentitysign.signEditor.equals(this.player.getUUID())) {
ServerGamePacketListenerImpl.LOGGER.warn("Player {} just tried to change non-editable sign", this.player.getName().getString());
this.send(tileentity.getUpdatePacket()); // CraftBukkit
return;
diff --git a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/SignBlockEntity.java
@@ -0,0 +0,0 @@ public class SignBlockEntity extends BlockEntity implements CommandSource { // C
private Player playerWhoMayEdit;
private final FormattedCharSequence[] renderMessages;
private DyeColor color;
+ public java.util.UUID signEditor; // Paper
public SignBlockEntity() {
super(BlockEntityType.SIGN);
@@ -0,0 +0,0 @@ public class SignBlockEntity extends BlockEntity implements CommandSource { // C
}
public void setAllowedPlayerEditor(Player player) {
- this.playerWhoMayEdit = player;
+ // Paper start
+ //this.c = entityhuman;
+ signEditor = player != null ? player.getUUID() : null;
+ // Paper end
}
public Player getPlayerWhoMayEdit() {

View file

@ -19,7 +19,7 @@ diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/ma
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -0,0 +0,0 @@ public class ServerPlayer extends Player implements ContainerListener {
@@ -0,0 +0,0 @@ public class ServerPlayer extends Player {
public int latency;
public boolean wonGame;
private int containerUpdateDelay; // Paper
@ -44,7 +44,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
@@ -0,0 +0,0 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
return getData() != null;
return this.getData() != null;
}
+ // Paper start
@ -104,7 +104,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
@Override
public Location getBedSpawnLocation() {
CompoundTag data = getData();
CompoundTag data = this.getData();
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@ -134,7 +134,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end
+
public void readExtraData(CompoundTag nbttagcompound) {
hasPlayedBefore = true;
this.hasPlayedBefore = true;
if (nbttagcompound.contains("bukkit")) {
@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
}
@ -146,7 +146,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
nbttagcompound.put("bukkit", new CompoundTag());
}
@@ -0,0 +0,0 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
data.putLong("firstPlayed", getFirstPlayed());
data.putLong("firstPlayed", this.getFirstPlayed());
data.putLong("lastPlayed", System.currentTimeMillis());
data.putString("lastKnownName", handle.getScoreboardName());
+

View file

@ -38,7 +38,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java
@@ -0,0 +0,0 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
this.getPacketListener().a(new TranslatableComponent("multiplayer.disconnect.generic"));
this.getPacketListener().onDisconnect(new TranslatableComponent("multiplayer.disconnect.generic"));
}
this.queue.clear(); // Free up packet queue.
+ // Paper start - Add PlayerConnectionCloseEvent
@ -70,13 +70,14 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
@@ -0,0 +0,0 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener
private final byte[] nonce = new byte[4];
private final MinecraftServer server;
final MinecraftServer server;
public final Connection connection;
- private ServerLoginPacketListenerImpl.State state;
+ private ServerLoginPacketListenerImpl.State state; public final ServerLoginPacketListenerImpl.State getLoginState() { return this.state; }; // Paper - OBFHELPER
- ServerLoginPacketListenerImpl.State state;
+ ServerLoginPacketListenerImpl.State state; public final ServerLoginPacketListenerImpl.State getLoginState() { return this.state; }; // Paper - OBFHELPER
private int tick;
- private GameProfile gameProfile; private void setGameProfile(final GameProfile profile) { this.gameProfile = profile; } private GameProfile getGameProfile() { return this.gameProfile; } // Paper - OBFHELPER
+ private GameProfile gameProfile; private void setGameProfile(final GameProfile profile) { this.gameProfile = profile; } public GameProfile getGameProfile() { return this.gameProfile; } // Paper - OBFHELPER
@Nullable
- GameProfile gameProfile;
+ GameProfile gameProfile; private void setGameProfile(final GameProfile profile) { this.gameProfile = profile; } public GameProfile getGameProfile() { return this.gameProfile; } // Paper - OBFHELPER
private final String serverId;
private SecretKey secretKey;
@Nullable
private ServerPlayer delayedAcceptPlayer;

View file

@ -33,41 +33,41 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
+ public boolean shouldBurnInDay() { return isSunSensitive(); } // Paper - OBFHELPER
+ public boolean isSunSensitivePublic() { return this.isSunSensitive(); } // Paper - public getter
protected boolean isSunSensitive() {
- return true;
+ return this.shouldBurnInDay; // Paper - use api value instead
+ }
+
}
+ // Paper start
+ public void setShouldBurnInDay(boolean shouldBurnInDay) {
+ this.shouldBurnInDay = shouldBurnInDay;
}
+ }
+ // Paper end
+
@Override
public boolean hurt(DamageSource source, float amount) {
if (!super.hurt(source, amount)) {
@@ -0,0 +0,0 @@ public class Zombie extends Monster {
tag.putBoolean("CanBreakDoors", this.canBreakDoors());
tag.putInt("InWaterTime", this.isInWater() ? this.inWaterTime : -1);
tag.putInt("DrownedConversionTime", this.isUnderWaterConverting() ? this.conversionTime : -1);
+ tag.putBoolean("Paper.ShouldBurnInDay", shouldBurnInDay); // Paper
nbt.putBoolean("CanBreakDoors", this.canBreakDoors());
nbt.putInt("InWaterTime", this.isInWater() ? this.inWaterTime : -1);
nbt.putInt("DrownedConversionTime", this.isUnderWaterConverting() ? this.conversionTime : -1);
+ nbt.putBoolean("Paper.ShouldBurnInDay", this.shouldBurnInDay); // Paper
}
@Override
@@ -0,0 +0,0 @@ public class Zombie extends Monster {
if (tag.contains("DrownedConversionTime", 99) && tag.getInt("DrownedConversionTime") > -1) {
this.startUnderWaterConversion(tag.getInt("DrownedConversionTime"));
if (nbt.contains("DrownedConversionTime", 99) && nbt.getInt("DrownedConversionTime") > -1) {
this.startUnderWaterConversion(nbt.getInt("DrownedConversionTime"));
}
-
+ // Paper start
+ if (tag.contains("Paper.ShouldBurnInDay")) {
+ shouldBurnInDay = tag.getBoolean("Paper.ShouldBurnInDay");
+ if (nbt.contains("Paper.ShouldBurnInDay")) {
+ this.shouldBurnInDay = nbt.getBoolean("Paper.ShouldBurnInDay");
+ }
+ // Paper end
}
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java
@ -94,7 +94,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+
+ @Override
+ public boolean shouldBurnInDay() {
+ return getHandle().shouldBurnInDay();
+ return getHandle().isSunSensitivePublic();
+ }
+
+ @Override

View file

@ -14,8 +14,8 @@ diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -0,0 +0,0 @@ import net.minecraft.network.protocol.Packet;
import net.minecraft.network.protocol.game.ClientboundSetBorderPacket;
@@ -0,0 +0,0 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.protocol.Packet;
import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation;
+import net.minecraft.server.MCUtil;

View file

@ -10,28 +10,30 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
@@ -0,0 +0,0 @@ public class PaperConfig {
velocitySecretKey = secret.getBytes(StandardCharsets.UTF_8);
}
}
+
+ public static int maxBookPageSize = 2560;
+ public static double maxBookTotalSizeMultiplier = 0.98D;
+ private static void maxBookSize() {
+ maxBookPageSize = getInt("settings.book-size.page-max", maxBookPageSize);
+ maxBookTotalSizeMultiplier = getDouble("settings.book-size.total-multiplier", maxBookTotalSizeMultiplier);
+ }
}
+
public static boolean asyncChunks = false;
private static void asyncChunks() {
ConfigurationSection section;
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
@Override
public void handleEditBook(ServerboundEditBookPacket packet) {
+ // Paper start
+ ItemStack testStack = packet.getBook();
+ if (!craftServer.isPrimaryThread() && !testStack.isEmpty() && testStack.getTag() != null) {
+ if (!this.cserver.isPrimaryThread() && !testStack.isEmpty() && testStack.getTag() != null) {
+ ListTag pageList = testStack.getTag().getList("pages", 8);
+ if (pageList.size() > 100) {
+ ServerGamePacketListenerImpl.LOGGER.warn(this.player.getScoreboardName() + " tried to send a book with too many pages");

View file

@ -40,7 +40,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
this.isDestroyingBlock = false;
- if (!Objects.equals(this.destroyPos, pos)) {
+ if (!Objects.equals(this.destroyPos, pos) && !BlockPos.ZERO.equals(this.destroyPos)) {
ServerPlayerGameMode.LOGGER.debug("Mismatch in destroy block pos: " + this.destroyPos + " " + pos); // CraftBukkit - SPIGOT-5457 sent by client when interact event cancelled
ServerPlayerGameMode.LOGGER.debug("Mismatch in destroy block pos: {} {}", this.destroyPos, pos); // CraftBukkit - SPIGOT-5457 sent by client when interact event cancelled
- this.level.destroyBlockProgress(this.player.getId(), this.destroyPos, -1);
- this.player.connection.send(new ClientboundBlockBreakAckPacket(this.destroyPos, this.level.getBlockState(this.destroyPos), action, true, "aborted mismatched destroying"));
+ BlockState type = this.level.getTypeIfLoaded(this.destroyPos); // Paper - don't load unloaded chunks for stale records here
@ -54,7 +54,7 @@ diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListener
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
case START_DESTROY_BLOCK:
case ABORT_DESTROY_BLOCK:
case STOP_DESTROY_BLOCK:
@ -63,6 +63,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return;
+ }
+ // Paper end - Don't allow digging in unloaded chunks
this.player.gameMode.handleBlockBreakAction(blockposition, packetplayinblockdig_enumplayerdigtype, packet.getDirection(), this.server.getMaxBuildHeight());
this.player.gameMode.handleBlockBreakAction(blockposition, packetplayinblockdig_enumplayerdigtype, packet.getDirection(), this.player.level.getMaxBuildHeight());
return;
default:

View file

@ -22,8 +22,8 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ co.aikar.util.Counter<ItemStack> matchedProvided = new co.aikar.util.Counter<>();
+ co.aikar.util.Counter<Ingredient> matchedIngredients = new co.aikar.util.Counter<>();
+ // Paper end
for (int j = 0; j < inv.getContainerSize(); ++j) {
ItemStack itemstack = inv.getItem(j);
for (int j = 0; j < inventory.getContainerSize(); ++j) {
ItemStack itemstack = inventory.getItem(j);
if (!itemstack.isEmpty()) {
- ++i;
@ -65,4 +65,4 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ // Paper end
}
public ItemStack assemble(CraftingContainer inv) {
public ItemStack assemble(CraftingContainer inventory) {

View file

@ -5,18 +5,6 @@ Subject: [PATCH] Fix SpongeAbsortEvent handling
Only process drops when the block is actually going to be removed
diff --git a/src/main/java/net/minecraft/world/level/block/Block.java b/src/main/java/net/minecraft/world/level/block/Block.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/Block.java
+++ b/src/main/java/net/minecraft/world/level/block/Block.java
@@ -0,0 +0,0 @@ public class Block extends BlockBehaviour implements ItemLike {
}
+ public static void dropNaturally(BlockState iblockdata, LevelAccessor generatoraccess, BlockPos blockposition, @Nullable BlockEntity tileentity) { dropResources(iblockdata, generatoraccess, blockposition, tileentity); }
public static void dropResources(BlockState state, LevelAccessor world, BlockPos pos, @Nullable BlockEntity blockEntity) {
if (world instanceof ServerLevel) {
getDrops(state, (ServerLevel) world, pos, blockEntity).forEach((itemstack) -> {
diff --git a/src/main/java/net/minecraft/world/level/block/SpongeBlock.java b/src/main/java/net/minecraft/world/level/block/SpongeBlock.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/block/SpongeBlock.java
@ -24,12 +12,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
@@ -0,0 +0,0 @@ public class SpongeBlock extends Block {
// NOP
} else if (material == Material.WATER_PLANT || material == Material.REPLACEABLE_WATER_PLANT) {
BlockEntity tileentity = iblockdata.getBlock().isEntityBlock() ? world.getBlockEntity(blockposition2) : null;
BlockEntity tileentity = iblockdata.hasBlockEntity() ? world.getBlockEntity(blockposition2) : null;
-
- dropResources(iblockdata, world, blockposition2, tileentity);
+ // Paper start
+ if (block.getHandle().getMaterial() == Material.AIR) {
+ dropNaturally(iblockdata, world, blockposition2, tileentity);
+ dropResources(iblockdata, world, blockposition2, tileentity);
+ }
+ // Paper end
}

View file

@ -10,20 +10,12 @@ diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java
@@ -0,0 +0,0 @@ import io.netty.channel.epoll.EpollEventLoopGroup;
import io.netty.channel.local.LocalChannel;
import io.netty.channel.local.LocalServerChannel;
import io.netty.channel.nio.NioEventLoopGroup;
+import io.netty.handler.codec.EncoderException; // Paper
import io.netty.handler.timeout.TimeoutException;
import io.netty.util.AttributeKey;
import io.netty.util.concurrent.Future;
@@ -0,0 +0,0 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
}
public void exceptionCaught(ChannelHandlerContext channelhandlercontext, Throwable throwable) {
+ // Paper start
+ if (throwable instanceof EncoderException && throwable.getCause() instanceof PacketEncoder.PacketTooLargeException) {
+ if (throwable instanceof io.netty.handler.codec.EncoderException && throwable.getCause() instanceof PacketEncoder.PacketTooLargeException) {
+ if (((PacketEncoder.PacketTooLargeException) throwable.getCause()).getPacket().packetTooLarge(this)) {
+ return;
+ } else {
@ -39,12 +31,12 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
--- a/src/main/java/net/minecraft/network/PacketEncoder.java
+++ b/src/main/java/net/minecraft/network/PacketEncoder.java
@@ -0,0 +0,0 @@ public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
throw throwable;
throw var9;
}
}
+
+ // Paper start
+ int packetLength = bytebuf.readableBytes();
+ int packetLength = friendlyByteBuf.readableBytes();
+ if (packetLength > MAX_PACKET_SIZE) {
+ throw new PacketTooLargeException(packet, packetLength);
+ }
@ -79,7 +71,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
void handle(T listener);
+ // Paper start
+ default boolean packetTooLarge(NetworkManager manager) {
+ default boolean packetTooLarge(net.minecraft.network.Connection manager) {
+ return false;
+ }
+ // Paper end
@ -91,40 +83,33 @@ diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundContai
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java
@@ -0,0 +0,0 @@ import java.io.IOException;
import java.util.Iterator;
import java.util.List;
import net.minecraft.core.NonNullList;
+import net.minecraft.network.Connection;
import net.minecraft.network.FriendlyByteBuf;
import net.minecraft.network.protocol.Packet;
import net.minecraft.world.item.ItemStack;
@@ -0,0 +0,0 @@ public class ClientboundContainerSetContentPacket implements Packet<ClientGamePa
private int containerId;
private List<ItemStack> items;
private final int containerId;
private final List<ItemStack> items;
+ //Paper start
+ @Override
+ public boolean packetTooLarge(Connection manager) {
+ public boolean packetTooLarge(net.minecraft.network.Connection manager) {
+ for (int i = 0 ; i < this.items.size() ; i++) {
+ manager.send(new ClientboundContainerSetSlotPacket(this.containerId, i, this.items.get(i)));
+ }
+ return true;
+ }
+ // Paper end
public ClientboundContainerSetContentPacket() {}
+
public ClientboundContainerSetContentPacket(int syncId, NonNullList<ItemStack> contents) {
this.containerId = syncId;
this.items = NonNullList.withSize(contents.size(), ItemStack.EMPTY);
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacket.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacket.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacket.java
@@ -0,0 +0,0 @@ public class ClientboundLevelChunkPacket implements Packet<ClientGamePacketListe
int i = buf.readVarInt();
- if (i > 2097152) {
+ if (i > 2097152) { // Paper - if this changes, update PacketEncoder
throw new RuntimeException("Chunk Packet trying to allocate too much memory on read.");
} else {
this.buffer = new byte[i];
this.biomes = buf.readVarIntArray(ChunkBiomeContainer.MAX_SIZE);
int i = buf.readVarInt();
- if (i > 2097152) {
+ if (i > 2097152) { // Paper - diff on change - if this changes, update PacketEncoder
throw new RuntimeException("Chunk Packet trying to allocate too much memory on read.");
} else {
this.buffer = new byte[i];

View file

@ -23,70 +23,58 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+import net.minecraft.server.ServerWorkerThread;
import net.minecraft.util.datafix.DataFixers;
import net.minecraft.world.level.block.state.properties.Property;
import org.apache.logging.log4j.LogManager;
import org.apache.commons.io.IOUtils;
@@ -0,0 +0,0 @@ import org.apache.logging.log4j.Logger;
public class Util {
public class Util {
private static final AtomicInteger WORKER_COUNT = new AtomicInteger(1);
- private static final ExecutorService BOOTSTRAP_EXECUTOR = makeExecutor("Bootstrap");
- private static final ExecutorService BACKGROUND_EXECUTOR = makeExecutor("Main");
+ private static final ExecutorService BOOTSTRAP_EXECUTOR = a("Bootstrap", -2); // Paper - add -2 priority
+ private static final ExecutorService BACKGROUND_EXECUTOR = a("Main", -1); // Paper - add -1 priority
+ private static final ExecutorService BOOTSTRAP_EXECUTOR = makeExecutor("Bootstrap", -2); // Paper - add -2 priority
+ private static final ExecutorService BACKGROUND_EXECUTOR = makeExecutor("Main", -1); // Paper - add -1 priority
private static final ExecutorService IO_POOL = makeIoExecutor();
public static LongSupplier timeSource = System::nanoTime;
public static final UUID NIL_UUID = new UUID(0L, 0L); public static final UUID getNullUUID() {return NIL_UUID;} // Paper OBFHELPER
public static final UUID NIL_UUID = new UUID(0L, 0L);
@@ -0,0 +0,0 @@ public class Util {
return Instant.now().toEpochMilli();
}
- private static ExecutorService makeExecutor(String name) {
- int i = Mth.clamp(Runtime.getRuntime().availableProcessors() - 1, 1, 7);
- Object object;
+ private static ExecutorService a(String s, int priorityModifier) { // Paper - add priority
+ private static ExecutorService makeExecutor(String s, int priorityModifier) { // Paper - add priority
+ // Paper start - use simpler thread pool that allows 1 thread
+ int i = Math.min(8, Math.max(Runtime.getRuntime().availableProcessors() - 2, 1));
+ i = Integer.getInteger("Paper.WorkerThreadCount", i);
+ ExecutorService object;
ExecutorService executorService;
+
if (i <= 0) {
object = MoreExecutors.newDirectExecutorService();
executorService = MoreExecutors.newDirectExecutorService();
} else {
- object = new ForkJoinPool(i, (forkjoinpool) -> {
- ForkJoinWorkerThread forkjoinworkerthread = new ForkJoinWorkerThread(forkjoinpool) {
+ object = new java.util.concurrent.ThreadPoolExecutor(i, i,0L, TimeUnit.MILLISECONDS, new java.util.concurrent.LinkedBlockingQueue<Runnable>(), target -> new ServerWorkerThread(target, s, priorityModifier));
- executorService = new ForkJoinPool(i, (forkJoinPool) -> {
- ForkJoinWorkerThread forkJoinWorkerThread = new ForkJoinWorkerThread(forkJoinPool) {
+ executorService = new java.util.concurrent.ThreadPoolExecutor(i, i,0L, TimeUnit.MILLISECONDS, new java.util.concurrent.LinkedBlockingQueue<Runnable>(), target -> new ServerWorkerThread(target, s, priorityModifier));
+ }
+ /*
@Override
protected void onTermination(Throwable throwable) {
if (throwable != null) {
- Util.LOGGER.warn("{} died", this.getName(), throwable);
+ SystemUtils.LOGGER.warn("{} died", this.getName(), throwable);
} else {
- Util.LOGGER.debug("{} shutdown", this.getName());
+ SystemUtils.LOGGER.debug("{} shutdown", this.getName());
}
super.onTermination(throwable);
}
};
- forkjoinworkerthread.setName("Worker-" + name + "-" + Util.WORKER_COUNT.getAndIncrement());
+ forkjoinworkerthread.setName("Worker-" + s + "-" + SystemUtils.c.getAndIncrement());
return forkjoinworkerthread;
- }, Util::onThreadException, true);
+ }, SystemUtils::a, true);
@@ -0,0 +0,0 @@ public class Util {
return forkJoinWorkerThread;
}, Util::onThreadException, true);
}
+ }*/ // Paper end
return (ExecutorService) object;
return executorService;
}
@@ -0,0 +0,0 @@ public class Util {
});
throw t instanceof RuntimeException ? (RuntimeException)t : new RuntimeException(t);
}
+ public static void onThreadError(Thread thread, Throwable throwable) { onThreadException(thread, throwable); } // Paper - OBFHELPER
private static void onThreadException(Thread thread, Throwable throwable) {
pauseInIde(throwable);
if (throwable instanceof CompletionException) {
- private static void onThreadException(Thread thread, Throwable t) {
+ public static void onThreadException(Thread thread, Throwable t) { // Paper - make public
pauseInIde(t);
if (t instanceof CompletionException) {
t = t.getCause();
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java
@ -116,6 +104,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ super(target, "Worker-" + poolName + "-" + threadId.getAndIncrement());
+ setPriority(Thread.NORM_PRIORITY+prioritityModifier); // Deprioritize over main
+ this.setDaemon(true);
+ this.setUncaughtExceptionHandler(Util::onThreadError);
+ this.setUncaughtExceptionHandler(Util::onThreadException);
+ }
+}

View file

@ -25,7 +25,7 @@ diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListener
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
private int aboveGroundVehicleTickCount;
private int receivedMovePacketCount;
private int knownMovePacketCount;
@ -33,22 +33,26 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
private static final long KEEPALIVE_LIMIT = Long.getLong("paper.playerconnection.keepalive", 30) * 1000; // Paper - provide property to set keepalive limit
public ServerGamePacketListenerImpl(MinecraftServer server, Connection connection, ServerPlayer player) {
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener {
@@ -0,0 +0,0 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
List<net.kyori.adventure.text.Component> lines = new java.util.ArrayList<>();
for (int i = 0; i < list.size(); ++i) {
- lines.add(net.kyori.adventure.text.Component.text(SharedConstants.filterAllowedChatCharacters(list.get(i)))); // Paper - Replaced with anvil color stripping method to stop exploits that allow colored signs to be created.
+ // Paper start - cap line length - modified clients can send longer data than normal
+ String currentLine = list.get(i);
+ if (MAX_SIGN_LINE_LENGTH > 0 && currentLine.length() > MAX_SIGN_LINE_LENGTH) {
+ net.minecraft.server.network.TextFilter.FilteredText currentLine = list.get(i);
+ if (MAX_SIGN_LINE_LENGTH > 0 && currentLine.getRaw().length() > MAX_SIGN_LINE_LENGTH) {
+ // This handles multibyte characters as 1
+ int offset = currentLine.codePoints().limit(MAX_SIGN_LINE_LENGTH).map(Character::charCount).sum();
+ if (offset < currentLine.length()) {
+ list.set(i, currentLine = currentLine.substring(0, offset));
+ int offset = currentLine.getRaw().codePoints().limit(MAX_SIGN_LINE_LENGTH).map(Character::charCount).sum();
+ if (offset < currentLine.getRaw().length()) {
+ list.set(i, currentLine = net.minecraft.server.network.TextFilter.FilteredText.passThrough(currentLine.getRaw().substring(0, offset))); // this will break any filtering, but filtering is NYI as of 1.17
+ }
+ }
+ // Paper end
+ lines.add(net.kyori.adventure.text.Component.text(SharedConstants.filterAllowedChatCharacters(currentLine))); // Paper - Replaced with anvil color stripping method to stop exploits that allow colored signs to be created.
if (this.player.isTextFilteringEnabled()) {
- lines.add(net.kyori.adventure.text.Component.text(SharedConstants.filterText(list.get(i).getFiltered())));
+ lines.add(net.kyori.adventure.text.Component.text(SharedConstants.filterText(currentLine.getFiltered())));
} else {
- lines.add(net.kyori.adventure.text.Component.text(SharedConstants.filterText(list.get(i).getRaw())));
+ lines.add(net.kyori.adventure.text.Component.text(SharedConstants.filterText(currentLine.getRaw())));
}
}
SignChangeEvent event = new SignChangeEvent(org.bukkit.craftbukkit.block.CraftBlock.at(worldserver, blockposition), this.getPlayer(), lines);
this.craftServer.getPluginManager().callEvent(event);
SignChangeEvent event = new SignChangeEvent((org.bukkit.craftbukkit.block.CraftBlock) player.getWorld().getBlockAt(x, y, z), this.cserver.getPlayer(this.player), lines);

View file

@ -8,16 +8,6 @@ diff --git a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java b/sr
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
+++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
@@ -0,0 +0,0 @@ public class EnderMan extends Monster implements NeutralMob {
int j = Mth.floor(this.enderman.getY() + random.nextDouble() * 3.0D);
int k = Mth.floor(this.enderman.getZ() - 2.0D + random.nextDouble() * 4.0D);
BlockPos blockposition = new BlockPos(i, j, k);
- BlockState iblockdata = world.getBlockState(blockposition);
+ BlockState iblockdata = world.getTypeIfLoaded(blockposition); // Paper
+ if (iblockdata == null) return; // Paper
Block block = iblockdata.getBlock();
Vec3 vec3d = new Vec3((double) Mth.floor(this.enderman.getX()) + 0.5D, (double) j + 0.5D, (double) Mth.floor(this.enderman.getZ()) + 0.5D);
Vec3 vec3d1 = new Vec3((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D);
@@ -0,0 +0,0 @@ public class EnderMan extends Monster implements NeutralMob {
int j = Mth.floor(this.enderman.getY() + random.nextDouble() * 2.0D);
int k = Mth.floor(this.enderman.getZ() - 1.0D + random.nextDouble() * 2.0D);
@ -28,3 +18,13 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
BlockPos blockposition1 = blockposition.below();
BlockState iblockdata1 = world.getBlockState(blockposition1);
BlockState iblockdata2 = this.enderman.getCarriedBlock();
@@ -0,0 +0,0 @@ public class EnderMan extends Monster implements NeutralMob {
int j = Mth.floor(this.enderman.getY() + random.nextDouble() * 3.0D);
int k = Mth.floor(this.enderman.getZ() - 2.0D + random.nextDouble() * 4.0D);
BlockPos blockposition = new BlockPos(i, j, k);
- BlockState iblockdata = world.getBlockState(blockposition);
+ BlockState iblockdata = world.getTypeIfLoaded(blockposition); // Paper
+ if (iblockdata == null) return; // Paper
Vec3 vec3d = new Vec3((double) this.enderman.getBlockX() + 0.5D, (double) j + 0.5D, (double) this.enderman.getBlockZ() + 0.5D);
Vec3 vec3d1 = new Vec3((double) i + 0.5D, (double) j + 0.5D, (double) k + 0.5D);
BlockHitResult movingobjectpositionblock = world.clip(new ClipContext(vec3d, vec3d1, ClipContext.Block.OUTLINE, ClipContext.Fluid.NONE, this.enderman));

View file

@ -10,7 +10,7 @@ diff --git a/src/main/java/net/minecraft/world/level/BlockGetter.java b/src/main
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/level/BlockGetter.java
+++ b/src/main/java/net/minecraft/world/level/BlockGetter.java
@@ -0,0 +0,0 @@ public interface BlockGetter {
@@ -0,0 +0,0 @@ public interface BlockGetter extends LevelHeightAccessor {
// CraftBukkit start - moved block handling into separate method for use by Block#rayTrace
default BlockHitResult rayTraceBlock(ClipContext raytrace1, BlockPos blockposition) {

View file

@ -8,7 +8,7 @@ diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/ma
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -0,0 +0,0 @@ public class ServerPlayer extends Player implements ContainerListener {
@@ -0,0 +0,0 @@ public class ServerPlayer extends Player {
}
this.setHealth(this.getMaxHealth());
@ -20,7 +20,7 @@ diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/jav
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
}

View file

@ -26,10 +26,10 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
public Inventory createInventory(InventoryHolder holder, InventoryType type) {
+ // Paper start
+ if (holder != null) {
+ return DEFAULT_CONVERTER.createInventory(holder, type);
+ return this.DEFAULT_CONVERTER.createInventory(holder, type);
+ }
+ //noinspection ConstantConditions // Paper end
return converterMap.get(type).createInventory(holder, type);
return this.converterMap.get(type).createInventory(holder, type);
}
@@ -0,0 +0,0 @@ public final class CraftInventoryCreator {
@ -41,6 +41,6 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
+ return DEFAULT_CONVERTER.createInventory(holder, type, title);
+ }
+ //noinspection ConstantConditions // Paper end
return converterMap.get(type).createInventory(holder, type, title);
return this.converterMap.get(type).createInventory(holder, type, title);
}

View file

@ -8,7 +8,7 @@ diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/ma
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -0,0 +0,0 @@ public class ServerPlayer extends Player implements ContainerListener {
@@ -0,0 +0,0 @@ public class ServerPlayer extends Player {
public void disconnect() {
this.disconnected = true;
this.ejectPassengers();

View file

@ -23,7 +23,7 @@ diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/ma
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -0,0 +0,0 @@ public class ServerPlayer extends Player implements ContainerListener {
@@ -0,0 +0,0 @@ public class ServerPlayer extends Player {
}
}
@ -44,7 +44,7 @@ diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/jav
index 0000000000000000000000000000000000000000..0000000000000000000000000000000000000000 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
}
@ -62,7 +62,7 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
}
}
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
return true; // CraftBukkit
}
@ -74,16 +74,16 @@ index 0000000000000000000000000000000000000000..00000000000000000000000000000000
if (entity.getVehicle() == this) {
throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)");
} else {
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s
if (getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity) {
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
if (this.getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity) {
VehicleExitEvent event = new VehicleExitEvent(
(Vehicle) getBukkitEntity(),
(Vehicle) this.getBukkitEntity(),
- (LivingEntity) entity.getBukkitEntity()
+ (LivingEntity) entity.getBukkitEntity(), !suppressCancellation // Paper
);
// Suppress during worldgen
if (this.valid) {
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s
@@ -0,0 +0,0 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
}
// CraftBukkit end
// Spigot start