Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 10 additions & 9 deletions src/main/java/dev/kugge/signmarkers/watcher/SignWatcher.java
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,11 @@ public class SignWatcher implements Listener {
@EventHandler
public void onSignWrite(SignChangeEvent event) {
Component header = event.line(0);
if (header == Component.empty() || header == null) return;
if (header == null || header == Component.empty()) return;
if (!header.toString().contains("[map]")) return;

Component cicon = event.line(3);
if (cicon == Component.empty() || cicon == null) return;
if (cicon == null || cicon == Component.empty()) return;

String icon = "./markers/" + LegacyComponentSerializer.legacySection().serialize(cicon) + ".png";
File iconFile = new File(SignMarkers.webRoot + "/" + icon);
Expand All @@ -40,16 +40,17 @@ public void onSignWrite(SignChangeEvent event) {
return;
}

Component clabel1 = event.line(1);
if (clabel1 == Component.empty() || clabel1 == null) return;

Component clabel2 = event.line(2);
String label = LegacyComponentSerializer.legacySection().serialize(clabel1)
+ LegacyComponentSerializer.legacySection().serialize(clabel2);

Block block = event.getBlock();
Vector3d pos = new Vector3d(block.getX(), block.getY(), block.getZ());

String label = "";
for (int i = 1; i <= 3; i++) {
Component line = event.line(i);
if (line != null && !line.equals(Component.empty())) {
label += LegacyComponentSerializer.legacySection().serialize(line);
}
}

String id = "marker-" + pos.getX() + "-" + pos.getY() + "-" + pos.getZ();
POIMarker marker = POIMarker.builder().label(label).position(pos).icon(icon, anchor).maxDistance(100000).build();
SignMarkers.markerSet.get(block.getWorld()).put(id, marker);
Expand Down