@@ -161,9 +161,43 @@ 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();
+
+ if (clickEvent != null && clickEvent.getAction().equals(ClickEvent.Action.RUN_COMMAND))
+ {
+ final String clickEventValue = clickEvent.getValue();