From 628d5adcb54baa737964e4cf09dff69540f3cabd Mon Sep 17 00:00:00 2001 From: HaHaWTH Date: Sat, 4 Nov 2023 18:31:36 +0800 Subject: [PATCH] MapUtils --- .../java/fr/xephi/authme/util/MapUtils.java | 23 +++++++++++++++++++ 1 file changed, 23 insertions(+) create mode 100644 src/main/java/fr/xephi/authme/util/MapUtils.java diff --git a/src/main/java/fr/xephi/authme/util/MapUtils.java b/src/main/java/fr/xephi/authme/util/MapUtils.java new file mode 100644 index 00000000..adb98644 --- /dev/null +++ b/src/main/java/fr/xephi/authme/util/MapUtils.java @@ -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; + } +}