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);
}
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) {
super(name, description, aliases);
}
@ -117,7 +122,7 @@ public class BukkitCommand extends BaseCommand<CommandSender> {
@Override
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 description;
private final List<String> aliases;
private final List<CommandSyntax<S>> syntaxes = new ArrayList<>();
private final List<BaseCommand<S>> subCommands = new ArrayList<>();
@Nullable
private Predicate<S> condition;
@Nullable
private CommandExecutor<S> defaultExecutor;
private Uniform uniform;
private final List<CommandSyntax<S>> syntaxes = new ArrayList<>();
private final List<BaseCommand<S>> subCommands = new ArrayList<>();
protected Uniform uniform;
public BaseCommand(@NotNull Command command) {
this.name = command.getName();

@ -31,6 +31,7 @@ import net.minecraft.util.Identifier;
import net.minecraft.util.InvalidIdentifierException;
import net.william278.uniform.BaseCommand;
import net.william278.uniform.Command;
import net.william278.uniform.Uniform;
import net.william278.uniform.element.ArgumentElement;
import org.jetbrains.annotations.NotNull;
@ -43,6 +44,11 @@ public class FabricCommand extends BaseCommand<ServerCommandSource> {
super(command);
}
private FabricCommand(@NotNull Command command, @NotNull Uniform uniform) {
super(command);
this.uniform = uniform;
}
public FabricCommand(@NotNull String name, @NotNull List<String> aliases) {
super(name, aliases);
}
@ -80,6 +86,6 @@ public class FabricCommand extends BaseCommand<ServerCommandSource> {
@Override
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.william278.uniform.BaseCommand;
import net.william278.uniform.Command;
import net.william278.uniform.Uniform;
import net.william278.uniform.element.ArgumentElement;
import org.jetbrains.annotations.NotNull;
@ -43,6 +44,11 @@ public class FabricCommand extends BaseCommand<ServerCommandSource> {
super(command);
}
private FabricCommand(@NotNull Command command, @NotNull Uniform uniform) {
super(command);
this.uniform = uniform;
}
public FabricCommand(@NotNull String name, @NotNull List<String> aliases) {
super(name, aliases);
}
@ -81,6 +87,6 @@ public class FabricCommand extends BaseCommand<ServerCommandSource> {
@Override
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.daemon=true
library_version=1.0
library_version=1.0.1
library_archive=uniform
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.Command;
import net.william278.uniform.CommandUser;
import net.william278.uniform.Uniform;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.plugin.java.JavaPlugin;
@ -51,6 +52,11 @@ public class LegacyPaperCommand extends BaseCommand<BukkitBrigadierCommandSource
super(command);
}
private LegacyPaperCommand(@NotNull Command command, @NotNull Uniform uniform) {
super(command);
this.uniform = uniform;
}
public LegacyPaperCommand(@NotNull String name, @NotNull List<String> aliases) {
super(name, aliases);
}
@ -61,7 +67,7 @@ public class LegacyPaperCommand extends BaseCommand<BukkitBrigadierCommandSource
@Override
public void addSubCommand(@NotNull Command command) {
addSubCommand(new LegacyPaperCommand(command));
addSubCommand(new LegacyPaperCommand(command, getUniform()));
}
@AllArgsConstructor

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

Loading…
Cancel
Save