diff --git a/Scripts/Mythicmobs_Support.superitem.kts b/Scripts/Mythicmobs_Support.superitem.kts index be07ac2..b82b229 100644 --- a/Scripts/Mythicmobs_Support.superitem.kts +++ b/Scripts/Mythicmobs_Support.superitem.kts @@ -11,7 +11,6 @@ listen{ val name = (it.dropName as String).toUpperCase() if(!name.startsWith("SI_"))return@listen val item = ItemManager.getItem(name.substring(3)) - //if(item==null)it.register(NothingDrop(it.config.line,it.config)) if(item!=null)it.register(ItemDrop(it.config.line,it.config,BukkitItemStack(item.get().newItemStack()))) } diff --git a/build.gradle b/build.gradle index c22989b..da9bb71 100644 --- a/build.gradle +++ b/build.gradle @@ -2,11 +2,11 @@ plugins { id 'com.github.johnrengelman.shadow' version '5.0.0' id 'java' - id 'org.jetbrains.kotlin.jvm' version "1.3.41" + id 'org.jetbrains.kotlin.jvm' version "1.3.61" id 'me.qoomon.git-versioning' version '1.2.1' } ext{ - kotlin_version ="1.3.41" + kotlin_version ="1.3.61" mc_version = '1.14-R0.1-SNAPSHOT' bc_version ='1.12-SNAPSHOT' } @@ -14,6 +14,7 @@ ext{ allprojects{ group = 'cf.wayzer' repositories { + maven{ url "http://maven.aliyun.com/nexus/content/groups/public/"} jcenter() mavenCentral() maven { @@ -28,7 +29,9 @@ shadowJar { // minimize() configurations = [project.configurations.shadow] relocate("me.dpohvar.powernbt.api","cf.wayzer.util.nbt") + relocate("me.dpohvar.powernbt.nbt","cf.wayzer.util.nbt.nbt") relocate("me.dpohvar.powernbt.utils","cf.wayzer.util.nbt.utils") + relocate("me.dpohvar.powernbt.exception","cf.wayzer.util.nbt.exception") // exclude("me/**") // exclude("example/**") // exclude("(?!plugin).yml") @@ -36,6 +39,8 @@ shadowJar { //for NBT include("me/dpohvar/powernbt/api/**") include("me/dpohvar/powernbt/utils/**") + include("me/dpohvar/powernbt/nbt/**") + include("me/dpohvar/powernbt/exception/**") include("cf/wayzer/**") include("*.kts") @@ -47,7 +52,7 @@ shadowJar { //start dependencies{ - shadow 'cf.wayzer:LibraryManager:1.2' + shadow 'cf.wayzer:LibraryManager:1.3' shadow(files("$rootDir/lib/PowerNBT.jar")) compile "org.jetbrains.kotlin:kotlin-script-util:$kotlin_version" compile "org.jetbrains.kotlin:kotlin-scripting-jvm-host:$kotlin_version" @@ -74,7 +79,7 @@ processResources{ } } } -def items = subprojects[0] as Project +def items = subprojects.first() task buildArtifact(type: Zip){ dependsOn items.getTasksByName("classes",false) dependsOn shadowJar @@ -93,3 +98,11 @@ task buildArtifact(type: Zip){ archiveFileName = "SuperItem-${rootProject.version}.zip" destinationDirectory =file("$rootDir/artifacts/") } + +task develCopy(type: Copy){ + dependsOn shadowJar + from(shadowJar.getArchiveFile()){ + rename("-all","") + } + into "F:\\minecraft\\RogInkTestServer\\plugins" +} diff --git a/gradle/wrapper/gradle-wrapper.properties b/gradle/wrapper/gradle-wrapper.properties index 696a69e..55cab99 100644 --- a/gradle/wrapper/gradle-wrapper.properties +++ b/gradle/wrapper/gradle-wrapper.properties @@ -1,5 +1,5 @@ distributionBase=GRADLE_USER_HOME distributionPath=wrapper/dists -distributionUrl=https://services.gradle.org/distributions/gradle-5.4.1-bin.zip +distributionUrl=https://services.gradle.org/distributions/gradle-6.1.1-bin.zip zipStoreBase=GRADLE_USER_HOME zipStorePath=wrapper/dists diff --git a/items/src/main/kotlin/Eggs_Gun.kt b/items/src/main/kotlin/Eggs_Gun.kt index d98f9f7..3f71990 100644 --- a/items/src/main/kotlin/Eggs_Gun.kt +++ b/items/src/main/kotlin/Eggs_Gun.kt @@ -8,7 +8,6 @@ import org.bukkit.DyeColor import org.bukkit.Material import org.bukkit.Sound import org.bukkit.block.Block -import org.bukkit.block.data.BlockData import org.bukkit.entity.EntityType import org.bukkit.entity.Monster import org.bukkit.entity.Player @@ -23,6 +22,7 @@ import org.bukkit.event.entity.ProjectileHitEvent import org.bukkit.event.player.PlayerInteractEvent import org.bukkit.event.server.PluginDisableEvent import org.bukkit.material.Colorable +import org.bukkit.material.MaterialData import org.bukkit.scheduler.BukkitRunnable import java.util.* @@ -36,17 +36,17 @@ class Eggs_Gun : Item() { internal var time: Byte = 0 init { - val data = block.blockData as Colorable + val data = block.state.data as Colorable old_color = data.color?:DyeColor.WHITE time = 20 data.color = DyeColor.RED - block.blockData = data as BlockData + block.state.data = data as MaterialData } fun setback() { - val data = block.blockData as Colorable + val data = block.state.data as Colorable data.color = old_color - block.blockData = data as BlockData + block.state.data = data as MaterialData } } @@ -104,16 +104,16 @@ class Eggs_Gun : Item() { @EventHandler fun onHit(e: ProjectileHitEvent) { if (e.entityType == EntityType.SNOWBALL && "§7雪球来复枪" == e.entity.customName - && e.entity.shooter is Player) { - val snow = e.entity - val loc = snow.location.block.location + && e.entity.shooter is Player && e.hitBlock !=null) { +// val snow = e.entity + val loc = e.hitBlock!!.location for (i in -1..1) for (i1 in -1..1) for (i11 in -1..1) if (i == 0 || i1 == 0 || i11 == 0) { val b = loc.world!!.getBlockAt(loc.blockX + i, loc.blockY + i1, loc.blockZ + i11) - if(b.blockData is Colorable && (b.blockData as Colorable).color != DyeColor.RED){ + if(b.state.data is Colorable && (b.state.data as Colorable).color != DyeColor.RED){ blocks.add(BlockInfo(b)) } } diff --git a/src/main/kotlin/cf/wayzer/SuperItem/Commander.kt b/src/main/kotlin/cf/wayzer/SuperItem/Commander.kt index 7735460..87fe608 100644 --- a/src/main/kotlin/cf/wayzer/SuperItem/Commander.kt +++ b/src/main/kotlin/cf/wayzer/SuperItem/Commander.kt @@ -128,7 +128,7 @@ class Commander : CommandExecutor { var i = pages * 10 - 10 while (i < list.size && i < pages * 10) { s.sendMessage(String.format("§e%03d §a|§e %-20s §a|§e %s", - i, list[i].name, list[i].get().newItemStack().itemMeta.displayName)) + i, list[i].name, list[i].get().newItemStack().itemMeta?.displayName)) i++ } s.sendMessage("§a================ §7$pages/$maxpages §a================") diff --git a/src/main/kotlin/cf/wayzer/SuperItem/ConfigManager.kt b/src/main/kotlin/cf/wayzer/SuperItem/ConfigManager.kt index 4acf265..0e0b125 100644 --- a/src/main/kotlin/cf/wayzer/SuperItem/ConfigManager.kt +++ b/src/main/kotlin/cf/wayzer/SuperItem/ConfigManager.kt @@ -43,5 +43,5 @@ object ConfigManager{ get() = map.getOrPut(this){ readFile(configFile) } private val Item.configFile:File - get() = File(rootDir, "$packageName ${File.pathSeparator} $name.json") + get() = File(rootDir, "$packageName/$name.json") } diff --git a/src/main/kotlin/cf/wayzer/SuperItem/Item.kt b/src/main/kotlin/cf/wayzer/SuperItem/Item.kt index 8ce4e2b..d950ea8 100644 --- a/src/main/kotlin/cf/wayzer/SuperItem/Item.kt +++ b/src/main/kotlin/cf/wayzer/SuperItem/Item.kt @@ -1,8 +1,6 @@ package cf.wayzer.SuperItem -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 @@ -37,23 +35,11 @@ abstract class Item : Listener { val features : MutableMap,MutableList>> = mutableMapOf() - @Deprecated("保证扩展和安全,请使用get,1.3版本弃用",ReplaceWith("get().newItemStack()")) - val item - get() = get().newItemStack() - - @Deprecated("保证扩展和安全,请使用get,1.3版本弃用",ReplaceWith("get()")) - val permission - get() = get() - - @Deprecated("保证扩展和安全,请使用get,1.3版本弃用",ReplaceWith("get()")) - val coolDown - get() = get() - open val name: String - get() = javaClass.simpleName + get() = javaClass.simpleName.toUpperCase() open val packageName: String - get() = javaClass.`package`.name + get() = javaClass.`package`?.name?:"ROOT" /** @@ -103,7 +89,7 @@ abstract class Item : Listener { } fun drop(location: Location,player: Player?=null){ - location.world.dropItem(location,get().newItemStack(player)) + location.world?.dropItem(location,get().newItemStack(player)) } /** @@ -135,19 +121,6 @@ abstract class Item : Listener { */ val pluginMain = Main.main as JavaPlugin - - @Deprecated("不建议直接使用,1.3版本弃用", ReplaceWith("get().hasPermission(p)")) - fun Item.hasPermission(p: Player) = - get().hasPermission(p) - - @Deprecated("不建议直接使用,1.3版本弃用", ReplaceWith("get().isCoolDownOK(p)")) - fun Item.isCoolDownOK(p: Player) = - get().isCoolDownOK(p) - - @Deprecated("不建议直接使用,1.3版本弃用", ReplaceWith("get().add(p)")) - fun Item.addCoolDown(p: Player) = - get().add(p) - /** * 消耗玩家指定物品 * @param item 需要消耗的物品 diff --git a/src/main/kotlin/cf/wayzer/SuperItem/ItemManager.kt b/src/main/kotlin/cf/wayzer/SuperItem/ItemManager.kt index 86e31fd..1e5501c 100644 --- a/src/main/kotlin/cf/wayzer/SuperItem/ItemManager.kt +++ b/src/main/kotlin/cf/wayzer/SuperItem/ItemManager.kt @@ -29,7 +29,6 @@ object ItemManager { ucl = URLClassLoader.newInstance(arrayOf(rootDir.toURI().toURL()), ItemManager::class.java.classLoader) loadDir(rootDir,"") - Main.main.saveConfig() } private fun loadDir(dir:File,prefix:String){ @@ -129,7 +128,7 @@ object ItemManager { * 通过 Item.class.simpleName 查询Item */ fun getItem(className: String): Item? { - return items[className] + return items[className.toUpperCase()] } /** diff --git a/src/main/kotlin/cf/wayzer/SuperItem/Main.kt b/src/main/kotlin/cf/wayzer/SuperItem/Main.kt index 1d37420..de41fe4 100644 --- a/src/main/kotlin/cf/wayzer/SuperItem/Main.kt +++ b/src/main/kotlin/cf/wayzer/SuperItem/Main.kt @@ -24,12 +24,12 @@ class Main : JavaPlugin() { } companion object { - const val kotlinVersion = "1.3.41" + const val kotlinVersion = "1.3.61" lateinit var main: Main private set init { LibraryManager(Paths.get("./libs/")).apply { - addMavenCentral() + addAliYunMirror() require(Dependency("org.jetbrains.kotlin:kotlin-reflect:$kotlinVersion")) require(Dependency("org.jetbrains.kotlinx:kotlinx-coroutines-core:1.1.1")) require(Dependency("org.jetbrains.kotlin:kotlin-stdlib:$kotlinVersion")) diff --git a/src/main/kotlin/cf/wayzer/SuperItem/features/ItemInfo.kt b/src/main/kotlin/cf/wayzer/SuperItem/features/ItemInfo.kt index 37abdaf..0acbcfb 100644 --- a/src/main/kotlin/cf/wayzer/SuperItem/features/ItemInfo.kt +++ b/src/main/kotlin/cf/wayzer/SuperItem/features/ItemInfo.kt @@ -49,9 +49,9 @@ class ItemInfo( 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("&","§") } + itemStack.itemMeta = itemStack.itemMeta?.apply { + setDisplayName(displayName.replace("&","§")) + lore = lore?.map { it.replace("&","§") } } return itemStack } @@ -63,8 +63,7 @@ class ItemInfo( fun registerHandler(handler: ItemStackHandler)=itemStackHandlers.add(handler) override fun onPostLoad(main: Main) { - @Suppress("DEPRECATION") - val itemStack = ItemStack(data.material, 1, 0,data.data.toByte()) + val itemStack = ItemStack(data.material, 1) val im = itemStack.itemMeta!! im.setDisplayName(data.name) diff --git a/src/main/kotlin/cf/wayzer/SuperItem/features/NBT.kt b/src/main/kotlin/cf/wayzer/SuperItem/features/NBT.kt index e27661d..02ff4b8 100644 --- a/src/main/kotlin/cf/wayzer/SuperItem/features/NBT.kt +++ b/src/main/kotlin/cf/wayzer/SuperItem/features/NBT.kt @@ -2,8 +2,8 @@ package cf.wayzer.SuperItem.features import cf.wayzer.SuperItem.Feature import cf.wayzer.SuperItem.Main -import me.dpohvar.powernbt.PowerNBT import me.dpohvar.powernbt.api.NBTCompound +import me.dpohvar.powernbt.api.NBTManager import java.util.logging.Level /** @@ -71,6 +71,6 @@ class NBT(override vararg val defaultData: AttributeModifier) : Feature logger.log(Level.WARNING,"##$index##"+rep.message,rep.exception) } - return@onSuccess ResultWithDiagnostics.Success(ResultValue.Unit) + return@onSuccess ResultWithDiagnostics.Success(res) } else { return@onSuccess ResultWithDiagnostics.Failure(ScriptDiagnostic("非物品Kts: ${file.name}")) } @@ -55,4 +55,4 @@ class ScriptLoader { constructorArgs(f.name.split(".")[0].toUpperCase()) }) } -} \ No newline at end of file +} diff --git a/src/main/kotlin/cf/wayzer/SuperItem/scripts/ScriptSupporter.kt b/src/main/kotlin/cf/wayzer/SuperItem/scripts/ScriptSupporter.kt index fc44512..02fd432 100644 --- a/src/main/kotlin/cf/wayzer/SuperItem/scripts/ScriptSupporter.kt +++ b/src/main/kotlin/cf/wayzer/SuperItem/scripts/ScriptSupporter.kt @@ -15,7 +15,7 @@ object ScriptSupporter { fun init(logger:Logger){ if(inited)return LibraryManager(Paths.get("./libs/")).apply { - addMavenCentral() + addAliYunMirror() require(Dependency("org.jetbrains.kotlin:kotlin-script-runtime:${Main.kotlinVersion}")) require(Dependency("org.jetbrains.kotlin:kotlin-scripting-common:${Main.kotlinVersion}")) require(Dependency("org.jetbrains.intellij.deps:trove4j:1.0.20181211")) @@ -36,4 +36,4 @@ object ScriptSupporter { if(!inited)throw IllegalStateException("Must init first!!") return loader.load(file) } -} \ No newline at end of file +} diff --git a/src/main/resources/META-INF/kotlin/script/templates/cf.wayzer.SuperItem.ScriptSupporter$SuperItemScript b/src/main/resources/META-INF/kotlin/script/templates/cf.wayzer.SuperItem.ScriptSupporter$SuperItemScript deleted file mode 100644 index e69de29..0000000