mirror of
https://github.com/Auxilor/EcoSkills.git
synced 2026-01-03 14:22:17 +00:00
Readded /skills togglexpgainsound
This commit is contained in:
@@ -16,6 +16,7 @@ class CommandSkills(plugin: EcoPlugin) : PluginCommand(
|
||||
) {
|
||||
init {
|
||||
this.addSubcommand(CommandToggleActionBar(plugin))
|
||||
.addSubcommand(CommandToggleXpGainSound(plugin))
|
||||
.addSubcommand(CommandTop(plugin))
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,3 @@
|
||||
@file:Suppress("DEPRECATION")
|
||||
|
||||
package com.willfp.ecoskills.commands
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin
|
||||
|
||||
@@ -0,0 +1,24 @@
|
||||
package com.willfp.ecoskills.commands
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin
|
||||
import com.willfp.eco.core.command.impl.Subcommand
|
||||
import com.willfp.ecoskills.skills.display.isXPGainSoundEnabled
|
||||
import com.willfp.ecoskills.skills.display.toggleXPGainSound
|
||||
import org.bukkit.entity.Player
|
||||
|
||||
class CommandToggleXpGainSound(plugin: EcoPlugin) : Subcommand(
|
||||
plugin, "togglexpgainsound", "ecoskills.command.togglexpgainsound", true
|
||||
) {
|
||||
|
||||
override fun onExecute(player: Player, args: List<String>) {
|
||||
when (player.isXPGainSoundEnabled) {
|
||||
true -> {
|
||||
player.sendMessage(plugin.langYml.getMessage("disabled-xp-gain-sound"))
|
||||
}
|
||||
|
||||
false -> player.sendMessage(plugin.langYml.getMessage("enabled-xp-gain-sound"))
|
||||
}
|
||||
|
||||
player.toggleXPGainSound()
|
||||
}
|
||||
}
|
||||
@@ -1,8 +1,12 @@
|
||||
package com.willfp.ecoskills.skills.display
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin
|
||||
import com.willfp.eco.core.data.keys.PersistentDataKey
|
||||
import com.willfp.eco.core.data.keys.PersistentDataKeyType
|
||||
import com.willfp.eco.core.data.profile
|
||||
import com.willfp.eco.core.sound.PlayableSound
|
||||
import com.willfp.eco.util.formatEco
|
||||
import com.willfp.eco.util.namespacedKeyOf
|
||||
import com.willfp.eco.util.toNiceString
|
||||
import com.willfp.ecoskills.actionbar.sendCompatibleActionBarMessage
|
||||
import com.willfp.ecoskills.api.event.PlayerSkillXPGainEvent
|
||||
@@ -12,9 +16,23 @@ import com.willfp.ecoskills.api.getSkillProgress
|
||||
import com.willfp.ecoskills.api.getSkillXP
|
||||
import org.bukkit.boss.BarColor
|
||||
import org.bukkit.boss.BarStyle
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.event.EventHandler
|
||||
import org.bukkit.event.Listener
|
||||
|
||||
private val xpGainSoundEnabledKey = PersistentDataKey(
|
||||
namespacedKeyOf("ecoskills", "gain_sound_enabled"),
|
||||
PersistentDataKeyType.BOOLEAN,
|
||||
true
|
||||
)
|
||||
|
||||
fun Player.toggleXPGainSound() {
|
||||
this.profile.write(xpGainSoundEnabledKey, !this.profile.read(xpGainSoundEnabledKey))
|
||||
}
|
||||
|
||||
val Player.isXPGainSoundEnabled: Boolean
|
||||
get() = this.profile.read(xpGainSoundEnabledKey)
|
||||
|
||||
class GainXPDisplay(
|
||||
private val plugin: EcoPlugin
|
||||
) : Listener {
|
||||
@@ -35,7 +53,9 @@ class GainXPDisplay(
|
||||
handleActionBar(event)
|
||||
handleBossBar(event)
|
||||
|
||||
sound?.playTo(player)
|
||||
if (player.isXPGainSoundEnabled) {
|
||||
sound?.playTo(player)
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -15,6 +15,8 @@ messages:
|
||||
gave-stat: "Gave %player% %amount% %obj%&r!"
|
||||
enabled-actionbar: "&fYou have &aenabled &fthe action bar!"
|
||||
disabled-actionbar: "&fYou have &cdisabled &fthe action bar!"
|
||||
enabled-xp-gain-sound: "&fYou have &aenabled &fXP gain sounds!"
|
||||
disabled-xp-gain-sound: "&fYou have &cdisabled &fXP gain sounds!"
|
||||
actionbar-disabled: "&cThe action bar is disabled on this server."
|
||||
resetting-all-players: "&fResetting all players... (this may take a while)"
|
||||
reset-all-players: "&fReset all players!"
|
||||
|
||||
@@ -35,6 +35,7 @@ permissions:
|
||||
ecoskills.command.top: true
|
||||
ecoskills.command.recount: true
|
||||
ecoskills.command.toggleactionbar: true
|
||||
ecoskills.command.togglexpgainsound: true
|
||||
|
||||
ecoskills.command.reload:
|
||||
description: Allows reloading the config
|
||||
@@ -60,6 +61,9 @@ permissions:
|
||||
ecoskills.command.toggleactionbar:
|
||||
description: Allows the use of /skills toggleactionbar.
|
||||
default: op
|
||||
ecoskills.command.togglexpgainsound:
|
||||
description: Allows the use of /skills togglexpgainsound.
|
||||
default: op
|
||||
|
||||
ecoskills.xpmultiplier.50percent:
|
||||
description: Gives the player 50% more skill experience
|
||||
|
||||
@@ -38,6 +38,7 @@ permissions:
|
||||
ecoskills.command.top: true
|
||||
ecoskills.command.recount: true
|
||||
ecoskills.command.toggleactionbar: true
|
||||
ecoskills.command.togglexpgainsound: true
|
||||
|
||||
ecoskills.command.reload:
|
||||
description: Allows reloading the config
|
||||
@@ -63,6 +64,9 @@ permissions:
|
||||
ecoskills.command.toggleactionbar:
|
||||
description: Allows the use of /skills toggleactionbar.
|
||||
default: op
|
||||
ecoskills.command.togglexpgainsound:
|
||||
description: Allows the use of /skills togglexpgainsound.
|
||||
default: op
|
||||
|
||||
ecoskills.xpmultiplier.50percent:
|
||||
description: Gives the player 50% more skill experience
|
||||
|
||||
Reference in New Issue
Block a user