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; private final String[] aliases;
public BaseCommand(@NotNull Command command) { public BaseCommand(@NotNull Command command) {
this.name = command.getNamespace(); this.name = command.getName();
this.aliases = command.getAliases().toArray(new String[0]); this.aliases = command.getAliases().toArray(new String[0]);
command.provide(this); command.provide(this);
} }

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

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

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

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

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

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

@ -54,8 +54,8 @@ public final class PaperUniform implements Listener {
private void onCommandRegistered(@NotNull CommandRegisteredEvent event) { private void onCommandRegistered(@NotNull CommandRegisteredEvent event) {
for (PaperCommand command : commands) { for (PaperCommand command : commands) {
event.getRoot().addChild(command.build()); 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 com.velocitypowered.api.proxy.Player;
import net.kyori.adventure.audience.Audience; import net.kyori.adventure.audience.Audience;
import net.william278.uniform.CommandUser; import net.william278.uniform.CommandUser;
import org.jetbrains.annotations.NotNull;
import org.jetbrains.annotations.Nullable; import org.jetbrains.annotations.Nullable;
import java.util.UUID; import java.util.UUID;
@ -32,7 +33,7 @@ import java.util.UUID;
public record VelocityCommandUser(CommandSource source) implements CommandUser { public record VelocityCommandUser(CommandSource source) implements CommandUser {
@Override @Override
public Audience getAudience() { public @NotNull Audience getAudience() {
return source; return source;
} }

Loading…
Cancel
Save