From 52ec13827308462d605c84bf5c17201b9e6fc485 Mon Sep 17 00:00:00 2001 From: William Date: Sun, 11 Aug 2024 12:52:23 +0100 Subject: [PATCH] fix: suppress map cursor paper exception --- .../husksync/util/BukkitMapPersister.java | 28 +++++++++++-------- 1 file changed, 16 insertions(+), 12 deletions(-) diff --git a/bukkit/src/main/java/net/william278/husksync/util/BukkitMapPersister.java b/bukkit/src/main/java/net/william278/husksync/util/BukkitMapPersister.java index d2b5a9f8..0621dbbd 100644 --- a/bukkit/src/main/java/net/william278/husksync/util/BukkitMapPersister.java +++ b/bukkit/src/main/java/net/william278/husksync/util/BukkitMapPersister.java @@ -424,19 +424,23 @@ private String getDimension() { @NotNull private MapData extractMapData() { final List banners = Lists.newArrayList(); - final String BANNER_PREFIX = "banner_"; - for (int i = 0; i < getCursors().size(); i++) { - final MapCursor cursor = getCursors().getCursor(i); - final String type = cursor.getType().name().toLowerCase(Locale.ENGLISH); - if (type.startsWith(BANNER_PREFIX)) { - banners.add(new MapBanner( - type.replaceAll(BANNER_PREFIX, ""), - cursor.getCaption() == null ? "" : cursor.getCaption(), - cursor.getX(), - mapView.getWorld() != null ? mapView.getWorld().getSeaLevel() : 128, - cursor.getY() - )); + try { + final String BANNER_PREFIX = "banner_"; + for (int i = 0; i < getCursors().size(); i++) { + final MapCursor cursor = getCursors().getCursor(i); + final String type = cursor.getType().name().toLowerCase(Locale.ENGLISH); + if (type.startsWith(BANNER_PREFIX)) { + banners.add(new MapBanner( + type.replaceAll(BANNER_PREFIX, ""), + cursor.getCaption() == null ? "" : cursor.getCaption(), + cursor.getX(), + mapView.getWorld() != null ? mapView.getWorld().getSeaLevel() : 128, + cursor.getY() + )); + } + } + } catch (Throwable ignored) { } return MapData.fromPixels(pixels, getDimension(), (byte) 2, banners, List.of()); }