Moved boosters to their own file
This commit is contained in:
@@ -48,7 +48,7 @@ allprojects {
|
||||
|
||||
compileOnly 'org.jetbrains:annotations:23.0.0'
|
||||
|
||||
compileOnly 'org.jetbrains.kotlin:kotlin-stdlib:1.7.10'
|
||||
compileOnly 'org.jetbrains.kotlin:kotlin-stdlib:1.7.20'
|
||||
}
|
||||
|
||||
tasks.withType(JavaCompile) {
|
||||
|
||||
@@ -5,24 +5,15 @@ import com.willfp.boosters.boosters.activeBoosters
|
||||
import com.willfp.boosters.boosters.expireBooster
|
||||
import com.willfp.boosters.boosters.scanForBoosters
|
||||
import com.willfp.boosters.commands.CommandBoosters
|
||||
import com.willfp.boosters.config.BoostersYml
|
||||
import com.willfp.eco.core.command.impl.PluginCommand
|
||||
import com.willfp.eco.core.data.ServerProfile
|
||||
import com.willfp.eco.core.data.profile
|
||||
import com.willfp.eco.core.integrations.placeholder.PlaceholderManager
|
||||
import com.willfp.eco.core.placeholder.PlayerlessPlaceholder
|
||||
import com.willfp.eco.util.formatEco
|
||||
import com.willfp.eco.util.savedDisplayName
|
||||
import com.willfp.libreforge.LibReforgePlugin
|
||||
import org.bukkit.Bukkit
|
||||
|
||||
import org.bukkit.event.Listener
|
||||
import kotlin.math.floor
|
||||
|
||||
class BoostersPlugin : LibReforgePlugin(supportsLrcdb = false) {
|
||||
val boostersYml = BoostersYml(this)
|
||||
|
||||
override fun handleEnableAdditional() {
|
||||
this.copyConfigs("boosters")
|
||||
|
||||
this.registerHolderProvider { Bukkit.getServer().activeBoosters.map { it.booster } }
|
||||
}
|
||||
|
||||
@@ -62,7 +53,7 @@ class BoostersPlugin : LibReforgePlugin(supportsLrcdb = false) {
|
||||
)
|
||||
}
|
||||
|
||||
override fun loadPluginCommands(): List<com.willfp.eco.core.command.impl.PluginCommand> {
|
||||
override fun loadPluginCommands(): List<PluginCommand> {
|
||||
return listOf(
|
||||
CommandBoosters(this)
|
||||
)
|
||||
|
||||
@@ -24,10 +24,9 @@ import kotlin.math.floor
|
||||
|
||||
class Booster(
|
||||
private val plugin: BoostersPlugin,
|
||||
val config: Config,
|
||||
override val id: String,
|
||||
val config: Config
|
||||
) : Holder {
|
||||
override val id = config.getString("id")
|
||||
|
||||
val ownedDataKey: PersistentDataKey<Int> = PersistentDataKey(
|
||||
plugin.namespacedKeyFactory.create(id),
|
||||
PersistentDataKeyType.INT,
|
||||
@@ -206,11 +205,12 @@ class Booster(
|
||||
) {
|
||||
var activeList = mutableListOf<String>()
|
||||
|
||||
for(active in Bukkit.getServer().activeBoosters){
|
||||
for (active in Bukkit.getServer().activeBoosters) {
|
||||
activeList.add(active.booster.name)
|
||||
}
|
||||
|
||||
var outputString = plugin.langYml.getString("no-currently-active-list").formatEco(formatPlaceholders = false)
|
||||
var outputString =
|
||||
plugin.langYml.getString("no-currently-active-list").formatEco(formatPlaceholders = false)
|
||||
if (activeList.size > 0) {
|
||||
outputString = activeList.joinToString(", ")
|
||||
}
|
||||
|
||||
@@ -4,13 +4,14 @@ import com.google.common.collect.BiMap
|
||||
import com.google.common.collect.HashBiMap
|
||||
import com.google.common.collect.ImmutableList
|
||||
import com.willfp.boosters.BoostersPlugin
|
||||
import com.willfp.eco.core.config.ConfigType
|
||||
import com.willfp.eco.core.config.readConfig
|
||||
import com.willfp.eco.core.config.updating.ConfigUpdater
|
||||
import com.willfp.libreforge.chains.EffectChains
|
||||
import java.io.File
|
||||
|
||||
object Boosters {
|
||||
/**
|
||||
* Registered boosters.
|
||||
*/
|
||||
/** Registered boosters. */
|
||||
private val BY_ID: BiMap<String, Booster> = HashBiMap.create()
|
||||
|
||||
/**
|
||||
@@ -42,14 +43,22 @@ object Boosters {
|
||||
@ConfigUpdater
|
||||
@JvmStatic
|
||||
fun update(plugin: BoostersPlugin) {
|
||||
plugin.boostersYml.getSubsections("chains").mapNotNull {
|
||||
EffectChains.compile(it, "Effect Chains")
|
||||
}
|
||||
for (booster in values()) {
|
||||
removeBooster(booster)
|
||||
}
|
||||
for (config in plugin.boostersYml.getSubsections("boosters")) {
|
||||
Booster(plugin, config)
|
||||
|
||||
for ((id, config) in plugin.fetchConfigs("boosters")) {
|
||||
Booster(plugin, id, config)
|
||||
}
|
||||
|
||||
// Legacy
|
||||
val boostersYml = File(plugin.dataFolder, "boosters.yml").readConfig(ConfigType.YAML)
|
||||
|
||||
for (config in boostersYml.getSubsections("boosters")) {
|
||||
Booster(plugin, config.getString("id"), config)
|
||||
}
|
||||
boostersYml.getSubsections("chains").mapNotNull {
|
||||
EffectChains.compile(it, "Effect Chains")
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -1,12 +0,0 @@
|
||||
package com.willfp.boosters.config
|
||||
|
||||
import com.willfp.eco.core.EcoPlugin
|
||||
import com.willfp.eco.core.config.BaseConfig
|
||||
import com.willfp.eco.core.config.ConfigType
|
||||
|
||||
class BoostersYml(plugin: EcoPlugin) : BaseConfig(
|
||||
"boosters",
|
||||
plugin,
|
||||
false,
|
||||
ConfigType.YAML
|
||||
)
|
||||
@@ -1,124 +0,0 @@
|
||||
boosters:
|
||||
- id: 1_5sell_multiplier
|
||||
name: "1.5x Sell Multiplier"
|
||||
duration: 72000
|
||||
effects:
|
||||
- id: sell_multiplier
|
||||
args:
|
||||
multiplier: 1.5
|
||||
conditions: []
|
||||
commands:
|
||||
activation: []
|
||||
expiry: []
|
||||
messages:
|
||||
activation:
|
||||
- ""
|
||||
- " %player%&f has activated a &a1.5x Sell Multiplier Booster&f!"
|
||||
- " &fThis booster will last an hour, be sure to thank them!"
|
||||
- ""
|
||||
expiry:
|
||||
- ""
|
||||
- " &fThe &a1.5x Sell Multiplier Booster&f has ended"
|
||||
- " &fGet another one here: &ahttps://store.ecomc.net/package/756887"
|
||||
- ""
|
||||
gui:
|
||||
item: player_head texture:eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTM0YjI3YmZjYzhmOWI5NjQ1OTRiNjE4YjExNDZhZjY5ZGUyNzhjZTVlMmUzMDEyY2I0NzFhOWEzY2YzODcxIn19fQ==
|
||||
name: "&d1.5x Sell Multiplier"
|
||||
lore:
|
||||
- ""
|
||||
- "&fGives everyone online a"
|
||||
- "&a1.5x Sell Multiplier"
|
||||
- "&fto make money faster!"
|
||||
- ""
|
||||
- "&fDuration: &a1 Hour"
|
||||
- ""
|
||||
- "&fYou have: &a%amount%"
|
||||
- "&fGet more at &astore.ecomc.net"
|
||||
- ""
|
||||
- "&e&oClick to activate!"
|
||||
- ""
|
||||
position:
|
||||
row: 2
|
||||
column: 2
|
||||
- id: 2sell_multiplier
|
||||
name: "2x Sell Multiplier"
|
||||
duration: 72000
|
||||
effects:
|
||||
- id: sell_multiplier
|
||||
args:
|
||||
multiplier: 2
|
||||
conditions: []
|
||||
commands:
|
||||
activation: []
|
||||
expiry: []
|
||||
messages:
|
||||
activation:
|
||||
- ""
|
||||
- " %player%&f has activated a &a2x Sell Multiplier Booster&f!"
|
||||
- " &fThis booster will last an hour, be sure to thank them!"
|
||||
- ""
|
||||
expiry:
|
||||
- ""
|
||||
- " &fThe &a2x Sell Multiplier Booster&f has ended"
|
||||
- " &fGet another one here: &ahttps://store.ecomc.net/package/756888"
|
||||
- ""
|
||||
gui:
|
||||
item: player_head texture:eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjBhN2I5NGM0ZTU4MWI2OTkxNTlkNDg4NDZlYzA5MTM5MjUwNjIzN2M4OWE5N2M5MzI0OGEwZDhhYmM5MTZkNSJ9fX0=
|
||||
name: "&d2x Sell Multiplier"
|
||||
lore:
|
||||
- ""
|
||||
- "&fGives everyone online a"
|
||||
- "&a2x Sell Multiplier"
|
||||
- "&fto make money faster!"
|
||||
- ""
|
||||
- "&fDuration: &a1 Hour"
|
||||
- ""
|
||||
- "&fYou have: &a%amount%"
|
||||
- "&fGet more at &astore.ecomc.net"
|
||||
- ""
|
||||
- "&e&oClick to activate!"
|
||||
- ""
|
||||
position:
|
||||
row: 2
|
||||
column: 5
|
||||
- id: skill_xp
|
||||
name: "2x Skill XP Multiplier"
|
||||
duration: 72000
|
||||
effects:
|
||||
- id: skill_xp_multiplier
|
||||
args:
|
||||
multiplier: 2
|
||||
conditions: []
|
||||
commands:
|
||||
activation: []
|
||||
expiry: []
|
||||
messages:
|
||||
activation:
|
||||
- ""
|
||||
- " %player%&f has activated a &a2x Skill XP Booster&f!"
|
||||
- " &fThis booster will last an hour, be sure to thank them!"
|
||||
- ""
|
||||
expiry:
|
||||
- ""
|
||||
- " &fThe &a2x Skill XP Booster&f has ended"
|
||||
- " &fGet another one here: &ahttps://store.ecomc.net/package/756893"
|
||||
- ""
|
||||
gui:
|
||||
item: player_head texture:eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODkyNmMxZjJjM2MxNGQwODZjNDBjZmMyMzVmZTkzODY5NGY0YTUxMDY3YWRhNDcyNmI0ODZlYTFjODdiMDNlMiJ9fX0=
|
||||
name: "&d2x Skill XP Multiplier"
|
||||
lore:
|
||||
- ""
|
||||
- "&fGives everyone online a"
|
||||
- "&a2x Skill XP Multiplier"
|
||||
- "&fto level up faster!"
|
||||
- ""
|
||||
- "&fDuration: &a1 Hour"
|
||||
- ""
|
||||
- "&fYou have: &a%amount%"
|
||||
- "&fGet more at &astore.ecomc.net"
|
||||
- ""
|
||||
- "&e&oClick to activate!"
|
||||
- ""
|
||||
position:
|
||||
row: 2
|
||||
column: 8
|
||||
@@ -0,0 +1,40 @@
|
||||
name: "1.5x Sell Multiplier"
|
||||
duration: 72000
|
||||
effects:
|
||||
- id: sell_multiplier
|
||||
args:
|
||||
multiplier: 1.5
|
||||
conditions: [ ]
|
||||
commands:
|
||||
activation: [ ]
|
||||
expiry: [ ]
|
||||
messages:
|
||||
activation:
|
||||
- ""
|
||||
- " %player%&f has activated a &a1.5x Sell Multiplier Booster&f!"
|
||||
- " &fThis booster will last an hour, be sure to thank them!"
|
||||
- ""
|
||||
expiry:
|
||||
- ""
|
||||
- " &fThe &a1.5x Sell Multiplier Booster&f has ended"
|
||||
- " &fGet another one here: &ahttps://store.ecomc.net/package/756887"
|
||||
- ""
|
||||
gui:
|
||||
item: player_head texture:eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTM0YjI3YmZjYzhmOWI5NjQ1OTRiNjE4YjExNDZhZjY5ZGUyNzhjZTVlMmUzMDEyY2I0NzFhOWEzY2YzODcxIn19fQ==
|
||||
name: "&d1.5x Sell Multiplier"
|
||||
lore:
|
||||
- ""
|
||||
- "&fGives everyone online a"
|
||||
- "&a1.5x Sell Multiplier"
|
||||
- "&fto make money faster!"
|
||||
- ""
|
||||
- "&fDuration: &a1 Hour"
|
||||
- ""
|
||||
- "&fYou have: &a%amount%"
|
||||
- "&fGet more at &astore.ecomc.net"
|
||||
- ""
|
||||
- "&e&oClick to activate!"
|
||||
- ""
|
||||
position:
|
||||
row: 2
|
||||
column: 2
|
||||
@@ -0,0 +1,40 @@
|
||||
name: "2x Sell Multiplier"
|
||||
duration: 72000
|
||||
effects:
|
||||
- id: sell_multiplier
|
||||
args:
|
||||
multiplier: 2
|
||||
conditions: [ ]
|
||||
commands:
|
||||
activation: [ ]
|
||||
expiry: [ ]
|
||||
messages:
|
||||
activation:
|
||||
- ""
|
||||
- " %player%&f has activated a &a2x Sell Multiplier Booster&f!"
|
||||
- " &fThis booster will last an hour, be sure to thank them!"
|
||||
- ""
|
||||
expiry:
|
||||
- ""
|
||||
- " &fThe &a2x Sell Multiplier Booster&f has ended"
|
||||
- " &fGet another one here: &ahttps://store.ecomc.net/package/756888"
|
||||
- ""
|
||||
gui:
|
||||
item: player_head texture:eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjBhN2I5NGM0ZTU4MWI2OTkxNTlkNDg4NDZlYzA5MTM5MjUwNjIzN2M4OWE5N2M5MzI0OGEwZDhhYmM5MTZkNSJ9fX0=
|
||||
name: "&d2x Sell Multiplier"
|
||||
lore:
|
||||
- ""
|
||||
- "&fGives everyone online a"
|
||||
- "&a2x Sell Multiplier"
|
||||
- "&fto make money faster!"
|
||||
- ""
|
||||
- "&fDuration: &a1 Hour"
|
||||
- ""
|
||||
- "&fYou have: &a%amount%"
|
||||
- "&fGet more at &astore.ecomc.net"
|
||||
- ""
|
||||
- "&e&oClick to activate!"
|
||||
- ""
|
||||
position:
|
||||
row: 2
|
||||
column: 5
|
||||
@@ -0,0 +1,55 @@
|
||||
# The ID of the booster is the name of the .yml file,
|
||||
# for example skill_xp_multiplier.yml has the ID of skill_xp_multiplier
|
||||
# You can place boosters anywhere in this folder,
|
||||
# including in subfolders if you want to organize your booster configs
|
||||
# _example.yml is not loaded.
|
||||
|
||||
name: "1.5x Sell Multiplier" # The name of the booster, shown to players
|
||||
duration: 72000 # The duration, in ticks
|
||||
|
||||
# The effects of the booster (i.e. the functionality)
|
||||
# See here: https://plugins.auxilor.io/effects/configuring-an-effect
|
||||
effects:
|
||||
- id: sell_multiplier
|
||||
args:
|
||||
multiplier: 1.5
|
||||
|
||||
# The conditions required for the effects to activate
|
||||
conditions: []
|
||||
|
||||
# Commands ran by console on booster activation and expiry
|
||||
commands:
|
||||
activation: []
|
||||
expiry: []
|
||||
|
||||
messages:
|
||||
activation:
|
||||
- ""
|
||||
- " %player%&f has activated a &a1.5x Sell Multiplier Booster&f!"
|
||||
- " &fThis booster will last an hour, be sure to thank them!"
|
||||
- ""
|
||||
expiry:
|
||||
- ""
|
||||
- " &fThe &a1.5x Sell Multiplier Booster&f has ended"
|
||||
- " &fGet another one here: &ahttps://store.ecomc.net/package/756887"
|
||||
- ""
|
||||
|
||||
gui:
|
||||
item: player_head texture:eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTM0YjI3YmZjYzhmOWI5NjQ1OTRiNjE4YjExNDZhZjY5ZGUyNzhjZTVlMmUzMDEyY2I0NzFhOWEzY2YzODcxIn19fQ==
|
||||
name: "&d1.5x Sell Multiplier"
|
||||
lore:
|
||||
- ""
|
||||
- "&fGives everyone online a"
|
||||
- "&a1.5x Sell Multiplier"
|
||||
- "&fto make money faster!"
|
||||
- ""
|
||||
- "&fDuration: &a1 Hour"
|
||||
- ""
|
||||
- "&fYou have: &a%amount%"
|
||||
- "&fGet more at &astore.ecomc.net"
|
||||
- ""
|
||||
- "&e&oClick to activate!"
|
||||
- ""
|
||||
position:
|
||||
row: 2
|
||||
column: 2
|
||||
@@ -0,0 +1,40 @@
|
||||
name: "2x Skill XP Multiplier"
|
||||
duration: 72000
|
||||
effects:
|
||||
- id: skill_xp_multiplier
|
||||
args:
|
||||
multiplier: 2
|
||||
conditions: [ ]
|
||||
commands:
|
||||
activation: [ ]
|
||||
expiry: [ ]
|
||||
messages:
|
||||
activation:
|
||||
- ""
|
||||
- " %player%&f has activated a &a2x Skill XP Booster&f!"
|
||||
- " &fThis booster will last an hour, be sure to thank them!"
|
||||
- ""
|
||||
expiry:
|
||||
- ""
|
||||
- " &fThe &a2x Skill XP Booster&f has ended"
|
||||
- " &fGet another one here: &ahttps://store.ecomc.net/package/756893"
|
||||
- ""
|
||||
gui:
|
||||
item: player_head texture:eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODkyNmMxZjJjM2MxNGQwODZjNDBjZmMyMzVmZTkzODY5NGY0YTUxMDY3YWRhNDcyNmI0ODZlYTFjODdiMDNlMiJ9fX0=
|
||||
name: "&d2x Skill XP Multiplier"
|
||||
lore:
|
||||
- ""
|
||||
- "&fGives everyone online a"
|
||||
- "&a2x Skill XP Multiplier"
|
||||
- "&fto level up faster!"
|
||||
- ""
|
||||
- "&fDuration: &a1 Hour"
|
||||
- ""
|
||||
- "&fYou have: &a%amount%"
|
||||
- "&fGet more at &astore.ecomc.net"
|
||||
- ""
|
||||
- "&e&oClick to activate!"
|
||||
- ""
|
||||
position:
|
||||
row: 2
|
||||
column: 8
|
||||
Reference in New Issue
Block a user