Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Commit bf27e55

Browse files
committed
Update documentation references and some other minor changes
1 parent eb56e00 commit bf27e55

File tree

21 files changed

+429
-221
lines changed

21 files changed

+429
-221
lines changed

commandapi-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
import com.mojang.brigadier.exceptions.CommandSyntaxException;
3131
import com.mojang.brigadier.suggestion.Suggestions;
3232
import com.mojang.brigadier.tree.LiteralCommandNode;
33+
import de.tr7zw.changeme.nbtapi.NBTContainer;
3334
import dev.jorel.commandapi.Brigadier;
3435
import dev.jorel.commandapi.BukkitTooltip;
3536
import dev.jorel.commandapi.CommandAPI;
@@ -70,6 +71,7 @@
7071
import dev.jorel.commandapi.arguments.MapArgumentBuilder;
7172
import dev.jorel.commandapi.arguments.MathOperationArgument;
7273
import dev.jorel.commandapi.arguments.MultiLiteralArgument;
74+
import dev.jorel.commandapi.arguments.NBTCompoundArgument;
7375
import dev.jorel.commandapi.arguments.ObjectiveArgument;
7476
import dev.jorel.commandapi.arguments.ObjectiveCriteriaArgument;
7577
import dev.jorel.commandapi.arguments.ParticleArgument;
@@ -735,6 +737,19 @@ void argument_multiLiteral() {
735737
/* ANCHOR_END: argumentMultiLiteral1 */
736738
}
737739

740+
void argument_nbt2() {
741+
/* ANCHOR: argumentNBT2 */
742+
new CommandAPICommand("award")
743+
.withArguments(new NBTCompoundArgument<NBTContainer>("nbt"))
744+
.executes((sender, args) -> {
745+
NBTContainer nbt = (NBTContainer) args.get("nbt");
746+
747+
// Do something with "nbt" here...
748+
})
749+
.register();
750+
/* ANCHOR_END: argumentNBT2 */
751+
}
752+
738753
void argument_objectives() {
739754
/* ANCHOR: argumentObjectives1 */
740755
new CommandAPICommand("sidebar")

commandapi-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -576,6 +576,19 @@ CommandAPICommand("gamemode")
576576
/* ANCHOR_END: argumentMultiLiteral1 */
577577
}
578578

579+
fun argument_nbt2() {
580+
/* ANCHOR: argumentNBT2 */
581+
CommandAPICommand("award")
582+
.withArguments(NBTCompoundArgument<NBTContainer>("nbt"))
583+
.executes(CommandExecutor { _, args ->
584+
val nbt = args["nbt"] as NBTContainer
585+
586+
// Do something with "nbt" here...
587+
})
588+
.register()
589+
/* ANCHOR_END: argumentNBT2 */
590+
}
591+
579592
fun argument_objectives() {
580593
/* ANCHOR: argumentObjectives1 */
581594
CommandAPICommand("sidebar")

commandapi-platforms/commandapi-bukkit/commandapi-bukkit-core/src/main/java/dev/jorel/commandapi/CommandAPIBukkitConfig.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,6 @@ public abstract class CommandAPIBukkitConfig<T extends CommandAPIBukkitConfig<T>
1111
JavaPlugin plugin;
1212

1313
// Default configuration
14-
boolean shouldHookPaperReload = true;
1514
boolean skipReloadDatapacks = false;
1615

1716
/**
@@ -70,6 +69,11 @@ public T setNamespace(String namespace) {
7069
return super.setNamespace(namespace);
7170
}
7271

72+
public T skipReloadDatapacks(boolean skip) {
73+
this.skipReloadDatapacks = skip;
74+
return instance();
75+
}
76+
7377
@Override
7478
public abstract T instance();
7579
}

commandapi-platforms/commandapi-paper/commandapi-paper-core/src/main/java/dev/jorel/commandapi/CommandAPIPaperConfig.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -31,8 +31,7 @@ public CommandAPIPaperConfig shouldHookPaperReload(boolean hooked) {
3131
* @return this CommandAPIBukkitConfig
3232
*/
3333
public CommandAPIPaperConfig skipReloadDatapacks(boolean skip) {
34-
this.skipReloadDatapacks = skip;
35-
return this;
34+
return super.skipReloadDatapacks(skip);
3635
}
3736

3837
@Override

commandapi-platforms/commandapi-paper/commandapi-paper-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java

Lines changed: 2 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -76,19 +76,6 @@ public void onLoad() {
7676
);
7777
}
7878
/* ANCHOR_END: argumentNBT1 */
79-
80-
void argument_nbt2() {
81-
/* ANCHOR: argumentNBT2 */
82-
new CommandAPICommand("award")
83-
.withArguments(new NBTCompoundArgument<NBTContainer>("nbt"))
84-
.executes((sender, args) -> {
85-
NBTContainer nbt = (NBTContainer) args.get("nbt");
86-
87-
// Do something with "nbt" here...
88-
})
89-
.register();
90-
/* ANCHOR_END: argumentNBT2 */
91-
}
9279
}
9380

