3
0
Mirror von https://github.com/ViaVersion/ViaVersion.git synchronisiert 2024-12-24 23:30:15 +01:00

Fix method checks in BukkitPickItemProvider (#4301)

Dieser Commit ist enthalten in:
riku6460 2024-12-07 22:02:15 +09:00 committet von GitHub
Ursprung 037410d405
Commit 813cf813cf
Es konnte kein GPG-Schlüssel zu dieser Signatur gefunden werden
GPG-Schlüssel-ID: B5690EEEBB952194
2 geänderte Dateien mit 5 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -98,9 +98,9 @@ public final class PaperViaInjector {
}
}
public static boolean hasMethod(final Class<?> clazz, final String method) {
public static boolean hasMethod(final Class<?> clazz, final String method, final Class<?>... params) {
try {
clazz.getDeclaredMethod(method);
clazz.getDeclaredMethod(method, params);
return true;
} catch (final NoSuchMethodException e) {
return false;

Datei anzeigen

@ -29,6 +29,7 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.entity.Entity;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemFactory;
import org.bukkit.inventory.ItemStack;
@ -37,8 +38,8 @@ import org.bukkit.inventory.meta.BlockStateMeta;
import org.checkerframework.checker.nullness.qual.Nullable;
public final class BukkitPickItemProvider extends PickItemProvider {
private static final boolean HAS_PLACEMENT_MATERIAL_METHOD = PaperViaInjector.hasMethod("org.bukkit.block.BlockData", "getPlacementMaterial");
private static final boolean HAS_SPAWN_EGG_METHOD = PaperViaInjector.hasMethod(ItemFactory.class, "getSpawnEgg");
private static final boolean HAS_PLACEMENT_MATERIAL_METHOD = PaperViaInjector.hasMethod("org.bukkit.block.data.BlockData", "getPlacementMaterial");
private static final boolean HAS_SPAWN_EGG_METHOD = PaperViaInjector.hasMethod(ItemFactory.class, "getSpawnEgg", EntityType.class);
private static final double BLOCK_RANGE = 4.5 + 1;
private static final double BLOCK_RANGE_SQUARED = BLOCK_RANGE * BLOCK_RANGE;
private static final double ENTITY_RANGE = 3 + 3;