-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
276b46e
commit f032b42
Showing
6 changed files
with
227 additions
and
1 deletion.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,26 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Telesphoreo <me@telesphoreo.me> | ||
Date: Sun, 5 May 2024 12:16:30 -0500 | ||
Subject: [PATCH] UUID validation | ||
|
||
|
||
diff --git a/src/main/java/net/minecraft/network/chat/HoverEvent.java b/src/main/java/net/minecraft/network/chat/HoverEvent.java | ||
index 1a958f994365eb8f2e010d703046fb73e04b66e4..d8de9ec38f5e5b10c177895728815d8659d0b601 100644 | ||
--- a/src/main/java/net/minecraft/network/chat/HoverEvent.java | ||
+++ b/src/main/java/net/minecraft/network/chat/HoverEvent.java | ||
@@ -171,7 +171,14 @@ public class HoverEvent { | ||
DynamicOps<JsonElement> dynamicOps = (DynamicOps<JsonElement>)(ops != null ? ops.withParent(JsonOps.INSTANCE) : JsonOps.INSTANCE); | ||
DataResult<Component> dataResult = ComponentSerialization.CODEC.parse(dynamicOps, JsonParser.parseString(compoundTag.getString("name"))); | ||
EntityType<?> entityType = BuiltInRegistries.ENTITY_TYPE.get(new ResourceLocation(compoundTag.getString("type"))); | ||
- UUID uUID = UUID.fromString(compoundTag.getString("id")); | ||
+ // Scissors start | ||
+ UUID uUID; | ||
+ try { | ||
+ uUID = UUID.fromString(compoundTag.getString("id")); | ||
+ } catch (Exception ex) { | ||
+ return null; | ||
+ } | ||
+ // Scissors end | ||
return dataResult.map(textx -> new HoverEvent.EntityTooltipInfo(entityType, uUID, textx)); | ||
} catch (Exception var7) { | ||
return DataResult.error(() -> "Failed to parse tooltip: " + var7.getMessage()); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,97 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Telesphoreo <me@telesphoreo.me> | ||
Date: Sun, 5 May 2024 12:29:05 -0500 | ||
Subject: [PATCH] ResourceLocation validation | ||
|
||
|
||
diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java b/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java | ||
index 183f31c81d9c0a966e6b20c2cff3d279dfc7e622..5d32a985894656712553a3f79abc454d6802d135 100644 | ||
--- a/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java | ||
+++ b/src/main/java/com/destroystokyo/paper/loottable/PaperContainerEntityLootableInventory.java | ||
@@ -20,7 +20,7 @@ public class PaperContainerEntityLootableInventory implements PaperLootableEntit | ||
|
||
@Override | ||
public org.bukkit.loot.LootTable getLootTable() { | ||
- return entity.getLootTable() != null && !entity.getLootTable().location().getPath().isEmpty() ? Optionull.map(entity.getLootTable(), rk -> Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(rk.location()))) : null; | ||
+ return entity.getLootTable() != null && !entity.getLootTable().location().getPath().isEmpty() && entity.getLootTable().toString().length() < 256 ? Optionull.map(entity.getLootTable(), rk -> Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(rk.location()))) : null; // Scissors - Validate length of loot tables before even trying | ||
} | ||
|
||
@Override | ||
diff --git a/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java b/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java | ||
index 6f6e19b7b57cb3070ef5b6810d8449344705af8c..f364b0ca67c31ae2dfbdbf5eb7980e8ddf8b82f5 100644 | ||
--- a/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java | ||
+++ b/src/main/java/com/destroystokyo/paper/loottable/PaperTileEntityLootableInventory.java | ||
@@ -17,7 +17,7 @@ public class PaperTileEntityLootableInventory implements PaperLootableBlockInven | ||
|
||
@Override | ||
public org.bukkit.loot.LootTable getLootTable() { | ||
- return tileEntityLootable.lootTable != null && !tileEntityLootable.lootTable.location().getPath().isEmpty() ? Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(tileEntityLootable.lootTable.location())) : null; | ||
+ return tileEntityLootable.lootTable != null && !tileEntityLootable.lootTable.location().getPath().isEmpty() && tileEntityLootable.lootTable.toString().length() < 256 ? Bukkit.getLootTable(CraftNamespacedKey.fromMinecraft(tileEntityLootable.lootTable.location())) : null; // Scissors - Validate length of loot tables before even trying | ||
} | ||
|
||
@Override | ||
diff --git a/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java b/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java | ||
index c3215f15b3088199dcf96f62b58d0ec7c2b4125c..e290a8b5f790b8ad84c3e16f650afb731018fd4d 100644 | ||
--- a/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java | ||
+++ b/src/main/java/org/bukkit/craftbukkit/block/CraftLootable.java | ||
@@ -1,5 +1,6 @@ | ||
package org.bukkit.craftbukkit.block; | ||
|
||
+import net.minecraft.resources.ResourceLocation; | ||
import net.minecraft.world.level.block.entity.RandomizableContainerBlockEntity; | ||
import org.bukkit.Location; | ||
import org.bukkit.Nameable; | ||
@@ -29,7 +30,13 @@ public abstract class CraftLootable<T extends RandomizableContainerBlockEntity> | ||
|
||
@Override | ||
public LootTable getLootTable() { | ||
- return CraftLootTable.minecraftToBukkit(this.getSnapshot().lootTable); | ||
+ // Scissors start - Return a null loot table if the specified loot table is not valid | ||
+ try { | ||
+ return CraftLootTable.minecraftToBukkit(this.getSnapshot().lootTable); | ||
+ } catch (Exception ex) { | ||
+ return null; | ||
+ } | ||
+ // Scissors end | ||
} | ||
|
||
@Override | ||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java | ||
index 4388cd0303b45faf21631e7644baebb63baaba10..3c049fe04c6a4166e6fd3a24de9209d806d1e33a 100644 | ||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java | ||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMinecartContainer.java | ||
@@ -25,7 +25,14 @@ public abstract class CraftMinecartContainer extends CraftMinecart implements Lo | ||
|
||
@Override | ||
public LootTable getLootTable() { | ||
- return CraftLootTable.minecraftToBukkit(this.getHandle().lootTable); | ||
+ // Scissors start - Return a null loot table if the specified loot table is not valid | ||
+ try { | ||
+ return CraftLootTable.minecraftToBukkit(this.getHandle().lootTable); | ||
+ } catch (Exception exception) | ||
+ { | ||
+ return null; | ||
+ } | ||
+ // Scissors end | ||
} | ||
|
||
@Override | ||
diff --git a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java | ||
index e155501fb3a88edf3ddac3aa0aae1b6a5a84962e..b588a3a39f2c003ddd1490decbce31f0b22bb2e1 100644 | ||
--- a/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java | ||
+++ b/src/main/java/org/bukkit/craftbukkit/entity/CraftMob.java | ||
@@ -78,7 +78,13 @@ public abstract class CraftMob extends CraftLivingEntity implements Mob { | ||
|
||
@Override | ||
public LootTable getLootTable() { | ||
- return CraftLootTable.minecraftToBukkit(this.getHandle().getLootTable()); | ||
+ // Scissors start - Return a null loot table if the specified loot table is not valid | ||
+ try { | ||
+ return CraftLootTable.minecraftToBukkit(this.getHandle().getLootTable()); | ||
+ } catch (Exception exception) { | ||
+ return null; | ||
+ } | ||
+ // Scissors end | ||
} | ||
|
||
@Override |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Telesphoreo <me@telesphoreo.me> | ||
Date: Sun, 5 May 2024 12:31:13 -0500 | ||
Subject: [PATCH] Fixes log spam | ||
|
||
|
||
diff --git a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java | ||
index ee972fa1a2bc023ed18eaceae21c8c8244754e6a..4f92d9c5850156c2349371d801a96a477f1af96c 100644 | ||
--- a/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java | ||
+++ b/src/main/java/net/minecraft/world/entity/AreaEffectCloud.java | ||
@@ -385,7 +385,7 @@ public class AreaEffectCloud extends Entity implements TraceableEntity { | ||
|
||
if (nbt.contains("Particle", 10)) { | ||
ParticleTypes.CODEC.parse(registryops, nbt.get("Particle")).resultOrPartial((s) -> { | ||
- AreaEffectCloud.LOGGER.warn("Failed to parse area effect cloud particle options: '{}'", s); | ||
+ // Scissors - Don't log custom particle errors | ||
}).ifPresent(this::setParticle); | ||
} | ||
|
||
diff --git a/src/main/java/net/minecraft/world/entity/EntityType.java b/src/main/java/net/minecraft/world/entity/EntityType.java | ||
index a46bf73c608641bf1f00fd55242de71a0f2ee06e..06a4a1cb9e46b3981629f1f8c4a0028c407ce234 100644 | ||
--- a/src/main/java/net/minecraft/world/entity/EntityType.java | ||
+++ b/src/main/java/net/minecraft/world/entity/EntityType.java | ||
@@ -603,7 +603,7 @@ public class EntityType<T extends Entity> implements FeatureElement, EntityTypeT | ||
if (generation) entity.generation = true; // Paper - Don't fire sync event during generation | ||
entity.load(nbt); | ||
}, () -> { | ||
- EntityType.LOGGER.warn("Skipping Entity with id {}", nbt.getString("id")); | ||
+ // Scissors - Don't log invalid entities | ||
}); | ||
} | ||
|
28 changes: 28 additions & 0 deletions
28
patches/server/0005-Ignore-errors-thrown-when-trying-to-remove-minecart-.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Telesphoreo <me@telesphoreo.me> | ||
Date: Sun, 5 May 2024 12:32:55 -0500 | ||
Subject: [PATCH] Ignore errors thrown when trying to remove minecart entities | ||
with content in them | ||
|
||
|
||
diff --git a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java | ||
index 2704389bc3ec6dbbf1b568a4380972f8c0d62d15..508275ec947826bc14b1671c2ae29d9804a811f2 100644 | ||
--- a/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java | ||
+++ b/src/main/java/net/minecraft/world/entity/vehicle/AbstractMinecartContainer.java | ||
@@ -148,8 +148,14 @@ public abstract class AbstractMinecartContainer extends AbstractMinecart impleme | ||
@Override | ||
public void remove(Entity.RemovalReason entity_removalreason, EntityRemoveEvent.Cause cause) { | ||
// CraftBukkit end | ||
- if (!this.level().isClientSide && entity_removalreason.shouldDestroy()) { | ||
- Containers.dropContents(this.level(), (Entity) this, (Container) this); | ||
+ if (!this.level().isClientSide && entity_removalreason.shouldDestroy()) | ||
+ { | ||
+ // Scissors start - Ignore errors thrown when trying to remove Minecart entities with content in them | ||
+ try { | ||
+ Containers.dropContents(this.level(), (Entity) this, (Container) this); | ||
+ } catch (Exception ignored) | ||
+ {} | ||
+ // Scissors end | ||
} | ||
|
||
super.remove(entity_removalreason, cause); // CraftBukkit - add Bukkit remove cause |
41 changes: 41 additions & 0 deletions
41
patches/server/0006-Fixes-Knowledge-Books-causing-log-spam-when-invalid-.patch
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001 | ||
From: Telesphoreo <me@telesphoreo.me> | ||
Date: Sun, 5 May 2024 12:47:29 -0500 | ||
Subject: [PATCH] Fixes Knowledge Books causing log spam when invalid data is | ||
provided | ||
|
||
|
||
diff --git a/src/main/java/net/minecraft/world/item/KnowledgeBookItem.java b/src/main/java/net/minecraft/world/item/KnowledgeBookItem.java | ||
index 635936aaac2426de05f0450f10815b29b52ca617..0b122b281c195ca47e7eeb27be29bffd916a8535 100644 | ||
--- a/src/main/java/net/minecraft/world/item/KnowledgeBookItem.java | ||
+++ b/src/main/java/net/minecraft/world/item/KnowledgeBookItem.java | ||
@@ -38,9 +38,9 @@ public class KnowledgeBookItem extends Item { | ||
List<RecipeHolder<?>> list2 = new ArrayList<>(list.size()); | ||
|
||
for (ResourceLocation resourceLocation : list) { | ||
- Optional<RecipeHolder<?>> optional = recipeManager.byKey(resourceLocation); | ||
+ Optional<RecipeHolder<?>> optional = recipeManager.byKey(ResourceLocation.tryParse(resourceLocation.getNamespace())); // Scissors - Validate resource location | ||
if (!optional.isPresent()) { | ||
- LOGGER.error("Invalid recipe: {}", resourceLocation); | ||
+ // Scissors - don't log errors caused by invalid recipes being provided | ||
return InteractionResultHolder.fail(itemStack); | ||
} | ||
|
||
diff --git a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java | ||
index 20638aa593e0a6c78e4bfdb936e69f3d36e18f4e..00b877fb43a8793a0f07580be93d026b624ad011 100644 | ||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java | ||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java | ||
@@ -38,7 +38,12 @@ public class CraftMetaKnowledgeBook extends CraftMetaItem implements KnowledgeBo | ||
for (int i = 0; i < pages.size(); i++) { | ||
ResourceLocation recipe = pages.get(i); | ||
|
||
- this.addRecipe(CraftNamespacedKey.fromMinecraft(recipe)); | ||
+ // Scissors start - Don't add recipes with invalid namespaces | ||
+ try { | ||
+ this.addRecipe(CraftNamespacedKey.fromMinecraft(recipe)); | ||
+ } catch (Exception ignored) | ||
+ {} | ||
+ // Scissors end | ||
} | ||
}); | ||
} |