This commit is contained in:
HaHaWTH 2023-11-04 18:31:36 +08:00
parent 8681cd0733
commit 628d5adcb5

View File

@ -0,0 +1,23 @@
package fr.xephi.authme.util;
import org.bukkit.map.MapView;
import java.lang.reflect.Method;
public class MapUtils {
public static int getMapId(MapView mapView) {
try {
Method method = mapView.getClass().getMethod("getId");
Object mapId = method.invoke(mapView);
if (mapId instanceof Short) {
return ((Short) mapId).intValue();
} else {
return (Integer) mapId;
}
} catch (Exception exception) {
exception.printStackTrace();
}
return 0;
}
}