Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
20 commits
Select commit Hold shift + click to select a range
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
1 change: 1 addition & 0 deletions api/src/main/java/module-info.java
Original file line number Diff line number Diff line change
Expand Up @@ -32,4 +32,5 @@
exports net.kyori.adventure.title;
exports net.kyori.adventure.translation;
exports net.kyori.adventure.util;
exports net.kyori.adventure.waypoint;
}
36 changes: 36 additions & 0 deletions api/src/main/java/net/kyori/adventure/audience/Audience.java
Original file line number Diff line number Diff line change
Expand Up @@ -50,6 +50,7 @@
import net.kyori.adventure.text.ComponentLike;
import net.kyori.adventure.title.Title;
import net.kyori.adventure.title.TitlePart;
import net.kyori.adventure.waypoint.Waypoint;

/**
* A receiver of Minecraft media.
Expand Down Expand Up @@ -720,4 +721,39 @@ default void showDialog(final DialogLike dialog) {
*/
default void closeDialog() {
}

// -------------------
// ---- Waypoints ----
// -------------------

/**
* Tracks a waypoint.
*
* @param waypoint a waypoint
* @since 5.1.0
* @sinceMinecraft 1.21.6
*/
default void trackWaypoint(final Waypoint waypoint) {
}

/**
* Updates a tracked waypoint.
*
* @param waypoint a waypoint
* @since 5.1.0
* @sinceMinecraft 1.21.6
*/
default void updateWaypoint(final Waypoint waypoint) {
}

