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.
This commit is contained in:
md678685 2020-05-20 19:49:45 +01:00
parent 5b9b76d5e7
commit 7d61953753

View File

@ -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;