9481
void chatPreview() {
@@ -158,8 +145,8 @@ public void onEnable() {
158145

159146
@Override
160147
public void onDisable() {
161-
CommandAPI.onDisable();
162-
}
148+
CommandAPI.onDisable();
149+
}
163150

164151
}
165152
/* ANCHOR_END: setupShading2 */

commandapi-platforms/commandapi-paper/commandapi-paper-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt

Lines changed: 3 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -73,19 +73,6 @@ override fun onLoad() {
7373
}
7474
/* ANCHOR_END: argumentNBT1 */
7575

76-
fun argument_nbt2() {
77-
/* ANCHOR: argumentNBT2 */
78-
CommandAPICommand("award")
79-
.withArguments(NBTCompoundArgument<NBTContainer>("nbt"))
80-
.executes(CommandExecutor { _, args ->
81-
val nbt = args["nbt"] as NBTContainer
82-
83-
// Do something with "nbt" here...
84-
})
85-
.register()
86-
/* ANCHOR_END: argumentNBT2 */
87-
}
88-
8976
}
9077

9178
fun chatPreview() {
@@ -127,9 +114,9 @@ class setupShading {
127114
val plugin: JavaPlugin = object : JavaPlugin() {}
128115

129116
fun setupShading1() {
130-
/* ANCHOR: setupShading1 */
131-
CommandAPI.onLoad(CommandAPIPaperConfig(plugin).silentLogs(true))
132-
/* ANCHOR_END: setupShading1 */
117+
/* ANCHOR: setupShading1 */
118+
CommandAPI.onLoad(CommandAPIPaperConfig(plugin).silentLogs(true))
119+
/* ANCHOR_END: setupShading1 */
133120
}
134121

135122
/* ANCHOR: setupShading2 */

commandapi-platforms/commandapi-paper/commandapi-paper-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/ExamplesKotlinDSL.kt

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,12 @@
11
package dev.jorel.commandapi.examples.kotlin
22

3+
import de.tr7zw.changeme.nbtapi.NBTContainer
34
import dev.jorel.commandapi.kotlindsl.anyExecutor
45
import dev.jorel.commandapi.kotlindsl.chatArgument
56
import dev.jorel.commandapi.kotlindsl.chatColorArgument
67
import dev.jorel.commandapi.kotlindsl.chatComponentArgument
78
import dev.jorel.commandapi.kotlindsl.commandAPICommand
9+
import dev.jorel.commandapi.kotlindsl.nbtCompoundArgument
810
import dev.jorel.commandapi.kotlindsl.playerArgument
911
import dev.jorel.commandapi.kotlindsl.playerExecutor
1012
import dev.jorel.commandapi.kotlindsl.stringArgument
@@ -62,4 +64,17 @@ commandAPICommand("pbroadcast") {
6264
/* ANCHOR_END: argumentChatAdventure3 */
6365
}
6466

67+
fun argument_nbt() {
68+
/* ANCHOR: argumentNBT1 */
69+
commandAPICommand("award") {
70+
nbtCompoundArgument<NBTContainer>("nbt")
71+
anyExecutor { _, args ->
72+
val nbt = args["nbt"] as NBTContainer
73+
74+
// Do something with "nbt" here...
75+
}
76+
}
77+
/* ANCHOR_END: argumentNBT1 */
78+
}
79+
6580
}

commandapi-platforms/commandapi-spigot/commandapi-spigot-core/src/main/java/dev/jorel/commandapi/CommandAPISpigotConfig.java

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,7 @@ public CommandAPISpigotConfig(JavaPlugin plugin) {
1515
* @return this CommandAPIBukkitConfig
1616
*/
1717
public CommandAPISpigotConfig skipReloadDatapacks(boolean skip) {
18-
this.skipReloadDatapacks = skip;
19-
return this;
18+
return super.skipReloadDatapacks(skip);
2019
}
2120

2221
@Override

commandapi-platforms/commandapi-spigot/commandapi-spigot-documentation-code/src/main/java/dev/jorel/commandapi/examples/java/Examples.java

Lines changed: 5 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -76,19 +76,6 @@ public void onLoad() {
7676
);
7777
}
7878
/* ANCHOR_END: argumentNBT1 */
79-
80-
void argument_nbt2() {
81-
/* ANCHOR: argumentNBT2 */
82-
new CommandAPICommand("award")
83-
.withArguments(new NBTCompoundArgument<NBTContainer>("nbt"))
84-
.executes((sender, args) -> {
85-
NBTContainer nbt = (NBTContainer) args.get("nbt");
86-
87-
// Do something with "nbt" here...
88-
})
89-
.register();
90-
/* ANCHOR_END: argumentNBT2 */
91-
}
9279
}
9380

