Merge pull request 'Linkage' (#22) from Linkage into master
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful
Reviewed-on: #22
Dieser Commit ist enthalten in:
Commit
d90938eff2
@ -31,6 +31,6 @@ public @interface AllowedContexts {
|
|||||||
/**
|
/**
|
||||||
* The context in which this annotation is valid.
|
* The context in which this annotation is valid.
|
||||||
*/
|
*/
|
||||||
LinkageType.Context[] value();
|
Context[] value();
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -19,13 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.linkage;
|
package de.steamwar.linkage;
|
||||||
|
|
||||||
import java.lang.annotation.ElementType;
|
public enum Context {
|
||||||
import java.lang.annotation.Retention;
|
BUNGEE,
|
||||||
import java.lang.annotation.RetentionPolicy;
|
SPIGOT
|
||||||
import java.lang.annotation.Target;
|
|
||||||
|
|
||||||
@AllowedContexts(LinkageType.Context.BUNGEE)
|
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
|
||||||
@Target({ElementType.TYPE})
|
|
||||||
public @interface DiscordMode {
|
|
||||||
}
|
}
|
@ -27,7 +27,7 @@ import java.lang.annotation.Retention;
|
|||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
@AllowedContexts(LinkageType.Context.BUNGEE)
|
@AllowedContexts(Context.BUNGEE)
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
@Target({ElementType.TYPE})
|
@Target({ElementType.TYPE})
|
||||||
public @interface EventMode {
|
public @interface EventMode {
|
||||||
|
@ -22,33 +22,28 @@ package de.steamwar.linkage;
|
|||||||
import de.steamwar.linkage.plan.BuildPlan;
|
import de.steamwar.linkage.plan.BuildPlan;
|
||||||
import de.steamwar.linkage.plan.FieldBuilder;
|
import de.steamwar.linkage.plan.FieldBuilder;
|
||||||
import de.steamwar.linkage.plan.MethodBuilder;
|
import de.steamwar.linkage.plan.MethodBuilder;
|
||||||
import de.steamwar.linkage.plan.ParameterBuilder;
|
import de.steamwar.linkage.types.Plain_GENERIC;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
import lombok.SneakyThrows;
|
import lombok.SneakyThrows;
|
||||||
|
|
||||||
import javax.annotation.processing.AbstractProcessor;
|
import javax.annotation.processing.*;
|
||||||
import javax.annotation.processing.Messager;
|
|
||||||
import javax.annotation.processing.ProcessingEnvironment;
|
|
||||||
import javax.annotation.processing.RoundEnvironment;
|
|
||||||
import javax.lang.model.SourceVersion;
|
import javax.lang.model.SourceVersion;
|
||||||
import javax.lang.model.element.*;
|
import javax.lang.model.element.*;
|
||||||
import javax.lang.model.type.DeclaredType;
|
import javax.lang.model.type.DeclaredType;
|
||||||
import javax.lang.model.type.TypeMirror;
|
import javax.lang.model.type.TypeMirror;
|
||||||
import javax.tools.Diagnostic;
|
import javax.tools.Diagnostic;
|
||||||
import java.io.*;
|
import java.io.*;
|
||||||
import java.io.Writer;
|
|
||||||
import java.lang.annotation.Annotation;
|
import java.lang.annotation.Annotation;
|
||||||
import java.nio.file.Files;
|
import java.nio.file.Files;
|
||||||
import java.nio.file.Path;
|
import java.nio.file.Path;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.function.Consumer;
|
import java.util.function.Consumer;
|
||||||
import java.util.stream.Collectors;
|
import java.util.stream.Collectors;
|
||||||
import java.util.stream.Stream;
|
|
||||||
|
|
||||||
|
@SupportedAnnotationTypes("de.steamwar.linkage.Linked")
|
||||||
public class LinkageProcessor extends AbstractProcessor {
|
public class LinkageProcessor extends AbstractProcessor {
|
||||||
|
|
||||||
@Getter
|
private static Context context;
|
||||||
private static LinkageType.Context context;
|
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
private static String pluginMain;
|
private static String pluginMain;
|
||||||
@ -65,13 +60,6 @@ public class LinkageProcessor extends AbstractProcessor {
|
|||||||
return SourceVersion.latestSupported();
|
return SourceVersion.latestSupported();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
|
||||||
public Set<String> getSupportedAnnotationTypes() {
|
|
||||||
return Stream.of(Linked.class, Linked.Linkages.class)
|
|
||||||
.map(Class::getCanonicalName)
|
|
||||||
.collect(Collectors.toSet());
|
|
||||||
}
|
|
||||||
|
|
||||||
@SneakyThrows
|
@SneakyThrows
|
||||||
@Override
|
@Override
|
||||||
public synchronized void init(ProcessingEnvironment processingEnv) {
|
public synchronized void init(ProcessingEnvironment processingEnv) {
|
||||||
@ -101,7 +89,7 @@ public class LinkageProcessor extends AbstractProcessor {
|
|||||||
messager.printMessage(Diagnostic.Kind.ERROR, "Could not find plugin.yml or bungee.yml");
|
messager.printMessage(Diagnostic.Kind.ERROR, "Could not find plugin.yml or bungee.yml");
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
context = pluginYMLFile.get().getName().equals("bungee.yml") ? LinkageType.Context.BUNGEE : LinkageType.Context.SPIGOT;
|
context = pluginYMLFile.get().getName().equals("bungee.yml") ? Context.BUNGEE : Context.SPIGOT;
|
||||||
Optional<String> mainName = getMainName(pluginYMLFile.get());
|
Optional<String> mainName = getMainName(pluginYMLFile.get());
|
||||||
if (!mainName.isPresent()) {
|
if (!mainName.isPresent()) {
|
||||||
messager.printMessage(Diagnostic.Kind.ERROR, "Could not find main class in plugin.yml or bungee.yml");
|
messager.printMessage(Diagnostic.Kind.ERROR, "Could not find main class in plugin.yml or bungee.yml");
|
||||||
@ -130,40 +118,20 @@ public class LinkageProcessor extends AbstractProcessor {
|
|||||||
Writer writer = processingEnv.getFiler().createSourceFile("de.steamwar." + name + ".linkage.LinkageUtils").openWriter();
|
Writer writer = processingEnv.getFiler().createSourceFile("de.steamwar." + name + ".linkage.LinkageUtils").openWriter();
|
||||||
|
|
||||||
BuildPlan buildPlan = new BuildPlan(packageName, className);
|
BuildPlan buildPlan = new BuildPlan(packageName, className);
|
||||||
buildPlan.addImport("java.util.Set");
|
|
||||||
buildPlan.addImport("java.lang.Class");
|
|
||||||
buildPlan.addImport("de.steamwar.linkage.LinkageType");
|
buildPlan.addImport("de.steamwar.linkage.LinkageType");
|
||||||
buildPlan.addImport("java.util.HashSet");
|
|
||||||
buildPlan.addField(new FieldBuilder("Set<Class<? extends LinkageType>>", "enabled", "new HashSet<>()"));
|
|
||||||
|
|
||||||
MethodBuilder runsMethod = new MethodBuilder("run", "void");
|
|
||||||
runsMethod.addParameter(new ParameterBuilder("Class<? extends LinkageType>...", "types"));
|
|
||||||
runsMethod.addLine("for (Class<? extends LinkageType> type : types) _run(type);");
|
|
||||||
buildPlan.addMethod(runsMethod);
|
|
||||||
|
|
||||||
|
|
||||||
MethodBuilder runMethod = new MethodBuilder("_run", "void");
|
|
||||||
runMethod.setPrivate(true);
|
|
||||||
buildPlan.addMethod(runMethod);
|
|
||||||
runMethod.addParameter(new ParameterBuilder("Class<? extends LinkageType>", "type"));
|
|
||||||
runMethod.addLine("if (!enabled.add(type)) return;");
|
|
||||||
Set<Class<? extends LinkageType>> alreadyGenerated = new HashSet<>();
|
|
||||||
|
|
||||||
Set<? extends Element> elements = roundEnv.getElementsAnnotatedWith(Linked.class);
|
Set<? extends Element> elements = roundEnv.getElementsAnnotatedWith(Linked.class);
|
||||||
elements.addAll((Set) roundEnv.getElementsAnnotatedWith(Linked.Linkages.class));
|
|
||||||
|
|
||||||
Map<String, TypeElement> neededFields = new HashMap<>();
|
Map<String, TypeElement> neededFields = new HashMap<>();
|
||||||
for (Element element : elements) {
|
for (Element element : elements) {
|
||||||
if (element.getKind() != ElementKind.CLASS) {
|
if (element.getKind() != ElementKind.CLASS) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
TypeElement typeElement = (TypeElement) element;
|
TypeElement typeElement = (TypeElement) element;
|
||||||
Linked[] linkeds = element.getAnnotationsByType(Linked.class);
|
Linked linked = element.getAnnotation(Linked.class);
|
||||||
if (linkeds.length == 0) {
|
if (linked == null) {
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
if (getLinkagesOfType(typeElement).size() > 1) {
|
||||||
if (linkeds.length > 1) {
|
|
||||||
neededFields.put(typeElement.getQualifiedName().toString(), typeElement);
|
neededFields.put(typeElement.getQualifiedName().toString(), typeElement);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -198,20 +166,12 @@ public class LinkageProcessor extends AbstractProcessor {
|
|||||||
}
|
}
|
||||||
neededFields.forEach((s, typeElement) -> {
|
neededFields.forEach((s, typeElement) -> {
|
||||||
buildPlan.addImport(typeElement.getQualifiedName().toString());
|
buildPlan.addImport(typeElement.getQualifiedName().toString());
|
||||||
buildPlan.addField(new FieldBuilder(typeElement.getSimpleName().toString(), typeElement.getSimpleName().toString()));
|
String t = typeElement.getSimpleName().toString();
|
||||||
|
t = t.substring(0, 1).toLowerCase() + t.substring(1);
|
||||||
MethodBuilder initializer = new MethodBuilder(typeElement.getSimpleName().toString(), typeElement.getSimpleName().toString());
|
buildPlan.addField(new FieldBuilder(typeElement.getSimpleName().toString(), t, "new " + typeElement.getSimpleName().toString() + "()"));
|
||||||
initializer.setPrivate(true);
|
|
||||||
specialElements(typeElement, buildPlan, initializer::addLine, () -> {
|
|
||||||
initializer.addLine("if (" + typeElement.getSimpleName().toString() + " == null) {");
|
|
||||||
initializer.addLine(" " + typeElement.getSimpleName().toString() + " = new " + typeElement.getSimpleName().toString() + "();");
|
|
||||||
initializer.addLine("}");
|
|
||||||
});
|
|
||||||
initializer.addLine("return " + typeElement.getSimpleName().toString() + ";");
|
|
||||||
buildPlan.addMethod(initializer);
|
|
||||||
});
|
});
|
||||||
|
|
||||||
Map<Class<?>, MethodBuilder> methods = new HashMap<>();
|
Map<String, MethodBuilder> methods = new HashMap<>();
|
||||||
for (Element element : elements) {
|
for (Element element : elements) {
|
||||||
if (element.getKind() != ElementKind.CLASS) {
|
if (element.getKind() != ElementKind.CLASS) {
|
||||||
continue;
|
continue;
|
||||||
@ -219,65 +179,24 @@ public class LinkageProcessor extends AbstractProcessor {
|
|||||||
TypeElement typeElement = (TypeElement) element;
|
TypeElement typeElement = (TypeElement) element;
|
||||||
|
|
||||||
System.out.println("Found element: " + typeElement.getQualifiedName().toString());
|
System.out.println("Found element: " + typeElement.getQualifiedName().toString());
|
||||||
element.getAnnotationMirrors().stream()
|
Map<String, List<LinkageType>> linkages = getLinkagesOfType(typeElement);
|
||||||
.filter(annotationMirror -> {
|
if (linkages.isEmpty()) {
|
||||||
String annotationNames = annotationMirror.getAnnotationType().asElement().getSimpleName().toString();
|
continue;
|
||||||
return annotationNames.equals("Linked") || annotationNames.equals("Linkages");
|
|
||||||
})
|
|
||||||
.flatMap(annotationMirror -> annotationMirror.getElementValues().values().stream())
|
|
||||||
.map(AnnotationValue::getValue)
|
|
||||||
.flatMap(o -> {
|
|
||||||
if (o instanceof List) {
|
|
||||||
return ((List<Object>) o).stream()
|
|
||||||
.map(AnnotationMirror.class::cast)
|
|
||||||
.map(AnnotationMirror::getElementValues)
|
|
||||||
.map(Map::values)
|
|
||||||
.flatMap(Collection::stream)
|
|
||||||
.map(AnnotationValue::getValue);
|
|
||||||
}
|
|
||||||
return Stream.of(o);
|
|
||||||
})
|
|
||||||
.map(Object::toString)
|
|
||||||
.map(s -> {
|
|
||||||
try {
|
|
||||||
return Class.forName(s);
|
|
||||||
} catch (Exception e) {
|
|
||||||
messager.printMessage(Diagnostic.Kind.ERROR, "Could not find class " + s, element);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.map(clazz -> {
|
|
||||||
try {
|
|
||||||
return (LinkageType) clazz.getDeclaredConstructor().newInstance();
|
|
||||||
} catch (Exception e) {
|
|
||||||
messager.printMessage(Diagnostic.Kind.ERROR, "Could not create instance of " + clazz.getName(), element);
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
})
|
|
||||||
.filter(Objects::nonNull)
|
|
||||||
.forEach(type -> {
|
|
||||||
Class<? extends LinkageType> clazz = type.getClass();
|
|
||||||
if (!type.requirements(typeElement.getSuperclass().toString(), typeElement.getInterfaces().stream().map(TypeMirror::toString).collect(Collectors.toSet()), typeElement)) {
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
if (alreadyGenerated.add(clazz)) {
|
for (Map.Entry<String, List<LinkageType>> entry : linkages.entrySet()) {
|
||||||
runMethod.addLine("if (type == " + clazz.getTypeName() + ".class) {");
|
MethodBuilder method = methods.computeIfAbsent(entry.getKey(), s -> {
|
||||||
runMethod.addLine(" run" + clazz.getSimpleName() + "();");
|
MethodBuilder methodBuilder = new MethodBuilder(s, "void");
|
||||||
runMethod.addLine("}");
|
|
||||||
}
|
|
||||||
|
|
||||||
MethodBuilder method = methods.computeIfAbsent(clazz, t -> {
|
|
||||||
MethodBuilder methodBuilder = new MethodBuilder("run" + t.getSimpleName(), "void");
|
|
||||||
methodBuilder.setPrivate(true);
|
|
||||||
buildPlan.addMethod(methodBuilder);
|
buildPlan.addMethod(methodBuilder);
|
||||||
return methodBuilder;
|
return methodBuilder;
|
||||||
});
|
});
|
||||||
|
for (LinkageType type : entry.getValue()) {
|
||||||
specialElements(typeElement, buildPlan, method::addLine, () -> {
|
specialElements(typeElement, buildPlan, method::addLine, () -> {
|
||||||
|
buildPlan.addImport(typeElement.getQualifiedName().toString());
|
||||||
type.generateCode(buildPlan, method, getElement(typeElement, neededFields), typeElement);
|
type.generateCode(buildPlan, method, getElement(typeElement, neededFields), typeElement);
|
||||||
});
|
});
|
||||||
});
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
BufferedWriter bufferedWriter = new BufferedWriter(writer);
|
BufferedWriter bufferedWriter = new BufferedWriter(writer);
|
||||||
@ -288,19 +207,19 @@ public class LinkageProcessor extends AbstractProcessor {
|
|||||||
|
|
||||||
private String getElement(TypeElement typeElement, Map<String, TypeElement> neededFields) {
|
private String getElement(TypeElement typeElement, Map<String, TypeElement> neededFields) {
|
||||||
if (neededFields.containsKey(typeElement.getQualifiedName().toString())) {
|
if (neededFields.containsKey(typeElement.getQualifiedName().toString())) {
|
||||||
return typeElement.getSimpleName().toString() + "()";
|
String s = typeElement.getSimpleName().toString();
|
||||||
|
return s.substring(0, 1).toLowerCase() + s.substring(1);
|
||||||
}
|
}
|
||||||
return "new " + typeElement.getQualifiedName().toString() + "()";
|
return "new " + typeElement.getSimpleName().toString() + "()";
|
||||||
}
|
}
|
||||||
|
|
||||||
private void specialElements(TypeElement typeElement, BuildPlan buildPlan, Consumer<String> stringConsumer, Runnable inner) {
|
private void specialElements(TypeElement typeElement, BuildPlan buildPlan, Consumer<String> stringConsumer, Runnable inner) {
|
||||||
MinVersion minVersion = typeElement.getAnnotation(MinVersion.class);
|
MinVersion minVersion = typeElement.getAnnotation(MinVersion.class);
|
||||||
MaxVersion maxVersion = typeElement.getAnnotation(MaxVersion.class);
|
MaxVersion maxVersion = typeElement.getAnnotation(MaxVersion.class);
|
||||||
EventMode eventMode = typeElement.getAnnotation(EventMode.class);
|
EventMode eventMode = typeElement.getAnnotation(EventMode.class);
|
||||||
DiscordMode discordMode = typeElement.getAnnotation(DiscordMode.class);
|
|
||||||
PluginCheck[] pluginChecks = typeElement.getAnnotationsByType(PluginCheck.class);
|
PluginCheck[] pluginChecks = typeElement.getAnnotationsByType(PluginCheck.class);
|
||||||
if (context == LinkageType.Context.SPIGOT) {
|
if (context == Context.SPIGOT) {
|
||||||
errorOnNonNull(typeElement, eventMode, discordMode);
|
errorOnNonNull(typeElement, eventMode);
|
||||||
List<String> checks = new ArrayList<>();
|
List<String> checks = new ArrayList<>();
|
||||||
if (minVersion != null) {
|
if (minVersion != null) {
|
||||||
buildPlan.addImport("de.steamwar.core.Core");
|
buildPlan.addImport("de.steamwar.core.Core");
|
||||||
@ -326,10 +245,6 @@ public class LinkageProcessor extends AbstractProcessor {
|
|||||||
buildPlan.addImport("de.steamwar.bungeecore.BungeeCore");
|
buildPlan.addImport("de.steamwar.bungeecore.BungeeCore");
|
||||||
checks.add(eventMode.value().getPrefix() + "BungeeCore.EVENT_MODE");
|
checks.add(eventMode.value().getPrefix() + "BungeeCore.EVENT_MODE");
|
||||||
}
|
}
|
||||||
if (discordMode != null) {
|
|
||||||
buildPlan.addImport("de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig");
|
|
||||||
checks.add("SteamwarDiscordBotConfig.loaded");
|
|
||||||
}
|
|
||||||
if (pluginChecks.length != 0) {
|
if (pluginChecks.length != 0) {
|
||||||
buildPlan.addImport("net.md_5.bungee.BungeeCord");
|
buildPlan.addImport("net.md_5.bungee.BungeeCord");
|
||||||
Arrays.stream(pluginChecks).map(pluginCheck -> {
|
Arrays.stream(pluginChecks).map(pluginCheck -> {
|
||||||
@ -349,4 +264,40 @@ public class LinkageProcessor extends AbstractProcessor {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private Plain_GENERIC plain_GENERIC = new Plain_GENERIC();
|
||||||
|
|
||||||
|
private Map<String, List<LinkageType>> getLinkagesOfType(TypeElement typeElement) {
|
||||||
|
Map<String, List<LinkageType>> linkages = new HashMap<>();
|
||||||
|
LinkageType superClassType = resolveSingle(typeElement.getSuperclass());
|
||||||
|
if (superClassType != null) {
|
||||||
|
linkages.computeIfAbsent(superClassType.method(), s -> new ArrayList<>()).add(superClassType);
|
||||||
|
}
|
||||||
|
for (TypeMirror typeMirror : typeElement.getInterfaces()) {
|
||||||
|
LinkageType interfaceType = resolveSingle(typeMirror);
|
||||||
|
if (interfaceType != null) {
|
||||||
|
linkages.computeIfAbsent(interfaceType.method(), s -> new ArrayList<>()).add(interfaceType);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!linkages.containsKey(plain_GENERIC.method())) {
|
||||||
|
linkages.put(plain_GENERIC.method(), Collections.singletonList(plain_GENERIC));
|
||||||
|
}
|
||||||
|
return linkages;
|
||||||
|
}
|
||||||
|
|
||||||
|
private LinkageType resolveSingle(TypeMirror typeMirror) {
|
||||||
|
String qualifier = typeMirror.toString();
|
||||||
|
qualifier = qualifier.substring(qualifier.lastIndexOf('.') + 1);
|
||||||
|
try {
|
||||||
|
return (LinkageType) Class.forName("de.steamwar.linkage.types." + qualifier + "_" + context.name()).getDeclaredConstructor().newInstance();
|
||||||
|
} catch (Exception e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
try {
|
||||||
|
return (LinkageType) Class.forName("de.steamwar.linkage.types." + qualifier + "_GENERIC").getDeclaredConstructor().newInstance();
|
||||||
|
} catch (Exception e) {
|
||||||
|
// Ignore
|
||||||
|
}
|
||||||
|
return null;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
@ -23,36 +23,14 @@ import de.steamwar.linkage.plan.BuildPlan;
|
|||||||
import de.steamwar.linkage.plan.MethodBuilder;
|
import de.steamwar.linkage.plan.MethodBuilder;
|
||||||
|
|
||||||
import javax.lang.model.element.TypeElement;
|
import javax.lang.model.element.TypeElement;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public interface LinkageType {
|
public interface LinkageType {
|
||||||
|
|
||||||
Context context = LinkageProcessor.getContext();
|
|
||||||
default String getPluginMain() {
|
default String getPluginMain() {
|
||||||
return LinkageProcessor.getPluginMain();
|
return LinkageProcessor.getPluginMain();
|
||||||
}
|
}
|
||||||
|
|
||||||
enum Context {
|
String method();
|
||||||
BUNGEE,
|
|
||||||
SPIGOT
|
|
||||||
}
|
|
||||||
|
|
||||||
default boolean requirements(String superClass, Set<String> interfaces, TypeElement typeElement) {
|
void generateCode(BuildPlan buildPlan, MethodBuilder method, String instance, TypeElement typeElement);
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
default void generateCode(BuildPlan buildPlan, MethodBuilder linkageTypeMethod, String instance, TypeElement typeElement) {
|
|
||||||
switch (context) {
|
|
||||||
case BUNGEE:
|
|
||||||
generateCodeBungee(buildPlan, linkageTypeMethod, instance, typeElement);
|
|
||||||
break;
|
|
||||||
case SPIGOT:
|
|
||||||
generateCodeSpigot(buildPlan, linkageTypeMethod, instance, typeElement);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
default void generateCodeBungee(BuildPlan buildPlan, MethodBuilder linkageTypeMethod, String instance, TypeElement typeElement) {
|
|
||||||
}
|
|
||||||
default void generateCodeSpigot(BuildPlan buildPlan, MethodBuilder linkageTypeMethod, String instance, TypeElement typeElement) {
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -23,13 +23,5 @@ import java.lang.annotation.*;
|
|||||||
|
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
@Target({ElementType.TYPE})
|
@Target({ElementType.TYPE})
|
||||||
@Repeatable(Linked.Linkages.class)
|
|
||||||
public @interface Linked {
|
public @interface Linked {
|
||||||
Class<? extends LinkageType> value();
|
|
||||||
|
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
|
||||||
@Target({ElementType.TYPE})
|
|
||||||
@interface Linkages {
|
|
||||||
@SuppressWarnings("unused") Linked[] value() default {};
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
@ -24,7 +24,7 @@ import java.lang.annotation.Retention;
|
|||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
@AllowedContexts(LinkageType.Context.SPIGOT)
|
@AllowedContexts(Context.SPIGOT)
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
@Target({ElementType.TYPE})
|
@Target({ElementType.TYPE})
|
||||||
public @interface MaxVersion {
|
public @interface MaxVersion {
|
||||||
|
@ -24,7 +24,7 @@ import java.lang.annotation.Retention;
|
|||||||
import java.lang.annotation.RetentionPolicy;
|
import java.lang.annotation.RetentionPolicy;
|
||||||
import java.lang.annotation.Target;
|
import java.lang.annotation.Target;
|
||||||
|
|
||||||
@AllowedContexts(LinkageType.Context.SPIGOT)
|
@AllowedContexts(Context.SPIGOT)
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
@Target({ElementType.TYPE})
|
@Target({ElementType.TYPE})
|
||||||
public @interface MinVersion {
|
public @interface MinVersion {
|
||||||
|
@ -21,7 +21,7 @@ package de.steamwar.linkage;
|
|||||||
|
|
||||||
import java.lang.annotation.*;
|
import java.lang.annotation.*;
|
||||||
|
|
||||||
@AllowedContexts({LinkageType.Context.BUNGEE, LinkageType.Context.SPIGOT})
|
@AllowedContexts({Context.BUNGEE, Context.SPIGOT})
|
||||||
@Retention(RetentionPolicy.SOURCE)
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
@Target({ElementType.TYPE})
|
@Target({ElementType.TYPE})
|
||||||
@Repeatable(PluginCheck.PluginChecks.class)
|
@Repeatable(PluginCheck.PluginChecks.class)
|
||||||
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file is a part of the SteamWar software.
|
* This file is a part of the SteamWar software.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2022 SteamWar.de-Serverteam
|
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
@ -24,17 +24,16 @@ import de.steamwar.linkage.plan.BuildPlan;
|
|||||||
import de.steamwar.linkage.plan.MethodBuilder;
|
import de.steamwar.linkage.plan.MethodBuilder;
|
||||||
|
|
||||||
import javax.lang.model.element.TypeElement;
|
import javax.lang.model.element.TypeElement;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class EnableLink implements LinkageType {
|
public class Disable_GENERIC implements LinkageType {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean requirements(String superClass, Set<String> interfaces, TypeElement typeElement) {
|
public String method() {
|
||||||
return interfaces.contains("de.steamwar.linkage.api.Enable");
|
return "unlink";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateCode(BuildPlan buildPlan, MethodBuilder linkageTypeMethod, String instance, TypeElement typeElement) {
|
public void generateCode(BuildPlan buildPlan, MethodBuilder method, String instance, TypeElement typeElement) {
|
||||||
linkageTypeMethod.addLine(instance + ".enable();");
|
method.addLine(instance + ".disable();");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file is a part of the SteamWar software.
|
* This file is a part of the SteamWar software.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2022 SteamWar.de-Serverteam
|
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
@ -24,17 +24,16 @@ import de.steamwar.linkage.plan.BuildPlan;
|
|||||||
import de.steamwar.linkage.plan.MethodBuilder;
|
import de.steamwar.linkage.plan.MethodBuilder;
|
||||||
|
|
||||||
import javax.lang.model.element.TypeElement;
|
import javax.lang.model.element.TypeElement;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class DisableLink implements LinkageType {
|
public class Enable_GENERIC implements LinkageType {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean requirements(String superClass, Set<String> interfaces, TypeElement typeElement) {
|
public String method() {
|
||||||
return interfaces.contains("de.steamwar.linkage.api.Disable");
|
return "link";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateCode(BuildPlan buildPlan, MethodBuilder linkageTypeMethod, String instance, TypeElement typeElement) {
|
public void generateCode(BuildPlan buildPlan, MethodBuilder method, String instance, TypeElement typeElement) {
|
||||||
linkageTypeMethod.addLine(instance + ".disable();");
|
method.addLine(instance + ".enable();");
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -1,7 +1,7 @@
|
|||||||
/*
|
/*
|
||||||
* This file is a part of the SteamWar software.
|
* This file is a part of the SteamWar software.
|
||||||
*
|
*
|
||||||
* Copyright (C) 2022 SteamWar.de-Serverteam
|
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||||
*
|
*
|
||||||
* This program is free software: you can redistribute it and/or modify
|
* This program is free software: you can redistribute it and/or modify
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
@ -24,22 +24,18 @@ import de.steamwar.linkage.plan.BuildPlan;
|
|||||||
import de.steamwar.linkage.plan.MethodBuilder;
|
import de.steamwar.linkage.plan.MethodBuilder;
|
||||||
|
|
||||||
import javax.lang.model.element.TypeElement;
|
import javax.lang.model.element.TypeElement;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class Command implements LinkageType {
|
public class Listener_BUNGEE implements LinkageType {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean requirements(String superClass, Set<String> interfaces, TypeElement typeElement) {
|
public String method() {
|
||||||
return superClass.equals("de.steamwar.command.SWCommand");
|
return "link";
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateCodeBungee(BuildPlan buildPlan, MethodBuilder linkageTypeMethod, String instance, TypeElement typeElement) {
|
public void generateCode(BuildPlan buildPlan, MethodBuilder method, String instance, TypeElement typeElement) {
|
||||||
linkageTypeMethod.addLine(instance + ";");
|
buildPlan.addImport("net.md_5.bungee.api.ProxyServer");
|
||||||
}
|
buildPlan.addImport("de.steamwar.bungeecore.BungeeCore");
|
||||||
|
method.addLine("ProxyServer.getInstance().getPluginManager().registerListener(BungeeCore.get(), " + instance + ");");
|
||||||
@Override
|
|
||||||
public void generateCodeSpigot(BuildPlan buildPlan, MethodBuilder linkageTypeMethod, String instance, TypeElement typeElement) {
|
|
||||||
linkageTypeMethod.addLine(instance + ".setMessage(" + getPluginMain() + ".MESSAGE);");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -29,28 +29,16 @@ import javax.lang.model.element.*;
|
|||||||
import javax.lang.model.type.DeclaredType;
|
import javax.lang.model.type.DeclaredType;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class ListenerLink implements LinkageType {
|
public class Listener_SPIGOT implements LinkageType {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean requirements(String superClass, Set<String> interfaces, TypeElement typeElement) {
|
public String method() {
|
||||||
if (context == Context.BUNGEE) {
|
return "link";
|
||||||
return interfaces.contains("net.md_5.bungee.api.plugin.Listener");
|
|
||||||
} else {
|
|
||||||
return interfaces.contains("org.bukkit.event.Listener");
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateCodeBungee(BuildPlan buildPlan, MethodBuilder linkageTypeMethod, String instance, TypeElement typeElement) {
|
public void generateCode(BuildPlan buildPlan, MethodBuilder method, String instance, TypeElement typeElement) {
|
||||||
buildPlan.addImport("net.md_5.bungee.api.ProxyServer");
|
|
||||||
buildPlan.addImport("de.steamwar.bungeecore.BungeeCore");
|
|
||||||
linkageTypeMethod.addLine("ProxyServer.getInstance().getPluginManager().registerListener(BungeeCore.get(), " + instance + ");");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void generateCodeSpigot(BuildPlan buildPlan, MethodBuilder linkageTypeMethod, String instance, TypeElement typeElement) {
|
|
||||||
Map<String, TypeElement> eventClasses = new HashMap<>();
|
Map<String, TypeElement> eventClasses = new HashMap<>();
|
||||||
Map<TypeElement, ExecutableElement> eventMethods = new HashMap<>();
|
Map<TypeElement, ExecutableElement> eventMethods = new HashMap<>();
|
||||||
|
|
||||||
@ -87,12 +75,11 @@ public class ListenerLink implements LinkageType {
|
|||||||
methodBuilder.addLine("};");
|
methodBuilder.addLine("};");
|
||||||
methodBuilder.addLine("handlerList" + eventType.getSimpleName() + ".register(new RegisteredListener(listener, eventExecutor, eventPriority, " + getPluginMain() + ".getInstance(), ignoreCancelled));");
|
methodBuilder.addLine("handlerList" + eventType.getSimpleName() + ".register(new RegisteredListener(listener, eventExecutor, eventPriority, " + getPluginMain() + ".getInstance(), ignoreCancelled));");
|
||||||
buildPlan.addMethod(methodBuilder);
|
buildPlan.addMethod(methodBuilder);
|
||||||
linkageTypeMethod.addLine("handlerList" + eventType.getSimpleName() + " = " + eventType.getSimpleName() + ".getHandlerList();");
|
method.addLine("handlerList" + eventType.getSimpleName() + " = " + eventType.getSimpleName() + ".getHandlerList();");
|
||||||
});
|
});
|
||||||
|
|
||||||
buildPlan.addImport(typeElement.getQualifiedName().toString());
|
|
||||||
String localInstance = "local" + typeElement.getSimpleName().toString();
|
String localInstance = "local" + typeElement.getSimpleName().toString();
|
||||||
linkageTypeMethod.addLine(typeElement.getSimpleName() + " " + localInstance + " = " + instance + ";");
|
method.addLine(typeElement.getSimpleName() + " " + localInstance + " = " + instance + ";");
|
||||||
eventMethods.forEach((type, executableElement) -> {
|
eventMethods.forEach((type, executableElement) -> {
|
||||||
AnnotationMirror eventHandler = executableElement.getAnnotationMirrors().stream().filter(annotationMirror -> annotationMirror.getAnnotationType().asElement().getSimpleName().toString().equals("EventHandler")).findFirst().orElse(null);
|
AnnotationMirror eventHandler = executableElement.getAnnotationMirrors().stream().filter(annotationMirror -> annotationMirror.getAnnotationType().asElement().getSimpleName().toString().equals("EventHandler")).findFirst().orElse(null);
|
||||||
if (eventHandler == null) {
|
if (eventHandler == null) {
|
||||||
@ -107,7 +94,7 @@ public class ListenerLink implements LinkageType {
|
|||||||
ignoreCancelled = entry.getValue().getValue().toString();
|
ignoreCancelled = entry.getValue().getValue().toString();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
linkageTypeMethod.addLine(type.getSimpleName().toString() + "(" + localInstance + ", " + localInstance + "::" + executableElement.getSimpleName().toString() + ", EventPriority." + priority + ", " + ignoreCancelled + ");");
|
method.addLine(type.getSimpleName().toString() + "(" + localInstance + ", " + localInstance + "::" + executableElement.getSimpleName().toString() + ", EventPriority." + priority + ", " + ignoreCancelled + ");");
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
}
|
}
|
@ -25,10 +25,15 @@ import de.steamwar.linkage.plan.MethodBuilder;
|
|||||||
|
|
||||||
import javax.lang.model.element.TypeElement;
|
import javax.lang.model.element.TypeElement;
|
||||||
|
|
||||||
public class Plain implements LinkageType {
|
public class PacketHandler_GENERIC implements LinkageType {
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void generateCode(BuildPlan buildPlan, MethodBuilder linkageTypeMethod, String instance, TypeElement typeElement) {
|
public String method() {
|
||||||
linkageTypeMethod.addLine(instance + ";");
|
return "link";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void generateCode(BuildPlan buildPlan, MethodBuilder method, String instance, TypeElement typeElement) {
|
||||||
|
method.addLine(instance + ".register();");
|
||||||
}
|
}
|
||||||
}
|
}
|
39
src/de/steamwar/linkage/types/Plain_GENERIC.java
Normale Datei
39
src/de/steamwar/linkage/types/Plain_GENERIC.java
Normale Datei
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.linkage.types;
|
||||||
|
|
||||||
|
import de.steamwar.linkage.LinkageType;
|
||||||
|
import de.steamwar.linkage.plan.BuildPlan;
|
||||||
|
import de.steamwar.linkage.plan.MethodBuilder;
|
||||||
|
|
||||||
|
import javax.lang.model.element.TypeElement;
|
||||||
|
|
||||||
|
public class Plain_GENERIC implements LinkageType {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String method() {
|
||||||
|
return "link";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void generateCode(BuildPlan buildPlan, MethodBuilder method, String instance, TypeElement typeElement) {
|
||||||
|
method.addLine(instance + ";");
|
||||||
|
}
|
||||||
|
}
|
39
src/de/steamwar/linkage/types/SWCommand_BUNGEE.java
Normale Datei
39
src/de/steamwar/linkage/types/SWCommand_BUNGEE.java
Normale Datei
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.linkage.types;
|
||||||
|
|
||||||
|
import de.steamwar.linkage.LinkageType;
|
||||||
|
import de.steamwar.linkage.plan.BuildPlan;
|
||||||
|
import de.steamwar.linkage.plan.MethodBuilder;
|
||||||
|
|
||||||
|
import javax.lang.model.element.TypeElement;
|
||||||
|
|
||||||
|
public class SWCommand_BUNGEE implements LinkageType {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String method() {
|
||||||
|
return "link";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void generateCode(BuildPlan buildPlan, MethodBuilder method, String instance, TypeElement typeElement) {
|
||||||
|
method.addLine(instance + ";");
|
||||||
|
}
|
||||||
|
}
|
39
src/de/steamwar/linkage/types/SWCommand_SPIGOT.java
Normale Datei
39
src/de/steamwar/linkage/types/SWCommand_SPIGOT.java
Normale Datei
@ -0,0 +1,39 @@
|
|||||||
|
/*
|
||||||
|
* This file is a part of the SteamWar software.
|
||||||
|
*
|
||||||
|
* Copyright (C) 2020 SteamWar.de-Serverteam
|
||||||
|
*
|
||||||
|
* This program is free software: you can redistribute it and/or modify
|
||||||
|
* it under the terms of the GNU Affero General Public License as published by
|
||||||
|
* the Free Software Foundation, either version 3 of the License, or
|
||||||
|
* (at your option) any later version.
|
||||||
|
*
|
||||||
|
* This program is distributed in the hope that it will be useful,
|
||||||
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||||
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||||
|
* GNU Affero General Public License for more details.
|
||||||
|
*
|
||||||
|
* You should have received a copy of the GNU Affero General Public License
|
||||||
|
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||||
|
*/
|
||||||
|
|
||||||
|
package de.steamwar.linkage.types;
|
||||||
|
|
||||||
|
import de.steamwar.linkage.LinkageType;
|
||||||
|
import de.steamwar.linkage.plan.BuildPlan;
|
||||||
|
import de.steamwar.linkage.plan.MethodBuilder;
|
||||||
|
|
||||||
|
import javax.lang.model.element.TypeElement;
|
||||||
|
|
||||||
|
public class SWCommand_SPIGOT implements LinkageType {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String method() {
|
||||||
|
return "link";
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void generateCode(BuildPlan buildPlan, MethodBuilder method, String instance, TypeElement typeElement) {
|
||||||
|
method.addLine(instance + ".setMessage(" + getPluginMain() + ".MESSAGE);");
|
||||||
|
}
|
||||||
|
}
|
@ -1,53 +0,0 @@
|
|||||||
/*
|
|
||||||
* This file is a part of the SteamWar software.
|
|
||||||
*
|
|
||||||
* Copyright (C) 2020 SteamWar.de-Serverteam
|
|
||||||
*
|
|
||||||
* This program is free software: you can redistribute it and/or modify
|
|
||||||
* it under the terms of the GNU Affero General Public License as published by
|
|
||||||
* the Free Software Foundation, either version 3 of the License, or
|
|
||||||
* (at your option) any later version.
|
|
||||||
*
|
|
||||||
* This program is distributed in the hope that it will be useful,
|
|
||||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
||||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
||||||
* GNU Affero General Public License for more details.
|
|
||||||
*
|
|
||||||
* You should have received a copy of the GNU Affero General Public License
|
|
||||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
|
||||||
*/
|
|
||||||
|
|
||||||
package de.steamwar.linkage.types;
|
|
||||||
|
|
||||||
import de.steamwar.linkage.LinkageType;
|
|
||||||
import de.steamwar.linkage.plan.BuildPlan;
|
|
||||||
import de.steamwar.linkage.plan.MethodBuilder;
|
|
||||||
|
|
||||||
import javax.lang.model.element.TypeElement;
|
|
||||||
import java.lang.reflect.Type;
|
|
||||||
import java.util.Set;
|
|
||||||
|
|
||||||
public class UnlinkListener implements LinkageType {
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public boolean requirements(String superClass, Set<String> interfaces, TypeElement typeElement) {
|
|
||||||
if (context == Context.BUNGEE) {
|
|
||||||
return interfaces.contains("net.md_5.bungee.api.plugin.Listener");
|
|
||||||
} else {
|
|
||||||
return interfaces.contains("org.bukkit.event.Listener");
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void generateCodeBungee(BuildPlan buildPlan, MethodBuilder linkageTypeMethod, String instance, TypeElement typeElement) {
|
|
||||||
buildPlan.addImport("net.md_5.bungee.api.ProxyServer");
|
|
||||||
buildPlan.addImport("de.steamwar.bungeecore.BungeeCore");
|
|
||||||
linkageTypeMethod.addLine("ProxyServer.getInstance().getPluginManager().registerListener(" + instance + ");");
|
|
||||||
}
|
|
||||||
|
|
||||||
@Override
|
|
||||||
public void generateCodeSpigot(BuildPlan buildPlan, MethodBuilder linkageTypeMethod, String instance, TypeElement typeElement) {
|
|
||||||
buildPlan.addImport("org.bukkit.event.HandlerList");
|
|
||||||
linkageTypeMethod.addLine("HandlerList.unregisterAll(" + instance + ");");
|
|
||||||
}
|
|
||||||
}
|
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren