diff --git a/build.gradle b/build.gradle index c97d5af..6da4309 100644 --- a/build.gradle +++ b/build.gradle @@ -4,7 +4,7 @@ buildscript { } dependencies { - classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.5.21" + classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:1.6.10" } } @@ -30,21 +30,23 @@ allprojects { mavenLocal() maven { url 'https://jitpack.io' } maven { url 'https://hub.spigotmc.org/nexus/content/repositories/snapshots/' } - maven { url 'https://repo.codemc.org/repository/nms/' } - maven { url 'https://repo.codemc.io/repository/maven-public/' } - maven { url 'https://repo.dmulloy2.net/repository/public/' } - maven { url 'https://repo.essentialsx.net/releases/' } } jar { onlyIf { !sourceSets.main.allSource.files.isEmpty() } } + shadowJar { + relocate('com.willfp.libreforge', 'com.willfp.boosters.libreforge') + } + dependencies { compileOnly 'com.willfp:eco:6.24.0' + implementation 'com.willfp:libreforge:3.17.0' - compileOnly 'org.jetbrains:annotations:19.0.0' - compileOnly 'org.jetbrains.kotlin:kotlin-stdlib:1.5.21' + compileOnly 'org.jetbrains:annotations:22.0.0' + + compileOnly 'org.jetbrains.kotlin:kotlin-stdlib:1.6.10' } tasks.withType(JavaCompile) { diff --git a/eco-core/core-plugin/build.gradle b/eco-core/core-plugin/build.gradle index 752d0b7..f18c142 100644 --- a/eco-core/core-plugin/build.gradle +++ b/eco-core/core-plugin/build.gradle @@ -2,12 +2,14 @@ group 'com.willfp' version rootProject.version dependencies { - compileOnly 'org.spigotmc:spigot-api:1.16.4-R0.1-SNAPSHOT' - compileOnly 'com.gmail.filoghost.holographicdisplays:holographicdisplays-api:2.4.0' - compileOnly 'com.comphenix.protocol:ProtocolLib:4.7.0' - compileOnly 'com.willfp:EcoEnchants:8.2.0' - compileOnly 'com.willfp:EcoSkills:1.2.4' - compileOnly 'com.github.brcdev-minecraft:shopgui-api:2.2.0' + compileOnly 'org.spigotmc:spigot-api:1.16.5-R0.1-SNAPSHOT' +} - compileOnly fileTree(dir: '../../lib', include: ['*.jar']) -} \ No newline at end of file +publishing { + publications { + Library(MavenPublication) { + from project.components.java + artifact tasks.shadowJar + } + } +} diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/BoosterHandlers.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/BoosterHandlers.kt index 8bc58ee..23c7a1e 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/BoosterHandlers.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/BoosterHandlers.kt @@ -1,3 +1,5 @@ +@file:JvmName("BoosterHandlers") + package com.willfp.boosters import com.willfp.boosters.boosters.ActivatedBooster @@ -6,14 +8,13 @@ import com.willfp.boosters.boosters.Boosters import com.willfp.eco.core.data.PlayerProfile import org.bukkit.Bukkit import org.bukkit.OfflinePlayer -import org.bukkit.Server import org.bukkit.Sound import org.bukkit.entity.Player private var active: ActivatedBooster? = null private val plugin = BoostersPlugin.instance -var Server.activeBooster: ActivatedBooster? +var activeBooster: ActivatedBooster? get() { return active } @@ -58,10 +59,10 @@ fun Player.activateBooster(booster: Booster): Boolean { } plugin.scheduler.runLater(booster.duration.toLong()) { - for (expiryMessage in booster.getExpiryMessages()) { + for (expiryMessage in booster.expiryMessages) { Bukkit.broadcastMessage(expiryMessage) } - Bukkit.getServer().activeBooster = null + activeBooster = null } active = ActivatedBooster(booster, this.uniqueId) @@ -77,4 +78,3 @@ fun Player.activateBooster(booster: Booster): Boolean { return true } - diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/BoostersPlugin.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/BoostersPlugin.kt index 2bbd720..7d86d63 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/BoostersPlugin.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/BoostersPlugin.kt @@ -1,30 +1,34 @@ package com.willfp.boosters -import com.willfp.boosters.boosters.Boosters import com.willfp.boosters.commands.CommandBoosters -import com.willfp.eco.core.EcoPlugin +import com.willfp.boosters.config.BoostersYml import com.willfp.eco.core.command.impl.PluginCommand import com.willfp.eco.core.integrations.placeholder.PlaceholderEntry import com.willfp.eco.core.integrations.placeholder.PlaceholderManager 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 -class BoostersPlugin : EcoPlugin() { - override fun handleEnable() { +class BoostersPlugin : LibReforgePlugin(0, 0, "") { + val boostersYml = BoostersYml(this) + + override fun handleEnableAdditional() { PlaceholderManager.registerPlaceholder( PlaceholderEntry( this, "booster_info", { - val booster = server.activeBooster + val booster = activeBooster if (booster == null) { - return@PlaceholderEntry "&cThere is no booster currently active!" + return@PlaceholderEntry this.langYml.getString("no-currently-active") .formatEco(formatPlaceholders = false) } else { - return@PlaceholderEntry "${Bukkit.getOfflinePlayer(booster.player).savedDisplayName} &fhas activated a &a${booster.booster.name}&f!" + return@PlaceholderEntry this.langYml.getString("active-placeholder") + .replace("%player%", Bukkit.getOfflinePlayer(booster.player).savedDisplayName) + .replace("%booster%", booster.booster.name) .formatEco(formatPlaceholders = false) } }, @@ -33,16 +37,6 @@ class BoostersPlugin : EcoPlugin() { ) } - override fun handleReload() { - for (booster in Boosters.values()) { - this.eventManager.unregisterListener(booster) - this.eventManager.registerListener(booster) - } - } - - override fun handleDisable() { - } - override fun loadListeners(): List { return listOf( @@ -66,4 +60,4 @@ class BoostersPlugin : EcoPlugin() { companion object { lateinit var instance: BoostersPlugin } -} \ No newline at end of file +} diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/boosters/Booster.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/boosters/Booster.kt index 141d978..a1721c8 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/boosters/Booster.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/boosters/Booster.kt @@ -1,18 +1,26 @@ package com.willfp.boosters.boosters import com.willfp.boosters.BoostersPlugin +import com.willfp.boosters.getAmountOfBooster +import com.willfp.eco.core.config.interfaces.Config import com.willfp.eco.core.data.keys.PersistentDataKey import com.willfp.eco.core.data.keys.PersistentDataKeyType +import com.willfp.eco.core.items.Items +import com.willfp.eco.core.items.builder.ItemStackBuilder import com.willfp.eco.util.StringUtils +import com.willfp.eco.util.formatEco +import com.willfp.libreforge.Holder +import com.willfp.libreforge.conditions.Conditions +import com.willfp.libreforge.effects.Effects import org.bukkit.entity.Player -import org.bukkit.event.Listener +import org.bukkit.inventory.ItemStack import java.util.UUID -abstract class Booster( - private val plugin: BoostersPlugin, - val id: String -) : Listener { - abstract val duration: Int +class Booster( + plugin: BoostersPlugin, + val config: Config, +) : Holder { + val id = config.getString("id") val dataKey = PersistentDataKey( plugin.namespacedKeyFactory.create(id), @@ -20,14 +28,50 @@ abstract class Booster( 0 ) - val name = plugin.configYml.getFormattedString("messages.${this.id}.name") + val name = config.getFormattedString("name") - init { - register() + val duration = config.getInt("duration") + + fun getActivationMessages(player: Player): List { + val messages = mutableListOf() + + for (string in config.getFormattedStrings( + "messages.activation", + StringUtils.FormatOption.WITHOUT_PLACEHOLDERS + )) { + messages.add(string.replace("%player%", player.displayName)) + } + + return messages } - private fun register() { - Boosters.registerNewBooster(this) + val expiryMessages = config.getStrings("messages.expiry") + + fun getGuiItem(player: Player): ItemStack { + return ItemStackBuilder(Items.lookup(config.getString("gui.item"))) + .setDisplayName(config.getFormattedString("gui.name")) + .addLoreLines( + config.getFormattedStrings("gui.lore", StringUtils.FormatOption.WITHOUT_PLACEHOLDERS) + .map { it.replace("%amount%", player.getAmountOfBooster(this).toString()) } + .formatEco(player) + ) + .build() + } + + val guiRow = config.getInt("gui.position.row") + + val guiColumn = config.getInt("gui.position.column") + + override val conditions = config.getSubsections("conditions").mapNotNull { + Conditions.compile(it, "Booster $id") + }.toSet() + + override val effects = config.getSubsections("effects").mapNotNull { + Effects.compile(it, "Booster $id") + }.toSet() + + init { + Boosters.addNewBooster(this) } override fun equals(other: Any?): Boolean { @@ -41,23 +85,6 @@ abstract class Booster( override fun hashCode(): Int { return this.id.hashCode() } - - fun getActivationMessages(player: Player): List { - val messages = mutableListOf() - - for (string in this.plugin.configYml.getFormattedStrings( - "messages.${this.id}.activation", - StringUtils.FormatOption.WITHOUT_PLACEHOLDERS - )) { - messages.add(string.replace("%player%", player.displayName)) - } - - return messages - } - - fun getExpiryMessages(): List { - return this.plugin.configYml.getFormattedStrings("messages.${this.id}.expiry") - } } data class ActivatedBooster( diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/boosters/Boosters.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/boosters/Boosters.kt index 02ef409..403ac31 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/boosters/Boosters.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/boosters/Boosters.kt @@ -1,29 +1,76 @@ package com.willfp.boosters.boosters -import com.willfp.boosters.boosters.boosters.Booster15SellMultiplier -import com.willfp.boosters.boosters.boosters.Booster2SellMultiplier -import com.willfp.boosters.boosters.boosters.BoosterSkillXP +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.updating.ConfigUpdater +import com.willfp.libreforge.chains.EffectChains object Boosters { - private val byId = mutableMapOf() - - val SKILL_XP = BoosterSkillXP() - val SELL_MULTIPLIER_LOW = Booster15SellMultiplier() - val SELL_MULTIPLIER_HIGH = Booster2SellMultiplier() - - fun getById(id: String): Booster? { - return byId[id.lowercase()] - } - - fun registerNewBooster(booster: Booster) { - byId[booster.id] = booster - } + /** + * Registered boosters. + */ + private val BY_ID: BiMap = HashBiMap.create() + /** + * Get all registered [Booster]s. + * + * @return A list of all [Booster]s. + */ + @JvmStatic fun values(): List { - return byId.values.toList() + return ImmutableList.copyOf(BY_ID.values) } - fun names(): List { - return byId.keys.toList() + /** + * Get [Booster] matching ID. + * + * @param name The name to search for. + * @return The matching [Booster], or null if not found. + */ + @JvmStatic + fun getByID(name: String): Booster? { + return BY_ID[name] } -} \ No newline at end of file + + /** + * Update all [Booster]s. + * + * @param plugin Instance of Booster. + */ + @ConfigUpdater + @JvmStatic + fun update(plugin: BoostersPlugin) { + plugin.boostersYml.getSubsections("chains").mapNotNull { + EffectChains.compile(it, "Effect Chains") + } + for (booster in values()) { + removeSet(booster) + } + for (config in plugin.boostersYml.getSubsections("boosters")) { + Booster(plugin, config) + } + } + + /** + * 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 removeSet(booster: Booster) { + BY_ID.remove(booster.id) + } +} diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/boosters/boosters/Booster15SellMultiplier.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/boosters/boosters/Booster15SellMultiplier.kt deleted file mode 100644 index b1c144f..0000000 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/boosters/boosters/Booster15SellMultiplier.kt +++ /dev/null @@ -1,48 +0,0 @@ -package com.willfp.boosters.boosters.boosters - -import com.willfp.boosters.BoostersPlugin -import com.willfp.boosters.activeBooster -import com.willfp.boosters.boosters.Booster -import dev.norska.dsw.api.DeluxeSellwandSellEvent -import net.brcdev.shopgui.event.ShopPreTransactionEvent -import net.brcdev.shopgui.shop.ShopManager -import org.bukkit.Bukkit -import org.bukkit.event.EventHandler -import org.bukkit.event.EventPriority - -class Booster15SellMultiplier: Booster( - BoostersPlugin.instance, - "1_5sell_multiplier" -) { - override val duration = 72000 - - @EventHandler(priority = EventPriority.HIGH) - fun handle(event: ShopPreTransactionEvent) { - if (Bukkit.getServer().activeBooster?.booster != this) { - return - } - - if (event.isCancelled) { - return - } - - if (event.shopAction == ShopManager.ShopAction.BUY) { - return - } - - event.price *= 1.5 - } - - @EventHandler(priority = EventPriority.HIGH) - fun handle(event: DeluxeSellwandSellEvent) { - if (Bukkit.getServer().activeBooster?.booster != this) { - return - } - - if (event.isCancelled) { - return - } - - event.money *= 1.5 - } -} \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/boosters/boosters/Booster2SellMultiplier.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/boosters/boosters/Booster2SellMultiplier.kt deleted file mode 100644 index 571a347..0000000 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/boosters/boosters/Booster2SellMultiplier.kt +++ /dev/null @@ -1,48 +0,0 @@ -package com.willfp.boosters.boosters.boosters - -import com.willfp.boosters.BoostersPlugin -import com.willfp.boosters.activeBooster -import com.willfp.boosters.boosters.Booster -import dev.norska.dsw.api.DeluxeSellwandSellEvent -import net.brcdev.shopgui.event.ShopPreTransactionEvent -import net.brcdev.shopgui.shop.ShopManager -import org.bukkit.Bukkit -import org.bukkit.event.EventHandler -import org.bukkit.event.EventPriority - -class Booster2SellMultiplier: Booster( - BoostersPlugin.instance, - "2sell_multiplier" -) { - override val duration = 72000 - - @EventHandler(priority = EventPriority.HIGH) - fun handle(event: ShopPreTransactionEvent) { - if (Bukkit.getServer().activeBooster?.booster != this) { - return - } - - if (event.isCancelled) { - return - } - - if (event.shopAction == ShopManager.ShopAction.BUY) { - return - } - - event.price *= 2 - } - - @EventHandler(priority = EventPriority.HIGH) - fun handle(event: DeluxeSellwandSellEvent) { - if (Bukkit.getServer().activeBooster?.booster != this) { - return - } - - if (event.isCancelled) { - return - } - - event.money *= 2 - } -} \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/boosters/boosters/BoosterSkillXP.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/boosters/boosters/BoosterSkillXP.kt deleted file mode 100644 index 2eaa5a7..0000000 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/boosters/boosters/BoosterSkillXP.kt +++ /dev/null @@ -1,29 +0,0 @@ -package com.willfp.boosters.boosters.boosters - -import com.willfp.boosters.BoostersPlugin -import com.willfp.boosters.activeBooster -import com.willfp.boosters.boosters.Booster -import com.willfp.ecoskills.api.PlayerSkillExpGainEvent -import org.bukkit.Bukkit -import org.bukkit.event.EventHandler -import org.bukkit.event.EventPriority - -class BoosterSkillXP: Booster( - BoostersPlugin.instance, - "skill_xp" -) { - override val duration = 72000 - - @EventHandler(priority = EventPriority.HIGH) - fun onGainSkillXP(event: PlayerSkillExpGainEvent) { - if (Bukkit.getServer().activeBooster?.booster != this) { - return - } - - if (event.isCancelled) { - return - } - - event.amount *= 2 - } -} \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/commands/CommandGive.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/commands/CommandGive.kt index 2232e3f..986f8e1 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/commands/CommandGive.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/commands/CommandGive.kt @@ -29,7 +29,7 @@ class CommandGive(plugin: EcoPlugin) : return } - val booster = Boosters.getById(args[1].lowercase()) + val booster = Boosters.getByID(args[1].lowercase()) if (booster == null) { sender.sendMessage(plugin.langYml.getMessage("invalid-booster")) @@ -71,12 +71,12 @@ class CommandGive(plugin: EcoPlugin) : if (args.size == 2) { StringUtil.copyPartialMatches( args[1], - Boosters.names(), + Boosters.values().map { it.id }, completions ) return completions } - return emptyList() + return emptyList() } } diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/config/BoostersYml.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/config/BoostersYml.kt new file mode 100644 index 0000000..e997a0b --- /dev/null +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/config/BoostersYml.kt @@ -0,0 +1,12 @@ +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 +) diff --git a/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/gui/BoosterGUI.kt b/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/gui/BoosterGUI.kt index 7a9349f..3373c5c 100644 --- a/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/gui/BoosterGUI.kt +++ b/eco-core/core-plugin/src/main/kotlin/com/willfp/boosters/gui/BoosterGUI.kt @@ -5,28 +5,25 @@ import com.willfp.boosters.activateBooster import com.willfp.boosters.activeBooster import com.willfp.boosters.boosters.Booster import com.willfp.boosters.boosters.Boosters -import com.willfp.boosters.getAmountOfBooster +import com.willfp.eco.core.config.updating.ConfigUpdater import com.willfp.eco.core.gui.menu +import com.willfp.eco.core.gui.menu.Menu import com.willfp.eco.core.gui.slot import com.willfp.eco.core.gui.slot.FillerMask +import com.willfp.eco.core.gui.slot.MaskItems import com.willfp.eco.core.gui.slot.functional.SlotHandler -import com.willfp.eco.core.items.builder.SkullBuilder -import com.willfp.eco.util.StringUtils -import com.willfp.eco.util.formatEco -import com.willfp.ecoskills.tryAsPlayer -import org.bukkit.Bukkit -import org.bukkit.Material +import com.willfp.libreforge.tryAsPlayer import org.bukkit.Sound import org.bukkit.entity.Player object BoosterGUI { - private val plugin = BoostersPlugin.instance + private lateinit var gui: Menu - private fun makeHandler(booster: Booster): SlotHandler { + private fun makeHandler(booster: Booster, plugin: BoostersPlugin): SlotHandler { return SlotHandler { event, _, _ -> val player = event.whoClicked.tryAsPlayer() ?: return@SlotHandler - if (Bukkit.getServer().activeBooster != null) { + if (activeBooster != null) { player.sendMessage(plugin.langYml.getMessage("already-active")) player.playSound( player.location, @@ -52,126 +49,37 @@ object BoosterGUI { } } - private val gui = menu(3) { - setMask( - FillerMask( - Material.BLACK_STAINED_GLASS_PANE, - "111111111", - "101101101", - "111111111" + @JvmStatic + @ConfigUpdater + fun update(plugin: BoostersPlugin) { + gui = menu(plugin.configYml.getInt("gui.rows")) { + setMask( + FillerMask( + MaskItems.fromItemNames(plugin.configYml.getStrings("gui.mask.items")), + *plugin.configYml.getStrings("gui.mask.pattern").toTypedArray() + ) ) - ) - setSlot( - 2, - 2, - slot( - SkullBuilder() - .setSkullTexture("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTM0YjI3YmZjYzhmOWI5NjQ1OTRiNjE4YjExNDZhZjY5ZGUyNzhjZTVlMmUzMDEyY2I0NzFhOWEzY2YzODcxIn19fQ==") - .build() - ) { - setUpdater { player, _, previous -> - val meta = previous.itemMeta ?: return@setUpdater previous - val lore = mutableListOf() - lore.add("") - lore.add("&fGives everyone online a") - lore.add("&a1.5x Sell Multiplier") - lore.add("&fto make money faster!") - lore.add("") - lore.add("&fDuration: &a1 Hour") - lore.add("") - lore.add("&fYou have: &a${player.getAmountOfBooster(Boosters.SELL_MULTIPLIER_LOW)}") - lore.add("&fGet more at &astore.ecomc.net") - lore.add("") - lore.add("&e&oClick to activate!") - lore.add("") - - meta.setDisplayName(StringUtils.format("&d1.5x Sell Multiplier")) - - meta.lore = lore.formatEco() - previous.itemMeta = meta - previous - } - onLeftClick(makeHandler(Boosters.SELL_MULTIPLIER_LOW)) - }) - - setSlot( - 2, - 5, - slot( - SkullBuilder() - .setSkullTexture("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjBhN2I5NGM0ZTU4MWI2OTkxNTlkNDg4NDZlYzA5MTM5MjUwNjIzN2M4OWE5N2M5MzI0OGEwZDhhYmM5MTZkNSJ9fX0=") - .build() - ) { - setUpdater { player, _, previous -> - val meta = previous.itemMeta ?: return@setUpdater previous - val lore = mutableListOf() - - lore.add("") - lore.add("&fGives everyone online a") - lore.add("&a2x Sell Multiplier") - lore.add("&fto make money faster!") - lore.add("") - lore.add("&fDuration: &a1 Hour") - lore.add("") - lore.add("&fYou have: &a${player.getAmountOfBooster(Boosters.SELL_MULTIPLIER_HIGH)}") - lore.add("&fGet more at &astore.ecomc.net") - lore.add("") - lore.add("&e&oClick to activate!") - lore.add("") - - meta.setDisplayName(StringUtils.format("&d2x Sell Multiplier")) - - meta.lore = lore.apply { - replaceAll { StringUtils.format(it) } + for (booster in Boosters.values()) { + setSlot( + booster.guiRow, + booster.guiColumn, + slot( + { player, _ -> booster.getGuiItem(player) } + ) { + setUpdater { player, _, _ -> + booster.getGuiItem(player) + } + onLeftClick(makeHandler(booster, plugin)) } - previous.itemMeta = meta - previous - } - onLeftClick(makeHandler(Boosters.SELL_MULTIPLIER_HIGH)) - build() + ) } - ) - setSlot( - 2, - 8, - slot( - SkullBuilder() - .setSkullTexture("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODkyNmMxZjJjM2MxNGQwODZjNDBjZmMyMzVmZTkzODY5NGY0YTUxMDY3YWRhNDcyNmI0ODZlYTFjODdiMDNlMiJ9fX0=") - .build() - ) { - setUpdater { player, _, previous -> - val meta = previous.itemMeta ?: return@setUpdater previous - val lore = mutableListOf() - lore.add("") - lore.add("&fGives everyone online a") - lore.add("&a2x Skill XP Multiplier") - lore.add("&fto level up faster!") - lore.add("") - lore.add("&fDuration: &a1 Hour") - lore.add("") - lore.add("&fYou have: &a${player.getAmountOfBooster(Boosters.SKILL_XP)}") - lore.add("&fGet more at &astore.ecomc.net") - lore.add("") - lore.add("&e&oClick to activate!") - lore.add("") - - meta.setDisplayName(StringUtils.format("&d2x Skill XP Multiplier")) - - meta.lore = lore.apply { - replaceAll { StringUtils.format(it) } - } - previous.itemMeta = meta - previous - } - onLeftClick(makeHandler(Boosters.SKILL_XP)) - } - ) - setTitle("Boosters") + setTitle(plugin.configYml.getFormattedString("gui.title")) + } } fun open(player: Player) { gui.open(player) } -} \ No newline at end of file +} diff --git a/eco-core/core-plugin/src/main/resources/boosters.yml b/eco-core/core-plugin/src/main/resources/boosters.yml new file mode 100644 index 0000000..5a3401d --- /dev/null +++ b/eco-core/core-plugin/src/main/resources/boosters.yml @@ -0,0 +1,115 @@ +boosters: + - id: 1_5sell_multiplier + name: "1.5x Sell Multiplier" + duration: 72000 + effects: + - id: sell_multiplier + args: + multiplier: 1.5 + conditions: [] + 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: 1.5 + conditions: [] + 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: 1.5 + conditions: [] + 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 \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/config.yml b/eco-core/core-plugin/src/main/resources/config.yml index d72974c..88c72a3 100644 --- a/eco-core/core-plugin/src/main/resources/config.yml +++ b/eco-core/core-plugin/src/main/resources/config.yml @@ -3,42 +3,41 @@ # by Auxilor # -log-autosaves: true # If auto-save messages should be sent to console +gui: + title: Boosters + rows: 3 + mask: + items: + - black_stained_glass_Pane + pattern: + - "111111111" + - "101101101" + - "111111111" -messages: - 1_5sell_multiplier: - 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" - - "" - name: "1.5x Sell Multiplier" - 2sell_multiplier: - 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" - - "" - name: "2x Sell Multiplier" - skill_xp: - 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" - - "" - name: "2x Skill XP Multiplier" \ No newline at end of file +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 + +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 +block-item-drop-place-check: true # If the block_item_drop trigger should only fire on naturally placed blocks (prevents dupes) \ No newline at end of file diff --git a/eco-core/core-plugin/src/main/resources/lang.yml b/eco-core/core-plugin/src/main/resources/lang.yml index cb2514c..51b379d 100644 --- a/eco-core/core-plugin/src/main/resources/lang.yml +++ b/eco-core/core-plugin/src/main/resources/lang.yml @@ -11,3 +11,9 @@ messages: gave-booster: "Gave %player% %booster%!" already-active: "&cA booster is already active!" dont-have: "&cYou don't have any of these boosters! Get some at &astore.ecomc.net" + on-cooldown: "&cThis effect is on cooldown! &fTime left: &a%seconds% seconds" + 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%" + +no-currently-active: "&cThere is no booster currently active!" +active-placeholder: "%player% &fhas activated a %booster%&f!" diff --git a/eco-core/core-plugin/src/main/resources/plugin.yml b/eco-core/core-plugin/src/main/resources/plugin.yml index 94a088f..f3305c1 100644 --- a/eco-core/core-plugin/src/main/resources/plugin.yml +++ b/eco-core/core-plugin/src/main/resources/plugin.yml @@ -8,9 +8,6 @@ load: POSTWORLD depend: - eco - PlaceholderAPI - - EcoSkills - - ShopGUIPlus - - DeluxeSellwands commands: boosters: diff --git a/gradle.properties b/gradle.properties index 8ca4522..3efb77c 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ -version = 1.3.2 +version = 2.0.0 plugin-name = Boosters \ No newline at end of file diff --git a/lib/DeluxeSellwands Build 22e.jar b/lib/DeluxeSellwands Build 22e.jar deleted file mode 100644 index f290560..0000000 Binary files a/lib/DeluxeSellwands Build 22e.jar and /dev/null differ