Skip to content
This repository was archived by the owner on Oct 2, 2024. It is now read-only.

Commit 0b8d32e

Browse files
committed
Update builder configuration section
1 parent f8a2bbb commit 0b8d32e

File tree

2 files changed

+151
-42
lines changed

2 files changed

+151
-42
lines changed

Writerside/litecommands.tree

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -5,16 +5,11 @@
55
<instance-profile id="litecommands"
66
name="LiteCommands"
77
start-page="Introdution.md">
8-
<toc-element toc-title="Introduction">
9-
<toc-element topic="Introdution.md">
10-
</toc-element>
11-
<toc-element topic="Features-of-LiteCommands.topic"/>
12-
</toc-element>
13-
<toc-element topic="IntelliJ-IDEA-Plugin.md"/>
148
<toc-element toc-title="Getting Started">
159
<toc-element topic="Dependency.md"/>
1610
<toc-element topic="Parameters-compile-flag.md"/>
1711
</toc-element>
12+
<toc-element topic="IntelliJ-IDEA-Plugin.md"/>
1813
<toc-element topic="Platforms.md">
1914
<toc-element topic="SENDER.md"/>
2015
</toc-element>
@@ -43,4 +38,8 @@
4338
<toc-element topic="adventure-platform.md"/>
4439
<toc-element topic="Adventure-Usage.md"/>
4540
</toc-element>
41+
<toc-element toc-title="Introduction">
42+
<toc-element topic="Introdution.md"/>
43+
<toc-element topic="Features-of-LiteCommands.topic"/>
44+
</toc-element>
4645
</instance-profile>

Writerside/topics/Configuration.md

Lines changed: 146 additions & 36 deletions
Original file line numberDiff line numberDiff line change
@@ -7,71 +7,181 @@ Create a new instance of `LiteCommands` using specific factory for your platform
77
<!-- Bukkit -->
88
<tab title="Bukkit">
99

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+
1015
```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+
}
1738
```
39+
1840
</tab>
1941

2042
<!-- Velocity -->
2143
<tab title="Velocity">
2244

2345
```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+
}
3074
```
75+
3176
</tab>
3277

3378
<!-- BungeeCord -->
3479
<tab title="BungeeCord">
3580

3681
```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+
4399
```
44100
</tab>
45101

46102
<!-- Minestom -->
47103
<tab title="Minestom">
48104

49105
```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+
}
59162
```
60163
</tab>
61164

62165
<!-- JDA -->
63166
<tab title="JDA">
64167

65168
```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+
}
75185
```
76186
</tab>
77187

0 commit comments

Comments
 (0)