Skip to content

Commit

Permalink
Rename to canUse
Browse files Browse the repository at this point in the history
  • Loading branch information
kennytv committed Jul 11, 2024
1 parent 8bb8be0 commit 4b464a9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
4 changes: 2 additions & 2 deletions patches/api/0469-Brigadier-based-command-API.patch
Original file line number Diff line number Diff line change
Expand Up @@ -548,11 +548,11 @@ index 0000000000000000000000000000000000000000..712db7acae2f9818a3b112f770ee7702
+ * Checks whether a command sender can receive and run the root command.
+ *
+ * @param sender the command sender trying to execute the command
+ * @return whether the command sender fulfill the root command requirement
+ * @return whether the command sender fulfills the root command requirement
+ * @see #permission()
+ */
+ @ApiStatus.OverrideOnly
+ default boolean requires(final @NotNull CommandSender sender) {
+ default boolean canUse(final @NotNull CommandSender sender) {
+ return this.permission() == null || sender.hasPermission(this.permission());
+ }
+
Expand Down
4 changes: 2 additions & 2 deletions patches/server/0975-Brigadier-based-command-API.patch
Original file line number Diff line number Diff line change
Expand Up @@ -686,7 +686,7 @@ index 0000000000000000000000000000000000000000..1b1642f306771f029e6214a2e2ebebb6
+}
diff --git a/src/main/java/io/papermc/paper/command/brigadier/PaperCommands.java b/src/main/java/io/papermc/paper/command/brigadier/PaperCommands.java
new file mode 100644
index 0000000000000000000000000000000000000000..ac83eefcea3f22b7980bf7b4f1f22a5ae18d82c1
index 0000000000000000000000000000000000000000..a3e128bde0fa4ab0ecab4172f02288a29b9fddc7
--- /dev/null
+++ b/src/main/java/io/papermc/paper/command/brigadier/PaperCommands.java
@@ -0,0 +1,194 @@
Expand Down Expand Up @@ -860,7 +860,7 @@ index 0000000000000000000000000000000000000000..ac83eefcea3f22b7980bf7b4f1f22a5a
+ @Override
+ public @Unmodifiable Set<String> register(final PluginMeta pluginMeta, final String label, final @Nullable String description, final Collection<String> aliases, final BasicCommand basicCommand) {
+ final LiteralArgumentBuilder<CommandSourceStack> builder = Commands.literal(label)
+ .requires(stack -> basicCommand.requires(stack.getSender()))
+ .requires(stack -> basicCommand.canUse(stack.getSender()))
+ .then(
+ Commands.argument("args", StringArgumentType.greedyString())
+ .suggests((context, suggestionsBuilder) -> {
Expand Down

0 comments on commit 4b464a9

Please sign in to comment.