Skip to content

Commit b69eb04

Browse files
authored
GH-1082 Move the config sections into dedicated classes. Improve parent comments of sections. (#1083)
* GH-1082 Move the config sections into dedicated classes. Improve `parent` comments of sections. * Follow gemini code assistant review. * Follow @CitralFlo feedback. * Fix spelling.
1 parent deaed4d commit b69eb04

File tree

14 files changed

+387
-290
lines changed

14 files changed

+387
-290
lines changed

eternalcore-core/src/main/java/com/eternalcode/core/configuration/implementation/PluginConfiguration.java

Lines changed: 105 additions & 285 deletions
Large diffs are not rendered by default.
Lines changed: 43 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,43 @@
1+
package com.eternalcode.core.feature.afk;
2+
3+
import eu.okaeri.configs.OkaeriConfig;
4+
import eu.okaeri.configs.annotation.Comment;
5+
import java.time.Duration;
6+
import lombok.Getter;
7+
import lombok.experimental.Accessors;
8+
9+
@Getter
10+
@Accessors(fluent = true)
11+
public class AfkConfig extends OkaeriConfig implements AfkSettings {
12+
@Comment({
13+
"# Number of interactions a player must make to have AFK status removed",
14+
"# This is for so that stupid miss-click doesn't disable AFK status"
15+
})
16+
public int interactionsCountDisableAfk = 20;
17+
18+
@Comment("# Time before using the /afk command again")
19+
public Duration afkCommandDelay = Duration.ofSeconds(60);
20+
21+
@Comment({
22+
"# Should a player be marked as AFK automatically?",
23+
"# If set to true, the player will be marked as AFK after a certain amount of time of inactivity",
24+
"# If set to false, the player will have to use the /afk command to be marked as AFK"
25+
})
26+
public boolean autoAfk = true;
27+
28+
@Comment("# The amount of time a player must be inactive to be marked as AFK")
29+
public Duration afkInactivityTime = Duration.ofMinutes(10);
30+
31+
@Comment("# Should a player be kicked from the game when marked as AFK?")
32+
public boolean kickOnAfk = false;
33+
34+
@Override
35+
public Duration getAfkDelay() {
36+
return this.afkCommandDelay;
37+
}
38+
39+
@Override
40+
public Duration getAfkInactivityTime() {
41+
return this.afkInactivityTime;
42+
}
43+
}
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,23 @@
1+
package com.eternalcode.core.feature.automessage;
2+
3+
import eu.okaeri.configs.OkaeriConfig;
4+
import eu.okaeri.configs.annotation.Comment;
5+
import java.time.Duration;
6+
import lombok.Getter;
7+
import lombok.experimental.Accessors;
8+
9+
@Getter
10+
@Accessors(fluent = true)
11+
public class AutoMessageConfig extends OkaeriConfig implements AutoMessageSettings {
12+
@Comment("# AutoMessage should be enabled?")
13+
public boolean enabled = true;
14+
15+
@Comment("# Interval between messages")
16+
public Duration interval = Duration.ofSeconds(60);
17+
18+
@Comment("# Draw mode (RANDOM, SEQUENTIAL)")
19+
public DrawMode drawMode = DrawMode.RANDOM;
20+
21+
@Comment("# Minimum number of players on the server to send an auto message.")
22+
public int minPlayers = 1;
23+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
package com.eternalcode.core.feature.butcher;
2+
3+
import eu.okaeri.configs.OkaeriConfig;
4+
import eu.okaeri.configs.annotation.Comment;
5+
import lombok.Getter;
6+
import lombok.experimental.Accessors;
7+
8+
@Getter
9+
@Accessors(fluent = true)
10+
public class ButcherConfig extends OkaeriConfig {
11+
@Comment("# Safe number of chunks for command execution (above this number it will not be possible to execute the command)")
12+
public int safeChunkNumber = 5;
13+
}
Lines changed: 44 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,44 @@
1+
package com.eternalcode.core.feature.chat;
2+
3+
import eu.okaeri.configs.OkaeriConfig;
4+
import eu.okaeri.configs.annotation.Comment;
5+
import java.time.Duration;
6+
import lombok.Getter;
7+
import lombok.experimental.Accessors;
8+
9+
@Getter
10+
@Accessors(fluent = true)
11+
public class ChatConfig extends OkaeriConfig implements ChatSettings {
12+
13+
@Comment("# Custom message for unknown command")
14+
public boolean replaceStandardHelpMessage = false;
15+
16+
@Comment("# Chat delay to send next message in chat")
17+
public Duration chatDelay = Duration.ofSeconds(5);
18+
19+
@Comment("# Number of lines that will be cleared when using the /chat clear command")
20+
public int linesToClear = 256;
21+
22+
@Comment("# Chat should be enabled?")
23+
public boolean chatEnabled = true;
24+
25+
@Override
26+
public boolean isChatEnabled() {
27+
return this.chatEnabled;
28+
}
29+
30+
@Override
31+
public void setChatEnabled(boolean chatEnabled) {
32+
this.chatEnabled = chatEnabled;
33+
}
34+
35+
@Override
36+
public Duration getChatDelay() {
37+
return this.chatDelay;
38+
}
39+
40+
@Override
41+
public void setChatDelay(Duration chatDelay) {
42+
this.chatDelay = chatDelay;
43+
}
44+
}
Lines changed: 20 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,20 @@
1+
package com.eternalcode.core.feature.helpop;
2+
3+
import eu.okaeri.configs.OkaeriConfig;
4+
import eu.okaeri.configs.annotation.Comment;
5+
import java.time.Duration;
6+
import lombok.Getter;
7+
import lombok.experimental.Accessors;
8+
9+
@Getter
10+
@Accessors(fluent = true)
11+
public class HelpOpConfig extends OkaeriConfig implements HelpOpSettings {
12+
13+
@Comment("# Delay to send the next message under /helpop")
14+
public Duration helpOpDelay = Duration.ofSeconds(60);
15+
16+
@Override
17+
public Duration getHelpOpDelay() {
18+
return this.helpOpDelay;
19+
}
20+
}
Lines changed: 28 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,28 @@
1+
package com.eternalcode.core.feature.home;
2+
3+
import eu.okaeri.configs.OkaeriConfig;
4+
import eu.okaeri.configs.annotation.Comment;
5+
import java.time.Duration;
6+
import java.util.LinkedHashMap;
7+
import java.util.Map;
8+
import lombok.Getter;
9+
import lombok.experimental.Accessors;
10+
11+
@Getter
12+
@Accessors(fluent = true)
13+
public class HomesConfig extends OkaeriConfig {
14+
@Comment("# Default home name")
15+
public String defaultHomeName = "home";
16+
17+
@Comment("# Time of teleportation to homes")
18+
public Duration teleportTimeToHomes = Duration.ofSeconds(5);
19+
20+
@Comment("# Max homes per permission")
21+
public Map<String, Integer> maxHomes = new LinkedHashMap<>() {
22+
{
23+
put("eternalcore.home.default", 1);
24+
put("eternalcore.home.vip", 2);
25+
put("eternalcore.home.premium", 3);
26+
}
27+
};
28+
}

eternalcore-core/src/main/java/com/eternalcode/core/feature/home/command/HomeCommand.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
package com.eternalcode.core.feature.home.command;
22

33
import com.eternalcode.annotations.scan.command.DescriptionDocs;
4-
import com.eternalcode.core.configuration.implementation.PluginConfiguration;
4+
import com.eternalcode.core.feature.home.HomesConfig;
55
import com.eternalcode.core.feature.home.Home;
66
import com.eternalcode.core.feature.home.HomeService;
77
import com.eternalcode.core.feature.home.HomeTeleportService;
@@ -21,14 +21,14 @@
2121
@Permission("eternalcore.home")
2222
class HomeCommand {
2323

24-
private final PluginConfiguration.Homes homesConfig;
24+
private final HomesConfig homesConfig;
2525
private final NoticeService noticeService;
2626
private final HomeService homeService;
2727
private final HomeTeleportService homeTeleportService;
2828

2929
@Inject
3030
HomeCommand(
31-
PluginConfiguration.Homes homesConfig,
31+
HomesConfig homesConfig,
3232
NoticeService noticeService,
3333
HomeService homeService,
3434
HomeTeleportService homeTeleportService
Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
package com.eternalcode.core.feature.jail;
2+
3+
import eu.okaeri.configs.OkaeriConfig;
4+
import eu.okaeri.configs.annotation.Comment;
5+
import java.time.Duration;
6+
import java.util.Set;
7+
import lombok.Getter;
8+
import lombok.experimental.Accessors;
9+
10+
@Getter
11+
@Accessors(fluent = true)
12+
public class JailConfig extends OkaeriConfig implements JailSettings {
13+
14+
@Comment("# Default jail duration, set if no duration is specified")
15+
public Duration defaultJailDuration = Duration.ofMinutes(30);
16+
17+
@Comment("# Allowed commands in jail")
18+
public Set<String> allowedCommands = Set.of("help", "msg", "r", "tell", "me", "helpop");
19+
}

eternalcore-core/src/main/java/com/eternalcode/core/feature/lightning/LightningConfig.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -8,10 +8,10 @@
88
@Getter
99
@Accessors(fluent = true)
1010
public class LightningConfig extends OkaeriConfig implements LightningSettings {
11-
@Comment({" ", "# Maximum distance for the lightning strike block when using /lightning."})
11+
@Comment("# Maximum distance for the lightning strike block when using /lightning.")
1212
@Comment("# If you will look at a block that is further than this distance, the lightning will strike at the player.")
1313
public int maxLightningBlockDistance = 100;
1414

15-
@Comment({" ", "# If there is no block in the range of lightning strike, should the lightning strike the player?"})
15+
@Comment("# If there is no block in the range of lightning strike, should the lightning strike the player?")
1616
public boolean lightningStrikePlayerIfNoBlock = true;
1717
}

0 commit comments

Comments
 (0)