Skip to content

Commit b6b71e1

Browse files
committed
Add confessions to setup wizard, fix more mojibake and dead config
Setup wizard: - Add 'confessions' module to the MODULES map so admins can configure the /confess channel via /setup (was only editable in config.yml). Mojibake (double-encoded UTF-8) in SlashCommandManager: - /seen embed author: '·' -> '·' (U+00B7) - /confess footer: '·' -> '·' (U+00B7) Startup banner: - 'Modules: x/15' was wrong - only 13 modules exist. Introduce TOTAL_MODULES constant (13) with a comment tying it to countActiveModules and the module fields. Dead/misleading config (bump config-version 4 -> 5): - Remove leaderboard.tracked-stats and leaderboard.top-count - neither is read anywhere (stats are hardcoded; only per-page is used). - Wire up api.enabled - it existed in config but the API service was registered unconditionally. Now honoured in onEnable. - Fix reaction-roles comment that referenced a non-existent /zdiscord reactionrole subcommand.
1 parent 7b818b0 commit b6b71e1

6 files changed

Lines changed: 25 additions & 17 deletions

File tree

src/main/java/dev/demonz/zdiscord/ZDiscord.java

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -110,12 +110,14 @@ public void onEnable() {
110110
registerCommands();
111111

112112

113-
ZDiscordProvider.register(new ZDiscordAPIImpl(this));
114-
getServer().getServicesManager().register(
115-
dev.demonz.zdiscord.api.ZDiscordAPI.class,
116-
ZDiscordProvider.get(),
117-
this,
118-
org.bukkit.plugin.ServicePriority.Normal);
113+
if (configManager.getBoolean("api.enabled", true)) {
114+
ZDiscordProvider.register(new ZDiscordAPIImpl(this));
115+
getServer().getServicesManager().register(
116+
dev.demonz.zdiscord.api.ZDiscordAPI.class,
117+
ZDiscordProvider.get(),
118+
this,
119+
org.bukkit.plugin.ServicePriority.Normal);
120+
}
119121

120122
if (configManager.getBoolean("misc.update-checker", true)) {
121123
new UpdateChecker(this);

src/main/java/dev/demonz/zdiscord/config/ConfigManager.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,7 @@
1818
public class ConfigManager {
1919

2020

21-
public static final int CURRENT_VERSION = 4;
21+
public static final int CURRENT_VERSION = 5;
2222

2323
private final File dataFolder;
2424
private final Logger logger;

src/main/java/dev/demonz/zdiscord/discord/SetupCommand.java

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,8 @@ public class SetupCommand extends ListenerAdapter {
7979
"TPS and memory alerts when thresholds are exceeded."));
8080
MODULES.put("achievements", new ModuleInfo("Achievements", "channels.achievements",
8181
"Player advancement announcements."));
82+
MODULES.put("confessions", new ModuleInfo("Confessions", "channels.confessions",
83+
"Anonymous confessions via /confess."));
8284
}
8385

8486
private static final List<String> MODULE_NAMES = new ArrayList<>(MODULES.keySet());

src/main/java/dev/demonz/zdiscord/discord/SlashCommandManager.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -363,7 +363,7 @@ private void handleSeen(SlashCommandInteractionEvent event) {
363363
: 0L;
364364

365365
EmbedBuilder embed = new EmbedBuilder()
366-
.setAuthor(name + " · Last seen",
366+
.setAuthor(name + " \u00B7 Last seen",
367367
"https://namemc.com/profile/" + uuid,
368368
HeadUtil.avatar(uuid, HeadUtil.SIZE_SMALL))
369369
.setColor(ColorUtil.parseHex("#3498DB"))
@@ -530,7 +530,7 @@ private void handleConfess(SlashCommandInteractionEvent event) {
530530
.setAuthor(":love_letter: A new confession", null, null)
531531
.setDescription(ColorUtil.toDiscordMarkdown(message))
532532
.setColor(ColorUtil.parseHex(colorHex))
533-
.setFooter(handle + " · posted at", null)
533+
.setFooter(handle + " \u00B7 posted at", null)
534534
.setTimestamp(Instant.now());
535535

536536
channel.sendMessageEmbeds(embed.build()).queue(

src/main/java/dev/demonz/zdiscord/util/StartupBanner.java

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,13 @@ public final class StartupBanner {
88

99
private static final int BOX_WIDTH = 46;
1010

11+
/**
12+
* Total number of toggleable modules. Must match the number of module
13+
* getters checked in {@link #countActiveModules(ZDiscord)} and the module
14+
* fields declared on {@link ZDiscord}. Keep these three in sync.
15+
*/
16+
private static final int TOTAL_MODULES = 13;
17+
1118
private StartupBanner() {
1219
}
1320

@@ -37,7 +44,7 @@ public static void print(ZDiscord plugin, long startupMs) {
3744
log.info(pad(" ZDiscord v" + version));
3845
log.info(pad(" Platform: " + platform));
3946
log.info(pad(" Bot: " + botName + " \u2022 Guild: " + truncate(guildName, 20)));
40-
log.info(pad(" Modules: " + activeModules + "/15 \u2022 Storage: " + storage));
47+
log.info(pad(" Modules: " + activeModules + "/" + TOTAL_MODULES + " \u2022 Storage: " + storage));
4148
log.info(pad(" Startup: " + startupMs + "ms"));
4249
log.info("\u255A" + "\u2550".repeat(BOX_WIDTH) + "\u255D");
4350
log.info("");

src/main/resources/config.yml

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
config-version: 4
1+
config-version: 5
22

33
storage:
44
# yaml = flatfile. mysql = requires a MySQL server running.
@@ -94,11 +94,7 @@ status:
9494
# can be viewed with /leaderboard on Discord.
9595
leaderboard:
9696
enabled: true
97-
tracked-stats:
98-
- KILLS
99-
- DEATHS
100-
- PLAYTIME
101-
top-count: 10
97+
# Number of entries shown per leaderboard page.
10298
per-page: 10
10399
panel-channel: ""
104100
panel-update-interval: 120
@@ -183,7 +179,8 @@ performance:
183179

184180
reaction-roles:
185181
enabled: true
186-
# Add mappings via /zdiscord reactionrole. See wiki for setup.
182+
# Add mappings to the `mappings` list below.
183+
# Each mapping: message-id, emoji, role-id, and (optional) minecraft permission.
187184
mappings: []
188185

189186
misc:

0 commit comments

Comments
 (0)