fix: pass Uniform instance to built subcommands

dependabot/gradle/org.projectlombok-lombok-1.18.34 1.0.1
William 5 months ago
parent 10baf5307a
commit 39ebab832a
No known key found for this signature in database

@ -46,6 +46,11 @@ public class BukkitCommand extends BaseCommand<CommandSender> {
super(command); super(command);
} }
private BukkitCommand(@NotNull Command command, @NotNull Uniform uniform) {
super(command);
this.uniform = uniform;
}
public BukkitCommand(@NotNull String name, @NotNull String description, @NotNull List<String> aliases) { public BukkitCommand(@NotNull String name, @NotNull String description, @NotNull List<String> aliases) {
super(name, description, aliases); super(name, description, aliases);
} }
@ -117,7 +122,7 @@ public class BukkitCommand extends BaseCommand<CommandSender> {
@Override @Override
public void addSubCommand(@NotNull Command command) { public void addSubCommand(@NotNull Command command) {
addSubCommand(new BukkitCommand(command)); addSubCommand(new BukkitCommand(command, uniform));
} }
} }

@ -43,14 +43,14 @@ public abstract class BaseCommand<S> {
private final String name; private final String name;
private final String description; private final String description;
private final List<String> aliases; private final List<String> aliases;
private final List<CommandSyntax<S>> syntaxes = new ArrayList<>();
private final List<BaseCommand<S>> subCommands = new ArrayList<>();
@Nullable @Nullable
private Predicate<S> condition; private Predicate<S> condition;
@Nullable @Nullable
private CommandExecutor<S> defaultExecutor; private CommandExecutor<S> defaultExecutor;
private Uniform uniform; protected Uniform uniform;
private final List<CommandSyntax<S>> syntaxes = new ArrayList<>();
private final List<BaseCommand<S>> subCommands = new ArrayList<>();
public BaseCommand(@NotNull Command command) { public BaseCommand(@NotNull Command command) {
this.name = command.getName(); this.name = command.getName();

@ -31,6 +31,7 @@ import net.minecraft.util.Identifier;
import net.minecraft.util.InvalidIdentifierException; import net.minecraft.util.InvalidIdentifierException;
import net.william278.uniform.BaseCommand; import net.william278.uniform.BaseCommand;
import net.william278.uniform.Command; import net.william278.uniform.Command;
import net.william278.uniform.Uniform;
import net.william278.uniform.element.ArgumentElement; import net.william278.uniform.element.ArgumentElement;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -43,6 +44,11 @@ public class FabricCommand extends BaseCommand<ServerCommandSource> {
super(command); super(command);
} }
private FabricCommand(@NotNull Command command, @NotNull Uniform uniform) {
super(command);
this.uniform = uniform;
}
public FabricCommand(@NotNull String name, @NotNull List<String> aliases) { public FabricCommand(@NotNull String name, @NotNull List<String> aliases) {
super(name, aliases); super(name, aliases);
} }
@ -80,6 +86,6 @@ public class FabricCommand extends BaseCommand<ServerCommandSource> {
@Override @Override
public void addSubCommand(@NotNull Command command) { public void addSubCommand(@NotNull Command command) {
addSubCommand(new FabricCommand(command)); addSubCommand(new FabricCommand(command, getUniform()));
} }
} }

@ -31,6 +31,7 @@ import net.minecraft.util.Identifier;
import net.minecraft.util.InvalidIdentifierException; import net.minecraft.util.InvalidIdentifierException;
import net.william278.uniform.BaseCommand; import net.william278.uniform.BaseCommand;
import net.william278.uniform.Command; import net.william278.uniform.Command;
import net.william278.uniform.Uniform;
import net.william278.uniform.element.ArgumentElement; import net.william278.uniform.element.ArgumentElement;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -43,6 +44,11 @@ public class FabricCommand extends BaseCommand<ServerCommandSource> {
super(command); super(command);
} }
private FabricCommand(@NotNull Command command, @NotNull Uniform uniform) {
super(command);
this.uniform = uniform;
}
public FabricCommand(@NotNull String name, @NotNull List<String> aliases) { public FabricCommand(@NotNull String name, @NotNull List<String> aliases) {
super(name, aliases); super(name, aliases);
} }
@ -81,6 +87,6 @@ public class FabricCommand extends BaseCommand<ServerCommandSource> {
@Override @Override
public void addSubCommand(@NotNull Command command) { public void addSubCommand(@NotNull Command command) {
addSubCommand(new FabricCommand(command)); addSubCommand(new FabricCommand(command, getUniform()));
} }
} }

