From ac91c77584764b8944ce9c5aad36382656e3b831 Mon Sep 17 00:00:00 2001 From: yoyosource Date: Sat, 24 Sep 2022 20:26:33 +0200 Subject: [PATCH] Add new linkages that are needed Signed-off-by: yoyosource --- BauSystem_Linkage/build.gradle | 24 +---------- .../bausystem/linkage/LinkageProcessor.java | 1 - .../linkage/ProcessorImplementation.java | 27 ------------- .../linkage/types/BauGuiItem_GENERIC.java | 40 +++++++++++++++++++ .../types/BoundingBoxLoader_GENERIC.java | 39 ++++++++++++++++++ .../types/ConfigConverter_GENERIC.java | 40 +++++++++++++++++++ .../types/PanzernAlgorithm_GENERIC.java | 40 +++++++++++++++++++ .../types/SmartPlaceBehaviour_GENERIC.java | 40 +++++++++++++++++++ .../linkage/types/SpecialCommand_GENERIC.java | 40 +++++++++++++++++++ BauSystem_Main/build.gradle | 5 --- .../slaves/laufbau/BoundingBoxLoader.java | 25 ++++++++++++ 11 files changed, 265 insertions(+), 56 deletions(-) delete mode 100644 BauSystem_Linkage/src/de/steamwar/bausystem/linkage/ProcessorImplementation.java create mode 100644 BauSystem_Linkage/src/de/steamwar/linkage/types/BauGuiItem_GENERIC.java create mode 100644 BauSystem_Linkage/src/de/steamwar/linkage/types/BoundingBoxLoader_GENERIC.java create mode 100644 BauSystem_Linkage/src/de/steamwar/linkage/types/ConfigConverter_GENERIC.java create mode 100644 BauSystem_Linkage/src/de/steamwar/linkage/types/PanzernAlgorithm_GENERIC.java create mode 100644 BauSystem_Linkage/src/de/steamwar/linkage/types/SmartPlaceBehaviour_GENERIC.java create mode 100644 BauSystem_Linkage/src/de/steamwar/linkage/types/SpecialCommand_GENERIC.java create mode 100644 BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BoundingBoxLoader.java diff --git a/BauSystem_Linkage/build.gradle b/BauSystem_Linkage/build.gradle index 486cb7c7..2169557f 100644 --- a/BauSystem_Linkage/build.gradle +++ b/BauSystem_Linkage/build.gradle @@ -43,27 +43,5 @@ sourceSets { } dependencies { - compileOnly 'org.projectlombok:lombok:1.18.22' - testCompileOnly 'org.projectlombok:lombok:1.18.22' - annotationProcessor 'org.projectlombok:lombok:1.18.22' - testAnnotationProcessor 'org.projectlombok:lombok:1.18.22' - - implementation 'org.atteo.classindex:classindex:3.11' - testImplementation 'org.atteo.classindex:classindex:3.11' - annotationProcessor 'org.atteo.classindex:classindex:3.11' - testAnnotationProcessor 'org.atteo.classindex:classindex:3.11' + compileOnly swdep('SpigotCore') } - -task buildResources { - doLast { - File from = new File("${buildDir}/classes/java/main/META-INF/annotations/de.steamwar.bausystem.linkage.ProcessorImplementation") - File to = new File("${buildDir}/classes/java/main/META-INF/services/javax.annotation.processing.Processor") - to.delete() - to.parentFile.mkdirs() - to.createNewFile() - for (String s : from.readLines()) { - to.append(s + "\n") - } - } -} -classes.finalizedBy(buildResources) \ No newline at end of file diff --git a/BauSystem_Linkage/src/de/steamwar/bausystem/linkage/LinkageProcessor.java b/BauSystem_Linkage/src/de/steamwar/bausystem/linkage/LinkageProcessor.java index deb7bce7..600ea4c4 100644 --- a/BauSystem_Linkage/src/de/steamwar/bausystem/linkage/LinkageProcessor.java +++ b/BauSystem_Linkage/src/de/steamwar/bausystem/linkage/LinkageProcessor.java @@ -30,7 +30,6 @@ import java.io.Writer; import java.util.*; import java.util.stream.Collectors; -@ProcessorImplementation @SupportedAnnotationTypes("de.steamwar.bausystem.linkage.Linked") public class LinkageProcessor extends AbstractProcessor { diff --git a/BauSystem_Linkage/src/de/steamwar/bausystem/linkage/ProcessorImplementation.java b/BauSystem_Linkage/src/de/steamwar/bausystem/linkage/ProcessorImplementation.java deleted file mode 100644 index 96cae2d3..00000000 --- a/BauSystem_Linkage/src/de/steamwar/bausystem/linkage/ProcessorImplementation.java +++ /dev/null @@ -1,27 +0,0 @@ -/* - * Copyright 2019,2020,2021 yoyosource - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * http://www.apache.org/licenses/LICENSE-2.0 - * Unless required by applicable law or agreed to in writing, software - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -package de.steamwar.bausystem.linkage; - -import org.atteo.classindex.IndexAnnotated; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@IndexAnnotated -@Retention(RetentionPolicy.CLASS) -@Target({ElementType.TYPE}) -public @interface ProcessorImplementation { -} diff --git a/BauSystem_Linkage/src/de/steamwar/linkage/types/BauGuiItem_GENERIC.java b/BauSystem_Linkage/src/de/steamwar/linkage/types/BauGuiItem_GENERIC.java new file mode 100644 index 00000000..160a7ca3 --- /dev/null +++ b/BauSystem_Linkage/src/de/steamwar/linkage/types/BauGuiItem_GENERIC.java @@ -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 . + */ + +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 BauGuiItem_GENERIC implements LinkageType { + + @Override + public String method() { + return "linkGUIItems"; + } + + @Override + public void generateCode(BuildPlan buildPlan, MethodBuilder methodBuilder, String s, TypeElement typeElement) { + buildPlan.addImport("de.steamwar.bausystem.features.gui.BauGUI"); + methodBuilder.addLine("BauGUI.addItem(" + s + ");"); + } +} diff --git a/BauSystem_Linkage/src/de/steamwar/linkage/types/BoundingBoxLoader_GENERIC.java b/BauSystem_Linkage/src/de/steamwar/linkage/types/BoundingBoxLoader_GENERIC.java new file mode 100644 index 00000000..a86d0cc5 --- /dev/null +++ b/BauSystem_Linkage/src/de/steamwar/linkage/types/BoundingBoxLoader_GENERIC.java @@ -0,0 +1,39 @@ +/* + * 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 . + */ + +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 BoundingBoxLoader_GENERIC implements LinkageType { + + @Override + public String method() { + return "linkBoundingBox"; + } + + @Override + public void generateCode(BuildPlan buildPlan, MethodBuilder method, String instance, TypeElement typeElement) { + method.addLine(instance + ".load();"); + } +} diff --git a/BauSystem_Linkage/src/de/steamwar/linkage/types/ConfigConverter_GENERIC.java b/BauSystem_Linkage/src/de/steamwar/linkage/types/ConfigConverter_GENERIC.java new file mode 100644 index 00000000..58db84e7 --- /dev/null +++ b/BauSystem_Linkage/src/de/steamwar/linkage/types/ConfigConverter_GENERIC.java @@ -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 . + */ + +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 ConfigConverter_GENERIC implements LinkageType { + + @Override + public String method() { + return "link"; + } + + @Override + public void generateCode(BuildPlan buildPlan, MethodBuilder methodBuilder, String s, TypeElement typeElement) { + buildPlan.addImport("de.steamwar.bausystem.configplayer.Config"); + methodBuilder.addLine("Config.addConfigConverter(" + s + ");"); + } +} diff --git a/BauSystem_Linkage/src/de/steamwar/linkage/types/PanzernAlgorithm_GENERIC.java b/BauSystem_Linkage/src/de/steamwar/linkage/types/PanzernAlgorithm_GENERIC.java new file mode 100644 index 00000000..bf701923 --- /dev/null +++ b/BauSystem_Linkage/src/de/steamwar/linkage/types/PanzernAlgorithm_GENERIC.java @@ -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 . + */ + +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 PanzernAlgorithm_GENERIC implements LinkageType { + + @Override + public String method() { + return "linkPanzern"; + } + + @Override + public void generateCode(BuildPlan buildPlan, MethodBuilder methodBuilder, String s, TypeElement typeElement) { + buildPlan.addImport("de.steamwar.bausystem.features.slaves.panzern.Panzern"); + methodBuilder.addLine("Panzern.add(" + s + ");"); + } +} diff --git a/BauSystem_Linkage/src/de/steamwar/linkage/types/SmartPlaceBehaviour_GENERIC.java b/BauSystem_Linkage/src/de/steamwar/linkage/types/SmartPlaceBehaviour_GENERIC.java new file mode 100644 index 00000000..6edaea3d --- /dev/null +++ b/BauSystem_Linkage/src/de/steamwar/linkage/types/SmartPlaceBehaviour_GENERIC.java @@ -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 . + */ + +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 SmartPlaceBehaviour_GENERIC implements LinkageType { + + @Override + public String method() { + return "linkPanzern"; + } + + @Override + public void generateCode(BuildPlan buildPlan, MethodBuilder methodBuilder, String s, TypeElement typeElement) { + buildPlan.addImport("de.steamwar.bausystem.features.smartplace.SmartPlaceListener"); + methodBuilder.addLine("SmartPlaceListener.add(" + s + ");"); + } +} diff --git a/BauSystem_Linkage/src/de/steamwar/linkage/types/SpecialCommand_GENERIC.java b/BauSystem_Linkage/src/de/steamwar/linkage/types/SpecialCommand_GENERIC.java new file mode 100644 index 00000000..97c63276 --- /dev/null +++ b/BauSystem_Linkage/src/de/steamwar/linkage/types/SpecialCommand_GENERIC.java @@ -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 . + */ + +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 SpecialCommand_GENERIC implements LinkageType { + + @Override + public String method() { + return "linkScriptCommands"; + } + + @Override + public void generateCode(BuildPlan buildPlan, MethodBuilder methodBuilder, String s, TypeElement typeElement) { + buildPlan.addImport("de.steamwar.bausystem.features.script.ScriptExecutor"); + methodBuilder.addLine("ScriptExecutor.SPECIAL_COMMANDS.add(" + s + ");"); + } +} diff --git a/BauSystem_Main/build.gradle b/BauSystem_Main/build.gradle index be1fcf2f..3f4576bc 100644 --- a/BauSystem_Main/build.gradle +++ b/BauSystem_Main/build.gradle @@ -51,11 +51,6 @@ dependencies { annotationProcessor 'org.projectlombok:lombok:1.18.22' testAnnotationProcessor 'org.projectlombok:lombok:1.18.22' - implementation 'org.atteo.classindex:classindex:3.11' - testImplementation 'org.atteo.classindex:classindex:3.11' - annotationProcessor 'org.atteo.classindex:classindex:3.11' - testAnnotationProcessor 'org.atteo.classindex:classindex:3.11' - implementation project(":BauSystem_Linkage") annotationProcessor project(":BauSystem_Linkage") diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BoundingBoxLoader.java b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BoundingBoxLoader.java new file mode 100644 index 00000000..7c2846b2 --- /dev/null +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BoundingBoxLoader.java @@ -0,0 +1,25 @@ +/* + * 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 . + */ + +package de.steamwar.bausystem.features.slaves.laufbau; + +public interface BoundingBoxLoader { + + void load(); +}