diff --git a/README.md b/README.md
index 6409c761..936e1b51 100644
--- a/README.md
+++ b/README.md
@@ -49,8 +49,8 @@ Minecraft uses Maven to download dependencies, EMC is loaded as a dependency. To
```
{
- "name": "me.deftware:EMC:13.1.0",
- "url": "https://github.com/Moudoux/EMC/raw/master/maven/"
+ "name": "com.github.Moudoux:EMC:13.1.0",
+ "url": "https://jitpack.io/"
}
```
diff --git a/build.gradle b/build.gradle
index 4244a573..d4e21c0a 100644
--- a/build.gradle
+++ b/build.gradle
@@ -9,7 +9,7 @@ buildscript {
url = 'http://repo.spongepowered.org/maven'
}
maven {
- url "https://plugins.gradle.org/m2/"
+ url = "https://plugins.gradle.org/m2/"
}
}
@@ -20,9 +20,9 @@ buildscript {
}
}
-version '13.1.6'
-def minecraftVersion = "1.12.2";
-def forgeVersion = "-14.23.2.2611";
+version = '13.1.6'
+def minecraftVersion = "1.12.2"
+def forgeVersion = "-14.23.2.2611"
def forgeBuild = true
apply plugin: 'maven'
@@ -35,7 +35,7 @@ if (forgeBuild) {
apply plugin: 'org.spongepowered.mixin'
apply plugin: "com.github.johnrengelman.shadow"
-group 'me.deftware'
+group = 'me.deftware'
sourceCompatibility = targetCompatibility = 1.8
compileJava {
@@ -49,7 +49,7 @@ minecraft {
useDepAts = true
makeObfSourceJar = true
if (!forgeBuild) {
- tweakClass = 'me.deftware.launch.Launcher'
+ tweakClass = 'me.deftware.launch.Launcher'
}
}
@@ -78,7 +78,7 @@ dependencies {
}
mixin {
- defaultObfuscationEnv forgeBuild ? searge : notch
+ defaultObfuscationEnv = forgeBuild ? searge : notch
add sourceSets.main, "mixins.client.refmap.json"
}
@@ -86,30 +86,14 @@ shadowJar {
dependencies {
include(dependency('org.spongepowered:mixin'))
}
- classifier = 'full'
-}
-
-task createPom << {
- pom {
- project {
- groupId "me.deftware"
- artifactId "EMC"
- version "${version}-${minecraftVersion}"
- }
- }.writeTo("maven/me/deftware/EMC/${version}-${minecraftVersion}/EMC-${version}-${minecraftVersion}.pom")
-}
-
-task copyBuilds(type: Copy) {
- from "$rootDir/build/libs"
- into "$rootDir/maven/me/deftware/" + (forgeBuild ? "EMC-Forge" : "EMC") + "/${version}-${minecraftVersion}/"
- if (forgeBuild) {
- rename { String fileName ->
- fileName.replace("EMC", "EMC-Forge")
- }
+ manifest {
+ attributes 'Implementation-Title': 'EMC'
+ attributes 'Implementation-Version': version
}
- rename { String fileName ->
- fileName.replace(version, "${version}-${minecraftVersion}")
- }
+
+ exclude 'dummyThing'
+ exclude 'LICENSE.txt'
+ classifier = 'full'
}
reobf {
@@ -134,13 +118,8 @@ if (forgeBuild) {
println "Building for Minecraft..."
}
-delete "$rootDir/build/libs"
-delete "$rootDir/maven/me/deftware/" + (forgeBuild ? "EMC-Forge" : "EMC") + "/${version}-${minecraftVersion}"
build.dependsOn(shadowJar)
-if (!forgeBuild) {
- build.dependsOn(createPom)
-}
-build.dependsOn(copyBuilds)
+compileTestJava.dependsOn(shadowJar)
tasks.build.doLast(){
if (forgeBuild) {
diff --git a/example_client.json b/example_client.json
index b471c1d3..20fb3f1f 100644
--- a/example_client.json
+++ b/example_client.json
@@ -13,8 +13,8 @@
"name": "net.minecraft:launchwrapper:1.12"
},
{
- "name": "me.deftware:EMC:13.1.0",
- "url": "https://github.com/Moudoux/EMC/raw/master/maven/"
+ "name": "com.github.Moudoux:EMC:13.1.0",
+ "url": "https://jitpack.io/"
},
{
"name": "org.spongepowered:mixin:0.7.1-SNAPSHOT",
diff --git a/maven/me/deftware/EMC-Forge/13.1.6-1.12.2/EMC-Forge-13.1.6-1.12.2-full.jar b/maven/me/deftware/EMC-Forge/13.1.6-1.12.2/EMC-Forge-13.1.6-1.12.2-full.jar
deleted file mode 100644
index 46932638..00000000
Binary files a/maven/me/deftware/EMC-Forge/13.1.6-1.12.2/EMC-Forge-13.1.6-1.12.2-full.jar and /dev/null differ
diff --git a/maven/me/deftware/EMC-Forge/13.1.6-1.12.2/EMC-Forge-13.1.6-1.12.2-sources.jar b/maven/me/deftware/EMC-Forge/13.1.6-1.12.2/EMC-Forge-13.1.6-1.12.2-sources.jar
deleted file mode 100644
index b846e7d4..00000000
Binary files a/maven/me/deftware/EMC-Forge/13.1.6-1.12.2/EMC-Forge-13.1.6-1.12.2-sources.jar and /dev/null differ
diff --git a/maven/me/deftware/EMC-Forge/13.1.6-1.12.2/EMC-Forge-13.1.6-1.12.2.jar b/maven/me/deftware/EMC-Forge/13.1.6-1.12.2/EMC-Forge-13.1.6-1.12.2.jar
deleted file mode 100644
index a2db081b..00000000
Binary files a/maven/me/deftware/EMC-Forge/13.1.6-1.12.2/EMC-Forge-13.1.6-1.12.2.jar and /dev/null differ
diff --git a/maven/me/deftware/EMC-Forge/13.1.6/EMC-Forge-13.1.6-full.jar b/maven/me/deftware/EMC-Forge/13.1.6/EMC-Forge-13.1.6-full.jar
deleted file mode 100644
index 124e41d6..00000000
Binary files a/maven/me/deftware/EMC-Forge/13.1.6/EMC-Forge-13.1.6-full.jar and /dev/null differ
diff --git a/maven/me/deftware/EMC-Forge/13.1.6/EMC-Forge-13.1.6-sources.jar b/maven/me/deftware/EMC-Forge/13.1.6/EMC-Forge-13.1.6-sources.jar
deleted file mode 100644
index 1751d465..00000000
Binary files a/maven/me/deftware/EMC-Forge/13.1.6/EMC-Forge-13.1.6-sources.jar and /dev/null differ
diff --git a/maven/me/deftware/EMC-Forge/13.1.6/EMC-Forge-13.1.6.jar b/maven/me/deftware/EMC-Forge/13.1.6/EMC-Forge-13.1.6.jar
deleted file mode 100644
index 057aa6b0..00000000
Binary files a/maven/me/deftware/EMC-Forge/13.1.6/EMC-Forge-13.1.6.jar and /dev/null differ
diff --git a/maven/me/deftware/EMC/13.1.6-1.12.2/EMC-13.1.6-1.12.2-full.jar b/maven/me/deftware/EMC/13.1.6-1.12.2/EMC-13.1.6-1.12.2-full.jar
deleted file mode 100644
index a1978aac..00000000
Binary files a/maven/me/deftware/EMC/13.1.6-1.12.2/EMC-13.1.6-1.12.2-full.jar and /dev/null differ
diff --git a/maven/me/deftware/EMC/13.1.6-1.12.2/EMC-13.1.6-1.12.2-sources.jar b/maven/me/deftware/EMC/13.1.6-1.12.2/EMC-13.1.6-1.12.2-sources.jar
deleted file mode 100644
index e5de6a4f..00000000
Binary files a/maven/me/deftware/EMC/13.1.6-1.12.2/EMC-13.1.6-1.12.2-sources.jar and /dev/null differ
diff --git a/maven/me/deftware/EMC/13.1.6-1.12.2/EMC-13.1.6-1.12.2.jar b/maven/me/deftware/EMC/13.1.6-1.12.2/EMC-13.1.6-1.12.2.jar
deleted file mode 100644
index 24d3e3f9..00000000
Binary files a/maven/me/deftware/EMC/13.1.6-1.12.2/EMC-13.1.6-1.12.2.jar and /dev/null differ
diff --git a/maven/me/deftware/EMC/13.1.6-1.12.2/EMC-13.1.6-1.12.2.pom b/maven/me/deftware/EMC/13.1.6-1.12.2/EMC-13.1.6-1.12.2.pom
deleted file mode 100644
index 42f69706..00000000
--- a/maven/me/deftware/EMC/13.1.6-1.12.2/EMC-13.1.6-1.12.2.pom
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
- 4.0.0
- me.deftware
- EMC
- 13.1.6-1.12.2
-
-
- org.spongepowered
- mixin
- 0.7.5-SNAPSHOT
- compile
-
-
- launchwrapper
- *
-
-
- gson
- *
-
-
- guava
- *
-
-
- commons-io
- *
-
-
-
-
-
diff --git a/maven/me/deftware/EMC/13.1.6/EMC-13.1.6-full.jar b/maven/me/deftware/EMC/13.1.6/EMC-13.1.6-full.jar
deleted file mode 100644
index 2a0d6d9b..00000000
Binary files a/maven/me/deftware/EMC/13.1.6/EMC-13.1.6-full.jar and /dev/null differ
diff --git a/maven/me/deftware/EMC/13.1.6/EMC-13.1.6-sources.jar b/maven/me/deftware/EMC/13.1.6/EMC-13.1.6-sources.jar
deleted file mode 100644
index a3838690..00000000
Binary files a/maven/me/deftware/EMC/13.1.6/EMC-13.1.6-sources.jar and /dev/null differ
diff --git a/maven/me/deftware/EMC/13.1.6/EMC-13.1.6.jar b/maven/me/deftware/EMC/13.1.6/EMC-13.1.6.jar
deleted file mode 100644
index 40d578ce..00000000
Binary files a/maven/me/deftware/EMC/13.1.6/EMC-13.1.6.jar and /dev/null differ
diff --git a/maven/me/deftware/EMC/13.1.6/EMC-13.1.6.pom b/maven/me/deftware/EMC/13.1.6/EMC-13.1.6.pom
deleted file mode 100644
index 4667e3ed..00000000
--- a/maven/me/deftware/EMC/13.1.6/EMC-13.1.6.pom
+++ /dev/null
@@ -1,34 +0,0 @@
-
-
- 4.0.0
- me.deftware
- EMC
- 13.1.6
-
-
- org.spongepowered
- mixin
- 0.7.5-SNAPSHOT
- compile
-
-
- launchwrapper
- *
-
-
- gson
- *
-
-
- guava
- *
-
-
- commons-io
- *
-
-
-
-
-
diff --git a/src/main/java/me/deftware/mixin/annotations/ModInfo.java b/src/main/java/me/deftware/mixin/annotations/ModInfo.java
new file mode 100644
index 00000000..8f78285f
--- /dev/null
+++ b/src/main/java/me/deftware/mixin/annotations/ModInfo.java
@@ -0,0 +1,28 @@
+package me.deftware.mixin.annotations;
+
+import me.deftware.client.framework.main.EMCMod;
+
+import javax.annotation.Nonnull;
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@SuppressWarnings("unused")
+@Retention(RetentionPolicy.SOURCE)
+@Target(ElementType.TYPE)
+public @interface ModInfo {
+ @Nonnull String name();
+
+ @Nonnull String website();
+
+ @Nonnull String author();
+
+ @Nonnull Class extends EMCMod> main();
+
+ boolean updateLinkOverride();
+
+ double minversion();
+
+ double version();
+}
diff --git a/src/main/java/me/deftware/mixin/annotations/ModInfoProcessor.java b/src/main/java/me/deftware/mixin/annotations/ModInfoProcessor.java
new file mode 100644
index 00000000..3443f71d
--- /dev/null
+++ b/src/main/java/me/deftware/mixin/annotations/ModInfoProcessor.java
@@ -0,0 +1,182 @@
+package me.deftware.mixin.annotations;
+
+import me.deftware.client.framework.FrameworkConstants;
+
+import javax.annotation.processing.AbstractProcessor;
+import javax.annotation.processing.RoundEnvironment;
+import javax.annotation.processing.SupportedAnnotationTypes;
+import javax.annotation.processing.SupportedSourceVersion;
+import javax.lang.model.element.Element;
+import javax.lang.model.element.Modifier;
+import javax.lang.model.element.TypeElement;
+import javax.lang.model.type.DeclaredType;
+import javax.lang.model.type.ExecutableType;
+import javax.lang.model.type.MirroredTypeException;
+import javax.lang.model.type.TypeVisitor;
+import javax.lang.model.util.SimpleTypeVisitor8;
+import javax.tools.StandardLocation;
+import java.io.IOException;
+import java.io.Writer;
+import java.util.Arrays;
+import java.util.Objects;
+import java.util.Set;
+
+import static javax.lang.model.SourceVersion.RELEASE_8;
+import static javax.lang.model.element.ElementKind.CONSTRUCTOR;
+import static javax.lang.model.element.Modifier.PUBLIC;
+
+@SupportedAnnotationTypes("me.deftware.mixin.annotations.ModInfo")
+@SupportedSourceVersion(RELEASE_8)
+public class ModInfoProcessor extends AbstractProcessor {
+ private final TypeVisitor checkInternalClassForStatic = new SimpleTypeVisitor8() {
+ @Override
+ public Void visitDeclared(final DeclaredType t,
+ final Void aVoid) {
+ if (t.asElement().getEnclosingElement().getKind().isClass()) {
+ t.asElement().getEnclosingElement().asType().accept(
+ this,
+ null
+ );
+ if (!t.asElement().getModifiers().contains(Modifier.STATIC)) {
+ throw new RuntimeException(String.format(
+ "EMCMod must be instantiable via .newInstance(): class %s must be declared static.",
+ t.toString()
+ ));
+ }
+ }
+ if (!t.asElement().getModifiers().contains(Modifier.PUBLIC)) {
+ throw new RuntimeException(String.format(
+ "EMCMod must be instantiable via .newInstance(): class %s must be declared public.",
+ t.toString()
+ ));
+ }
+ return null;
+ }
+ };
+ private TypeVisitor noArgsVisitor = new SimpleTypeVisitor8() {
+ @Override
+ public Boolean visitExecutable(final ExecutableType t,
+ final Void aVoid) {
+ return t.getParameterTypes().isEmpty();
+ }
+ };
+ private final TypeVisitor classValidatingVisitor = new SimpleTypeVisitor8() {
+ @Override
+ public Void visitDeclared(final DeclaredType t,
+ final Void aVoid) {
+ if (t.asElement().getEnclosingElement().getKind().isClass()) {
+ t.asElement().getEnclosingElement().asType().accept(
+ checkInternalClassForStatic,
+ null
+ );
+ }
+ if (!t.asElement().getModifiers().contains(Modifier.PUBLIC)) {
+ throw new RuntimeException(String.format(
+ "EMCMod must be instantiable via .newInstance(): class %s must be declared public.",
+ t.toString()
+ ));
+ }
+ if (t.asElement().getEnclosedElements().stream().filter(subelement -> subelement.getKind() == CONSTRUCTOR && subelement.getModifiers().contains(PUBLIC)).map(Element::asType).anyMatch(typeMirror -> typeMirror.accept(
+ noArgsVisitor,
+ null
+ ))) {
+ return null;
+ } else {
+ throw new RuntimeException(String.format(
+ "EMCMod must be instantiable via .newInstance(): class %s must define publicly accessible no args constructor.",
+ t.toString()
+ ));
+ }
+ }
+ };
+ private TypeVisitor nameFetchingVisitor = new SimpleTypeVisitor8() {
+ @Override
+ public String visitDeclared(final DeclaredType t,
+ final Void aVoid) {
+ return t.toString();
+ }
+ };
+
+ @Override
+ public boolean process(final Set extends TypeElement> annotations,
+ final RoundEnvironment roundEnv) {
+ boolean alreadyProcessed = false;
+ if (!roundEnv.processingOver()) {
+ for (TypeElement type : annotations) {
+ for (Element element : roundEnv.getElementsAnnotatedWith(type)) {
+ if (alreadyProcessed) {
+ throw new RuntimeException("Too many ModInfo annotations for one given library.");
+ }
+ ModInfo modInfo = element.getAnnotation(ModInfo.class);
+ checkValid(modInfo);
+ String json = fromAnnotation(modInfo);
+ try (
+ Writer writer = processingEnv.getFiler().createResource(
+ StandardLocation.CLASS_OUTPUT,
+ "",
+ "client.json"
+ ).openWriter()
+ ) {
+ writer.write(json);
+ } catch (IOException e) {
+ e.printStackTrace();
+ }
+ alreadyProcessed = true;
+ }
+ }
+ if (!alreadyProcessed) {
+ throw new RuntimeException("Must have one class declared with ModInfo (preferably, an implementation of EMCMod).");
+ }
+ }
+ return true;
+ }
+
+ private void checkValid(final ModInfo annotation) {
+ Arrays.asList(
+ annotation.author(),
+ annotation.name(),
+ annotation.website()
+ ).forEach(Objects::requireNonNull);
+ try {
+ annotation.main();
+ } catch (MirroredTypeException mte) {
+ mte.getTypeMirror().accept(
+ classValidatingVisitor,
+ null
+ );
+ }
+ if (annotation.minversion() > FrameworkConstants.VERSION) {
+ throw new RuntimeException(String.format(
+ "This version of EMC is less than specified version for %s (%s > %s).",
+ getModClassname(annotation),
+ annotation.minversion(),
+ FrameworkConstants.VERSION
+ ));
+ }
+ }
+
+ private String fromAnnotation(final ModInfo annotation) {
+ return String.format(
+ "{\n \"name\":\"%s\",\n \"website\":\"%s\",\n \"author\":\"%s\",\n \"minversion\":%s,\n \"version\":%s,\n \"main\":\"%s\",\n \"updateLinkOverride\":%s\n}\n",
+ annotation.name(),
+ annotation.website(),
+ annotation.author(),
+ annotation.minversion(),
+ annotation.version(),
+ getModClassname(annotation),
+ annotation.updateLinkOverride()
+ );
+ }
+
+ private String getModClassname(final ModInfo annotation) {
+ try {
+ annotation.main();
+ } catch (MirroredTypeException mte) {
+ return mte.getTypeMirror().accept(
+ nameFetchingVisitor,
+ null
+ );
+ }
+ return null;
+ }
+}
diff --git a/src/main/resources/META-INF/services/javax.annotation.processing.Processor b/src/main/resources/META-INF/services/javax.annotation.processing.Processor
new file mode 100644
index 00000000..95899d06
--- /dev/null
+++ b/src/main/resources/META-INF/services/javax.annotation.processing.Processor
@@ -0,0 +1 @@
+me.deftware.mixin.annotations.ModInfoProcessor
diff --git a/src/test/java/io/github/trulyfree/testmods/TestEMCMod.java b/src/test/java/io/github/trulyfree/testmods/TestEMCMod.java
new file mode 100644
index 00000000..2ae3680f
--- /dev/null
+++ b/src/test/java/io/github/trulyfree/testmods/TestEMCMod.java
@@ -0,0 +1,27 @@
+package io.github.trulyfree.testmods;
+
+import me.deftware.client.framework.event.Event;
+import me.deftware.client.framework.main.EMCMod;
+import me.deftware.mixin.annotations.ModInfo;
+
+@ModInfo(name = "testmod",
+ author = "vtcakavsmoace",
+ main = TestEMCMod.class,
+ updateLinkOverride = false,
+ website = "https://google.com",
+ minversion = 13.0,
+ version = 1)
+public class TestEMCMod extends EMCMod {
+ @Override
+ public void initialize() {
+ }
+
+ @Override
+ public EMCClientInfo getClientInfo() {
+ return null;
+ }
+
+ @Override
+ public void onEvent(final Event event) {
+ }
+}