Skip to content

Commit 208b9b8

Browse files
authored
minor correction (missing arguments + dead link + inverted comments) (#12)
* fix: requirement description for "create" literal to indicate players must not have a party * fix: update economy command examples to include missing literals and correct /economy reset usage * fix: dead link to Minecraft commands protocol - old link: https://wiki.vg/Protocol#Declare_Commands - waybackmachine: https://web.archive.org/web/20200417072545/https://wiki.vg/Protocol#Declare_Commands - wiki.vg merge: https://minecraft.wiki/w/Minecraft_Wiki:Projects/wiki.vg_merge/Commands - new link: https://minecraft.wiki/w/Java_Edition_protocol#Commands * fix: remove new keyword in Kotlin example
1 parent dafa2c4 commit 208b9b8

File tree

8 files changed

+12
-6
lines changed

8 files changed

+12
-6
lines changed

docs/en/create-commands/permissions.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -114,7 +114,7 @@ For example, say we're registering a command `/economy`:
114114
/economy - shows your own balance | economy.self
115115
/economy <target> - shows you another players balance | economy.other
116116
/economy give <target> <amount> - gives the target a set amount of money | economy.admin.give
117-
/economy reset <target> <amount> - resets the targets balance | economy.admin.reset
117+
/economy reset <target> - resets the targets balance | economy.admin.reset
118118
```
119119

120120
We first declare the command as normal. Nothing fancy is going on here:

docs/en/create-commands/requirements.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -122,7 +122,7 @@ What's important to note in this example is that if you spend the time to set up
122122

123123
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):
124124

125-
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.
125+
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.
126126

127127
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.
128128

reference-code/src/main/java/createcommands/Permissions.java

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
import dev.jorel.commandapi.CommandAPICommand;
44
import dev.jorel.commandapi.CommandPermission;
55
import dev.jorel.commandapi.arguments.DoubleArgument;
6+
import dev.jorel.commandapi.arguments.LiteralArgument;
67
import dev.jorel.commandapi.arguments.PlayerArgument;
78
import org.bukkit.entity.Player;
89

@@ -73,6 +74,7 @@ class Permissions {
7374
// /economy give <target> <amount> - requires the permission "economy.admin.give" to execute
7475
new CommandAPICommand("economy")
7576
.withPermission("economy.admin.give") // The important part of this example
77+
.withArguments(new LiteralArgument("give"))
7678
.withArguments(new PlayerArgument("target"))
7779
.withArguments(new DoubleArgument("amount"))
7880
.executesPlayer((player, args) -> {
@@ -87,6 +89,7 @@ class Permissions {
8789
// /economy reset <target> - requires the permission "economy.admin.reset" to execute
8890
new CommandAPICommand("economy")
8991
.withPermission("economy.admin.reset") // The important part of this example
92+
.withArguments(new LiteralArgument("reset"))
9093
.withArguments(new PlayerArgument("target"))
9194
.executesPlayer((player, args) -> {
9295
Player target = (Player) args.get("target");

reference-code/src/main/java/createcommands/Requirements.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -49,7 +49,7 @@ class Requirements {
4949
// #region partySystemExampleStep2
5050
List<Argument<?>> arguments = new ArrayList<>();
5151

52-
// The "create" literal, with a requirement that a player must have a party
52+
// The "create" literal, with a requirement that a player must not have a party
5353
arguments.add(new LiteralArgument("create")
5454
.withRequirement(sender -> !partyMembers.containsKey(((Player) sender).getUniqueId()))
5555
);

reference-code/src/main/java/tips/PredicateTips.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@ class PredicateTips {
1818
// #region exampleStep1
1919
List<Argument<?>> arguments = new ArrayList<>();
2020

21-
// The "create" literal, with a requirement that a player must have a party
21+
// The "create" literal, with a requirement that a player must not have a party
2222
arguments.add(new LiteralArgument("create")
2323
.withRequirement(sender -> !partyMembers.containsKey(((Player) sender).getUniqueId()))
2424
);

reference-code/src/main/kotlin/createcommands/Permissions.kt

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@ import createcommands.Permissions.Economy
44
import dev.jorel.commandapi.CommandAPICommand
55
import dev.jorel.commandapi.CommandPermission
66
import dev.jorel.commandapi.arguments.DoubleArgument
7+
import dev.jorel.commandapi.arguments.LiteralArgument;
78
import dev.jorel.commandapi.arguments.PlayerArgument
89
import dev.jorel.commandapi.executors.PlayerCommandExecutor
910
import org.bukkit.entity.Player
@@ -74,6 +75,7 @@ fun permissions() {
7475
// /economy give <target> <amount> - requires the permission "economy.admin.give" to execute
7576
CommandAPICommand("economy")
7677
.withPermission("economy.admin.give") // The important part of this example
78+
.withArguments(LiteralArgument("give"))
7779
.withArguments(PlayerArgument("target"))
7880
.withArguments(DoubleArgument("amount"))
7981
.executesPlayer(PlayerCommandExecutor { player, args ->
@@ -88,6 +90,7 @@ fun permissions() {
8890
// /economy reset <target> - requires the permission "economy.admin.reset" to execute
8991
CommandAPICommand("economy")
9092
.withPermission("economy.admin.reset") // The important part of this example
93+
.withArguments(LiteralArgument("reset"))
9194
.withArguments(PlayerArgument("target"))
9295
.executesPlayer(PlayerCommandExecutor { player, args ->
9396
val target = args["target"] as Player

reference-code/src/main/kotlin/createcommands/Requirements.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ fun requirements() {
3737
// #region partySystemExampleStep2
3838
var arguments = mutableListOf<Argument<*>>()
3939

40-
// The "create" literal, with a requirement that a player must have a party
40+
// The "create" literal, with a requirement that a player must not have a party
4141
arguments.add(LiteralArgument("create")
4242
.withRequirement { !partyMembers.containsKey((it as Player).uniqueId) }
4343
)

reference-code/src/main/kotlin/tips/PredicateTips.kt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ fun predicateTips() {
1313
// #region exampleStep1
1414
var arguments = mutableListOf<Argument<*>>()
1515

16-
// The "create" literal, with a requirement that a player must have a party
16+
// The "create" literal, with a requirement that a player must not have a party
1717
arguments.add(LiteralArgument("create")
1818
.withRequirement { !partyMembers.containsKey((it as Player).uniqueId) }
1919
)

0 commit comments

Comments
 (0)