From 7d61953753137ca117e06f2a0ca9e858821b3920 Mon Sep 17 00:00:00 2001 From: md678685 <1917406+md678685@users.noreply.github.com> Date: Wed, 20 May 2020 19:49:45 +0100 Subject: [PATCH] Fix spawner provider detection only working on 1.13+ This caused a seemingly-unrelated error where the 1.7/1.8 provider was being used on all versions up until 1.12. Upon further investigation, this line caused a NoSuchFieldError, and since this isn't an Exception it was caught by the outer `catch (Throwable t)` which was intended to catch throwables from the providers rather than the setup of tryProvider. --- .../src/net/ess3/nms/SpawnerProvider.java | 17 +++++++++-------- 1 file changed, 9 insertions(+), 8 deletions(-) diff --git a/nms/NMSProvider/src/net/ess3/nms/SpawnerProvider.java b/nms/NMSProvider/src/net/ess3/nms/SpawnerProvider.java index 387c517a9..635e29449 100644 --- a/nms/NMSProvider/src/net/ess3/nms/SpawnerProvider.java +++ b/nms/NMSProvider/src/net/ess3/nms/SpawnerProvider.java @@ -1,7 +1,7 @@ package net.ess3.nms; -import net.ess3.providers.Provider; import com.google.common.collect.ImmutableMap; +import net.ess3.providers.Provider; import org.bukkit.ChatColor; import org.bukkit.Material; import org.bukkit.entity.EntityType; @@ -29,14 +29,15 @@ public abstract class SpawnerProvider implements Provider { @Override public boolean tryProvider() { + EntityType type = EntityType.CREEPER; + Material MOB_SPAWNER; + try { + MOB_SPAWNER = Material.valueOf("SPAWNER"); + } catch (Exception e) { + MOB_SPAWNER = Material.valueOf("MOB_SPAWNER"); + } + try { - EntityType type = EntityType.CREEPER; - Material MOB_SPAWNER; - try { - MOB_SPAWNER = Material.SPAWNER; - } catch (Exception e) { - MOB_SPAWNER = Material.valueOf("MOB_SPAWNER"); - } ItemStack is = setEntityType(new ItemStack(MOB_SPAWNER), type); EntityType readType = getEntityType(is); return type == readType;