Updated eco to 6.24.0
This commit is contained in:
@@ -56,12 +56,12 @@ fun Player.activateBooster(booster: Booster): Boolean {
|
|||||||
Bukkit.broadcastMessage(activationMessage)
|
Bukkit.broadcastMessage(activationMessage)
|
||||||
}
|
}
|
||||||
|
|
||||||
plugin.scheduler.runLater ({
|
plugin.scheduler.runLater(booster.duration.toLong()) {
|
||||||
for (expiryMessage in booster.getExpiryMessages()) {
|
for (expiryMessage in booster.getExpiryMessages()) {
|
||||||
Bukkit.broadcastMessage(expiryMessage)
|
Bukkit.broadcastMessage(expiryMessage)
|
||||||
}
|
}
|
||||||
Bukkit.getServer().activeBooster = null
|
Bukkit.getServer().activeBooster = null
|
||||||
}, booster.duration.toLong())
|
}
|
||||||
|
|
||||||
active = booster
|
active = booster
|
||||||
|
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ class BoostersPlugin : EcoPlugin() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
override fun getMinimumEcoVersion(): String {
|
override fun getMinimumEcoVersion(): String {
|
||||||
return "6.12.0"
|
return "6.24.0"
|
||||||
}
|
}
|
||||||
|
|
||||||
init {
|
init {
|
||||||
|
|||||||
@@ -10,10 +10,10 @@ import org.bukkit.event.Listener
|
|||||||
abstract class Booster(
|
abstract class Booster(
|
||||||
private val plugin: BoostersPlugin,
|
private val plugin: BoostersPlugin,
|
||||||
val id: String
|
val id: String
|
||||||
): Listener {
|
) : Listener {
|
||||||
abstract val duration: Int
|
abstract val duration: Int
|
||||||
|
|
||||||
val dataKey = PersistentDataKey<Int>(
|
val dataKey = PersistentDataKey(
|
||||||
plugin.namespacedKeyFactory.create(id),
|
plugin.namespacedKeyFactory.create(id),
|
||||||
PersistentDataKeyType.INT,
|
PersistentDataKeyType.INT,
|
||||||
0
|
0
|
||||||
@@ -35,6 +35,10 @@ abstract class Booster(
|
|||||||
return other.id == this.id
|
return other.id == this.id
|
||||||
}
|
}
|
||||||
|
|
||||||
|
override fun hashCode(): Int {
|
||||||
|
return this.id.hashCode()
|
||||||
|
}
|
||||||
|
|
||||||
fun getActivationMessages(player: Player): List<String> {
|
fun getActivationMessages(player: Player): List<String> {
|
||||||
val messages = mutableListOf<String>()
|
val messages = mutableListOf<String>()
|
||||||
|
|
||||||
|
|||||||
+6
-9
@@ -2,7 +2,6 @@ package com.willfp.boosters.commands
|
|||||||
|
|
||||||
import com.willfp.boosters.gui.BoosterGUI
|
import com.willfp.boosters.gui.BoosterGUI
|
||||||
import com.willfp.eco.core.EcoPlugin
|
import com.willfp.eco.core.EcoPlugin
|
||||||
import com.willfp.eco.core.command.CommandHandler
|
|
||||||
import com.willfp.eco.core.command.impl.PluginCommand
|
import com.willfp.eco.core.command.impl.PluginCommand
|
||||||
import org.bukkit.command.CommandSender
|
import org.bukkit.command.CommandSender
|
||||||
import org.bukkit.entity.Player
|
import org.bukkit.entity.Player
|
||||||
@@ -20,14 +19,12 @@ class CommandBoosters(plugin: EcoPlugin) :
|
|||||||
.addSubcommand(CommandReload(plugin))
|
.addSubcommand(CommandReload(plugin))
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getHandler(): CommandHandler {
|
override fun onExecute(sender: CommandSender, args: List<String>) {
|
||||||
return CommandHandler { sender: CommandSender, _: List<String> ->
|
if (sender !is Player) {
|
||||||
if (sender !is Player) {
|
sender.sendMessage(this.plugin.langYml.getMessage("not-player"))
|
||||||
sender.sendMessage(this.plugin.langYml.getMessage("not-player"))
|
return
|
||||||
return@CommandHandler
|
|
||||||
}
|
|
||||||
|
|
||||||
BoosterGUI.open(sender)
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
BoosterGUI.open(sender)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -4,8 +4,6 @@ import com.willfp.boosters.boosters.Boosters
|
|||||||
import com.willfp.boosters.getAmountOfBooster
|
import com.willfp.boosters.getAmountOfBooster
|
||||||
import com.willfp.boosters.setAmountOfBooster
|
import com.willfp.boosters.setAmountOfBooster
|
||||||
import com.willfp.eco.core.EcoPlugin
|
import com.willfp.eco.core.EcoPlugin
|
||||||
import com.willfp.eco.core.command.CommandHandler
|
|
||||||
import com.willfp.eco.core.command.TabCompleteHandler
|
|
||||||
import com.willfp.eco.core.command.impl.Subcommand
|
import com.willfp.eco.core.command.impl.Subcommand
|
||||||
import com.willfp.eco.util.StringUtils
|
import com.willfp.eco.util.StringUtils
|
||||||
import org.bukkit.Bukkit
|
import org.bukkit.Bukkit
|
||||||
@@ -19,69 +17,66 @@ class CommandGive(plugin: EcoPlugin) :
|
|||||||
"boosters.command.give",
|
"boosters.command.give",
|
||||||
false
|
false
|
||||||
) {
|
) {
|
||||||
override fun getHandler(): CommandHandler {
|
|
||||||
return CommandHandler { sender: CommandSender, args: List<String> ->
|
override fun onExecute(sender: CommandSender, args: List<String>) {
|
||||||
if (args.isEmpty()) {
|
if (args.isEmpty()) {
|
||||||
sender.sendMessage(plugin.langYml.getMessage("requires-player"))
|
sender.sendMessage(plugin.langYml.getMessage("requires-player"))
|
||||||
return@CommandHandler
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
if (args.size == 1) {
|
||||||
|
sender.sendMessage(plugin.langYml.getMessage("requires-booster"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
val booster = Boosters.getById(args[1].lowercase())
|
||||||
|
|
||||||
|
if (booster == null) {
|
||||||
|
sender.sendMessage(plugin.langYml.getMessage("invalid-booster"))
|
||||||
|
return
|
||||||
|
}
|
||||||
|
|
||||||
|
this.plugin.scheduler.runAsync {
|
||||||
|
@Suppress("DEPRECATION")
|
||||||
|
val player = Bukkit.getOfflinePlayer(args[0])
|
||||||
|
if (!player.hasPlayedBefore()) {
|
||||||
|
sender.sendMessage(plugin.langYml.getMessage("invalid-player"))
|
||||||
|
return@runAsync
|
||||||
}
|
}
|
||||||
|
|
||||||
if (args.size == 1) {
|
this.plugin.scheduler.run {
|
||||||
sender.sendMessage(plugin.langYml.getMessage("requires-booster"))
|
player.setAmountOfBooster(booster, player.getAmountOfBooster(booster) + 1)
|
||||||
return@CommandHandler
|
|
||||||
}
|
}
|
||||||
|
|
||||||
val booster = Boosters.getById(args[1].lowercase())
|
sender.sendMessage(
|
||||||
|
plugin.langYml.getMessage("gave-booster", StringUtils.FormatOption.WITHOUT_PLACEHOLDERS)
|
||||||
if (booster == null) {
|
.replace("%player%", player.name ?: return@runAsync)
|
||||||
sender.sendMessage(plugin.langYml.getMessage("invalid-booster"))
|
.replace("%booster%", booster.id)
|
||||||
return@CommandHandler
|
)
|
||||||
}
|
|
||||||
|
|
||||||
this.plugin.scheduler.runAsync {
|
|
||||||
@Suppress("DEPRECATION")
|
|
||||||
val player = Bukkit.getOfflinePlayer(args[0])
|
|
||||||
if (!player.hasPlayedBefore()) {
|
|
||||||
sender.sendMessage(plugin.langYml.getMessage("invalid-player"))
|
|
||||||
return@runAsync
|
|
||||||
}
|
|
||||||
|
|
||||||
this.plugin.scheduler.run {
|
|
||||||
player.setAmountOfBooster(booster, player.getAmountOfBooster(booster) + 1)
|
|
||||||
}
|
|
||||||
|
|
||||||
sender.sendMessage(
|
|
||||||
plugin.langYml.getMessage("gave-booster", StringUtils.FormatOption.WITHOUT_PLACEHOLDERS)
|
|
||||||
.replace("%player%", player.name?: return@runAsync)
|
|
||||||
.replace("%booster%", booster.id)
|
|
||||||
)
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
override fun getTabCompleter(): TabCompleteHandler {
|
override fun tabComplete(sender: CommandSender, args: List<String>): List<String> {
|
||||||
return TabCompleteHandler { _, args ->
|
val completions = mutableListOf<String>()
|
||||||
val completions = mutableListOf<String>()
|
|
||||||
|
|
||||||
if (args.size == 1) {
|
if (args.size == 1) {
|
||||||
StringUtil.copyPartialMatches(
|
StringUtil.copyPartialMatches(
|
||||||
args[0],
|
args[0],
|
||||||
Bukkit.getOnlinePlayers().map { player -> player.name }.toCollection(ArrayList()),
|
Bukkit.getOnlinePlayers().map { player -> player.name }.toCollection(ArrayList()),
|
||||||
completions
|
completions
|
||||||
)
|
)
|
||||||
return@TabCompleteHandler completions
|
return completions
|
||||||
}
|
|
||||||
|
|
||||||
if (args.size == 2) {
|
|
||||||
StringUtil.copyPartialMatches(
|
|
||||||
args[1],
|
|
||||||
Boosters.names(),
|
|
||||||
completions
|
|
||||||
)
|
|
||||||
return@TabCompleteHandler completions
|
|
||||||
}
|
|
||||||
|
|
||||||
return@TabCompleteHandler emptyList<String>()
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (args.size == 2) {
|
||||||
|
StringUtil.copyPartialMatches(
|
||||||
|
args[1],
|
||||||
|
Boosters.names(),
|
||||||
|
completions
|
||||||
|
)
|
||||||
|
return completions
|
||||||
|
}
|
||||||
|
|
||||||
|
return emptyList<String>()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -1,7 +1,6 @@
|
|||||||
package com.willfp.boosters.commands
|
package com.willfp.boosters.commands
|
||||||
|
|
||||||
import com.willfp.eco.core.EcoPlugin
|
import com.willfp.eco.core.EcoPlugin
|
||||||
import com.willfp.eco.core.command.CommandHandler
|
|
||||||
import com.willfp.eco.core.command.impl.Subcommand
|
import com.willfp.eco.core.command.impl.Subcommand
|
||||||
import org.bukkit.command.CommandSender
|
import org.bukkit.command.CommandSender
|
||||||
|
|
||||||
@@ -12,10 +11,9 @@ class CommandReload(plugin: EcoPlugin) :
|
|||||||
"boosters.command.reload",
|
"boosters.command.reload",
|
||||||
false
|
false
|
||||||
) {
|
) {
|
||||||
override fun getHandler(): CommandHandler {
|
|
||||||
return CommandHandler { sender: CommandSender, _: List<String> ->
|
override fun onExecute(sender: CommandSender, args: List<String>) {
|
||||||
plugin.reload()
|
plugin.reload()
|
||||||
sender.sendMessage(plugin.langYml.getMessage("reloaded"))
|
sender.sendMessage(plugin.langYml.getMessage("reloaded"))
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -6,12 +6,13 @@ import com.willfp.boosters.activeBooster
|
|||||||
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.boosters.getAmountOfBooster
|
import com.willfp.boosters.getAmountOfBooster
|
||||||
import com.willfp.eco.core.gui.menu.Menu
|
import com.willfp.eco.core.gui.menu
|
||||||
|
import com.willfp.eco.core.gui.slot
|
||||||
import com.willfp.eco.core.gui.slot.FillerMask
|
import com.willfp.eco.core.gui.slot.FillerMask
|
||||||
import com.willfp.eco.core.gui.slot.Slot
|
|
||||||
import com.willfp.eco.core.gui.slot.functional.SlotHandler
|
import com.willfp.eco.core.gui.slot.functional.SlotHandler
|
||||||
import com.willfp.eco.core.items.builder.SkullBuilder
|
import com.willfp.eco.core.items.builder.SkullBuilder
|
||||||
import com.willfp.eco.util.StringUtils
|
import com.willfp.eco.util.StringUtils
|
||||||
|
import com.willfp.eco.util.formatEco
|
||||||
import com.willfp.ecoskills.tryAsPlayer
|
import com.willfp.ecoskills.tryAsPlayer
|
||||||
import org.bukkit.Bukkit
|
import org.bukkit.Bukkit
|
||||||
import org.bukkit.Material
|
import org.bukkit.Material
|
||||||
@@ -51,8 +52,8 @@ object BoosterGUI {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private val gui = Menu.builder(3)
|
private val gui = menu(3) {
|
||||||
.setMask(
|
setMask(
|
||||||
FillerMask(
|
FillerMask(
|
||||||
Material.BLACK_STAINED_GLASS_PANE,
|
Material.BLACK_STAINED_GLASS_PANE,
|
||||||
"111111111",
|
"111111111",
|
||||||
@@ -60,16 +61,16 @@ object BoosterGUI {
|
|||||||
"111111111"
|
"111111111"
|
||||||
)
|
)
|
||||||
)
|
)
|
||||||
.setSlot(
|
setSlot(
|
||||||
2,
|
2,
|
||||||
2,
|
2,
|
||||||
Slot.builder(
|
slot(
|
||||||
SkullBuilder()
|
SkullBuilder()
|
||||||
.setSkullTexture("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTM0YjI3YmZjYzhmOWI5NjQ1OTRiNjE4YjExNDZhZjY5ZGUyNzhjZTVlMmUzMDEyY2I0NzFhOWEzY2YzODcxIn19fQ==")
|
.setSkullTexture("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYTM0YjI3YmZjYzhmOWI5NjQ1OTRiNjE4YjExNDZhZjY5ZGUyNzhjZTVlMmUzMDEyY2I0NzFhOWEzY2YzODcxIn19fQ==")
|
||||||
.build()
|
.build()
|
||||||
)
|
) {
|
||||||
.setModifier { player, _, previous ->
|
setUpdater { player, _, previous ->
|
||||||
val meta = previous.itemMeta ?: return@setModifier
|
val meta = previous.itemMeta ?: return@setUpdater previous
|
||||||
val lore = mutableListOf<String>()
|
val lore = mutableListOf<String>()
|
||||||
|
|
||||||
lore.add("")
|
lore.add("")
|
||||||
@@ -87,25 +88,23 @@ object BoosterGUI {
|
|||||||
|
|
||||||
meta.setDisplayName(StringUtils.format("&d1.5x Sell Multiplier"))
|
meta.setDisplayName(StringUtils.format("&d1.5x Sell Multiplier"))
|
||||||
|
|
||||||
meta.lore = lore.apply {
|
meta.lore = lore.formatEco()
|
||||||
replaceAll { StringUtils.format(it) }
|
|
||||||
}
|
|
||||||
previous.itemMeta = meta
|
previous.itemMeta = meta
|
||||||
|
previous
|
||||||
}
|
}
|
||||||
.onLeftClick(makeHandler(Boosters.SELL_MULTIPLIER_LOW))
|
onLeftClick(makeHandler(Boosters.SELL_MULTIPLIER_LOW))
|
||||||
.build()
|
})
|
||||||
)
|
|
||||||
.setSlot(
|
setSlot(
|
||||||
2,
|
2,
|
||||||
5,
|
5,
|
||||||
Slot.builder(
|
slot(
|
||||||
SkullBuilder()
|
SkullBuilder()
|
||||||
.setSkullTexture("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjBhN2I5NGM0ZTU4MWI2OTkxNTlkNDg4NDZlYzA5MTM5MjUwNjIzN2M4OWE5N2M5MzI0OGEwZDhhYmM5MTZkNSJ9fX0=")
|
.setSkullTexture("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvYjBhN2I5NGM0ZTU4MWI2OTkxNTlkNDg4NDZlYzA5MTM5MjUwNjIzN2M4OWE5N2M5MzI0OGEwZDhhYmM5MTZkNSJ9fX0=")
|
||||||
.build()
|
.build()
|
||||||
)
|
) {
|
||||||
.setModifier { player, _, previous ->
|
setUpdater { player, _, previous ->
|
||||||
val meta = previous.itemMeta ?: return@setModifier
|
val meta = previous.itemMeta ?: return@setUpdater previous
|
||||||
val lore = mutableListOf<String>()
|
val lore = mutableListOf<String>()
|
||||||
|
|
||||||
lore.add("")
|
lore.add("")
|
||||||
@@ -127,21 +126,22 @@ object BoosterGUI {
|
|||||||
replaceAll { StringUtils.format(it) }
|
replaceAll { StringUtils.format(it) }
|
||||||
}
|
}
|
||||||
previous.itemMeta = meta
|
previous.itemMeta = meta
|
||||||
|
previous
|
||||||
}
|
}
|
||||||
.onLeftClick(makeHandler(Boosters.SELL_MULTIPLIER_HIGH))
|
onLeftClick(makeHandler(Boosters.SELL_MULTIPLIER_HIGH))
|
||||||
.build()
|
build()
|
||||||
|
}
|
||||||
)
|
)
|
||||||
.setSlot(
|
setSlot(
|
||||||
2,
|
2,
|
||||||
8,
|
8,
|
||||||
Slot.builder(
|
slot(
|
||||||
SkullBuilder()
|
SkullBuilder()
|
||||||
.setSkullTexture("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODkyNmMxZjJjM2MxNGQwODZjNDBjZmMyMzVmZTkzODY5NGY0YTUxMDY3YWRhNDcyNmI0ODZlYTFjODdiMDNlMiJ9fX0=")
|
.setSkullTexture("eyJ0ZXh0dXJlcyI6eyJTS0lOIjp7InVybCI6Imh0dHA6Ly90ZXh0dXJlcy5taW5lY3JhZnQubmV0L3RleHR1cmUvODkyNmMxZjJjM2MxNGQwODZjNDBjZmMyMzVmZTkzODY5NGY0YTUxMDY3YWRhNDcyNmI0ODZlYTFjODdiMDNlMiJ9fX0=")
|
||||||
.build()
|
.build()
|
||||||
)
|
) {
|
||||||
.setModifier { player, _, previous ->
|
setUpdater { player, _, previous ->
|
||||||
val meta = previous.itemMeta ?: return@setModifier
|
val meta = previous.itemMeta ?: return@setUpdater previous
|
||||||
val lore = mutableListOf<String>()
|
val lore = mutableListOf<String>()
|
||||||
|
|
||||||
lore.add("")
|
lore.add("")
|
||||||
@@ -163,13 +163,13 @@ object BoosterGUI {
|
|||||||
replaceAll { StringUtils.format(it) }
|
replaceAll { StringUtils.format(it) }
|
||||||
}
|
}
|
||||||
previous.itemMeta = meta
|
previous.itemMeta = meta
|
||||||
|
previous
|
||||||
}
|
}
|
||||||
.onLeftClick(makeHandler(Boosters.SKILL_XP))
|
onLeftClick(makeHandler(Boosters.SKILL_XP))
|
||||||
.build()
|
}
|
||||||
)
|
)
|
||||||
.setTitle("Boosters")
|
setTitle("Boosters")
|
||||||
.build()
|
}
|
||||||
|
|
||||||
fun open(player: Player) {
|
fun open(player: Player) {
|
||||||
gui.open(player)
|
gui.open(player)
|
||||||
|
|||||||
@@ -10,8 +10,6 @@ depend:
|
|||||||
- PlaceholderAPI
|
- PlaceholderAPI
|
||||||
- EcoSkills
|
- EcoSkills
|
||||||
- ShopGUIPlus
|
- ShopGUIPlus
|
||||||
libraries:
|
|
||||||
- org.jetbrains.kotlin:kotlin-stdlib:1.5.21
|
|
||||||
|
|
||||||
commands:
|
commands:
|
||||||
boosters:
|
boosters:
|
||||||
|
|||||||
+1
-1
@@ -1,2 +1,2 @@
|
|||||||
version = 1.1.2
|
version = 1.2.0
|
||||||
plugin-name = Boosters
|
plugin-name = Boosters
|
||||||
Reference in New Issue
Block a user