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 strokeOpacity

The opacity of the outer stroke

* @param strokeWeight

The weight (priority) of the stroke

* @param fillColor

The color of the filled-in area

* @param fillOpacity

The opacity of the filled-in area

* @param homeMarker

The name of the icon to use for marking faction homes

* @param homeIcon

The 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 dynmapFactionsPlugin

An instance of the dynmap factions plugin

* @param cfg

The configuration to read

* @param path

The path of the area style to load from the config

* @param def

The 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 dynmapFactionsPlugin

An instance of the dynmap factions plugin

* @param cfg

The configuration to read

* @param path

The 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 dynmapFactionsPlugin

An instance of the dynmap factions plugin

* @param homeMarker

The name of the marker to get

* @return

The 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; } }