From e29da1279bb92d5d03d6f49484767b2e46e6231a Mon Sep 17 00:00:00 2001 From: Eric Date: Wed, 15 Feb 2017 17:04:32 +0100 Subject: [PATCH] Catch IllegalStateException for getLineOfSight Closes #79 --- .../java/de/epiceric/shopchest/utils/ShopUtils.java | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/src/main/java/de/epiceric/shopchest/utils/ShopUtils.java b/src/main/java/de/epiceric/shopchest/utils/ShopUtils.java index dc9abc1..7c49132 100644 --- a/src/main/java/de/epiceric/shopchest/utils/ShopUtils.java +++ b/src/main/java/de/epiceric/shopchest/utils/ShopUtils.java @@ -233,7 +233,16 @@ public class ShopUtils { if (plugin.getShopChestConfig().only_show_shops_in_sight) { HashSet transparent = new HashSet<>(); transparent.add(Material.AIR); - List sight = player.getLineOfSight(transparent, (int) plugin.getShopChestConfig().maximal_distance); + + List sight; + + try { + sight = player.getLineOfSight(transparent, (int) plugin.getShopChestConfig().maximal_distance); + } catch (IllegalStateException e) { + // This method is occasionally throwing this exception but the exact reason is unknown... + plugin.debug("Failed to get line of sight: " + e.getMessage()); + return; + } ArrayList shopsInSight = new ArrayList<>();