mirror of
https://github.com/Auxilor/EcoSkills.git
synced 2026-01-04 15:41:36 +00:00
Added /skills toggleactionbar
This commit is contained in:
@@ -1,7 +1,9 @@
|
||||
package com.willfp.ecoskills.actionbar
|
||||
|
||||
import com.willfp.eco.core.data.PlayerProfile
|
||||
import com.willfp.eco.util.StringUtils
|
||||
import com.willfp.ecoskills.EcoSkillsPlugin
|
||||
import com.willfp.ecoskills.commands.CommandToggleActionbar
|
||||
import net.md_5.bungee.api.ChatMessageType
|
||||
import net.md_5.bungee.api.chat.TextComponent
|
||||
import org.bukkit.Bukkit
|
||||
@@ -45,6 +47,10 @@ object ActionBarUtils {
|
||||
continue
|
||||
}
|
||||
|
||||
if (!PlayerProfile.load(player).read(CommandToggleActionbar.DESCRIPTIONS_KEY)) {
|
||||
continue
|
||||
}
|
||||
|
||||
val message = plugin.configYml
|
||||
.getString("persistent-action-bar.format", false)
|
||||
val component = StringUtils.formatToComponent(message, player)
|
||||
|
||||
@@ -18,6 +18,7 @@ class CommandSkills(plugin: EcoPlugin) :
|
||||
init {
|
||||
this.addSubcommand(CommandTop(plugin))
|
||||
.addSubcommand(CommandRank(plugin))
|
||||
.addSubcommand(CommandToggleActionbar(plugin))
|
||||
}
|
||||
|
||||
override fun getHandler(): CommandHandler {
|
||||
|
||||
@@ -0,0 +1,47 @@
|
||||
package com.willfp.ecoskills.commands
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin
|
||||
import com.willfp.eco.core.command.CommandHandler
|
||||
import com.willfp.eco.core.command.impl.Subcommand
|
||||
import com.willfp.eco.core.data.PlayerProfile
|
||||
import com.willfp.eco.core.data.keys.PersistentDataKey
|
||||
import com.willfp.eco.core.data.keys.PersistentDataKeyType
|
||||
import com.willfp.eco.util.NamespacedKeyUtils
|
||||
import org.bukkit.command.CommandSender
|
||||
import org.bukkit.entity.Player
|
||||
|
||||
class CommandToggleActionbar(plugin: EcoPlugin) : Subcommand(
|
||||
plugin,
|
||||
"toggleactionbar",
|
||||
"ecoskills.command.toggleactionbar",
|
||||
true
|
||||
) {
|
||||
override fun getHandler(): CommandHandler {
|
||||
return CommandHandler { sender: CommandSender, _: List<String?>? ->
|
||||
if (!plugin.configYml.getBool("persistent-action-bar.enabled")) {
|
||||
sender.sendMessage(plugin.langYml.getMessage("actionbar-disabled"))
|
||||
return@CommandHandler
|
||||
}
|
||||
|
||||
val player = sender as Player
|
||||
val profile = PlayerProfile.load(player)
|
||||
|
||||
var currentStatus = profile.read(DESCRIPTIONS_KEY)
|
||||
currentStatus = !currentStatus
|
||||
profile.write(DESCRIPTIONS_KEY, currentStatus)
|
||||
if (currentStatus) {
|
||||
player.sendMessage(plugin.langYml.getMessage("enabled-actionbar"))
|
||||
} else {
|
||||
player.sendMessage(plugin.langYml.getMessage("disabled-actionbar"))
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
companion object {
|
||||
val DESCRIPTIONS_KEY = PersistentDataKey(
|
||||
NamespacedKeyUtils.create("ecoskills", "actionbar_enabled"),
|
||||
PersistentDataKeyType.BOOLEAN,
|
||||
true
|
||||
)
|
||||
}
|
||||
}
|
||||
@@ -16,6 +16,9 @@ messages:
|
||||
invalid-amount: "&cInvalid amount!"
|
||||
gave-skill-xp: "Gave %player% %amount% %skill% experience!"
|
||||
gave-stat: "Gave %player% %amount% %stat%&r!"
|
||||
enabled-descriptions: "&fYou have &aenabled &fthe action bar!"
|
||||
disabled-descriptions: "&fYou have &cdisabled &fthe action bar!"
|
||||
descriptions-disabled: "&cThe action bar disabled on this server."
|
||||
|
||||
line-wrap-color: "&8"
|
||||
|
||||
|
||||
@@ -46,6 +46,7 @@ permissions:
|
||||
ecoskills.command.top: true
|
||||
ecoskills.command.rank: true
|
||||
ecoskills.command.recount: true
|
||||
ecoskills.command.toggleactionbar: true
|
||||
|
||||
ecoskills.command.reload:
|
||||
description: Allows reloading the config
|
||||
@@ -71,6 +72,9 @@ permissions:
|
||||
ecoskills.command.recount:
|
||||
description: Allows the use of /ecoskills recount.
|
||||
default: op
|
||||
ecoskills.command.toggleactionbar:
|
||||
description: Allows the use of /skills toggleactionbar.
|
||||
default: op
|
||||
|
||||
ecoskills.xpmultiplier.50percent:
|
||||
description: Gives the player 50% more skill experience
|
||||
|
||||
Reference in New Issue
Block a user