Skip to content

Commit

Permalink
refactor: use Brigadier command logic
Browse files Browse the repository at this point in the history
  • Loading branch information
Boy0000 committed Jun 8, 2024
1 parent 3e6ed01 commit 2871786
Show file tree
Hide file tree
Showing 4 changed files with 47 additions and 78 deletions.
Original file line number Diff line number Diff line change
@@ -0,0 +1,45 @@
package com.mineinabyss.emojy

import com.mineinabyss.idofront.commands.brigadier.commands
import com.mineinabyss.idofront.messaging.success
import com.mineinabyss.idofront.textcomponents.miniMsg
import net.kyori.adventure.text.Component
import org.bukkit.entity.Player

object EmojyBrigadierCommands {

fun registerCommands() {
emojy.plugin.commands {
"emojy" {
"list" {
executes {
val emotes = emojy.emotes.filter { it.checkPermission(sender as? Player) && it !in emojyConfig.emojyList.ignoredEmotes }.toSet()
val gifs = emojy.gifs.filter { it.checkPermission(sender as? Player) && it !in emojyConfig.emojyList.ignoredGifs }.toSet()

val emoteList = when (sender) {
is Player -> Component.textOfChildren(*emotes.map { it.formattedUnicode(true) }.toTypedArray())
else -> emotes.joinToString(", ") { it.id }.miniMsg()
}

val gifList = when (sender) {
is Player -> Component.textOfChildren(*gifs.map { it.formattedUnicode(true) }.toTypedArray())
else -> gifs.joinToString(", ") { it.id }.miniMsg()
}

sender.sendRichMessage("<green>List of emojis:")
sender.sendMessage(emoteList)
sender.sendRichMessage("<#f35444>List of GIFs")
sender.sendMessage(gifList)
}
}
"reload" {
executes {
emojy.plugin.createEmojyContext()
EmojyGenerator.generateResourcePack()
sender.success("Emojy has been reloaded!")
}
}
}
}
}
}
75 changes: 0 additions & 75 deletions core/src/main/kotlin/com/mineinabyss/emojy/EmojyCommands.kt

This file was deleted.

3 changes: 1 addition & 2 deletions core/src/main/kotlin/com/mineinabyss/emojy/EmojyPlugin.kt
Original file line number Diff line number Diff line change
Expand Up @@ -35,8 +35,7 @@ class EmojyPlugin : JavaPlugin() {

EmojyGenerator.generateResourcePack()

EmojyCommands()

EmojyBrigadierCommands.registerCommands()
}

fun createEmojyContext() {
Expand Down
2 changes: 1 addition & 1 deletion gradle.properties
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
group=com.mineinabyss
version=0.9
idofrontVersion=0.24.0
idofrontVersion=0.24.5

0 comments on commit 2871786

Please sign in to comment.