Added booster placeholders
This commit is contained in:
@@ -1,5 +1,6 @@
|
|||||||
package com.willfp.boosters
|
package com.willfp.boosters
|
||||||
|
|
||||||
|
import com.willfp.boosters.boosters.ActivatedBooster
|
||||||
import com.willfp.boosters.boosters.Booster
|
import com.willfp.boosters.boosters.Booster
|
||||||
import com.willfp.boosters.boosters.Boosters
|
import com.willfp.boosters.boosters.Boosters
|
||||||
import com.willfp.eco.core.data.PlayerProfile
|
import com.willfp.eco.core.data.PlayerProfile
|
||||||
@@ -9,10 +10,10 @@ import org.bukkit.Server
|
|||||||
import org.bukkit.Sound
|
import org.bukkit.Sound
|
||||||
import org.bukkit.entity.Player
|
import org.bukkit.entity.Player
|
||||||
|
|
||||||
private var active: Booster? = null
|
private var active: ActivatedBooster? = null
|
||||||
private val plugin = BoostersPlugin.instance
|
private val plugin = BoostersPlugin.instance
|
||||||
|
|
||||||
var Server.activeBooster: Booster?
|
var Server.activeBooster: ActivatedBooster?
|
||||||
get() {
|
get() {
|
||||||
return active
|
return active
|
||||||
}
|
}
|
||||||
@@ -63,7 +64,7 @@ fun Player.activateBooster(booster: Booster): Boolean {
|
|||||||
Bukkit.getServer().activeBooster = null
|
Bukkit.getServer().activeBooster = null
|
||||||
}
|
}
|
||||||
|
|
||||||
active = booster
|
active = ActivatedBooster(booster, this.uniqueId)
|
||||||
|
|
||||||
for (player in Bukkit.getOnlinePlayers()) {
|
for (player in Bukkit.getOnlinePlayers()) {
|
||||||
player.playSound(
|
player.playSound(
|
||||||
|
|||||||
@@ -4,9 +4,35 @@ import com.willfp.boosters.boosters.Boosters
|
|||||||
import com.willfp.boosters.commands.CommandBoosters
|
import com.willfp.boosters.commands.CommandBoosters
|
||||||
import com.willfp.eco.core.EcoPlugin
|
import com.willfp.eco.core.EcoPlugin
|
||||||
import com.willfp.eco.core.command.impl.PluginCommand
|
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
|
import org.bukkit.event.Listener
|
||||||
|
|
||||||
class BoostersPlugin : EcoPlugin() {
|
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() {
|
override fun handleReload() {
|
||||||
for (booster in Boosters.values()) {
|
for (booster in Boosters.values()) {
|
||||||
this.eventManager.unregisterListener(booster)
|
this.eventManager.unregisterListener(booster)
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import com.willfp.eco.core.data.keys.PersistentDataKeyType
|
|||||||
import com.willfp.eco.util.StringUtils
|
import com.willfp.eco.util.StringUtils
|
||||||
import org.bukkit.entity.Player
|
import org.bukkit.entity.Player
|
||||||
import org.bukkit.event.Listener
|
import org.bukkit.event.Listener
|
||||||
|
import java.util.UUID
|
||||||
|
|
||||||
abstract class Booster(
|
abstract class Booster(
|
||||||
private val plugin: BoostersPlugin,
|
private val plugin: BoostersPlugin,
|
||||||
@@ -19,6 +20,8 @@ abstract class Booster(
|
|||||||
0
|
0
|
||||||
)
|
)
|
||||||
|
|
||||||
|
val name = plugin.configYml.getFormattedString("message.${this.id}.name")
|
||||||
|
|
||||||
init {
|
init {
|
||||||
register()
|
register()
|
||||||
}
|
}
|
||||||
@@ -56,4 +59,9 @@ abstract class Booster(
|
|||||||
fun getExpiryMessages(): List<String> {
|
fun getExpiryMessages(): List<String> {
|
||||||
return this.plugin.configYml.getStrings("messages.${this.id}.expiry")
|
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)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
fun handle(event: ShopPreTransactionEvent) {
|
fun handle(event: ShopPreTransactionEvent) {
|
||||||
if (Bukkit.getServer().activeBooster != this) {
|
if (Bukkit.getServer().activeBooster?.booster != this) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ class Booster15SellMultiplier: Booster(
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
fun handle(event: DeluxeSellwandSellEvent) {
|
fun handle(event: DeluxeSellwandSellEvent) {
|
||||||
if (Bukkit.getServer().activeBooster != this) {
|
if (Bukkit.getServer().activeBooster?.booster != this) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -18,7 +18,7 @@ class Booster2SellMultiplier: Booster(
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
fun handle(event: ShopPreTransactionEvent) {
|
fun handle(event: ShopPreTransactionEvent) {
|
||||||
if (Bukkit.getServer().activeBooster != this) {
|
if (Bukkit.getServer().activeBooster?.booster != this) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -35,7 +35,7 @@ class Booster2SellMultiplier: Booster(
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
fun handle(event: DeluxeSellwandSellEvent) {
|
fun handle(event: DeluxeSellwandSellEvent) {
|
||||||
if (Bukkit.getServer().activeBooster != this) {
|
if (Bukkit.getServer().activeBooster?.booster != this) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -16,7 +16,7 @@ class BoosterSkillXP: Booster(
|
|||||||
|
|
||||||
@EventHandler(priority = EventPriority.HIGH)
|
@EventHandler(priority = EventPriority.HIGH)
|
||||||
fun onGainSkillXP(event: PlayerSkillExpGainEvent) {
|
fun onGainSkillXP(event: PlayerSkillExpGainEvent) {
|
||||||
if (Bukkit.getServer().activeBooster != this) {
|
if (Bukkit.getServer().activeBooster?.booster != this) {
|
||||||
return
|
return
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -17,6 +17,7 @@ messages:
|
|||||||
- " &fThe &a1.5x Sell Multiplier Booster&f has ended"
|
- " &fThe &a1.5x Sell Multiplier Booster&f has ended"
|
||||||
- " &fGet another one here: &ahttps://store.ecomc.net/package/756887"
|
- " &fGet another one here: &ahttps://store.ecomc.net/package/756887"
|
||||||
- ""
|
- ""
|
||||||
|
name: "1.5x Sell Multiplier"
|
||||||
2sell_multiplier:
|
2sell_multiplier:
|
||||||
activation:
|
activation:
|
||||||
- ""
|
- ""
|
||||||
@@ -28,6 +29,7 @@ messages:
|
|||||||
- " &fThe &a2x Sell Multiplier Booster&f has ended"
|
- " &fThe &a2x Sell Multiplier Booster&f has ended"
|
||||||
- " &fGet another one here: &ahttps://store.ecomc.net/package/756888"
|
- " &fGet another one here: &ahttps://store.ecomc.net/package/756888"
|
||||||
- ""
|
- ""
|
||||||
|
name: "2x Sell Multiplier"
|
||||||
skill_xp:
|
skill_xp:
|
||||||
activation:
|
activation:
|
||||||
- ""
|
- ""
|
||||||
@@ -38,4 +40,5 @@ messages:
|
|||||||
- ""
|
- ""
|
||||||
- " &fThe &a2x Skill XP Booster&f has ended"
|
- " &fThe &a2x Skill XP Booster&f has ended"
|
||||||
- " &fGet another one here: &ahttps://store.ecomc.net/package/756893"
|
- " &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
|
plugin-name = Boosters
|
||||||
Reference in New Issue
Block a user