Add ParameterBuilder Add MinVersion
Dieser Commit ist enthalten in:
Ursprung
8c574c1975
Commit
f8e18ec79f
@ -19,6 +19,8 @@
|
|||||||
|
|
||||||
package de.steamwar.linkage;
|
package de.steamwar.linkage;
|
||||||
|
|
||||||
|
import de.steamwar.linkage.plan.BuildPlan;
|
||||||
|
|
||||||
public interface LinkageType {
|
public interface LinkageType {
|
||||||
|
|
||||||
// String name = new BufferedReader(new InputStreamReader(processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", "plugin.yml").openInputStream()))
|
// String name = new BufferedReader(new InputStreamReader(processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", "plugin.yml").openInputStream()))
|
||||||
@ -36,5 +38,5 @@ public interface LinkageType {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
String generateCode(String instance);
|
void generateCode(BuildPlan buildPlan, String instance);
|
||||||
}
|
}
|
||||||
|
27
src/de/steamwar/linkage/MinVersion.java
Normale Datei
27
src/de/steamwar/linkage/MinVersion.java
Normale Datei
@ -0,0 +1,27 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Only applicable in Spigot context. Will be ignored in other contexts.
|
||||||
|
*/
|
||||||
|
public @interface MinVersion {
|
||||||
|
int value();
|
||||||
|
}
|
@ -34,9 +34,26 @@ public class BuildPlan implements Writer {
|
|||||||
private final String className;
|
private final String className;
|
||||||
|
|
||||||
private Map<Class<?>, FieldBuilder> fieldBuilderMap = new HashMap<>();
|
private Map<Class<?>, FieldBuilder> fieldBuilderMap = new HashMap<>();
|
||||||
|
private Map<String, MethodBuilder> methodBuilderMap = new HashMap<>();
|
||||||
|
|
||||||
public void addField(FieldBuilder fieldBuilder) {
|
public void addField(FieldBuilder fieldBuilder) {
|
||||||
fieldBuilderMap.put(fieldBuilder.getType(), fieldBuilder);
|
fieldBuilderMap.putIfAbsent(fieldBuilder.getType(), fieldBuilder);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasField(Class<?> type) {
|
||||||
|
return fieldBuilderMap.containsKey(type);
|
||||||
|
}
|
||||||
|
|
||||||
|
public String getFieldName(Class<?> type) {
|
||||||
|
return fieldBuilderMap.get(type).getFieldName();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void addMethod(MethodBuilder methodBuilder) {
|
||||||
|
methodBuilderMap.put(methodBuilder.getMethodName(), methodBuilder);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean hasMethod(String methodName) {
|
||||||
|
return methodBuilderMap.containsKey(methodName);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
@ -47,6 +64,12 @@ public class BuildPlan implements Writer {
|
|||||||
for (FieldBuilder fieldBuilder : fieldBuilderMap.values()) {
|
for (FieldBuilder fieldBuilder : fieldBuilderMap.values()) {
|
||||||
fieldBuilder.write(writer);
|
fieldBuilder.write(writer);
|
||||||
}
|
}
|
||||||
|
if (!fieldBuilderMap.isEmpty() && !methodBuilderMap.isEmpty()) {
|
||||||
|
writer.write("\n");
|
||||||
|
}
|
||||||
|
for (MethodBuilder methodBuilder : methodBuilderMap.values()) {
|
||||||
|
methodBuilder.write(writer);
|
||||||
|
}
|
||||||
writer.write("}\n");
|
writer.write("}\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -31,8 +31,12 @@ public class FieldBuilder implements Writer {
|
|||||||
@Getter
|
@Getter
|
||||||
private Class<?> type;
|
private Class<?> type;
|
||||||
|
|
||||||
|
public String getFieldName() {
|
||||||
|
return type.getSimpleName();
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void write(BufferedWriter writer) throws IOException {
|
public void write(BufferedWriter writer) throws IOException {
|
||||||
writer.write(" private static " + type.getTypeName() + " " + type.getSimpleName() + ";");
|
writer.write(" private static " + type.getTypeName() + " " + getFieldName() + ";\n");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
57
src/de/steamwar/linkage/plan/MethodBuilder.java
Normale Datei
57
src/de/steamwar/linkage/plan/MethodBuilder.java
Normale Datei
@ -0,0 +1,57 @@
|
|||||||
|
/*
|
||||||
|
* 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.plan;
|
||||||
|
|
||||||
|
import de.steamwar.linkage.Writer;
|
||||||
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class MethodBuilder implements Writer {
|
||||||
|
|
||||||
|
private final String name;
|
||||||
|
private final Class<?> returnType;
|
||||||
|
private List<ParameterBuilder> parameters = new ArrayList<>();
|
||||||
|
private List<String> lines = new ArrayList<>();
|
||||||
|
|
||||||
|
public String getMethodName() {
|
||||||
|
return name;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(BufferedWriter writer) throws IOException {
|
||||||
|
writer.write(" public static " + returnType.getTypeName() + " " + getMethodName() + "(");
|
||||||
|
for (int i = 0; i < parameters.size(); i++) {
|
||||||
|
parameters.get(i).write(writer);
|
||||||
|
if (i < parameters.size() - 1) {
|
||||||
|
writer.write(", ");
|
||||||
|
}
|
||||||
|
}
|
||||||
|
writer.write(") {");
|
||||||
|
for (String line : lines) {
|
||||||
|
writer.write(" " + line);
|
||||||
|
}
|
||||||
|
writer.write(" }\n");
|
||||||
|
}
|
||||||
|
}
|
37
src/de/steamwar/linkage/plan/ParameterBuilder.java
Normale Datei
37
src/de/steamwar/linkage/plan/ParameterBuilder.java
Normale Datei
@ -0,0 +1,37 @@
|
|||||||
|
/*
|
||||||
|
* 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.plan;
|
||||||
|
|
||||||
|
import de.steamwar.linkage.Writer;
|
||||||
|
import lombok.AllArgsConstructor;
|
||||||
|
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class ParameterBuilder implements Writer {
|
||||||
|
private Class<?> type;
|
||||||
|
private String name;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(BufferedWriter writer) throws IOException {
|
||||||
|
writer.write(type.getTypeName() + " " + name);
|
||||||
|
}
|
||||||
|
}
|
@ -21,6 +21,7 @@ package de.steamwar.linkage.types;
|
|||||||
|
|
||||||
import de.steamwar.command.AbstractSWCommand;
|
import de.steamwar.command.AbstractSWCommand;
|
||||||
import de.steamwar.linkage.LinkageType;
|
import de.steamwar.linkage.LinkageType;
|
||||||
|
import de.steamwar.linkage.plan.BuildPlan;
|
||||||
|
|
||||||
public class Command implements LinkageType {
|
public class Command implements LinkageType {
|
||||||
|
|
||||||
@ -30,7 +31,6 @@ public class Command implements LinkageType {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String generateCode(String instance) {
|
public void generateCode(BuildPlan buildPlan, String instance) {
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren