Skip to content

minor correction (missing arguments + dead link + inverted comments) #12

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 4 commits into from
Apr 23, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion docs/en/create-commands/permissions.md
Original file line number Diff line number Diff line change
Expand Up @@ -114,7 +114,7 @@ For example, say we're registering a command `/economy`:
/economy - shows your own balance | economy.self
/economy <target> - shows you another players balance | economy.other
/economy give <target> <amount> - gives the target a set amount of money | economy.admin.give
/economy reset <target> <amount> - resets the targets balance | economy.admin.reset
/economy reset <target> - resets the targets balance | economy.admin.reset
```

We first declare the command as normal. Nothing fancy is going on here:
Expand Down
2 changes: 1 addition & 1 deletion docs/en/create-commands/requirements.md
Original file line number Diff line number Diff line change
Expand Up @@ -122,7 +122,7 @@ What's important to note in this example is that if you spend the time to set up

Finally, the part you've all been waiting for - how to update requirements. With the way requirements work, they need to be updated manually. To illustrate why this is the case, I'll explain using [the example of the /repair command](#example-perks-based-on-a-players-level):

When a player joins the game, the server tells the client the list of all commands that the client can run _(don't worry, this is completely normal, as declared [here](https://wiki.vg/Protocol#Declare_Commands))_. Let's say that the player has joined and has less than 30 levels.
When a player joins the game, the server tells the client the list of all commands that the client can run _(don't worry, this is completely normal, as declared [here](https://minecraft.wiki/w/Java_Edition_protocol#Commands))_. Let's say that the player has joined and has less than 30 levels.

When a player has less than 30 levels, they are unable to execute the `/repair` command, because the list of commands that the server sent to the client did not contain the `/repair` command. Eventually, the player will fight some mobs or mine some ores and eventually will reach 30 levels. Despite this, the player's client doesn't actually know that they're now able to use the `/repair` command until the server tells them. As such, the server needs to somehow update the requirements that a player has so a player knows they can run the command.

Expand Down
3 changes: 3 additions & 0 deletions reference-code/src/main/java/createcommands/Permissions.java
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
import dev.jorel.commandapi.CommandAPICommand;
import dev.jorel.commandapi.CommandPermission;
import dev.jorel.commandapi.arguments.DoubleArgument;
import dev.jorel.commandapi.arguments.LiteralArgument;
import dev.jorel.commandapi.arguments.PlayerArgument;
import org.bukkit.entity.Player;

Expand Down Expand Up @@ -73,6 +74,7 @@ class Permissions {
// /economy give <target> <amount> - requires the permission "economy.admin.give" to execute
new CommandAPICommand("economy")
.withPermission("economy.admin.give") // The important part of this example
.withArguments(new LiteralArgument("give"))
.withArguments(new PlayerArgument("target"))
.withArguments(new DoubleArgument("amount"))
.executesPlayer((player, args) -> {
Expand All @@ -87,6 +89,7 @@ class Permissions {
// /economy reset <target> - requires the permission "economy.admin.reset" to execute
new CommandAPICommand("economy")
.withPermission("economy.admin.reset") // The important part of this example
.withArguments(new LiteralArgument("reset"))
.withArguments(new PlayerArgument("target"))
.executesPlayer((player, args) -> {
Player target = (Player) args.get("target");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ class Requirements {
// #region partySystemExampleStep2
List<Argument<?>> arguments = new ArrayList<>();

// The "create" literal, with a requirement that a player must have a party
// The "create" literal, with a requirement that a player must not have a party
arguments.add(new LiteralArgument("create")
.withRequirement(sender -> !partyMembers.containsKey(((Player) sender).getUniqueId()))
);
Expand Down
2 changes: 1 addition & 1 deletion reference-code/src/main/java/tips/PredicateTips.java
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ class PredicateTips {
// #region exampleStep1
List<Argument<?>> arguments = new ArrayList<>();

// The "create" literal, with a requirement that a player must have a party
// The "create" literal, with a requirement that a player must not have a party
arguments.add(new LiteralArgument("create")
.withRequirement(sender -> !partyMembers.containsKey(((Player) sender).getUniqueId()))
);
Expand Down
3 changes: 3 additions & 0 deletions reference-code/src/main/kotlin/createcommands/Permissions.kt
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@ import createcommands.Permissions.Economy
import dev.jorel.commandapi.CommandAPICommand
import dev.jorel.commandapi.CommandPermission
import dev.jorel.commandapi.arguments.DoubleArgument
import dev.jorel.commandapi.arguments.LiteralArgument;
import dev.jorel.commandapi.arguments.PlayerArgument
import dev.jorel.commandapi.executors.PlayerCommandExecutor
import org.bukkit.entity.Player
Expand Down Expand Up @@ -74,6 +75,7 @@ fun permissions() {
// /economy give <target> <amount> - requires the permission "economy.admin.give" to execute
CommandAPICommand("economy")
.withPermission("economy.admin.give") // The important part of this example
.withArguments(LiteralArgument("give"))
.withArguments(PlayerArgument("target"))
.withArguments(DoubleArgument("amount"))
.executesPlayer(PlayerCommandExecutor { player, args ->
Expand All @@ -88,6 +90,7 @@ fun permissions() {
// /economy reset <target> - requires the permission "economy.admin.reset" to execute
CommandAPICommand("economy")
.withPermission("economy.admin.reset") // The important part of this example
.withArguments(LiteralArgument("reset"))
.withArguments(PlayerArgument("target"))
.executesPlayer(PlayerCommandExecutor { player, args ->
val target = args["target"] as Player
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -37,7 +37,7 @@ fun requirements() {
// #region partySystemExampleStep2
var arguments = mutableListOf<Argument<*>>()

// The "create" literal, with a requirement that a player must have a party
// The "create" literal, with a requirement that a player must not have a party
arguments.add(LiteralArgument("create")
.withRequirement { !partyMembers.containsKey((it as Player).uniqueId) }
)
Expand Down
2 changes: 1 addition & 1 deletion reference-code/src/main/kotlin/tips/PredicateTips.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ fun predicateTips() {
// #region exampleStep1
var arguments = mutableListOf<Argument<*>>()

// The "create" literal, with a requirement that a player must have a party
// The "create" literal, with a requirement that a player must not have a party
arguments.add(LiteralArgument("create")
.withRequirement { !partyMembers.containsKey((it as Player).uniqueId) }
)
Expand Down