Clean up patches (#103)

* Clean up command block event patch

* Merge resource location patches

* Merge map decoration patches

* Merge Video's resource location patches

* Merge large tag reset patches
This commit is contained in:
allinkdev 2023-06-17 04:54:59 +01:00 committed by GitHub
parent ca518d0329
commit 871cc5653c
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
43 changed files with 236 additions and 489 deletions

View file

@ -1,13 +1,22 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Video <videogamesm12@gmail.com>
Date: Mon, 9 May 2022 23:40:59 -0500
Subject: [PATCH] Even more ResourceLocation validation and log spam fixes
Subject: [PATCH] Even more resource location validation
diff --git a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
index fa724cd34a7c469ca12068e64295cd00ad215a3c..168b60fda38a7172f4473017ccc42447b36faab2 100644
index 91e0328f847a2464a1cf65134520244a4cec705f..77ae3bc5fd6cf34aae7bd3baa563f3e23e57de26 100644
--- a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
+++ b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
@@ -145,7 +145,7 @@ public class AreaEffectCloud extends Entity implements TraceableEntity {
}
public void setPotionType(String string) {
- this.setPotion(BuiltInRegistries.POTION.get(new ResourceLocation(string)));
+ this.setPotion(BuiltInRegistries.POTION.get(ResourceLocation.tryParse(string))); // Scissors - Validate resource locations
}
// CraftBukkit end
@@ -425,7 +425,7 @@ public class AreaEffectCloud extends Entity implements TraceableEntity {
try {
this.setParticle(ParticleArgument.readParticle(new StringReader(nbt.getString("Particle")), (HolderLookup) BuiltInRegistries.PARTICLE_TYPE.asLookup()));
@ -17,6 +26,41 @@ index fa724cd34a7c469ca12068e64295cd00ad215a3c..168b60fda38a7172f4473017ccc42447
}
}
diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java
index 9afc81ccb237c3655d64cdbe8a0db9a4d7791043..ffcb77755b28bcdb3eae981fc735e6dde664bb6e 100644
--- a/src/main/java/net/minecraft/world/entity/EntityType.java
+++ b/src/main/java/net/minecraft/world/entity/EntityType.java
@@ -588,7 +588,7 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
}), (entity) -> {
entity.load(nbt);
}, () -> {
- EntityType.LOGGER.warn("Skipping Entity with id {}", nbt.getString("id"));
+ /*EntityType.LOGGER.warn("Skipping Entity with id {}", nbt.getString("id"));*/ // Scissors - Don't log invalid entities
});
}
@@ -607,7 +607,7 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
}
public static Optional<EntityType<?>> by(CompoundTag nbt) {
- return BuiltInRegistries.ENTITY_TYPE.getOptional(new ResourceLocation(nbt.getString("id")));
+ return BuiltInRegistries.ENTITY_TYPE.getOptional(ResourceLocation.tryParse(nbt.getString("id")));
}
@Nullable
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
index e2a25c29ec74147b3e66aa0b3deb85a8f6ee53a5..b0c953ad8275740679c847e348b311de93d64965 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
@@ -618,7 +618,7 @@ public abstract class Mob extends LivingEntity implements Targeting {
this.setLeftHanded(nbt.getBoolean("LeftHanded"));
if (nbt.contains("DeathLootTable", 8)) {
- this.lootTable = new ResourceLocation(nbt.getString("DeathLootTable"));
+ this.lootTable = ResourceLocation.tryParse(nbt.getString("DeathLootTable"));
this.lootTableSeed = nbt.getLong("DeathLootTableSeed");
}
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java b/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java
index e49eece9bff3a53469673d03a7bbf8f9cf8776b8..a49f32e9649155b6af4b1f236e4e8142d730e7e8 100644
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java
@ -60,7 +104,7 @@ index 0dd0ce9a9b3253e87eda12354249ec2fd2a33cf2..b6920f9432ca1736afbe775186fbbcf1
@Override
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
index 620d918e302a00d5a6640648e3096988d15535a0..ac6831248b7c4f25d48391432afb613f25d7e23a 100644
index 18b9b0dc70f6872a9d71c120bcd2edca531b0ac4..fa0c023b3a88bd797f563e0e675d70966ff7dbd3 100644
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java
@@ -80,8 +80,18 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob {

View file

@ -77,7 +77,7 @@ index 9d687da5bdf398bb3f6c84cdf1249a7213d09f2e..0a8fda6939152d393f07e5d2812409ad
switch (distance) {
case -1:
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
index bfa091f72d6f477bcaf63d364639a1b4df9b1987..1fe26cb620e8b550790c3e110e2a1180cf0838fd 100644
index 717e292040ed7779eb4b6c5fa26665d3df9024e7..0fb3a648ee6bd6cb88515770bcfc70e368313527 100644
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
@@ -292,7 +292,7 @@ public class Main {

View file

@ -1,54 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Telesphoreo <me@telesphoreo.me>
Date: Sat, 10 Dec 2022 23:02:48 -0600
Subject: [PATCH] Even more resource location validation
diff --git a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
index db3cddf8b227453c9b08e481b21101c5d2e0472d..77ae3bc5fd6cf34aae7bd3baa563f3e23e57de26 100644
--- a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
+++ b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java
@@ -145,7 +145,7 @@ public class AreaEffectCloud extends Entity implements TraceableEntity {
}
public void setPotionType(String string) {
- this.setPotion(BuiltInRegistries.POTION.get(new ResourceLocation(string)));
+ this.setPotion(BuiltInRegistries.POTION.get(ResourceLocation.tryParse(string))); // Scissors - Validate resource locations
}
// CraftBukkit end
diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java
index 9afc81ccb237c3655d64cdbe8a0db9a4d7791043..ffcb77755b28bcdb3eae981fc735e6dde664bb6e 100644
--- a/src/main/java/net/minecraft/world/entity/EntityType.java
+++ b/src/main/java/net/minecraft/world/entity/EntityType.java
@@ -588,7 +588,7 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
}), (entity) -> {
entity.load(nbt);
}, () -> {
- EntityType.LOGGER.warn("Skipping Entity with id {}", nbt.getString("id"));
+ /*EntityType.LOGGER.warn("Skipping Entity with id {}", nbt.getString("id"));*/ // Scissors - Don't log invalid entities
});
}
@@ -607,7 +607,7 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT
}
public static Optional<EntityType<?>> by(CompoundTag nbt) {
- return BuiltInRegistries.ENTITY_TYPE.getOptional(new ResourceLocation(nbt.getString("id")));
+ return BuiltInRegistries.ENTITY_TYPE.getOptional(ResourceLocation.tryParse(nbt.getString("id")));
}
@Nullable
diff --git a/src/main/java/net/minecraft/world/entity/Mob.java b/src/main/java/net/minecraft/world/entity/Mob.java
index e2a25c29ec74147b3e66aa0b3deb85a8f6ee53a5..b0c953ad8275740679c847e348b311de93d64965 100644
--- a/src/main/java/net/minecraft/world/entity/Mob.java
+++ b/src/main/java/net/minecraft/world/entity/Mob.java
@@ -618,7 +618,7 @@ public abstract class Mob extends LivingEntity implements Targeting {
this.setLeftHanded(nbt.getBoolean("LeftHanded"));
if (nbt.contains("DeathLootTable", 8)) {
- this.lootTable = new ResourceLocation(nbt.getString("DeathLootTable"));
+ this.lootTable = ResourceLocation.tryParse(nbt.getString("DeathLootTable"));
this.lootTableSeed = nbt.getLong("DeathLootTableSeed");
}

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Limit ListTags to 1024 elements
diff --git a/src/main/java/net/minecraft/nbt/ListTag.java b/src/main/java/net/minecraft/nbt/ListTag.java
index 749d3e67a877d7d1ed47b5fef511a604ee6589b6..fe7a7fd77c7dd1750144fb57e181c51ccda26329 100644
index b74b77ec2fd45c7a44e4f2696c4f57075c3d4080..c6ac2aff889ff157da47ee26fbfc1f83616d5b8f 100644
--- a/src/main/java/net/minecraft/nbt/ListTag.java
+++ b/src/main/java/net/minecraft/nbt/ListTag.java
@@ -31,6 +31,7 @@ public class ListTag extends CollectionTag<Tag> {

View file

@ -6,7 +6,7 @@ Subject: [PATCH] Fixes creative-killing potion effects and certain potion
diff --git a/src/main/java/net/minecraft/world/effect/MobEffect.java b/src/main/java/net/minecraft/world/effect/MobEffect.java
index 2cc714585fc3790b70a7ad1ab8034543462e2b3b..2d3706d8d0dbed3b3588066eaa6b9ce1b266294f 100644
index bcce17f884b57e619749351b7b2047f0a5f9be71..65e245e02676077e481f8a1fcd9885c389f9666c 100644
--- a/src/main/java/net/minecraft/world/effect/MobEffect.java
+++ b/src/main/java/net/minecraft/world/effect/MobEffect.java
@@ -58,6 +58,7 @@ public class MobEffect {

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Fix negative death times
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 67627bbf84f5aab2872f636b1dcb6728c8494147..468f64afb7e9b3ef579205d3beea025deb31b460 100644
index a189461330a4d427a7450d504ef13de3605497e3..79430aef1cbcad7d872435ebdec60321e2573bb3 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -630,7 +630,7 @@ public abstract class LivingEntity extends Entity implements Attackable {

View file

@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Business Goose <arclicious@vivaldi.net>
Date: Sat, 11 Jun 2022 23:33:13 -0500
Subject: [PATCH] Account for items inside containers
From: Telesphoreo <me@telesphoreo.me>
Date: Sat, 10 Dec 2022 23:38:53 -0600
Subject: [PATCH] Reset large tags
diff --git a/src/main/java/net/minecraft/world/ContainerHelper.java b/src/main/java/net/minecraft/world/ContainerHelper.java
@ -58,8 +58,56 @@ index 4092c7a8c2b0d9d26e6f4d97386735236300d132..9e0ab51dd7a4f9fed8f9edde962d42d4
stacks.set(j, ItemStack.of(compoundTag));
}
}
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
index adb7220be617d6d9f2cdd7fbe4fa2dd24cc7d142..aabde31cd4c6a4f58855156272bc451b042cc315 100644
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
@@ -21,6 +21,7 @@ import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.Nullable;
+import me.totalfreedom.scissors.NbtUtility;
import net.minecraft.ChatFormatting;
import net.minecraft.Util;
import net.minecraft.advancements.CriteriaTriggers;
@@ -253,6 +254,12 @@ public final class ItemStack {
// CraftBukkit - break into own method
private void load(CompoundTag nbttagcompound) {
+ // Scissors start - Reset large tags
+ if (NbtUtility.isTooLarge(nbttagcompound)) {
+ // Reset tag without destroying item
+ nbttagcompound = NbtUtility.Item.removeItemData(nbttagcompound);
+ }
+ // Scissors end
this.item = (Item) BuiltInRegistries.ITEM.get(new ResourceLocation(nbttagcompound.getString("id")));
this.count = nbttagcompound.getByte("Count");
if (nbttagcompound.contains("tag", 10)) {
@@ -550,7 +557,11 @@ public final class ItemStack {
nbt.putString("id", minecraftkey == null ? "minecraft:air" : minecraftkey.toString());
nbt.putByte("Count", (byte) this.count);
if (this.tag != null) {
- nbt.put("tag", this.tag.copy());
+ // Scissors start - Don't save large tags
+ if (!NbtUtility.isTooLarge(this.tag)) {
+ nbt.put("tag", this.tag.copy());
+ }
+ // Scissors end
}
return nbt;
@@ -880,6 +891,9 @@ public final class ItemStack {
// Paper end
public void setTag(@Nullable CompoundTag nbt) {
+ // Scissors start - Ignore large tags
+ if (NbtUtility.isTooLarge(nbt)) return;
+ // Scissors end
this.tag = nbt;
this.processEnchantOrder(this.tag); // Paper
if (this.getItem().canBeDepleted()) {
diff --git a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
index 2a786c9fd29dc2139cf487fa645cd43345d60167..dbdc66620ae4284cfe96f633b1f4db46866b597b 100644
index 448fa4f4f200430d6ce3051763c7ceb697696146..430810b9cc554dfb3bb0972c103c8a36e8db67ef 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
@@ -9,6 +9,7 @@ import java.util.Iterator;
@ -201,7 +249,7 @@ index 881379681c39230a00b3a1f11cd87498984396c7..1be5d600573f7632e6630224530dd765
}
diff --git a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
index 789e5458f4a137694563a22612455506807de51b..84c721da46b7786857677b56f439c2b9448ba4b8 100644
index a8a26a0a37a08b6bbeb5a1fde417d6f448d3c79f..2502c38640fa39552efc02b59733bd0d7330e13a 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/HopperBlockEntity.java
@@ -6,6 +6,7 @@ import java.util.function.BooleanSupplier;

View file

@ -1,54 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Telesphoreo <me@telesphoreo.me>
Date: Sat, 10 Dec 2022 23:38:53 -0600
Subject: [PATCH] Reset large tags
diff --git a/src/main/java/net/minecraft/world/item/ItemStack.java b/src/main/java/net/minecraft/world/item/ItemStack.java
index b367ec1feaccbd67e9e28c0d0515e163f37135fe..d1547b9ba36baec925751b9bb0498c8a8cac12f8 100644
--- a/src/main/java/net/minecraft/world/item/ItemStack.java
+++ b/src/main/java/net/minecraft/world/item/ItemStack.java
@@ -21,6 +21,7 @@ import java.util.function.Predicate;
import java.util.stream.Collectors;
import java.util.stream.Stream;
import javax.annotation.Nullable;
+import me.totalfreedom.scissors.NbtUtility;
import net.minecraft.ChatFormatting;
import net.minecraft.Util;
import net.minecraft.advancements.CriteriaTriggers;
@@ -253,6 +254,12 @@ public final class ItemStack {
// CraftBukkit - break into own method
private void load(CompoundTag nbttagcompound) {
+ // Scissors start - Reset large tags
+ if (NbtUtility.isTooLarge(nbttagcompound)) {
+ // Reset tag without destroying item
+ nbttagcompound = NbtUtility.Item.removeItemData(nbttagcompound);
+ }
+ // Scissors end
this.item = (Item) BuiltInRegistries.ITEM.get(new ResourceLocation(nbttagcompound.getString("id")));
this.count = nbttagcompound.getByte("Count");
if (nbttagcompound.contains("tag", 10)) {
@@ -550,7 +557,11 @@ public final class ItemStack {
nbt.putString("id", minecraftkey == null ? "minecraft:air" : minecraftkey.toString());
nbt.putByte("Count", (byte) this.count);
if (this.tag != null) {
- nbt.put("tag", this.tag.copy());
+ // Scissors start - Don't save large tags
+ if (!NbtUtility.isTooLarge(this.tag)) {
+ nbt.put("tag", this.tag.copy());
+ }
+ // Scissors end
}
return nbt;
@@ -880,6 +891,9 @@ public final class ItemStack {
// Paper end
public void setTag(@Nullable CompoundTag nbt) {
+ // Scissors start - Ignore large tags
+ if (NbtUtility.isTooLarge(nbt)) return;
+ // Scissors end
this.tag = nbt;
this.processEnchantOrder(this.tag); // Paper
if (this.getItem().canBeDepleted()) {

View file

@ -110,7 +110,7 @@ index 97a2657bc98d41c3c1e376b266d2c85f685acc88..7b6476455e095eed15c92797ce3a3e11
}
}).reduce((accumulator, current) -> {
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 92202262eff01ae3bbeff0e6ebdcf26ad613c169..38c027c0fbddf58136b7d67eb7156403a79de4d1 100644
index b38c4cbcf0405d82c7b6e018e80a3174e460c1a4..bcd9565c8e09b44ca4cac372bea1b1e9ec343871 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -2473,12 +2473,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Don't log invalid teams to console
diff --git a/src/main/java/net/minecraft/world/entity/LivingEntity.java b/src/main/java/net/minecraft/world/entity/LivingEntity.java
index 468f64afb7e9b3ef579205d3beea025deb31b460..71a32f8dfdf043f55f092225a13884ae8935e67c 100644
index 79430aef1cbcad7d872435ebdec60321e2573bb3..ee1744ca00fe14b052b9d164d2bbe9dc93201bde 100644
--- a/src/main/java/net/minecraft/world/entity/LivingEntity.java
+++ b/src/main/java/net/minecraft/world/entity/LivingEntity.java
@@ -862,7 +862,9 @@ public abstract class LivingEntity extends Entity implements Attackable {

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Validate block entity tag query positions
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 37fcbdcddaa6cbfd6ae37d70cffab957c90f4e07..01f88bf2f4872884a9c4c2d1d5f1369c61fb0ebf 100644
index afc17ec86d12cefc30c2aabd86a04131f7dffdb6..27c48014605d34d9716ea3029ac84b2eb4907a4e 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -1375,7 +1375,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Prevent velocity freeze
diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java
index 2096e8a0bdbcfc865f175f3a01ab688542481531..15d375221c253dc4ca1b598eb80b4638eba6f8d0 100644
index 6c9a8f062f989db022154155e8a05b334a0510da..68c80eab60680c647094b4465ee1377c9e13d5ff 100644
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractHurtingProjectile.java
@@ -1,5 +1,6 @@

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Patch invalid entity rotation log spam
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
index 38c027c0fbddf58136b7d67eb7156403a79de4d1..ff3940a0d552140cae820fbed16bfb5e69507822 100644
index bcd9565c8e09b44ca4cac372bea1b1e9ec343871..71e64ecf217b77371b5be32f93c66be042f124f2 100644
--- a/src/main/java/net/minecraft/world/entity/Entity.java
+++ b/src/main/java/net/minecraft/world/entity/Entity.java
@@ -4615,7 +4615,9 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {

View file

@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Luna <lunahatesgogle@gmail.com>
Date: Fri, 28 Apr 2023 16:29:23 -0300
Subject: [PATCH] Limit map decoration text length
Subject: [PATCH] Limit map decorations
diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapDecoration.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapDecoration.java
@ -29,3 +29,20 @@ index 347d2914f9560a3ee8cea59444bc0dfbb7cf3456..b225f770869832775c9a8a79ffaf89e9
this.type = type;
this.x = x;
this.y = z;
diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
index 3b12030b49b1c539684d75ca3896eb498400ef99..a1f042e5329343489cf30e436a8f553d39e5a6e4 100644
--- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
+++ b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
@@ -354,6 +354,12 @@ public class MapItemSavedData extends SavedData {
}
private void addDecoration(MapDecoration.Type type, @Nullable LevelAccessor world, String key, double x, double z, double rotation, @Nullable Component text) {
+ // Scissors start - Limit decoration count
+ if (this.decorations.size() > 32) {
+ return;
+ }
+ // Scissors end
+
int i = 1 << this.scale;
float f = (float) (x - (double) this.centerX) / (float) i;
float f1 = (float) (z - (double) this.centerZ) / (float) i;

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Prevent player banning using duplicate UUIDs
diff --git a/src/main/java/net/minecraft/server/level/ServerLevel.java b/src/main/java/net/minecraft/server/level/ServerLevel.java
index 2ac23779222369ace69f1e3f7fb12184865b7a43..05c8e4e30b2dce565e84f4c09b3f27244f8c0451 100644
index 18aac3da3c88f33b1a71a5920a8daa27e9723913..f5b59d0ab82472e1c992ffb6a8b7fbb687a2b70f 100644
--- a/src/main/java/net/minecraft/server/level/ServerLevel.java
+++ b/src/main/java/net/minecraft/server/level/ServerLevel.java
@@ -1610,7 +1610,14 @@ public class ServerLevel extends Level implements WorldGenLevel {

View file

@ -1,23 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Luna <lunahatesgogle@gmail.com>
Date: Fri, 28 Apr 2023 16:34:15 -0300
Subject: [PATCH] Limit map decoration count
diff --git a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
index 3b12030b49b1c539684d75ca3896eb498400ef99..a1f042e5329343489cf30e436a8f553d39e5a6e4 100644
--- a/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
+++ b/src/main/java/net/minecraft/world/level/saveddata/maps/MapItemSavedData.java
@@ -354,6 +354,12 @@ public class MapItemSavedData extends SavedData {
}
private void addDecoration(MapDecoration.Type type, @Nullable LevelAccessor world, String key, double x, double z, double rotation, @Nullable Component text) {
+ // Scissors start - Limit decoration count
+ if (this.decorations.size() > 32) {
+ return;
+ }
+ // Scissors end
+
int i = 1 << this.scale;
float f = (float) (x - (double) this.centerX) / (float) i;
float f1 = (float) (z - (double) this.centerZ) / (float) i;

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Make excluding players from nbt components configurable
diff --git a/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java b/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java
index 9f2a51fddb692f5152c32dcbe1f5a6ba150634e4..39b56ca496ed7369ead21805d476c2b813fcdd1d 100644
index ec93980fefcab57b7bac78d2fc4a217b376b7eca..44920c46aa75bcdc450e192d8c8ca0bf7ad0b7d5 100644
--- a/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java
+++ b/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java
@@ -87,8 +87,8 @@ public class ScissorsConfig

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Add depth limit to Component deserializer
diff --git a/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java b/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java
index 39b56ca496ed7369ead21805d476c2b813fcdd1d..9659cff6412584190ff0c32e01f602de4ff7d3b3 100644
index 44920c46aa75bcdc450e192d8c8ca0bf7ad0b7d5..56aa12b57d893b0be9ff7a18df87645dae2c8a19 100644
--- a/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java
+++ b/src/main/java/me/totalfreedom/scissors/ScissorsConfig.java
@@ -87,8 +87,8 @@ public class ScissorsConfig

View file

@ -0,0 +1,90 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Allink <arclicious@vivaldi.net>
Date: Fri, 2 Jun 2023 20:55:18 +0100
Subject: [PATCH] Implement command block events
diff --git a/src/main/java/net/minecraft/network/protocol/game/ServerboundSetCommandMinecartPacket.java b/src/main/java/net/minecraft/network/protocol/game/ServerboundSetCommandMinecartPacket.java
index c99fc118013cb3d4043638e2001a8297e79ddf9c..cdaa81e1f2167b29ec01cc25e51a8400deb533d2 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ServerboundSetCommandMinecartPacket.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ServerboundSetCommandMinecartPacket.java
@@ -9,7 +9,7 @@ import net.minecraft.world.level.BaseCommandBlock;
import net.minecraft.world.level.Level;
public class ServerboundSetCommandMinecartPacket implements Packet<ServerGamePacketListener> {
- private final int entity;
+ public final int entity; // Scissors - private -> public
private final String command;
private final boolean trackOutput;
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 26bf05922698c734302fa80076e7a1eadbfe1d8d..dcb8058380bea82bae1b02de4fdcbd0463d3a4f3 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -1,6 +1,8 @@
package net.minecraft.server.network;
import me.totalfreedom.scissors.ScissorsConfig;
+import me.totalfreedom.scissors.event.block.CommandBlockPlayerEditEvent;
+import me.totalfreedom.scissors.event.block.CommandMinecartPlayerEditEvent;
import me.totalfreedom.scissors.event.player.SpectatorTeleportEvent;
import com.google.common.collect.Lists;
import com.google.common.primitives.Floats;
@@ -160,6 +162,7 @@ import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.ProfilePublicKey;
import net.minecraft.world.entity.projectile.AbstractArrow;
import net.minecraft.world.entity.vehicle.Boat;
+import net.minecraft.world.entity.vehicle.MinecartCommandBlock;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.BucketItem;
import net.minecraft.world.item.Item;
@@ -188,6 +191,8 @@ import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
+import org.bukkit.craftbukkit.block.CraftCommandBlock;
+import org.bukkit.craftbukkit.entity.CraftMinecartCommand;
import org.slf4j.Logger;
// CraftBukkit start
@@ -1001,6 +1006,17 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
this.player.level().getChunkAt(blockposition).setBlockEntity(tileentity);
}
+ CommandBlockPlayerEditEvent event = new CommandBlockPlayerEditEvent(this.getCraftPlayer(), commandblocklistenerabstract.getCommand(), s, new CraftCommandBlock(this.player.level().getWorld(), tileentitycommand));
+
+ if (!event.callEvent()) {
+ return;
+ }
+
+ s = event.getNewCommand();
+
+
+ // Scissors end
+
commandblocklistenerabstract.setCommand(s);
commandblocklistenerabstract.setTrackOutput(flag);
if (!flag) {
@@ -1032,7 +1048,21 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
BaseCommandBlock commandblocklistenerabstract = packet.getCommandBlock(this.player.level());
if (commandblocklistenerabstract != null) {
- commandblocklistenerabstract.setCommand(packet.getCommand());
+ // Scissors start - Implement command block events
+ String command = packet.getCommand();
+ CommandMinecartPlayerEditEvent event = new CommandMinecartPlayerEditEvent(this.getCraftPlayer(), commandblocklistenerabstract.getCommand(), command, new CraftMinecartCommand(this.cserver, (MinecartCommandBlock) this.player.level().getEntity(packet.entity)));
+
+ if (!event.callEvent()) {
+ return;
+ }
+
+ command = event.getNewCommand();
+ commandblocklistenerabstract.setCommand(command);
+
+ // commandblocklistenerabstract.setCommand(packet.getCommand());
+
+ // Scissors end
+
commandblocklistenerabstract.setTrackOutput(packet.isTrackOutput());
if (!packet.isTrackOutput()) {
commandblocklistenerabstract.setLastOutput((Component) null);

View file

@ -5,7 +5,7 @@ Subject: [PATCH] Limit beacon effectRange
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
index f2325c0c475bb465f5275f78c71949648a860d0c..4ec228ce026ee39eebd17d180fb5caea1b74e6e2 100644
index 5005a0ad5f703727ea9c618ae4b769a77d5655b5..8645ebb37dfab4e76b238a3660816a59018d3dde 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/BeaconBlockEntity.java
@@ -83,7 +83,7 @@ public class BeaconBlockEntity extends BlockEntity implements MenuProvider, Name

View file

@ -1,315 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Allink <arclicious@vivaldi.net>
Date: Fri, 2 Jun 2023 20:55:18 +0100
Subject: [PATCH] Implement command block events
diff --git a/src/main/java/net/minecraft/network/protocol/game/ServerboundSetCommandMinecartPacket.java b/src/main/java/net/minecraft/network/protocol/game/ServerboundSetCommandMinecartPacket.java
index c99fc118013cb3d4043638e2001a8297e79ddf9c..cdaa81e1f2167b29ec01cc25e51a8400deb533d2 100644
--- a/src/main/java/net/minecraft/network/protocol/game/ServerboundSetCommandMinecartPacket.java
+++ b/src/main/java/net/minecraft/network/protocol/game/ServerboundSetCommandMinecartPacket.java
@@ -9,7 +9,7 @@ import net.minecraft.world.level.BaseCommandBlock;
import net.minecraft.world.level.Level;
public class ServerboundSetCommandMinecartPacket implements Packet<ServerGamePacketListener> {
- private final int entity;
+ public final int entity; // Scissors - private -> public
private final String command;
private final boolean trackOutput;
diff --git a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
index 26bf05922698c734302fa80076e7a1eadbfe1d8d..5422eb931d83f65d40be5fcca49b6d9e57eec735 100644
--- a/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
+++ b/src/main/java/net/minecraft/server/network/ServerGamePacketListenerImpl.java
@@ -1,6 +1,8 @@
package net.minecraft.server.network;
import me.totalfreedom.scissors.ScissorsConfig;
+import me.totalfreedom.scissors.event.block.CommandBlockPlayerEditEvent;
+import me.totalfreedom.scissors.event.block.CommandMinecartPlayerEditEvent;
import me.totalfreedom.scissors.event.player.SpectatorTeleportEvent;
import com.google.common.collect.Lists;
import com.google.common.primitives.Floats;
@@ -160,6 +162,7 @@ import net.minecraft.world.entity.player.Inventory;
import net.minecraft.world.entity.player.ProfilePublicKey;
import net.minecraft.world.entity.projectile.AbstractArrow;
import net.minecraft.world.entity.vehicle.Boat;
+import net.minecraft.world.entity.vehicle.MinecartCommandBlock;
import net.minecraft.world.item.BlockItem;
import net.minecraft.world.item.BucketItem;
import net.minecraft.world.item.Item;
@@ -188,6 +191,10 @@ import net.minecraft.world.phys.Vec3;
import net.minecraft.world.phys.shapes.BooleanOp;
import net.minecraft.world.phys.shapes.Shapes;
import net.minecraft.world.phys.shapes.VoxelShape;
+import org.bukkit.craftbukkit.block.CraftBlockStates;
+import org.bukkit.craftbukkit.block.CraftCommandBlock;
+import org.bukkit.craftbukkit.entity.CraftMinecartCommand;
+import org.bukkit.entity.minecart.CommandMinecart;
import org.slf4j.Logger;
// CraftBukkit start
@@ -651,14 +658,14 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
if (this.player.level().paperConfig().chunks.preventMovingIntoUnloadedChunks && (
!worldserver.areChunksLoadedForMove(this.player.getBoundingBox().expandTowards(new Vec3(toX, toY, toZ).subtract(this.player.position()))) ||
!worldserver.areChunksLoadedForMove(entity.getBoundingBox().expandTowards(new Vec3(toX, toY, toZ).subtract(entity.position())))
- )) {
+ )) {
this.connection.send(new ClientboundMoveVehiclePacket(entity));
return;
}
// Paper end
if (d10 - d9 > Math.max(100.0D, Math.pow((double) (org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed), 2)) && !this.isSingleplayerOwner()) {
- // CraftBukkit end
+ // CraftBukkit end
ServerGamePacketListenerImpl.LOGGER.warn("{} (vehicle of {}) moved too quickly! {},{},{}", new Object[]{entity.getName().getString(), this.player.getName().getString(), d6, d7, d8});
this.connection.send(new ClientboundMoveVehiclePacket(entity));
return;
@@ -905,11 +912,11 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
// Paper end - Don't suggest if tab-complete is disabled
// Paper start - async tab completion
TAB_COMPLETE_EXECUTOR.execute(() -> {
- StringReader stringreader = new StringReader(packet.getCommand());
+ StringReader stringreader = new StringReader(packet.getCommand());
- if (stringreader.canRead() && stringreader.peek() == '/') {
- stringreader.skip();
- }
+ if (stringreader.canRead() && stringreader.peek() == '/') {
+ stringreader.skip();
+ }
final String command = packet.getCommand();
final com.destroystokyo.paper.event.server.AsyncTabCompleteEvent event = new com.destroystokyo.paper.event.server.AsyncTabCompleteEvent(this.getCraftPlayer(), command, true, null);
event.callEvent();
@@ -1001,6 +1008,17 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
this.player.level().getChunkAt(blockposition).setBlockEntity(tileentity);
}
+ CommandBlockPlayerEditEvent event = new CommandBlockPlayerEditEvent(this.getCraftPlayer(), commandblocklistenerabstract.getCommand(), s, new CraftCommandBlock(this.player.level().getWorld(), tileentitycommand));
+
+ if (!event.callEvent()) {
+ return;
+ }
+
+ s = event.getNewCommand();
+
+
+ // Scissors end
+
commandblocklistenerabstract.setCommand(s);
commandblocklistenerabstract.setTrackOutput(flag);
if (!flag) {
@@ -1032,7 +1050,21 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
BaseCommandBlock commandblocklistenerabstract = packet.getCommandBlock(this.player.level());
if (commandblocklistenerabstract != null) {
- commandblocklistenerabstract.setCommand(packet.getCommand());
+ // Scissors start - Implement command block events
+ String command = packet.getCommand();
+ CommandMinecartPlayerEditEvent event = new CommandMinecartPlayerEditEvent(this.getCraftPlayer(), commandblocklistenerabstract.getCommand(), command, new CraftMinecartCommand(this.cserver, (MinecartCommandBlock) this.player.level().getEntity(packet.entity)));
+
+ if (!event.callEvent()) {
+ return;
+ }
+
+ command = event.getNewCommand();
+ commandblocklistenerabstract.setCommand(command);
+
+ // commandblocklistenerabstract.setCommand(packet.getCommand());
+
+ // Scissors end
+
commandblocklistenerabstract.setTrackOutput(packet.isTrackOutput());
if (!packet.isTrackOutput()) {
commandblocklistenerabstract.setLastOutput((Component) null);
@@ -1484,7 +1516,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
float f2 = this.player.isFallFlying() ? 300.0F : 100.0F;
if (d10 - d9 > Math.max(f2, Math.pow((double) (org.spigotmc.SpigotConfig.movedTooQuicklyMultiplier * (float) i * speed), 2)) && !this.isSingleplayerOwner()) {
- // CraftBukkit end
+ // CraftBukkit end
ServerGamePacketListenerImpl.LOGGER.warn("{} moved too quickly! {},{},{}", new Object[]{this.player.getName().getString(), d6, d7, d8});
this.teleport(this.player.getX(), this.player.getY(), this.player.getZ(), this.player.getYRot(), this.player.getXRot());
return;
@@ -1979,7 +2011,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
MutableComponent ichatmutablecomponent = Component.translatable("build.tooHigh", i - 1).withStyle(ChatFormatting.RED);
this.player.sendSystemMessage(ichatmutablecomponent, true);
- } else if (enuminteractionresult.shouldSwing() && !this.player.gameMode.interactResult) { // Paper
+ } else if (enuminteractionresult.shouldSwing() && !this.player.gameMode.interactResult) { // Paper
this.player.swing(enumhand, true);
}
}
@@ -2230,32 +2262,32 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
// CraftBukkit end
if (ServerGamePacketListenerImpl.isChatMessageIllegal(packet.message())) {
this.server.scheduleOnMain(() -> { // Paper - push to main for event firing
- this.disconnect(Component.translatable("multiplayer.disconnect.illegal_characters"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_CHARACTERS); // Paper - add cause
+ this.disconnect(Component.translatable("multiplayer.disconnect.illegal_characters"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_CHARACTERS); // Paper - add cause
}); // Paper - push to main for event firing
} else {
Optional<LastSeenMessages> optional = this.tryHandleChat(packet.message(), packet.timeStamp(), packet.lastSeenMessages());
if (optional.isPresent()) {
// this.server.submit(() -> { // CraftBukkit - async chat
- PlayerChatMessage playerchatmessage;
+ PlayerChatMessage playerchatmessage;
- try {
- playerchatmessage = this.getSignedMessage(packet, (LastSeenMessages) optional.get());
- } catch (SignedMessageChain.DecodeException signedmessagechain_a) {
- this.handleMessageDecodeFailure(signedmessagechain_a);
- return;
- }
+ try {
+ playerchatmessage = this.getSignedMessage(packet, (LastSeenMessages) optional.get());
+ } catch (SignedMessageChain.DecodeException signedmessagechain_a) {
+ this.handleMessageDecodeFailure(signedmessagechain_a);
+ return;
+ }
- CompletableFuture<FilteredText> completablefuture = this.filterTextPacket(playerchatmessage.signedContent());
- CompletableFuture<net.minecraft.network.chat.ChatDecorator.Result> completablefuture1 = this.server.getChatDecorator().decorate(this.player, null, playerchatmessage.decoratedContent()); // Paper
+ CompletableFuture<FilteredText> completablefuture = this.filterTextPacket(playerchatmessage.signedContent());
+ CompletableFuture<net.minecraft.network.chat.ChatDecorator.Result> completablefuture1 = this.server.getChatDecorator().decorate(this.player, null, playerchatmessage.decoratedContent()); // Paper
- this.chatMessageChain.append((executor) -> {
- return CompletableFuture.allOf(completablefuture, completablefuture1).thenAcceptAsync((ovoid) -> {
- PlayerChatMessage playerchatmessage1 = playerchatmessage.filter(((FilteredText) completablefuture.join()).mask()).withResult(completablefuture1.join()); // Paper
+ this.chatMessageChain.append((executor) -> {
+ return CompletableFuture.allOf(completablefuture, completablefuture1).thenAcceptAsync((ovoid) -> {
+ PlayerChatMessage playerchatmessage1 = playerchatmessage.filter(((FilteredText) completablefuture.join()).mask()).withResult(completablefuture1.join()); // Paper
- this.broadcastChatMessage(playerchatmessage1);
- }, this.server.chatExecutor); // CraftBukkit - async chat
- });
+ this.broadcastChatMessage(playerchatmessage1);
+ }, this.server.chatExecutor); // CraftBukkit - async chat
+ });
// }); // CraftBukkit - async chat
}
@@ -2266,7 +2298,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
public void handleChatCommand(ServerboundChatCommandPacket packet) {
if (ServerGamePacketListenerImpl.isChatMessageIllegal(packet.command())) {
this.server.scheduleOnMain(() -> { // Paper - push to main for event firing
- this.disconnect(Component.translatable("multiplayer.disconnect.illegal_characters"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_CHARACTERS); // Paper
+ this.disconnect(Component.translatable("multiplayer.disconnect.illegal_characters"), org.bukkit.event.player.PlayerKickEvent.Cause.ILLEGAL_CHARACTERS); // Paper
}); // Paper - push to main for event firing
} else {
Optional<LastSeenMessages> optional = this.tryHandleChat(packet.command(), packet.timeStamp(), packet.lastSeenMessages());
@@ -2291,7 +2323,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
// CraftBukkit start
String command = "/" + packet.command();
if (org.spigotmc.SpigotConfig.logCommands) { // Paper
- ServerGamePacketListenerImpl.LOGGER.info(this.player.getScoreboardName() + " issued server command: " + command);
+ ServerGamePacketListenerImpl.LOGGER.info(this.player.getScoreboardName() + " issued server command: " + command);
} // Paper
PlayerCommandPreprocessEvent event = new PlayerCommandPreprocessEvent(this.getCraftPlayer(), command, new LazyPlayerSet(this.server));
@@ -2356,7 +2388,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
if (!this.updateChatOrder(timestamp)) {
ServerGamePacketListenerImpl.LOGGER.warn("{} sent out-of-order chat: '{}': {} > {}", this.player.getName().getString(), message, this.lastChatTimeStamp.get().getEpochSecond(), timestamp.getEpochSecond()); // Paper
this.server.scheduleOnMain(() -> { // Paper - push to main
- this.disconnect(Component.translatable("multiplayer.disconnect.out_of_order_chat"), org.bukkit.event.player.PlayerKickEvent.Cause.OUT_OF_ORDER_CHAT); // Paper - kick event ca
+ this.disconnect(Component.translatable("multiplayer.disconnect.out_of_order_chat"), org.bukkit.event.player.PlayerKickEvent.Cause.OUT_OF_ORDER_CHAT); // Paper - kick event ca
}); // Paper - push to main
return Optional.empty();
} else {
@@ -2427,7 +2459,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
this.handleCommand(s);
} else if (this.player.getChatVisibility() == ChatVisiblity.SYSTEM) {
// Do nothing, this is coming from a plugin
- // Paper start
+ // Paper start
} else if (true) {
final ChatProcessor cp = new ChatProcessor(this.server, this.player, original, async);
cp.process();
@@ -2538,7 +2570,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
// Paper End
co.aikar.timings.MinecraftTimings.playerCommandTimer.startTiming(); // Paper
if ( org.spigotmc.SpigotConfig.logCommands ) // Spigot
- this.LOGGER.info(this.player.getScoreboardName() + " issued server command: " + s);
+ this.LOGGER.info(this.player.getScoreboardName() + " issued server command: " + s);
CraftPlayer player = this.getCraftPlayer();
@@ -2617,16 +2649,16 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
@Override
public void handleChatAck(ServerboundChatAckPacket packet) {
LastSeenMessagesValidator lastseenmessagesvalidator = this.lastSeenMessages;
- if (!this.lastSeenMessages.applyOffset(packet.offset())) {
- synchronized (this.lastSeenMessages) {
- // Scissors start - Add configuration option to disable chat signatures
- if (!ScissorsConfig.chatSignaturesEnabled)
- {
- return;
- }
- // Scissors end
- ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message acknowledgements from {}", this.player.getName().getString());
- this.disconnect(ServerGamePacketListenerImpl.CHAT_VALIDATION_FAILED, org.bukkit.event.player.PlayerKickEvent.Cause.CHAT_VALIDATION_FAILED); // Paper - kick event causes
+ if (!this.lastSeenMessages.applyOffset(packet.offset())) {
+ synchronized (this.lastSeenMessages) {
+ // Scissors start - Add configuration option to disable chat signatures
+ if (!ScissorsConfig.chatSignaturesEnabled)
+ {
+ return;
+ }
+ // Scissors end
+ ServerGamePacketListenerImpl.LOGGER.warn("Failed to validate message acknowledgements from {}", this.player.getName().getString());
+ this.disconnect(ServerGamePacketListenerImpl.CHAT_VALIDATION_FAILED, org.bukkit.event.player.PlayerKickEvent.Cause.CHAT_VALIDATION_FAILED); // Paper - kick event causes
}
}
@@ -2865,7 +2897,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
}
if (event.isCancelled()) {
- ServerGamePacketListenerImpl.this.player.containerMenu.sendAllDataToRemote(); // Paper - Refresh player inventory
+ ServerGamePacketListenerImpl.this.player.containerMenu.sendAllDataToRemote(); // Paper - Refresh player inventory
return;
}
// CraftBukkit end
@@ -3439,19 +3471,19 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
itemstack = CraftItemStack.asNMSCopy(event.getCursor());
switch (event.getResult()) {
- case ALLOW:
- // Plugin cleared the id / stacksize checks
- flag2 = true;
- break;
- case DEFAULT:
- break;
- case DENY:
- // Reset the slot
- if (packet.getSlotNum() >= 0) {
- this.player.connection.send(new ClientboundContainerSetSlotPacket(this.player.inventoryMenu.containerId, this.player.inventoryMenu.incrementStateId(), packet.getSlotNum(), this.player.inventoryMenu.getSlot(packet.getSlotNum()).getItem()));
- this.player.connection.send(new ClientboundContainerSetSlotPacket(-1, this.player.inventoryMenu.incrementStateId(), -1, ItemStack.EMPTY));
- }
- return;
+ case ALLOW:
+ // Plugin cleared the id / stacksize checks
+ flag2 = true;
+ break;
+ case DEFAULT:
+ break;
+ case DENY:
+ // Reset the slot
+ if (packet.getSlotNum() >= 0) {
+ this.player.connection.send(new ClientboundContainerSetSlotPacket(this.player.inventoryMenu.containerId, this.player.inventoryMenu.incrementStateId(), packet.getSlotNum(), this.player.inventoryMenu.getSlot(packet.getSlotNum()).getItem()));
+ this.player.connection.send(new ClientboundContainerSetSlotPacket(-1, this.player.inventoryMenu.incrementStateId(), -1, ItemStack.EMPTY));
+ }
+ return;
}
}
// CraftBukkit end
@@ -3519,7 +3551,7 @@ public class ServerGamePacketListenerImpl implements ServerPlayerConnection, Tic
} else if (!this.isSingleplayerOwner()) {
// Paper start - This needs to be handled on the main thread for plugins
server.submit(() -> {
- this.disconnect(Component.translatable("disconnect.timeout"), org.bukkit.event.player.PlayerKickEvent.Cause.TIMEOUT); // Paper - kick event cause
+ this.disconnect(Component.translatable("disconnect.timeout"), org.bukkit.event.player.PlayerKickEvent.Cause.TIMEOUT); // Paper - kick event cause
});
// Paper end
}

View file

@ -1,7 +1,7 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Luna <lunahatesgogle@gmail.com>
Date: Tue, 13 Jun 2023 18:37:56 -0300
Subject: [PATCH] Some more ResourceLocation validation
Date: Tue, 13 Jun 2023 18:29:18 -0300
Subject: [PATCH] Improve validation of ResourceLocations
diff --git a/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/AbstractFurnaceBlockEntity.java
@ -23,7 +23,7 @@ index 430810b9cc554dfb3bb0972c103c8a36e8db67ef..b2832c75beab2a1fa077b0317392b6aa
// Paper start - cook speed API
diff --git a/src/main/java/net/minecraft/world/level/block/entity/BrushableBlockEntity.java b/src/main/java/net/minecraft/world/level/block/entity/BrushableBlockEntity.java
index 14ddb953176b02e7ac68401c5c03120f920739a1..c04d24930f03d91f341fb45bed3b8356890dce83 100644
index 7a3ac883be4015d41a4c7582341a424b4bd6bbf4..6a6d34831a3c9a1a0fd47dbfd3a497c0b7923ce5 100644
--- a/src/main/java/net/minecraft/world/level/block/entity/BrushableBlockEntity.java
+++ b/src/main/java/net/minecraft/world/level/block/entity/BrushableBlockEntity.java
@@ -199,7 +199,7 @@ public class BrushableBlockEntity extends BlockEntity {
@ -35,3 +35,15 @@ index 14ddb953176b02e7ac68401c5c03120f920739a1..c04d24930f03d91f341fb45bed3b8356
this.lootTableSeed = nbt.getLong("LootTableSeed");
return true;
} else {
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java b/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java
index 5014192edb9616ce725fc1592832034789527b6f..64da1b0afd51720803aba0d9e86d0b1743bdb0da 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java
@@ -21,6 +21,7 @@ public final class CraftNamespacedKey {
}
public static NamespacedKey fromMinecraft(ResourceLocation minecraft) {
+ if (minecraft == null) throw new IllegalArgumentException("Null ResourceLocation provided"); // Scissors
return new NamespacedKey(minecraft.getNamespace(), minecraft.getPath());
}

View file

@ -1,18 +0,0 @@
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
From: Luna <lunahatesgogle@gmail.com>
Date: Tue, 13 Jun 2023 18:29:18 -0300
Subject: [PATCH] Catch null ResourceLocations in CraftNamespacedKey
diff --git a/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java b/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java
index 5014192edb9616ce725fc1592832034789527b6f..64da1b0afd51720803aba0d9e86d0b1743bdb0da 100644
--- a/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java
+++ b/src/main/java/org/bukkit/craftbukkit/util/CraftNamespacedKey.java
@@ -21,6 +21,7 @@ public final class CraftNamespacedKey {
}
public static NamespacedKey fromMinecraft(ResourceLocation minecraft) {
+ if (minecraft == null) throw new IllegalArgumentException("Null ResourceLocation provided"); // Scissors
return new NamespacedKey(minecraft.getNamespace(), minecraft.getPath());
}