Some minor config comment improvements

This commit is contained in:
Vankka 2022-04-14 10:55:01 +03:00
parent 2a11718ae8
commit a8944309c8
No known key found for this signature in database
GPG Key ID: 6E50CB7A29B96AD0
5 changed files with 13 additions and 13 deletions

View File

@ -28,7 +28,7 @@ import java.util.List;
import java.util.Optional;
@ConfigSerializable
public class DiscordIgnores {
public class DiscordIgnoresConfig {
@Comment("User, bot and webhook ids to ignore")
public IDs usersAndWebhookIds = new IDs();
@ -39,7 +39,7 @@ public class DiscordIgnores {
@Comment("If bots (webhooks not included) should be ignored")
public boolean bots = false;
@Comment("If webhooks should be ignored")
@Comment("If webhooks should be ignored (webhook messages sent by this DiscordSRV instance will always be ignored)")
public boolean webhooks = true;
@ConfigSerializable
@ -58,12 +58,12 @@ public class DiscordIgnores {
return true;
}
DiscordIgnores.IDs users = usersAndWebhookIds;
DiscordIgnoresConfig.IDs users = usersAndWebhookIds;
if (users != null && users.ids.contains(author.getId()) != users.whitelist) {
return true;
}
DiscordIgnores.IDs roles = roleIds;
DiscordIgnoresConfig.IDs roles = roleIds;
return roles != null && Optional.ofNullable(member)
.map(m -> m.getRoles().stream().anyMatch(role -> roles.ids.contains(role.getId())))
.map(hasRole -> hasRole != roles.whitelist)

View File

@ -19,7 +19,7 @@
package com.discordsrv.common.config.main.channels;
import com.discordsrv.common.config.annotation.Untranslated;
import com.discordsrv.common.config.main.DiscordIgnores;
import com.discordsrv.common.config.main.DiscordIgnoresConfig;
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.meta.Comment;
@ -51,7 +51,7 @@ public class DiscordToMinecraftChatConfig {
public Map<Pattern, String> contentRegexFilters = new LinkedHashMap<>();
@Comment("Users, bots and webhooks to ignore")
public DiscordIgnores ignores = new DiscordIgnores();
public DiscordIgnoresConfig ignores = new DiscordIgnoresConfig();
@Comment("The representations of Discord mentions in-game")
public Mentions mentions = new Mentions();

View File

@ -18,7 +18,7 @@
package com.discordsrv.common.config.main.channels;
import com.discordsrv.common.config.main.DiscordIgnores;
import com.discordsrv.common.config.main.DiscordIgnoresConfig;
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
import org.spongepowered.configurate.objectmapping.meta.Comment;
@ -28,10 +28,10 @@ public class MirroringConfig {
public boolean enabled = true;
@Comment("Users, bots and webhooks to ignore when mirroring")
public DiscordIgnores ignores = new DiscordIgnores();
public DiscordIgnoresConfig ignores = new DiscordIgnoresConfig();
@Comment("The format of the username of mirrored messages\n"
+ "It's recommended to include some special character if in-game messages use webhooks,\n"
+ "in order to prevent Discord users and in-game players being grouped together")
+ "in order to prevent Discord users and in-game players with the same name being grouped together")
public String usernameFormat = "%user_effective_name% \uD83D\uDD03";
}

View File

@ -32,7 +32,7 @@ import com.discordsrv.api.placeholder.util.Placeholders;
import com.discordsrv.common.DiscordSRV;
import com.discordsrv.common.component.renderer.DiscordSRVMinecraftRenderer;
import com.discordsrv.common.component.util.ComponentUtil;
import com.discordsrv.common.config.main.DiscordIgnores;
import com.discordsrv.common.config.main.DiscordIgnoresConfig;
import com.discordsrv.common.config.main.channels.DiscordToMinecraftChatConfig;
import com.discordsrv.common.config.main.channels.base.BaseChannelConfig;
import com.discordsrv.common.function.OrDefault;
@ -87,7 +87,7 @@ public class DiscordChatMessageModule extends AbstractModule<DiscordSRV> {
DiscordGuildMember member = discordMessage.getMember().orElse(null);
boolean webhookMessage = discordMessage.isWebhookMessage();
DiscordIgnores ignores = chatConfig.get(cfg -> cfg.ignores);
DiscordIgnoresConfig ignores = chatConfig.get(cfg -> cfg.ignores);
if (ignores != null && ignores.shouldBeIgnored(webhookMessage, author, member)) {
// TODO: response for humans
return;

View File

@ -32,7 +32,7 @@ import com.discordsrv.api.discord.events.message.DiscordMessageUpdateEvent;
import com.discordsrv.api.event.bus.Subscribe;
import com.discordsrv.api.event.events.message.receive.discord.DiscordChatMessageProcessingEvent;
import com.discordsrv.common.DiscordSRV;
import com.discordsrv.common.config.main.DiscordIgnores;
import com.discordsrv.common.config.main.DiscordIgnoresConfig;
import com.discordsrv.common.config.main.channels.MirroringConfig;
import com.discordsrv.common.config.main.channels.base.BaseChannelConfig;
import com.discordsrv.common.config.main.channels.base.IChannelConfig;
@ -83,7 +83,7 @@ public class DiscordMessageMirroringModule extends AbstractModule<DiscordSRV> {
continue;
}
DiscordIgnores ignores = config.get(cfg -> cfg.ignores);
DiscordIgnoresConfig ignores = config.get(cfg -> cfg.ignores);
if (ignores != null && ignores.shouldBeIgnored(message.isWebhookMessage(), message.getAuthor(), message.getMember().orElse(null))) {
continue;
}