13
0
geforkt von Mirrors/Paper

patches and patches

Dieser Commit ist enthalten in:
Jason Penilla 2021-06-13 01:26:58 -07:00
Ursprung 79f1d1a078
Commit 41a5f14f9e
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: 0E75A301420E48F8
34 geänderte Dateien mit 231 neuen und 261 gelöschten Zeilen

Datei anzeigen

@ -5,7 +5,7 @@ Subject: [PATCH] Make the default permission message configurable
diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java diff --git a/src/main/java/org/bukkit/Bukkit.java b/src/main/java/org/bukkit/Bukkit.java
index 6b619b85fee86ccc599cb46d789e39b81af3201c..dcaefdaf5a0de8486f59115c8c4d4c211b7d64cd 100644 index 1f4532e60abe62b88472a9bb0ef8d1af1f921220..a69e0b0c9f515256c6406ef8ff55f72c98dabe0d 100644
--- a/src/main/java/org/bukkit/Bukkit.java --- a/src/main/java/org/bukkit/Bukkit.java
+++ b/src/main/java/org/bukkit/Bukkit.java +++ b/src/main/java/org/bukkit/Bukkit.java
@@ -1793,6 +1793,15 @@ public final class Bukkit { @@ -1793,6 +1793,15 @@ public final class Bukkit {
@ -25,7 +25,7 @@ index 6b619b85fee86ccc599cb46d789e39b81af3201c..dcaefdaf5a0de8486f59115c8c4d4c21
* Creates a PlayerProfile for the specified uuid, with name as null * Creates a PlayerProfile for the specified uuid, with name as null
* @param uuid UUID to create profile for * @param uuid UUID to create profile for
diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java diff --git a/src/main/java/org/bukkit/Server.java b/src/main/java/org/bukkit/Server.java
index c642fe9cfae6407404f5cf17264f42ef83a01280..9b8e6b7bbbed44e2659379c8046acaa35aaa8910 100644 index ca4e2d3b27f629e0d5e672fc915a5d03f0c0581d..17f8dd9870a47227a7c9bb09cceedb94f7190ead 100644
--- a/src/main/java/org/bukkit/Server.java --- a/src/main/java/org/bukkit/Server.java
+++ b/src/main/java/org/bukkit/Server.java +++ b/src/main/java/org/bukkit/Server.java
@@ -1575,6 +1575,13 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi @@ -1575,6 +1575,13 @@ public interface Server extends PluginMessageRecipient, net.kyori.adventure.audi

Datei anzeigen

@ -5,6 +5,8 @@ Subject: [PATCH] Fix sign edit memory leak
when a player edits a sign, a reference to their Entity is never cleand up. when a player edits a sign, a reference to their Entity is never cleand up.
removed 1.17 - mojang uses a UUID instead of a player field now
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index b1c505d3fdcc2fb3496f80bee85e4895b9069dcb..276773e17149f57038cd21485fd9d9061670ff2d 100644 index b1c505d3fdcc2fb3496f80bee85e4895b9069dcb..276773e17149f57038cd21485fd9d9061670ff2d 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java

Datei anzeigen

@ -1,37 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Sat, 10 Nov 2018 05:15:21 +0000
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 9d2e4adddae481735053c64eec0ee7259c61f1a4..fca5d175cbef24fb0ee2d0bbedc8d1c0af3eb528 100644
--- a/src/main/java/net/minecraft/world/level/block/Block.java
+++ b/src/main/java/net/minecraft/world/level/block/Block.java
@@ -228,6 +228,7 @@ 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 c453963ec90cd4eeec845fd0c2137e60dfdd6225..1895c75deee8da40624ba3abbd08ba7cd4f0f503 100644
--- a/src/main/java/net/minecraft/world/level/block/SpongeBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/SpongeBlock.java
@@ -128,8 +128,11 @@ 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;
-
- dropResources(iblockdata, world, blockposition2, tileentity);
+ // Paper start
+ if (block.getHandle().getMaterial() == Material.AIR) {
+ dropNaturally(iblockdata, world, blockposition2, tileentity);
+ }
+ // Paper end
}
}
world.setBlock(blockposition2, block.getHandle(), block.getFlag());

Datei anzeigen

@ -5,10 +5,10 @@ Subject: [PATCH] Reset players airTicks on respawn
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 92139b271eb6c305787662ef8c7d221fb42296f7..b68acf219fc61e2ea811d0c732393824fa44db2d 100644 index b2324b53b3cec3e577a8ec8c45b113c232d220a6..5eb37fb1ae861940839fe6815b57111812d6b3ec 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -2159,6 +2159,7 @@ public class ServerPlayer extends Player implements ContainerListener { @@ -2210,6 +2210,7 @@ public class ServerPlayer extends Player {
} }
this.setHealth(this.getMaxHealth()); this.setHealth(this.getMaxHealth());
@ -17,10 +17,10 @@ index 92139b271eb6c305787662ef8c7d221fb42296f7..b68acf219fc61e2ea811d0c732393824
this.fallDistance = 0; this.fallDistance = 0;
this.foodData = new FoodData(this); this.foodData = new FoodData(this);
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index e7fed1f8bb8ffb164ddcdab51f41c369d6e3103d..460c6fd61bb45247715d99445821e15e98e4c465 100644 index 0974781e2f7fc541eaf397de033fb12b87dbf8ba..c3bbe8429ee792b881953c5894a55505cdba63d3 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java --- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -2354,6 +2354,7 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s @@ -2585,6 +2585,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
} }

Datei anzeigen

