mirror of
https://github.com/PaperMC/Paper.git
synced 2024-11-26 20:46:59 +01:00
Do not allow null in CanPlaceDestroy NBT API
Fixes GH-1523
This commit is contained in:
parent
38f0f0b71a
commit
10209bfbd8
@ -1,4 +1,4 @@
|
||||
From 8bde0c87a214ab11f4cded62f33cd91d56234781 Mon Sep 17 00:00:00 2001
|
||||
From e3c47b51dc2c5d2390319fbec0fcc01dbbfe138d Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Wed, 30 Mar 2016 19:36:20 -0400
|
||||
Subject: [PATCH] MC Dev fixes
|
||||
@ -390,6 +390,19 @@ index 5b54cbde18..769d599c59 100644
|
||||
}
|
||||
+ */ // Paper end - Decompile fix
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/PacketEncoder.java b/src/main/java/net/minecraft/server/PacketEncoder.java
|
||||
index 113e8780a8..8e312c7617 100644
|
||||
--- a/src/main/java/net/minecraft/server/PacketEncoder.java
|
||||
+++ b/src/main/java/net/minecraft/server/PacketEncoder.java
|
||||
@@ -49,7 +49,7 @@ public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
|
||||
}
|
||||
|
||||
// $FF: synthetic method
|
||||
- protected void encode(ChannelHandlerContext channelhandlercontext, Object object, ByteBuf bytebuf) throws Exception {
|
||||
+ protected void encode(ChannelHandlerContext channelhandlercontext, Packet<?> object, ByteBuf bytebuf) throws Exception { // Paper - decompiler fix
|
||||
this.a(channelhandlercontext, (Packet)object, bytebuf);
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/Registry.java b/src/main/java/net/minecraft/server/Registry.java
|
||||
index 5be9f0ff2f..9efec49d66 100644
|
||||
--- a/src/main/java/net/minecraft/server/Registry.java
|
||||
@ -493,5 +506,5 @@ index ef9d8e06fe..0c9910d9a5 100644
|
||||
}
|
||||
}
|
||||
--
|
||||
2.18.0
|
||||
2.19.0
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
From d47f33ac66c41a28e7c99b00b17bf78e11c0e85c Mon Sep 17 00:00:00 2001
|
||||
From 056171fe4ced36a78f0f52df367876fcf6598101 Mon Sep 17 00:00:00 2001
|
||||
From: Aikar <aikar@aikar.co>
|
||||
Date: Mon, 28 Mar 2016 20:55:47 -0400
|
||||
Subject: [PATCH] MC Utils
|
||||
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/BlockPosition.java b/src/main/java/net/minecraft/server/BlockPosition.java
|
||||
index 6ffc53514..5ed34cf7e 100644
|
||||
index 6ffc535146..5ed34cf7e3 100644
|
||||
--- a/src/main/java/net/minecraft/server/BlockPosition.java
|
||||
+++ b/src/main/java/net/minecraft/server/BlockPosition.java
|
||||
@@ -9,7 +9,7 @@ import org.apache.logging.log4j.Logger;
|
||||
@ -42,7 +42,7 @@ index 6ffc53514..5ed34cf7e 100644
|
||||
return this.c(MathHelper.floor(d0), MathHelper.floor(d1), MathHelper.floor(d2));
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/Chunk.java b/src/main/java/net/minecraft/server/Chunk.java
|
||||
index fe5328ef4..b7c40d5ce 100644
|
||||
index bc5e4a654a..d3eac35e4d 100644
|
||||
--- a/src/main/java/net/minecraft/server/Chunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/Chunk.java
|
||||
@@ -28,7 +28,7 @@ import com.google.common.collect.Lists; // CraftBukkit
|
||||
@ -63,7 +63,7 @@ index fe5328ef4..b7c40d5ce 100644
|
||||
public TileEntity a(BlockPosition blockposition, Chunk.EnumTileEntityState chunk_enumtileentitystate) {
|
||||
// CraftBukkit start
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkCoordIntPair.java b/src/main/java/net/minecraft/server/ChunkCoordIntPair.java
|
||||
index 744762b8b..d9608121b 100644
|
||||
index 744762b8b9..d9608121b6 100644
|
||||
--- a/src/main/java/net/minecraft/server/ChunkCoordIntPair.java
|
||||
+++ b/src/main/java/net/minecraft/server/ChunkCoordIntPair.java
|
||||
@@ -23,6 +23,8 @@ public class ChunkCoordIntPair {
|
||||
@ -76,7 +76,7 @@ index 744762b8b..d9608121b 100644
|
||||
return (long)i & 4294967295L | ((long)j & 4294967295L) << 32;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/ChunkTaskScheduler.java b/src/main/java/net/minecraft/server/ChunkTaskScheduler.java
|
||||
index 3b6b3b9a9..22af9c188 100644
|
||||
index 3b6b3b9a99..22af9c1885 100644
|
||||
--- a/src/main/java/net/minecraft/server/ChunkTaskScheduler.java
|
||||
+++ b/src/main/java/net/minecraft/server/ChunkTaskScheduler.java
|
||||
@@ -16,7 +16,7 @@ import org.apache.logging.log4j.Logger;
|
||||
@ -89,7 +89,7 @@ index 3b6b3b9a9..22af9c188 100644
|
||||
private final IChunkLoader e;
|
||||
private final IAsyncTaskHandler f;
|
||||
diff --git a/src/main/java/net/minecraft/server/DataBits.java b/src/main/java/net/minecraft/server/DataBits.java
|
||||
index 95ca5f6d8..0dc948a37 100644
|
||||
index 95ca5f6d80..0dc948a375 100644
|
||||
--- a/src/main/java/net/minecraft/server/DataBits.java
|
||||
+++ b/src/main/java/net/minecraft/server/DataBits.java
|
||||
@@ -54,6 +54,7 @@ public class DataBits {
|
||||
@ -101,7 +101,7 @@ index 95ca5f6d8..0dc948a37 100644
|
||||
return this.a;
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/DataPalette.java b/src/main/java/net/minecraft/server/DataPalette.java
|
||||
index 7f905b1e0..fa5b9262b 100644
|
||||
index 7f905b1e09..fa5b9262b4 100644
|
||||
--- a/src/main/java/net/minecraft/server/DataPalette.java
|
||||
+++ b/src/main/java/net/minecraft/server/DataPalette.java
|
||||
@@ -3,10 +3,11 @@ package net.minecraft.server;
|
||||
@ -119,7 +119,7 @@ index 7f905b1e0..fa5b9262b 100644
|
||||
void b(PacketDataSerializer var1);
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/DataPaletteBlock.java b/src/main/java/net/minecraft/server/DataPaletteBlock.java
|
||||
index 304e47bf2..6e7454b13 100644
|
||||
index 304e47bf20..6e7454b134 100644
|
||||
--- a/src/main/java/net/minecraft/server/DataPaletteBlock.java
|
||||
+++ b/src/main/java/net/minecraft/server/DataPaletteBlock.java
|
||||
@@ -7,7 +7,7 @@ import java.util.function.Function;
|
||||
@ -161,7 +161,7 @@ index 304e47bf2..6e7454b13 100644
|
||||
this.b();
|
||||
packetdataserializer.writeByte(this.i);
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityCreature.java b/src/main/java/net/minecraft/server/EntityCreature.java
|
||||
index 2c6fbd1d6..a5c147b98 100644
|
||||
index 2c6fbd1d6f..a5c147b989 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityCreature.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityCreature.java
|
||||
@@ -6,6 +6,7 @@ import org.bukkit.event.entity.EntityUnleashEvent;
|
||||
@ -173,7 +173,7 @@ index 2c6fbd1d6..a5c147b98 100644
|
||||
private float b;
|
||||
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityInsentient.java b/src/main/java/net/minecraft/server/EntityInsentient.java
|
||||
index ebb177927..60b1dcd8e 100644
|
||||
index ebb177927f..60b1dcd8ea 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityInsentient.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityInsentient.java
|
||||
@@ -124,6 +124,7 @@ public abstract class EntityInsentient extends EntityLiving {
|
||||
@ -185,7 +185,7 @@ index ebb177927..60b1dcd8e 100644
|
||||
// CraftBukkit start - fire event
|
||||
setGoalTarget(entityliving, EntityTargetEvent.TargetReason.UNKNOWN, true);
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityLiving.java b/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
index fd050c5f3..8d33c1658 100644
|
||||
index 1aefd3763a..76cc9085bd 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityLiving.java
|
||||
@@ -122,6 +122,7 @@ public abstract class EntityLiving extends Entity {
|
||||
@ -197,7 +197,7 @@ index fd050c5f3..8d33c1658 100644
|
||||
@Override
|
||||
public float getBukkitYaw() {
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityMonster.java b/src/main/java/net/minecraft/server/EntityMonster.java
|
||||
index c0f48bbc2..f3cc2cef0 100644
|
||||
index c0f48bbc29..f3cc2cef0a 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityMonster.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityMonster.java
|
||||
@@ -1,6 +1,8 @@
|
||||
@ -210,7 +210,7 @@ index c0f48bbc2..f3cc2cef0 100644
|
||||
super(entitytypes, world);
|
||||
this.b_ = 5;
|
||||
diff --git a/src/main/java/net/minecraft/server/EntityTypes.java b/src/main/java/net/minecraft/server/EntityTypes.java
|
||||
index 17bfa356f..5c1ab6a0b 100644
|
||||
index 17bfa356f1..5c1ab6a0b6 100644
|
||||
--- a/src/main/java/net/minecraft/server/EntityTypes.java
|
||||
+++ b/src/main/java/net/minecraft/server/EntityTypes.java
|
||||
@@ -3,6 +3,7 @@ package net.minecraft.server;
|
||||
@ -261,7 +261,7 @@ index 17bfa356f..5c1ab6a0b 100644
|
||||
// Paper end
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/ItemStack.java b/src/main/java/net/minecraft/server/ItemStack.java
|
||||
index c54275bc2..318c4204d 100644
|
||||
index c54275bc2f..318c4204df 100644
|
||||
--- a/src/main/java/net/minecraft/server/ItemStack.java
|
||||
+++ b/src/main/java/net/minecraft/server/ItemStack.java
|
||||
@@ -26,6 +26,7 @@ import org.bukkit.TreeType;
|
||||
@ -292,7 +292,7 @@ index c54275bc2..318c4204d 100644
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/MCUtil.java b/src/main/java/net/minecraft/server/MCUtil.java
|
||||
new file mode 100644
|
||||
index 000000000..faec94722
|
||||
index 0000000000..faec947224
|
||||
--- /dev/null
|
||||
+++ b/src/main/java/net/minecraft/server/MCUtil.java
|
||||
@@ -0,0 +1,340 @@
|
||||
@ -637,7 +637,7 @@ index 000000000..faec94722
|
||||
+ }
|
||||
+}
|
||||
diff --git a/src/main/java/net/minecraft/server/NBTTagCompound.java b/src/main/java/net/minecraft/server/NBTTagCompound.java
|
||||
index 41cd3ceab..2a66a3026 100644
|
||||
index 41cd3ceabe..2a66a30264 100644
|
||||
--- a/src/main/java/net/minecraft/server/NBTTagCompound.java
|
||||
+++ b/src/main/java/net/minecraft/server/NBTTagCompound.java
|
||||
@@ -23,7 +23,7 @@ import org.apache.logging.log4j.Logger;
|
||||
@ -682,7 +682,7 @@ index 41cd3ceab..2a66a3026 100644
|
||||
}
|
||||
}
|
||||
diff --git a/src/main/java/net/minecraft/server/NetworkManager.java b/src/main/java/net/minecraft/server/NetworkManager.java
|
||||
index 0afaea810..26da89724 100644
|
||||
index 0afaea8109..26da897243 100644
|
||||
--- a/src/main/java/net/minecraft/server/NetworkManager.java
|
||||
+++ b/src/main/java/net/minecraft/server/NetworkManager.java
|
||||
@@ -44,7 +44,7 @@ public class NetworkManager extends SimpleChannelInboundHandler<Packet<?>> {
|
||||
@ -723,7 +723,7 @@ index 0afaea810..26da89724 100644
|
||||
public QueuedPacket(Packet<?> packet, @Nullable GenericFutureListener<? extends Future<? super Void>> genericfuturelistener) {
|
||||
this.a = packet;
|
||||
diff --git a/src/main/java/net/minecraft/server/PacketDataSerializer.java b/src/main/java/net/minecraft/server/PacketDataSerializer.java
|
||||
index d04afceb7..a63a5811d 100644
|
||||
index d04afceb70..a63a5811d6 100644
|
||||
--- a/src/main/java/net/minecraft/server/PacketDataSerializer.java
|
||||
+++ b/src/main/java/net/minecraft/server/PacketDataSerializer.java
|
||||
@@ -33,6 +33,7 @@ public class PacketDataSerializer extends ByteBuf {
|
||||
@ -734,8 +734,20 @@ index d04afceb7..a63a5811d 100644
|
||||
public static int a(int i) {
|
||||
for (int j = 1; j < 5; ++j) {
|
||||
if ((i & -1 << j * 7) == 0) {
|
||||
diff --git a/src/main/java/net/minecraft/server/PacketEncoder.java b/src/main/java/net/minecraft/server/PacketEncoder.java
|
||||
index 8e312c7617..c20911c965 100644
|
||||
--- a/src/main/java/net/minecraft/server/PacketEncoder.java
|
||||
+++ b/src/main/java/net/minecraft/server/PacketEncoder.java
|
||||
@@ -38,6 +38,7 @@ public class PacketEncoder extends MessageToByteEncoder<Packet<?>> {
|
||||
packet.b(packetdataserializer);
|
||||
} catch (Throwable throwable) {
|
||||
a.error(throwable);
|
||||
+ throwable.printStackTrace(); // Paper - WHAT WAS IT? WHO DID THIS TO YOU? WHAT DID YOU SEE?
|
||||
if (packet.a()) {
|
||||
throw new SkipEncodeException(throwable);
|
||||
} else {
|
||||
diff --git a/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
|
||||
index 12d6c99cf..af382815f 100644
|
||||
index 12d6c99cf0..af382815f3 100644
|
||||
--- a/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
|
||||
+++ b/src/main/java/net/minecraft/server/PacketPlayOutMapChunk.java
|
||||
@@ -11,7 +11,7 @@ public class PacketPlayOutMapChunk implements Packet<PacketListenerPlayOut> {
|
||||
@ -756,7 +768,7 @@ index 12d6c99cf..af382815f 100644
|
||||
int j = 0;
|
||||
ChunkSection[] achunksection = chunk.getSections();
|
||||
diff --git a/src/main/java/net/minecraft/server/PlayerConnection.java b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
index 8e4e6f3b9..996ffbdfa 100644
|
||||
index d455eadfc7..8db0b6a6db 100644
|
||||
--- a/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
+++ b/src/main/java/net/minecraft/server/PlayerConnection.java
|
||||
@@ -68,9 +68,9 @@ public class PlayerConnection implements PacketListenerPlayIn, ITickable {
|
||||
@ -773,7 +785,7 @@ index 8e4e6f3b9..996ffbdfa 100644
|
||||
private volatile int chatThrottle;
|
||||
private static final AtomicIntegerFieldUpdater chatSpamField = AtomicIntegerFieldUpdater.newUpdater(PlayerConnection.class, "chatThrottle");
|
||||
diff --git a/src/main/java/net/minecraft/server/RegistryBlockID.java b/src/main/java/net/minecraft/server/RegistryBlockID.java
|
||||
index a21006290..6c6f006f3 100644
|
||||
index a21006290c..6c6f006f3a 100644
|
||||
--- a/src/main/java/net/minecraft/server/RegistryBlockID.java
|
||||
+++ b/src/main/java/net/minecraft/server/RegistryBlockID.java
|
||||
@@ -54,6 +54,7 @@ public class RegistryBlockID<T> implements Registry<T> {
|
||||
@ -785,5 +797,5 @@ index a21006290..6c6f006f3 100644
|
||||
return this.b.size();
|
||||
}
|
||||
--
|
||||
2.18.0
|
||||
2.19.0
|
||||
|
||||
|
@ -1,11 +1,11 @@
|
||||
From c7cba25fff8b3dacf6a6ac702169f308be67770b Mon Sep 17 00:00:00 2001
|
||||
From 12fc862bde751d3c9842ff5a59eb75da76f3dbac Mon Sep 17 00:00:00 2001
|
||||
From: Mark Vainomaa <mikroskeem@mikroskeem.eu>
|
||||
Date: Wed, 12 Sep 2018 18:53:55 +0300
|
||||
Subject: [PATCH] Implement an API for CanPlaceOn and CanDestroy NBT values
|
||||
|
||||
|
||||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
index 55afe8382c..d928119254 100644
|
||||
index 55afe8382c..598ad807a2 100644
|
||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaItem.java
|
||||
@@ -252,6 +252,12 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable {
|
||||
@ -43,7 +43,7 @@ index 55afe8382c..d928119254 100644
|
||||
this.unhandledTags.putAll(meta.unhandledTags);
|
||||
|
||||
this.internalTag = meta.internalTag;
|
||||
@@ -347,6 +361,23 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable {
|
||||
@@ -347,6 +361,31 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable {
|
||||
if (tag.hasKey(DAMAGE.NBT)) {
|
||||
damage = tag.getInt(DAMAGE.NBT);
|
||||
}
|
||||
@ -52,6 +52,10 @@ index 55afe8382c..d928119254 100644
|
||||
+ NBTTagList list = tag.getList(CAN_DESTROY.NBT, CraftMagicNumbers.NBT.TAG_STRING);
|
||||
+ for (int i = 0; i < list.size(); i++) {
|
||||
+ Material material = Material.matchMaterial(list.getString(i), false);
|
||||
+ if (material == null) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ this.canDestroy.add(material);
|
||||
+ }
|
||||
+ }
|
||||
@ -60,6 +64,10 @@ index 55afe8382c..d928119254 100644
|
||||
+ NBTTagList list = tag.getList(CAN_PLACE_ON.NBT, CraftMagicNumbers.NBT.TAG_STRING);
|
||||
+ for (int i = 0; i < list.size(); i++) {
|
||||
+ Material material = Material.matchMaterial(list.getString(i), false);
|
||||
+ if (material == null) {
|
||||
+ continue;
|
||||
+ }
|
||||
+
|
||||
+ this.canPlaceOn.add(material);
|
||||
+ }
|
||||
+ }
|
||||
@ -67,7 +75,7 @@ index 55afe8382c..d928119254 100644
|
||||
|
||||
Set<String> keys = tag.getKeys();
|
||||
for (String key : keys) {
|
||||
@@ -579,6 +610,25 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable {
|
||||
@@ -579,6 +618,25 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable {
|
||||
if (hasDamage()) {
|
||||
itemTag.setInt(DAMAGE.NBT, damage);
|
||||
}
|
||||
@ -93,7 +101,7 @@ index 55afe8382c..d928119254 100644
|
||||
|
||||
for (Map.Entry<String, NBTBase> e : unhandledTags.entrySet()) {
|
||||
itemTag.set(e.getKey(), e.getValue());
|
||||
@@ -1247,7 +1297,9 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable {
|
||||
@@ -1247,7 +1305,9 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable {
|
||||
CraftMetaArmorStand.NO_BASE_PLATE.NBT,
|
||||
CraftMetaArmorStand.SHOW_ARMS.NBT,
|
||||
CraftMetaArmorStand.SMALL.NBT,
|
||||
@ -104,7 +112,7 @@ index 55afe8382c..d928119254 100644
|
||||
// Paper end
|
||||
));
|
||||
}
|
||||
@@ -1294,4 +1346,35 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable {
|
||||
@@ -1294,4 +1354,35 @@ class CraftMetaItem implements ItemMeta, Damageable, Repairable {
|
||||
return spigot;
|
||||
}
|
||||
// Spigot end
|
||||
|
Loading…
Reference in New Issue
Block a user