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 ef16806..8bc58ee 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,5 +1,6 @@ package com.willfp.boosters +import com.willfp.boosters.boosters.ActivatedBooster import com.willfp.boosters.boosters.Booster import com.willfp.boosters.boosters.Boosters import com.willfp.eco.core.data.PlayerProfile @@ -9,10 +10,10 @@ import org.bukkit.Server import org.bukkit.Sound import org.bukkit.entity.Player -private var active: Booster? = null +private var active: ActivatedBooster? = null private val plugin = BoostersPlugin.instance -var Server.activeBooster: Booster? +var Server.activeBooster: ActivatedBooster? get() { return active } @@ -63,7 +64,7 @@ fun Player.activateBooster(booster: Booster): Boolean { Bukkit.getServer().activeBooster = null } - active = booster + active = ActivatedBooster(booster, this.uniqueId) for (player in Bukkit.getOnlinePlayers()) { player.playSound( 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 b4277d4..78beba2 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 @@ -4,9 +4,35 @@ import com.willfp.boosters.boosters.Boosters import com.willfp.boosters.commands.CommandBoosters import com.willfp.eco.core.EcoPlugin 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 org.bukkit.Bukkit import org.bukkit.event.Listener class BoostersPlugin : EcoPlugin() { + override fun handleEnable() { + PlaceholderManager.registerPlaceholder( + PlaceholderEntry( + this, + "booster_info", + { + val booster = server.activeBooster + + if (booster == null) { + return@PlaceholderEntry "&cThere is no booster currently active!" + .formatEco(formatPlaceholders = false) + } else { + return@PlaceholderEntry "${Bukkit.getOfflinePlayer(booster.player).savedDisplayName} &fHas activated a &a${booster.booster.name}&f!" + .formatEco(formatPlaceholders = false) + } + }, + false + ) + ) + } + override fun handleReload() { for (booster in Boosters.values()) { this.eventManager.unregisterListener(booster) 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 7e73a67..127d412 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 @@ -6,6 +6,7 @@ import com.willfp.eco.core.data.keys.PersistentDataKeyType import com.willfp.eco.util.StringUtils import org.bukkit.entity.Player import org.bukkit.event.Listener +import java.util.UUID abstract class Booster( private val plugin: BoostersPlugin, @@ -19,6 +20,8 @@ abstract class Booster( 0 ) + val name = plugin.configYml.getFormattedString("message.${this.id}.name") + init { register() } @@ -56,4 +59,9 @@ abstract class Booster( fun getExpiryMessages(): List { return this.plugin.configYml.getStrings("messages.${this.id}.expiry") } -} \ No newline at end of file +} + +data class ActivatedBooster( + val booster: Booster, + val player: UUID +) 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 index 2ec5c2f..b1c144f 100644 --- 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 @@ -18,7 +18,7 @@ class Booster15SellMultiplier: Booster( @EventHandler(priority = EventPriority.HIGH) fun handle(event: ShopPreTransactionEvent) { - if (Bukkit.getServer().activeBooster != this) { + if (Bukkit.getServer().activeBooster?.booster != this) { return } @@ -35,7 +35,7 @@ class Booster15SellMultiplier: Booster( @EventHandler(priority = EventPriority.HIGH) fun handle(event: DeluxeSellwandSellEvent) { - if (Bukkit.getServer().activeBooster != this) { + if (Bukkit.getServer().activeBooster?.booster != this) { return } 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 index 8210c0c..571a347 100644 --- 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 @@ -18,7 +18,7 @@ class Booster2SellMultiplier: Booster( @EventHandler(priority = EventPriority.HIGH) fun handle(event: ShopPreTransactionEvent) { - if (Bukkit.getServer().activeBooster != this) { + if (Bukkit.getServer().activeBooster?.booster != this) { return } @@ -35,7 +35,7 @@ class Booster2SellMultiplier: Booster( @EventHandler(priority = EventPriority.HIGH) fun handle(event: DeluxeSellwandSellEvent) { - if (Bukkit.getServer().activeBooster != this) { + if (Bukkit.getServer().activeBooster?.booster != this) { return } 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 index f3d32cc..2eaa5a7 100644 --- 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 @@ -16,7 +16,7 @@ class BoosterSkillXP: Booster( @EventHandler(priority = EventPriority.HIGH) fun onGainSkillXP(event: PlayerSkillExpGainEvent) { - if (Bukkit.getServer().activeBooster != this) { + if (Bukkit.getServer().activeBooster?.booster != this) { return } diff --git a/eco-core/core-plugin/src/main/resources/config.yml b/eco-core/core-plugin/src/main/resources/config.yml index fdd2d33..d72974c 100644 --- a/eco-core/core-plugin/src/main/resources/config.yml +++ b/eco-core/core-plugin/src/main/resources/config.yml @@ -17,6 +17,7 @@ messages: - " &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: - "" @@ -28,6 +29,7 @@ messages: - " &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: - "" @@ -38,4 +40,5 @@ messages: - "" - " &fThe &a2x Skill XP Booster&f has ended" - " &fGet another one here: &ahttps://store.ecomc.net/package/756893" - - "" \ No newline at end of file + - "" + name: "2x Skill XP Multiplier" \ No newline at end of file diff --git a/gradle.properties b/gradle.properties index 18e68f7..4d40349 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,2 +1,2 @@ -version = 1.2.0 +version = 1.3.0 plugin-name = Boosters \ No newline at end of file