1.7 velocity support
This commit is contained in:
parent
bba80af506
commit
66f4ba911f
|
|
@ -6,7 +6,7 @@ plugins {
|
||||||
}
|
}
|
||||||
|
|
||||||
group 'io.izzel.taboolib'
|
group 'io.izzel.taboolib'
|
||||||
version '1.6'
|
version '1.7'
|
||||||
|
|
||||||
configurations {
|
configurations {
|
||||||
embed
|
embed
|
||||||
|
|
|
||||||
|
|
@ -1,6 +1,5 @@
|
||||||
package io.izzel.taboolib.gradle
|
package io.izzel.taboolib.gradle
|
||||||
|
|
||||||
import com.google.gson.Gson
|
|
||||||
import com.google.gson.GsonBuilder
|
import com.google.gson.GsonBuilder
|
||||||
import org.gradle.api.Project
|
import org.gradle.api.Project
|
||||||
import com.google.gson.JsonArray
|
import com.google.gson.JsonArray
|
||||||
|
|
@ -21,7 +20,7 @@ class Description {
|
||||||
def api = "1.0.0"
|
def api = "1.0.0"
|
||||||
def apiVersion = '1.13'
|
def apiVersion = '1.13'
|
||||||
def libraries
|
def libraries
|
||||||
def dependencies = "spongeapi@7.2.0"
|
def dependencies
|
||||||
def requiredMods = "spongeapi@7.2.0"
|
def requiredMods = "spongeapi@7.2.0"
|
||||||
|
|
||||||
static List<String> buildFile() {
|
static List<String> buildFile() {
|
||||||
|
|
@ -123,12 +122,19 @@ class Description {
|
||||||
}
|
}
|
||||||
if (dependencies instanceof List<String>) {
|
if (dependencies instanceof List<String>) {
|
||||||
def arr = new JsonArray()
|
def arr = new JsonArray()
|
||||||
|
if (dependencies.none { "spongeapi" in it }) {
|
||||||
|
arr.add("spongeapi@7.2.0")
|
||||||
|
}
|
||||||
dependencies.each { arr.add(it) }
|
dependencies.each { arr.add(it) }
|
||||||
info.add("dependencies", arr)
|
info.add("dependencies", arr)
|
||||||
} else if (dependencies != null) {
|
} else if (dependencies != null) {
|
||||||
def arr = new JsonArray()
|
def arr = new JsonArray()
|
||||||
arr.add(dependencies.toString())
|
arr.add(dependencies.toString())
|
||||||
info.add("dependencies", arr)
|
info.add("dependencies", arr)
|
||||||
|
} else {
|
||||||
|
def arr = new JsonArray()
|
||||||
|
arr.add("spongeapi@7.2.0")
|
||||||
|
info.add("dependencies", arr)
|
||||||
}
|
}
|
||||||
if (requiredMods instanceof List<String>) {
|
if (requiredMods instanceof List<String>) {
|
||||||
def arr = new JsonArray()
|
def arr = new JsonArray()
|
||||||
|
|
@ -143,6 +149,35 @@ class Description {
|
||||||
return new GsonBuilder().setPrettyPrinting().create().toJson(base).getBytes(StandardCharsets.UTF_8)
|
return new GsonBuilder().setPrettyPrinting().create().toJson(base).getBytes(StandardCharsets.UTF_8)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
byte[] buildVelocityFile(Project project) {
|
||||||
|
def base = new JsonArray()
|
||||||
|
def info = new JsonObject()
|
||||||
|
info.addProperty("id", project.name.toLowerCase())
|
||||||
|
info.addProperty("name", project.name)
|
||||||
|
info.addProperty("main", "${project.group}.taboolib.platform.VelocityPlugin")
|
||||||
|
info.addProperty("version", project.version.toString())
|
||||||
|
if (authors instanceof List<String>) {
|
||||||
|
def arr = new JsonArray()
|
||||||
|
authors.each { arr.add(it) }
|
||||||
|
info.add("authors", arr)
|
||||||
|
} else if (authors != null) {
|
||||||
|
def arr = new JsonArray()
|
||||||
|
arr.add(authors.toString())
|
||||||
|
info.add("authors", arr)
|
||||||
|
}
|
||||||
|
if (dependencies instanceof List<String>) {
|
||||||
|
def arr = new JsonArray()
|
||||||
|
dependencies.each { arr.add(it) }
|
||||||
|
info.add("dependencies", arr)
|
||||||
|
} else if (dependencies != null) {
|
||||||
|
def arr = new JsonArray()
|
||||||
|
arr.add(dependencies.toString())
|
||||||
|
info.add("dependencies", arr)
|
||||||
|
}
|
||||||
|
base.add(info)
|
||||||
|
return new GsonBuilder().setPrettyPrinting().create().toJson(base).getBytes(StandardCharsets.UTF_8)
|
||||||
|
}
|
||||||
|
|
||||||
def author(author) {
|
def author(author) {
|
||||||
this.authors = author
|
this.authors = author
|
||||||
}
|
}
|
||||||
|
|
|
||||||
|
|
@ -4,11 +4,11 @@ import org.gradle.api.Project
|
||||||
import org.objectweb.asm.AnnotationVisitor
|
import org.objectweb.asm.AnnotationVisitor
|
||||||
import org.objectweb.asm.Opcodes
|
import org.objectweb.asm.Opcodes
|
||||||
|
|
||||||
class SpongeAnnotationVisitor extends AnnotationVisitor {
|
class PluginAnnotationVisitor extends AnnotationVisitor {
|
||||||
|
|
||||||
Project project
|
Project project
|
||||||
|
|
||||||
SpongeAnnotationVisitor(AnnotationVisitor annotationVisitor, project) {
|
PluginAnnotationVisitor(AnnotationVisitor annotationVisitor, project) {
|
||||||
super(Opcodes.ASM7, annotationVisitor)
|
super(Opcodes.ASM7, annotationVisitor)
|
||||||
this.project = project
|
this.project = project
|
||||||
}
|
}
|
||||||
|
|
@ -128,6 +128,10 @@ class RelocateJar extends DefaultTask {
|
||||||
out.putNextEntry(new JarEntry("mcmod.info"))
|
out.putNextEntry(new JarEntry("mcmod.info"))
|
||||||
out.write(tabooExt.description.buildSpongeFile(project))
|
out.write(tabooExt.description.buildSpongeFile(project))
|
||||||
}
|
}
|
||||||
|
if (tabooExt.modules.contains("platform-velocity")) {
|
||||||
|
out.putNextEntry(new JarEntry("velocity-plugin.json"))
|
||||||
|
out.write(tabooExt.description.buildVelocityFile(project))
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Files.copy(tempOut2.toPath(), outJar.toPath(), StandardCopyOption.REPLACE_EXISTING)
|
Files.copy(tempOut2.toPath(), outJar.toPath(), StandardCopyOption.REPLACE_EXISTING)
|
||||||
|
|
|
||||||
|
|
@ -26,8 +26,8 @@ class TabooLibClassVisitor extends ClassVisitor {
|
||||||
AnnotationVisitor visitAnnotation(String descriptor, boolean visible) {
|
AnnotationVisitor visitAnnotation(String descriptor, boolean visible) {
|
||||||
if (descriptor == "L${project.group.replace('.', '/')}/taboolib/common/Isolated;") {
|
if (descriptor == "L${project.group.replace('.', '/')}/taboolib/common/Isolated;") {
|
||||||
return new IsolatedAnnotationVisitor(super.visitAnnotation(descriptor, visible), project, name, this)
|
return new IsolatedAnnotationVisitor(super.visitAnnotation(descriptor, visible), project, name, this)
|
||||||
} else if (descriptor == "Lorg/spongepowered/api/plugin/Plugin;") {
|
} else if (descriptor == "Lorg/spongepowered/api/plugin/Plugin;" || descriptor == "Lcom/velocitypowered/api/plugin/Plugin;") {
|
||||||
return new SpongeAnnotationVisitor(super.visitAnnotation(descriptor, visible), project)
|
return new PluginAnnotationVisitor(super.visitAnnotation(descriptor, visible), project)
|
||||||
} else {
|
} else {
|
||||||
return super.visitAnnotation(descriptor, visible)
|
return super.visitAnnotation(descriptor, visible)
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Reference in New Issue