From 070c5139e1afad52421f917c4e46913bfc6ddf1e Mon Sep 17 00:00:00 2001 From: Intelli Date: Thu, 24 Mar 2022 17:11:37 -0600 Subject: [PATCH] Fixed IllegalArgumentException when processing corrupt data --- .../net/coreprotect/database/Rollback.java | 2 +- .../java/net/coreprotect/utility/Util.java | 18 ++++++++++++------ 2 files changed, 13 insertions(+), 7 deletions(-) diff --git a/src/main/java/net/coreprotect/database/Rollback.java b/src/main/java/net/coreprotect/database/Rollback.java index f186e29..eec0297 100644 --- a/src/main/java/net/coreprotect/database/Rollback.java +++ b/src/main/java/net/coreprotect/database/Rollback.java @@ -1914,7 +1914,7 @@ public class Rollback extends Queue { } itemstack.setItemMeta(meta); } - else if ((rowType == Material.MAP)) { + else if (rowType == Material.MAP || rowType == Material.FILLED_MAP) { for (Map colorData : map) { MapMeta meta = (MapMeta) itemstack.getItemMeta(); org.bukkit.Color color = org.bukkit.Color.deserialize(colorData); diff --git a/src/main/java/net/coreprotect/utility/Util.java b/src/main/java/net/coreprotect/utility/Util.java index 9abfc0a..97a071e 100755 --- a/src/main/java/net/coreprotect/utility/Util.java +++ b/src/main/java/net/coreprotect/utility/Util.java @@ -1386,12 +1386,16 @@ public class Util extends Queue { } public static BlockData createBlockData(Material material) { - BlockData result = material.createBlockData(); - if (result instanceof Waterlogged) { - ((Waterlogged) result).setWaterlogged(false); + try { + BlockData result = material.createBlockData(); + if (result instanceof Waterlogged) { + ((Waterlogged) result).setWaterlogged(false); + } + return result; + } + catch (Exception e) { + return null; } - - return result; } public static void prepareTypeAndData(Map map, Block block, Material type, BlockData blockData, boolean update) { @@ -1413,7 +1417,9 @@ public class Util extends Queue { blockData = createBlockData(type); } - block.setBlockData(blockData, update); + if (blockData != null) { + block.setBlockData(blockData, update); + } } public static boolean successfulQuery(Connection connection, String query) {