Updated to libreforge 4
This commit is contained in:
@@ -49,6 +49,7 @@ fun Player.activateBooster(booster: Booster): Boolean {
|
||||
this.setAmountOfBooster(booster, amount - 1)
|
||||
|
||||
for (activationMessage in booster.getActivationMessages(this)) {
|
||||
@Suppress("DEPRECATION")
|
||||
Bukkit.broadcastMessage(activationMessage)
|
||||
}
|
||||
|
||||
|
||||
@@ -6,18 +6,24 @@ import com.willfp.boosters.boosters.expireBooster
|
||||
import com.willfp.boosters.boosters.scanForBoosters
|
||||
import com.willfp.boosters.commands.CommandBoosters
|
||||
import com.willfp.eco.core.command.impl.PluginCommand
|
||||
import com.willfp.libreforge.LibReforgePlugin
|
||||
import com.willfp.libreforge.SimpleProvidedHolder
|
||||
import com.willfp.libreforge.loader.LibreforgePlugin
|
||||
import com.willfp.libreforge.loader.configs.ConfigCategory
|
||||
import com.willfp.libreforge.registerHolderProvider
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.event.Listener
|
||||
|
||||
class BoostersPlugin : LibReforgePlugin() {
|
||||
override fun handleEnableAdditional() {
|
||||
this.copyConfigs("boosters")
|
||||
|
||||
this.registerHolderProvider { Bukkit.getServer().activeBoosters.map { it.booster } }
|
||||
class BoostersPlugin : LibreforgePlugin() {
|
||||
override fun loadConfigCategories(): List<ConfigCategory> {
|
||||
return listOf(
|
||||
Boosters
|
||||
)
|
||||
}
|
||||
|
||||
override fun handleReloadAdditional() {
|
||||
override fun handleEnable() {
|
||||
registerHolderProvider { Bukkit.getServer().activeBoosters.map { it.booster }.map { SimpleProvidedHolder(it) } }
|
||||
}
|
||||
|
||||
override fun handleReload() {
|
||||
this.scheduler.runTimer(1, 1) {
|
||||
for (booster in Boosters.values()) {
|
||||
if (booster.active == null) {
|
||||
@@ -26,6 +32,7 @@ class BoostersPlugin : LibReforgePlugin() {
|
||||
|
||||
if (booster.secondsLeft <= 0) {
|
||||
for (expiryMessage in booster.expiryMessages) {
|
||||
@Suppress("DEPRECATION")
|
||||
Bukkit.broadcastMessage(expiryMessage)
|
||||
}
|
||||
|
||||
@@ -47,12 +54,6 @@ class BoostersPlugin : LibReforgePlugin() {
|
||||
}
|
||||
}
|
||||
|
||||
override fun loadListeners(): List<Listener> {
|
||||
return listOf(
|
||||
|
||||
)
|
||||
}
|
||||
|
||||
override fun loadPluginCommands(): List<PluginCommand> {
|
||||
return listOf(
|
||||
CommandBoosters(this)
|
||||
|
||||
@@ -10,10 +10,12 @@ import com.willfp.eco.core.integrations.placeholder.PlaceholderManager
|
||||
import com.willfp.eco.core.items.Items
|
||||
import com.willfp.eco.core.items.builder.ItemStackBuilder
|
||||
import com.willfp.eco.core.placeholder.PlayerlessPlaceholder
|
||||
import com.willfp.eco.core.registry.Registrable
|
||||
import com.willfp.eco.util.StringUtils
|
||||
import com.willfp.eco.util.formatEco
|
||||
import com.willfp.eco.util.savedDisplayName
|
||||
import com.willfp.libreforge.Holder
|
||||
import com.willfp.libreforge.ViolationContext
|
||||
import com.willfp.libreforge.conditions.Conditions
|
||||
import com.willfp.libreforge.effects.Effects
|
||||
import org.bukkit.Bukkit
|
||||
@@ -24,9 +26,9 @@ import kotlin.math.floor
|
||||
|
||||
class Booster(
|
||||
private val plugin: BoostersPlugin,
|
||||
override val id: String,
|
||||
id: String,
|
||||
val config: Config
|
||||
) : Holder {
|
||||
) : Holder, Registrable {
|
||||
val ownedDataKey: PersistentDataKey<Int> = PersistentDataKey(
|
||||
plugin.namespacedKeyFactory.create(id),
|
||||
PersistentDataKeyType.INT,
|
||||
@@ -109,16 +111,17 @@ class Booster(
|
||||
|
||||
override val conditions = Conditions.compile(
|
||||
config.getSubsections("conditions"),
|
||||
"Booster $id"
|
||||
ViolationContext(plugin, "Booster $id")
|
||||
)
|
||||
|
||||
override val effects = Effects.compile(
|
||||
config.getSubsections("effects"),
|
||||
"Booster $id"
|
||||
ViolationContext(plugin, "Booster $id")
|
||||
)
|
||||
|
||||
override val id = plugin.createNamespacedKey(id)
|
||||
|
||||
init {
|
||||
Boosters.addNewBooster(this)
|
||||
PlaceholderManager.registerPlaceholder(
|
||||
PlayerlessPlaceholder(
|
||||
plugin,
|
||||
@@ -220,6 +223,10 @@ class Booster(
|
||||
)
|
||||
}
|
||||
|
||||
override fun getID(): String {
|
||||
return this.id.key
|
||||
}
|
||||
|
||||
override fun equals(other: Any?): Boolean {
|
||||
if (other !is Booster) {
|
||||
return false
|
||||
|
||||
@@ -1,18 +1,21 @@
|
||||
package com.willfp.boosters.boosters
|
||||
|
||||
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
|
||||
import com.willfp.eco.core.config.interfaces.Config
|
||||
import com.willfp.eco.core.registry.Registry
|
||||
import com.willfp.libreforge.loader.LibreforgePlugin
|
||||
import com.willfp.libreforge.loader.configs.ConfigCategory
|
||||
import com.willfp.libreforge.loader.configs.LegacyLocation
|
||||
|
||||
object Boosters {
|
||||
object Boosters : ConfigCategory("booster", "boosters") {
|
||||
/** Registered boosters. */
|
||||
private val BY_ID: BiMap<String, Booster> = HashBiMap.create()
|
||||
private val registry = Registry<Booster>()
|
||||
|
||||
override val legacyLocation = LegacyLocation(
|
||||
"boosters.yml",
|
||||
"boosters"
|
||||
)
|
||||
|
||||
/**
|
||||
* Get all registered [Booster]s.
|
||||
@@ -21,7 +24,7 @@ object Boosters {
|
||||
*/
|
||||
@JvmStatic
|
||||
fun values(): List<Booster> {
|
||||
return ImmutableList.copyOf(BY_ID.values)
|
||||
return ImmutableList.copyOf(registry.values())
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -32,54 +35,14 @@ object Boosters {
|
||||
*/
|
||||
@JvmStatic
|
||||
fun getByID(name: String): Booster? {
|
||||
return BY_ID[name]
|
||||
return registry[name]
|
||||
}
|
||||
|
||||
/**
|
||||
* Update all [Booster]s.
|
||||
*
|
||||
* @param plugin Instance of Booster.
|
||||
*/
|
||||
@ConfigUpdater
|
||||
@JvmStatic
|
||||
fun update(plugin: BoostersPlugin) {
|
||||
for (booster in values()) {
|
||||
removeBooster(booster)
|
||||
}
|
||||
|
||||
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")
|
||||
}
|
||||
override fun clear(plugin: LibreforgePlugin) {
|
||||
registry.clear()
|
||||
}
|
||||
|
||||
/**
|
||||
* Add new [Booster] to Booster.
|
||||
*
|
||||
* @param booster The [Booster] to add.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun addNewBooster(booster: Booster) {
|
||||
BY_ID.remove(booster.id)
|
||||
BY_ID[booster.id] = booster
|
||||
}
|
||||
|
||||
/**
|
||||
* Remove [Booster] from Booster.
|
||||
*
|
||||
* @param booster The [Booster] to remove.
|
||||
*/
|
||||
@JvmStatic
|
||||
fun removeBooster(booster: Booster) {
|
||||
BY_ID.remove(booster.id)
|
||||
override fun acceptConfig(plugin: LibreforgePlugin, id: String, config: Config) {
|
||||
registry.register(Booster(plugin as BoostersPlugin, id, config))
|
||||
}
|
||||
}
|
||||
|
||||
+2
-15
@@ -1,16 +1,12 @@
|
||||
package com.willfp.boosters.commands
|
||||
|
||||
import com.willfp.boosters.boosters.Boosters
|
||||
import com.willfp.boosters.gui.BoosterGUI
|
||||
import com.willfp.eco.core.EcoPlugin
|
||||
import com.willfp.eco.core.command.impl.PluginCommand
|
||||
import com.willfp.libreforge.LibReforgePlugin
|
||||
import com.willfp.libreforge.lrcdb.CommandExport
|
||||
import com.willfp.libreforge.lrcdb.CommandImport
|
||||
import com.willfp.libreforge.lrcdb.ExportableConfig
|
||||
import org.bukkit.command.CommandSender
|
||||
import org.bukkit.entity.Player
|
||||
|
||||
class CommandBoosters(plugin: LibReforgePlugin) :
|
||||
class CommandBoosters(plugin: EcoPlugin) :
|
||||
PluginCommand(
|
||||
plugin,
|
||||
"boosters",
|
||||
@@ -23,15 +19,6 @@ class CommandBoosters(plugin: LibReforgePlugin) :
|
||||
.addSubcommand(CommandReload(plugin))
|
||||
.addSubcommand(CommandCancel(plugin))
|
||||
.addSubcommand(CommandActivate(plugin))
|
||||
.addSubcommand(CommandImport("boosters", plugin))
|
||||
.addSubcommand(CommandExport(plugin) {
|
||||
Boosters.values().map {
|
||||
ExportableConfig(
|
||||
it.id,
|
||||
it.config
|
||||
)
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
override fun onExecute(sender: CommandSender, args: List<String>) {
|
||||
|
||||
@@ -73,7 +73,7 @@ class CommandGive(plugin: EcoPlugin) :
|
||||
if (args.size == 2) {
|
||||
StringUtil.copyPartialMatches(
|
||||
args[1],
|
||||
Boosters.values().map { it.id },
|
||||
Boosters.values().map { it.id.key },
|
||||
completions
|
||||
)
|
||||
return completions
|
||||
|
||||
@@ -1,21 +0,0 @@
|
||||
# Read more about chains: https://plugins.auxilor.io/effects/configuring-an-effect#effect-chains
|
||||
|
||||
chains:
|
||||
- id: example_chain
|
||||
effects:
|
||||
- id: teleport
|
||||
- id: potion_effect
|
||||
args:
|
||||
effect: blindness
|
||||
level: 3
|
||||
duration: 30
|
||||
apply_to_player: true
|
||||
- id: send_message
|
||||
args:
|
||||
message: "&fYou have been teleported!"
|
||||
action_bar: true
|
||||
- id: play_sound
|
||||
args:
|
||||
sound: entity_dragon_fireball_explode
|
||||
pitch: 1.5
|
||||
volume: 4
|
||||
@@ -13,48 +13,3 @@ gui:
|
||||
- "111111111"
|
||||
- "101101101"
|
||||
- "111111111"
|
||||
|
||||
cooldown:
|
||||
in-actionbar: true
|
||||
sound:
|
||||
enabled: true
|
||||
sound: "BLOCK_NOTE_BLOCK_PLING"
|
||||
pitch: 0.5
|
||||
|
||||
cannot-afford:
|
||||
in-actionbar: true
|
||||
sound:
|
||||
enabled: true
|
||||
sound: "BLOCK_NOTE_BLOCK_PLING"
|
||||
pitch: 0.5
|
||||
|
||||
cannot-afford-type:
|
||||
in-actionbar: true
|
||||
sound:
|
||||
enabled: true
|
||||
sound: "BLOCK_NOTE_BLOCK_PLING"
|
||||
pitch: 0.5
|
||||
|
||||
cannot-afford-price:
|
||||
in-actionbar: true
|
||||
sound:
|
||||
enabled: true
|
||||
sound: "BLOCK_NOTE_BLOCK_PLING"
|
||||
pitch: 0.5
|
||||
|
||||
point-names: # If you have point names that look ugly (eg g_souls) then you can map them to nice names to be shown to players.
|
||||
example_point: "Nicely Formatted Point"
|
||||
|
||||
use-faster-move-trigger: true # Disable if you want move trigger to detect sub-1-block movements
|
||||
raytrace-distance: 80 # The distance that alt_click should check for a location
|
||||
|
||||
potions:
|
||||
icon:
|
||||
permanent: true
|
||||
triggered: true
|
||||
ambient:
|
||||
permanent: false
|
||||
triggered: true
|
||||
particles:
|
||||
permanent: false
|
||||
triggered: true
|
||||
|
||||
@@ -1,3 +1,8 @@
|
||||
resource-id: 2036
|
||||
bstats-id: 14269
|
||||
color: "&e"
|
||||
environment:
|
||||
- name: libreforge version
|
||||
value: ${libreforgeVersion}
|
||||
|
||||
options:
|
||||
resource-id: 2036
|
||||
bstats-id: 14269
|
||||
color: "&e"
|
||||
|
||||
@@ -4,18 +4,6 @@ messages:
|
||||
not-player: "&cThis command must be run by a player"
|
||||
invalid-command: "&cUnknown subcommand!"
|
||||
reloaded: "Reloaded!"
|
||||
cannot-afford: "&cYou can't afford to do this! &fCost: &a$$%cost%"
|
||||
cannot-afford-type: "&cYou can't afford to do this! &fCost: &a%cost% %type%"
|
||||
cannot-afford-price: "&cYou can't afford to do this! &fPrice: %price%"
|
||||
on-cooldown: "&cThis effect is on cooldown! &fTime left: &a%seconds% seconds"
|
||||
cannot-transmit: "&cYou can't transmit here!"
|
||||
must-specify-lrcdb-id: "&cYou must specify the ID of the config to download! Not sure what this means? Go to &alrcdb.auxilor.io"
|
||||
lrcdb-import-error: "&cError importing config: &f%message%"
|
||||
lrcdb-import-success: "&fImported &a%name%&f! Reload the plugin to install it"
|
||||
must-specify-config-name: "&cYou must specify the config name!"
|
||||
invalid-config-name: "&cInvalid config name!"
|
||||
lrcdb-export-error: "&cError exporting config: &f%message%"
|
||||
lrcdb-export-success: "&fExported &a%name%&f! View it on &alrcdb.auxilor.io&f, or share your config ID: &f%id%"
|
||||
|
||||
requires-player: "&cYou must specify a player!"
|
||||
invalid-player: "&cInvalid player!"
|
||||
|
||||
@@ -1,19 +0,0 @@
|
||||
# Options for lrcdb (https://lrcdb.auxilor.io), a website to share configs
|
||||
# with other server owners, so you can get more configs without making them
|
||||
# yourself!
|
||||
|
||||
author: "Unknown Author" # The name attached to configs you export
|
||||
|
||||
# Options about automatically sharing configs you create
|
||||
share-configs:
|
||||
# If you want all your configs to automatically be publicly available,
|
||||
# set this to true. This really helps out other users!
|
||||
publicly: false
|
||||
|
||||
# If you don't want your configs to be usable to gather information about
|
||||
# plugin usage or to improve the plugins in the future, disable this.
|
||||
# Nothing identifying is shared.
|
||||
enabled: true
|
||||
|
||||
# If you disable share-configs, you can still share select configs publicly
|
||||
# with /boosters export <config>.
|
||||
@@ -0,0 +1,17 @@
|
||||
name: ${pluginName}
|
||||
version: ${version}
|
||||
main: com.willfp.boosters.BoostersPlugin
|
||||
api-version: 1.19
|
||||
|
||||
dependencies:
|
||||
- name: eco
|
||||
required: true
|
||||
bootstrap: false
|
||||
|
||||
- name: libreforge
|
||||
required: false
|
||||
bootstrap: false
|
||||
|
||||
load-after:
|
||||
- name: eco
|
||||
bootstrap: false
|
||||
@@ -1,5 +1,5 @@
|
||||
name: Boosters
|
||||
version: ${projectVersion}
|
||||
name: ${pluginName}
|
||||
version: ${version}
|
||||
main: com.willfp.boosters.BoostersPlugin
|
||||
api-version: 1.17
|
||||
authors: [ Auxilor ]
|
||||
@@ -7,17 +7,7 @@ website: willfp.com
|
||||
depend:
|
||||
- eco
|
||||
softdepend:
|
||||
- AureliumSkills
|
||||
- Jobs
|
||||
- mcMMO
|
||||
- Vault
|
||||
- TMMobcoins
|
||||
- EcoEnchants
|
||||
- EcoBosses
|
||||
- Talismans
|
||||
- EcoArmor
|
||||
- EcoItems
|
||||
- EcoSkills
|
||||
- libreforge
|
||||
|
||||
commands:
|
||||
boosters:
|
||||
@@ -41,8 +31,6 @@ permissions:
|
||||
boosters.command.boosters: true
|
||||
boosters.command.cancel: true
|
||||
boosters.command.activate: true
|
||||
boosters.command.import: true
|
||||
boosters.command.export: true
|
||||
|
||||
boosters.command.reload:
|
||||
description: Allows reloading the config
|
||||
@@ -58,10 +46,4 @@ permissions:
|
||||
default: op
|
||||
boosters.command.cancel:
|
||||
description: Allows the use of /boosters cancel.
|
||||
default: op
|
||||
boosters.command.import:
|
||||
description: Allows the use of /boosters import
|
||||
default: op
|
||||
boosters.command.export:
|
||||
description: Allows the use of /boosters export
|
||||
default: op
|
||||
Reference in New Issue
Block a user