mirror of
https://github.com/AtlasMediaGroup/Scissors.git
synced 2024-11-30 08:06:01 +00:00
some more patches
This commit is contained in:
parent
5a93f07bd7
commit
37e93142a5
@ -1,49 +0,0 @@
|
|||||||
From 0000000000000000000000000000000000000000 Mon Sep 17 00:00:00 2001
|
|
||||||
From: Video <videogamesm12@gmail.com>
|
|
||||||
Date: Sun, 13 Mar 2022 18:42:07 -0600
|
|
||||||
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 b79f4ce38a42e4dba8ebdfc97dadc531b7245c7a..9c49be7c53a1f2a8c203341b8ded9cd222d0c178 100644
|
|
||||||
--- a/src/main/java/net/minecraft/world/item/KnowledgeBookItem.java
|
|
||||||
+++ b/src/main/java/net/minecraft/world/item/KnowledgeBookItem.java
|
|
||||||
@@ -40,9 +40,9 @@ public class KnowledgeBookItem extends Item {
|
|
||||||
|
|
||||||
for(int i = 0; i < listTag.size(); ++i) {
|
|
||||||
String string = listTag.getString(i);
|
|
||||||
- Optional<? extends Recipe<?>> optional = recipeManager.byKey(new ResourceLocation(string));
|
|
||||||
+ Optional<? extends Recipe<?>> optional = recipeManager.byKey(ResourceLocation.tryParse(string)); // Scissors - Validate resource locations
|
|
||||||
if (!optional.isPresent()) {
|
|
||||||
- LOGGER.error("Invalid recipe: {}", (Object)string);
|
|
||||||
+ // Scissors - Don't log errors caused by invalid recipes being provided
|
|
||||||
return InteractionResultHolder.fail(itemStack);
|
|
||||||
}
|
|
||||||
|
|
||||||
@@ -55,7 +55,7 @@ public class KnowledgeBookItem extends Item {
|
|
||||||
|
|
||||||
return InteractionResultHolder.sidedSuccess(itemStack, world.isClientSide());
|
|
||||||
} else {
|
|
||||||
- LOGGER.error("Tag not valid: {}", (Object)compoundTag);
|
|
||||||
+ // Scissors - Don't throw errors into the logs if an NBT compound isn't present or is missing the Recipes tag.
|
|
||||||
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 50fdb086ffec84edc5138737c95f08ed4757a6f3..da312b4670fc0ac07e4ab798d4793025e362783e 100644
|
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java
|
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaKnowledgeBook.java
|
|
||||||
@@ -41,7 +41,11 @@ public class CraftMetaKnowledgeBook extends CraftMetaItem implements KnowledgeBo
|
|
||||||
for (int i = 0; i < pages.size(); i++) {
|
|
||||||
String recipe = pages.getString(i);
|
|
||||||
|
|
||||||
- this.addRecipe(CraftNamespacedKey.fromString(recipe));
|
|
||||||
+ // Scissors start - Don't add recipes with invalid namespaces
|
|
||||||
+ try {
|
|
||||||
+ this.addRecipe(CraftNamespacedKey.fromString(recipe));
|
|
||||||
+ } catch (Exception ignored) {}
|
|
||||||
+ // Scissors end
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
@ -5,10 +5,10 @@ Subject: [PATCH] Validate BlockState and SoundEvent values
|
|||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java
|
diff --git a/src/main/java/net/minecraft/nbt/NbtUtils.java b/src/main/java/net/minecraft/nbt/NbtUtils.java
|
||||||
index efa800402413202d190926610d8264dfbf5019e7..1b3229128771adb85a7d007989891ef073a80278 100644
|
index 82b53a7bfb37bfa1752a016a8a454c0b994b9108..b8720020f98ea26da7d3225ddfbb1d9e80be4eb1 100644
|
||||||
--- a/src/main/java/net/minecraft/nbt/NbtUtils.java
|
--- a/src/main/java/net/minecraft/nbt/NbtUtils.java
|
||||||
+++ b/src/main/java/net/minecraft/nbt/NbtUtils.java
|
+++ b/src/main/java/net/minecraft/nbt/NbtUtils.java
|
||||||
@@ -234,7 +234,7 @@ public final class NbtUtils {
|
@@ -231,7 +231,7 @@ public final class NbtUtils {
|
||||||
if (!nbt.contains("Name", 8)) {
|
if (!nbt.contains("Name", 8)) {
|
||||||
return Blocks.AIR.defaultBlockState();
|
return Blocks.AIR.defaultBlockState();
|
||||||
} else {
|
} else {
|
||||||
@ -18,7 +18,7 @@ index efa800402413202d190926610d8264dfbf5019e7..1b3229128771adb85a7d007989891ef0
|
|||||||
if (optional.isEmpty()) {
|
if (optional.isEmpty()) {
|
||||||
return Blocks.AIR.defaultBlockState();
|
return Blocks.AIR.defaultBlockState();
|
||||||
diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
diff --git a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
||||||
index fa885337085348308604e50049ecc5bb52023884..366f70bfe6559e4d43844473a2c080c3ec52a4fc 100644
|
index 8affdd74769aed9aa92a76ba539cd9d27208827c..23e480535bfb4071cde84fc400c2e6acb129e1ae 100644
|
||||||
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
--- a/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
||||||
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
+++ b/src/main/java/net/minecraft/world/entity/projectile/AbstractArrow.java
|
||||||
@@ -541,7 +541,7 @@ public abstract class AbstractArrow extends Projectile {
|
@@ -541,7 +541,7 @@ public abstract class AbstractArrow extends Projectile {
|
@ -77,7 +77,7 @@ index 9d687da5bdf398bb3f6c84cdf1249a7213d09f2e..bc5ed619e05f24f3ad50a6a81306d120
|
|||||||
switch (distance) {
|
switch (distance) {
|
||||||
case -1:
|
case -1:
|
||||||
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
|
diff --git a/src/main/java/org/bukkit/craftbukkit/Main.java b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||||
index 7c29d92362a82330440dff151bcf421f15c68f71..d1c8671ba5ca95c425e4c679445d55c4bbba217e 100644
|
index e7746952417a3ca4ea97103e38568db42039f717..e3c230fd2a054a8cb60328c9309410a2f53dad26 100644
|
||||||
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
--- a/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||||
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
+++ b/src/main/java/org/bukkit/craftbukkit/Main.java
|
||||||
@@ -300,7 +300,7 @@ public class Main {
|
@@ -300,7 +300,7 @@ public class Main {
|
@ -4,27 +4,8 @@ Date: Mon, 28 Mar 2022 13:19:43 -0600
|
|||||||
Subject: [PATCH] Better handling of invalid JSON components
|
Subject: [PATCH] Better handling of invalid JSON components
|
||||||
|
|
||||||
|
|
||||||
diff --git a/src/main/java/io/papermc/paper/util/MCUtil.java b/src/main/java/io/papermc/paper/util/MCUtil.java
|
|
||||||
index c69088a2ec374b2d236fec61e267f42afa2967b1..7ca1ece926b0ef4598d4fa913b96d1e7a0e5bba4 100644
|
|
||||||
--- a/src/main/java/io/papermc/paper/util/MCUtil.java
|
|
||||||
+++ b/src/main/java/io/papermc/paper/util/MCUtil.java
|
|
||||||
@@ -559,13 +559,7 @@ public final class MCUtil {
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
String string = compound.getString(key);
|
|
||||||
- try {
|
|
||||||
- return Component.Serializer.fromJson(string);
|
|
||||||
- } catch (com.google.gson.JsonParseException e) {
|
|
||||||
- org.bukkit.Bukkit.getLogger().warning("Unable to parse " + key + " from " + compound +": " + e.getMessage());
|
|
||||||
- }
|
|
||||||
-
|
|
||||||
- return null;
|
|
||||||
+ return Component.Serializer.fromJsonSafe(string);
|
|
||||||
}
|
|
||||||
|
|
||||||
public static ChunkStatus getChunkStatus(ChunkHolder chunk) {
|
|
||||||
diff --git a/src/main/java/net/minecraft/network/chat/Component.java b/src/main/java/net/minecraft/network/chat/Component.java
|
diff --git a/src/main/java/net/minecraft/network/chat/Component.java b/src/main/java/net/minecraft/network/chat/Component.java
|
||||||
index 37fc353c3e59dd5af2fd6c58ac084fb0e6e155d7..2873ed7c443ed8c8c57a8b1d3e444d229f10f07b 100644
|
index b540ce21c65ad52ad7e94d2ca2b3926c0875bee1..9cb6fa8e35c89f73e7c95dbe219a4bf6d00b60a9 100644
|
||||||
--- a/src/main/java/net/minecraft/network/chat/Component.java
|
--- a/src/main/java/net/minecraft/network/chat/Component.java
|
||||||
+++ b/src/main/java/net/minecraft/network/chat/Component.java
|
+++ b/src/main/java/net/minecraft/network/chat/Component.java
|
||||||
@@ -26,6 +26,7 @@ import java.util.List;
|
@@ -26,6 +26,7 @@ import java.util.List;
|
||||||
@ -128,10 +109,10 @@ index 97a2657bc98d41c3c1e376b266d2c85f685acc88..9d20f3f1af8e663a8c13714c8928d4a9
|
|||||||
}
|
}
|
||||||
}).reduce((accumulator, current) -> {
|
}).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
|
diff --git a/src/main/java/net/minecraft/world/entity/Entity.java b/src/main/java/net/minecraft/world/entity/Entity.java
|
||||||
index e8485fb900b25e911a858678a833852731cb2ace..842f8af14b2bd694a48ee6573d98e6cfcf910e16 100644
|
index f20ae9153b7098980ce6c0e75fcbbb4da652661b..7f5b2787482f52114c62f8b9d19755f3baeaefa0 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
|
||||||
@@ -2487,12 +2487,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
@@ -2470,12 +2470,7 @@ public abstract class Entity implements Nameable, EntityAccess, CommandSource {
|
||||||
this.setRot(this.getYRot(), this.getXRot());
|
this.setRot(this.getYRot(), this.getXRot());
|
||||||
if (nbt.contains("CustomName", 8)) {
|
if (nbt.contains("CustomName", 8)) {
|
||||||
String s = nbt.getString("CustomName");
|
String s = nbt.getString("CustomName");
|
||||||
@ -146,10 +127,10 @@ index e8485fb900b25e911a858678a833852731cb2ace..842f8af14b2bd694a48ee6573d98e6cf
|
|||||||
|
|
||||||
this.setCustomNameVisible(nbt.getBoolean("CustomNameVisible"));
|
this.setCustomNameVisible(nbt.getBoolean("CustomNameVisible"));
|
||||||
diff --git a/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java b/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java
|
diff --git a/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java b/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java
|
||||||
index 2be7a697f08045b974579e6942b38571e744efac..84ec21c38bb44db1e9ff26c01d5c8af1a2417616 100644
|
index 4def212655cea0fd998b52e924f8b671d6aeb559..4359fb5997f8a207c52a09aa61a9431fa3ff550e 100644
|
||||||
--- a/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java
|
--- a/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java
|
||||||
+++ b/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java
|
+++ b/src/main/java/net/minecraft/world/scores/ScoreboardSaveData.java
|
||||||
@@ -35,7 +35,7 @@ public class ScoreboardSaveData extends SavedData {
|
@@ -38,7 +38,7 @@ public class ScoreboardSaveData extends SavedData {
|
||||||
CompoundTag compoundTag = nbt.getCompound(i);
|
CompoundTag compoundTag = nbt.getCompound(i);
|
||||||
String string = compoundTag.getString("Name");
|
String string = compoundTag.getString("Name");
|
||||||
PlayerTeam playerTeam = this.scoreboard.addPlayerTeam(string);
|
PlayerTeam playerTeam = this.scoreboard.addPlayerTeam(string);
|
||||||
@ -158,7 +139,7 @@ index 2be7a697f08045b974579e6942b38571e744efac..84ec21c38bb44db1e9ff26c01d5c8af1
|
|||||||
if (component != null) {
|
if (component != null) {
|
||||||
playerTeam.setDisplayName(component);
|
playerTeam.setDisplayName(component);
|
||||||
}
|
}
|
||||||
@@ -53,14 +53,14 @@ public class ScoreboardSaveData extends SavedData {
|
@@ -56,14 +56,14 @@ public class ScoreboardSaveData extends SavedData {
|
||||||
}
|
}
|
||||||
|
|
||||||
if (compoundTag.contains("MemberNamePrefix", 8)) {
|
if (compoundTag.contains("MemberNamePrefix", 8)) {
|
||||||
@ -175,12 +156,12 @@ index 2be7a697f08045b974579e6942b38571e744efac..84ec21c38bb44db1e9ff26c01d5c8af1
|
|||||||
if (component3 != null) {
|
if (component3 != null) {
|
||||||
playerTeam.setPlayerSuffix(component3);
|
playerTeam.setPlayerSuffix(component3);
|
||||||
}
|
}
|
||||||
@@ -115,7 +115,7 @@ public class ScoreboardSaveData extends SavedData {
|
@@ -123,7 +123,7 @@ public class ScoreboardSaveData extends SavedData {
|
||||||
CompoundTag compoundTag = nbt.getCompound(i);
|
return ObjectiveCriteria.DUMMY;
|
||||||
ObjectiveCriteria.byName(compoundTag.getString("CriteriaName")).ifPresent((criterion) -> {
|
|
||||||
String string = compoundTag.getString("Name");
|
|
||||||
- Component component = Component.Serializer.fromJson(compoundTag.getString("DisplayName"));
|
|
||||||
+ Component component = Component.Serializer.fromJsonSafe(compoundTag.getString("DisplayName")); // Scissors - Use safer method for getting Components from JSON
|
|
||||||
ObjectiveCriteria.RenderType renderType = ObjectiveCriteria.RenderType.byId(compoundTag.getString("RenderType"));
|
|
||||||
this.scoreboard.addObjective(string, criterion, component, renderType);
|
|
||||||
});
|
});
|
||||||
|
String string2 = compoundTag.getString("Name");
|
||||||
|
- Component component = Component.Serializer.fromJson(compoundTag.getString("DisplayName"));
|
||||||
|
+ Component component = Component.Serializer.fromJsonSafe(compoundTag.getString("DisplayName")); // Scissors - Use safer method for getting Components from JSON
|
||||||
|
ObjectiveCriteria.RenderType renderType = ObjectiveCriteria.RenderType.byId(compoundTag.getString("RenderType"));
|
||||||
|
this.scoreboard.addObjective(string2, objectiveCriteria, component, renderType);
|
||||||
|
}
|
Loading…
Reference in New Issue
Block a user