Skip to content

Commit

Permalink
Fix CNF error
Browse files Browse the repository at this point in the history
  • Loading branch information
PotatoPresident committed Dec 23, 2022
1 parent 1c31444 commit 4a09a4d
Show file tree
Hide file tree
Showing 5 changed files with 16 additions and 8 deletions.
4 changes: 3 additions & 1 deletion build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,6 @@ allprojects {

// Optional deps
modRuntimeOnly(rootProject.libs.permission.api)
modImplementation(rootProject.libs.vanish.api)
}

// Produce a sources distribution
Expand Down Expand Up @@ -110,6 +109,9 @@ dependencies {
shadow(libs.konf.base)
shadow(libs.konf.toml)

// Optional deps
modCompileOnly(rootProject.libs.vanish.api)

subprojects.forEach {
implementation(project(":${it.name}", "namedElements"))
include(project("${it.name}:")) // nest within distribution
Expand Down
2 changes: 1 addition & 1 deletion libs.versions.toml
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@ adventure-gson = "4.11.0"

placeholder-api = "2.0.0-pre.2+1.19.3"
permission-api = "0.2-SNAPSHOT"
vanish-api = "1.0.2"
vanish-api = "1.3.0"
konf = "1.1.2"

[libraries]
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@ package io.github.quiltservertools.blockbotdiscord.config

import com.uchuhimo.konf.Config
import com.uchuhimo.konf.ConfigSpec
import dev.kord.common.entity.ActivityType
import eu.pb4.placeholders.api.PlaceholderContext
import eu.pb4.placeholders.api.Placeholders
import eu.pb4.placeholders.api.TextParserUtils
Expand All @@ -13,6 +12,14 @@ object PresenceSpec : ConfigSpec() {
val activityText by required<String>()
}

enum class ActivityType {
Disabled,
Game,
Listening,
Watching,
Competing;
}

fun Config.formatPresenceText(
server: MinecraftServer
): String = Placeholders.parseText(
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,6 @@ import com.kotlindiscord.kord.extensions.utils.ensureWebhook
import com.kotlindiscord.kord.extensions.utils.getTopRole
import com.kotlindiscord.kord.extensions.utils.hasPermission
import com.vdurmont.emoji.EmojiParser
import dev.kord.common.entity.ActivityType
import dev.kord.common.entity.AllowedMentionType
import dev.kord.common.entity.Permission
import dev.kord.common.entity.Snowflake
Expand Down Expand Up @@ -125,8 +124,8 @@ class BlockBotApiExtension : Extension(), Bot {
// Vanish fake join/leave messages
if (FabricLoader.getInstance().isModLoaded("melius-vanish")) {
VanishEvents.VANISH_EVENT.register {player, vanished ->
if (vanished) sendPlayerLeaveMessage(player);
else sendPlayerJoinMessage(player);
if (vanished) sendPlayerLeaveMessage(player)
else sendPlayerJoinMessage(player)
}
}

Expand Down Expand Up @@ -405,7 +404,7 @@ class BlockBotApiExtension : Extension(), Bot {
ActivityType.Listening -> listening(config.formatPresenceText(server))
ActivityType.Watching -> watching(config.formatPresenceText(server))
ActivityType.Competing -> competing(config.formatPresenceText(server))
else -> Unit
ActivityType.Disabled -> Unit
}
}
}
Expand Down
2 changes: 1 addition & 1 deletion src/main/resources/blockbot-discord.toml
Original file line number Diff line number Diff line change
Expand Up @@ -93,7 +93,7 @@ allowedRoles = []
opLevel = 3

[Presence]
# The type of presence. Can be "Game", "Listening", "Watching", "Competing"
# The type of presence. Can be "Game", "Listening", "Watching", "Competing", "Disabled"
# Updates every 400 ticks (20 seconds)
activityType = "Game"
activityText = "Minecraft | %server:online%/%server:max_players%"
Expand Down

0 comments on commit 4a09a4d

Please sign in to comment.