diff --git a/src/main/java/net/rptools/maptool/client/functions/DrawingFunctions.java b/src/main/java/net/rptools/maptool/client/functions/DrawingFunctions.java index b6c5b820d4..074e12fe17 100644 --- a/src/main/java/net/rptools/maptool/client/functions/DrawingFunctions.java +++ b/src/main/java/net/rptools/maptool/client/functions/DrawingFunctions.java @@ -23,7 +23,6 @@ import net.rptools.lib.MD5Key; import net.rptools.maptool.client.MapTool; import net.rptools.maptool.client.MapToolUtil; -import net.rptools.maptool.client.ui.zone.ZoneRenderer; import net.rptools.maptool.language.I18N; import net.rptools.maptool.model.GUID; import net.rptools.maptool.model.Zone; @@ -210,24 +209,6 @@ protected Layer getLayer(String layer) { return Layer.TOKEN; } - /** - * Find the map/zone for a given map name - * - * @param functionName String Name of the calling function. - * @param mapName String Name of the searched for map. - * @return ZoneRenderer The map/zone. - * @throws ParserException if the map is not found - */ - protected ZoneRenderer getNamedMap(String functionName, String mapName) throws ParserException { - for (ZoneRenderer zr : MapTool.getFrame().getZoneRenderers()) { - if (mapName.equals(zr.getZone().getName())) { - return zr; - } - } - throw new ParserException( - I18N.getText("macro.function.moveTokenMap.unknownMap", functionName, mapName)); - } - /** * Looks for a drawing on a specific map that matches a specific id and returns its pen. Throws a * ParserException if the drawing is not found. diff --git a/src/main/java/net/rptools/maptool/client/functions/DrawingGetterFunctions.java b/src/main/java/net/rptools/maptool/client/functions/DrawingGetterFunctions.java index 8677a60463..56ef1ab21b 100644 --- a/src/main/java/net/rptools/maptool/client/functions/DrawingGetterFunctions.java +++ b/src/main/java/net/rptools/maptool/client/functions/DrawingGetterFunctions.java @@ -61,7 +61,7 @@ public Object childEvaluate( FunctionUtil.checkNumberParam(functionName, parameters, 2, 2); String mapName = parameters.get(0).toString(); String id = parameters.get(1).toString(); - Zone map = getNamedMap(functionName, mapName).getZone(); + Zone map = FunctionUtil.getZoneRenderer(functionName, mapName).getZone(); GUID guid = getGUID(functionName, id); if ("getDrawingLayer".equalsIgnoreCase(functionName)) { return getDrawable(functionName, map, guid).getLayer().name(); diff --git a/src/main/java/net/rptools/maptool/client/functions/DrawingMiscFunctions.java b/src/main/java/net/rptools/maptool/client/functions/DrawingMiscFunctions.java index 48f1c934a7..2312355706 100644 --- a/src/main/java/net/rptools/maptool/client/functions/DrawingMiscFunctions.java +++ b/src/main/java/net/rptools/maptool/client/functions/DrawingMiscFunctions.java @@ -64,7 +64,7 @@ public Object childEvaluate( checkTrusted(functionName); String mapName = parameters.get(0).toString(); String drawing = parameters.get(1).toString(); - Zone map = getNamedMap(functionName, mapName).getZone(); + Zone map = FunctionUtil.getZoneRenderer(functionName, mapName).getZone(); if ("movedOverDrawing".equalsIgnoreCase(functionName)) { FunctionUtil.checkNumberParam(functionName, parameters, 3, 3); String jsonPath = parameters.get(2).toString(); diff --git a/src/main/java/net/rptools/maptool/client/functions/DrawingSetterFunctions.java b/src/main/java/net/rptools/maptool/client/functions/DrawingSetterFunctions.java index 27210c4d08..b94c6eacd2 100644 --- a/src/main/java/net/rptools/maptool/client/functions/DrawingSetterFunctions.java +++ b/src/main/java/net/rptools/maptool/client/functions/DrawingSetterFunctions.java @@ -54,7 +54,7 @@ public Object childEvaluate( FunctionUtil.checkNumberParam(functionName, parameters, 3, 3); String mapName = parameters.get(0).toString(); String id = parameters.get(1).toString(); - Zone map = getNamedMap(functionName, mapName).getZone(); + Zone map = FunctionUtil.getZoneRenderer(functionName, mapName).getZone(); GUID guid = getGUID(functionName, id); if ("setDrawingLayer".equalsIgnoreCase(functionName)) { Layer layer = getLayer(parameters.get(2).toString()); diff --git a/src/main/java/net/rptools/maptool/client/functions/FindTokenFunctions.java b/src/main/java/net/rptools/maptool/client/functions/FindTokenFunctions.java index 80c80559be..fe60e6adef 100644 --- a/src/main/java/net/rptools/maptool/client/functions/FindTokenFunctions.java +++ b/src/main/java/net/rptools/maptool/client/functions/FindTokenFunctions.java @@ -872,21 +872,35 @@ private String findTokenId(String identifier, String zoneName) { * Finds the specified token. * * @param identifier the identifier of the token (name, GM name, or GUID). - * @param zoneName the name of the zone. If null, check current zone. + * @param zoneNameOrId the name or ID of the zone. If null, check current zone. * @return the token, or null if none found. */ - public static Token findToken(String identifier, String zoneName) { + public static Token findToken(String identifier, String zoneNameOrId) { if (identifier == null) { return null; } - if (zoneName == null || zoneName.length() == 0) { + if (zoneNameOrId == null || zoneNameOrId.length() == 0) { ZoneRenderer zr = MapTool.getFrame().getCurrentZoneRenderer(); return zr == null ? null : zr.getZone().resolveToken(identifier); } else { + if (!GUID.isNotGUID(zoneNameOrId)) { + try { + final var zr = MapTool.getFrame().getZoneRenderer(GUID.valueOf(zoneNameOrId)); + if (zr != null) { + Token token = zr.getZone().resolveToken(identifier); + if (token != null) { + return token; + } + } + } catch (InvalidGUIDException ignored) { + // Wasn't a GUID after all. Fall back to looking up by name. + } + } + List zrenderers = MapTool.getFrame().getZoneRenderers(); for (ZoneRenderer zr : zrenderers) { Zone zone = zr.getZone(); - if (zone.getName().equalsIgnoreCase(zoneName)) { + if (zone.getName().equalsIgnoreCase(zoneNameOrId)) { Token token = zone.resolveToken(identifier); if (token != null) { return token; diff --git a/src/main/java/net/rptools/maptool/client/functions/FogOfWarFunctions.java b/src/main/java/net/rptools/maptool/client/functions/FogOfWarFunctions.java index f77caf74cf..d0fd07e70a 100644 --- a/src/main/java/net/rptools/maptool/client/functions/FogOfWarFunctions.java +++ b/src/main/java/net/rptools/maptool/client/functions/FogOfWarFunctions.java @@ -28,6 +28,7 @@ import net.rptools.maptool.model.GUID; import net.rptools.maptool.model.Token; import net.rptools.maptool.model.Zone; +import net.rptools.maptool.util.FunctionUtil; import net.rptools.parser.Parser; import net.rptools.parser.ParserException; import net.rptools.parser.VariableResolver; @@ -75,17 +76,7 @@ public Object childEvaluate( parameters.size())); } - ZoneRenderer zoneRenderer; - if (parameters.size() >= 1) { - String mapName = parameters.get(0).toString(); - zoneRenderer = MapTool.getFrame().getZoneRenderer(mapName); - if (zoneRenderer == null) { - throw new ParserException( - I18N.getText("macro.function.moveTokenMap.unknownMap", functionName, mapName)); - } - } else { - zoneRenderer = MapTool.getFrame().getCurrentZoneRenderer(); - } + final var zoneRenderer = FunctionUtil.getZoneRendererFromParam(functionName, parameters, 0); /* * String empty = exposePCOnlyArea(optional String mapName) diff --git a/src/main/java/net/rptools/maptool/client/functions/MapFunctions.java b/src/main/java/net/rptools/maptool/client/functions/MapFunctions.java index 42521020cb..71519c4f80 100644 --- a/src/main/java/net/rptools/maptool/client/functions/MapFunctions.java +++ b/src/main/java/net/rptools/maptool/client/functions/MapFunctions.java @@ -20,6 +20,8 @@ import net.rptools.maptool.client.MapTool; import net.rptools.maptool.client.ui.zone.ZoneRenderer; import net.rptools.maptool.language.I18N; +import net.rptools.maptool.model.GUID; +import net.rptools.maptool.model.InvalidGUIDException; import net.rptools.maptool.model.Zone; import net.rptools.maptool.util.FunctionUtil; import net.rptools.parser.Parser; @@ -34,10 +36,14 @@ private MapFunctions() { super( 0, 2, + "getCurrentMapID", + "getAllMapIDs", + "getMapIDs", "getAllMapNames", "getAllMapDisplayNames", "getCurrentMapName", "getMapDisplayName", + "getVisibleMapIDs", "getVisibleMapNames", "getVisibleMapDisplayNames", "setCurrentMap", @@ -58,7 +64,25 @@ public static MapFunctions getInstance() { public Object childEvaluate( Parser parser, VariableResolver resolver, String functionName, List parameters) throws ParserException { - if (functionName.equalsIgnoreCase("getCurrentMapName")) { + if (functionName.equalsIgnoreCase("getCurrentMapID")) { + FunctionUtil.checkNumberParam(functionName, parameters, 0, 0); + ZoneRenderer currentZR = MapTool.getFrame().getCurrentZoneRenderer(); + if (currentZR == null) { + throw new ParserException(I18N.getText("macro.function.map.none", functionName)); + } + return currentZR.getZone().getId().toString(); + } else if (functionName.equalsIgnoreCase("getMapIDs")) { + FunctionUtil.checkNumberParam(functionName, parameters, 1, 2); + final var mapName = parameters.get(0).toString(); + final var delim = parameters.size() < 2 ? "," : parameters.get(1).toString(); + final var zoneIds = + MapTool.getCampaign().getZones().stream() + .filter(zone -> mapName.equals(zone.getName())) + .map(Zone::getId) + .map(GUID::toString) + .toList(); + return FunctionUtil.delimitedResult(delim, zoneIds); + } else if (functionName.equalsIgnoreCase("getCurrentMapName")) { FunctionUtil.checkNumberParam(functionName, parameters, 0, 0); ZoneRenderer currentZR = MapTool.getFrame().getCurrentZoneRenderer(); if (currentZR == null) { @@ -75,10 +99,10 @@ public Object childEvaluate( } else if (functionName.equalsIgnoreCase("setCurrentMap")) { FunctionUtil.blockUntrustedMacro(functionName); FunctionUtil.checkNumberParam(functionName, parameters, 1, 1); - String mapName = parameters.get(0).toString(); - final var zr = FunctionUtil.getZoneRenderer(functionName, mapName); + String mapNameOrId = parameters.get(0).toString(); + final var zr = FunctionUtil.getZoneRenderer(functionName, mapNameOrId); MapTool.getFrame().setCurrentZoneRenderer(zr); - return mapName; + return mapNameOrId; } else if ("getMapVisible".equalsIgnoreCase(functionName)) { FunctionUtil.checkNumberParam(functionName, parameters, 0, 1); @@ -101,9 +125,9 @@ public Object childEvaluate( } else if ("setMapName".equalsIgnoreCase(functionName)) { FunctionUtil.blockUntrustedMacro(functionName); FunctionUtil.checkNumberParam(functionName, parameters, 2, 2); - String oldMapName = parameters.get(0).toString(); + String mapNameOrId = parameters.get(0).toString(); String newMapName = parameters.get(1).toString(); - Zone zone = FunctionUtil.getZoneRenderer(functionName, oldMapName).getZone(); + Zone zone = FunctionUtil.getZoneRenderer(functionName, mapNameOrId).getZone(); zone.setName(newMapName); MapTool.serverCommand().renameZone(zone.getId(), newMapName); if (zone == MapTool.getFrame().getCurrentZoneRenderer().getZone()) { @@ -114,10 +138,10 @@ public Object childEvaluate( } else if ("setMapDisplayName".equalsIgnoreCase(functionName)) { FunctionUtil.blockUntrustedMacro(functionName); FunctionUtil.checkNumberParam(functionName, parameters, 2, 2); - String mapName = parameters.get(0).toString(); + String mapNameOrId = parameters.get(0).toString(); String newMapDisplayName = parameters.get(1).toString(); - Zone zone = FunctionUtil.getZoneRenderer(functionName, mapName).getZone(); + Zone zone = FunctionUtil.getZoneRenderer(functionName, mapNameOrId).getZone(); if (newMapDisplayName.equals(zone.getDisplayName())) { // The name is the same, so nothing to do. return newMapDisplayName; @@ -134,15 +158,35 @@ public Object childEvaluate( } else if ("copyMap".equalsIgnoreCase(functionName)) { FunctionUtil.blockUntrustedMacro(functionName); FunctionUtil.checkNumberParam(functionName, parameters, 2, 2); - String oldName = parameters.get(0).toString(); + String oldMapNameOrId = parameters.get(0).toString(); String newName = parameters.get(1).toString(); - Zone oldMap = FunctionUtil.getZoneRenderer(functionName, oldName).getZone(); + Zone oldMap = FunctionUtil.getZoneRenderer(functionName, oldMapNameOrId).getZone(); Zone newMap = new Zone(oldMap); newMap.setName(newName); MapTool.addZone(newMap, false); MapTool.serverCommand().putZone(newMap); return newMap.getName(); + } else if ("getVisibleMapIDs".equalsIgnoreCase(functionName) + || "getAllMapIDs".equalsIgnoreCase(functionName)) { + FunctionUtil.checkNumberParam(functionName, parameters, 0, 1); + String delim = parameters.size() > 0 ? parameters.get(0).toString() : ","; + + boolean allMaps = functionName.equalsIgnoreCase("getAllMapIDs"); + + if (allMaps) { + FunctionUtil.blockUntrustedMacro(functionName); + } + + List mapIds = new LinkedList<>(); + for (ZoneRenderer zr : MapTool.getFrame().getZoneRenderers()) { + if (allMaps || zr.getZone().isVisible()) { + mapIds.add(zr.getZone().getId().toString()); + } + } + + return FunctionUtil.delimitedResult(delim, mapIds); + } else if ("getVisibleMapNames".equalsIgnoreCase(functionName) || "getAllMapNames".equalsIgnoreCase(functionName)) { FunctionUtil.checkNumberParam(functionName, parameters, 0, 1); @@ -182,15 +226,34 @@ public Object childEvaluate( return FunctionUtil.delimitedResult(delim, mapNames); } else if ("getMapName".equalsIgnoreCase(functionName)) { - FunctionUtil.checkNumberParam(functionName, parameters, 1, 1); - String displayName = parameters.get(0).toString(); FunctionUtil.blockUntrustedMacro(functionName); + FunctionUtil.checkNumberParam(functionName, parameters, 1, 1); - for (ZoneRenderer zr : MapTool.getFrame().getZoneRenderers()) { - if (displayName.equals(zr.getZone().getDisplayName())) { - return zr.getZone().getName(); + final var map = parameters.get(0).toString(); + + // First try treat it as a map ID. + ZoneRenderer match = null; + if (!GUID.isNotGUID(map)) { + try { + match = MapTool.getFrame().getZoneRenderer(GUID.valueOf(map)); + } catch (InvalidGUIDException ignored) { + // Wasn't a GUID after all. } } + + if (match == null) { + // Fall back to look up by display name. + for (ZoneRenderer zr : MapTool.getFrame().getZoneRenderers()) { + if (map.equals(zr.getZone().getDisplayName())) { + match = zr; + break; + } + } + } + if (match != null) { + return match.getZone().getName(); + } + throw new ParserException(I18N.getText("macro.function.map.notFound", functionName)); } else if ("setMapSelectButton".equalsIgnoreCase(functionName)) { diff --git a/src/main/java/net/rptools/maptool/client/functions/TokenLocationFunctions.java b/src/main/java/net/rptools/maptool/client/functions/TokenLocationFunctions.java index c66b419320..599b40177d 100644 --- a/src/main/java/net/rptools/maptool/client/functions/TokenLocationFunctions.java +++ b/src/main/java/net/rptools/maptool/client/functions/TokenLocationFunctions.java @@ -14,7 +14,6 @@ */ package net.rptools.maptool.client.functions; -import com.google.gson.JsonArray; import com.google.gson.JsonElement; import java.awt.*; import java.awt.geom.Point2D; @@ -22,6 +21,7 @@ import java.util.ArrayList; import java.util.List; import java.util.Set; +import java.util.stream.Stream; import net.rptools.maptool.client.AppPreferences; import net.rptools.maptool.client.MapTool; import net.rptools.maptool.client.functions.json.JSONMacroFunctions; @@ -31,6 +31,7 @@ import net.rptools.maptool.client.walker.astar.AStarSquareEuclideanWalker; import net.rptools.maptool.language.I18N; import net.rptools.maptool.model.CellPoint; +import net.rptools.maptool.model.GUID; import net.rptools.maptool.model.Grid; import net.rptools.maptool.model.Token; import net.rptools.maptool.model.Zone; @@ -65,6 +66,7 @@ private TokenLocationFunctions() { "getTokenY", "getTokenDrawOrder", "getTokenMap", + "getTokenMapIDs", "getDistance", "moveToken", "goto", @@ -111,10 +113,18 @@ public Object childEvaluate( return BigDecimal.valueOf(token.getZOrder()); } if (functionName.equalsIgnoreCase("getTokenMap")) { - FunctionUtil.checkNumberParam("getDistance", parameters, 1, 2); + FunctionUtil.checkNumberParam(functionName, parameters, 1, 2); + String identifier = parameters.get(0).toString(); + String delim = parameters.size() > 1 ? parameters.get(1).toString() : ","; + final var zoneNames = getTokenZones(identifier).map(Zone::getName).toList(); + return FunctionUtil.delimitedResult(delim, zoneNames); + } + if (functionName.equalsIgnoreCase("getTokenMapIDs")) { + FunctionUtil.checkNumberParam(functionName, parameters, 1, 2); String identifier = parameters.get(0).toString(); String delim = parameters.size() > 1 ? parameters.get(1).toString() : ","; - return getTokenMap(identifier, delim); + final var zoneNames = getTokenZones(identifier).map(Zone::getId).map(GUID::toString).toList(); + return FunctionUtil.delimitedResult(delim, zoneNames); } if (functionName.equalsIgnoreCase("getDistance")) { FunctionUtil.checkNumberParam("getDistance", parameters, 1, 4); @@ -166,19 +176,9 @@ private String tokenMoveMap(boolean fromCurrentMap, List args) throws Pa } else { tokens.add((String) tokenString); } - Zone zone = null; - List zrenderers = MapTool.getFrame().getZoneRenderers(); - for (ZoneRenderer zr : zrenderers) { - Zone z = zr.getZone(); - if (z.getName().equalsIgnoreCase(map)) { - zone = z; - break; - } - } - if (zone == null) { - throw new ParserException( - I18N.getText("macro.function.moveTokenMap.unknownMap", functionName, map)); - } + + final var zone = FunctionUtil.getZoneRenderer(functionName, map).getZone(); + Zone toZone; Zone fromZone; @@ -606,32 +606,14 @@ public CellPoint getTokenCell(Token token) { } /** - * Returns a list of maps containing the token. + * Returns the zones containing the identified token. * * @param identifier the identifier of the token. - * @param delim the delimiter of the returned list. - * @return the list of maps containing the token. + * @return all zones containing the token. */ - private Object getTokenMap(String identifier, String delim) { - List zrenderers = MapTool.getFrame().getZoneRenderers(); - List mapList = new ArrayList<>(); - - for (final ZoneRenderer zr : zrenderers) { - Zone zone = zr.getZone(); - Token token = zone.resolveToken(identifier); - if (token != null) { - mapList.add(zr.getZone().getName()); - } - } - - if ("json".equalsIgnoreCase(delim)) { - JsonArray jsonArray = new JsonArray(); - for (String map : mapList) { - jsonArray.add(map); - } - return jsonArray; - } else { - return String.join(delim, mapList); - } + private Stream getTokenZones(String identifier) { + return MapTool.getFrame().getZoneRenderers().stream() + .map(ZoneRenderer::getZone) + .filter(zone -> zone.resolveToken(identifier) != null); } } diff --git a/src/main/java/net/rptools/maptool/client/functions/getInfoFunction.java b/src/main/java/net/rptools/maptool/client/functions/getInfoFunction.java index 82f2986be1..f31aa852aa 100644 --- a/src/main/java/net/rptools/maptool/client/functions/getInfoFunction.java +++ b/src/main/java/net/rptools/maptool/client/functions/getInfoFunction.java @@ -307,10 +307,13 @@ private JsonObject getCampaignInfo() throws ParserException { "initiative owner permissions", FunctionUtil.getDecimalForBoolean(cp.isInitiativeOwnerPermissions())); + JsonArray zoneIds = new JsonArray(); JsonObject zinfo = new JsonObject(); for (Zone z : c.getZones()) { + zoneIds.add(z.getId().toString()); zinfo.addProperty(z.getName(), z.getId().toString()); } + cinfo.add("zoneIDs", zoneIds); cinfo.add("zones", zinfo); JsonArray tinfo = new JsonArray(); diff --git a/src/main/java/net/rptools/maptool/util/FunctionUtil.java b/src/main/java/net/rptools/maptool/util/FunctionUtil.java index ba46ace065..6eb3e9424c 100644 --- a/src/main/java/net/rptools/maptool/util/FunctionUtil.java +++ b/src/main/java/net/rptools/maptool/util/FunctionUtil.java @@ -20,6 +20,7 @@ import com.google.gson.JsonPrimitive; import java.math.BigDecimal; import java.util.List; +import javax.annotation.Nonnull; import net.rptools.maptool.client.MapTool; import net.rptools.maptool.client.MapToolVariableResolver; import net.rptools.maptool.client.functions.FindTokenFunctions; @@ -27,6 +28,8 @@ import net.rptools.maptool.client.functions.json.JSONMacroFunctions; import net.rptools.maptool.client.ui.zone.ZoneRenderer; import net.rptools.maptool.language.I18N; +import net.rptools.maptool.model.GUID; +import net.rptools.maptool.model.InvalidGUIDException; import net.rptools.maptool.model.Token; import net.rptools.parser.ParserException; import net.rptools.parser.VariableResolver; @@ -51,6 +54,7 @@ public class FunctionUtil { private static final String KEY_NOT_STRING = "macro.function.general.argumentTypeS"; private static final String KEY_NO_PERM = "macro.function.general.noPermOther"; + private static final String KEY_NO_CURRENT_MAP = "macro.function.map.none"; private static final String KEY_UNKNOWN_MAP = "macro.function.moveTokenMap.unknownMap"; private static final String KEY_UNKNOWN_TOKEN = "macro.function.general.unknownToken"; private static final String KEY_UNKNOWN_TOKEN_ON_MAP = "macro.function.general.unknownTokenOnMap"; @@ -106,7 +110,7 @@ public static void checkNumberParam( * @param functionName the function name (used for generating exception messages). * @param param the parameters for the function * @param indexToken the index to find the token at. If -1, use current token instead. - * @param indexMap the index to find the map name at. If -1, use current map instead. + * @param indexMap the index to find the map name or ID at. If -1, use current map instead. * @return the token. * @throws ParserException if a token is specified but the macro is not trusted, or the specified * token can not be found, or if no token is specified and no token is impersonated. @@ -150,15 +154,26 @@ public static Token getTokenFromParam( * Gets the ZoneRender with the given name, throwing a ParserException if it does not exist. * * @param functionName the function name (used for generating exception messages). - * @param mapName the name of the map + * @param map the name or ID of the map * @return the ZoneRenderer. * @throws ParserException if the map cannot be found */ - public static ZoneRenderer getZoneRenderer(String functionName, String mapName) + public static @Nonnull ZoneRenderer getZoneRenderer(String functionName, String map) throws ParserException { - ZoneRenderer zoneRenderer = MapTool.getFrame().getZoneRenderer(mapName); + if (!GUID.isNotGUID(map)) { + try { + final var zr = MapTool.getFrame().getZoneRenderer(GUID.valueOf(map)); + if (zr != null) { + return zr; + } + } catch (InvalidGUIDException ignored) { + // Wasn't a GUID after all. Fall back to looking up by name. + } + } + + ZoneRenderer zoneRenderer = MapTool.getFrame().getZoneRenderer(map); if (zoneRenderer == null) { - throw new ParserException(I18N.getText(KEY_UNKNOWN_MAP, functionName, mapName)); + throw new ParserException(I18N.getText(KEY_UNKNOWN_MAP, functionName, map)); } return zoneRenderer; } @@ -170,11 +185,11 @@ public static ZoneRenderer getZoneRenderer(String functionName, String mapName) * * @param functionName the function name (used for generating exception messages). * @param param the parameters for the function - * @param indexMap the index to find the map name at. If -1, use current map instead. + * @param indexMap the index to find the map name or ID at. If -1, use current map instead. * @return the ZoneRenderer. * @throws ParserException if the map cannot be found */ - public static ZoneRenderer getZoneRendererFromParam( + public static @Nonnull ZoneRenderer getZoneRendererFromParam( String functionName, List param, int indexMap) throws ParserException { String map = indexMap >= 0 && param.size() > indexMap ? param.get(indexMap).toString() : null; @@ -185,9 +200,6 @@ public static ZoneRenderer getZoneRendererFromParam( } else { zoneRenderer = getZoneRenderer(functionName, map); } - if (zoneRenderer == null) { - throw new ParserException(I18N.getText(KEY_UNKNOWN_MAP, functionName, map)); - } return zoneRenderer; }