Added booster placeholders
This commit is contained in:
@@ -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(
|
||||
|
||||
@@ -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)
|
||||
|
||||
@@ -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()
|
||||
}
|
||||
@@ -57,3 +60,8 @@ abstract class Booster(
|
||||
return this.plugin.configYml.getStrings("messages.${this.id}.expiry")
|
||||
}
|
||||
}
|
||||
|
||||
data class ActivatedBooster(
|
||||
val booster: Booster,
|
||||
val player: UUID
|
||||
)
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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
|
||||
}
|
||||
|
||||
|
||||
@@ -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:
|
||||
- ""
|
||||
@@ -39,3 +41,4 @@ messages:
|
||||
- " &fThe &a2x Skill XP Booster&f has ended"
|
||||
- " &fGet another one here: &ahttps://store.ecomc.net/package/756893"
|
||||
- ""
|
||||
name: "2x Skill XP Multiplier"
|
||||
@@ -1,2 +1,2 @@
|
||||
version = 1.2.0
|
||||
version = 1.3.0
|
||||
plugin-name = Boosters
|
||||
Reference in New Issue
Block a user