mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-02 06:28:54 +00:00
30 lines
782 B
Java
30 lines
782 B
Java
package net.draycia.carbon.util;
|
|
|
|
import org.bukkit.inventory.ItemFactory;
|
|
import org.bukkit.inventory.ItemStack;
|
|
import org.checkerframework.checker.nullness.qual.NonNull;
|
|
|
|
@SuppressWarnings("ResultOfMethodCallIgnored") // This is a common pattern in this class.
|
|
public final class FunctionalityConstants {
|
|
|
|
public static final boolean HAS_HOVER_EVENT_METHOD = noThrow(() -> ItemFactory.class.getMethod("hoverContentOf", ItemStack.class));
|
|
|
|
private FunctionalityConstants() {
|
|
|
|
}
|
|
|
|
private static boolean noThrow(@NonNull final ThrowingRunnable runnable) {
|
|
try {
|
|
runnable.run();
|
|
return true;
|
|
} catch (final Exception ex) {
|
|
return false;
|
|
}
|
|
}
|
|
|
|
@FunctionalInterface
|
|
private interface ThrowingRunnable {
|
|
void run() throws Exception;
|
|
}
|
|
}
|