Skip to content

Commit 70fbef1

Browse files
committed
comments
1 parent 8abd039 commit 70fbef1

5 files changed

Lines changed: 30 additions & 22 deletions

File tree

.gitattributes

Lines changed: 16 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,16 @@
1-
#
2-
# https://help.github.com/articles/dealing-with-line-endings/
3-
#
4-
# Linux start script should use lf
5-
/gradlew text eol=lf
6-
7-
# These are Windows script files and should use crlf
8-
*.bat text eol=crlf
9-
10-
# Binary files should be left untouched
11-
*.jar binary
12-
1+
# Auto detect text files and perform LF normalization
2+
*.java text=auto eol=lf
3+
*.xml text=auto eol=lf
4+
*.json text=auto eol=lf
5+
*.md text=auto eol=lf
6+
*.yml text=auto eol=lf
7+
*.template text=auto eol=lf
8+
*.txt text=auto eol=lf
9+
*.bat text=auto eol=lf
10+
*.gradle text=auto eol=lf
11+
*.sh text=auto eol=lf
12+
*.html text=auto eol=lf
13+
*.settings text=auto eol=lf
14+
Jenkinsfile text=auto eol=lf
15+
gradlew test=auto eol=lf
16+
*.py text=auto eol=lf

src/main/java/org/example/ExampleConfig.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,11 @@
1010
* Fields to static inner classes generate nested JSON objects.
1111
*/
1212
public class ExampleConfig {
13-
public final ExampleModuleConfig moduleConfig = new ExampleModuleConfig();
13+
public boolean esp = false;
14+
15+
public final ExampleModuleConfig exampleModule = new ExampleModuleConfig();
1416
public static class ExampleModuleConfig {
1517
public boolean enabled = true;
1618
public int delayTicks = 250;
1719
}
18-
19-
public boolean esp = false;
2020
}

src/main/java/org/example/command/ExampleCommand.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -35,15 +35,15 @@ public CommandUsage commandUsage() {
3535
public LiteralArgumentBuilder<CommandContext> register() {
3636
return command("examplePlugin")
3737
.then(argument("toggle", toggle()).executes(c -> {
38-
PLUGIN_CONFIG.moduleConfig.enabled = getToggle(c, "toggle");
38+
PLUGIN_CONFIG.exampleModule.enabled = getToggle(c, "toggle");
3939
// make sure to sync so the module is actually toggled
4040
MODULE.get(ExampleModule.class).syncEnabledFromConfig();
4141
c.getSource().getEmbed()
42-
.title("Example Plugin " + toggleStrCaps(PLUGIN_CONFIG.moduleConfig.enabled));
42+
.title("Example Plugin " + toggleStrCaps(PLUGIN_CONFIG.exampleModule.enabled));
4343
return OK;
4444
}))
4545
.then(literal("delay").then(argument("ticks", integer(0)).executes(c -> {
46-
PLUGIN_CONFIG.moduleConfig.delayTicks = getInteger(c, "ticks");
46+
PLUGIN_CONFIG.exampleModule.delayTicks = getInteger(c, "ticks");
4747
c.getSource().getEmbed()
4848
.title("Delay Set");
4949
return OK;
@@ -54,7 +54,7 @@ public LiteralArgumentBuilder<CommandContext> register() {
5454
public void postPopulate(Embed embed) {
5555
embed
5656
.primaryColor()
57-
.addField("Enabled", toggleStr(PLUGIN_CONFIG.moduleConfig.enabled), false)
58-
.addField("Delay", PLUGIN_CONFIG.moduleConfig.delayTicks + " ticks", false);
57+
.addField("Enabled", toggleStr(PLUGIN_CONFIG.exampleModule.enabled), false)
58+
.addField("Delay", PLUGIN_CONFIG.exampleModule.delayTicks + " ticks", false);
5959
}
6060
}

src/main/java/org/example/module/ExampleESPModule.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -26,13 +26,17 @@ public PacketHandlerCodec registerServerPacketHandlerCodec() {
2626
.setId("esp")
2727
.setPriority(1000)
2828
.state(ProtocolState.GAME, PacketHandlerStateCodec.<ServerSession>builder()
29+
// packet classes can and will change between MC versions
30+
// if you want to have packet handlers you probably need separate plugin builds for each MC version
2931
.registerInbound(ClientboundSetEntityDataPacket.class, new GlowingEntityMetadataPacketHandler())
3032
// or with in-line lambda:
3133
// .registerOutbound(ClientboundSetEntityDataPacket.class, (ClientboundSetEntityDataPacket packet, ServerSession session) -> {
3234
// ClientboundSetEntityDataPacket p = packet;
3335
// ...more impl...
3436
// return p;
3537
// })
38+
// beware there are different PacketHandler interfaces that would be trickier to declare as a lambda
39+
// i.e. to handle client packets on the tick loop you need to implement ClientEventLoopPacketHandler
3640
.build())
3741
.build();
3842
}

src/main/java/org/example/module/ExampleModule.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ public class ExampleModule extends Module {
1616

1717
@Override
1818
public boolean enabledSetting() {
19-
return ExamplePlugin.PLUGIN_CONFIG.moduleConfig.enabled;
19+
return ExamplePlugin.PLUGIN_CONFIG.exampleModule.enabled;
2020
}
2121

2222
@Override
@@ -27,7 +27,7 @@ public List<EventConsumer<?>> registerEvents() {
2727
}
2828

2929
private void handleBotTick(ClientBotTick event) {
30-
if (timer.tick(ExamplePlugin.PLUGIN_CONFIG.moduleConfig.delayTicks)) {
30+
if (timer.tick(ExamplePlugin.PLUGIN_CONFIG.exampleModule.delayTicks)) {
3131
info("Hello from ExampleModule!");
3232
}
3333
}

0 commit comments

Comments
 (0)