From 7e78a43094d19768137b1f949789c952d81994e3 Mon Sep 17 00:00:00 2001 From: Zrips Date: Sat, 15 Feb 2020 16:41:23 +0200 Subject: [PATCH] Good old fashion way to get target block which seem to be working on older versions --- src/main/java/com/gamingmesh/jobs/stuff/Util.java | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/src/main/java/com/gamingmesh/jobs/stuff/Util.java b/src/main/java/com/gamingmesh/jobs/stuff/Util.java index 8295a766..6b444432 100644 --- a/src/main/java/com/gamingmesh/jobs/stuff/Util.java +++ b/src/main/java/com/gamingmesh/jobs/stuff/Util.java @@ -7,6 +7,7 @@ import java.net.URLClassLoader; import java.util.ArrayList; import java.util.Enumeration; import java.util.HashMap; +import java.util.HashSet; import java.util.Iterator; import java.util.List; import java.util.Map.Entry; @@ -29,6 +30,7 @@ import org.bukkit.inventory.meta.BlockStateMeta; import org.bukkit.inventory.meta.ItemMeta; import org.bukkit.inventory.meta.SkullMeta; import org.bukkit.util.BlockIterator; +import org.jetbrains.annotations.NotNull; import com.gamingmesh.jobs.Jobs; import com.gamingmesh.jobs.CMILib.CMIMaterial; @@ -69,8 +71,8 @@ public class Util { return is; } - @SuppressWarnings("deprecation") - public static ItemStack getSkull(String skullOwner) { + @SuppressWarnings("deprecation") + public static ItemStack getSkull(String skullOwner) { ItemStack item = CMIMaterial.PLAYER_HEAD.newItemStack(); SkullMeta skullMeta = (SkullMeta) item.getItemMeta(); if (skullOwner.length() == 36) { @@ -145,6 +147,15 @@ public class Util { distance = 1; ArrayList blocks = new ArrayList<>(); + + try { + Block bl = player.getTargetBlock(null, distance); + if (!CMIMaterial.isAir(bl.getType())) { + return bl; + } + } catch (Throwable e) { + } + Iterator itr = new BlockIterator(player, distance); while (itr.hasNext()) { Block block = itr.next();