mirror of
https://github.com/darksaid98/HuskHomes.git
synced 2026-12-04 06:28:49 +00:00
Resolve executor during builder when not set
This commit is contained in:
1 file changed
+6
-5
@@ -27,7 +27,7 @@ public class TeleportBuilder {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@NotNull
|
@NotNull
|
||||||
public TimedTeleport toTimedTeleport() throws IllegalStateException {
|
public TimedTeleport toTimedTeleport() throws TeleportationException, IllegalStateException {
|
||||||
validateTeleport();
|
validateTeleport();
|
||||||
if (!(teleporter instanceof OnlineUser onlineTeleporter)) {
|
if (!(teleporter instanceof OnlineUser onlineTeleporter)) {
|
||||||
throw new IllegalStateException("Teleporter must be an OnlineUser for timed teleportation");
|
throw new IllegalStateException("Teleporter must be an OnlineUser for timed teleportation");
|
||||||
@@ -36,19 +36,20 @@ public class TeleportBuilder {
|
|||||||
plugin.getSettings().getTeleportWarmupTime(), updateLastPosition, economyActions, plugin);
|
plugin.getSettings().getTeleportWarmupTime(), updateLastPosition, economyActions, plugin);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void validateTeleport() throws IllegalStateException {
|
private void validateTeleport() throws TeleportationException {
|
||||||
if (teleporter == null) {
|
if (teleporter == null) {
|
||||||
throw new IllegalStateException("Teleporter must be set");
|
throw new TeleportationException(TeleportationException.Type.TELEPORTER_NOT_FOUND);
|
||||||
}
|
}
|
||||||
if (executor == null) {
|
if (executor == null) {
|
||||||
if (teleporter instanceof OnlineUser onlineUser) {
|
if (teleporter instanceof OnlineUser onlineUser) {
|
||||||
executor = onlineUser;
|
executor = onlineUser;
|
||||||
} else {
|
} else {
|
||||||
throw new IllegalStateException("Executor must be set if teleporter is not an OnlineUser");
|
executor = ((Username) teleporter).findLocally(plugin)
|
||||||
|
.orElseThrow(() -> new TeleportationException(TeleportationException.Type.TELEPORTER_NOT_FOUND));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (target == null) {
|
if (target == null) {
|
||||||
throw new IllegalStateException("Target must be set");
|
throw new TeleportationException(TeleportationException.Type.TARGET_NOT_FOUND);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user