Claims
unknown
java
a month ago
4.7 kB
3
Indexable
Never
public static void updateClaims(BlueMapAPI blueMap) { if (server == null) { LOGGER.warn("updateClaims called with minecraftServer == null!"); return; } LOGGER.info("Refreshing OpenPaC BlueMap markers"); OpenPACServerAPI.get(server) .getServerClaimsManager() .getPlayerInfoStream() .forEach(playerClaimInfo -> { String name = playerClaimInfo.getClaimsName(); final String idName; if (StringUtils.isBlank(name)) { idName = name = playerClaimInfo.getPlayerUsername(); if (name.length() > 2 && name.charAt(0) == '"' && name.charAt(name.length() - 1) == '"') { name = name.substring(1, name.length() - 1) + " claim"; } else { name += "'s claim"; } } else { idName = name; } final String displayName = name; playerClaimInfo.getStream().forEach(entry -> { final BlueMapWorld world = blueMap.getWorld(ResourceKey.create(Registries.DIMENSION, entry.getKey())).orElse(null); if (world == null) return; final List<ShapeHolder> shapes = createShapes( entry.getValue() .getStream() .flatMap(IPlayerClaimPosListAPI::getStream) .collect(Collectors.toSet()) ); world.getMaps().forEach(map -> { final Map<String, de.bluecolored.bluemap.api.markers.Marker> markers = map .getMarkerSets() .computeIfAbsent(MARKER_SET_KEY, k -> MarkerSet.builder() .toggleable(true) .label("Open Parties and Claims") .build() ) .getMarkers(); final float minY = CONFIG.getMarkerMinY(); final float maxY = CONFIG.getMarkerMaxY(); //noinspection SuspiciousNameCombination final boolean flatPlane = Mth.equal(minY, maxY); markers.keySet().removeIf(k -> k.startsWith(idName + "---")); for (int i = 0; i < shapes.size(); i++) { final ShapeHolder shape = shapes.get(i); markers.put(idName + "---" + i, // Yes these builders are the same. No they don't share a superclass (except for label). flatPlane ? ShapeMarker.builder() .label(displayName) .fillColor(new Color(playerClaimInfo.getClaimsColor(), 150)) .lineColor(new Color(playerClaimInfo.getClaimsColor(), 255)) .shape(shape.baseShape(), minY) .holes(shape.holes()) .depthTestEnabled(CONFIG.isDepthTest()) .build() : ExtrudeMarker.builder() .label(displayName) .fillColor(new Color(playerClaimInfo.getClaimsColor(), 150)) .lineColor(new Color(playerClaimInfo.getClaimsColor(), 255)) .shape(shape.baseShape(), minY, maxY) .holes(shape.holes()) .depthTestEnabled(CONFIG.isDepthTest()) .build() ); } }); }); });
Leave a Comment