Skip to content

Commit 60e791a

Browse files
committed
feat: add methods to add and remove viewers to Waypoint
1 parent 9a844d0 commit 60e791a

File tree

1 file changed

+26
-0
lines changed

1 file changed

+26
-0
lines changed

api/src/main/java/net/kyori/adventure/waypoint/Waypoint.java

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -208,6 +208,32 @@ static VectorWaypoint vector(final Key style, final TextColor color, final int x
208208
@UnmodifiableView
209209
Iterable<? extends Audience> viewers();
210210

211+
/**
212+
* Track this waypoint for {@code viewer}.
213+
*
214+
* @param viewer the viewer
215+
* @return the waypoint
216+
* @see Audience#trackWaypoint(Waypoint)
217+
* @since 5.1.0
218+
*/
219+
default Waypoint addViewer(final Audience viewer) {
220+
viewer.trackWaypoint(this);
221+
return this;
222+
}
223+
224+
/**
225+
* Untrack this waypoint for {@code viewer}.
226+
*
227+
* @param viewer the viewer
228+
* @return the waypoint
229+
* @see Audience#untrackWaypoint(Waypoint)
230+
* @since 5.1.0
231+
*/
232+
default Waypoint removeViewer(final Audience viewer) {
233+
viewer.untrackWaypoint(this);
234+
return this;
235+
}
236+
211237
/**
212238
* A listener for changes on a {@link Waypoint}.
213239
*

0 commit comments

Comments
 (0)