From a81f3cf23181e27e9a5048db919d8d0d6da5c696 Mon Sep 17 00:00:00 2001 From: Micalhl Date: Thu, 15 Aug 2024 00:15:26 +0800 Subject: [PATCH] Update --- src/main/kotlin/com/mcstarrysky/land/Land.kt | 3 +- .../com/mcstarrysky/land/LandCommands.kt | 6 ++ .../kotlin/com/mcstarrysky/land/data/Land.kt | 36 ++++----- .../com/mcstarrysky/land/flag/PermBuild.kt | 3 +- .../land/flag/PermDamageAnimals.kt | 3 +- .../mcstarrysky/land/flag/PermDamageGolem.kt | 3 +- .../land/flag/PermDamageMonster.kt | 3 +- .../mcstarrysky/land/listener/PosSelection.kt | 73 +++++++++++++------ .../mcstarrysky/land/manager/LandManager.kt | 7 +- .../mcstarrysky/land/menu/LandFlagsMenu.kt | 4 +- .../com/mcstarrysky/land/menu/LandInfoMenu.kt | 40 +++++++--- .../com/mcstarrysky/land/menu/LandListMenu.kt | 4 +- .../com/mcstarrysky/land/menu/LandMainMenu.kt | 2 +- .../com/mcstarrysky/land/util/ChunkUtils.kt | 9 +++ 14 files changed, 132 insertions(+), 64 deletions(-) diff --git a/src/main/kotlin/com/mcstarrysky/land/Land.kt b/src/main/kotlin/com/mcstarrysky/land/Land.kt index 3332a46..be8646f 100644 --- a/src/main/kotlin/com/mcstarrysky/land/Land.kt +++ b/src/main/kotlin/com/mcstarrysky/land/Land.kt @@ -6,7 +6,6 @@ import taboolib.common.env.RuntimeDependencies import taboolib.common.env.RuntimeDependency import taboolib.common.platform.Plugin import taboolib.library.xseries.XMaterial -import taboolib.module.ui.virtual.InventoryHandler import taboolib.platform.util.buildItem /** @@ -64,7 +63,7 @@ object Land : Plugin() { override fun onEnable() { LandManager.import() - InventoryHandler.instance + // InventoryHandler.instance } override fun onDisable() { diff --git a/src/main/kotlin/com/mcstarrysky/land/LandCommands.kt b/src/main/kotlin/com/mcstarrysky/land/LandCommands.kt index cc29edb..88c2eb9 100644 --- a/src/main/kotlin/com/mcstarrysky/land/LandCommands.kt +++ b/src/main/kotlin/com/mcstarrysky/land/LandCommands.kt @@ -76,5 +76,11 @@ object LandCommands { } } } + command("landdelete", permission = "admin") { + exec { + val land = LandManager.getLand(sender.location) ?: return@exec + land.area -= sender.location.chunk + } + } } } \ No newline at end of file diff --git a/src/main/kotlin/com/mcstarrysky/land/data/Land.kt b/src/main/kotlin/com/mcstarrysky/land/data/Land.kt index 660dc2a..2ed408e 100644 --- a/src/main/kotlin/com/mcstarrysky/land/data/Land.kt +++ b/src/main/kotlin/com/mcstarrysky/land/data/Land.kt @@ -1,5 +1,3 @@ -@file:Suppress("DEPRECATION") - package com.mcstarrysky.land.data import com.mcstarrysky.land.Land @@ -27,8 +25,8 @@ import taboolib.module.chat.Components import taboolib.platform.util.checkItem import taboolib.platform.util.takeItem import java.util.Date -import java.util.HashMap import java.util.UUID +import kotlin.collections.HashMap /** * Land @@ -51,22 +49,22 @@ data class Land( var leaveMessage: String? = "你离开了 &{#8abcd1}$name", @Serializable(with = LocationSerializer::class) var tpLocation: Location, - @Deprecated(message = "协作者功能已废除") - val cooperators: MutableList<@Serializable(with = UUIDSerializer::class) UUID>, +// @Deprecated(message = "协作者功能已废除") +// val cooperators: MutableList<@Serializable(with = UUIDSerializer::class) UUID>, val flags: MutableMap = mutableMapOf(), // 玩家 UUID 对一个 Map, Map 是 权限节点对应的值 val users: MutableMap<@Serializable(with = UUIDSerializer::class) UUID, MutableMap>, ) { - init { - // 迁移协作者 - if (cooperators.isNotEmpty()) { - cooperators.forEach { uuid -> - (users.computeIfAbsent(uuid) { HashMap() }) += PermAdmin.id to true - } - cooperators.clear() - } - } +// init { +// // 迁移协作者 +// if (cooperators.isNotEmpty()) { +// cooperators.forEach { uuid -> +// (users.computeIfAbsent(uuid) { HashMap() }) += PermAdmin.id to true +// } +// cooperators.clear() +// } +// } @Transient val date = DATE_FORMAT.format(Date(timestamp)) @@ -85,6 +83,10 @@ data class Land( player.prettyInfo("你所要占领的区块已被其他领地占领, 请换一个区块!") return } + if (!ChunkUtils.isAdjacentToAnyChunk(location.chunk, area)) { + player.prettyInfo("占领的区块必须与你领地相邻!") + return + } if (player.checkItem(Land.crystal, 3)) { player.inventory.takeItem(3) { it.isSimilar(Land.crystal) } area += location.chunk @@ -93,7 +95,7 @@ data class Land( // 这里用到一个奇怪的操作 Components.parseRaw( GsonComponentSerializer.gson() - .serialize(GsonComponentSerializer.gson().deserialize(cacheMessageWithPrefix("抱歉, 你要准备 3 个").toRawMessage()) + .serialize(GsonComponentSerializer.gson().deserialize(cacheMessageWithPrefix("抱歉, 你要准备 3 个 ").toRawMessage()) .append(LegacyComponentSerializer.legacyAmpersand().deserialize("&b开拓水晶") .hoverEvent(Land.crystal.clone().asHoverEvent()))) ).append(cacheMessageWithPrefixColor(" 才能占领一个区块")) @@ -111,8 +113,8 @@ data class Land( } fun hasPermission(player: Player, perm: Permission? = null): Boolean { - return if (perm == null) { - player.isOp || player.uniqueId == owner || users[player.uniqueId]?.get(PermAdmin.id) == true + return isAdmin(player) || if (perm == null) { + users[player.uniqueId]?.get(PermAdmin.id) == true } else { users[player.uniqueId]?.get(perm.id) ?: getFlag(perm.id) } diff --git a/src/main/kotlin/com/mcstarrysky/land/flag/PermBuild.kt b/src/main/kotlin/com/mcstarrysky/land/flag/PermBuild.kt index 2471b5e..09b9e58 100644 --- a/src/main/kotlin/com/mcstarrysky/land/flag/PermBuild.kt +++ b/src/main/kotlin/com/mcstarrysky/land/flag/PermBuild.kt @@ -20,6 +20,7 @@ import taboolib.common.LifeCycle import taboolib.common.platform.Awake import taboolib.common.platform.event.SubscribeEvent import taboolib.library.xseries.XMaterial +import taboolib.platform.util.attacker import taboolib.platform.util.buildItem /** @@ -124,7 +125,7 @@ object PermBuild : Permission { @SubscribeEvent(ignoreCancelled = true) fun e(e: EntityDamageByEntityEvent) { if (e.entity is ArmorStand) { - val player = e.damager as? Player ?: return + val player = e.attacker as? Player ?: return // val player = Servers.getAttackerInDamageEvent(e) ?: return LandManager.getLand(e.entity.location.block.location)?.run { if (!hasPermission(player, this@PermBuild)) { diff --git a/src/main/kotlin/com/mcstarrysky/land/flag/PermDamageAnimals.kt b/src/main/kotlin/com/mcstarrysky/land/flag/PermDamageAnimals.kt index 9c7410d..3237afb 100644 --- a/src/main/kotlin/com/mcstarrysky/land/flag/PermDamageAnimals.kt +++ b/src/main/kotlin/com/mcstarrysky/land/flag/PermDamageAnimals.kt @@ -14,6 +14,7 @@ import taboolib.common.LifeCycle import taboolib.common.platform.Awake import taboolib.common.platform.event.SubscribeEvent import taboolib.library.xseries.XMaterial +import taboolib.platform.util.attacker import taboolib.platform.util.buildItem /** @@ -60,7 +61,7 @@ object PermDamageAnimals : Permission { @SubscribeEvent(ignoreCancelled = true) fun e(e: EntityDamageByEntityEvent) { if (e.entity is Animals) { - val player = e.damager as? Player ?: return + val player = e.attacker as? Player ?: return LandManager.getLand(e.entity.location)?.run { if (!hasPermission(player, this@PermDamageAnimals)) { e.isCancelled = true diff --git a/src/main/kotlin/com/mcstarrysky/land/flag/PermDamageGolem.kt b/src/main/kotlin/com/mcstarrysky/land/flag/PermDamageGolem.kt index a9c363c..4e58b24 100644 --- a/src/main/kotlin/com/mcstarrysky/land/flag/PermDamageGolem.kt +++ b/src/main/kotlin/com/mcstarrysky/land/flag/PermDamageGolem.kt @@ -14,6 +14,7 @@ import taboolib.common.LifeCycle import taboolib.common.platform.Awake import taboolib.common.platform.event.SubscribeEvent import taboolib.library.xseries.XMaterial +import taboolib.platform.util.attacker import taboolib.platform.util.buildItem /** @@ -60,7 +61,7 @@ object PermDamageGolem : Permission { @SubscribeEvent(ignoreCancelled = true) fun e(e: EntityDamageByEntityEvent) { if (e.entity is Golem) { - val player = e.damager as? Player ?: return + val player = e.attacker as? Player ?: return LandManager.getLand(e.entity.location)?.run { if (!hasPermission(player, this@PermDamageGolem)) { e.isCancelled = true diff --git a/src/main/kotlin/com/mcstarrysky/land/flag/PermDamageMonster.kt b/src/main/kotlin/com/mcstarrysky/land/flag/PermDamageMonster.kt index 5999f4d..dbe4898 100644 --- a/src/main/kotlin/com/mcstarrysky/land/flag/PermDamageMonster.kt +++ b/src/main/kotlin/com/mcstarrysky/land/flag/PermDamageMonster.kt @@ -14,6 +14,7 @@ import taboolib.common.LifeCycle import taboolib.common.platform.Awake import taboolib.common.platform.event.SubscribeEvent import taboolib.library.xseries.XMaterial +import taboolib.platform.util.attacker import taboolib.platform.util.buildItem /** @@ -61,7 +62,7 @@ object PermDamageMonster : Permission{ @SubscribeEvent(ignoreCancelled = true) fun e(e: EntityDamageByEntityEvent) { if (e.entity is Monster) { - val player = e.damager as Player + val player = e.attacker as? Player ?: return LandManager.getLand(e.entity.location)?.run { if (!hasPermission(player, this@PermDamageMonster)) { e.isCancelled = true diff --git a/src/main/kotlin/com/mcstarrysky/land/listener/PosSelection.kt b/src/main/kotlin/com/mcstarrysky/land/listener/PosSelection.kt index a70f282..1e1aae5 100644 --- a/src/main/kotlin/com/mcstarrysky/land/listener/PosSelection.kt +++ b/src/main/kotlin/com/mcstarrysky/land/listener/PosSelection.kt @@ -25,7 +25,7 @@ object PosSelection { val pos1 = ConcurrentHashMap() val pos2 = ConcurrentHashMap() - // @SubscribeEvent + @SubscribeEvent fun e(e: PlayerInteractEvent) { val player = e.player // 主手 @@ -35,43 +35,74 @@ object PosSelection { // 判断左右键 when { e.isLeftClickBlock() -> { + e.isCancelled = true val pos = e.clickedBlock!!.location.chunk pos1.computeIfAbsent(player.uniqueId) { pos } if (pos2[player.uniqueId] == null) { - player.prettyInfo("+========选择的范围信息========+[](br)" + - "世界: &b" + LandSettings.worldAliases[pos.world.name] + "[](br)" + - "点1: &b(${pos.x}, ${pos.z})[](br)" + - "+===================================+") + listOf( + "+========选择的范围信息========+", + "世界: &{#8cc269}" + LandSettings.worldAliases[pos.world.name], + "点1: &{#8cc269}(${pos.x}, ${pos.z})", + "+===========================+" + ).forEach { player.prettyInfo(it) } +// player.prettyInfo("+========选择的范围信息========+[](br)" + +// "世界: &{#8cc269}" + LandSettings.worldAliases[pos.world.name] + "[](br)" + +// "点1: &{#8cc269}(${pos.x}, ${pos.z})[](br)" + +// "+===================================+") //"+==(输入/land进入领地主菜单)==+") } else { val p2 = pos2[player.uniqueId]!! val chunks = ChunkUtils.getChunksInRectangle(pos.world, pos, p2) - player.prettyInfo("+========选择的范围信息========+[](br)" + - "世界: &b" + LandSettings.worldAliases[pos.world.name] + "[](br)" + - "点1: &b(${pos.x}, ${pos.z})[](br)" + - "点2: &b(${p2.x}, ${p2.z})[](br)" + - "范围花费: 每区块3*区块数${chunks.size}=${3*chunks.size}个开拓水晶[](br)" + - "+==(输入/land进入领地主菜单)==+") + listOf( + "+========选择的范围信息========+", + "世界: &{#8cc269}" + LandSettings.worldAliases[pos.world.name], + "点1: &{#8cc269}(${pos.x}, ${pos.z})", + "点2: &{#8cc269}(${p2.x}, ${p2.z})", + "范围花费: 每区块3*共${chunks.size}个区块=${3*chunks.size}个开拓水晶", + "+====(输入/land进入领地主菜单)====+" + ).forEach { player.prettyInfo(it) } +// player.prettyInfo("+========选择的范围信息========+[](br)" + +// "世界: &{#8cc269}" + LandSettings.worldAliases[pos.world.name] + "[](br)" + +// "点1: &{#8cc269}(${pos.x}, ${pos.z})[](br)" + +// "点2: &{#8cc269}(${p2.x}, ${p2.z})[](br)" + +// "范围花费: 每区块3*共${chunks.size}个区块=${3*chunks.size}个开拓水晶[](br)" + +// "+==(输入/land进入领地主菜单)==+") } } e.isRightClickBlock() -> { + e.isCancelled = true val pos = e.clickedBlock!!.location.chunk pos2.computeIfAbsent(player.uniqueId) { pos } if (pos1[player.uniqueId] == null) { - player.prettyInfo("+========选择的范围信息========+[](br)" + - "世界: &b" + LandSettings.worldAliases[pos.world.name] + "[](br)" + - "点2: &b(${pos.x}, ${pos.z})[](br)" + - "+===================================+") + listOf( + "+========选择的范围信息========+", + "世界: &{#8cc269}" + LandSettings.worldAliases[pos.world.name], + "点2: &{#8cc269}(${pos.x}, ${pos.z})", + "+===========================+" + ).forEach { player.prettyInfo(it) } +// player.prettyInfo("+========选择的范围信息========+[](br)" + +// "世界: &{#8cc269}" + LandSettings.worldAliases[pos.world.name] + "[](br)" + +// "点2: &{#8cc269}(${pos.x}, ${pos.z})[](br)" + +// "+===================================+") //"+==(输入/land进入领地主菜单)==+") } else { val p1 = pos1[player.uniqueId]!! val chunks = ChunkUtils.getChunksInRectangle(pos.world, pos, p1) - player.prettyInfo("+========选择的范围信息========+[](br)" + - "世界: &b" + LandSettings.worldAliases[pos.world.name] + "[](br)" + - "点1: &b(${p1.x}, ${p1.z})[](br)" + - "点2: &b(${pos.x}, ${pos.z})[](br)" + - "范围花费: 每区块3*区块数${chunks.size}=${3*chunks.size}个开拓水晶[](br)" + - "+==(输入/land进入领地主菜单)==+") + listOf( + "+========选择的范围信息========+", + "世界: &{#8cc269}" + LandSettings.worldAliases[pos.world.name], + "点1: &{#8cc269}(${p1.x}, ${p1.z})", + "点2: &{#8cc269}(${pos.x}, ${pos.z})", + "范围花费: 每区块3*共${chunks.size}个区块=${3*chunks.size}个开拓水晶", + "+====(输入/land进入领地主菜单)====+" + ).forEach { player.prettyInfo(it) } + +// player.prettyInfo("+========选择的范围信息========+[](br)" + +// "世界: &{#8cc269}" + LandSettings.worldAliases[pos.world.name] + "[](br)" + +// "点1: &{#8cc269}(${p1.x}, ${p1.z})[](br)" + +// "点2: &{#8cc269}(${pos.x}, ${pos.z})[](br)" + +// "范围花费: 每区块3*区块数${chunks.size}=${3*chunks.size}个开拓水晶[](br)" + +// "+==(输入/land进入领地主菜单)==+") } } } diff --git a/src/main/kotlin/com/mcstarrysky/land/manager/LandManager.kt b/src/main/kotlin/com/mcstarrysky/land/manager/LandManager.kt index 4a135fd..3291df7 100644 --- a/src/main/kotlin/com/mcstarrysky/land/manager/LandManager.kt +++ b/src/main/kotlin/com/mcstarrysky/land/manager/LandManager.kt @@ -142,7 +142,7 @@ object LandManager { GsonComponentSerializer.gson() .serialize( GsonComponentSerializer.gson() - .deserialize(cacheMessageWithPrefix("抱歉, 你要准备 $crystalNeeds 个").toRawMessage()) + .deserialize(cacheMessageWithPrefix("抱歉, 你要准备 $crystalNeeds 个 ").toRawMessage()) .append( LegacyComponentSerializer.legacyAmpersand().deserialize("&b开拓水晶") .hoverEvent(com.mcstarrysky.land.Land.crystal.clone().asHoverEvent()) @@ -150,6 +150,7 @@ object LandManager { ) ).append(cacheMessageWithPrefixColor(" 才能占领你选中的这 ${area.size} 个区块")) .sendTo(adaptPlayer(player)) + return } val centre = LocationUtils.calculateLandCenter(area, player.world) @@ -163,7 +164,7 @@ object LandManager { name, area = area.toMutableList(), tpLocation = centre, - cooperators = mutableListOf(), +// cooperators = mutableListOf(), users = mutableMapOf() ) for (perm in defaultFlags) { @@ -206,7 +207,7 @@ object LandManager { "${player.name} 的免费领地", area = area.toMutableList(), tpLocation = clickedLocation.add(0.0, 1.0, 0.0), - cooperators = mutableListOf(), +// cooperators = mutableListOf(), users = mutableMapOf() ) for (perm in defaultFlags) { diff --git a/src/main/kotlin/com/mcstarrysky/land/menu/LandFlagsMenu.kt b/src/main/kotlin/com/mcstarrysky/land/menu/LandFlagsMenu.kt index 7e38b5d..313b85c 100644 --- a/src/main/kotlin/com/mcstarrysky/land/menu/LandFlagsMenu.kt +++ b/src/main/kotlin/com/mcstarrysky/land/menu/LandFlagsMenu.kt @@ -27,7 +27,7 @@ object LandFlagsMenu { fun openMenu(player: Player, land: Land, other: OfflinePlayer?, back: Consumer?) { val title = if (other == null) "领地标记管理" else "${other.name} 的标记管理" player.openMenu>(title) { - virtualize() + // virtualize() map( "b======pn", @@ -60,7 +60,7 @@ object LandFlagsMenu { set('b', MenuRegistry.BACK) { back?.accept(player) } onClick { event, flag -> - when (event.virtualEvent().clickType) { + when (event.clickEvent().click) { ClickType.LEFT, ClickType.SHIFT_LEFT -> { // 如果没设置, 就设置成默认值 if (land.getFlagValueOrNull(flag.id) == null) { diff --git a/src/main/kotlin/com/mcstarrysky/land/menu/LandInfoMenu.kt b/src/main/kotlin/com/mcstarrysky/land/menu/LandInfoMenu.kt index 23f685e..7ea8e93 100644 --- a/src/main/kotlin/com/mcstarrysky/land/menu/LandInfoMenu.kt +++ b/src/main/kotlin/com/mcstarrysky/land/menu/LandInfoMenu.kt @@ -12,6 +12,7 @@ import com.mcstarrysky.land.util.prettyInfo import org.bukkit.Bukkit import org.bukkit.entity.Player import org.bukkit.event.inventory.ClickType +import org.bukkit.inventory.ItemFlag import taboolib.library.xseries.XMaterial import taboolib.module.ui.openMenu import taboolib.module.ui.type.Chest @@ -30,7 +31,7 @@ object LandInfoMenu { fun openMenu(player: Player, land: Land, back: Consumer?, elements: List) { player.openMenu("领地(ID:${land.id}) ${land.name}") { - virtualize() + // virtualize() // map( // "b========", @@ -44,15 +45,18 @@ object LandInfoMenu { "b========", " a z f ", // 描述, 加入, c欢送点 " d g c ", // 标记, 转让所有者, 退出 - " m z e " // 玩家标记管理, 占领当前区块, 删除 + " m k e ", // 玩家标记管理, 占领当前区块, 删除 + "=========" ) - set('z', buildItem(XMaterial.NETHERITE_BOOTS) { + set('k', buildItem(XMaterial.NETHERITE_BOOTS) { name = "&d占领脚下区块" lore += listOf( + "&7注意: 必须与领地现有范围相邻", "&7需要花费 &b3 &7个开拓水晶" ) colored() + flags += ItemFlag.values().toList() }) { land.tryClaim(clicker) } @@ -79,13 +83,15 @@ object LandInfoMenu { colored() }) { if (check(clicker, land)) { - when (virtualEvent().clickType) { + when (clickEvent().click) { ClickType.LEFT, ClickType.SHIFT_LEFT -> { clicker.closeInventory() clicker.prettyInfo("请在聊天框输入新的描述, 或输入'取消'来取消操作!") clicker.nextChat { ctx -> - if (ctx == "取消") + if (ctx == "取消") { + player.prettyInfo("操作已取消!") return@nextChat + } land.description = ctx land.export() clicker.prettyInfo("修改成功!") @@ -95,8 +101,10 @@ object LandInfoMenu { clicker.closeInventory() clicker.prettyInfo("请在聊天框输入新的名字, 或输入'取消'来取消操作!") clicker.nextChat { ctx -> - if (ctx == "取消") + if (ctx == "取消") { + player.prettyInfo("操作已取消!") return@nextChat + } if (!ctx.isValidLandName()) { clicker.prettyInfo("为避免与领地编号混淆, 名字不能是纯数字!") return@nextChat @@ -127,13 +135,15 @@ object LandInfoMenu { colored() }) { if (!check(player, land)) return@set - when (virtualEvent().clickType) { + when (clickEvent().click) { ClickType.LEFT, ClickType.SHIFT_LEFT -> { clicker.closeInventory() clicker.prettyInfo("请在聊天框输入新的进入信息, 支持行内复合文本. 输入'取消'来取消操作!") clicker.nextChat { ctx -> - if (ctx == "取消") + if (ctx == "取消") { + player.prettyInfo("操作已取消!") return@nextChat + } land.enterMessage = ctx land.export() clicker.prettyInfo("修改成功!") @@ -161,13 +171,15 @@ object LandInfoMenu { colored() }) { if (!check(player, land)) return@set - when (virtualEvent().clickType) { + when (clickEvent().click) { ClickType.LEFT, ClickType.SHIFT_LEFT -> { clicker.closeInventory() clicker.prettyInfo("请在聊天框输入新的离开信息, 支持行内复合文本. 输入'取消'来取消操作!") clicker.nextChat { ctx -> - if (ctx == "取消") + if (ctx == "取消") { + player.prettyInfo("操作已取消!") return@nextChat + } land.leaveMessage = ctx land.export() clicker.prettyInfo("修改成功!") @@ -212,8 +224,10 @@ object LandInfoMenu { clicker.closeInventory() clicker.prettyInfo("请在聊天框输入新的玩家名, 或输入'取消'来取消操作!") clicker.nextChat { ctx -> - if (ctx == "取消") + if (ctx == "取消") { + player.prettyInfo("操作已取消!") return@nextChat + } val offlinePlayer = Bukkit.getOfflinePlayerIfCached(ctx) if (offlinePlayer == null) { clicker.prettyInfo("并没有找到这位玩家!") @@ -236,8 +250,10 @@ object LandInfoMenu { clicker.closeInventory() clicker.prettyInfo("你确定要删除吗? 输入'确认'来确认, 或输入其他内容来取消操作!") clicker.nextChat { ctx -> - if (ctx != "确认") + if (ctx != "确认") { + player.prettyInfo("操作已取消!") return@nextChat + } LandManager.lands -= land clicker.prettyInfo("已删除领地!") } diff --git a/src/main/kotlin/com/mcstarrysky/land/menu/LandListMenu.kt b/src/main/kotlin/com/mcstarrysky/land/menu/LandListMenu.kt index 46123e6..218c594 100644 --- a/src/main/kotlin/com/mcstarrysky/land/menu/LandListMenu.kt +++ b/src/main/kotlin/com/mcstarrysky/land/menu/LandListMenu.kt @@ -23,7 +23,7 @@ object LandListMenu { fun openMenu(player: Player, elements: List, back: Consumer?) { player.openMenu>("领地列表 #%p") { - virtualize() + // virtualize() map( "b======pn", @@ -57,7 +57,7 @@ object LandListMenu { } onClick { e, land -> - when (e.virtualEvent().clickType) { + when (e.clickEvent().click) { ClickType.LEFT, ClickType.SHIFT_LEFT -> { e.clicker.closeInventory() land.teleport(e.clicker) diff --git a/src/main/kotlin/com/mcstarrysky/land/menu/LandMainMenu.kt b/src/main/kotlin/com/mcstarrysky/land/menu/LandMainMenu.kt index a39003b..34610e0 100644 --- a/src/main/kotlin/com/mcstarrysky/land/menu/LandMainMenu.kt +++ b/src/main/kotlin/com/mcstarrysky/land/menu/LandMainMenu.kt @@ -26,7 +26,7 @@ object LandMainMenu { fun openMenu(player: Player, back: Consumer? = null) { player.openMenu("领地主菜单") { - virtualize() + // virtualize() map( "b========", diff --git a/src/main/kotlin/com/mcstarrysky/land/util/ChunkUtils.kt b/src/main/kotlin/com/mcstarrysky/land/util/ChunkUtils.kt index aeb86af..8ff8deb 100644 --- a/src/main/kotlin/com/mcstarrysky/land/util/ChunkUtils.kt +++ b/src/main/kotlin/com/mcstarrysky/land/util/ChunkUtils.kt @@ -3,6 +3,7 @@ package com.mcstarrysky.land.util import org.bukkit.Chunk import org.bukkit.Location import org.bukkit.World +import kotlin.math.abs /** * Land @@ -50,4 +51,12 @@ object ChunkUtils { return chunks } + + fun isAdjacentToAnyChunk(chunk: Chunk, chunkList: List): Boolean { + return chunkList.all { it.world == chunk.world } && chunkList.any { neighborChunk -> + val dx = abs(chunk.x - neighborChunk.x) + val dz = abs(chunk.z - neighborChunk.z) + (dx <= 1 && dz <= 1) && (dx != 0 || dz != 0) + } + } } \ No newline at end of file