@ -3,6 +3,6 @@ javaVersion=17
org.gradle.jvmargs='-Dfile.encoding=UTF-8' org.gradle.jvmargs='-Dfile.encoding=UTF-8'
org.gradle.daemon=true org.gradle.daemon=true
library_version=1.0 library_version=1.0.1
library_archive=uniform library_archive=uniform
library_description=Cross-platform wrapper for making Brigadier commands, based on BrigadierWrapper by Tofaa2, itself inspired by emortalmcs command system. library_description=Cross-platform wrapper for making Brigadier commands, based on BrigadierWrapper by Tofaa2, itself inspired by emortalmcs command system.

@ -30,6 +30,7 @@ import lombok.AllArgsConstructor;
import net.william278.uniform.BaseCommand; import net.william278.uniform.BaseCommand;
import net.william278.uniform.Command; import net.william278.uniform.Command;
import net.william278.uniform.CommandUser; import net.william278.uniform.CommandUser;
import net.william278.uniform.Uniform;
import org.bukkit.event.EventHandler; import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener; import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.plugin.java.JavaPlugin;
@ -51,6 +52,11 @@ public class LegacyPaperCommand extends BaseCommand<BukkitBrigadierCommandSource
super(command); super(command);
} }
private LegacyPaperCommand(@NotNull Command command, @NotNull Uniform uniform) {
super(command);
this.uniform = uniform;
}
public LegacyPaperCommand(@NotNull String name, @NotNull List<String> aliases) { public LegacyPaperCommand(@NotNull String name, @NotNull List<String> aliases) {
super(name, aliases); super(name, aliases);
} }
@ -61,7 +67,7 @@ public class LegacyPaperCommand extends BaseCommand<BukkitBrigadierCommandSource
@Override @Override
public void addSubCommand(@NotNull Command command) { public void addSubCommand(@NotNull Command command) {
addSubCommand(new LegacyPaperCommand(command)); addSubCommand(new LegacyPaperCommand(command, getUniform()));
} }
@AllArgsConstructor @AllArgsConstructor

@ -27,6 +27,7 @@ import io.papermc.paper.plugin.lifecycle.event.types.LifecycleEvents;
import net.william278.uniform.BaseCommand; import net.william278.uniform.BaseCommand;
import net.william278.uniform.Command; import net.william278.uniform.Command;
import net.william278.uniform.CommandUser; import net.william278.uniform.CommandUser;
import net.william278.uniform.Uniform;
import net.william278.uniform.element.ArgumentElement; import net.william278.uniform.element.ArgumentElement;
import org.bukkit.Bukkit; import org.bukkit.Bukkit;
import org.bukkit.Material; import org.bukkit.Material;
@ -50,6 +51,12 @@ public class PaperCommand extends BaseCommand<CommandSourceStack> {
super(command); super(command);
} }
private PaperCommand(@NotNull Command command, @NotNull Uniform uniform) {
super(command);
this.uniform = uniform;
}
public PaperCommand(@NotNull String name, @NotNull List<String> aliases) { public PaperCommand(@NotNull String name, @NotNull List<String> aliases) {
super(name, aliases); super(name, aliases);
} }
@ -109,7 +116,7 @@ public class PaperCommand extends BaseCommand<CommandSourceStack> {
@Override @Override
public void addSubCommand(@NotNull Command command) { public void addSubCommand(@NotNull Command command) {
addSubCommand(new PaperCommand(command)); addSubCommand(new PaperCommand(command, getUniform()));
} }
} }

@ -30,6 +30,7 @@ import com.velocitypowered.api.proxy.ProxyServer;
import com.velocitypowered.api.proxy.server.RegisteredServer; import com.velocitypowered.api.proxy.server.RegisteredServer;
import net.william278.uniform.BaseCommand; import net.william278.uniform.BaseCommand;
import net.william278.uniform.Command; import net.william278.uniform.Command;
import net.william278.uniform.Uniform;
import net.william278.uniform.element.ArgumentElement; import net.william278.uniform.element.ArgumentElement;
import org.jetbrains.annotations.NotNull; import org.jetbrains.annotations.NotNull;
@ -42,6 +43,11 @@ public class VelocityCommand extends BaseCommand<CommandSource> {
super(command); super(command);
} }
private VelocityCommand(@NotNull Command command, @NotNull Uniform uniform) {
super(command);
this.uniform = uniform;
}
public VelocityCommand(@NotNull String name, @NotNull List<String> aliases) { public VelocityCommand(@NotNull String name, @NotNull List<String> aliases) {
super(name, aliases); super(name, aliases);
} }
@ -97,7 +103,7 @@ public class VelocityCommand extends BaseCommand<CommandSource> {
@Override @Override
public void addSubCommand(@NotNull Command command) { public void addSubCommand(@NotNull Command command) {
addSubCommand(new VelocityCommand(command)); addSubCommand(new VelocityCommand(command, getUniform()));
} }
} }

Loading…
Cancel
Save