Skip to content

Commit 69f425e

Browse files
authored
feat(bluemap): Add colored markers based on shop state (#2179)
- Added colored circle SVG markers as new default option - Green (#2ecc71) for selling shops - Blue (#3498db) for buying shops - Gray (#888888) for frozen/disabled shops - Colors are configurable in config.yml - Added use-custom-icon option to switch between custom icon and colored markers - Kept icon-file-location for backwards compatibility - Adjusted marker Y position for better visibility
1 parent 05abaac commit 69f425e

File tree

2 files changed

+69
-10
lines changed

2 files changed

+69
-10
lines changed

addon/bluemap/src/main/java/com/ghostchu/quickshop/addon/bluemap/Main.java

Lines changed: 51 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -90,19 +90,64 @@ public void updateShopMarker(final Shop shop) {
9090
final MarkerSet markerSet = map.getMarkerSets().computeIfAbsent("quickshop-hikari-shops", (key)->createMarkerSet());
9191
final String markerName = fillPlaceholders(getConfig().getString("marker-label"), shop);
9292
final String desc = fillPlaceholders(getConfig().getString("marker-detail"), shop);
93-
final POIMarker marker = POIMarker.builder()
93+
94+
final POIMarker.Builder markerBuilder = POIMarker.builder()
9495
.label(markerName)
9596
.position(shop.getLocation().getX(),
96-
shop.getLocation().getY(),
97+
shop.getLocation().getY() + 1,
9798
shop.getLocation().getZ())
9899
.maxDistance(getConfig().getDouble("max-distance"))
99-
.detail(desc)
100-
.styleClasses()
101-
.build();
102-
markerSet.getMarkers().put("quickshop-hikari-shop" + shop.getShopId(), marker);
100+
.detail(desc);
101+
102+
// Use custom icon or colored circle based on config
103+
if(getConfig().getBoolean("use-custom-icon", false)) {
104+
final String iconPath = getConfig().getString("icon-file-location", "/assets/chest.png");
105+
markerBuilder.icon(iconPath, 0, 0);
106+
} else {
107+
final String color = getShopColor(shop);
108+
final String svgIcon = "data:image/svg+xml," + createColoredMarkerSvg(color);
109+
markerBuilder.icon(svgIcon, 12, 24); // Anchor at bottom-center of 24x24 icon
110+
}
111+
112+
markerSet.getMarkers().put("quickshop-hikari-shop" + shop.getShopId(), markerBuilder.build());
103113
}
104114
}
105115

116+
/**
117+
* Create a colored circle SVG marker
118+
*
119+
* @param color The fill color
120+
* @return SVG string (URL encoded)
121+
*/
122+
@NotNull
123+
private String createColoredMarkerSvg(final String color) {
124+
125+
final String svg = "<svg xmlns='http://www.w3.org/2000/svg' width='24' height='24'>" +
126+
"<circle cx='12' cy='12' r='10' fill='" + color + "' stroke='white' stroke-width='2'/>" +
127+
"</svg>";
128+
// URL encode for data URI
129+
return svg.replace("#", "%23").replace("'", "%27");
130+
}
131+
132+
/**
133+
* Get the color for a shop based on its state
134+
*
135+
* @param shop The shop to get color for
136+
* @return The color (CSS format)
137+
*/
138+
@NotNull
139+
private String getShopColor(final Shop shop) {
140+
141+
if(shop.isFrozen()) {
142+
return getConfig().getString("colors.frozen", "#888888");
143+
}
144+
if(shop.isBuying()) {
145+
return getConfig().getString("colors.buying", "#3498db");
146+
}
147+
// Default to selling
148+
return getConfig().getString("colors.selling", "#2ecc71");
149+
}
150+
106151
private String fillPlaceholders(String s, final Shop shop) {
107152

108153
final Location loc = shop.getLocation();

addon/bluemap/src/main/resources/config.yml

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,24 @@
1-
config-version: 1
1+
config-version: 2
22
# If you want the marker set/markers to display by default when opening the map.
33
display-by-default: true
4-
#Location for the image you want as your quick-shop marker, it's defaulted to the BlueMap assets folder.
4+
5+
# Icon settings
6+
# If true, uses a custom icon from icon-file-location
7+
# If false, uses colored circle markers based on shop state
8+
use-custom-icon: false
9+
# Location for the image you want as your quick-shop marker (only used if use-custom-icon is true)
510
icon-file-location: "/assets/chest.png"
6-
# If you want to display the marker icon.
7-
display-icon: true
11+
12+
# Marker colors for different shop states (CSS color format: hex, rgb, or color name)
13+
# Only used when use-custom-icon is false
14+
colors:
15+
# Selling shops (players buy from this shop) - Green
16+
selling: "#2ecc71"
17+
# Buying shops (players sell to this shop) - Blue
18+
buying: "#3498db"
19+
# Frozen/disabled shops - Gray
20+
frozen: "#888888"
21+
822
# Max distance of range where the user can see the marker, useful for lag reduction in frames.
923
max-distance: 1000
1024
# This is where the name of each quick-shop marker when looking at the list (placeholders are %item%, %price%, %stock%, %owner%, %type%, %location%).

0 commit comments

Comments
 (0)