Simplify first join config
This commit is contained in:
parent
0f573d50e4
commit
d22d55902d
|
@ -21,12 +21,10 @@ package com.discordsrv.common.config.main.channels;
|
|||
import com.discordsrv.api.discord.entity.message.DiscordMessageEmbed;
|
||||
import com.discordsrv.api.discord.entity.message.SendableDiscordMessage;
|
||||
import com.discordsrv.api.event.events.message.receive.game.JoinMessageReceiveEvent;
|
||||
import com.discordsrv.common.config.configurate.annotation.Constants;
|
||||
import com.discordsrv.common.config.configurate.annotation.Untranslated;
|
||||
import com.discordsrv.common.config.main.generic.IMessageConfig;
|
||||
import org.jetbrains.annotations.Nullable;
|
||||
import org.spongepowered.configurate.objectmapping.ConfigSerializable;
|
||||
import org.spongepowered.configurate.objectmapping.meta.Comment;
|
||||
|
||||
@ConfigSerializable
|
||||
public class JoinMessageConfig implements IMessageConfig {
|
||||
|
@ -59,28 +57,14 @@ public class JoinMessageConfig implements IMessageConfig {
|
|||
}
|
||||
|
||||
public final IMessageConfig getForEvent(JoinMessageReceiveEvent event) {
|
||||
FirstJoin firstJoin;
|
||||
if (event.isFirstJoin() && (firstJoin = firstJoin()) != null && !firstJoin.isRegular()) {
|
||||
return firstJoin;
|
||||
}
|
||||
return this;
|
||||
FirstJoin firstJoin = firstJoin();
|
||||
return firstJoin != null && event.isFirstJoin() ? firstJoin : this;
|
||||
}
|
||||
|
||||
@ConfigSerializable
|
||||
public static class FirstJoin implements IMessageConfig {
|
||||
|
||||
@Comment("How first join should behave:\n"
|
||||
+ "- %1 (uses the format below)\n"
|
||||
+ "- %2 (first join messages are disabled)\n"
|
||||
+ "- %3 (uses the format above)")
|
||||
@Constants.Comment({"enabled", "disabled", "use_regular"})
|
||||
public Preference preference = Preference.ENABLED;
|
||||
|
||||
public enum Preference {
|
||||
ENABLED,
|
||||
DISABLED,
|
||||
USE_REGULAR
|
||||
}
|
||||
public boolean enabled = true;
|
||||
|
||||
@Untranslated(Untranslated.Type.VALUE)
|
||||
public SendableDiscordMessage.Builder format = SendableDiscordMessage.builder()
|
||||
|
@ -91,13 +75,9 @@ public class JoinMessageConfig implements IMessageConfig {
|
|||
.build()
|
||||
);
|
||||
|
||||
public boolean isRegular() {
|
||||
return preference == Preference.USE_REGULAR;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean enabled() {
|
||||
return preference == Preference.ENABLED;
|
||||
return enabled;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
Loading…
Reference in New Issue