From 63d1f2368e267340300ff57c8968a51d3823dd5f Mon Sep 17 00:00:00 2001 From: CraftBukkit/Spigot Date: Fri, 12 Dec 2014 09:40:48 +0000 Subject: [PATCH] Ignore errors when parsing books and treat them as old books In previous versions there was a mistake with book handled which may leave books in a broken state, this tries to handle that By: Thinkofdeath --- .../org/bukkit/craftbukkit/inventory/CraftMetaBook.java | 6 +++++- .../bukkit/craftbukkit/inventory/CraftMetaBookSigned.java | 6 +++++- 2 files changed, 10 insertions(+), 2 deletions(-) diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java index debca310e1..0c69a3e73b 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBook.java @@ -78,7 +78,11 @@ class CraftMetaBook extends CraftMetaItem implements BookMeta { for (int i = 0; i < pages.size(); i++) { String page = pages.getString(i); if (resolved) { - page = CraftChatMessage.fromComponent(ChatSerializer.a(page)); + try { + page = CraftChatMessage.fromComponent(ChatSerializer.a(page)); + } catch (Exception e) { + // Ignore and treat as an old book + } } pageArray[i] = page; } diff --git a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java index fd8ba56d9c..8c3d3a4405 100644 --- a/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java +++ b/paper-server/src/main/java/org/bukkit/craftbukkit/inventory/CraftMetaBookSigned.java @@ -39,7 +39,11 @@ class CraftMetaBookSigned extends CraftMetaBook implements BookMeta { for (int i = 0; i < pages.size(); i++) { String page = pages.getString(i); if (resolved) { - page = CraftChatMessage.fromComponent(ChatSerializer.a(page)); + try { + page = CraftChatMessage.fromComponent(ChatSerializer.a(page)); + } catch (Exception e) { + // Ignore and treat as an old book + } } pageArray[i] = page; }