Skip to content

Commit

Permalink
GH-478 Add description support for programmatic API. Fix type resolvi…
Browse files Browse the repository at this point in the history
…ng (#478)

* add LiteCommand#executorMeta, add LiteCommand#description, fix LiteContext#get

* fix LiteContext#get
  • Loading branch information
huanmeng-qwq authored Nov 3, 2024
1 parent a5f0208 commit 2c1a623
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 15 deletions.
2 changes: 1 addition & 1 deletion examples/bukkit/build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ plugins {
id("java")
id("com.github.johnrengelman.shadow") version "8.1.1"
id("net.minecrell.plugin-yml.bukkit") version "0.6.0"
id("xyz.jpenilla.run-paper") version "2.3.1"
id("xyz.jpenilla.run-paper") version "2.3.0"
}

version = "3.9.0"
Expand Down
Original file line number Diff line number Diff line change
@@ -1,36 +1,36 @@
package dev.rollczi.example.bukkit;

import dev.rollczi.example.bukkit.argument.GameModeArgument;
import dev.rollczi.example.bukkit.command.GiveCommand;
import dev.rollczi.example.bukkit.command.KickAllCommand;
import dev.rollczi.example.bukkit.command.MuteCommand;
import dev.rollczi.example.bukkit.command.ConvertCommand;
import dev.rollczi.example.bukkit.command.FlyCommand;
import dev.rollczi.example.bukkit.command.GameModeCommand;
import dev.rollczi.example.bukkit.command.GiveCommand;
import dev.rollczi.example.bukkit.command.KickAllCommand;
import dev.rollczi.example.bukkit.command.KickCommand;
import dev.rollczi.example.bukkit.command.MuteCommand;
import dev.rollczi.example.bukkit.command.NumberCommand;
import dev.rollczi.example.bukkit.command.OfflineInfoCommand;
import dev.rollczi.example.bukkit.command.RandomItemCommand;
import dev.rollczi.example.bukkit.command.TeleportCommand;
import dev.rollczi.example.bukkit.command.currency.CurrencyBalanceCommand;
import dev.rollczi.example.bukkit.command.currency.CurrencyCommand;
import dev.rollczi.example.bukkit.command.currency.CurrencyService;
import dev.rollczi.example.bukkit.handler.ExampleInvalidUsageHandler;
import dev.rollczi.example.bukkit.handler.ExampleMissingPermissionsHandler;
import dev.rollczi.example.bukkit.user.User;
import dev.rollczi.example.bukkit.user.UserArgumentResolver;
import dev.rollczi.example.bukkit.user.UserCommand;
import dev.rollczi.example.bukkit.user.UserService;
import dev.rollczi.example.bukkit.validator.IsNotOpValidator;
import dev.rollczi.example.bukkit.validator.IsNotOp;
import dev.rollczi.example.bukkit.validator.IsNotOpValidator;
import dev.rollczi.litecommands.LiteCommands;
import dev.rollczi.litecommands.argument.profile.ProfileNamespaces;
import dev.rollczi.litecommands.bukkit.LiteBukkitFactory;
import dev.rollczi.litecommands.bukkit.LiteBukkitMessages;
import dev.rollczi.example.bukkit.handler.ExampleInvalidUsageHandler;
import dev.rollczi.example.bukkit.handler.ExampleMissingPermissionsHandler;
import dev.rollczi.litecommands.LiteCommands;
import dev.rollczi.litecommands.programmatic.LiteCommand;
import dev.rollczi.litecommands.schematic.SchematicFormat;
import dev.rollczi.litecommands.strict.StrictMode;
import dev.rollczi.litecommands.suggestion.SuggestionResult;
import dev.rollczi.litecommands.schematic.SchematicFormat;
import org.bukkit.GameMode;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;
Expand Down Expand Up @@ -119,7 +119,7 @@ public void onDisable() {
// unregister all commands from bukkit
if (this.liteCommands != null) {
this.liteCommands.unregister();
}
}
}

}
Original file line number Diff line number Diff line change
Expand Up @@ -81,7 +81,7 @@ private <T> T get(String name, TypeToken<T> format) {
return null;
}

if (matchResult.getClass() != format.getRawType()) {
if (!format.getRawType().isAssignableFrom(matchResult.getClass())) {
throw new IllegalArgumentException("Argument with name '" + name + "' is not instance of " + format.getRawType().getName() + " but " + matchResult.getClass().getName());
}
return (T) matchResult;
Expand Down
Original file line number Diff line number Diff line change
@@ -1,22 +1,22 @@
package dev.rollczi.litecommands.programmatic;

import dev.rollczi.litecommands.argument.Argument;
import dev.rollczi.litecommands.bind.BindRequirement;
import dev.rollczi.litecommands.command.builder.CommandBuilder;
import dev.rollczi.litecommands.command.executor.CommandExecutor;
import dev.rollczi.litecommands.command.executor.LiteContext;
import dev.rollczi.litecommands.context.ContextRequirement;
import dev.rollczi.litecommands.flag.FlagProfile;
import dev.rollczi.litecommands.join.JoinProfile;
import dev.rollczi.litecommands.literal.LiteralProfile;
import dev.rollczi.litecommands.meta.Meta;
import dev.rollczi.litecommands.meta.MetaKey;
import dev.rollczi.litecommands.quoted.QuotedProfile;
import dev.rollczi.litecommands.bind.BindRequirement;
import dev.rollczi.litecommands.context.ContextRequirement;
import dev.rollczi.litecommands.reflect.type.TypeToken;
import dev.rollczi.litecommands.requirement.Requirement;
import dev.rollczi.litecommands.scheduler.SchedulerPoll;
import dev.rollczi.litecommands.shared.Preconditions;
import dev.rollczi.litecommands.strict.StrictMode;
import org.jetbrains.annotations.ApiStatus;

import java.util.ArrayList;
import java.util.Arrays;
Expand All @@ -26,7 +26,6 @@
import java.util.function.Consumer;
import java.util.function.Function;
import java.util.function.UnaryOperator;
import org.jetbrains.annotations.ApiStatus;

public class LiteCommand<SENDER> {

Expand Down Expand Up @@ -133,6 +132,15 @@ public <T> LiteCommand<SENDER> meta(MetaKey<T> key, T value) {
return this;
}

public <T> LiteCommand<SENDER> executorMeta(MetaKey<T> key, T value) {
this.executorMeta.put(key, value);
return this;
}

public LiteCommand<SENDER> description(String... description) {
return this.executorMeta(Meta.DESCRIPTION, Arrays.asList(description));
}

/**
* @deprecated Use {@link #execute(Consumer)} instead
*/
Expand Down

0 comments on commit 2c1a623

Please sign in to comment.