refactor: add `isConsole method`

dependabot/gradle/org.projectlombok-lombok-1.18.34
William 5 months ago
parent 521769cfd4
commit accf186c33
No known key found for this signature in database

@ -27,6 +27,7 @@ import org.jetbrains.annotations.Nullable;
import java.util.UUID; import java.util.UUID;
@SuppressWarnings("unused")
public interface CommandUser { public interface CommandUser {
@NotNull @NotNull
@ -36,6 +37,10 @@ public interface CommandUser {
String getName(); String getName();
@Nullable @Nullable
UUID getUniqueId(); UUID getUuid();
default boolean isConsole() {
return getName() == null;
}
} }

@ -44,7 +44,7 @@ public record FabricCommandUser(@NotNull ServerCommandSource source) implements
@Override @Override
@Nullable @Nullable
public UUID getUniqueId() { public UUID getUuid() {
return source.getPlayer() != null ? source.getPlayer().getUuid() : null; return source.getPlayer() != null ? source.getPlayer().getUuid() : null;
} }

@ -44,7 +44,7 @@ public record FabricCommandUser(@NotNull ServerCommandSource source) implements
@Override @Override
@Nullable @Nullable
public UUID getUniqueId() { public UUID getUuid() {
return source.getPlayer() != null ? source.getPlayer().getUuid() : null; return source.getPlayer() != null ? source.getPlayer().getUuid() : null;
} }

@ -45,7 +45,7 @@ public record PaperCommandUser(@NotNull BukkitBrigadierCommandSource source) imp
@Override @Override
@Nullable @Nullable
public UUID getUniqueId() { public UUID getUuid() {
return source.getBukkitEntity() != null ? source.getBukkitEntity().getUniqueId() : null; return source.getBukkitEntity() != null ? source.getBukkitEntity().getUniqueId() : null;
} }
} }

@ -45,7 +45,7 @@ public record VelocityCommandUser(CommandSource source) implements CommandUser {
@Override @Override
@Nullable @Nullable
public UUID getUniqueId() { public UUID getUuid() {
return source instanceof Player ? ((Player) source).getUniqueId() : null; return source instanceof Player ? ((Player) source).getUniqueId() : null;
} }

Loading…
Cancel
Save