Skip to content

Commit 64d5951

Browse files
committed
GH-532 Add slash command examples
1 parent 813539d commit 64d5951

File tree

4 files changed

+41
-2
lines changed

4 files changed

+41
-2
lines changed

examples/bukkit/src/main/java/dev/rollczi/example/bukkit/ExamplePlugin.java

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616
import dev.rollczi.example.bukkit.command.currency.CurrencyBalanceCommand;
1717
import dev.rollczi.example.bukkit.command.currency.CurrencyCommand;
1818
import dev.rollczi.example.bukkit.command.currency.CurrencyService;
19+
import dev.rollczi.example.bukkit.command.currency.DoubleSlashCommand;
1920
import dev.rollczi.example.bukkit.handler.ExampleInvalidUsageHandler;
2021
import dev.rollczi.example.bukkit.handler.ExampleMissingPermissionsHandler;
2122
import dev.rollczi.example.bukkit.user.User;
@@ -72,7 +73,8 @@ public void onEnable() {
7273
new CurrencyCommand(currencyService),
7374
new CurrencyBalanceCommand(currencyService),
7475
new CatCommand(),
75-
new UserCommand()
76+
new UserCommand(),
77+
new DoubleSlashCommand()
7678
)
7779

7880
// Custom annotation validators
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
package dev.rollczi.example.bukkit.command.currency;
2+
3+
import dev.rollczi.litecommands.annotations.command.Command;
4+
import dev.rollczi.litecommands.annotations.context.Sender;
5+
import dev.rollczi.litecommands.annotations.execute.Execute;
6+
import org.bukkit.command.CommandSender;
7+
8+
@Command(name = "/slash")
9+
public class DoubleSlashCommand {
10+
11+
@Execute
12+
void executeSlash(@Sender CommandSender sender) {
13+
sender.sendMessage("Double slash command! Hi " + sender.getName() + "!");
14+
}
15+
16+
}

examples/fabric/src/main/java/dev/rollczi/example/fabric/server/ServerExampleFabric.java

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
package dev.rollczi.example.fabric.server;
22

3+
import dev.rollczi.example.fabric.server.command.DoubleSlashCommand;
34
import dev.rollczi.example.fabric.server.command.ExampleCommand;
45
import dev.rollczi.litecommands.fabric.LiteFabricFactory;
56
import dev.rollczi.litecommands.luckperms.LuckPermsPermissionResolver;
@@ -10,7 +11,10 @@ public class ServerExampleFabric implements DedicatedServerModInitializer {
1011
public void onInitializeServer() {
1112
LiteFabricFactory.server()
1213
.permissionResolver(LuckPermsPermissionResolver.lazy())
13-
.commands(new ExampleCommand())
14+
.commands(
15+
new ExampleCommand(),
16+
new DoubleSlashCommand()
17+
)
1418
.build();
1519
}
1620
}
Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
package dev.rollczi.example.fabric.server.command;
2+
3+
import dev.rollczi.litecommands.annotations.command.Command;
4+
import dev.rollczi.litecommands.annotations.context.Sender;
5+
import dev.rollczi.litecommands.annotations.execute.Execute;
6+
import net.minecraft.server.command.ServerCommandSource;
7+
import net.minecraft.text.Text;
8+
9+
@Command(name = "/slash")
10+
public class DoubleSlashCommand {
11+
12+
@Execute
13+
void executeSlash(@Sender ServerCommandSource sender) {
14+
sender.sendMessage(Text.of("Double slash command! Hi " + sender.getName() + "!"));
15+
}
16+
17+
}

0 commit comments

Comments
 (0)