Finish command refactoring

This commit is contained in:
William278 committed 2023-03-20 12:57:52 +00:00
1 parent 34eb2c1f54
commit 8b809b6b5b
34 files changed
+427 -589

No files matched your search

@@ -79,7 +79,8 @@ public class Teleport {
// Teleport a local user
final OnlineUser teleporter = localTeleporter.get();
if (target instanceof Username username) {
final Optional<OnlineUser> localTarget = username.findLocally(plugin);
final Optional<OnlineUser> localTarget = username.name().equals("@s")
? Optional.of(executor) : username.findLocally(plugin);
if (localTarget.isPresent()) {
fireEvent((event) -> {
executeEconomyActions();
@@ -37,6 +37,9 @@ public class TeleportBuilder {
}
private void validateTeleport() throws IllegalStateException {
if (teleporter == null) {
throw new IllegalStateException("Teleporter must be set");
}
if (executor == null) {
if (teleporter instanceof OnlineUser onlineUser) {
executor = onlineUser;
@@ -44,9 +47,6 @@ public class TeleportBuilder {
throw new IllegalStateException("Executor must be set if teleporter is not an OnlineUser");
}
}
if (teleporter == null) {
throw new IllegalStateException("Teleporter must be set");
}
if (target == null) {
throw new IllegalStateException("Target must be set");
}