@@ -111,8 +112,7 @@ public class WrittenBookItem extends Item {
public static boolean resolveBookComponents(ItemStack book, @Nullable CommandSourceStack commandSource, @Nullable Player player) {
CompoundTag compoundTag = book.getTag();
- if (io.papermc.paper.configuration.GlobalConfiguration.get().itemValidation.resolveSelectorsInBooks && compoundTag != null && !compoundTag.getBoolean("resolved")) { // Paper
- compoundTag.putBoolean("resolved", true);
+ if (compoundTag != null) { // Paper
if (!makeSureTagIsValid(compoundTag)) {
return false;
} else {
@@ -161,8 +161,41 @@ public class WrittenBookItem extends Item {
component2 = Component.literal(text);
}
- return Component.Serializer.toJson(component2);
+ return Component.Serializer.toJson(!ScissorsConfig.runCommandsInBooks ? sanitize(component2, 0) : component2); // Scissors - Allow server owners to disable run command in books
+ }
+
+ // Scissors start - Allow server owners to disable run command in books
+ public static Component sanitize(Component component, int depth) {
+ if (depth > 128) {
+ return Component.nullToEmpty("Sanitization function depth limit exceeded");
+ }
+
+ MutableComponent component2 = component.copy();
+
+ final Style style = component2.getStyle();
+ final ClickEvent clickEvent = style.getClickEvent();