diff --git a/build.gradle b/build.gradle index 5db30a3..3c5bcf1 100644 --- a/build.gradle +++ b/build.gradle @@ -78,7 +78,7 @@ task buildArtifact(type: Zip){ from(shadowJar.getArchiveFile()){ rename("-all","") } - archiveFileName ="SuperItem-${version}.zip" + archiveFileName = "SuperItem-${version.toString()}.zip" destinationDirectory =file("$rootDir/artifacts/") } artifacts { diff --git a/src/main/kotlin/cf/wayzer/SuperItem/Commander.kt b/src/main/kotlin/cf/wayzer/SuperItem/Commander.kt index 779683c..7735460 100644 --- a/src/main/kotlin/cf/wayzer/SuperItem/Commander.kt +++ b/src/main/kotlin/cf/wayzer/SuperItem/Commander.kt @@ -64,6 +64,11 @@ class Commander : CommandExecutor { } if (item.givePlayer(player)) s.sendMessage("§a给予成功") + else{ + item.drop(player.location,player) + player.sendMessage("§a背包已满,已掉落") + s.sendMessage("§e背包已满,已掉落") + } } private fun getItem(s: CommandSender, args: Array) { diff --git a/src/main/kotlin/cf/wayzer/SuperItem/Item.kt b/src/main/kotlin/cf/wayzer/SuperItem/Item.kt index 722fc97..bc9cc36 100644 --- a/src/main/kotlin/cf/wayzer/SuperItem/Item.kt +++ b/src/main/kotlin/cf/wayzer/SuperItem/Item.kt @@ -4,6 +4,7 @@ import cf.wayzer.SuperItem.features.CoolDown import cf.wayzer.SuperItem.features.ItemInfo import cf.wayzer.SuperItem.features.Permission import org.bukkit.Bukkit +import org.bukkit.Location import org.bukkit.entity.Player import org.bukkit.event.Event import org.bukkit.event.EventPriority @@ -101,6 +102,10 @@ abstract class Item : Listener { return true } + fun drop(location: Location,player: Player?=null){ + location.world.dropItem(location,get().newItemStack(player)) + } + /** * 判断物品是否是当前Item的道具 */ diff --git a/src/main/kotlin/cf/wayzer/SuperItem/events/ItemStackHandleEvent.kt b/src/main/kotlin/cf/wayzer/SuperItem/events/ItemStackHandleEvent.kt new file mode 100644 index 0000000..e877c98 --- /dev/null +++ b/src/main/kotlin/cf/wayzer/SuperItem/events/ItemStackHandleEvent.kt @@ -0,0 +1,14 @@ +package cf.wayzer.SuperItem.events + +import org.bukkit.entity.Player +import org.bukkit.event.Event +import org.bukkit.event.HandlerList +import org.bukkit.inventory.ItemStack + +data class ItemStackHandleEvent (var itemStack:ItemStack,val player:Player?):Event() { + override fun getHandlers()=staticHandlers + + companion object{ + private val staticHandlers = HandlerList() + } +} \ No newline at end of file diff --git a/src/main/kotlin/cf/wayzer/SuperItem/features/ItemInfo.kt b/src/main/kotlin/cf/wayzer/SuperItem/features/ItemInfo.kt index 1b89fe6..24e09ec 100644 --- a/src/main/kotlin/cf/wayzer/SuperItem/features/ItemInfo.kt +++ b/src/main/kotlin/cf/wayzer/SuperItem/features/ItemInfo.kt @@ -2,6 +2,8 @@ package cf.wayzer.SuperItem.features import cf.wayzer.SuperItem.Feature import cf.wayzer.SuperItem.Main +import cf.wayzer.SuperItem.Main.Companion.main +import cf.wayzer.SuperItem.events.ItemStackHandleEvent import org.bukkit.Material import org.bukkit.entity.Player import org.bukkit.inventory.ItemStack @@ -48,6 +50,11 @@ class ItemInfo( fun newItemStack(p:Player?=null):ItemStack{ val itemStack = itemStackTemplate.clone() itemStackHandlers.forEach { it(itemStack,p) } + main.server.pluginManager.callEvent(ItemStackHandleEvent(itemStack,p)) + itemStack.itemMeta = itemStack.itemMeta.apply { + displayName = displayName.replace("&","§") + lore = lore.map { it.replace("&","§") } + } return itemStack }