mirror of
https://github.com/EssentialsX/Essentials.git
synced 2024-12-22 09:08:01 +01:00
Attempt to fall back to Material.getMaterial(int) below 1.13
Fixes #2615.
This commit is contained in:
parent
74d96ce624
commit
9089fe8be3
@ -3,8 +3,12 @@ package com.earth2me.essentials.utils;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.DyeColor;
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.material.MaterialData;
|
||||
|
||||
import java.lang.reflect.Constructor;
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.lang.reflect.Method;
|
||||
import java.util.EnumSet;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
@ -124,10 +128,16 @@ public class MaterialUtil {
|
||||
try {
|
||||
return Bukkit.getUnsafe().fromLegacy(new MaterialData(material, damage));
|
||||
} catch (NoSuchMethodError error) {
|
||||
return null;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try {
|
||||
Method getMaterialFromId = Material.class.getDeclaredMethod("getMaterial", int.class);
|
||||
return (Material) getMaterialFromId.invoke(null, id);
|
||||
} catch (NoSuchMethodException | IllegalAccessException | InvocationTargetException ignored) {}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user