fix gson type confusion bug

This commit is contained in:
nikky 2018-04-22 18:56:42 +02:00
parent f367690789
commit 928576c64b
7 changed files with 13 additions and 13 deletions

View File

@ -44,7 +44,7 @@ object BridgeCommandRegistry {
return if (help.isNotBlank()) help else "No help for '$cmd'"
}
fun getCommandList(permLvl: Int): String {
fun getCommandList(permLvl: Double): String {
return commandMap
.filterValues {
it.permLevel <= permLvl

View File

@ -10,7 +10,7 @@ data class CustomCommand(
val type: CommandType = CommandType.RESPONSE,
val execute: String = "",
val response: String = "",
override val permLevel: Int = 0,
override val permLevel: Double = 0.0,
override val help: String = "",
val allowArgs: Boolean = true,
val timeout: Int = 20

View File

@ -6,7 +6,7 @@ import matterlink.config.cfg
object HelpCommand : IBridgeCommand {
override val help: String = "Returns the help string for the given command. Syntax: help <command>"
override val permLevel = 0
override val permLevel = 0.0
override fun execute(alias: String, user: String, userId: String, server: String, args: String): Boolean {
val msg: String = when {
args.isEmpty() ->

View File

@ -4,7 +4,7 @@ import matterlink.config.PermissionConfig
interface IBridgeCommand {
val help: String
val permLevel: Int
val permLevel: Double
fun execute(alias: String, user: String, userId: String, server: String, args: String): Boolean
@ -15,9 +15,9 @@ interface IBridgeCommand {
fun validate() = true
companion object {
fun getPermLevel(userId: String, server: String): Int {
if (PermissionConfig.perms[server] == null) return 0
return PermissionConfig.perms[server]?.get(userId) ?: 0
fun getPermLevel(userId: String, server: String): Double {
val serverMap = PermissionConfig.perms[server] ?: return 0.0
return serverMap[userId] ?: 0.0
}
}
}

View File

@ -37,7 +37,7 @@ object CommandConfig {
),
"uptime" to CustomCommand(
type = CommandType.RESPONSE,
permLevel = 1,
permLevel = 1.0,
response = "{uptime}",
help = "Print server uptime",
allowArgs = false

View File

@ -8,7 +8,7 @@ import matterlink.instance
import matterlink.stackTraceString
import java.io.File
typealias PermissionMap = Map<String, Map<String, Int>>
typealias PermissionMap = Map<String, Map<String, Double>>
object PermissionConfig {
private val gson: Gson = GsonBuilder().setPrettyPrinting().create()
@ -16,11 +16,11 @@ object PermissionConfig {
private val default = mapOf(
"irc.esper" to mapOf(
"~nikky@nikky.moe" to 0,
"user@example." to 0
"~nikky@nikky.moe" to 0.0,
"user@example." to 0.0
),
"discord.game" to mapOf(
"112228624366575616" to 0
"112228624366575616" to 0.0
)
)

View File

@ -1,5 +1,5 @@
mod_name = MatterLink
mod_version = 1.5.4
mod_version = 1.5.5
forgelin_version = 1.6.0
curse_id = 287323
curse_release_type = beta