支持MMOItem
This commit is contained in:
+9
-3
@@ -2,7 +2,7 @@ plugins {
|
||||
`java-library`
|
||||
`maven-publish`
|
||||
id("io.izzel.taboolib") version "1.54"
|
||||
id("org.jetbrains.kotlin.jvm") version "1.8.0"
|
||||
id("org.jetbrains.kotlin.jvm") version "1.7.10"
|
||||
}
|
||||
|
||||
taboolib {
|
||||
@@ -10,6 +10,8 @@ taboolib {
|
||||
dependencies {
|
||||
name("PlaceholderAPI").optional(true)
|
||||
name("Vault").optional(true)
|
||||
name("MMOItems").optional(true)
|
||||
name("Zaphkiel").optional(true)
|
||||
}
|
||||
contributors {
|
||||
name("小白")
|
||||
@@ -28,9 +30,10 @@ taboolib {
|
||||
install("platform-bukkit")
|
||||
install("expansion-command-helper")
|
||||
classifier = null
|
||||
version = "6.0.11-13"
|
||||
version = "6.0.12-13"
|
||||
options("skit-kotlin")
|
||||
relocate("kotlin","libs.kotlin180")
|
||||
relocate("kotlin", "libs.kotlin171")
|
||||
relocate("com.xbaimiao.ktor", "libs.kotlin171.ktor")
|
||||
}
|
||||
|
||||
repositories {
|
||||
@@ -40,12 +43,15 @@ repositories {
|
||||
|
||||
dependencies {
|
||||
compileOnly("ink.ptms:nms-all:1.0.0")
|
||||
compileOnly("public:MythicMobs:4.14.1")
|
||||
compileOnly("public:papi:1.0.0")
|
||||
compileOnly("public:vault:1.0.0")
|
||||
compileOnly("public:points:1.0.0")
|
||||
compileOnly("ink.ptms.core:v11902:11902-minimize:mapped")
|
||||
compileOnly("ink.ptms.core:v11902:11902-minimize:universal")
|
||||
compileOnly("public:Zaphkiel:1.0.0")
|
||||
compileOnly("public:MMOItems:6.9.4")
|
||||
taboo("com.xbaimiao.ktor:ktor-plugins-bukkit:1.0.8")
|
||||
taboo(kotlin("stdlib"))
|
||||
compileOnly(fileTree("libs"))
|
||||
}
|
||||
|
||||
+1
-1
@@ -1,2 +1,2 @@
|
||||
group=com.github.xbaimiao.shoppro
|
||||
version=1.1.9
|
||||
version=1.2.1
|
||||
|
||||
@@ -6,11 +6,15 @@ import com.github.xbaimiao.shoppro.core.database.SQLiteDatabase
|
||||
import com.github.xbaimiao.shoppro.core.item.ItemLoaderManager
|
||||
import com.github.xbaimiao.shoppro.core.shop.ShopManager
|
||||
import com.github.xbaimiao.shoppro.core.vault.DiyCurrency
|
||||
import com.xbaimiao.ktor.KtorPluginsBukkit
|
||||
import com.xbaimiao.ktor.KtorStat
|
||||
import taboolib.common.platform.Plugin
|
||||
import taboolib.common.platform.function.info
|
||||
import taboolib.module.configuration.Config
|
||||
import taboolib.module.configuration.Configuration
|
||||
import taboolib.platform.BukkitPlugin
|
||||
|
||||
object ShopPro : Plugin() {
|
||||
object ShopPro : Plugin(), KtorStat {
|
||||
|
||||
@Config(value = "config.yml")
|
||||
lateinit var config: Configuration
|
||||
@@ -21,6 +25,9 @@ object ShopPro : Plugin() {
|
||||
val itemLoaderManager = ItemLoaderManager()
|
||||
|
||||
override fun onActive() {
|
||||
KtorPluginsBukkit.init(BukkitPlugin.getInstance(), this)
|
||||
info("$userId 感谢您的使用")
|
||||
stat()
|
||||
ShopManager.load()
|
||||
DiyCurrency.load()
|
||||
database = if (config.getBoolean("mysql.enable")) MysqlDatabase(config) else SQLiteDatabase()
|
||||
|
||||
@@ -12,6 +12,8 @@ class ItemLoaderManager {
|
||||
itemLoaders.add(ItemsAdderShopItem)
|
||||
itemLoaders.add(HeadShopItem)
|
||||
itemLoaders.add(ZapItem)
|
||||
itemLoaders.add(MythicItem)
|
||||
itemLoaders.add(MMOItem)
|
||||
}
|
||||
|
||||
fun getVanillaShop(): ItemLoader = VanillaShopItem.Companion
|
||||
|
||||
@@ -15,7 +15,7 @@ class ItemsAdderShopItem(
|
||||
itemSetting: ItemSetting
|
||||
) : ShopItem(itemSetting) {
|
||||
|
||||
override val material: Material
|
||||
final override val material: Material
|
||||
|
||||
val custom: Int
|
||||
|
||||
|
||||
@@ -0,0 +1,67 @@
|
||||
package com.github.xbaimiao.shoppro.core.item.impl
|
||||
|
||||
import com.github.xbaimiao.shoppro.core.item.Item
|
||||
import com.github.xbaimiao.shoppro.core.item.ItemLoader
|
||||
import com.github.xbaimiao.shoppro.core.shop.Shop
|
||||
import net.Indyuce.mmoitems.MMOItems
|
||||
import net.Indyuce.mmoitems.api.Type
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.configuration.ConfigurationSection
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.inventory.ItemStack
|
||||
|
||||
/**
|
||||
* MMOItem
|
||||
*
|
||||
* @author xbaimiao
|
||||
* @since 2023/10/5 12:42
|
||||
*/
|
||||
class MMOItem(
|
||||
private val itemStack: ItemStack,
|
||||
private val type: Type,
|
||||
private val mmoitemsID: String,
|
||||
itemSetting: ItemSetting
|
||||
) : VanillaShopItem(itemSetting) {
|
||||
|
||||
override val material: Material
|
||||
get() = itemStack.type
|
||||
|
||||
override fun vanillaItem(player: Player): ItemStack {
|
||||
return itemStack
|
||||
}
|
||||
|
||||
override fun equal(itemStack: ItemStack): Boolean {
|
||||
val t = MMOItems.getType(itemStack) ?: return false
|
||||
if (t != type) return false
|
||||
val i = MMOItems.getID(itemStack) ?: return false
|
||||
return i == mmoitemsID
|
||||
}
|
||||
|
||||
companion object : ItemLoader() {
|
||||
|
||||
override val prefix: String = "MMO_ITEM"
|
||||
|
||||
override fun formSection(char: Char, section: ConfigurationSection, shop: Shop): Item {
|
||||
if (Bukkit.getPluginManager().getPlugin("MMOItems") == null) {
|
||||
error("MMOItems Plugin not found")
|
||||
}
|
||||
val mmoitemsData = section.getString("material")!!.substring(prefix.length + 1).split(":")
|
||||
val type = Type.get(mmoitemsData[0]) ?: error("MMOItems ${mmoitemsData[0]} not is type")
|
||||
val id = mmoitemsData[1]
|
||||
val item = MMOItems.plugin.getItem(type, id) ?: error("MMOItems $mmoitemsData 不是一个有效的物品")
|
||||
return MMOItem(
|
||||
item,
|
||||
type,
|
||||
id,
|
||||
section.toItemSetting(char, shop)
|
||||
)
|
||||
}
|
||||
|
||||
override fun parseToMaterial(section: ConfigurationSection): Material {
|
||||
return Material.AIR
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,57 @@
|
||||
package com.github.xbaimiao.shoppro.core.item.impl
|
||||
|
||||
import com.github.xbaimiao.shoppro.core.item.Item
|
||||
import com.github.xbaimiao.shoppro.core.item.ItemLoader
|
||||
import com.github.xbaimiao.shoppro.core.shop.Shop
|
||||
import io.lumine.xikage.mythicmobs.MythicMobs
|
||||
import io.lumine.xikage.mythicmobs.adapters.bukkit.BukkitAdapter
|
||||
import org.bukkit.Bukkit
|
||||
import org.bukkit.Material
|
||||
import org.bukkit.configuration.ConfigurationSection
|
||||
import org.bukkit.entity.Player
|
||||
import org.bukkit.inventory.ItemStack
|
||||
|
||||
/**
|
||||
* @author 小白
|
||||
* @date 2023/5/15 17:59
|
||||
**/
|
||||
class MythicItem(
|
||||
private val itemStack: ItemStack,
|
||||
itemSetting: ItemSetting
|
||||
) : VanillaShopItem(itemSetting) {
|
||||
|
||||
override val material: Material
|
||||
get() = itemStack.type
|
||||
|
||||
override fun vanillaItem(player: Player): ItemStack {
|
||||
return itemStack
|
||||
}
|
||||
|
||||
override fun equal(itemStack: ItemStack): Boolean {
|
||||
return itemStack.isSimilar(this.itemStack)
|
||||
}
|
||||
|
||||
companion object : ItemLoader() {
|
||||
|
||||
override val prefix: String = "MM"
|
||||
|
||||
override fun formSection(char: Char, section: ConfigurationSection, shop: Shop): Item {
|
||||
if (Bukkit.getPluginManager().plugins.find { it.name.lowercase() == "MythicMobs".lowercase() } == null) {
|
||||
error("MythicMobs Plugin not found")
|
||||
}
|
||||
val mmID = section.getString("material")!!.substring(prefix.length + 1)
|
||||
|
||||
val item = MythicMobs.inst().itemManager.getItem(mmID) ?: error("MythicMobs $mmID not found")
|
||||
if (!item.isPresent) {
|
||||
error("MythicMobs $mmID not found")
|
||||
}
|
||||
return MythicItem(BukkitAdapter.adapt(item.get().generateItemStack(1)), section.toItemSetting(char, shop))
|
||||
}
|
||||
|
||||
override fun parseToMaterial(section: ConfigurationSection): Material {
|
||||
return Material.AIR
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
@@ -7,7 +7,7 @@ title: "系统出售商店"
|
||||
# 物品摆放顺序
|
||||
slots:
|
||||
- 'NNNNNNNNN'
|
||||
- 'NABC N'
|
||||
- 'NABCD N'
|
||||
- 'NNNNNNNNN'
|
||||
items:
|
||||
N:
|
||||
@@ -98,3 +98,26 @@ items:
|
||||
- '&e| &7全服限制购买: ${allLimit}'
|
||||
- '&e| &7您已购买: ${limit-player}'
|
||||
- '&e| &7全服剩余: ${limit-server}'
|
||||
# MM物品示范
|
||||
D:
|
||||
material: 'MM:KingsCrown'
|
||||
name: 'MM物品'
|
||||
# 每日限购买
|
||||
limit: 5000
|
||||
# 每个玩家限购买
|
||||
limit-player: 500
|
||||
# 物品金额
|
||||
price: 2
|
||||
lore:
|
||||
- '&e| &7这里可以购买&6 ${name}'
|
||||
- '&e| &7购买单价 &6${price}'
|
||||
- '&e| &7你的余额 &6${money}'
|
||||
- ''
|
||||
- '&e|&6 左击 &7购买 &6单个'
|
||||
- '&e|&6 右击 &7购买 &6一组 &7需要 &6${price64}'
|
||||
- ''
|
||||
- '&e| &7限买公示:'
|
||||
- '&e| &7每人限制购买: ${limit}'
|
||||
- '&e| &7全服限制购买: ${allLimit}'
|
||||
- '&e| &7您已购买: ${limit-player}'
|
||||
- '&e| &7全服剩余: ${limit-server}'
|
||||
@@ -7,7 +7,7 @@ title: "系统收购商店"
|
||||
# 物品摆放顺序
|
||||
slots:
|
||||
- 'NNNNNNNNN'
|
||||
- 'NABC N'
|
||||
- 'NABCD N'
|
||||
- 'NNNNNNNNN'
|
||||
items:
|
||||
N:
|
||||
@@ -99,3 +99,26 @@ items:
|
||||
- '&e· &7全服限制出售: ${allLimit}'
|
||||
- '&e· &7您当前已出售: ${limit-player} &8| &7全服剩余: ${limit-server}'
|
||||
- '&x&F&5&A&5&0&E&M &x&E&E&A&2&1&C&M &x&E&7&9&F&2&A&M &x&E&0&9&C&3&8&M &x&D&9&9&9&4&6&M &x&D&2&9&6&5&4&M &x&C&B&9&3&6&2&M &x&C&4&9&C&7&0&M &x&B&D&9&F&7&E&M &x&B&D&9&F&7&E&M &x&B&6&A&2&8&C&M &x&A&F&A&5&9&A&M &M &M &x&A&F&A&5&9&A&M &M &M &x&B&6&A&2&8&C&M &x&B&D&9&F&7&E&M &x&C&4&9&C&7&0&M &x&C&B&9&9&6&2&M &x&D&2&9&6&5&4&M &x&D&9&9&3&4&6&M &x&E&0&9&0&3&8&M &x&E&7&8&D&2&A&M &x&E&E&8&A&1&C&M &x&F&5&8&7&0&E&M &x&F&C&8&4&0&0&M '
|
||||
D:
|
||||
material: 'MMO_ITEM:SWORD:新手剑'
|
||||
name: 'MMO_ITEM物品名'
|
||||
# 每日限出售
|
||||
limit: 5000
|
||||
# 每个玩家限出售
|
||||
limit-player: 500
|
||||
# 物品金额
|
||||
price: 1
|
||||
lore:
|
||||
- '&e| &7这里可以出售你背包里面的&6 ${name}'
|
||||
- '&e| &7收购单价 &6${price}'
|
||||
- '&e| &7你的余额 &6${money}'
|
||||
- ''
|
||||
- '&e|&6 左击 &7出售 &6单个'
|
||||
- '&e|&6 右击 &7出售 &6一组 &7获得 &6${price64}'
|
||||
- '&e|&6 Shift + 右击 &7出售 &6背包所有 &7获得${priceAll}'
|
||||
- ''
|
||||
- '&e| &7限售公示:'
|
||||
- '&e| &7每人限制出售: ${limit}'
|
||||
- '&e| &7全服限制出售: ${allLimit}'
|
||||
- '&e| &7您已出售: ${limit-player}'
|
||||
- '&e| &7全服剩余: ${limit-server}'
|
||||
Reference in New Issue
Block a user