9481
void chatPreview() {
@@ -110,7 +97,7 @@ void chatPreview() {
11097
.register();
11198
/* ANCHOR_END: chatPreview1 */
11299

113-
/* ANCHOR: chatPreview3 */
100+
/* ANCHOR: chatPreview2 */
114101
new CommandAPICommand("broadcast")
115102
.withArguments(new ChatArgument("message").usePreview(true).withPreview(info -> {
116103
// Convert parsed BaseComponent[] to plain text
@@ -123,17 +110,17 @@ void chatPreview() {
123110
Bukkit.spigot().broadcast((BaseComponent[]) args.get("message"));
124111
})
125112
.register();
126-
/* ANCHOR_END: chatPreview3 */
113+
/* ANCHOR_END: chatPreview2 */
127114
}
128115

129116
class setupShading {
130117
JavaPlugin plugin = new JavaPlugin() {
131118
};
132119

133120
{
134-
/* ANCHOR: setupShading1 */
135-
CommandAPI.onLoad(new CommandAPISpigotConfig(plugin).silentLogs(true));
136-
/* ANCHOR_END: setupShading1 */
121+
/* ANCHOR: setupShading1 */
122+
CommandAPI.onLoad(new CommandAPISpigotConfig(plugin).silentLogs(true));
123+
/* ANCHOR_END: setupShading1 */
137124
}
138125

139126
/* ANCHOR: setupShading2 */

commandapi-platforms/commandapi-spigot/commandapi-spigot-documentation-code/src/main/kotlin/dev/jorel/commandapi/examples/kotlin/Examples.kt

Lines changed: 3 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -76,20 +76,6 @@ override fun onLoad() {
7676
)
7777
}
7878
/* ANCHOR_END: argumentNBT1 */
79-
80-
fun argument_nbt2() {
81-
/* ANCHOR: argumentNBT2 */
82-
CommandAPICommand("award")
83-
.withArguments(NBTCompoundArgument<NBTContainer>("nbt"))
84-
.executes(CommandExecutor { _, args ->
85-
val nbt = args["nbt"] as NBTContainer
86-
87-
// Do something with "nbt" here...
88-
})
89-
.register()
90-
/* ANCHOR_END: argumentNBT2 */
91-
}
92-
9379
}
9480

9581
fun chatPreview() {
@@ -132,9 +118,9 @@ class setupShading {
132118
val plugin: JavaPlugin = object : JavaPlugin() {}
133119

134120
fun setupShading1() {
135-
/* ANCHOR: setupShading1 */
136-
CommandAPI.onLoad(CommandAPISpigotConfig(plugin).silentLogs(true))
137-
/* ANCHOR_END: setupShading1 */
121+
/* ANCHOR: setupShading1 */
122+
CommandAPI.onLoad(CommandAPISpigotConfig(plugin).silentLogs(true))
123+
/* ANCHOR_END: setupShading1 */
138124
}
139125

140126
/* ANCHOR: setupShading2 */

0 commit comments

Comments
 (0)