Skip to content

Commit

Permalink
迁移至NBT-API
Browse files Browse the repository at this point in the history
  • Loading branch information
Iseason2000 committed Aug 31, 2024
1 parent bcaa7cc commit 8c060fb
Show file tree
Hide file tree
Showing 35 changed files with 335 additions and 393 deletions.
8 changes: 4 additions & 4 deletions build.gradle.kts
Original file line number Diff line number Diff line change
Expand Up @@ -46,26 +46,26 @@ subprojects {
dependencies {
val kotlinVersion: String by rootProject
val exposedVersion: String by rootProject
val nbtEditorVersion: String by rootProject
compileOnly("de.tr7zw:item-nbt-api-plugin:2.13.2")
compileOnly(platform("org.jetbrains.kotlin:kotlin-bom:$kotlinVersion"))
//基础库
compileOnly(kotlin("stdlib"))
compileOnly("org.spigotmc", "spigot-api", "1.16.5-R0.1-SNAPSHOT")
compileOnly("org.spigotmc", "spigot-api", "1.20.3-R0.1-SNAPSHOT")
// compileOnly("org.spigotmc", "spigot-api", "1.16.5-R0.1-SNAPSHOT")
compileOnly(
"com.destroystokyo.paper", "paper-api", "1.16.5-R0.1-SNAPSHOT"
) {
isTransitive = false
exclude("org.bukkit")
}
compileOnly("me.clip:placeholderapi:2.11.3")
implementation("io.github.bananapuncher714:nbteditor:$nbtEditorVersion")
// implementation("io.github.bananapuncher714:nbteditor:7.19.3")

// 数据库
compileOnly("org.jetbrains.exposed", "exposed-core", exposedVersion)
compileOnly("org.jetbrains.exposed", "exposed-dao", exposedVersion)
compileOnly("org.jetbrains.exposed", "exposed-jdbc", exposedVersion)
compileOnly("org.jetbrains.exposed", "exposed-java-time", exposedVersion)

compileOnly("com.zaxxer:HikariCP:4.0.3")
}

Expand Down
Original file line number Diff line number Diff line change
@@ -1,14 +1,24 @@
package top.iseason.bukkittemplate.hook

import me.clip.placeholderapi.PlaceholderAPI
import org.bukkit.Bukkit
import org.bukkit.OfflinePlayer
import top.iseason.bukkittemplate.BukkitTemplate
import top.iseason.bukkittemplate.utils.bukkit.MessageUtils.toColor

object PlaceHolderHook : BaseHook("PlaceholderAPI") {
init {
Bukkit.getScheduler().runTaskAsynchronously(BukkitTemplate.getPlugin(), PlaceHolderHook::checkHooked)
}

fun setPlaceHolder(str: String, player: OfflinePlayer?): String {
return if (hasHooked)
PlaceholderAPI.setPlaceholders(player, str).toColor()
else str.toColor()
}

fun setPlaceHolder(str: List<String>, player: OfflinePlayer?): List<String> {
return if (hasHooked) str.map { PlaceholderAPI.setPlaceholders(player, it).toColor() }
else str.toColor()
}
}
Original file line number Diff line number Diff line change
Expand Up @@ -20,7 +20,7 @@ import top.iseason.bukkittemplate.ui.slot.ClickSlot
import top.iseason.bukkittemplate.ui.slot.IOSlot
import top.iseason.bukkittemplate.ui.slot.merge
import top.iseason.bukkittemplate.utils.bukkit.ItemUtils.checkAir
import top.iseason.bukkittemplate.utils.bukkit.ItemUtils.subtract
import top.iseason.bukkittemplate.utils.bukkit.ItemUtils.decrease
import top.iseason.bukkittemplate.utils.other.WeakCoolDown
import top.iseason.bukkittemplate.utils.other.submit

Expand Down Expand Up @@ -244,7 +244,7 @@ fun InventoryClickEvent.ioEvent() {
if (slot.output(slot, output)) {
amount += outputAmount
slot.onOutput(slot, output)
itemStack.subtract(outputAmount)
itemStack.decrease(outputAmount)
}
}
}
Expand All @@ -260,7 +260,7 @@ fun InventoryClickEvent.ioEvent() {
val need = maxStackSize - amount
val outputAmount = if (slotAmount <= need) slotAmount else need
amount += outputAmount
itemStack.subtract(outputAmount)
itemStack.decrease(outputAmount)
}
view.cursor = cursor.apply { this.amount = amount }
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,6 @@

package top.iseason.bukkittemplate.utils.bukkit

import io.github.bananapuncher714.nbteditor.NBTEditor
import org.bukkit.entity.Entity
import org.bukkit.entity.EntityType
import org.bukkit.entity.Item
Expand Down Expand Up @@ -47,7 +46,7 @@ object EntityUtils {
for (addItem in addItems) {
if (addItem == null) continue
val item = world.spawnEntity(location, EntityType.DROPPED_ITEM) as Item
item.setItemStack(addItem)
item.itemStack = addItem
}
}

Expand All @@ -67,8 +66,4 @@ object EntityUtils {
*/
fun Player.getHeldItem(): ItemStack? = inventory.getHeldItem()

/**
* 序列化为json
*/
fun Entity.toJson(): String = NBTEditor.getNBTCompound(this).toJson()
}
Loading

0 comments on commit 8c060fb

Please sign in to comment.