diff --git a/core/src/main/kotlin/com/mineinabyss/emojy/EmojyBrigadierCommands.kt b/core/src/main/kotlin/com/mineinabyss/emojy/EmojyBrigadierCommands.kt new file mode 100644 index 0000000..818d325 --- /dev/null +++ b/core/src/main/kotlin/com/mineinabyss/emojy/EmojyBrigadierCommands.kt @@ -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("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!") + } + } + } + } + } +} \ No newline at end of file diff --git a/core/src/main/kotlin/com/mineinabyss/emojy/EmojyCommands.kt b/core/src/main/kotlin/com/mineinabyss/emojy/EmojyCommands.kt deleted file mode 100644 index d0b3444..0000000 --- a/core/src/main/kotlin/com/mineinabyss/emojy/EmojyCommands.kt +++ /dev/null @@ -1,75 +0,0 @@ -package com.mineinabyss.emojy - -import com.mineinabyss.emojy.config.EmojyConfig -import com.mineinabyss.idofront.commands.execution.IdofrontCommandExecutor -import com.mineinabyss.idofront.messaging.broadcastVal -import com.mineinabyss.idofront.messaging.success -import com.mineinabyss.idofront.textcomponents.miniMsg -import net.kyori.adventure.inventory.Book -import net.kyori.adventure.text.Component -import net.kyori.adventure.text.TranslatableComponent -import net.kyori.adventure.translation.GlobalTranslator -import org.bukkit.command.Command -import org.bukkit.command.CommandSender -import org.bukkit.command.TabCompleter -import org.bukkit.entity.Player - -class EmojyCommands : IdofrontCommandExecutor(), TabCompleter { - override val commands = commands(emojy.plugin) { - "emojy" { - "lang" { - emojy.languages.map { it.locale }.joinToString { it.toString() }.broadcastVal() - sender.sendMessage(emojy.languages.any { it.locale == (sender as Player).locale() }.toString()) - } - "test" { - action { - val lang = (sender as? Player)?.locale()?.takeIf { it in emojy.languages.map { it.locale } } ?: emojy.languages.last().locale - sender.sendMessage(GlobalTranslator.render(("" + " : ").miniMsg(), lang)) - sender.sendMessage(GlobalTranslator.render(("" + "" + " : ").miniMsg(), lang)) - } - } - "list" { - action { - 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 -> emojy.emotes.joinToString(", ") { it.id }.miniMsg() - } - - val gifList = when (sender) { - is Player -> Component.textOfChildren(*gifs.map { it.formattedUnicode(true) }.toTypedArray()) - - else -> emojy.gifs.joinToString(", ") { it.id }.miniMsg() - } - - sender.sendRichMessage("List of emojis:") - sender.sendMessage(emoteList) - sender.sendRichMessage("<#f35444>List of GIFs") - sender.sendMessage(gifList) - } - } - "reload" { - action { - emojy.plugin.createEmojyContext() - EmojyGenerator.generateResourcePack() - sender.success("Emojy has been reloaded!") - } - } - } - } - - override fun onTabComplete( - sender: CommandSender, - command: Command, - label: String, - args: Array - ): List { - return if (command.name == "emojy") when (args.size) { - 1 -> listOf("list", "reload").filter { it.startsWith(args[0]) } - else -> emptyList() - } - else return emptyList() - } -} diff --git a/core/src/main/kotlin/com/mineinabyss/emojy/EmojyPlugin.kt b/core/src/main/kotlin/com/mineinabyss/emojy/EmojyPlugin.kt index 7663aec..ed7d726 100644 --- a/core/src/main/kotlin/com/mineinabyss/emojy/EmojyPlugin.kt +++ b/core/src/main/kotlin/com/mineinabyss/emojy/EmojyPlugin.kt @@ -35,8 +35,7 @@ class EmojyPlugin : JavaPlugin() { EmojyGenerator.generateResourcePack() - EmojyCommands() - + EmojyBrigadierCommands.registerCommands() } fun createEmojyContext() { diff --git a/gradle.properties b/gradle.properties index e14b3ee..a19d782 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,3 @@ group=com.mineinabyss version=0.9 -idofrontVersion=0.24.0 +idofrontVersion=0.24.5