Skip to content

Commit

Permalink
add TeleportEvent and change event call
Browse files Browse the repository at this point in the history
  • Loading branch information
HSGamer committed Oct 3, 2024
1 parent 0c78b9f commit 21d1186
Show file tree
Hide file tree
Showing 2 changed files with 30 additions and 2 deletions.
28 changes: 28 additions & 0 deletions src/main/java/me/hsgamer/yatpa/event/TeleportEvent.java
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
package me.hsgamer.yatpa.event;

import me.hsgamer.yatpa.request.RequestEntry;
import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
import org.jetbrains.annotations.NotNull;

public class TeleportEvent extends Event {
private static final HandlerList HANDLERS = new HandlerList();
private final RequestEntry requestEntry;

public TeleportEvent(RequestEntry requestEntry) {
this.requestEntry = requestEntry;
}

public static @NotNull HandlerList getHandlerList() {
return HANDLERS;
}

@Override
public @NotNull HandlerList getHandlers() {
return HANDLERS;
}

public RequestEntry getRequestEntry() {
return requestEntry;
}
}
4 changes: 2 additions & 2 deletions src/main/java/me/hsgamer/yatpa/teleport/TeleportManager.java
Original file line number Diff line number Diff line change
Expand Up @@ -60,9 +60,9 @@ public TeleportResult teleport(RequestEntry requestEntry) {
@Override
public boolean getAsBoolean() {
if (teleportFuture == null) {
plugin.getServer().getPluginManager().callEvent(new PostTeleportEvent(requestEntry));
teleportFuture = teleport.teleport(player, targetLocation);
PostTeleportEvent event = new PostTeleportEvent(requestEntry);
plugin.getServer().getPluginManager().callEvent(event);
teleportFuture.whenComplete((result, throwable) -> plugin.getServer().getPluginManager().callEvent(new PostTeleportEvent(requestEntry)));
return true;
} else {
return !teleportFuture.isDone();
Expand Down

0 comments on commit 21d1186

Please sign in to comment.