refactor: Add shortcut methods to ParsedDestination

This commit is contained in:
Ben Woo 2023-02-15 19:47:11 +08:00
parent 71367d2d69
commit 5d1d71baf2
2 changed files with 34 additions and 2 deletions

View File

@ -2,6 +2,10 @@ package com.onarandombox.MultiverseCore.destination;
import com.onarandombox.MultiverseCore.api.Destination;
import com.onarandombox.MultiverseCore.api.DestinationInstance;
import org.bukkit.Location;
import org.bukkit.entity.Entity;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
/**
* A parsed destination.
@ -23,6 +27,34 @@ public class ParsedDestination<S extends DestinationInstance> {
this.destinationInstance = destinationInstance;
}
/**
* Shortcut for {@link Destination#getIdentifier()}.
*
* @return The destination identifier.
*/
public @NotNull String getIdentifier() {
return destination.getIdentifier();
}
/**
* Shortcut for {@link DestinationInstance#getLocation(Entity)}.
*
* @param teleportee The entity to teleport.
* @return The location to teleport to.
*/
public @Nullable Location getLocation(@NotNull Entity teleportee) {
return destinationInstance.getLocation(teleportee);
}
/**
* Shortcut for {@link DestinationInstance#getFinerPermissionSuffix()}.
*
* @return The finer permission suffix.
*/
public @Nullable String getFinerPermissionSuffix() {
return destinationInstance.getFinerPermissionSuffix();
}
/**
* Gets the destination.
*
@ -48,6 +80,6 @@ public class ParsedDestination<S extends DestinationInstance> {
*/
@Override
public String toString() {
return destination.getIdentifier() + ":" + destinationInstance.serialise();
return getIdentifier() + ":" + destinationInstance.serialise();
}
}

View File

@ -208,7 +208,7 @@ public class SimpleSafeTTeleporter implements SafeTTeleporter {
MultiverseCore.addPlayerToTeleportQueue(teleporter.getIssuer().getName(), teleporteePlayer.getName());
Location safeLoc = destination.getDestinationInstance().getLocation(teleportee);
Location safeLoc = destination.getLocation(teleportee);
if (destination.getDestination().checkTeleportSafety()) {
safeLoc = this.getSafeLocation(teleportee, destination.getDestinationInstance());
}