package org.dynmap.factions.config; import org.bukkit.configuration.file.FileConfiguration; import org.dynmap.factions.DynmapFactionsPlugin; import org.dynmap.markers.MarkerIcon; import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.Nullable; /** * A style usable to mark a faction area * * @param strokeColor
The color of the outer stroke
* @param strokeOpacityThe opacity of the outer stroke
* @param strokeWeightThe weight (priority) of the stroke
* @param fillColorThe color of the filled-in area
* @param fillOpacityThe opacity of the filled-in area
* @param homeMarkerThe name of the icon to use for marking faction homes
* @param homeIconThe icon to use for marking faction homes
* @param boost */ public record AreaStyle(String strokeColor, double strokeOpacity, int strokeWeight, String fillColor, double fillOpacity, String homeMarker, MarkerIcon homeIcon, boolean boost) { /** * Instantiates a new area style * * @param dynmapFactionsPluginAn instance of the dynmap factions plugin
* @param cfgThe configuration to read
* @param pathThe path of the area style to load from the config
* @param defThe default area style to use for missing values
*/ public AreaStyle(@NotNull DynmapFactionsPlugin dynmapFactionsPlugin, @NotNull FileConfiguration cfg, @NotNull String path, @NotNull AreaStyle def) { this(cfg.getString(path + ".strokeColor", def.strokeColor), cfg.getDouble(path + ".strokeOpacity", def.strokeOpacity), cfg.getInt(path + ".strokeWeight", def.strokeWeight), cfg.getString(path + ".fillColor", def.fillColor), cfg.getDouble(path + ".fillOpacity", def.fillOpacity), cfg.getString(path + ".homeIcon", def.homeMarker), getHomeIcon(dynmapFactionsPlugin, cfg.getString(path + ".homeIcon", def.homeMarker)), cfg.getBoolean(path + ".boost", def.boost)); } /** * Instantiates a new area style * * @param dynmapFactionsPluginAn instance of the dynmap factions plugin
* @param cfgThe configuration to read
* @param pathThe path of the area style to load from the config
*/ public AreaStyle(@NotNull DynmapFactionsPlugin dynmapFactionsPlugin, @NotNull FileConfiguration cfg, @NotNull String path) { this(cfg.getString(path + ".strokeColor", "#FF0000"), cfg.getDouble(path + ".strokeOpacity", 0.8), cfg.getInt(path + ".strokeWeight", 3), cfg.getString(path + ".fillColor", "#FF0000"), cfg.getDouble(path + ".fillOpacity", 0.35), cfg.getString(path + ".homeIcon", null), getHomeIcon(dynmapFactionsPlugin, cfg.getString(path + ".homeIcon", null)), cfg.getBoolean(path + ".boost", false)); } /** * Gets the icon to use for marking a faction home * * @param dynmapFactionsPluginAn instance of the dynmap factions plugin
* @param homeMarkerThe name of the marker to get
* @returnThe marker, or null if it does not exist
*/ @Nullable private static MarkerIcon getHomeIcon(@NotNull DynmapFactionsPlugin dynmapFactionsPlugin, @Nullable String homeMarker) { MarkerIcon homeIcon = null; if (homeMarker != null) { homeIcon = dynmapFactionsPlugin.getMarkerAPI().getMarkerIcon(homeMarker); if (homeIcon == null) { DynmapFactionsPlugin.severe("Invalid home icon: " + homeMarker); homeIcon = dynmapFactionsPlugin.getMarkerAPI().getMarkerIcon("blueicon"); } } return homeIcon; } }