@ -12,10 +12,10 @@ server threads
Allow usage of a single thread executor by not using ForkJoin so single core CPU's. Allow usage of a single thread executor by not using ForkJoin so single core CPU's.
diff --git a/src/main/java/net/minecraft/Util.java b/src/main/java/net/minecraft/Util.java diff --git a/src/main/java/net/minecraft/Util.java b/src/main/java/net/minecraft/Util.java
index 7b36274718b7cce24ac00530697f145648d52590..cec5ad5052c8cf6059e9b117117846bdb217748f 100644 index 6f29d1fc437764a75d592ccb0c0ddc0593a89967..99d52a9643efe38b449b59b6aac81c5b20ed9477 100644
--- a/src/main/java/net/minecraft/Util.java --- a/src/main/java/net/minecraft/Util.java
+++ b/src/main/java/net/minecraft/Util.java +++ b/src/main/java/net/minecraft/Util.java
@@ -45,7 +45,7 @@ import java.util.stream.Stream; @@ -56,7 +56,7 @@ import java.util.stream.Stream;
import javax.annotation.Nullable; import javax.annotation.Nullable;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
import net.minecraft.server.Bootstrap; import net.minecraft.server.Bootstrap;
@ -23,75 +23,63 @@ index 7b36274718b7cce24ac00530697f145648d52590..cec5ad5052c8cf6059e9b117117846bd
+import net.minecraft.server.ServerWorkerThread; +import net.minecraft.server.ServerWorkerThread;
import net.minecraft.util.datafix.DataFixers; import net.minecraft.util.datafix.DataFixers;
import net.minecraft.world.level.block.state.properties.Property; import net.minecraft.world.level.block.state.properties.Property;
import org.apache.logging.log4j.LogManager; import org.apache.commons.io.IOUtils;
@@ -54,8 +54,8 @@ import org.apache.logging.log4j.Logger; @@ -65,8 +65,8 @@ import org.apache.logging.log4j.Logger;
public class Util {
public class Util {
private static final AtomicInteger WORKER_COUNT = new AtomicInteger(1); private static final AtomicInteger WORKER_COUNT = new AtomicInteger(1);
- private static final ExecutorService BOOTSTRAP_EXECUTOR = makeExecutor("Bootstrap"); - private static final ExecutorService BOOTSTRAP_EXECUTOR = makeExecutor("Bootstrap");
- private static final ExecutorService BACKGROUND_EXECUTOR = makeExecutor("Main"); - 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 BOOTSTRAP_EXECUTOR = makeExecutor("Bootstrap", -2); // Paper - add -2 priority
+ private static final ExecutorService BACKGROUND_EXECUTOR = a("Main", -1); // Paper - add -1 priority + private static final ExecutorService BACKGROUND_EXECUTOR = makeExecutor("Main", -1); // Paper - add -1 priority
private static final ExecutorService IO_POOL = makeIoExecutor(); private static final ExecutorService IO_POOL = makeIoExecutor();
public static LongSupplier timeSource = System::nanoTime; 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);
@@ -85,30 +85,34 @@ public class Util { @@ -101,14 +101,18 @@ public class Util {
return Instant.now().toEpochMilli(); return Instant.now().toEpochMilli();
} }
- private static ExecutorService makeExecutor(String name) { - private static ExecutorService makeExecutor(String name) {
- int i = Mth.clamp(Runtime.getRuntime().availableProcessors() - 1, 1, 7); - int i = Mth.clamp(Runtime.getRuntime().availableProcessors() - 1, 1, 7);
- Object object; + private static ExecutorService makeExecutor(String s, int priorityModifier) { // Paper - add priority
+ private static ExecutorService a(String s, int priorityModifier) { // Paper - add priority
+ // Paper start - use simpler thread pool that allows 1 thread + // Paper start - use simpler thread pool that allows 1 thread
+ int i = Math.min(8, Math.max(Runtime.getRuntime().availableProcessors() - 2, 1)); + int i = Math.min(8, Math.max(Runtime.getRuntime().availableProcessors() - 2, 1));
+ i = Integer.getInteger("Paper.WorkerThreadCount", i); + i = Integer.getInteger("Paper.WorkerThreadCount", i);
+ ExecutorService object; ExecutorService executorService;
+
if (i <= 0) { if (i <= 0) {
object = MoreExecutors.newDirectExecutorService(); executorService = MoreExecutors.newDirectExecutorService();
} else { } else {
- object = new ForkJoinPool(i, (forkjoinpool) -> { - executorService = new ForkJoinPool(i, (forkJoinPool) -> {
- ForkJoinWorkerThread forkjoinworkerthread = new ForkJoinWorkerThread(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 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) { protected void onTermination(Throwable throwable) {
if (throwable != null) { if (throwable != null) {
- Util.LOGGER.warn("{} died", this.getName(), throwable); @@ -124,6 +128,7 @@ public class Util {
+ SystemUtils.LOGGER.warn("{} died", this.getName(), throwable); return forkJoinWorkerThread;
} else { }, Util::onThreadException, true);
- 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);
} }
+ }*/ // Paper end + }*/ // Paper end
return (ExecutorService) object; return executorService;
} }
@@ -157,6 +161,7 @@ public class Util { @@ -180,7 +185,7 @@ 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 t) {
private static void onThreadException(Thread thread, Throwable throwable) { + public static void onThreadException(Thread thread, Throwable t) { // Paper - make public
pauseInIde(throwable); pauseInIde(t);
if (throwable instanceof CompletionException) { 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 diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 5a76ca77b974ff6fe862c9e05a88b507a34b44be..5faa8f3cc251b6687e33e40009db98d2aee48f2c 100644 index 24fc2eb3ee067a4164db166aa3e07ecbb426bbba..a302d232da3fbaa2cb3e1903cfd096d404847c54 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java --- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -284,6 +284,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -318,6 +318,7 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
S s0 = serverFactory.apply(thread); // CraftBukkit - decompile error S s0 = serverFactory.apply(thread); // CraftBukkit - decompile error
atomicreference.set(s0); atomicreference.set(s0);
@ -101,7 +89,7 @@ index 5a76ca77b974ff6fe862c9e05a88b507a34b44be..5faa8f3cc251b6687e33e40009db98d2
} }
diff --git a/src/main/java/net/minecraft/server/ServerWorkerThread.java b/src/main/java/net/minecraft/server/ServerWorkerThread.java diff --git a/src/main/java/net/minecraft/server/ServerWorkerThread.java b/src/main/java/net/minecraft/server/ServerWorkerThread.java
new file mode 100644 new file mode 100644
index 0000000000000000000000000000000000000000..4313e21463c16ea9a3edc81763d40702f9d3930b index 0000000000000000000000000000000000000000..480129f430da33157342becb9d3b010f9f7c5edd
--- /dev/null --- /dev/null
+++ b/src/main/java/net/minecraft/server/ServerWorkerThread.java +++ b/src/main/java/net/minecraft/server/ServerWorkerThread.java
@@ -0,0 +1,14 @@ @@ -0,0 +1,14 @@
@ -116,6 +104,6 @@ index 0000000000000000000000000000000000000000..4313e21463c16ea9a3edc81763d40702
+ super(target, "Worker-" + poolName + "-" + threadId.getAndIncrement()); + super(target, "Worker-" + poolName + "-" + threadId.getAndIncrement());
+ setPriority(Thread.NORM_PRIORITY+prioritityModifier); // Deprioritize over main + setPriority(Thread.NORM_PRIORITY+prioritityModifier); // Deprioritize over main
+ this.setDaemon(true); + this.setDaemon(true);
+ this.setUncaughtExceptionHandler(Util::onThreadError); + this.setUncaughtExceptionHandler(Util::onThreadException);
+ } + }
+} +}

Datei anzeigen

@ -8,10 +8,10 @@ the updates per world, so that we can re-use the same packet
object for every player unless they have per-player time enabled. object for every player unless they have per-player time enabled.
diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java diff --git a/src/main/java/net/minecraft/server/MinecraftServer.java b/src/main/java/net/minecraft/server/MinecraftServer.java
index 5faa8f3cc251b6687e33e40009db98d2aee48f2c..6ccc0be795e3ac7689de0eff6f9142d13161a29c 100644 index a302d232da3fbaa2cb3e1903cfd096d404847c54..a1c65ea148692e50dbc466d87dae5198e0b6a51f 100644
--- a/src/main/java/net/minecraft/server/MinecraftServer.java --- a/src/main/java/net/minecraft/server/MinecraftServer.java
+++ b/src/main/java/net/minecraft/server/MinecraftServer.java +++ b/src/main/java/net/minecraft/server/MinecraftServer.java
@@ -1314,12 +1314,24 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa @@ -1387,12 +1387,24 @@ public abstract class MinecraftServer extends ReentrantBlockableEventLoop<TickTa
MinecraftTimings.timeUpdateTimer.startTiming(); // Spigot // Paper MinecraftTimings.timeUpdateTimer.startTiming(); // Spigot // Paper
// Send time updates to everyone, it will get the right time from the world the player is in. // Send time updates to everyone, it will get the right time from the world the player is in.

Datei anzeigen

@ -17,7 +17,7 @@ will always work as intended in the past, those without will create implementati
based inventories. based inventories.
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftInventoryCreator.java b/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftInventoryCreator.java diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftInventoryCreator.java b/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftInventoryCreator.java
index 94d807c5d09f165c6eedd0a1c4026c2b833806a0..3e56de295be0d03dddd3e54fcd7b05d4b9c74dc4 100644 index 0899afd175f969da0df9371d96d3b5e1de4c8533..fc307213a4bc9675c6011a81e4e06cd23a22926d 100644
--- a/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftInventoryCreator.java --- a/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftInventoryCreator.java
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftInventoryCreator.java +++ b/src/main/java/org/bukkit/craftbukkit/inventory/util/CraftInventoryCreator.java
@@ -40,6 +40,11 @@ public final class CraftInventoryCreator { @@ -40,6 +40,11 @@ public final class CraftInventoryCreator {
@ -26,10 +26,10 @@ index 94d807c5d09f165c6eedd0a1c4026c2b833806a0..3e56de295be0d03dddd3e54fcd7b05d4
public Inventory createInventory(InventoryHolder holder, InventoryType type) { public Inventory createInventory(InventoryHolder holder, InventoryType type) {
+ // Paper start + // Paper start
+ if (holder != null) { + if (holder != null) {
+ return DEFAULT_CONVERTER.createInventory(holder, type); + return this.DEFAULT_CONVERTER.createInventory(holder, type);
+ } + }
+ //noinspection ConstantConditions // Paper end + //noinspection ConstantConditions // Paper end
return converterMap.get(type).createInventory(holder, type); return this.converterMap.get(type).createInventory(holder, type);
} }
@@ -55,6 +60,11 @@ public final class CraftInventoryCreator { @@ -55,6 +60,11 @@ public final class CraftInventoryCreator {
@ -41,6 +41,6 @@ index 94d807c5d09f165c6eedd0a1c4026c2b833806a0..3e56de295be0d03dddd3e54fcd7b05d4
+ return DEFAULT_CONVERTER.createInventory(holder, type, title); + return DEFAULT_CONVERTER.createInventory(holder, type, title);
+ } + }
+ //noinspection ConstantConditions // Paper end + //noinspection ConstantConditions // Paper end
return converterMap.get(type).createInventory(holder, type, title); return this.converterMap.get(type).createInventory(holder, type, title);
} }

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] Use Vanilla Minecart Speeds
CraftBukkit changed the values on flying speed, restore back to vanilla CraftBukkit changed the values on flying speed, restore back to vanilla
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
index 7ba74b0a9319e29077b5afe3019a463ed3004813..1257a740a4ab79870fe89057782e8ffc6c658c14 100644 index 1963a47d8b5471aadc6a054854025e270da15f8b..fa889f93a5c6782957bdbf803915cb5e80e05f3e 100644
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java --- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java +++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecart.java
@@ -99,9 +99,9 @@ public abstract class AbstractMinecart extends Entity { @@ -105,9 +105,9 @@ public abstract class AbstractMinecart extends Entity {
private double derailedX = 0.5; private double derailedX = 0.5;
private double derailedY = 0.5; private double derailedY = 0.5;
private double derailedZ = 0.5; private double derailedZ = 0.5;

Datei anzeigen

@ -0,0 +1,25 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Shane Freeder <theboyetronic@gmail.com>
Date: Sat, 10 Nov 2018 05:15:21 +0000
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/SpongeBlock.java b/src/main/java/net/minecraft/world/level/block/SpongeBlock.java
index b8ae2000a44469245c6ba3cda0c0e87b07156b06..1ef8eadd4e59f2e5d2bbd84f6f9bcf37b59db5bd 100644
--- a/src/main/java/net/minecraft/world/level/block/SpongeBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/SpongeBlock.java
@@ -130,8 +130,11 @@ public class SpongeBlock extends Block {
// NOP
} else if (material == Material.WATER_PLANT || material == Material.REPLACEABLE_WATER_PLANT) {
BlockEntity tileentity = iblockdata.hasBlockEntity() ? world.getBlockEntity(blockposition2) : null;
-
- dropResources(iblockdata, world, blockposition2, tileentity);
+ // Paper start
+ if (block.getHandle().getMaterial() == Material.AIR) {
+ dropResources(iblockdata, world, blockposition2, tileentity);
+ }
+ // Paper end
}
}
world.setBlock(blockposition2, block.getHandle(), block.getFlag());

Datei anzeigen

@ -5,10 +5,10 @@ Subject: [PATCH] Don't allow digging into unloaded chunks
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java diff --git a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
index b1a53093eb5b5f359eedb6c252cf6d0d1ae8e409..d97607f2ded4977b253d3afa3bafcbe6d7f98837 100644 index 315dad4789f5f2582ee9b4fc176affd1f57537ef..f4a056185990181e486f452960159a5287947382 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java --- a/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayerGameMode.java
@@ -113,8 +113,8 @@ public class ServerPlayerGameMode { @@ -119,8 +119,8 @@ public class ServerPlayerGameMode {
BlockState iblockdata; BlockState iblockdata;
if (this.hasDelayedDestroy) { if (this.hasDelayedDestroy) {
@ -19,7 +19,7 @@ index b1a53093eb5b5f359eedb6c252cf6d0d1ae8e409..d97607f2ded4977b253d3afa3bafcbe6
this.hasDelayedDestroy = false; this.hasDelayedDestroy = false;
} else { } else {
float f = this.incrementDestroyProgress(iblockdata, this.delayedDestroyPos, this.delayedTickStart); float f = this.incrementDestroyProgress(iblockdata, this.delayedDestroyPos, this.delayedTickStart);
@@ -125,7 +125,13 @@ public class ServerPlayerGameMode { @@ -131,7 +131,13 @@ public class ServerPlayerGameMode {
} }
} }
} else if (this.isDestroyingBlock) { } else if (this.isDestroyingBlock) {
@ -34,13 +34,13 @@ index b1a53093eb5b5f359eedb6c252cf6d0d1ae8e409..d97607f2ded4977b253d3afa3bafcbe6
if (iblockdata.isAir()) { if (iblockdata.isAir()) {
this.level.destroyBlockProgress(this.player.getId(), this.destroyPos, -1); this.level.destroyBlockProgress(this.player.getId(), this.destroyPos, -1);
this.lastSentState = -1; this.lastSentState = -1;
@@ -289,10 +295,12 @@ public class ServerPlayerGameMode { @@ -295,10 +301,12 @@ public class ServerPlayerGameMode {
this.player.connection.send(new ClientboundBlockBreakAckPacket(pos, this.level.getBlockState(pos), action, true, "stopped destroying")); this.player.connection.send(new ClientboundBlockBreakAckPacket(pos, this.level.getBlockState(pos), action, true, "stopped destroying"));
} else if (action == ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK) { } else if (action == ServerboundPlayerActionPacket.Action.ABORT_DESTROY_BLOCK) {
this.isDestroyingBlock = false; this.isDestroyingBlock = false;
- if (!Objects.equals(this.destroyPos, pos)) { - if (!Objects.equals(this.destroyPos, pos)) {
+ if (!Objects.equals(this.destroyPos, pos) && !BlockPos.ZERO.equals(this.destroyPos)) { + 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.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")); - 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 + BlockState type = this.level.getTypeIfLoaded(this.destroyPos); // Paper - don't load unloaded chunks for stale records here
@ -51,10 +51,10 @@ index b1a53093eb5b5f359eedb6c252cf6d0d1ae8e409..d97607f2ded4977b253d3afa3bafcbe6
this.level.destroyBlockProgress(this.player.getId(), pos, -1); this.level.destroyBlockProgress(this.player.getId(), pos, -1);
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index b5593300516fad767f603084aca4abcda4424db3..a6ad7747396f94def688b4d2783137180dc2bb84 100644 index 5f4718fa42be0ade1a40c0472efbbd0c65f061a7..8b716c625c363d7143fe6fbc26d3d674d62a5833 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -1518,6 +1518,11 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener { @@ -1558,6 +1558,11 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
case START_DESTROY_BLOCK: case START_DESTROY_BLOCK:
case ABORT_DESTROY_BLOCK: case ABORT_DESTROY_BLOCK:
case STOP_DESTROY_BLOCK: case STOP_DESTROY_BLOCK:
@ -63,6 +63,6 @@ index b5593300516fad767f603084aca4abcda4424db3..a6ad7747396f94def688b4d278313718
+ return; + return;
+ } + }
+ // Paper end - Don't allow digging in unloaded chunks + // 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; return;
default: default:

Datei anzeigen

@ -6,10 +6,10 @@ Subject: [PATCH] Make the default permission message configurable
TODO: Change the message in PaperCommand TODO: Change the message in PaperCommand
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
index 13edb435b3fa65b4980bd7472aa5a5196f4d5b2b..469f78775b03cf363d88e35c69c0dc185c22547c 100644 index 9768c591e72ce2ef5fdb43e2fc63378c57773216..11d628869a9a6eda8bf21a4f213ff23ad753b18e 100644
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java --- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
@@ -19,6 +19,7 @@ import java.util.regex.Pattern; @@ -20,6 +20,7 @@ import java.util.regex.Pattern;
import com.google.common.collect.Lists; import com.google.common.collect.Lists;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
@ -17,7 +17,7 @@ index 13edb435b3fa65b4980bd7472aa5a5196f4d5b2b..469f78775b03cf363d88e35c69c0dc18
import org.bukkit.command.Command; import org.bukkit.command.Command;
import org.bukkit.configuration.ConfigurationSection; import org.bukkit.configuration.ConfigurationSection;
import org.bukkit.configuration.InvalidConfigurationException; import org.bukkit.configuration.InvalidConfigurationException;
@@ -287,6 +288,11 @@ public class PaperConfig { @@ -288,6 +289,11 @@ public class PaperConfig {
connectionThrottleKickMessage = getString("messages.kick.connection-throttle", connectionThrottleKickMessage); connectionThrottleKickMessage = getString("messages.kick.connection-throttle", connectionThrottleKickMessage);
} }
@ -30,10 +30,10 @@ index 13edb435b3fa65b4980bd7472aa5a5196f4d5b2b..469f78775b03cf363d88e35c69c0dc18
Object val = config.get("settings.save-player-data"); Object val = config.get("settings.save-player-data");
if (val instanceof Boolean) { if (val instanceof Boolean) {
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java diff --git a/src/main/java/org/bukkit/craftbukkit/CraftServer.java b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
index c06b35f114a8d243198b66c44ef57d8c2b201361..590687d5941cbed3a330bcd749f8d52cd4b5e3ae 100644 index 717ad1c24bbc882db8f76cfef7bf847c58914e5a..0448e6b4c512f512bda13f41f1feb58de02fc9d4 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java --- a/src/main/java/org/bukkit/craftbukkit/CraftServer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftServer.java
@@ -2340,6 +2340,11 @@ public final class CraftServer implements Server { @@ -2341,6 +2341,11 @@ public final class CraftServer implements Server {
return com.destroystokyo.paper.PaperConfig.suggestPlayersWhenNullTabCompletions; return com.destroystokyo.paper.PaperConfig.suggestPlayersWhenNullTabCompletions;
} }

Datei anzeigen

@ -7,10 +7,10 @@ ray tracing into an unloaded chunk should be treated as a miss
this saves a ton of lag for when AI tries to raytrace near unloaded chunks. this saves a ton of lag for when AI tries to raytrace near unloaded chunks.
diff --git a/src/main/java/net/minecraft/world/level/BlockGetter.java b/src/main/java/net/minecraft/world/level/BlockGetter.java diff --git a/src/main/java/net/minecraft/world/level/BlockGetter.java b/src/main/java/net/minecraft/world/level/BlockGetter.java
index 2feb187f62be5cf5d354a1e806087417cc189ab1..07fe8e72a7ff01d872dd5b04ccbc435e82ebe990 100644 index e85e4a2dfceb0aa40e73b43a5e122a5906cac585..fe4dba491b586757a16aa36e62682f364daa2602 100644
--- a/src/main/java/net/minecraft/world/level/BlockGetter.java --- a/src/main/java/net/minecraft/world/level/BlockGetter.java
+++ b/src/main/java/net/minecraft/world/level/BlockGetter.java +++ b/src/main/java/net/minecraft/world/level/BlockGetter.java
@@ -58,7 +58,15 @@ public interface BlockGetter { @@ -75,7 +75,15 @@ public interface BlockGetter extends LevelHeightAccessor {
// CraftBukkit start - moved block handling into separate method for use by Block#rayTrace // CraftBukkit start - moved block handling into separate method for use by Block#rayTrace
default BlockHitResult rayTraceBlock(ClipContext raytrace1, BlockPos blockposition) { default BlockHitResult rayTraceBlock(ClipContext raytrace1, BlockPos blockposition) {

Datei anzeigen

@ -7,23 +7,15 @@ If a players inventory is too big to send in a single packet,
split the inventory set into multiple packets instead. split the inventory set into multiple packets instead.
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index 7f4681910751047a26fdfc6b59bc460449c02001..35191d968fd30db16213540ef7121f4dede68e68 100644 index 0c5c62be83223e20f216df84413b8c2438db81ff..8bbf13a7aea1142b3154a1c76837a98aa5ed431d 100644
--- a/src/main/java/net/minecraft/network/Connection.java --- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java
@@ -12,6 +12,7 @@ import io.netty.channel.epoll.EpollEventLoopGroup; @@ -120,6 +120,15 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
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;
@@ -107,6 +108,15 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> {
} }
public void exceptionCaught(ChannelHandlerContext channelhandlercontext, Throwable throwable) { public void exceptionCaught(ChannelHandlerContext channelhandlercontext, Throwable throwable) {
+ // Paper start + // 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)) { + if (((PacketEncoder.PacketTooLargeException) throwable.getCause()).getPacket().packetTooLarge(this)) {
+ return; + return;
+ } else { + } else {
@ -35,16 +27,16 @@ index 7f4681910751047a26fdfc6b59bc460449c02001..35191d968fd30db16213540ef7121f4d
Connection.LOGGER.debug("Skipping packet due to errors", throwable.getCause()); Connection.LOGGER.debug("Skipping packet due to errors", throwable.getCause());
} else { } else {
diff --git a/src/main/java/net/minecraft/network/PacketEncoder.java b/src/main/java/net/minecraft/network/PacketEncoder.java diff --git a/src/main/java/net/minecraft/network/PacketEncoder.java b/src/main/java/net/minecraft/network/PacketEncoder.java
index d36d0424bcd4811af892f5f76fdcefda2af1ad33..a58c4fa8be7193b8acae5ea18a9780866312d768 100644 index b8a0c0411fd2caab21672de7f3e721645b61a8ba..c0df136c408d7f001395291d8c80da5b4b54d462 100644
--- a/src/main/java/net/minecraft/network/PacketEncoder.java --- a/src/main/java/net/minecraft/network/PacketEncoder.java
+++ b/src/main/java/net/minecraft/network/PacketEncoder.java +++ b/src/main/java/net/minecraft/network/PacketEncoder.java
@@ -53,7 +53,31 @@ public class PacketEncoder extends MessageToByteEncoder<Packet<?>> { @@ -54,7 +54,31 @@ public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
throw throwable; throw var9;
} }
} }
+ +
+ // Paper start + // Paper start
+ int packetLength = bytebuf.readableBytes(); + int packetLength = friendlyByteBuf.readableBytes();
+ if (packetLength > MAX_PACKET_SIZE) { + if (packetLength > MAX_PACKET_SIZE) {
+ throw new PacketTooLargeException(packet, packetLength); + throw new PacketTooLargeException(packet, packetLength);
+ } + }
@ -71,15 +63,15 @@ index d36d0424bcd4811af892f5f76fdcefda2af1ad33..a58c4fa8be7193b8acae5ea18a978086
+ // Paper end + // Paper end
} }
diff --git a/src/main/java/net/minecraft/network/protocol/Packet.java b/src/main/java/net/minecraft/network/protocol/Packet.java diff --git a/src/main/java/net/minecraft/network/protocol/Packet.java b/src/main/java/net/minecraft/network/protocol/Packet.java
index 29f10af7feabe2765f576586db4e3dba320dceda..9914a82ba0ec146ab13fe94c4dbf0ebf64926536 100644 index 10c1f2d8a92f848c3f2be9d1d06fd254978e6dcc..74bfe0d3942259c45702b099efdc4e101a4e3022 100644
--- a/src/main/java/net/minecraft/network/protocol/Packet.java --- a/src/main/java/net/minecraft/network/protocol/Packet.java
+++ b/src/main/java/net/minecraft/network/protocol/Packet.java +++ b/src/main/java/net/minecraft/network/protocol/Packet.java
@@ -12,6 +12,12 @@ public interface Packet<T extends PacketListener> { @@ -8,6 +8,12 @@ public interface Packet<T extends PacketListener> {
void handle(T listener); void handle(T listener);
+ // Paper start + // Paper start
+ default boolean packetTooLarge(NetworkManager manager) { + default boolean packetTooLarge(net.minecraft.network.Connection manager) {
+ return false; + return false;
+ } + }
+ // Paper end + // Paper end
@ -88,43 +80,36 @@ index 29f10af7feabe2765f576586db4e3dba320dceda..9914a82ba0ec146ab13fe94c4dbf0ebf
return false; return false;
} }
diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java diff --git a/src/main/java/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java b/src/main/java/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java
index 70684318c562a9c3ce566b16cd0e68cfe95cbd50..64a15dcaef40c4e16458ab71d648f9fff169a3b2 100644 index a27d46e90ad04c624d41f6cbededcd3121dfeee8..d5ca796408f975f4f002a5b385574d3516915507 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java --- a/src/main/java/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java +++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundContainerSetContentPacket.java
@@ -4,6 +4,7 @@ import java.io.IOException; @@ -10,6 +10,16 @@ public class ClientboundContainerSetContentPacket implements Packet<ClientGamePa
import java.util.Iterator; private final int containerId;
import java.util.List; private final List<ItemStack> items;
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;
@@ -13,6 +14,15 @@ public class ClientboundContainerSetContentPacket implements Packet<ClientGamePa
private int containerId;
private List<ItemStack> items;
+ //Paper start + //Paper start
+ @Override + @Override
+ public boolean packetTooLarge(Connection manager) { + public boolean packetTooLarge(net.minecraft.network.Connection manager) {
+ for (int i = 0 ; i < this.items.size() ; i++) { + for (int i = 0 ; i < this.items.size() ; i++) {
+ manager.send(new ClientboundContainerSetSlotPacket(this.containerId, i, this.items.get(i))); + manager.send(new ClientboundContainerSetSlotPacket(this.containerId, i, this.items.get(i)));
+ } + }
+ return true; + return true;
+ } + }
+ // Paper end + // Paper end
public ClientboundContainerSetContentPacket() {} +
public ClientboundContainerSetContentPacket(int syncId, NonNullList<ItemStack> contents) { 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 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 4fe15aa331ca18319ca46d1b426f0d6fd24341f0..b7d303b5f51a35504888933efef74564fa01e59d 100644 index 1451a98d69b185dd15a2d1d7681bcecb6a4f99c1..96626835fee3c0fdb452acacdc9f737ad90c08de 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacket.java --- a/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacket.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacket.java +++ b/src/main/java/net/minecraft/network/protocol/game/ClientboundLevelChunkPacket.java
@@ -91,7 +91,7 @@ public class ClientboundLevelChunkPacket implements Packet<ClientGamePacketListe @@ -64,7 +64,7 @@ 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 { } 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];

Datei anzeigen

@ -20,10 +20,10 @@ this is going to be the best soultion all around.
Improvements/suggestions welcome! Improvements/suggestions welcome!
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index b68acf219fc61e2ea811d0c732393824fa44db2d..416c21f0a6be8d71a654e18f7ea0fa074f8fc5ff 100644 index 5eb37fb1ae861940839fe6815b57111812d6b3ec..963a3c159e912a39b98dfcb3fdb8c384765990d7 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -1258,11 +1258,13 @@ public class ServerPlayer extends Player implements ContainerListener { @@ -1299,11 +1299,13 @@ public class ServerPlayer extends Player {
} }
} }
@ -41,10 +41,10 @@ index b68acf219fc61e2ea811d0c732393824fa44db2d..416c21f0a6be8d71a654e18f7ea0fa07
if (entity1 != entity && this.connection != null) { if (entity1 != entity && this.connection != null) {
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 460c6fd61bb45247715d99445821e15e98e4c465..c5d6235a132818dfc78105e9d03d0687f697bb00 100644 index c3bbe8429ee792b881953c5894a55505cdba63d3..8df9bd656374d0b43af378c61c1df7b951085b58 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java --- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java +++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -2044,12 +2044,15 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s @@ -2212,12 +2212,15 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
} }
@ -62,7 +62,7 @@ index 460c6fd61bb45247715d99445821e15e98e4c465..c5d6235a132818dfc78105e9d03d0687
} }
} }
@@ -2104,7 +2107,10 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s @@ -2280,7 +2283,10 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
return true; // CraftBukkit return true; // CraftBukkit
} }
@ -74,16 +74,16 @@ index 460c6fd61bb45247715d99445821e15e98e4c465..c5d6235a132818dfc78105e9d03d0687
if (entity.getVehicle() == this) { if (entity.getVehicle() == this) {
throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)"); throw new IllegalStateException("Use x.stopRiding(y), not y.removePassenger(x)");
} else { } else {
@@ -2114,7 +2120,7 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s @@ -2290,7 +2296,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
if (getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity) { if (this.getBukkitEntity() instanceof Vehicle && entity.getBukkitEntity() instanceof LivingEntity) {
VehicleExitEvent event = new VehicleExitEvent( VehicleExitEvent event = new VehicleExitEvent(
(Vehicle) getBukkitEntity(), (Vehicle) this.getBukkitEntity(),
- (LivingEntity) entity.getBukkitEntity() - (LivingEntity) entity.getBukkitEntity()
+ (LivingEntity) entity.getBukkitEntity(), !suppressCancellation // Paper + (LivingEntity) entity.getBukkitEntity(), !suppressCancellation // Paper
); );
// Suppress during worldgen // Suppress during worldgen
if (this.valid) { if (this.valid) {
@@ -2128,7 +2134,7 @@ public abstract class Entity implements Nameable, CommandSource, net.minecraft.s @@ -2304,7 +2310,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource, n
} }
// CraftBukkit end // CraftBukkit end
// Spigot start // Spigot start
@ -93,10 +93,10 @@ index 460c6fd61bb45247715d99445821e15e98e4c465..c5d6235a132818dfc78105e9d03d0687
if (this.valid) { if (this.valid) {
Bukkit.getPluginManager().callEvent(event); Bukkit.getPluginManager().callEvent(event);
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 7a2292e6907a2ae2026bd7243e864bd8300ecafa..29d4ed42e5d763639a50d849ef274c4d848bc9c9 100644 index 8333d604fce05349455bf1779f3e5b0a980c4c16..1dabdba428c10e65b634b6e2036f993c4be186a7 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java --- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java +++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -3012,11 +3012,13 @@ public abstract class LivingEntity extends Entity { @@ -3329,11 +3329,13 @@ public abstract class LivingEntity extends Entity {
return ((Byte) this.entityData.get(LivingEntity.DATA_LIVING_ENTITY_FLAGS) & 4) != 0; return ((Byte) this.entityData.get(LivingEntity.DATA_LIVING_ENTITY_FLAGS) & 4) != 0;
} }
@ -114,10 +114,10 @@ index 7a2292e6907a2ae2026bd7243e864bd8300ecafa..29d4ed42e5d763639a50d849ef274c4d
this.dismountVehicle(entity); this.dismountVehicle(entity);
} }
diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java diff --git a/src/main/java/net/minecraft/world/entity/player/Player.java b/src/main/java/net/minecraft/world/entity/player/Player.java
index 3aadc4ab5fe7b2ee9e20e0789ddcfe750599972f..0685920073a6a2b2c6a80018d0c9009b2ef860c4 100644 index e0e33dd92b686939f622f0a7da0d5a971f43d0d6..4c9261c68518ab7429325f0366dfb2930663288c 100644
--- a/src/main/java/net/minecraft/world/entity/player/Player.java --- a/src/main/java/net/minecraft/world/entity/player/Player.java
+++ b/src/main/java/net/minecraft/world/entity/player/Player.java +++ b/src/main/java/net/minecraft/world/entity/player/Player.java
@@ -1036,9 +1036,11 @@ public abstract class Player extends LivingEntity { @@ -1096,9 +1096,11 @@ public abstract class Player extends LivingEntity {
return -0.35D; return -0.35D;
} }

Datei anzeigen

@ -5,10 +5,10 @@ Subject: [PATCH] Add more Zombie API
diff --git a/src/main/java/net/minecraft/world/entity/monster/Zombie.java b/src/main/java/net/minecraft/world/entity/monster/Zombie.java diff --git a/src/main/java/net/minecraft/world/entity/monster/Zombie.java b/src/main/java/net/minecraft/world/entity/monster/Zombie.java
index 94e2a8f74e74d68d4a9b82b667fbff24b7e9e629..ad4eeb15771750193a28116117992270c72a3644 100644 index 017d8de4d09f524aed2ee03af7ef79468503edf0..c60d9775230b2ff554eeb38136f8e7c32c47d8cf 100644
--- a/src/main/java/net/minecraft/world/entity/monster/Zombie.java --- a/src/main/java/net/minecraft/world/entity/monster/Zombie.java
+++ b/src/main/java/net/minecraft/world/entity/monster/Zombie.java +++ b/src/main/java/net/minecraft/world/entity/monster/Zombie.java
@@ -91,6 +91,7 @@ public class Zombie extends Monster { @@ -96,6 +96,7 @@ public class Zombie extends Monster {
private int inWaterTime; private int inWaterTime;
public int conversionTime; public int conversionTime;
private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field private int lastTick = MinecraftServer.currentTick; // CraftBukkit - add field
@ -16,7 +16,7 @@ index 94e2a8f74e74d68d4a9b82b667fbff24b7e9e629..ad4eeb15771750193a28116117992270
public Zombie(EntityType<? extends Zombie> type, Level world) { public Zombie(EntityType<? extends Zombie> type, Level world) {
super(type, world); super(type, world);
@@ -259,6 +260,12 @@ public class Zombie extends Monster { @@ -264,6 +265,12 @@ public class Zombie extends Monster {
super.aiStep(); super.aiStep();
} }
@ -29,47 +29,47 @@ index 94e2a8f74e74d68d4a9b82b667fbff24b7e9e629..ad4eeb15771750193a28116117992270
public void startUnderWaterConversion(int ticksUntilWaterConversion) { public void startUnderWaterConversion(int ticksUntilWaterConversion) {
this.lastTick = MinecraftServer.currentTick; // CraftBukkit this.lastTick = MinecraftServer.currentTick; // CraftBukkit
this.conversionTime = ticksUntilWaterConversion; this.conversionTime = ticksUntilWaterConversion;
@@ -287,9 +294,16 @@ public class Zombie extends Monster { @@ -292,10 +299,17 @@ public class Zombie extends Monster {
} }
+ public boolean shouldBurnInDay() { return isSunSensitive(); } // Paper - OBFHELPER + public boolean isSunSensitivePublic() { return this.isSunSensitive(); } // Paper - public getter
protected boolean isSunSensitive() { protected boolean isSunSensitive() {
- return true; - return true;
+ return this.shouldBurnInDay; // Paper - use api value instead + return this.shouldBurnInDay; // Paper - use api value instead
+ } }
+
+ // Paper start + // Paper start
+ public void setShouldBurnInDay(boolean shouldBurnInDay) { + public void setShouldBurnInDay(boolean shouldBurnInDay) {
+ this.shouldBurnInDay = shouldBurnInDay; + this.shouldBurnInDay = shouldBurnInDay;
} + }
+ // Paper end + // Paper end
+
@Override @Override
public boolean hurt(DamageSource source, float amount) { public boolean hurt(DamageSource source, float amount) {
@@ -410,6 +424,7 @@ public class Zombie extends Monster { if (!super.hurt(source, amount)) {
tag.putBoolean("CanBreakDoors", this.canBreakDoors()); @@ -415,6 +429,7 @@ public class Zombie extends Monster {
tag.putInt("InWaterTime", this.isInWater() ? this.inWaterTime : -1); nbt.putBoolean("CanBreakDoors", this.canBreakDoors());
tag.putInt("DrownedConversionTime", this.isUnderWaterConverting() ? this.conversionTime : -1); nbt.putInt("InWaterTime", this.isInWater() ? this.inWaterTime : -1);
+ tag.putBoolean("Paper.ShouldBurnInDay", shouldBurnInDay); // Paper nbt.putInt("DrownedConversionTime", this.isUnderWaterConverting() ? this.conversionTime : -1);
+ nbt.putBoolean("Paper.ShouldBurnInDay", this.shouldBurnInDay); // Paper
} }
@Override @Override
@@ -421,7 +436,11 @@ public class Zombie extends Monster { @@ -426,6 +441,11 @@ public class Zombie extends Monster {
if (tag.contains("DrownedConversionTime", 99) && tag.getInt("DrownedConversionTime") > -1) { if (nbt.contains("DrownedConversionTime", 99) && nbt.getInt("DrownedConversionTime") > -1) {
this.startUnderWaterConversion(tag.getInt("DrownedConversionTime")); this.startUnderWaterConversion(nbt.getInt("DrownedConversionTime"));
} }
-
+ // Paper start + // Paper start
+ if (tag.contains("Paper.ShouldBurnInDay")) { + if (nbt.contains("Paper.ShouldBurnInDay")) {
+ shouldBurnInDay = tag.getBoolean("Paper.ShouldBurnInDay"); + this.shouldBurnInDay = nbt.getBoolean("Paper.ShouldBurnInDay");
+ } + }
+ // Paper end + // 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 diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java
index 038793987338c2e4b73784a10836f85c7061175a..86f65c07806a118c49e900c59be86c2bd2eb124c 100644 index 2e643e92569512ac4e75c0ef2ee7aa4b688e7356..41b5059f6fde8a1afa8c70b983750854ac0207a6 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftZombie.java
@@ -93,6 +93,42 @@ public class CraftZombie extends CraftMonster implements Zombie { @@ -93,6 +93,42 @@ public class CraftZombie extends CraftMonster implements Zombie {
@ -94,7 +94,7 @@ index 038793987338c2e4b73784a10836f85c7061175a..86f65c07806a118c49e900c59be86c2b
+ +
+ @Override + @Override
+ public boolean shouldBurnInDay() { + public boolean shouldBurnInDay() {
+ return getHandle().shouldBurnInDay(); + return getHandle().isSunSensitivePublic();
+ } + }
+ +
+ @Override + @Override

Datei anzeigen

@ -6,32 +6,34 @@ Subject: [PATCH] Book Size Limits
Puts some limits on the size of books. Puts some limits on the size of books.
diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java diff --git a/src/main/java/com/destroystokyo/paper/PaperConfig.java b/src/main/java/com/destroystokyo/paper/PaperConfig.java
index 3139c194f9b1bc3510d51a81f13ae43d00a3dc29..13edb435b3fa65b4980bd7472aa5a5196f4d5b2b 100644 index 11d628869a9a6eda8bf21a4f213ff23ad753b18e..8bf4d2b8c38c02d6a5b2fea37113689a252f1571 100644
--- a/src/main/java/com/destroystokyo/paper/PaperConfig.java --- a/src/main/java/com/destroystokyo/paper/PaperConfig.java
+++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java +++ b/src/main/java/com/destroystokyo/paper/PaperConfig.java
@@ -339,4 +339,11 @@ public class PaperConfig { @@ -347,6 +347,13 @@ public class PaperConfig {
velocitySecretKey = secret.getBytes(StandardCharsets.UTF_8);
} }
} }
+
+ public static int maxBookPageSize = 2560; + public static int maxBookPageSize = 2560;
+ public static double maxBookTotalSizeMultiplier = 0.98D; + public static double maxBookTotalSizeMultiplier = 0.98D;
+ private static void maxBookSize() { + private static void maxBookSize() {
+ maxBookPageSize = getInt("settings.book-size.page-max", maxBookPageSize); + maxBookPageSize = getInt("settings.book-size.page-max", maxBookPageSize);
+ maxBookTotalSizeMultiplier = getDouble("settings.book-size.total-multiplier", maxBookTotalSizeMultiplier); + 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 diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index a6ad7747396f94def688b4d2783137180dc2bb84..b1c505d3fdcc2fb3496f80bee85e4895b9069dcb 100644 index 8b716c625c363d7143fe6fbc26d3d674d62a5833..f1a8470d0b314c8fa5eade198cffc1f8cd5e6832 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -999,6 +999,52 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener { @@ -1002,6 +1002,52 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
@Override @Override
public void handleEditBook(ServerboundEditBookPacket packet) { public void handleEditBook(ServerboundEditBookPacket packet) {
+ // Paper start + // Paper start
+ ItemStack testStack = packet.getBook(); + 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); + ListTag pageList = testStack.getTag().getList("pages", 8);
+ if (pageList.size() > 100) { + if (pageList.size() > 100) {
+ ServerGamePacketListenerImpl.LOGGER.warn(this.player.getScoreboardName() + " tried to send a book with too many pages"); + ServerGamePacketListenerImpl.LOGGER.warn(this.player.getScoreboardName() + " tried to send a book with too many pages");

Datei anzeigen

@ -34,11 +34,11 @@ how PlayerPreLoginEvent interacts with PlayerConnectionCloseEvent
is undefined. is undefined.
diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java diff --git a/src/main/java/net/minecraft/network/Connection.java b/src/main/java/net/minecraft/network/Connection.java
index 35191d968fd30db16213540ef7121f4dede68e68..3247ec5d6cf329ba0b7e6d5a6c3294dec2e34db4 100644 index 8bbf13a7aea1142b3154a1c76837a98aa5ed431d..9f0537799a3cae43fb120056b8fe805a4883cc4d 100644
--- a/src/main/java/net/minecraft/network/Connection.java --- a/src/main/java/net/minecraft/network/Connection.java
+++ b/src/main/java/net/minecraft/network/Connection.java +++ b/src/main/java/net/minecraft/network/Connection.java
@@ -350,6 +350,26 @@ public class Connection extends SimpleChannelInboundHandler<Packet<?>> { @@ -418,6 +418,26 @@ 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. this.queue.clear(); // Free up packet queue.
+ // Paper start - Add PlayerConnectionCloseEvent + // Paper start - Add PlayerConnectionCloseEvent
@ -65,18 +65,19 @@ index 35191d968fd30db16213540ef7121f4dede68e68..3247ec5d6cf329ba0b7e6d5a6c3294de
} }
diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java diff --git a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
index 22d6f41001977917ec75046252cbf7157b92396d..9631fa93b821c7f6bc6dc707c2c82cce2ae8291e 100644 index a196ab2510a1c302ef1c946400c1a7c07619994a..abbd1926107b49f9b7c8097419ba19baf6f6b7d3 100644
--- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java --- a/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerLoginPacketListenerImpl.java
@@ -55,9 +55,9 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener @@ -56,10 +56,10 @@ public class ServerLoginPacketListenerImpl implements ServerLoginPacketListener
private final byte[] nonce = new byte[4]; private final byte[] nonce = new byte[4];
private final MinecraftServer server; final MinecraftServer server;
public final Connection connection; public final Connection connection;
- private ServerLoginPacketListenerImpl.State state; - ServerLoginPacketListenerImpl.State state;
+ private ServerLoginPacketListenerImpl.State state; public final ServerLoginPacketListenerImpl.State getLoginState() { return this.state; }; // Paper - OBFHELPER + ServerLoginPacketListenerImpl.State state; public final ServerLoginPacketListenerImpl.State getLoginState() { return this.state; }; // Paper - OBFHELPER
private int tick; private int tick;
- private GameProfile gameProfile; private void setGameProfile(final GameProfile profile) { this.gameProfile = profile; } private GameProfile getGameProfile() { return this.gameProfile; } // Paper - OBFHELPER @Nullable
+ private GameProfile gameProfile; private void setGameProfile(final GameProfile profile) { this.gameProfile = profile; } public GameProfile getGameProfile() { return this.gameProfile; } // Paper - OBFHELPER - 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 final String serverId;
private SecretKey secretKey; @Nullable
private ServerPlayer delayedAcceptPlayer; private ServerPlayer delayedAcceptPlayer;

Datei anzeigen

@ -5,20 +5,10 @@ Subject: [PATCH] Prevent Enderman from loading chunks
diff --git a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java diff --git a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
index d190b58bea310f4006ea3deaf0d42c502d441284..dae35d3f758e40c1edf31b11c6e11f1b7bb2dfae 100644 index abd1130529dd74780054e26bac89cf757ba9cdc1..a39f4a1585ba888d27588a86130f6dae24f5a71b 100644
--- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java --- a/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
+++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java +++ b/src/main/java/net/minecraft/world/entity/monster/EnderMan.java
@@ -434,7 +434,8 @@ public class EnderMan extends Monster implements NeutralMob { @@ -465,7 +465,8 @@ 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);
@@ -474,7 +475,8 @@ public class EnderMan extends Monster implements NeutralMob {
int j = Mth.floor(this.enderman.getY() + random.nextDouble() * 2.0D); int j = Mth.floor(this.enderman.getY() + random.nextDouble() * 2.0D);
int k = Mth.floor(this.enderman.getZ() - 1.0D + random.nextDouble() * 2.0D); int k = Mth.floor(this.enderman.getZ() - 1.0D + random.nextDouble() * 2.0D);
BlockPos blockposition = new BlockPos(i, j, k); BlockPos blockposition = new BlockPos(i, j, k);
@ -28,3 +18,13 @@ index d190b58bea310f4006ea3deaf0d42c502d441284..dae35d3f758e40c1edf31b11c6e11f1b
BlockPos blockposition1 = blockposition.below(); BlockPos blockposition1 = blockposition.below();
BlockState iblockdata1 = world.getBlockState(blockposition1); BlockState iblockdata1 = world.getBlockState(blockposition1);
BlockState iblockdata2 = this.enderman.getCarriedBlock(); BlockState iblockdata2 = this.enderman.getCarriedBlock();
@@ -511,7 +512,8 @@ 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));

Datei anzeigen

@ -16,10 +16,10 @@ intent to remove) and replace it with two new methods, clearly named and
documented as to their purpose. documented as to their purpose.
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 416c21f0a6be8d71a654e18f7ea0fa074f8fc5ff..1fa4f58658ff98396eb5abfc27e19e5832d56f5a 100644 index 963a3c159e912a39b98dfcb3fdb8c384765990d7..44da4efc23a3273449431845308ba889615ac425 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -211,6 +211,7 @@ public class ServerPlayer extends Player implements ContainerListener { @@ -218,6 +218,7 @@ public class ServerPlayer extends Player {
public int latency; public int latency;
public boolean wonGame; public boolean wonGame;
private int containerUpdateDelay; // Paper private int containerUpdateDelay; // Paper
@ -28,10 +28,10 @@ index 416c21f0a6be8d71a654e18f7ea0fa074f8fc5ff..1fa4f58658ff98396eb5abfc27e19e58
public boolean queueHealthUpdatePacket = false; public boolean queueHealthUpdatePacket = false;
public net.minecraft.network.protocol.game.ClientboundSetHealthPacket queuedHealthUpdatePacket; public net.minecraft.network.protocol.game.ClientboundSetHealthPacket queuedHealthUpdatePacket;
diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java diff --git a/src/main/java/net/minecraft/server/players/PlayerList.java b/src/main/java/net/minecraft/server/players/PlayerList.java
index 7c307a16ca3962db65be09a0ddd058a4ce81c7be..5b71b487836cdd2ddc75b2039f4dc0177719d345 100644 index b62aa9f934c33b4d22b985b5e56937baa8454677..0df68991eb2ef3dabe779f42c2bf44846ac0d862 100644
--- a/src/main/java/net/minecraft/server/players/PlayerList.java --- a/src/main/java/net/minecraft/server/players/PlayerList.java
+++ b/src/main/java/net/minecraft/server/players/PlayerList.java +++ b/src/main/java/net/minecraft/server/players/PlayerList.java
@@ -164,6 +164,7 @@ public abstract class PlayerList { @@ -169,6 +169,7 @@ public abstract class PlayerList {
} }
public void placeNewPlayer(Connection connection, ServerPlayer player) { public void placeNewPlayer(Connection connection, ServerPlayer player) {
@ -40,11 +40,11 @@ index 7c307a16ca3962db65be09a0ddd058a4ce81c7be..5b71b487836cdd2ddc75b2039f4dc017
GameProfileCache usercache = this.server.getProfileCache(); GameProfileCache usercache = this.server.getProfileCache();
GameProfile gameprofile1 = usercache.get(gameprofile.getId()); GameProfile gameprofile1 = usercache.get(gameprofile.getId());
diff --git a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java diff --git a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
index 1eeb1d1fe54eba68652be8dba52dce8ca91d948d..19aee8c6d0989bcf263e27adab42b3e6e411b66f 100644 index 93de44b05a698515457052c9c684c4ef44c5cc40..b20bfe5ab165bf86985e5ff2f93f415d9710e0e4 100644
--- a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java --- a/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/CraftOfflinePlayer.java
@@ -244,6 +244,61 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa @@ -244,6 +244,61 @@ public class CraftOfflinePlayer implements OfflinePlayer, ConfigurationSerializa
return getData() != null; return this.getData() != null;
} }
+ // Paper start + // Paper start
@ -104,12 +104,12 @@ index 1eeb1d1fe54eba68652be8dba52dce8ca91d948d..19aee8c6d0989bcf263e27adab42b3e6
+ +
@Override @Override
public Location getBedSpawnLocation() { 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 diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index a3e65028d3e0c09a65cd9c28b037fe01a2ed1d76..ba03a1cdac68dc08ed878e311adeebc531e8f2f1 100644 index 686dc5859c081d3b86d8e58a63abee49258208d7..f0bdf17d86458da3678945aeb23fdb5bceabc366 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -144,6 +144,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -150,6 +150,7 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
private org.bukkit.event.player.PlayerResourcePackStatusEvent.Status resourcePackStatus; private org.bukkit.event.player.PlayerResourcePackStatusEvent.Status resourcePackStatus;
private String resourcePackHash; private String resourcePackHash;
private static final boolean DISABLE_CHANNEL_LIMIT = System.getProperty("paper.disableChannelLimit") != null; // Paper - add a flag to disable the channel limit private static final boolean DISABLE_CHANNEL_LIMIT = System.getProperty("paper.disableChannelLimit") != null; // Paper - add a flag to disable the channel limit
@ -117,7 +117,7 @@ index a3e65028d3e0c09a65cd9c28b037fe01a2ed1d76..ba03a1cdac68dc08ed878e311adeebc5
// Paper end // Paper end
public CraftPlayer(CraftServer server, ServerPlayer entity) { public CraftPlayer(CraftServer server, ServerPlayer entity) {
@@ -1480,6 +1481,18 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -1502,6 +1503,18 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
this.firstPlayed = firstPlayed; this.firstPlayed = firstPlayed;
} }
@ -134,9 +134,9 @@ index a3e65028d3e0c09a65cd9c28b037fe01a2ed1d76..ba03a1cdac68dc08ed878e311adeebc5
+ // Paper end + // Paper end
+ +
public void readExtraData(CompoundTag nbttagcompound) { public void readExtraData(CompoundTag nbttagcompound) {
hasPlayedBefore = true; this.hasPlayedBefore = true;
if (nbttagcompound.contains("bukkit")) { if (nbttagcompound.contains("bukkit")) {
@@ -1502,6 +1515,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -1524,6 +1537,8 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
} }
public void setExtraData(CompoundTag nbttagcompound) { public void setExtraData(CompoundTag nbttagcompound) {
@ -145,8 +145,8 @@ index a3e65028d3e0c09a65cd9c28b037fe01a2ed1d76..ba03a1cdac68dc08ed878e311adeebc5
if (!nbttagcompound.contains("bukkit")) { if (!nbttagcompound.contains("bukkit")) {
nbttagcompound.put("bukkit", new CompoundTag()); nbttagcompound.put("bukkit", new CompoundTag());
} }
@@ -1516,6 +1531,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -1538,6 +1553,16 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
data.putLong("firstPlayed", getFirstPlayed()); data.putLong("firstPlayed", this.getFirstPlayed());
data.putLong("lastPlayed", System.currentTimeMillis()); data.putLong("lastPlayed", System.currentTimeMillis());
data.putString("lastKnownName", handle.getScoreboardName()); data.putString("lastKnownName", handle.getScoreboardName());
+ +

Datei anzeigen

@ -5,10 +5,10 @@ Subject: [PATCH] Workaround for vehicle tracking issue on disconnect
diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java diff --git a/src/main/java/net/minecraft/server/level/ServerPlayer.java b/src/main/java/net/minecraft/server/level/ServerPlayer.java
index 1fa4f58658ff98396eb5abfc27e19e5832d56f5a..fd2717a00a85f91ee23a1c0f929f856972892a9b 100644 index 44da4efc23a3273449431845308ba889615ac425..955a7fcd80a57f920e402a5533f5029b9683104c 100644
--- a/src/main/java/net/minecraft/server/level/ServerPlayer.java --- a/src/main/java/net/minecraft/server/level/ServerPlayer.java
+++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java +++ b/src/main/java/net/minecraft/server/level/ServerPlayer.java
@@ -1524,6 +1524,13 @@ public class ServerPlayer extends Player implements ContainerListener { @@ -1538,6 +1538,13 @@ public class ServerPlayer extends Player {
public void disconnect() { public void disconnect() {
this.disconnected = true; this.disconnected = true;
this.ejectPassengers(); this.ejectPassengers();

Datei anzeigen

@ -24,10 +24,10 @@ Instead we opt to remove the check entirely so that the event fires for
all piston types. all piston types.
diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java diff --git a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
index 878cec21b52fb62369310c2f85001e859a270dd8..dc9584a30c18d964afd9cc118c81c24a80beba63 100644 index ca9e94b92d26eb6cd3ca6ff4b8cb1cd98aabf4e0..c345bd7542f3ffa09719864887e1516f1182e7e3 100644
--- a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java --- a/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
+++ b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java +++ b/src/main/java/net/minecraft/world/level/block/piston/PistonBaseBlock.java
@@ -140,7 +140,7 @@ public class PistonBaseBlock extends DirectionalBlock { @@ -147,7 +147,7 @@ public class PistonBaseBlock extends DirectionalBlock {
} }
// CraftBukkit start // CraftBukkit start
@ -36,7 +36,7 @@ index 878cec21b52fb62369310c2f85001e859a270dd8..dc9584a30c18d964afd9cc118c81c24a
org.bukkit.block.Block block = world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ()); org.bukkit.block.Block block = world.getWorld().getBlockAt(pos.getX(), pos.getY(), pos.getZ());
BlockPistonRetractEvent event = new BlockPistonRetractEvent(block, ImmutableList.<org.bukkit.block.Block>of(), CraftBlock.notchToBlockFace(enumdirection)); BlockPistonRetractEvent event = new BlockPistonRetractEvent(block, ImmutableList.<org.bukkit.block.Block>of(), CraftBlock.notchToBlockFace(enumdirection));
world.getCraftServer().getPluginManager().callEvent(event); world.getCraftServer().getPluginManager().callEvent(event);
@@ -148,7 +148,7 @@ public class PistonBaseBlock extends DirectionalBlock { @@ -155,7 +155,7 @@ public class PistonBaseBlock extends DirectionalBlock {
if (event.isCancelled()) { if (event.isCancelled()) {
return; return;
} }

Datei anzeigen

@ -12,10 +12,10 @@ Player we will look at limiting the scope of this change. It appears to
be unintentional in the few cases we've seen so far. be unintentional in the few cases we've seen so far.
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
index ba03a1cdac68dc08ed878e311adeebc531e8f2f1..c2c6eb54096ef85b01c0b700cbe6a8054b62729f 100644 index f0bdf17d86458da3678945aeb23fdb5bceabc366..2ed7920b0e046bc9d581878a10b04ad784bb8655 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java --- a/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java +++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftPlayer.java
@@ -2231,6 +2231,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player { @@ -2255,6 +2255,15 @@ public class CraftPlayer extends CraftHumanEntity implements Player {
public void resetCooldown() { public void resetCooldown() {
getHandle().resetAttackStrengthTicker(); getHandle().resetAttackStrengthTicker();
} }

Datei anzeigen

@ -11,18 +11,18 @@ floating in the air.
This can replace many uses of BlockPhysicsEvent This can replace many uses of BlockPhysicsEvent
diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java diff --git a/src/main/java/net/minecraft/world/level/Level.java b/src/main/java/net/minecraft/world/level/Level.java
index b75ffafb6840b6acab6e5b0ef5e222c4fa130977..c8542636e89748699d608eb29569cacb6321d334 100644 index 8d4f8719b30a66fbb68c9407ee8484312f05b3fb..a1b713391c2445967c3b5a645304f193c013d551 100644
--- a/src/main/java/net/minecraft/world/level/Level.java --- a/src/main/java/net/minecraft/world/level/Level.java
+++ b/src/main/java/net/minecraft/world/level/Level.java +++ b/src/main/java/net/minecraft/world/level/Level.java
@@ -27,6 +27,7 @@ import net.minecraft.network.protocol.Packet; @@ -28,6 +28,7 @@ import net.minecraft.nbt.CompoundTag;
import net.minecraft.network.protocol.game.ClientboundSetBorderPacket; import net.minecraft.network.protocol.Packet;
import net.minecraft.resources.ResourceKey; import net.minecraft.resources.ResourceKey;
import net.minecraft.resources.ResourceLocation; import net.minecraft.resources.ResourceLocation;
+import net.minecraft.server.MCUtil; +import net.minecraft.server.MCUtil;
import net.minecraft.server.MinecraftServer; import net.minecraft.server.MinecraftServer;
import net.minecraft.server.level.ChunkHolder; import net.minecraft.server.level.ChunkHolder;
import net.minecraft.server.level.ServerLevel; import net.minecraft.server.level.ServerLevel;
@@ -559,8 +560,20 @@ public abstract class Level implements LevelAccessor, AutoCloseable { @@ -567,8 +568,20 @@ public abstract class Level implements LevelAccessor, AutoCloseable {
return false; return false;
} else { } else {
FluidState fluid = this.getFluidState(pos); FluidState fluid = this.getFluidState(pos);

Datei anzeigen

@ -10,10 +10,10 @@ This made the Bukkit RecipeChoice API not work for Shapeless.
This reimplements vanilla logic using the same test logic as Shaped This reimplements vanilla logic using the same test logic as Shaped
diff --git a/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipe.java b/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipe.java diff --git a/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipe.java b/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipe.java
index 7bd62f598f3fff7520c276bdc45e538bd3260bc9..a8d0a90d36d58515bb6f6128de1ef15b72c20c17 100644 index 4e1159b3188d39c998e6887c2846209c10b701f9..6b960f0a31175bcfd8d477ee5b3c4d783303cdd5 100644
--- a/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipe.java --- a/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipe.java
+++ b/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipe.java +++ b/src/main/java/net/minecraft/world/item/crafting/ShapelessRecipe.java
@@ -71,16 +71,49 @@ public class ShapelessRecipe implements CraftingRecipe { @@ -76,16 +76,49 @@ public class ShapelessRecipe implements CraftingRecipe {
StackedContents autorecipestackmanager = new StackedContents(); StackedContents autorecipestackmanager = new StackedContents();
int i = 0; int i = 0;
@ -22,8 +22,8 @@ index 7bd62f598f3fff7520c276bdc45e538bd3260bc9..a8d0a90d36d58515bb6f6128de1ef15b
+ co.aikar.util.Counter<ItemStack> matchedProvided = new co.aikar.util.Counter<>(); + co.aikar.util.Counter<ItemStack> matchedProvided = new co.aikar.util.Counter<>();
+ co.aikar.util.Counter<Ingredient> matchedIngredients = new co.aikar.util.Counter<>(); + co.aikar.util.Counter<Ingredient> matchedIngredients = new co.aikar.util.Counter<>();
+ // Paper end + // Paper end
for (int j = 0; j < inv.getContainerSize(); ++j) { for (int j = 0; j < inventory.getContainerSize(); ++j) {
ItemStack itemstack = inv.getItem(j); ItemStack itemstack = inventory.getItem(j);
if (!itemstack.isEmpty()) { if (!itemstack.isEmpty()) {
- ++i; - ++i;
@ -65,4 +65,4 @@ index 7bd62f598f3fff7520c276bdc45e538bd3260bc9..a8d0a90d36d58515bb6f6128de1ef15b
+ // Paper end + // Paper end
} }
public ItemStack assemble(CraftingContainer inv) { public ItemStack assemble(CraftingContainer inventory) {

Datei anzeigen

@ -22,10 +22,10 @@ it only impacts data sent from the client.
Set -DPaper.maxSignLength=XX to change limit or -1 to disable Set -DPaper.maxSignLength=XX to change limit or -1 to disable
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 276773e17149f57038cd21485fd9d9061670ff2d..d6d8d83bc16572474d56a278dd119eacc2c52476 100644 index f1a8470d0b314c8fa5eade198cffc1f8cd5e6832..defebf7b45e4f006fa7e575b5dbd01ac1e231d5a 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java --- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java +++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -254,6 +254,7 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener { @@ -255,6 +255,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
private int aboveGroundVehicleTickCount; private int aboveGroundVehicleTickCount;
private int receivedMovePacketCount; private int receivedMovePacketCount;
private int knownMovePacketCount; private int knownMovePacketCount;
@ -33,22 +33,26 @@ index 276773e17149f57038cd21485fd9d9061670ff2d..d6d8d83bc16572474d56a278dd119eac
private static final long KEEPALIVE_LIMIT = Long.getLong("paper.playerconnection.keepalive", 30) * 1000; // Paper - provide property to set keepalive limit 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) { public ServerGamePacketListenerImpl(MinecraftServer server, Connection connection, ServerPlayer player) {
@@ -2860,7 +2861,17 @@ public class ServerGamePacketListenerImpl implements ServerGamePacketListener { @@ -2867,10 +2868,20 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Ser
List<net.kyori.adventure.text.Component> lines = new java.util.ArrayList<>(); List<net.kyori.adventure.text.Component> lines = new java.util.ArrayList<>();
for (int i = 0; i < list.size(); ++i) { 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 + // Paper start - cap line length - modified clients can send longer data than normal
+ String currentLine = list.get(i); + net.minecraft.server.network.TextFilter.FilteredText currentLine = list.get(i);
+ if (MAX_SIGN_LINE_LENGTH > 0 && currentLine.length() > MAX_SIGN_LINE_LENGTH) { + if (MAX_SIGN_LINE_LENGTH > 0 && currentLine.getRaw().length() > MAX_SIGN_LINE_LENGTH) {
+ // This handles multibyte characters as 1 + // This handles multibyte characters as 1
+ int offset = currentLine.codePoints().limit(MAX_SIGN_LINE_LENGTH).map(Character::charCount).sum(); + int offset = currentLine.getRaw().codePoints().limit(MAX_SIGN_LINE_LENGTH).map(Character::charCount).sum();
+ if (offset < currentLine.length()) { + if (offset < currentLine.getRaw().length()) {
+ list.set(i, currentLine = currentLine.substring(0, offset)); + 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 + // 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); SignChangeEvent event = new SignChangeEvent((org.bukkit.craftbukkit.block.CraftBlock) player.getWorld().getBlockAt(x, y, z), this.cserver.getPlayer(this.player), lines);
this.craftServer.getPluginManager().callEvent(event);