mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-02 06:28:49 +00:00
fix: being able to teleport a dead player (#758)
* fix: being able to teleport a dead player * why did this changes not get commited * chore: update javadoc
This commit is contained in:
1 parent
c2de97baea
commit
3190a81b7d
6 files changed
+40
-1
No files matched your search
@@ -82,6 +82,10 @@ public class Teleport implements Completable {
|
||||
* @throws TeleportationException if the teleport fails for some reason.
|
||||
*/
|
||||
public void execute() throws TeleportationException {
|
||||
if (!teleporter.isValid()) {
|
||||
throw new TeleportationException(TeleportationException.Type.TELEPORTER_INVALID, plugin);
|
||||
}
|
||||
|
||||
validateTransactions();
|
||||
resolveLocalTeleporter().ifPresentOrElse(this::executeLocal, this::executeRemote);
|
||||
}
|
||||
|
||||
@@ -49,6 +49,13 @@ public interface Teleportable {
|
||||
@NotNull
|
||||
String getName();
|
||||
|
||||
/**
|
||||
* Check if the teleporter can teleport.
|
||||
*
|
||||
* @return true if the teleport may complete.
|
||||
*/
|
||||
boolean isValid();
|
||||
|
||||
@NotNull
|
||||
@Deprecated(since = "4.8")
|
||||
default String getUsername() {
|
||||
|
||||
@@ -80,7 +80,8 @@ public class TeleportationException extends IllegalStateException {
|
||||
WARMUP_ALREADY_MOVING,
|
||||
WORLD_NOT_FOUND,
|
||||
ILLEGAL_TARGET_COORDINATES,
|
||||
CANNOT_TELEPORT_TO_SELF
|
||||
CANNOT_TELEPORT_TO_SELF,
|
||||
TELEPORTER_INVALID
|
||||
}
|
||||
|
||||
}
|
||||
@@ -65,4 +65,13 @@ public record Username(@NotNull String name) implements Teleportable, Target {
|
||||
return name;
|
||||
}
|
||||
|
||||
/**
|
||||
* Check if the teleporter can teleport.
|
||||
*
|
||||
* @return true if the teleport may complete.
|
||||
*/
|
||||
@Override
|
||||
public boolean isValid() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
Reference in new issue
Block a user