refactor: fixup Command method names

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

@ -45,7 +45,7 @@ public abstract class BaseCommand<S> {
private final String[] aliases;
public BaseCommand(@NotNull Command command) {
this.name = command.getNamespace();
this.name = command.getName();
this.aliases = command.getAliases().toArray(new String[0]);
command.provide(this);
}

@ -28,10 +28,12 @@ import java.util.List;
public interface Command {
@NotNull
String getNamespace();
String getName();
@NotNull
List<String> getAliases();
default List<String> getAliases() {
return List.of();
}
<S> void provide(@NotNull BaseCommand<S> command);

@ -22,15 +22,20 @@
package net.william278.uniform;
import net.kyori.adventure.audience.Audience;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.UUID;
public interface CommandUser {
@NotNull
Audience getAudience();
@Nullable
String getName();
@Nullable
UUID getUniqueId();
}

@ -25,20 +25,12 @@ import net.kyori.adventure.audience.Audience;
import net.kyori.adventure.text.Component;
import org.jetbrains.annotations.NotNull;
import java.util.List;
public class ExampleCrossPlatCommand implements Command {
@Override
@NotNull
public String getNamespace() {
return "example";
}
@Override
@NotNull
public List<String> getAliases() {
return List.of("cross-plat");
public String getName() {
return "example-crossplat";
}
@Override

@ -32,7 +32,7 @@ import java.util.UUID;
public record FabricCommandUser(@NotNull ServerCommandSource source) implements CommandUser {
@Override
public Audience getAudience() {
public @NotNull Audience getAudience() {
return (Audience) source.getPlayer();
}

@ -32,7 +32,7 @@ import java.util.UUID;
public record FabricCommandUser(@NotNull ServerCommandSource source) implements CommandUser {
@Override
public Audience getAudience() {
public @NotNull Audience getAudience() {
return (Audience) source.getPlayer();
}

@ -33,7 +33,7 @@ public record PaperCommandUser(@NotNull BukkitBrigadierCommandSource source) imp
@Override
public Audience getAudience() {
public @NotNull Audience getAudience() {
return source.getBukkitSender();
}

@ -54,8 +54,8 @@ public final class PaperUniform implements Listener {
private void onCommandRegistered(@NotNull CommandRegisteredEvent event) {
for (PaperCommand command : commands) {
event.getRoot().addChild(command.build());
commands.remove(command);
}
commands.clear();
}
/**

@ -25,6 +25,7 @@ import com.velocitypowered.api.command.CommandSource;
import com.velocitypowered.api.proxy.Player;
import net.kyori.adventure.audience.Audience;
import net.william278.uniform.CommandUser;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable;
import java.util.UUID;
@ -32,7 +33,7 @@ import java.util.UUID;
public record VelocityCommandUser(CommandSource source) implements CommandUser {
@Override
public Audience getAudience() {
public @NotNull Audience getAudience() {
return source;
}

Loading…
Cancel
Save