Dieser Commit ist enthalten in:
Ursprung
6e6d34905a
Commit
3da9e9bc69
40
src/de/steamwar/linkage/LinkageType.java
Normale Datei
40
src/de/steamwar/linkage/LinkageType.java
Normale Datei
@ -0,0 +1,40 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
public interface LinkageType {
|
||||||
|
|
||||||
|
// String name = new BufferedReader(new InputStreamReader(processingEnv.getFiler().getResource(StandardLocation.CLASS_OUTPUT, "", "plugin.yml").openInputStream()))
|
||||||
|
// .lines()
|
||||||
|
// .filter(s -> s.startsWith("main: "))
|
||||||
|
// .map(s -> s.substring(6))
|
||||||
|
// .map(s -> s.substring(s.lastIndexOf('.')))
|
||||||
|
// .findFirst()
|
||||||
|
// .orElse(null);
|
||||||
|
|
||||||
|
default Class<?> clazzType() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
default Class<?> interfaceType() {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
String generateCode(String instance);
|
||||||
|
}
|
35
src/de/steamwar/linkage/Linked.java
Normale Datei
35
src/de/steamwar/linkage/Linked.java
Normale Datei
@ -0,0 +1,35 @@
|
|||||||
|
/*
|
||||||
|
* 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.*;
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
|
@Target({ElementType.TYPE})
|
||||||
|
@Repeatable(Linked.Linkages.class)
|
||||||
|
public @interface Linked {
|
||||||
|
Class<LinkageType> value();
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
|
@Target({ElementType.TYPE})
|
||||||
|
@interface Linkages {
|
||||||
|
@SuppressWarnings("unused") Linked[] value() default {};
|
||||||
|
}
|
||||||
|
}
|
30
src/de/steamwar/linkage/LinkedInstance.java
Normale Datei
30
src/de/steamwar/linkage/LinkedInstance.java
Normale Datei
@ -0,0 +1,30 @@
|
|||||||
|
/*
|
||||||
|
* 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;
|
||||||
|
|
||||||
|
@Retention(RetentionPolicy.SOURCE)
|
||||||
|
@Target({ElementType.FIELD})
|
||||||
|
public @interface LinkedInstance {
|
||||||
|
}
|
27
src/de/steamwar/linkage/Writer.java
Normale Datei
27
src/de/steamwar/linkage/Writer.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;
|
||||||
|
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
public interface Writer {
|
||||||
|
void write(BufferedWriter writer) throws IOException;
|
||||||
|
}
|
52
src/de/steamwar/linkage/plan/BuildPlan.java
Normale Datei
52
src/de/steamwar/linkage/plan/BuildPlan.java
Normale Datei
@ -0,0 +1,52 @@
|
|||||||
|
/*
|
||||||
|
* 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.HashMap;
|
||||||
|
import java.util.Map;
|
||||||
|
|
||||||
|
@RequiredArgsConstructor
|
||||||
|
public class BuildPlan implements Writer {
|
||||||
|
|
||||||
|
private final String packageName;
|
||||||
|
private final String className;
|
||||||
|
|
||||||
|
private Map<Class<?>, FieldBuilder> fieldBuilderMap = new HashMap<>();
|
||||||
|
|
||||||
|
public void addField(FieldBuilder fieldBuilder) {
|
||||||
|
fieldBuilderMap.put(fieldBuilder.getType(), fieldBuilder);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(BufferedWriter writer) throws IOException {
|
||||||
|
writer.write("package " + packageName + ";\n");
|
||||||
|
writer.write("\n");
|
||||||
|
writer.write("public class " + className + " {\n");
|
||||||
|
for (FieldBuilder fieldBuilder : fieldBuilderMap.values()) {
|
||||||
|
fieldBuilder.write(writer);
|
||||||
|
}
|
||||||
|
writer.write("}\n");
|
||||||
|
}
|
||||||
|
}
|
38
src/de/steamwar/linkage/plan/FieldBuilder.java
Normale Datei
38
src/de/steamwar/linkage/plan/FieldBuilder.java
Normale Datei
@ -0,0 +1,38 @@
|
|||||||
|
/*
|
||||||
|
* 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 lombok.Getter;
|
||||||
|
|
||||||
|
import java.io.BufferedWriter;
|
||||||
|
import java.io.IOException;
|
||||||
|
|
||||||
|
@AllArgsConstructor
|
||||||
|
public class FieldBuilder implements Writer {
|
||||||
|
@Getter
|
||||||
|
private Class<?> type;
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void write(BufferedWriter writer) throws IOException {
|
||||||
|
writer.write(" private static " + type.getTypeName() + " " + type.getSimpleName() + ";");
|
||||||
|
}
|
||||||
|
}
|
36
src/de/steamwar/linkage/types/Command.java
Normale Datei
36
src/de/steamwar/linkage/types/Command.java
Normale Datei
@ -0,0 +1,36 @@
|
|||||||
|
/*
|
||||||
|
* 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.types;
|
||||||
|
|
||||||
|
import de.steamwar.command.AbstractSWCommand;
|
||||||
|
import de.steamwar.linkage.LinkageType;
|
||||||
|
|
||||||
|
public class Command implements LinkageType {
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public Class<?> clazzType() {
|
||||||
|
return AbstractSWCommand.class;
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String generateCode(String instance) {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren