Skip to content

Commit

Permalink
Add abillity to remove markers from the marker list while keeping the…
Browse files Browse the repository at this point in the history
…m on the map
  • Loading branch information
TBlueF committed Feb 7, 2023
1 parent 2a3cc1c commit 812e4b8
Showing 1 changed file with 33 additions and 1 deletion.
34 changes: 33 additions & 1 deletion src/main/java/de/bluecolored/bluemap/api/markers/Marker.java
Original file line number Diff line number Diff line change
Expand Up @@ -45,12 +45,14 @@ public abstract class Marker {
private String label;
private Vector3d position;
private int sorting;
private boolean listed;

public Marker(String type, String label, Vector3d position) {
this.type = Objects.requireNonNull(type, "type cannot be null");
this.label = Objects.requireNonNull(label, "label cannot be null");
this.position = Objects.requireNonNull(position, "position cannot be null");
this.sorting = 0;
this.listed = true;
}

/**
Expand Down Expand Up @@ -114,7 +116,7 @@ public void setPosition(double x, double y, double z) {
* A lower value makes the marker sorted first (in lists and menus), a higher value makes it sorted later.<br>
* If multiple markers have the same sorting-value, their order will be arbitrary.<br>
* This value defaults to 0.
* @return This markers sorting-value
* @return this markers sorting-value
*/
public int getSorting() {
return sorting;
Expand All @@ -131,6 +133,24 @@ public void setSorting(int sorting) {
this.sorting = sorting;
}

/**
* This value defines whether the marker will be listed (true) in markers and lists by the webapp (additionally to being
* displayed on the map) or not (false).
* @return whether the marker will be listed or not
*/
public boolean isListed() {
return listed;
}

/**
* Defines whether the marker will be listed (true) in markers and lists by the webapp (additionally to being
* displayed on the map) or not (false).
* @param listed whether the marker will be listed or not
*/
public void setListed(boolean listed) {
this.listed = listed;
}

@Override
public boolean equals(Object o) {
if (this == o) return true;
Expand All @@ -156,6 +176,7 @@ public static abstract class Builder<T extends Marker, B extends Marker.Builder<
String label;
Vector3d position;
Integer sorting;
Boolean listed;

/**
* Sets the label of the {@link Marker}.
Expand Down Expand Up @@ -201,6 +222,16 @@ public B sorting(Integer sorting) {
return self();
}

/**
* Defines whether the marker will be listed (true) in markers and lists by the webapp (additionally to being
* displayed on the map) or not (false).
* @param listed whether the marker will be listed or not
*/
public B listed(Boolean listed) {
this.listed = listed;
return self();
}

/**
* Creates a new {@link Marker} with the current builder-settings
* @return The new {@link Marker}-instance
Expand All @@ -211,6 +242,7 @@ T build(T marker) {
if (label != null) marker.setLabel(label);
if (position != null) marker.setPosition(position);
if (sorting != null) marker.setSorting(sorting);
if (listed != null) marker.setListed(listed);
return marker;
}

Expand Down

0 comments on commit 812e4b8

Please sign in to comment.