From 5a0f2a7c19612e058780c941dcc11292b3f105af Mon Sep 17 00:00:00 2001 From: Mysticdrew Date: Tue, 9 Jul 2024 11:13:19 -0500 Subject: [PATCH] added waypoint group transfer event --- .../v2/common/event/CommonEventRegistry.java | 6 +++ .../event/common/WaypointGroupEvent.java | 2 +- .../common/WaypointGroupTransferEvent.java | 54 +++++++++++++++++++ 3 files changed, 61 insertions(+), 1 deletion(-) create mode 100644 common/src/main/java/journeymap/api/v2/common/event/common/WaypointGroupTransferEvent.java diff --git a/common/src/main/java/journeymap/api/v2/common/event/CommonEventRegistry.java b/common/src/main/java/journeymap/api/v2/common/event/CommonEventRegistry.java index 5e0631cb..260b9867 100644 --- a/common/src/main/java/journeymap/api/v2/common/event/CommonEventRegistry.java +++ b/common/src/main/java/journeymap/api/v2/common/event/CommonEventRegistry.java @@ -4,6 +4,7 @@ import journeymap.api.v2.client.IClientPlugin; import journeymap.api.v2.common.event.common.WaypointEvent; import journeymap.api.v2.common.event.common.WaypointGroupEvent; +import journeymap.api.v2.common.event.common.WaypointGroupTransferEvent; import journeymap.api.v2.common.event.impl.Event; import journeymap.api.v2.common.event.impl.EventFactory; @@ -25,4 +26,9 @@ public class CommonEventRegistry * This event handles all the CRUD operations of a waypoint groups on client and server. */ public static final Event WAYPOINT_GROUP_EVENT = EventFactory.create(WaypointGroupEvent.class); + + /** + * This event fires when a waypoint is transferred from one group to another, from may be null. + */ + public static final Event WAYPOINT_GROUP_TRANSFER_EVENT = EventFactory.create(WaypointGroupTransferEvent.class); } diff --git a/common/src/main/java/journeymap/api/v2/common/event/common/WaypointGroupEvent.java b/common/src/main/java/journeymap/api/v2/common/event/common/WaypointGroupEvent.java index 7738f391..e48b60a6 100644 --- a/common/src/main/java/journeymap/api/v2/common/event/common/WaypointGroupEvent.java +++ b/common/src/main/java/journeymap/api/v2/common/event/common/WaypointGroupEvent.java @@ -16,7 +16,7 @@ protected WaypointGroupEvent(WaypointGroup group, Context context) } /** - * Gets the waypoint that the event is handling. + * Gets the waypoint group that the event is handling. * * @return - The waypoint group. */ diff --git a/common/src/main/java/journeymap/api/v2/common/event/common/WaypointGroupTransferEvent.java b/common/src/main/java/journeymap/api/v2/common/event/common/WaypointGroupTransferEvent.java new file mode 100644 index 00000000..a7c6d29b --- /dev/null +++ b/common/src/main/java/journeymap/api/v2/common/event/common/WaypointGroupTransferEvent.java @@ -0,0 +1,54 @@ +package journeymap.api.v2.common.event.common; + +import journeymap.api.v2.common.event.impl.JourneyMapEvent; +import journeymap.api.v2.common.waypoint.Waypoint; +import journeymap.api.v2.common.waypoint.WaypointGroup; +import org.jetbrains.annotations.Nullable; + +public class WaypointGroupTransferEvent extends JourneyMapEvent +{ + private final WaypointGroup to; + private final WaypointGroup from; + private final Waypoint waypoint; + + protected WaypointGroupTransferEvent(@Nullable WaypointGroup from, WaypointGroup to, Waypoint waypoint) + { + super(true); + this.from = from; + this.to = to; + this.waypoint = waypoint; + } + + /** + * The group the waypoint is transferring to. + * + * @return - The waypoint group. + */ + public WaypointGroup getGroupTo() + { + return to; + } + + /** + * The group the waypoint is transferring from. + *

+ * May be null. + * + * @return - The waypoint group. + */ + @Nullable + public WaypointGroup getGroupFrom() + { + return from; + } + + /** + * Gets the waypoint that is transferring groups. + * + * @return - The waypoint group. + */ + public Waypoint getWaypoint() + { + return waypoint; + } +}