/**
* Untracks a tracked waypoint.
*
* @param waypoint a waypoint
* @since 5.1.0
* @sinceMinecraft 1.21.6
*/
default void untrackWaypoint(final Waypoint waypoint) {
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@
import net.kyori.adventure.sound.SoundStop;
import net.kyori.adventure.text.Component;
import net.kyori.adventure.title.TitlePart;
import net.kyori.adventure.waypoint.Waypoint;
import org.jetbrains.annotations.ApiStatus;
import org.jetbrains.annotations.Contract;
import org.jetbrains.annotations.UnknownNullability;
Expand Down Expand Up @@ -217,6 +218,21 @@ default void closeDialog() {
for (final Audience audience : this.audiences()) audience.closeDialog();
}

@Override
default void trackWaypoint(final Waypoint waypoint) {
for (final Audience audience : this.audiences()) audience.trackWaypoint(waypoint);
}

@Override
default void updateWaypoint(final Waypoint waypoint) {
for (final Audience audience : this.audiences()) audience.updateWaypoint(waypoint);
}

@Override
default void untrackWaypoint(final Waypoint waypoint) {
for (final Audience audience : this.audiences()) audience.untrackWaypoint(waypoint);
}

/**
* An audience that forwards everything to a single other audience.
*
Expand Down Expand Up @@ -397,5 +413,20 @@ default void showDialog(final DialogLike dialog) {
default void closeDialog() {
this.audience().closeDialog();
}

@Override
default void trackWaypoint(final Waypoint waypoint) {
this.audience().trackWaypoint(waypoint);
}

@Override
default void updateWaypoint(final Waypoint waypoint) {
this.audience().updateWaypoint(waypoint);
}

@Override
default void untrackWaypoint(final Waypoint waypoint) {
this.audience().untrackWaypoint(waypoint);
}
}
}
Original file line number Diff line number Diff line change
@@ -0,0 +1,54 @@
/*
* This file is part of adventure, licensed under the MIT License.
*
* Copyright (c) 2017-2025 KyoriPowered
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.kyori.adventure.waypoint;

import org.jetbrains.annotations.Contract;

/**
* Represents an azimuth waypoint.
*
* @since 5.1.0
* @sinceMinecraft 1.21.6
*/
public sealed interface AzimuthWaypoint extends Waypoint permits AzimuthWaypointImpl {

/**
* Gets the angle.
*
* @return the angle
* @since 5.1.0
*/
float angle();

/**
* Sets the angle.
*
* @param angle the angle
* @return the waypoint
* @since 5.1.0
*/
@Contract("_ -> this")
AzimuthWaypoint angle(final float angle);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,57 @@
/*
* This file is part of adventure, licensed under the MIT License.
*
* Copyright (c) 2017-2025 KyoriPowered
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.kyori.adventure.waypoint;

import net.kyori.adventure.key.Key;
import net.kyori.adventure.text.format.TextColor;

final class AzimuthWaypointImpl extends WaypointImpl implements AzimuthWaypoint {

private float angle;

AzimuthWaypointImpl(final Key style, final TextColor color, final float angle) {
super(style, color);
this.angle = angle;
}

AzimuthWaypointImpl(final TextColor color, final float angle) {
super(color);
this.angle = angle;
}

@Override
public float angle() {
return this.angle;
}

@Override
public AzimuthWaypoint angle(final float angle) {
final float oldAngle = this.angle;
if (angle != oldAngle) {
this.angle = angle;
this.forEachListener(listener -> listener.waypointAngleChanged(this, oldAngle, angle));
}
return this;
}
}
63 changes: 63 additions & 0 deletions api/src/main/java/net/kyori/adventure/waypoint/ChunkWaypoint.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
/*
* This file is part of adventure, licensed under the MIT License.
*
* Copyright (c) 2017-2025 KyoriPowered
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.kyori.adventure.waypoint;

import org.jetbrains.annotations.Contract;

/**
* Represents a chunk waypoint.
*
* @since 5.1.0
* @sinceMinecraft 1.21.6
*/
public sealed interface ChunkWaypoint extends Waypoint permits ChunkWaypointImpl {

/**
* Gets the X coordinate.
*
* @return the X coordinate
* @since 5.1.0
*/
int x();

/**
* Gets the Z coordinate.
*
* @return the Z coordinate
* @since 5.1.0
*/
int z();

/**
* Sets the X and Z coordinate.
*
* @param x the X coordinate
* @param z the Z coordinate
* @return the waypoint
* @since 5.1.0
*/
@Contract("_, _ -> this")
ChunkWaypoint pos(final int x, final int z);

}
Original file line number Diff line number Diff line change
@@ -0,0 +1,68 @@
/*
* This file is part of adventure, licensed under the MIT License.
*
* Copyright (c) 2017-2025 KyoriPowered
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.kyori.adventure.waypoint;

import net.kyori.adventure.key.Key;
import net.kyori.adventure.text.format.TextColor;

final class ChunkWaypointImpl extends WaypointImpl implements ChunkWaypoint {

private int x;
private int z;

ChunkWaypointImpl(final Key style, final TextColor color, final int x, final int z) {
super(style, color);
this.x = x;
this.z = z;
}

ChunkWaypointImpl(final TextColor color, final int x, final int z) {
super(color);
this.x = x;
this.z = z;
}

@Override
public int x() {
return this.x;
}

@Override
public int z() {
return this.z;
}

@Override
public ChunkWaypoint pos(final int x, final int z) {
final int oldX = this.x;
final int oldZ = this.z;
if (x != oldX || z != oldZ) {
this.x = x;
this.z = z;
this.forEachListener(listener -> listener.waypointChunkPositionChanged(this, oldX, oldZ, x, z));
}
return this;
}

}
33 changes: 33 additions & 0 deletions api/src/main/java/net/kyori/adventure/waypoint/EmptyWaypoint.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,33 @@
/*
* This file is part of adventure, licensed under the MIT License.
*
* Copyright (c) 2017-2025 KyoriPowered
*
* Permission is hereby granted, free of charge, to any person obtaining a copy
* of this software and associated documentation files (the "Software"), to deal
* in the Software without restriction, including without limitation the rights
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
* copies of the Software, and to permit persons to whom the Software is
* furnished to do so, subject to the following conditions:
*
* The above copyright notice and this permission notice shall be included in all
* copies or substantial portions of the Software.
*
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
* SOFTWARE.
*/
package net.kyori.adventure.waypoint;

/**
* Represents an empty waypoint.
*
* @since 5.1.0
* @sinceMinecraft 1.21.6
*/
public sealed interface EmptyWaypoint extends Waypoint permits EmptyWaypointImpl {
}
Loading