@@ -9,6 +9,8 @@ import com.willfp.ecocrates.config.CratesYml
|
||||
import com.willfp.ecocrates.config.RewardsYml
|
||||
import com.willfp.ecocrates.converters.Converters
|
||||
import com.willfp.ecocrates.converters.cratereloaded.CrateReloadedConverter
|
||||
import com.willfp.ecocrates.converters.crazycrates.CrazyCratesConverter
|
||||
import com.willfp.ecocrates.converters.excellentcrates.ExcellentCratesConverter
|
||||
import com.willfp.ecocrates.crate.CrateKeyListener
|
||||
import com.willfp.ecocrates.crate.placed.CrateDisplay
|
||||
import com.willfp.ecocrates.crate.placed.PlacedCrates
|
||||
@@ -53,6 +55,12 @@ class EcoCratesPlugin : EcoPlugin() {
|
||||
return mutableListOf(
|
||||
IntegrationLoader("CrateReloaded") {
|
||||
Converters.registerConverter(CrateReloadedConverter(this))
|
||||
},
|
||||
IntegrationLoader("ExcellentCrates") {
|
||||
Converters.registerConverter(ExcellentCratesConverter(this))
|
||||
},
|
||||
IntegrationLoader("CrazyCrates") {
|
||||
Converters.registerConverter(CrazyCratesConverter(this))
|
||||
}
|
||||
)
|
||||
}
|
||||
|
||||
@@ -0,0 +1,119 @@
|
||||
package com.willfp.ecocrates.converters.crazycrates
|
||||
|
||||
import com.badbones69.crazycrates.api.CrazyManager
|
||||
import com.badbones69.crazycrates.api.objects.Crate
|
||||
import com.badbones69.crazycrates.api.objects.Prize
|
||||
import com.willfp.eco.core.config.BuildableConfig
|
||||
import com.willfp.eco.core.config.interfaces.Config
|
||||
import com.willfp.ecocrates.EcoCratesPlugin
|
||||
import com.willfp.ecocrates.converters.Converter
|
||||
import com.willfp.ecocrates.converters.util.ConversionHelpers
|
||||
import com.willfp.ecocrates.converters.util.toLookupString
|
||||
import com.willfp.ecocrates.crate.Crates
|
||||
import com.willfp.ecocrates.crate.placed.PlacedCrates
|
||||
|
||||
class CrazyCratesConverter(private val plugin: EcoCratesPlugin) : Converter {
|
||||
override val id = "CrazyCrates"
|
||||
|
||||
override fun convert() {
|
||||
val newCrates = CrazyManager.getInstance().crates.map { convertCrate(it) }
|
||||
|
||||
val crates = plugin.cratesYml.getSubsections("crates").toMutableList()
|
||||
|
||||
crates.addAll(newCrates)
|
||||
|
||||
plugin.cratesYml.set("crates", crates)
|
||||
plugin.cratesYml.save()
|
||||
plugin.rewardsYml.save()
|
||||
plugin.reload()
|
||||
|
||||
val jank = ArrayList(CrazyManager.getInstance().crateLocations)
|
||||
|
||||
jank.forEach {
|
||||
CrazyManager.getInstance().removeCrateLocation(it.id)
|
||||
}
|
||||
|
||||
jank.forEach {
|
||||
val crate = Crates.getByID(it.crate.name.lowercase())!!
|
||||
PlacedCrates.setAsCrate(it.location, crate)
|
||||
}
|
||||
}
|
||||
|
||||
private fun convertCrate(crate: Crate): Config {
|
||||
val result = ConversionHelpers.createEmptyCrate()
|
||||
|
||||
val id = crate.name.lowercase()
|
||||
|
||||
result.set("id", id)
|
||||
result.set("name", crate.name)
|
||||
result.set("preview.title", crate.crateInventoryName)
|
||||
result.set("key.item", crate.key.toLookupString())
|
||||
result.set("key.lore", crate.key.itemMeta?.lore)
|
||||
result.set("keygui.item", "tripwire_hook unbreaking:1 hide_enchants name:\"${crate.name}\"")
|
||||
result.set("keygui.lore", mutableListOf(
|
||||
"<g:#56ab2f>${crate.name}</g:#a8e063>",
|
||||
"&fYou have %keys% keys",
|
||||
"&fGet more at &astore.example.net"
|
||||
))
|
||||
result.set("keygui.shift-left-click-messsage", mutableListOf(
|
||||
"Buy a ${crate.name}&r key here! &astore.example.net"
|
||||
))
|
||||
result.set("placed.hologram.height", crate.hologram.height)
|
||||
result.set("placed.hologram.frames", mutableListOf(
|
||||
BuildableConfig()
|
||||
.add("tick", 0)
|
||||
.add("lines", crate.hologram.messages)
|
||||
))
|
||||
result.set("open.broadcasts", mutableListOf("%player%&f is opening the ${crate.name}!"))
|
||||
result.set("finish.broadcasts", mutableListOf("%player%&f won %reward%&f from the ${crate.name}!"))
|
||||
|
||||
val newRewards = mutableListOf<Config>()
|
||||
var row = 2
|
||||
var col = 2
|
||||
var counter = 1
|
||||
crate.prizes.forEach {
|
||||
val salt = id + "_" + counter
|
||||
newRewards.add(convertReward(it, salt, row, col))
|
||||
col++
|
||||
if (col >= 8) {
|
||||
col = 2
|
||||
row++
|
||||
}
|
||||
if (row >= 5) {
|
||||
row = 2
|
||||
}
|
||||
counter++
|
||||
}
|
||||
|
||||
val rewards = plugin.rewardsYml.getSubsections("rewards").toMutableList()
|
||||
|
||||
rewards.addAll(newRewards)
|
||||
|
||||
plugin.rewardsYml.set("rewards", rewards)
|
||||
result.set("rewards", newRewards.map { it.getString("id") })
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
private fun convertReward(reward: Prize, salt: String, row: Int, col: Int): Config {
|
||||
val result = ConversionHelpers.createEmptyReward()
|
||||
|
||||
result.set("id", salt)
|
||||
|
||||
result.set("commands", reward.commands)
|
||||
result.set("items", reward.items.map { it.toLookupString() })
|
||||
|
||||
result.set("weight.actual", reward.chance)
|
||||
result.set("weight.display", reward.chance)
|
||||
|
||||
val meta = reward.displayItem.itemMeta
|
||||
|
||||
result.set("display.name", reward.name)
|
||||
result.set("display.item", reward.displayItem.toLookupString())
|
||||
result.set("display.lore", meta?.lore)
|
||||
result.set("display.row", row)
|
||||
result.set("display.column", col)
|
||||
|
||||
return result
|
||||
}
|
||||
}
|
||||
@@ -0,0 +1,136 @@
|
||||
package com.willfp.ecocrates.converters.excellentcrates
|
||||
|
||||
import com.willfp.eco.core.config.BuildableConfig
|
||||
import com.willfp.eco.core.config.interfaces.Config
|
||||
import com.willfp.ecocrates.EcoCratesPlugin
|
||||
import com.willfp.ecocrates.converters.Converter
|
||||
import com.willfp.ecocrates.converters.util.ConversionHelpers
|
||||
import com.willfp.ecocrates.converters.util.toLookupString
|
||||
import com.willfp.ecocrates.crate.Crates
|
||||
import com.willfp.ecocrates.crate.placed.PlacedCrate
|
||||
import com.willfp.ecocrates.crate.placed.PlacedCrates
|
||||
import org.bukkit.Location
|
||||
import su.nightexpress.excellentcrates.api.GoldenCratesAPI
|
||||
import su.nightexpress.excellentcrates.api.OpenCostType
|
||||
import su.nightexpress.excellentcrates.api.crate.ICrate
|
||||
import su.nightexpress.excellentcrates.api.crate.ICrateReward
|
||||
|
||||
@Suppress("UNCHECKED_CAST", "DEPRECATION")
|
||||
class ExcellentCratesConverter(private val plugin: EcoCratesPlugin) : Converter {
|
||||
|
||||
override val id = "ExcellentCrates"
|
||||
|
||||
override fun convert() {
|
||||
val newCrates = GoldenCratesAPI.getCrateManager().crates.map { convertCrate(it) }
|
||||
|
||||
val crates = plugin.cratesYml.getSubsections("crates").toMutableList()
|
||||
|
||||
crates.addAll(newCrates)
|
||||
|
||||
plugin.cratesYml.set("crates", crates)
|
||||
plugin.cratesYml.save()
|
||||
plugin.rewardsYml.save()
|
||||
plugin.reload()
|
||||
|
||||
GoldenCratesAPI.getCrateManager().crates.forEach {
|
||||
val jank = mutableListOf<Location>()
|
||||
jank.addAll(it.blockLocations)
|
||||
jank.forEach { it1 -> it.removeBlockLocation(it1) }
|
||||
jank.forEach { it1 -> PlacedCrates.setAsCrate(it1, Crates.getByID(it.id)!!)}
|
||||
}
|
||||
}
|
||||
|
||||
private fun convertCrate(crate: ICrate): Config {
|
||||
val result = ConversionHelpers.createEmptyCrate()
|
||||
|
||||
val id = crate.id
|
||||
|
||||
result.set("id", id)
|
||||
|
||||
result.set("name", crate.name)
|
||||
|
||||
if (crate.getOpenCost(OpenCostType.MONEY) > 0.0) {
|
||||
result.set("pay-to-open.enabled", true)
|
||||
result.set("pay-to-open.price", crate.getOpenCost(OpenCostType.MONEY))
|
||||
}
|
||||
|
||||
if (crate.keyIds.isNotEmpty()) {
|
||||
val key = GoldenCratesAPI.getKeyManager().getKeyById(crate.keyIds.first())!!
|
||||
result.set("key.item", key.item.toLookupString())
|
||||
result.set("key.lore", key.item.itemMeta?.lore)
|
||||
} else {
|
||||
result.set("key.item", "tripwire_hook unbreaking:1 hide_enchants name:\"${crate.name} Key\"")
|
||||
result.set("key.lore", mutableListOf("&fUse this key to open", "&fthe ${crate.name}"))
|
||||
}
|
||||
|
||||
result.set("keygui.item", crate.item.toLookupString())
|
||||
result.set("keygui.lore", crate.item.itemMeta?.lore)
|
||||
|
||||
result.set("placed.hologram.height", crate.blockHologramOffsetY)
|
||||
result.set("placed.hologram.frames", mutableListOf(
|
||||
BuildableConfig()
|
||||
.add("tick", 0)
|
||||
.add("lines", crate.blockHologramText)
|
||||
))
|
||||
|
||||
result.set("preview.title", crate.name)
|
||||
|
||||
val newRewards = mutableListOf<Config>()
|
||||
var row = 2
|
||||
var col = 2
|
||||
var counter = 1
|
||||
crate.rewards.forEach {
|
||||
val salt = id + "_" + counter
|
||||
newRewards.add(convertReward(it, salt, row, col))
|
||||
col++
|
||||
if (col >= 8) {
|
||||
col = 2
|
||||
row++
|
||||
}
|
||||
counter++
|
||||
}
|
||||
|
||||
val rewards = plugin.rewardsYml.getSubsections("rewards").toMutableList()
|
||||
|
||||
rewards.addAll(newRewards)
|
||||
|
||||
plugin.rewardsYml.set("rewards", rewards)
|
||||
|
||||
result.set("open.broadcasts", mutableListOf("%player%&f is opening the ${crate.name}!"))
|
||||
|
||||
result.set("finish.broadcasts", mutableListOf("%player%&f won %reward%&f from the ${crate.name}!"))
|
||||
|
||||
result.set("rewards", newRewards.map { it.getString("id") })
|
||||
|
||||
return result
|
||||
}
|
||||
|
||||
private fun convertReward(reward: ICrateReward, salt: String, row: Int, col: Int): Config {
|
||||
val result = ConversionHelpers.createEmptyReward()
|
||||
|
||||
result.set("id", salt)
|
||||
|
||||
result.set("commands", reward.commands.map {
|
||||
it.replace("[CONSOLE]", "")
|
||||
.replace("[CONSOLE] ", "")
|
||||
.replace("[PLAYER]", "")
|
||||
.replace("[PLAYER] ", "")
|
||||
})
|
||||
result.set("items", reward.items.map { it.toLookupString() })
|
||||
|
||||
result.set("max-wins", reward.winLimitAmount)
|
||||
|
||||
result.set("weight.actual", reward.chance)
|
||||
result.set("weight.display", reward.chance)
|
||||
|
||||
val meta = reward.preview.itemMeta
|
||||
|
||||
result.set("display.name", reward.name)
|
||||
result.set("display.item", reward.preview.toLookupString())
|
||||
result.set("display.lore", meta?.lore)
|
||||
result.set("display.row", row)
|
||||
result.set("display.column", col)
|
||||
|
||||
return result
|
||||
}
|
||||
}
|
||||
@@ -10,6 +10,8 @@ depend:
|
||||
- ProtocolLib
|
||||
softdepend:
|
||||
- CrateReloaded
|
||||
- ExcellentCrates
|
||||
- CrazyCrates
|
||||
|
||||
commands:
|
||||
ecocrates:
|
||||
|
||||
BIN
lib/Crazy-Crates-[v1.10.3].jar
Normal file
BIN
lib/Crazy-Crates-[v1.10.3].jar
Normal file
Binary file not shown.
BIN
lib/ExcellentCrates-4.0.3.6.jar
Normal file
BIN
lib/ExcellentCrates-4.0.3.6.jar
Normal file
Binary file not shown.
BIN
lib/NexEngine.jar
Normal file
BIN
lib/NexEngine.jar
Normal file
Binary file not shown.
Reference in New Issue
Block a user