Skip to content

Commit

Permalink
Update version to 3.1.0
Browse files Browse the repository at this point in the history
Modified:
- Reorganized BotControllerManager to be a little more navigable
- Minor syntax tweaks taking advantage of new Kotlin syntax
- Added 'private' and removed some explicit type declarations so
  IDEA would make the squiggly lines go away
  • Loading branch information
DiamondIceNS committed Dec 15, 2017
1 parent 582f754 commit ad69465
Show file tree
Hide file tree
Showing 9 changed files with 170 additions and 152 deletions.
2 changes: 1 addition & 1 deletion build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,7 @@ plugins {
apply plugin: 'kotlin'

group = 'gg.obsidian'
version = '3.1.0-dev1'
version = '3.1.0'
description = """Bridge chat between Minecraft and Discord"""
ext.url = 'https://github.com/the-obsidian/DiscordBridge'

Expand Down
26 changes: 13 additions & 13 deletions src/main/kotlin/gg/obsidian/discordbridge/Plugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -136,7 +136,7 @@ class Plugin : JavaPlugin() {
/**
* Saves all default configs where configs do not exist and reloads data from file into memory
*/
fun updateConfig(version: String) {
private fun updateConfig(version: String) {
this.saveDefaultConfig()
config.options().copyDefaults(true)
config.set("version", version)
Expand Down Expand Up @@ -182,7 +182,7 @@ class Plugin : JavaPlugin() {
val users = Connection.listUsers()
val found: Member = users.find { it.user.name + "#" + it.user.discriminator == discriminator } ?: return null

val ua: UserAlias = UserAlias(player.uniqueId, found.user.id)
val ua = UserAlias(player.uniqueId, found.user.id)
requests.add(ua)
val msg = "Minecraft user '${server.getOfflinePlayer(ua.mcUuid).name}' has requested to become associated with your Discord" +
" account. If this is you, respond '${Connection.JDA.selfUser.asMention} confirm'. If this is not" +
Expand All @@ -203,8 +203,8 @@ class Plugin : JavaPlugin() {

var response = "${CC.YELLOW}Discord users:"
for (user in users) {
if (user.user.isBot) response += "\n${CC.GOLD}- ${user.effectiveName} (Bot) | ${user.user.name}#${user.user.discriminator}${CC.RESET}"
else response += "\n${CC.YELLOW}- ${user.effectiveName} | ${user.user.name}#${user.user.discriminator}${CC.RESET}"
response += if (user.user.isBot) "\n${CC.GOLD}- ${user.effectiveName} (Bot) | ${user.user.name}#${user.user.discriminator}${CC.RESET}"
else "\n${CC.YELLOW}- ${user.effectiveName} | ${user.user.name}#${user.user.discriminator}${CC.RESET}"
}
return response.trim()
}
Expand All @@ -218,25 +218,25 @@ class Plugin : JavaPlugin() {
return "${CC.YELLOW}No Discord members could be found. Either server is empty or an error has occurred."

var response = ""
if (onlineUsers.filter { it.onlineStatus == OnlineStatus.ONLINE }.isNotEmpty()) {
if (onlineUsers.any { it.onlineStatus == OnlineStatus.ONLINE }) {
response += "\n${CC.DARK_GREEN}Online:${CC.RESET}"
for (user in onlineUsers.filter { it.onlineStatus == OnlineStatus.ONLINE }) {
if (user.user.isBot) response += "\n${CC.DARK_GREEN}- ${user.effectiveName} (Bot)${CC.RESET}"
else response += "\n${CC.DARK_GREEN}- ${user.effectiveName}${CC.RESET}"
response += if (user.user.isBot) "\n${CC.DARK_GREEN}- ${user.effectiveName} (Bot)${CC.RESET}"
else "\n${CC.DARK_GREEN}- ${user.effectiveName}${CC.RESET}"
}
}
if (onlineUsers.filter { it.onlineStatus == OnlineStatus.IDLE }.isNotEmpty()) {
if (onlineUsers.any { it.onlineStatus == OnlineStatus.IDLE }) {
response += "\n${CC.YELLOW}Idle:${CC.RESET}"
for (user in onlineUsers.filter { it.onlineStatus == OnlineStatus.IDLE }) {
if (user.user.isBot) response += "\n${CC.YELLOW}- ${user.effectiveName} (Bot)${CC.RESET}"
else response += "\n${CC.YELLOW}- ${user.effectiveName}${CC.RESET}"
response += if (user.user.isBot) "\n${CC.YELLOW}- ${user.effectiveName} (Bot)${CC.RESET}"
else "\n${CC.YELLOW}- ${user.effectiveName}${CC.RESET}"
}
}
if (onlineUsers.filter { it.onlineStatus == OnlineStatus.DO_NOT_DISTURB }.isNotEmpty()) {
if (onlineUsers.any { it.onlineStatus == OnlineStatus.DO_NOT_DISTURB }) {
response += "\n${CC.RED}Do Not Disturb:${CC.RESET}"
for (user in onlineUsers.filter { it.onlineStatus == OnlineStatus.DO_NOT_DISTURB }) {
if (user.user.isBot) response += "\n${CC.RED}- ${user.effectiveName} (Bot)${CC.RESET}"
else response += "\n${CC.RED}- ${user.effectiveName}${CC.RESET}"
response += if (user.user.isBot) "\n${CC.RED}- ${user.effectiveName} (Bot)${CC.RESET}"
else "\n${CC.RED}- ${user.effectiveName}${CC.RESET}"
}
}

Expand Down
4 changes: 2 additions & 2 deletions src/main/kotlin/gg/obsidian/discordbridge/UserAliasConfig.kt
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ object UserAliasConfig {
*/
fun load(plugin: Plugin) {
val list = plugin.users.data.getList("aliases")
if (list != null) aliases = list.checkItemsAre<UserAlias>() ?:
if (list != null) aliases = list.checkItemsAre() ?:
throw IllegalStateException("usernames.yml could not be read - list items are not properly formatted")
else mutableListOf<UserAlias>()
}
Expand Down Expand Up @@ -42,5 +42,5 @@ object UserAliasConfig {
* A function to assert that all the items in a given list are of a specific type
*/
@Suppress("UNCHECKED_CAST")
inline fun <reified T : Any> List<*>.checkItemsAre() = if (all { it is T }) this as List<T> else null
private inline fun <reified T : Any> List<*>.checkItemsAre() = if (all { it is T }) this as List<T> else null
}
Loading

0 comments on commit ad69465

Please sign in to comment.