Adds a new StargateTeleportEvent to combine some duplicated code

This commit is contained in:
Kristian Knarvik 2022-01-28 22:58:02 +01:00
parent 8a5c094ce1
commit 95293204d5
3 changed files with 22 additions and 2 deletions

View File

@ -12,7 +12,7 @@ import org.jetbrains.annotations.NotNull;
* <p>This event can be used to overwrite the location the entity is teleported to.</p>
*/
@SuppressWarnings("unused")
public class StargateEntityPortalEvent extends StargateEvent {
public class StargateEntityPortalEvent extends StargateEvent implements StargateTeleportEvent {
private static final HandlerList handlers = new HandlerList();
final Entity travellingEntity;
@ -58,6 +58,7 @@ public class StargateEntityPortalEvent extends StargateEvent {
*
* @return <p>Location of the exit point</p>
*/
@Override
public Location getExit() {
return exit;
}

View File

@ -12,7 +12,7 @@ import org.jetbrains.annotations.NotNull;
* <p>This event can be used to overwrite the location the player is teleported to.</p>
*/
@SuppressWarnings("unused")
public class StargatePlayerPortalEvent extends StargatePlayerEvent {
public class StargatePlayerPortalEvent extends StargatePlayerEvent implements StargateTeleportEvent {
private static final HandlerList handlers = new HandlerList();
private final Portal destination;
@ -47,6 +47,7 @@ public class StargatePlayerPortalEvent extends StargatePlayerEvent {
*
* @return <p>Location of the exit point</p>
*/
@Override
public Location getExit() {
return exit;
}

View File

@ -0,0 +1,18 @@
package net.knarcraft.stargate.event;
import org.bukkit.Location;
import org.bukkit.event.Cancellable;
/**
* A generic teleportation event
*/
public interface StargateTeleportEvent extends Cancellable {
/**
* Return the location of the players exit point
*
* @return <p>Location of the exit point</p>
*/
Location getExit();
}