Dieser Commit ist enthalten in:
Ursprung
ff8ffbf5fb
Commit
eac3433ed1
@ -37,6 +37,7 @@ import javax.lang.model.type.TypeMirror;
|
||||
import javax.tools.Diagnostic;
|
||||
import java.io.*;
|
||||
import java.io.Writer;
|
||||
import java.lang.annotation.Annotation;
|
||||
import java.util.*;
|
||||
import java.util.function.Consumer;
|
||||
import java.util.stream.Collectors;
|
||||
@ -289,17 +290,25 @@ public class LinkageProcessor extends AbstractProcessor {
|
||||
}
|
||||
|
||||
private void specialElements(TypeElement typeElement, BuildPlan buildPlan, Consumer<String> stringConsumer, Runnable inner) {
|
||||
if (context == LinkageType.Context.SPIGOT) {
|
||||
MinVersion minVersion = typeElement.getAnnotation(MinVersion.class);
|
||||
MaxVersion maxVersion = typeElement.getAnnotation(MaxVersion.class);
|
||||
EventMode eventMode = typeElement.getAnnotation(EventMode.class);
|
||||
DiscordMode discordMode = typeElement.getAnnotation(DiscordMode.class);
|
||||
if (context == LinkageType.Context.SPIGOT) {
|
||||
errorOnNonNull(typeElement, eventMode, discordMode);
|
||||
if (minVersion != null) {
|
||||
buildPlan.addImport("de.steamwar.core.Core");
|
||||
stringConsumer.accept("if (Core.getVersion() >= " + minVersion.value() + ") {");
|
||||
}
|
||||
if (maxVersion != null) {
|
||||
buildPlan.addImport("de.steamwar.core.Core");
|
||||
stringConsumer.accept("if (Core.getVersion() < " + maxVersion.value() + ") {");
|
||||
}
|
||||
inner.run();
|
||||
if (maxVersion != null) stringConsumer.accept("}");
|
||||
if (minVersion != null) stringConsumer.accept("}");
|
||||
} else {
|
||||
EventMode eventMode = typeElement.getAnnotation(EventMode.class);
|
||||
DiscordMode discordMode = typeElement.getAnnotation(DiscordMode.class);
|
||||
errorOnNonNull(typeElement, minVersion, maxVersion);
|
||||
if (eventMode != null) {
|
||||
buildPlan.addImport("de.steamwar.bungeecore.BungeeCore");
|
||||
stringConsumer.accept("if (" + eventMode.value().getPrefix() + "BungeeCore.EVENT_MODE) {");
|
||||
@ -313,4 +322,12 @@ public class LinkageProcessor extends AbstractProcessor {
|
||||
if (eventMode != null) stringConsumer.accept("}");
|
||||
}
|
||||
}
|
||||
|
||||
private void errorOnNonNull(TypeElement typeElement, Annotation... annotations) {
|
||||
for (Annotation annotation : annotations) {
|
||||
if (annotation != null) {
|
||||
messager.printMessage(Diagnostic.Kind.ERROR, annotation.annotationType().getSimpleName() + " is not supported in " + context.name(), typeElement);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
32
src/de/steamwar/linkage/MaxVersion.java
Normale Datei
32
src/de/steamwar/linkage/MaxVersion.java
Normale Datei
@ -0,0 +1,32 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2022 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;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@AllowedContexts(LinkageType.Context.SPIGOT)
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@Target({ElementType.TYPE})
|
||||
public @interface MaxVersion {
|
||||
int value();
|
||||
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren