@@ -7,71 +7,181 @@ Create a new instance of `LiteCommands` using specific factory for your platform
7
7
<!-- Bukkit -->
8
8
<tab title =" Bukkit " >
9
9
10
+ <warning >
11
+ <b ><u >Don't</u ></b > add any commands to <code >plugin.yml</code >! If you have declared commands in the <code >plugin.yml</code > then LiteCommands will <b >not able</b > to register them.
12
+ </warning >
13
+ <br />
14
+
10
15
``` Java
11
- this . liteCommands = LiteCommandsBukkit . builder(" my-plugin" , this )
12
- .commands(
13
- new FlyCommand (),
14
- new GameModeCommand ()
15
- )
16
- .build();
16
+ public class MyPlugin extends JavaPlugin {
17
+
18
+ private LiteCommands<CommandSender > liteCommands;
19
+
20
+ @Override
21
+ public void onEnable () {
22
+ this . liteCommands = LiteBukkitFactory . builder(" my-plugin" , this )
23
+ .commands(
24
+ new FlyCommand (),
25
+ new GameModeCommand ()
26
+ )
27
+ .build();
28
+
29
+ // your code ...
30
+ }
31
+
32
+ @Override
33
+ public void onDisable () {
34
+ this . liteCommands. unregister();
35
+ }
36
+
37
+ }
17
38
```
39
+
18
40
</tab >
19
41
20
42
<!-- Velocity -->
21
43
<tab title =" Velocity " >
22
44
23
45
``` Java
24
- this . liteCommands = LiteVelocityFactory . builder(this . proxyServer)
25
- .commands(
26
- new SendCommand (),
27
- new MoveCommand ()
28
- )
29
- .build();
46
+ @Plugin (id = " example-plugin" , name = " ExamplePlugin" , version = " 1.0.0" )
47
+ public class ExamplePlugin {
48
+
49
+ private final ProxyServer proxyServer;
50
+ private LiteCommands<CommandSource > liteCommands;
51
+
52
+ @Inject
53
+ public ExamplePlugin (ProxyServer proxyServer ) {
54
+ this . proxyServer = proxyServer;
55
+ }
56
+
57
+ @Subscribe
58
+ public void onProxyInitialization (ProxyInitializeEvent event ) {
59
+ this . liteCommands = LiteVelocityFactory . builder(this . proxyServer)
60
+ .commands(
61
+ new SendCommand (),
62
+ new MoveCommand ()
63
+ )
64
+ .build();
65
+
66
+ // your code ...
67
+ }
68
+
69
+ @Subscribe
70
+ public void onProxyShutdown (ProxyShutdownEvent event ) {
71
+ this . liteCommands. unregister();
72
+ }
73
+ }
30
74
```
75
+
31
76
</tab >
32
77
33
78
<!-- BungeeCord -->
34
79
<tab title =" BungeeCord " >
35
80
36
81
``` Java
37
- this . liteCommands = LiteBungeeFactory . builder(this )
38
- .commands(
39
- new SendCommand (),
40
- new MoveCommand ()
41
- )
42
- .build();
82
+ public class ExamplePlugin extends Plugin {
83
+
84
+ private LiteCommands<CommandSender > liteCommands;
85
+
86
+ @Override
87
+ public void onEnable () {
88
+ this . liteCommands = LiteBungeeFactory . builder(this )
89
+ .commands(
90
+ new SendCommand (),
91
+ new MoveCommand ()
92
+ )
93
+ .build();
94
+
95
+ // your code ...
96
+ }
97
+ }
98
+
43
99
```
44
100
</tab >
45
101
46
102
<!-- Minestom -->
47
103
<tab title =" Minestom " >
48
104
49
105
``` Java
50
- Server server = MinecraftServer . getServer();
51
- CommandManager commandManager = MinecraftServer . getCommandManager();
52
-
53
- this . liteCommands = LiteMinestomFactory . builder(server, commandManager)
54
- .commands(
55
- new FlyCommand (),
56
- new GameModeCommand ()
57
- )
58
- .build();
106
+ public class ExampleMinestom {
107
+
108
+ public static void main (String [] args ) {
109
+ LiteMinestomFactory . builder()
110
+ .commands(
111
+ new FlyCommand (),
112
+ new GameModeCommand ()
113
+ )
114
+ .build();
115
+
116
+ // your code ...
117
+ }
118
+ }
119
+ ```
120
+ </tab >
121
+
122
+ <!-- Sponge -->
123
+ <tab title =" Sponge " >
124
+
125
+ ``` Java
126
+ @Plugin (" sponge-plugin" )
127
+ public class SpongePlugin {
128
+
129
+ @Inject
130
+ public SpongePlugin (PluginContainer pluginContainer , Game game ) {
131
+ LiteSpongeFactory . builder(pluginContainer, game)
132
+ .commands(
133
+ new TeleportCommand (),
134
+ new KickCommand ()
135
+ )
136
+ .build();
137
+
138
+ // your code ...
139
+ }
140
+ }
141
+ ```
142
+ </tab >
143
+
144
+ <!-- Fabric -->
145
+ <tab title =" Fabric " >
146
+
147
+ ``` Java
148
+ public class ExampleFabric implements ModInitializer {
149
+
150
+ @Override
151
+ public void onInitialize () {
152
+ LiteFabricFactory . create()
153
+ .commands(
154
+ new BanCommand (),
155
+ new MuteCommand ()
156
+ )
157
+ .build();
158
+
159
+ // your code ...
160
+ }
161
+ }
59
162
```
60
163
</tab >
61
164
62
165
<!-- JDA -->
63
166
<tab title =" JDA " >
64
167
65
168
``` Java
66
- JDA jda = JDABuilder . createDefault(" token" )
67
- .build();
68
-
69
- this . liteCommands = LiteJDAFactory . builder(jda)
70
- .commands(
71
- new EmbedCommand (),
72
- new MessageCommand ()
73
- )
74
- .build();
169
+ public class ExampleJDA {
170
+
171
+ public static void main (String [] args ) {
172
+ JDA jda = JDABuilder . createDefault(" token" )
173
+ .build();
174
+
175
+ LiteJDAFactory . builder(jda)
176
+ .commands(
177
+ new EmbedCommand (),
178
+ new MessageCommand ()
179
+ )
180
+ .build();
181
+
182
+ // your code ...
183
+ }
184
+ }
75
185
```
76
186
</tab >
77
187
0 commit comments