From 2d376bc72f54e12689559a4fc85966e52466cfde Mon Sep 17 00:00:00 2001 From: vemacs Date: Sun, 15 Nov 2015 07:59:19 -0700 Subject: [PATCH] Restore LocationUtil compatibility with 1_8_R1 --- .../com/earth2me/essentials/utils/LocationUtil.java | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/Essentials/src/com/earth2me/essentials/utils/LocationUtil.java b/Essentials/src/com/earth2me/essentials/utils/LocationUtil.java index ef87b4a80..f0239d2d4 100644 --- a/Essentials/src/com/earth2me/essentials/utils/LocationUtil.java +++ b/Essentials/src/com/earth2me/essentials/utils/LocationUtil.java @@ -195,8 +195,18 @@ public class LocationUtil { VOLUME = pos.toArray(new Vector3D[0]); } + @SuppressWarnings("deprecation") public static Location getTarget(final LivingEntity entity) throws Exception { - final Block block = entity.getTargetBlock(TRANSPARENT_MATERIALS, 300); + Block block; + try { + block = entity.getTargetBlock(TRANSPARENT_MATERIALS, 300); + } catch (NoSuchMethodError e) { + HashSet legacyTransparent = new HashSet<>(); // Bukkit API prevents declaring as Set + for (Material m : TRANSPARENT_MATERIALS) { + legacyTransparent.add((byte) m.getId()); + } + block = entity.getTargetBlock(legacyTransparent, 300); + } if (block == null) { throw new Exception("Not targeting a block"); }