From 412971af4dbbd5e90705e3e32f0ece5a686183fa Mon Sep 17 00:00:00 2001 From: YoyoNow Date: Tue, 6 Aug 2024 11:09:19 +0200 Subject: [PATCH] Remove compile time linkage in favour of class index Optimize build time when no change happened for the BauSystem --- .../linkage/types/BauGuiItem_GENERIC.java | 40 -- .../types/BoundingBoxLoader_GENERIC.java | 39 -- .../types/ConfigConverter_GENERIC.java | 40 -- .../linkage/types/FAWEMaskParser_GENERIC.java | 41 -- .../types/FAWEPatternParser_GENERIC.java | 41 -- .../linkage/types/LuaLib_GENERIC.java | 40 -- .../types/PanzernAlgorithm_GENERIC.java | 40 -- .../types/ScoreboardElement_GENERIC.java | 40 -- BauSystem/BauSystem_Main/build.gradle.kts | 7 +- .../src/de/steamwar/bausystem/BauSystem.java | 144 +++++-- .../steamwar/bausystem/config/BauServer.java | 7 +- .../bausystem/features/gui/BauGUI.java | 8 +- .../features/script/event/HotkeyListener.java | 5 +- .../slaves/laufbau/BlockBoundingBox.java | 14 +- .../features/slaves/panzern/Panzern.java | 4 - .../smartplace/SmartPlaceListener.java | 3 +- .../features/world/NoCreativeKnockback.java | 3 +- .../mask/above/FAWEAboveMaskParser.java | 1 + .../mask/below/FAWEBelowMaskParser.java | 1 + .../FAWECheckerboard3DMaskParser.java | 1 + .../FAWECheckerboardMaskParser.java | 2 + .../mask/grid/FAWEGridMaskParser.java | 1 + .../gradient/FAWEGradientPatternParser.java | 2 + .../src/de/steamwar/linkage/Linked.java | 9 +- .../de/steamwar/linkage/LinkedInstance.java | 2 +- .../src/de/steamwar/linkage/MaxVersion.java | 3 +- .../src/de/steamwar/linkage/MinVersion.java | 3 +- .../src/de/steamwar/linkage/PluginCheck.java | 5 +- .../src/de/steamwar/linkage/api/Disable.java} | 13 +- .../src/de/steamwar/linkage/api/Enable.java | 19 +- .../de/steamwar/linkage/AllowedContexts.java | 36 -- .../src/de/steamwar/linkage/Context.java | 25 -- .../src/de/steamwar/linkage/EventMode.java | 44 --- .../de/steamwar/linkage/LinkageProcessor.java | 356 ------------------ .../src/de/steamwar/linkage/LinkageType.java | 36 -- .../src/de/steamwar/linkage/api/Disable.java | 24 -- .../src/de/steamwar/linkage/api/Enable.java | 24 -- .../src/de/steamwar/linkage/api/Plain.java | 23 -- .../de/steamwar/linkage/plan/BuildPlan.java | 89 ----- .../steamwar/linkage/plan/FieldBuilder.java | 44 --- .../steamwar/linkage/plan/MethodBuilder.java | 70 ---- .../linkage/plan/ParameterBuilder.java | 35 -- .../linkage/types/Disable_GENERIC.java | 39 -- .../linkage/types/Enable_GENERIC.java | 39 -- .../linkage/types/Listener_BUNGEE.java | 41 -- .../linkage/types/Listener_SPIGOT.java | 105 ------ .../linkage/types/PacketHandler_GENERIC.java | 39 -- .../steamwar/linkage/types/Plain_GENERIC.java | 39 -- .../linkage/types/SWCommand_BUNGEE.java | 39 -- .../linkage/types/SWCommand_SPIGOT.java | 39 -- CommonCore/build.gradle.kts | 1 - settings.gradle.kts | 2 - 52 files changed, 165 insertions(+), 1602 deletions(-) delete mode 100644 BauSystem/BauSystem_Linkage/src/de/steamwar/linkage/types/BauGuiItem_GENERIC.java delete mode 100644 BauSystem/BauSystem_Linkage/src/de/steamwar/linkage/types/BoundingBoxLoader_GENERIC.java delete mode 100644 BauSystem/BauSystem_Linkage/src/de/steamwar/linkage/types/ConfigConverter_GENERIC.java delete mode 100644 BauSystem/BauSystem_Linkage/src/de/steamwar/linkage/types/FAWEMaskParser_GENERIC.java delete mode 100644 BauSystem/BauSystem_Linkage/src/de/steamwar/linkage/types/FAWEPatternParser_GENERIC.java delete mode 100644 BauSystem/BauSystem_Linkage/src/de/steamwar/linkage/types/LuaLib_GENERIC.java delete mode 100644 BauSystem/BauSystem_Linkage/src/de/steamwar/linkage/types/PanzernAlgorithm_GENERIC.java delete mode 100644 BauSystem/BauSystem_Linkage/src/de/steamwar/linkage/types/ScoreboardElement_GENERIC.java rename {CommonCore/Linkage => BauSystem/BauSystem_Main}/src/de/steamwar/linkage/Linked.java (80%) rename {CommonCore/Linkage => BauSystem/BauSystem_Main}/src/de/steamwar/linkage/LinkedInstance.java (96%) rename {CommonCore/Linkage => BauSystem/BauSystem_Main}/src/de/steamwar/linkage/MaxVersion.java (93%) rename {CommonCore/Linkage => BauSystem/BauSystem_Main}/src/de/steamwar/linkage/MinVersion.java (93%) rename {CommonCore/Linkage => BauSystem/BauSystem_Main}/src/de/steamwar/linkage/PluginCheck.java (90%) rename BauSystem/{BauSystem_Linkage/build.gradle.kts => BauSystem_Main/src/de/steamwar/linkage/api/Disable.java} (80%) rename CommonCore/Linkage/build.gradle.kts => BauSystem/BauSystem_Main/src/de/steamwar/linkage/api/Enable.java (65%) delete mode 100644 CommonCore/Linkage/src/de/steamwar/linkage/AllowedContexts.java delete mode 100644 CommonCore/Linkage/src/de/steamwar/linkage/Context.java delete mode 100644 CommonCore/Linkage/src/de/steamwar/linkage/EventMode.java delete mode 100644 CommonCore/Linkage/src/de/steamwar/linkage/LinkageProcessor.java delete mode 100644 CommonCore/Linkage/src/de/steamwar/linkage/LinkageType.java delete mode 100644 CommonCore/Linkage/src/de/steamwar/linkage/api/Disable.java delete mode 100644 CommonCore/Linkage/src/de/steamwar/linkage/api/Enable.java delete mode 100644 CommonCore/Linkage/src/de/steamwar/linkage/api/Plain.java delete mode 100644 CommonCore/Linkage/src/de/steamwar/linkage/plan/BuildPlan.java delete mode 100644 CommonCore/Linkage/src/de/steamwar/linkage/plan/FieldBuilder.java delete mode 100644 CommonCore/Linkage/src/de/steamwar/linkage/plan/MethodBuilder.java delete mode 100644 CommonCore/Linkage/src/de/steamwar/linkage/plan/ParameterBuilder.java delete mode 100644 CommonCore/Linkage/src/de/steamwar/linkage/types/Disable_GENERIC.java delete mode 100644 CommonCore/Linkage/src/de/steamwar/linkage/types/Enable_GENERIC.java delete mode 100644 CommonCore/Linkage/src/de/steamwar/linkage/types/Listener_BUNGEE.java delete mode 100644 CommonCore/Linkage/src/de/steamwar/linkage/types/Listener_SPIGOT.java delete mode 100644 CommonCore/Linkage/src/de/steamwar/linkage/types/PacketHandler_GENERIC.java delete mode 100644 CommonCore/Linkage/src/de/steamwar/linkage/types/Plain_GENERIC.java delete mode 100644 CommonCore/Linkage/src/de/steamwar/linkage/types/SWCommand_BUNGEE.java delete mode 100644 CommonCore/Linkage/src/de/steamwar/linkage/types/SWCommand_SPIGOT.java diff --git a/BauSystem/BauSystem_Linkage/src/de/steamwar/linkage/types/BauGuiItem_GENERIC.java b/BauSystem/BauSystem_Linkage/src/de/steamwar/linkage/types/BauGuiItem_GENERIC.java deleted file mode 100644 index 160a7ca3..00000000 --- a/BauSystem/BauSystem_Linkage/src/de/steamwar/linkage/types/BauGuiItem_GENERIC.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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/BauSystem_Linkage/src/de/steamwar/linkage/types/BoundingBoxLoader_GENERIC.java b/BauSystem/BauSystem_Linkage/src/de/steamwar/linkage/types/BoundingBoxLoader_GENERIC.java deleted file mode 100644 index a86d0cc5..00000000 --- a/BauSystem/BauSystem_Linkage/src/de/steamwar/linkage/types/BoundingBoxLoader_GENERIC.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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/BauSystem_Linkage/src/de/steamwar/linkage/types/ConfigConverter_GENERIC.java b/BauSystem/BauSystem_Linkage/src/de/steamwar/linkage/types/ConfigConverter_GENERIC.java deleted file mode 100644 index 58db84e7..00000000 --- a/BauSystem/BauSystem_Linkage/src/de/steamwar/linkage/types/ConfigConverter_GENERIC.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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/BauSystem_Linkage/src/de/steamwar/linkage/types/FAWEMaskParser_GENERIC.java b/BauSystem/BauSystem_Linkage/src/de/steamwar/linkage/types/FAWEMaskParser_GENERIC.java deleted file mode 100644 index fac3093e..00000000 --- a/BauSystem/BauSystem_Linkage/src/de/steamwar/linkage/types/FAWEMaskParser_GENERIC.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 FAWEMaskParser_GENERIC implements LinkageType { - - @Override - public String method() { - return "link"; - } - - @Override - public void generateCode(BuildPlan buildPlan, MethodBuilder methodBuilder, String s, TypeElement typeElement) { - methodBuilder.addLine("if (org.bukkit.Bukkit.getPluginManager().getPlugin(\"FastAsyncWorldEdit\") != null) {"); - methodBuilder.addLine(" " + s + ";"); - methodBuilder.addLine("}"); - } -} diff --git a/BauSystem/BauSystem_Linkage/src/de/steamwar/linkage/types/FAWEPatternParser_GENERIC.java b/BauSystem/BauSystem_Linkage/src/de/steamwar/linkage/types/FAWEPatternParser_GENERIC.java deleted file mode 100644 index 60a1a4ea..00000000 --- a/BauSystem/BauSystem_Linkage/src/de/steamwar/linkage/types/FAWEPatternParser_GENERIC.java +++ /dev/null @@ -1,41 +0,0 @@ -/* - * 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 FAWEPatternParser_GENERIC implements LinkageType { - - @Override - public String method() { - return "link"; - } - - @Override - public void generateCode(BuildPlan buildPlan, MethodBuilder methodBuilder, String s, TypeElement typeElement) { - methodBuilder.addLine("if (org.bukkit.Bukkit.getPluginManager().getPlugin(\"FastAsyncWorldEdit\") != null) {"); - methodBuilder.addLine(" " + s + ";"); - methodBuilder.addLine("}"); - } -} diff --git a/BauSystem/BauSystem_Linkage/src/de/steamwar/linkage/types/LuaLib_GENERIC.java b/BauSystem/BauSystem_Linkage/src/de/steamwar/linkage/types/LuaLib_GENERIC.java deleted file mode 100644 index 570f6a33..00000000 --- a/BauSystem/BauSystem_Linkage/src/de/steamwar/linkage/types/LuaLib_GENERIC.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2023 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 LuaLib_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.features.script.lua.SteamWarLuaPlugin"); - methodBuilder.addLine("SteamWarLuaPlugin.add(" + s + ");"); - } -} diff --git a/BauSystem/BauSystem_Linkage/src/de/steamwar/linkage/types/PanzernAlgorithm_GENERIC.java b/BauSystem/BauSystem_Linkage/src/de/steamwar/linkage/types/PanzernAlgorithm_GENERIC.java deleted file mode 100644 index bf701923..00000000 --- a/BauSystem/BauSystem_Linkage/src/de/steamwar/linkage/types/PanzernAlgorithm_GENERIC.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * 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/BauSystem_Linkage/src/de/steamwar/linkage/types/ScoreboardElement_GENERIC.java b/BauSystem/BauSystem_Linkage/src/de/steamwar/linkage/types/ScoreboardElement_GENERIC.java deleted file mode 100644 index ffd6382f..00000000 --- a/BauSystem/BauSystem_Linkage/src/de/steamwar/linkage/types/ScoreboardElement_GENERIC.java +++ /dev/null @@ -1,40 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2023 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 ScoreboardElement_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.features.world.BauScoreboard"); - methodBuilder.addLine("BauScoreboard.addElement(" + s + ");"); - } -} diff --git a/BauSystem/BauSystem_Main/build.gradle.kts b/BauSystem/BauSystem_Main/build.gradle.kts index 2b694df6..4080a719 100644 --- a/BauSystem/BauSystem_Main/build.gradle.kts +++ b/BauSystem/BauSystem_Main/build.gradle.kts @@ -23,7 +23,6 @@ plugins { tasks.compileJava { options.isWarnings = false - options.compilerArgs.add("-AprojectDir=$projectDir") } java { @@ -32,8 +31,6 @@ java { } dependencies { - annotationProcessor(project(":BauSystem:BauSystem_Linkage")) - annotationProcessor(project(":SpigotCore")) compileOnly(project(":SpigotCore")) compileOnly(libs.spigotapi) @@ -43,7 +40,9 @@ dependencies { compileOnly(libs.nms20) compileOnly(libs.fawe18) - implementation(project(":BauSystem:BauSystem_Linkage")) + compileOnly("org.atteo.classindex:classindex:3.13") + annotationProcessor("org.atteo.classindex:classindex:3.13") + implementation(libs.luaj) implementation(files("$projectDir/../libs/YAPION-SNAPSHOT.jar")) } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java index 23f768a7..b51e2cf4 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/BauSystem.java @@ -20,33 +20,54 @@ package de.steamwar.bausystem; import com.comphenix.tinyprotocol.TinyProtocol; +import de.steamwar.bausystem.config.BauServer; import de.steamwar.bausystem.configplayer.Config; +import de.steamwar.bausystem.configplayer.ConfigConverter; +import de.steamwar.bausystem.features.gui.BauGUI; +import de.steamwar.bausystem.features.script.lua.SteamWarLuaPlugin; +import de.steamwar.bausystem.features.script.lua.libs.LuaLib; +import de.steamwar.bausystem.features.slaves.panzern.Panzern; +import de.steamwar.bausystem.features.slaves.panzern.PanzernAlgorithm; import de.steamwar.bausystem.features.tpslimit.TPSFreezeUtils; -import de.steamwar.bausystem.linkage.LinkageUtils; +import de.steamwar.bausystem.features.world.BauScoreboard; +import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.bausystem.region.loader.PrototypeLoader; import de.steamwar.bausystem.region.loader.RegionLoader; import de.steamwar.bausystem.region.loader.Updater; +import de.steamwar.bausystem.utils.ScoreboardElement; import de.steamwar.bausystem.utils.TickListener; import de.steamwar.bausystem.worlddata.WorldData; import de.steamwar.command.AbstractValidator; +import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommandUtils; +import de.steamwar.core.Core; +import de.steamwar.linkage.*; +import de.steamwar.linkage.api.Disable; +import de.steamwar.linkage.api.Enable; import de.steamwar.message.Message; +import de.steamwar.network.packets.PacketHandler; import lombok.Getter; +import org.atteo.classindex.ClassIndex; import org.bukkit.Bukkit; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; +import org.bukkit.event.HandlerList; import org.bukkit.event.Listener; import org.bukkit.plugin.Plugin; import org.bukkit.plugin.java.JavaPlugin; import org.bukkit.scheduler.BukkitRunnable; import org.bukkit.scheduler.BukkitTask; -import java.io.IOException; -import java.io.OutputStream; -import java.io.PrintStream; +import java.io.*; +import java.lang.reflect.Field; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.Objects; import java.util.concurrent.atomic.AtomicReference; import java.util.function.Consumer; import java.util.logging.Level; +import java.util.stream.Collectors; public class BauSystem extends JavaPlugin implements Listener { @@ -57,6 +78,8 @@ public class BauSystem extends JavaPlugin implements Listener { @Getter private static BauSystem instance; + private final Map, Object> instances = new HashMap<>(); + @Override public void onEnable() { // LOGGER @@ -85,17 +108,105 @@ public class BauSystem extends JavaPlugin implements Listener { SWCommandUtils.addValidator("supervisor", validator(Permission.SUPERVISOR)); SWCommandUtils.addValidator("owner", validator(Permission.OWNER)); - try { - LinkageUtils.link(); - } catch (Exception e) { - Bukkit.getLogger().log(Level.SEVERE, e.getMessage(), e); - Bukkit.shutdown(); - System.exit(1); - return; - } + instances.put(BauServer.class, BauServer.getInstance()); + List> classes = new BufferedReader(new InputStreamReader(BauSystem.class.getResourceAsStream("/META-INF/annotations/de.steamwar.linkage.Linked"))) + .lines() + .map(s -> { + try { + return Class.forName(s); + } catch (ClassNotFoundException e) { + return null; + } + }) + .filter(Objects::nonNull) + .collect(Collectors.toList()); + classes.forEach(clazz -> { + try { + Object any = clazz.newInstance(); + + MinVersion minVersion = clazz.getAnnotation(MinVersion.class); + MaxVersion maxVersion = clazz.getAnnotation(MaxVersion.class); + PluginCheck[] pluginChecks = clazz.getAnnotationsByType(PluginCheck.class); + if (minVersion != null && Core.getVersion() < minVersion.value()) { + return; + } + if (maxVersion != null && Core.getVersion() > maxVersion.value()) { + return; + } + for (PluginCheck pluginCheck : pluginChecks) { + if (pluginCheck.has() == PluginCheck.Has.THIS && Bukkit.getPluginManager().getPlugin(pluginCheck.value()) != null) { + continue; + } + if (pluginCheck.has() == PluginCheck.Has.NOT && Bukkit.getPluginManager().getPlugin(pluginCheck.value()) == null) { + continue; + } + return; + } + + instances.put(clazz, any); + if (any instanceof Enable) { + ((Enable) any).enable(); + } + if (any instanceof SWCommand) { + ((SWCommand) any).setMessage(BauSystem.MESSAGE); + } + if (any instanceof Listener) { + Bukkit.getPluginManager().registerEvents((Listener) any, BauSystem.getInstance()); + } + if (any instanceof PacketHandler) { + ((PacketHandler) any).register(); + } + if (any instanceof LuaLib) { + SteamWarLuaPlugin.add((LuaLib) any); + } + if (any instanceof ScoreboardElement) { + BauScoreboard.addElement((ScoreboardElement) any); + } + if (any instanceof BauGuiItem) { + BauGUI.addItem((BauGuiItem) any); + } + if (any instanceof PanzernAlgorithm) { + Panzern.add((PanzernAlgorithm) any); + } + if (any instanceof ConfigConverter) { + Config.addConfigConverter((ConfigConverter) any); + } + } catch (InstantiationException | IllegalAccessException e) { + Bukkit.getLogger().log(Level.SEVERE, e.getMessage(), e); + } + }); + + instances.forEach((clazz, o) -> { + for (Field field : clazz.getFields()) { + if (field.getAnnotation(LinkedInstance.class) != null) { + try { + field.set(o, instances.get(field.getType())); + } catch (IllegalAccessException e) { + throw new RuntimeException(e); + } + } + } + }); + TickListener.impl.init(); } + @Override + public void onDisable() { + instances.forEach((aClass, o) -> { + if (o instanceof Listener) { + HandlerList.unregisterAll((Listener) o); + } + if (o instanceof Disable) { + ((Disable) o).disable(); + } + }); + + WorldData.write(); + Config.getInstance().saveAll(); + TinyProtocol.instance.close(); + } + private AbstractValidator validator(Permission permission) { return (commandSender, object, messageSender) -> { if (commandSender instanceof Player) { @@ -109,15 +220,6 @@ public class BauSystem extends JavaPlugin implements Listener { }; } - @Override - public void onDisable() { - LinkageUtils.unlink(); - - WorldData.write(); - Config.getInstance().saveAll(); - TinyProtocol.instance.close(); - } - private void fixLogging() { System.setErr(new PrintStream(new OutputStream() { private StringBuilder current = new StringBuilder(); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/config/BauServer.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/config/BauServer.java index 3dc792f0..ee7d48e8 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/config/BauServer.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/config/BauServer.java @@ -19,21 +19,18 @@ package de.steamwar.bausystem.config; -import de.steamwar.linkage.Linked; import de.steamwar.providers.BauServerInfo; import de.steamwar.sql.SteamwarUser; import lombok.Getter; import java.util.UUID; -@Linked public class BauServer { @Getter - private static BauServer instance; + private static BauServer instance = new BauServer(); - public BauServer() { - instance = this; + private BauServer() { } private Integer owner; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGUI.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGUI.java index 3b8dc600..4c71acf4 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGUI.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/gui/BauGUI.java @@ -23,9 +23,9 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.SWUtils; import de.steamwar.bausystem.features.gui.editor.BauGuiMapping; -import de.steamwar.bausystem.linkage.LinkageUtils; import de.steamwar.bausystem.linkage.specific.BauGuiItem; import de.steamwar.inventory.SWInventory; +import lombok.Getter; import lombok.experimental.UtilityClass; import net.md_5.bungee.api.ChatColor; import org.bukkit.Material; @@ -38,13 +38,9 @@ import java.util.*; @UtilityClass public class BauGUI { + @Getter private static final Map ITEMS = new HashMap<>(); - public static Map getITEMS() { - if (ITEMS.isEmpty()) LinkageUtils.linkGUIItems(); - return ITEMS; - } - private static final Set OPEN_INVS = new HashSet<>(); private static boolean updating = false; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/event/HotkeyListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/event/HotkeyListener.java index 52843f79..466f1e60 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/event/HotkeyListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/script/event/HotkeyListener.java @@ -23,13 +23,12 @@ import de.steamwar.bausystem.BauSystem; import de.steamwar.bausystem.Permission; import de.steamwar.bausystem.features.script.ScriptRunner; import de.steamwar.linkage.Linked; -import de.steamwar.linkage.api.Plain; import org.bukkit.Bukkit; import org.bukkit.entity.Player; import org.bukkit.plugin.messaging.PluginMessageListener; @Linked -public class HotkeyListener implements PluginMessageListener, Plain { +public class HotkeyListener implements PluginMessageListener { { Bukkit.getServer().getMessenger().registerIncomingPluginChannel(BauSystem.getInstance(), "sw:hotkeys", this); @@ -37,7 +36,7 @@ public class HotkeyListener implements PluginMessageListener, Plain { @Override public void onPluginMessageReceived(String channel, Player player, byte[] message) { - if(!Permission.BUILD.hasPermission(player)) return; + if (!Permission.BUILD.hasPermission(player)) return; if (!channel.equals("sw:hotkeys")) return; if (message.length < 5) return; int action = message[4] & 0xFF; diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BlockBoundingBox.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BlockBoundingBox.java index 9809ac37..f10811f8 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BlockBoundingBox.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/laufbau/BlockBoundingBox.java @@ -21,26 +21,23 @@ package de.steamwar.bausystem.features.slaves.laufbau; import com.sk89q.worldedit.blocks.SkullBlock; import com.sk89q.worldedit.world.block.BaseBlock; -import de.steamwar.bausystem.linkage.LinkageUtils; import de.steamwar.bausystem.utils.NMSWrapper; import de.steamwar.core.Core; import de.steamwar.inventory.SWItem; import lombok.Getter; import lombok.ToString; -import org.bukkit.Bukkit; import org.bukkit.Material; -import org.bukkit.OfflinePlayer; -import org.bukkit.SkullType; -import org.bukkit.block.Block; import org.bukkit.block.BlockFace; -import org.bukkit.block.Skull; import org.bukkit.block.data.Bisected; import org.bukkit.block.data.BlockData; import org.bukkit.block.data.Directional; import org.bukkit.block.data.Waterlogged; import org.bukkit.block.data.type.*; -import java.util.*; +import java.util.ArrayList; +import java.util.Arrays; +import java.util.List; +import java.util.Random; import java.util.function.Consumer; import static de.steamwar.bausystem.features.slaves.laufbau.LaufbauUtils.createItem; @@ -52,6 +49,7 @@ public class BlockBoundingBox { private static List randomPlayerHead = new ArrayList<>(); private static Random random = new Random(); + static { randomPlayerHead.add("zOnlyKroks"); randomPlayerHead.add("YoyoNow"); @@ -274,8 +272,6 @@ public class BlockBoundingBox { eastTrapDoor.setFacing(BlockFace.EAST); eastTrapDoor.setOpen(true); addPixel(eastTrapDoor, 0, 0, 0, 3, 16, 16, createItem("LAUFBAU_BLOCK_IRON_TRAPDOOR", Material.IRON_TRAPDOOR, "LAUFBAU_FACING_EAST", "LAUFBAU_OPEN")); - - LinkageUtils.linkBoundingBox(); } private static void addPixel(BlockData blockData, double xPixel, double yPixel, double zPixel, double dxPixel, double dyPixel, double dzPixel, SWItem swItem) { diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/Panzern.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/Panzern.java index 3b8461df..3eca97f4 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/Panzern.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/slaves/panzern/Panzern.java @@ -24,7 +24,6 @@ import com.sk89q.worldedit.bukkit.BukkitAdapter; import com.sk89q.worldedit.world.block.BaseBlock; import com.sk89q.worldedit.world.block.BlockState; import com.sk89q.worldedit.world.block.BlockTypes; -import de.steamwar.bausystem.linkage.LinkageUtils; import de.steamwar.bausystem.utils.WorldEditUtils; import lombok.Getter; import lombok.SneakyThrows; @@ -41,9 +40,6 @@ import java.util.*; public class Panzern { private static List panzernAlgorithmList = new ArrayList<>(); - static { - LinkageUtils.linkPanzern(); - } public static void add(PanzernAlgorithm panzernAlgorithm) { panzernAlgorithmList.add(panzernAlgorithm); } diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceListener.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceListener.java index d8aaf2c7..10916beb 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceListener.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/smartplace/SmartPlaceListener.java @@ -27,7 +27,6 @@ import de.steamwar.bausystem.configplayer.Config; import de.steamwar.core.Core; import de.steamwar.inventory.SWItem; import de.steamwar.linkage.Linked; -import de.steamwar.linkage.api.Plain; import org.bukkit.*; import org.bukkit.block.Block; import org.bukkit.block.BlockFace; @@ -50,7 +49,7 @@ import java.util.Set; import java.util.stream.Collectors; @Linked -public class SmartPlaceListener implements Plain, Listener { +public class SmartPlaceListener implements Listener { private static final Set CONTAINERS = new HashSet<>(); private static final Set IGNORED = new HashSet<>(); diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/NoCreativeKnockback.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/NoCreativeKnockback.java index 83b33d42..19417ec2 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/NoCreativeKnockback.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/world/NoCreativeKnockback.java @@ -23,11 +23,10 @@ import com.comphenix.tinyprotocol.Reflection; import com.comphenix.tinyprotocol.TinyProtocol; import de.steamwar.bausystem.utils.NMSWrapper; import de.steamwar.linkage.Linked; -import de.steamwar.linkage.api.Plain; import org.bukkit.GameMode; @Linked -public class NoCreativeKnockback implements Plain { +public class NoCreativeKnockback { public NoCreativeKnockback() { TinyProtocol.instance.addFilter(Reflection.getClass("{nms.network.protocol.game}.PacketPlayOutExplosion"), (player, o) -> { diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/above/FAWEAboveMaskParser.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/above/FAWEAboveMaskParser.java index d25dcdeb..58130f47 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/above/FAWEAboveMaskParser.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/above/FAWEAboveMaskParser.java @@ -32,6 +32,7 @@ import javax.annotation.Nonnull; import java.util.stream.Stream; @Linked +@PluginCheck("FastAsyncWorldEdit") public class FAWEAboveMaskParser extends FAWEMaskParser { public FAWEAboveMaskParser() { diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/below/FAWEBelowMaskParser.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/below/FAWEBelowMaskParser.java index bc7cb34c..449db3bf 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/below/FAWEBelowMaskParser.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/below/FAWEBelowMaskParser.java @@ -32,6 +32,7 @@ import javax.annotation.Nonnull; import java.util.stream.Stream; @Linked +@PluginCheck("FastAsyncWorldEdit") public class FAWEBelowMaskParser extends FAWEMaskParser { public FAWEBelowMaskParser() { diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/checkerboard3d/FAWECheckerboard3DMaskParser.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/checkerboard3d/FAWECheckerboard3DMaskParser.java index cb943408..84cd46c6 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/checkerboard3d/FAWECheckerboard3DMaskParser.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/checkerboard3d/FAWECheckerboard3DMaskParser.java @@ -31,6 +31,7 @@ import javax.annotation.Nonnull; import java.util.stream.Stream; @Linked +@PluginCheck("FastAsyncWorldEdit") public class FAWECheckerboard3DMaskParser extends FAWEMaskParser { public FAWECheckerboard3DMaskParser() { diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/checkerboard3d/FAWECheckerboardMaskParser.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/checkerboard3d/FAWECheckerboardMaskParser.java index 1bfa6fb9..3036ba8e 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/checkerboard3d/FAWECheckerboardMaskParser.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/checkerboard3d/FAWECheckerboardMaskParser.java @@ -25,11 +25,13 @@ import com.sk89q.worldedit.extension.input.ParserContext; import com.sk89q.worldedit.function.mask.Mask; import de.steamwar.bausystem.features.worldedit.utils.FAWEMaskParser; import de.steamwar.linkage.Linked; +import de.steamwar.linkage.PluginCheck; import javax.annotation.Nonnull; import java.util.stream.Stream; @Linked +@PluginCheck("FastAsyncWorldEdit") public class FAWECheckerboardMaskParser extends FAWEMaskParser { public FAWECheckerboardMaskParser() { diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/grid/FAWEGridMaskParser.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/grid/FAWEGridMaskParser.java index f0d4a867..85a01162 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/grid/FAWEGridMaskParser.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/mask/grid/FAWEGridMaskParser.java @@ -31,6 +31,7 @@ import javax.annotation.Nonnull; import java.util.stream.Stream; @Linked +@PluginCheck("FastAsyncWorldEdit") public class FAWEGridMaskParser extends FAWEMaskParser { public FAWEGridMaskParser() { diff --git a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/pattern/gradient/FAWEGradientPatternParser.java b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/pattern/gradient/FAWEGradientPatternParser.java index 15b311e5..d8065658 100644 --- a/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/pattern/gradient/FAWEGradientPatternParser.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/bausystem/features/worldedit/pattern/gradient/FAWEGradientPatternParser.java @@ -27,12 +27,14 @@ import com.sk89q.worldedit.regions.Region; import de.steamwar.bausystem.features.worldedit.utils.FAWEPatternParser; import de.steamwar.bausystem.utils.WorldEditUtils; import de.steamwar.linkage.Linked; +import de.steamwar.linkage.PluginCheck; import org.bukkit.Axis; import javax.annotation.Nonnull; import java.util.stream.Stream; @Linked +@PluginCheck("FastAsyncWorldEdit") public class FAWEGradientPatternParser extends FAWEPatternParser { public FAWEGradientPatternParser() { diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/Linked.java b/BauSystem/BauSystem_Main/src/de/steamwar/linkage/Linked.java similarity index 80% rename from CommonCore/Linkage/src/de/steamwar/linkage/Linked.java rename to BauSystem/BauSystem_Main/src/de/steamwar/linkage/Linked.java index dbaf0eb7..3b0aa9e0 100644 --- a/CommonCore/Linkage/src/de/steamwar/linkage/Linked.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/linkage/Linked.java @@ -19,10 +19,15 @@ package de.steamwar.linkage; -import java.lang.annotation.*; +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.SOURCE) @Target({ElementType.TYPE}) public @interface Linked { - String feature() default ""; } diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/LinkedInstance.java b/BauSystem/BauSystem_Main/src/de/steamwar/linkage/LinkedInstance.java similarity index 96% rename from CommonCore/Linkage/src/de/steamwar/linkage/LinkedInstance.java rename to BauSystem/BauSystem_Main/src/de/steamwar/linkage/LinkedInstance.java index 9636ba52..04e382d1 100644 --- a/CommonCore/Linkage/src/de/steamwar/linkage/LinkedInstance.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/linkage/LinkedInstance.java @@ -24,7 +24,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -@Retention(RetentionPolicy.SOURCE) +@Retention(RetentionPolicy.RUNTIME) @Target({ElementType.FIELD}) public @interface LinkedInstance { } diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/MaxVersion.java b/BauSystem/BauSystem_Main/src/de/steamwar/linkage/MaxVersion.java similarity index 93% rename from CommonCore/Linkage/src/de/steamwar/linkage/MaxVersion.java rename to BauSystem/BauSystem_Main/src/de/steamwar/linkage/MaxVersion.java index e144b164..79dbfe94 100644 --- a/CommonCore/Linkage/src/de/steamwar/linkage/MaxVersion.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/linkage/MaxVersion.java @@ -24,8 +24,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -@AllowedContexts(Context.SPIGOT) -@Retention(RetentionPolicy.SOURCE) +@Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE}) public @interface MaxVersion { int value(); diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/MinVersion.java b/BauSystem/BauSystem_Main/src/de/steamwar/linkage/MinVersion.java similarity index 93% rename from CommonCore/Linkage/src/de/steamwar/linkage/MinVersion.java rename to BauSystem/BauSystem_Main/src/de/steamwar/linkage/MinVersion.java index b6f5b997..82d9ce3d 100644 --- a/CommonCore/Linkage/src/de/steamwar/linkage/MinVersion.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/linkage/MinVersion.java @@ -24,8 +24,7 @@ import java.lang.annotation.Retention; import java.lang.annotation.RetentionPolicy; import java.lang.annotation.Target; -@AllowedContexts(Context.SPIGOT) -@Retention(RetentionPolicy.SOURCE) +@Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE}) public @interface MinVersion { int value(); diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/PluginCheck.java b/BauSystem/BauSystem_Main/src/de/steamwar/linkage/PluginCheck.java similarity index 90% rename from CommonCore/Linkage/src/de/steamwar/linkage/PluginCheck.java rename to BauSystem/BauSystem_Main/src/de/steamwar/linkage/PluginCheck.java index 241f19a1..332e2b4f 100644 --- a/CommonCore/Linkage/src/de/steamwar/linkage/PluginCheck.java +++ b/BauSystem/BauSystem_Main/src/de/steamwar/linkage/PluginCheck.java @@ -21,8 +21,7 @@ package de.steamwar.linkage; import java.lang.annotation.*; -@AllowedContexts({Context.BUNGEE, Context.SPIGOT}) -@Retention(RetentionPolicy.SOURCE) +@Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE}) @Repeatable(PluginCheck.PluginChecks.class) public @interface PluginCheck { @@ -34,7 +33,7 @@ public @interface PluginCheck { NOT } - @Retention(RetentionPolicy.SOURCE) + @Retention(RetentionPolicy.RUNTIME) @Target({ElementType.TYPE}) @interface PluginChecks { @SuppressWarnings("unused") PluginCheck[] value() default {}; diff --git a/BauSystem/BauSystem_Linkage/build.gradle.kts b/BauSystem/BauSystem_Main/src/de/steamwar/linkage/api/Disable.java similarity index 80% rename from BauSystem/BauSystem_Linkage/build.gradle.kts rename to BauSystem/BauSystem_Main/src/de/steamwar/linkage/api/Disable.java index 8e924396..2ce273d9 100644 --- a/BauSystem/BauSystem_Linkage/build.gradle.kts +++ b/BauSystem/BauSystem_Main/src/de/steamwar/linkage/api/Disable.java @@ -17,15 +17,8 @@ * along with this program. If not, see . */ -plugins { - steamwar.java -} +package de.steamwar.linkage.api; -java { - sourceCompatibility = JavaVersion.VERSION_17 - targetCompatibility = JavaVersion.VERSION_17 -} - -dependencies { - compileOnly(project(":SpigotCore")) +public interface Disable { + void disable(); } diff --git a/CommonCore/Linkage/build.gradle.kts b/BauSystem/BauSystem_Main/src/de/steamwar/linkage/api/Enable.java similarity index 65% rename from CommonCore/Linkage/build.gradle.kts rename to BauSystem/BauSystem_Main/src/de/steamwar/linkage/api/Enable.java index ac86c4ce..df52baca 100644 --- a/CommonCore/Linkage/build.gradle.kts +++ b/BauSystem/BauSystem_Main/src/de/steamwar/linkage/api/Enable.java @@ -17,21 +17,8 @@ * along with this program. If not, see . */ -plugins { - steamwar.java -} +package de.steamwar.linkage.api; -tasks.register("buildResources") { - doLast { - val to = File("$projectDir/build/classes/java/main/META-INF/services/javax.annotation.processing.Processor") - to.parentFile.mkdirs() - if (!to.exists()) { - to.createNewFile() - to.writeText("de.steamwar.linkage.LinkageProcessor\n") - } - } +public interface Enable { + void enable(); } - -tasks.classes { - finalizedBy("buildResources") -} \ No newline at end of file diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/AllowedContexts.java b/CommonCore/Linkage/src/de/steamwar/linkage/AllowedContexts.java deleted file mode 100644 index 175a7831..00000000 --- a/CommonCore/Linkage/src/de/steamwar/linkage/AllowedContexts.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@Target(ElementType.ANNOTATION_TYPE) -@Retention(RetentionPolicy.CLASS) -public @interface AllowedContexts { - - /** - * The context in which this annotation is valid. - */ - Context[] value(); - -} diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/Context.java b/CommonCore/Linkage/src/de/steamwar/linkage/Context.java deleted file mode 100644 index 7559bd0c..00000000 --- a/CommonCore/Linkage/src/de/steamwar/linkage/Context.java +++ /dev/null @@ -1,25 +0,0 @@ -/* - * 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; - -public enum Context { - BUNGEE, - SPIGOT -} diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/EventMode.java b/CommonCore/Linkage/src/de/steamwar/linkage/EventMode.java deleted file mode 100644 index cdff4665..00000000 --- a/CommonCore/Linkage/src/de/steamwar/linkage/EventMode.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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; - -import lombok.AllArgsConstructor; -import lombok.Getter; - -import java.lang.annotation.ElementType; -import java.lang.annotation.Retention; -import java.lang.annotation.RetentionPolicy; -import java.lang.annotation.Target; - -@AllowedContexts(Context.BUNGEE) -@Retention(RetentionPolicy.SOURCE) -@Target({ElementType.TYPE}) -public @interface EventMode { - Mode value(); - - @AllArgsConstructor - enum Mode { - EventOnly(""), - NonEvent("!"); - - @Getter - private String prefix; - } -} diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/LinkageProcessor.java b/CommonCore/Linkage/src/de/steamwar/linkage/LinkageProcessor.java deleted file mode 100644 index e6b70418..00000000 --- a/CommonCore/Linkage/src/de/steamwar/linkage/LinkageProcessor.java +++ /dev/null @@ -1,356 +0,0 @@ -/* - * This file is a part of the SteamWar software. - * - * Copyright (C) 2024 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; - -import de.steamwar.linkage.plan.BuildPlan; -import de.steamwar.linkage.plan.FieldBuilder; -import de.steamwar.linkage.plan.MethodBuilder; -import de.steamwar.linkage.types.Plain_GENERIC; -import lombok.Cleanup; -import lombok.Getter; -import lombok.SneakyThrows; - -import javax.annotation.processing.*; -import javax.lang.model.SourceVersion; -import javax.lang.model.element.ElementKind; -import javax.lang.model.element.Modifier; -import javax.lang.model.element.TypeElement; -import javax.lang.model.element.VariableElement; -import javax.lang.model.type.DeclaredType; -import javax.lang.model.type.TypeMirror; -import javax.tools.Diagnostic; -import java.io.*; -import java.lang.annotation.Annotation; -import java.nio.file.Files; -import java.nio.file.Path; -import java.util.*; -import java.util.function.Consumer; -import java.util.stream.Collectors; -import java.util.stream.Stream; - -@SupportedAnnotationTypes("de.steamwar.linkage.Linked") -public class LinkageProcessor extends AbstractProcessor { - - private File projectDir; - - private static Context context; - - @Getter - private static String pluginMain; - - private String name; - private String className; - - private Set disabledFeatures = new HashSet<>(); - - private Messager messager; - private boolean processed = false; - - @Override - public SourceVersion getSupportedSourceVersion() { - return SourceVersion.latestSupported(); - } - - @SneakyThrows - @Override - public synchronized void init(ProcessingEnvironment processingEnv) { - super.init(processingEnv); - messager = processingEnv.getMessager(); - className = "LinkageUtils"; - - projectDir = new File(processingEnv.getOptions().get("projectDir")); - mainClass(projectDir); - disabledFeatures(); - - String name = projectDir.getName(); - if (name.contains("_")) { - name = name.substring(0, name.indexOf("_")); - } - this.name = name.replaceAll("[^a-zA-Z]", "").toLowerCase(); - } - - @SneakyThrows - private void mainClass(File projectDir) { - Optional pluginYMLFile = Files.walk(projectDir.toPath()) - .map(Path::toFile) - .filter(File::isFile) - .filter(f -> f.getName().equals("plugin.yml") || f.getName().equals("bungee.yml")) - .findFirst(); - if (!pluginYMLFile.isPresent()) { - messager.printMessage(Diagnostic.Kind.ERROR, "Could not find plugin.yml or bungee.yml"); - return; - } - context = pluginYMLFile.get().getName().equals("bungee.yml") ? Context.BUNGEE : Context.SPIGOT; - @Cleanup BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(pluginYMLFile.get()))); - Optional mainName = reader.lines() - .filter(line -> line.startsWith("main:")) - .map(line -> line.substring(line.indexOf(':') + 1).trim()) - .findFirst(); - if (mainName.isPresent()) { - pluginMain = mainName.get(); - } else { - messager.printMessage(Diagnostic.Kind.ERROR, "Could not find main class in plugin.yml or bungee.yml"); - } - } - - @SneakyThrows - private void disabledFeatures() { - File file = new File(System.getProperty("user.dir"), "disabled-features.txt"); - if (!file.exists()) return; - @Cleanup BufferedReader reader = new BufferedReader(new InputStreamReader(new FileInputStream(file))); - reader.lines() - .map(String::trim) - .filter(line -> !line.isEmpty()) - .filter(line -> !line.startsWith("#")) - .forEach(disabledFeatures::add); - } - - @SneakyThrows - @Override - public boolean process(Set annotations, RoundEnvironment roundEnv) { - if (processed) return false; - processed = true; - - Writer writer = processingEnv.getFiler().createSourceFile("de.steamwar." + name + ".linkage.LinkageUtils").openWriter(); - BuildPlan buildPlan = new BuildPlan("de.steamwar." + name + ".linkage", className); - - Set disabledElements = new HashSet<>(); - - Set elements = roundEnv.getElementsAnnotatedWith(Linked.class).stream() - .filter(element -> element.getKind() == ElementKind.CLASS) - .map(TypeElement.class::cast) - .peek(element -> { - String featureName = element.getAnnotation(Linked.class).feature(); - if (featureName.isEmpty()) { - String tempName = element.getQualifiedName().toString(); - if (tempName.contains(".features.")) { - tempName = tempName.substring(tempName.indexOf(".features.") + 10); - featureName = tempName.substring(0, tempName.indexOf('.')); - } else { - tempName = tempName.substring(0, tempName.lastIndexOf('.')); - featureName = tempName.substring(tempName.lastIndexOf('.') + 1); - } - } - if (disabledFeatures.contains(featureName) || disabledFeatures.contains("*")) { - disabledElements.add(element); - } - }) - .peek(typeElement -> System.out.println("Found element: " + typeElement.getQualifiedName().toString())) - .collect(Collectors.toSet()); - - Map, List> groupedByChecks = elements.stream() - .collect(Collectors.groupingBy(element -> checks(element, buildPlan))); - - Map neededFields = new HashMap<>(); - Set fieldInjections = new HashSet<>(); - for (TypeElement typeElement : elements) { - if (getLinkagesOfType(typeElement).size() > 1) { - neededFields.put(typeElement.getQualifiedName().toString(), typeElement); - } - - List variableElements = typeElement.getEnclosedElements().stream() - .filter(e -> e.getKind() == ElementKind.FIELD) - .map(VariableElement.class::cast) - .filter(e -> e.getAnnotation(LinkedInstance.class) != null) - .collect(Collectors.toList()); - if (variableElements.isEmpty()) continue; - - for (VariableElement variableElement : variableElements) { - if (!variableElement.getModifiers().contains(Modifier.PUBLIC)) { - messager.printMessage(Diagnostic.Kind.ERROR, "Field " + variableElement.getSimpleName() + " must be public", variableElement); - continue; - } - if (variableElement.getModifiers().contains(Modifier.STATIC)) { - messager.printMessage(Diagnostic.Kind.ERROR, "Field " + variableElement.getSimpleName() + " must be non static", variableElement); - continue; - } - if (variableElement.getModifiers().contains(Modifier.FINAL)) { - messager.printMessage(Diagnostic.Kind.ERROR, "Field " + variableElement.getSimpleName() + " must be non final", variableElement); - continue; - } - TypeElement fieldType = (TypeElement) ((DeclaredType) variableElement.asType()).asElement(); - if (disabledElements.contains(fieldType)) { - continue; - } - if (disabledElements.contains(typeElement)) { - continue; - } - neededFields.put(typeElement.getQualifiedName().toString(), typeElement); - neededFields.put(fieldType.getQualifiedName().toString(), fieldType); - - fieldInjections.add(() -> { - specialElements(typeElement, buildPlan, buildPlan::addStaticLine, () -> { - buildPlan.addStaticLine(getElement(typeElement, neededFields) + "." + variableElement.getSimpleName().toString() + " = " + getElement((TypeElement) ((DeclaredType) variableElement.asType()).asElement(), neededFields) + ";"); - }); - }); - } - } - neededFields.forEach((s, typeElement) -> { - if (disabledElements.contains(typeElement)) return; - buildPlan.addImport(typeElement.getQualifiedName().toString()); - String t = typeElement.getSimpleName().toString(); - t = t.substring(0, 1).toLowerCase() + t.substring(1); - buildPlan.addField(new FieldBuilder(typeElement.getSimpleName().toString(), t)); - - String finalT = t; - specialElements(typeElement, buildPlan, buildPlan::addStaticLine, () -> { - buildPlan.addStaticLine(finalT + " = new " + typeElement.getSimpleName().toString() + "();"); - }); - }); - fieldInjections.forEach(Runnable::run); - - Map methods = new HashMap<>(); - for (Map.Entry, List> entry : groupedByChecks.entrySet()) { - Map>> groupedByMethod = new HashMap<>(); - for (TypeElement typeElement : entry.getValue()) { - for (Map.Entry> linkages : getLinkagesOfType(typeElement).entrySet()) { - groupedByMethod.computeIfAbsent(linkages.getKey(), ignored -> new HashMap<>()) - .put(typeElement, linkages.getValue()); - } - } - - for (Map.Entry>> group : groupedByMethod.entrySet()) { - MethodBuilder method = methods.computeIfAbsent(group.getKey(), s -> { - MethodBuilder methodBuilder = new MethodBuilder(s, "void"); - buildPlan.addMethod(methodBuilder); - return methodBuilder; - }); - - boolean generated = false; - for (Map.Entry> toGenerate : group.getValue().entrySet()) { - if (disabledElements.contains(toGenerate.getKey())) continue; - if (!generated && !entry.getKey().isEmpty()) { - method.addLine("if (" + String.join(" && ", entry.getKey()) + ") {"); - generated = true; - } - TypeElement typeElement = toGenerate.getKey(); - String instance = getElement(typeElement, neededFields); - if (toGenerate.getValue().size() > 1 && instance.startsWith("new ")) { - method.addLine(typeElement.getSimpleName() + " local" + typeElement.getSimpleName().toString() + " = " + instance + ";"); - instance = "local" + typeElement.getSimpleName().toString(); - } - String finalInstance = instance; - toGenerate.getValue().forEach(linkageType -> { - buildPlan.addImport(typeElement.getQualifiedName().toString()); - linkageType.generateCode(buildPlan, method, finalInstance, typeElement); - }); - } - if (generated && !entry.getKey().isEmpty()) method.addLine("}"); - } - } - - BufferedWriter bufferedWriter = new BufferedWriter(writer); - buildPlan.write(bufferedWriter); - bufferedWriter.close(); - return true; - } - - private String getElement(TypeElement typeElement, Map neededFields) { - String s = typeElement.getSimpleName().toString(); - if (neededFields.containsKey(typeElement.getQualifiedName().toString())) { - return s.substring(0, 1).toLowerCase() + s.substring(1); - } - return "new " + s + "()"; - } - - private Set checks(TypeElement typeElement, BuildPlan buildPlan) { - Set checks = new HashSet<>(); - MinVersion minVersion = typeElement.getAnnotation(MinVersion.class); - MaxVersion maxVersion = typeElement.getAnnotation(MaxVersion.class); - EventMode eventMode = typeElement.getAnnotation(EventMode.class); - PluginCheck[] pluginChecks = typeElement.getAnnotationsByType(PluginCheck.class); - if (context == Context.SPIGOT) { - errorOnNonNull(typeElement, eventMode); - if (minVersion != null) { - buildPlan.addImport("de.steamwar.core.Core"); - checks.add("Core.getVersion() >= " + minVersion.value()); - } - if (maxVersion != null) { - buildPlan.addImport("de.steamwar.core.Core"); - checks.add("Core.getVersion() <= " + maxVersion.value()); - } - if (pluginChecks.length != 0) { - buildPlan.addImport("org.bukkit.Bukkit"); - Arrays.stream(pluginChecks).map(pluginCheck -> { - return "Bukkit.getPluginManager().getPlugin(\"" + pluginCheck.value() + "\") " + (pluginCheck.has() == PluginCheck.Has.THIS ? "!" : "=") + "= null"; - }).forEach(checks::add); - } - } else { - errorOnNonNull(typeElement, minVersion, maxVersion); - if (eventMode != null) { - buildPlan.addImport("de.steamwar.bungeecore.BungeeCore"); - checks.add(eventMode.value().getPrefix() + "BungeeCore.EVENT_MODE"); - } - if (pluginChecks.length != 0) { - buildPlan.addImport("net.md_5.bungee.BungeeCord"); - Arrays.stream(pluginChecks).map(pluginCheck -> { - return "BungeeCord.getPluginManager().getPlugin(\"" + pluginCheck.value() + "\") " + (pluginCheck.has() == PluginCheck.Has.THIS ? "!" : "=") + "= null"; - }).forEach(checks::add); - } - } - return checks; - } - - private void specialElements(TypeElement typeElement, BuildPlan buildPlan, Consumer stringConsumer, Runnable inner) { - Set checks = checks(typeElement, buildPlan); - if (!checks.isEmpty()) stringConsumer.accept("if (" + String.join(" && ", checks) + ") {"); - inner.run(); - if (!checks.isEmpty()) 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); - } - } - } - - private Plain_GENERIC plain_GENERIC = new Plain_GENERIC(); - - private Map> getLinkagesOfType(TypeElement typeElement) { - Map> linkages = new HashMap<>(); - Stream.concat(Stream.of(typeElement.getSuperclass()), typeElement.getInterfaces().stream()) - .map(this::resolveSingle) - .filter(Objects::nonNull) - .forEach(linkageType -> linkages.computeIfAbsent(linkageType.method(), s -> new ArrayList<>()).add(linkageType)); - if (linkages.size() == 1 && linkages.containsKey("unlink")) { - linkages.put(plain_GENERIC.method(), Collections.singletonList(plain_GENERIC)); - } - return linkages; - } - - private LinkageType resolveSingle(TypeMirror typeMirror) { - String qualifier = typeMirror.toString(); - if (qualifier.contains("<")) qualifier = qualifier.substring(0, qualifier.indexOf('<')); - 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; - } -} diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/LinkageType.java b/CommonCore/Linkage/src/de/steamwar/linkage/LinkageType.java deleted file mode 100644 index 9291279b..00000000 --- a/CommonCore/Linkage/src/de/steamwar/linkage/LinkageType.java +++ /dev/null @@ -1,36 +0,0 @@ -/* - * 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; - -import de.steamwar.linkage.plan.BuildPlan; -import de.steamwar.linkage.plan.MethodBuilder; - -import javax.lang.model.element.TypeElement; - -public interface LinkageType { - - default String getPluginMain() { - return LinkageProcessor.getPluginMain(); - } - - String method(); - - void generateCode(BuildPlan buildPlan, MethodBuilder method, String instance, TypeElement typeElement); -} diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/api/Disable.java b/CommonCore/Linkage/src/de/steamwar/linkage/api/Disable.java deleted file mode 100644 index f09b8468..00000000 --- a/CommonCore/Linkage/src/de/steamwar/linkage/api/Disable.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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.api; - -public interface Disable { - void disable(); -} diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/api/Enable.java b/CommonCore/Linkage/src/de/steamwar/linkage/api/Enable.java deleted file mode 100644 index 5d516cd6..00000000 --- a/CommonCore/Linkage/src/de/steamwar/linkage/api/Enable.java +++ /dev/null @@ -1,24 +0,0 @@ -/* - * 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.api; - -public interface Enable { - void enable(); -} diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/api/Plain.java b/CommonCore/Linkage/src/de/steamwar/linkage/api/Plain.java deleted file mode 100644 index 23901ed2..00000000 --- a/CommonCore/Linkage/src/de/steamwar/linkage/api/Plain.java +++ /dev/null @@ -1,23 +0,0 @@ -/* - * 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.api; - -public interface Plain { -} diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/plan/BuildPlan.java b/CommonCore/Linkage/src/de/steamwar/linkage/plan/BuildPlan.java deleted file mode 100644 index 2fc7b8b4..00000000 --- a/CommonCore/Linkage/src/de/steamwar/linkage/plan/BuildPlan.java +++ /dev/null @@ -1,89 +0,0 @@ -/* - * 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.plan; - -import lombok.RequiredArgsConstructor; - -import java.io.BufferedWriter; -import java.io.IOException; -import java.util.*; - -@RequiredArgsConstructor -public class BuildPlan { - - private final String packageName; - private Set imports = new HashSet<>(); - private final String className; - - private List fieldBuilders = new ArrayList<>(); - private Map methodBuilderMap = new HashMap<>(); - private List staticLines = new ArrayList<>(); - - public void addImport(String importName) { - imports.add(importName); - } - - public void addField(FieldBuilder fieldBuilder) { - fieldBuilders.add(fieldBuilder); - } - - public void addMethod(MethodBuilder methodBuilder) { - methodBuilderMap.put(methodBuilder.getMethodName(), methodBuilder); - } - - public boolean hasMethod(String methodName) { - return methodBuilderMap.containsKey(methodName); - } - - public void addStaticLine(String line) { - staticLines.add(line); - } - - public void write(BufferedWriter writer) throws IOException { - writer.write("package " + packageName + ";\n"); - if (!imports.isEmpty()) { - writer.write("\n"); - for (String importName : imports) { - writer.write("import " + importName + ";\n"); - } - } - writer.write("\n"); - writer.write("public class " + className + " {\n"); - if (!fieldBuilders.isEmpty()) { - for (FieldBuilder fieldBuilder : fieldBuilders) { - fieldBuilder.write(writer); - } - writer.write("\n"); - } - if (!staticLines.isEmpty()) { - writer.write(" static {\n"); - for (String line : staticLines) { - writer.write(" " + line + "\n"); - } - writer.write(" }\n"); - writer.write("\n"); - } - for (MethodBuilder methodBuilder : methodBuilderMap.values()) { - methodBuilder.write(writer); - writer.write("\n"); - } - writer.write("}\n"); - } -} diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/plan/FieldBuilder.java b/CommonCore/Linkage/src/de/steamwar/linkage/plan/FieldBuilder.java deleted file mode 100644 index 12fa4408..00000000 --- a/CommonCore/Linkage/src/de/steamwar/linkage/plan/FieldBuilder.java +++ /dev/null @@ -1,44 +0,0 @@ -/* - * 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.plan; - -import lombok.AllArgsConstructor; -import lombok.Getter; -import lombok.RequiredArgsConstructor; - -import java.io.BufferedWriter; -import java.io.IOException; - -@RequiredArgsConstructor -@AllArgsConstructor -public class FieldBuilder { - @Getter - private final String type; - private final String name; - private String initializer; - - public String getFieldName() { - return name; - } - - public void write(BufferedWriter writer) throws IOException { - writer.write(" private static " + type + " " + getFieldName() + (initializer == null ? "" : " = " + initializer) + ";\n"); - } -} diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/plan/MethodBuilder.java b/CommonCore/Linkage/src/de/steamwar/linkage/plan/MethodBuilder.java deleted file mode 100644 index 6a31175a..00000000 --- a/CommonCore/Linkage/src/de/steamwar/linkage/plan/MethodBuilder.java +++ /dev/null @@ -1,70 +0,0 @@ -/* - * 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.plan; - -import lombok.RequiredArgsConstructor; - -import java.io.BufferedWriter; -import java.io.IOException; -import java.util.ArrayList; -import java.util.List; - -@RequiredArgsConstructor -public class MethodBuilder { - - private final String name; - private final String returnType; - private List parameters = new ArrayList<>(); - private List lines = new ArrayList<>(); - private boolean isPrivate = false; - - public void addParameter(ParameterBuilder parameterBuilder) { - parameters.add(parameterBuilder); - } - - public void addLine(String line) { - lines.add(line); - } - - public String getMethodName() { - return name; - } - - public void setPrivate(boolean isPrivate) { - this.isPrivate = isPrivate; - } - - public void write(BufferedWriter writer) throws IOException { - writer.write(" " + (isPrivate ? "private" : "public") + " static " + returnType + " " + 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("\n"); - writer.write(" " + line); - } - writer.write("\n"); - writer.write(" }\n"); - } -} diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/plan/ParameterBuilder.java b/CommonCore/Linkage/src/de/steamwar/linkage/plan/ParameterBuilder.java deleted file mode 100644 index d88364be..00000000 --- a/CommonCore/Linkage/src/de/steamwar/linkage/plan/ParameterBuilder.java +++ /dev/null @@ -1,35 +0,0 @@ -/* - * 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.plan; - -import lombok.AllArgsConstructor; - -import java.io.BufferedWriter; -import java.io.IOException; - -@AllArgsConstructor -public class ParameterBuilder { - private String type; - private String name; - - public void write(BufferedWriter writer) throws IOException { - writer.write(type + " " + name); - } -} diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/types/Disable_GENERIC.java b/CommonCore/Linkage/src/de/steamwar/linkage/types/Disable_GENERIC.java deleted file mode 100644 index ea58c91b..00000000 --- a/CommonCore/Linkage/src/de/steamwar/linkage/types/Disable_GENERIC.java +++ /dev/null @@ -1,39 +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 . - */ - -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 Disable_GENERIC implements LinkageType { - - @Override - public String method() { - return "unlink"; - } - - @Override - public void generateCode(BuildPlan buildPlan, MethodBuilder method, String instance, TypeElement typeElement) { - method.addLine(instance + ".disable();"); - } -} diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/types/Enable_GENERIC.java b/CommonCore/Linkage/src/de/steamwar/linkage/types/Enable_GENERIC.java deleted file mode 100644 index 03afd570..00000000 --- a/CommonCore/Linkage/src/de/steamwar/linkage/types/Enable_GENERIC.java +++ /dev/null @@ -1,39 +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 . - */ - -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 Enable_GENERIC implements LinkageType { - - @Override - public String method() { - return "link"; - } - - @Override - public void generateCode(BuildPlan buildPlan, MethodBuilder method, String instance, TypeElement typeElement) { - method.addLine(instance + ".enable();"); - } -} diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/types/Listener_BUNGEE.java b/CommonCore/Linkage/src/de/steamwar/linkage/types/Listener_BUNGEE.java deleted file mode 100644 index 327b19ad..00000000 --- a/CommonCore/Linkage/src/de/steamwar/linkage/types/Listener_BUNGEE.java +++ /dev/null @@ -1,41 +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 . - */ - -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 Listener_BUNGEE implements LinkageType { - - @Override - public String method() { - return "link"; - } - - @Override - 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"); - method.addLine("ProxyServer.getInstance().getPluginManager().registerListener(BungeeCore.get(), " + instance + ");"); - } -} diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/types/Listener_SPIGOT.java b/CommonCore/Linkage/src/de/steamwar/linkage/types/Listener_SPIGOT.java deleted file mode 100644 index 3491d6d2..00000000 --- a/CommonCore/Linkage/src/de/steamwar/linkage/types/Listener_SPIGOT.java +++ /dev/null @@ -1,105 +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 . - */ - -package de.steamwar.linkage.types; - -import de.steamwar.linkage.LinkageType; -import de.steamwar.linkage.plan.BuildPlan; -import de.steamwar.linkage.plan.FieldBuilder; -import de.steamwar.linkage.plan.MethodBuilder; -import de.steamwar.linkage.plan.ParameterBuilder; - -import javax.lang.model.element.*; -import javax.lang.model.type.DeclaredType; -import java.util.HashMap; -import java.util.Map; - -public class Listener_SPIGOT implements LinkageType { - - @Override - public String method() { - return "link"; - } - - @Override - public void generateCode(BuildPlan buildPlan, MethodBuilder method, String instance, TypeElement typeElement) { - Map eventClasses = new HashMap<>(); - Map eventMethods = new HashMap<>(); - - typeElement.getEnclosedElements().stream().filter(e -> e.getKind() == ElementKind.METHOD).map(ExecutableElement.class::cast).filter(e -> { - return e.getAnnotationMirrors().stream().anyMatch(annotationMirror -> { - return annotationMirror.getAnnotationType().asElement().getSimpleName().toString().equals("EventHandler"); - }); - }).forEach(e -> { - TypeElement current = ((TypeElement)((DeclaredType) e.getParameters().get(0).asType()).asElement()); - eventClasses.put(current.getQualifiedName().toString(), current); - eventMethods.put(current, e); - }); - - eventClasses.forEach((s, eventType) -> { - if (buildPlan.hasMethod(eventType.getSimpleName().toString())) return; - buildPlan.addImport("org.bukkit.event.HandlerList"); - buildPlan.addImport("org.bukkit.event.Listener"); - buildPlan.addImport("java.util.function.Consumer"); - buildPlan.addImport("org.bukkit.event.EventPriority"); - buildPlan.addImport("org.bukkit.plugin.RegisteredListener"); - buildPlan.addImport("org.bukkit.plugin.EventExecutor"); - buildPlan.addImport(s); - buildPlan.addField(new FieldBuilder("HandlerList", "handlerList" + eventType.getSimpleName())); - MethodBuilder methodBuilder = new MethodBuilder(eventType.getSimpleName().toString(), "void"); - methodBuilder.addParameter(new ParameterBuilder("Listener", "listener")); - methodBuilder.addParameter(new ParameterBuilder("Consumer<" + eventType.getSimpleName() + ">", "consumer")); - methodBuilder.addParameter(new ParameterBuilder("EventPriority", "eventPriority")); - methodBuilder.addParameter(new ParameterBuilder("boolean", "ignoreCancelled")); - methodBuilder.setPrivate(true); - methodBuilder.addLine("EventExecutor eventExecutor = (l, event) -> {"); - methodBuilder.addLine(" if (event instanceof " + eventType.getSimpleName() + ") {"); - methodBuilder.addLine(" consumer.accept((" + eventType.getSimpleName() + ") event);"); - methodBuilder.addLine(" }"); - methodBuilder.addLine("};"); - methodBuilder.addLine("handlerList" + eventType.getSimpleName() + ".register(new RegisteredListener(listener, eventExecutor, eventPriority, " + getPluginMain() + ".getInstance(), ignoreCancelled));"); - buildPlan.addMethod(methodBuilder); - method.addLine("handlerList" + eventType.getSimpleName() + " = " + eventType.getSimpleName() + ".getHandlerList();"); - }); - - String localInstance = "local" + typeElement.getSimpleName().toString(); - if (!instance.startsWith("new ")) { - localInstance = instance; - } else { - method.addLine(typeElement.getSimpleName() + " " + localInstance + " = " + instance + ";"); - } - String finalLocalInstance = localInstance; - eventMethods.forEach((type, executableElement) -> { - AnnotationMirror eventHandler = executableElement.getAnnotationMirrors().stream().filter(annotationMirror -> annotationMirror.getAnnotationType().asElement().getSimpleName().toString().equals("EventHandler")).findFirst().orElse(null); - if (eventHandler == null) { - return; - } - String priority = "NORMAL"; - String ignoreCancelled = "false"; - for (Map.Entry entry : eventHandler.getElementValues().entrySet()) { - if (entry.getKey().getSimpleName().toString().equals("priority")) { - priority = entry.getValue().getValue().toString(); - } else if (entry.getKey().getSimpleName().toString().equals("ignoreCancelled")) { - ignoreCancelled = entry.getValue().getValue().toString(); - } - } - method.addLine(type.getSimpleName().toString() + "(" + finalLocalInstance + ", " + finalLocalInstance + "::" + executableElement.getSimpleName().toString() + ", EventPriority." + priority + ", " + ignoreCancelled + ");"); - }); - } -} diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/types/PacketHandler_GENERIC.java b/CommonCore/Linkage/src/de/steamwar/linkage/types/PacketHandler_GENERIC.java deleted file mode 100644 index 630f6f95..00000000 --- a/CommonCore/Linkage/src/de/steamwar/linkage/types/PacketHandler_GENERIC.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * 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 PacketHandler_GENERIC implements LinkageType { - - @Override - public String method() { - return "link"; - } - - @Override - public void generateCode(BuildPlan buildPlan, MethodBuilder method, String instance, TypeElement typeElement) { - method.addLine(instance + ".register();"); - } -} diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/types/Plain_GENERIC.java b/CommonCore/Linkage/src/de/steamwar/linkage/types/Plain_GENERIC.java deleted file mode 100644 index f066d035..00000000 --- a/CommonCore/Linkage/src/de/steamwar/linkage/types/Plain_GENERIC.java +++ /dev/null @@ -1,39 +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 . - */ - -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) { - if (instance.startsWith("new ")) method.addLine(instance + ";"); - } -} diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/types/SWCommand_BUNGEE.java b/CommonCore/Linkage/src/de/steamwar/linkage/types/SWCommand_BUNGEE.java deleted file mode 100644 index 5db62c4b..00000000 --- a/CommonCore/Linkage/src/de/steamwar/linkage/types/SWCommand_BUNGEE.java +++ /dev/null @@ -1,39 +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 . - */ - -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 + ";"); - } -} diff --git a/CommonCore/Linkage/src/de/steamwar/linkage/types/SWCommand_SPIGOT.java b/CommonCore/Linkage/src/de/steamwar/linkage/types/SWCommand_SPIGOT.java deleted file mode 100644 index 96e3f770..00000000 --- a/CommonCore/Linkage/src/de/steamwar/linkage/types/SWCommand_SPIGOT.java +++ /dev/null @@ -1,39 +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 . - */ - -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);"); - } -} diff --git a/CommonCore/build.gradle.kts b/CommonCore/build.gradle.kts index b6ca5861..91b10d6f 100644 --- a/CommonCore/build.gradle.kts +++ b/CommonCore/build.gradle.kts @@ -23,6 +23,5 @@ plugins { dependencies { api(project(":CommonCore:SQL")) - api(project(":CommonCore:Linkage")) api(project(":CommonCore:Network")) } diff --git a/settings.gradle.kts b/settings.gradle.kts index 49fbfa9f..3e56bc86 100644 --- a/settings.gradle.kts +++ b/settings.gradle.kts @@ -147,7 +147,6 @@ include( "BauSystem:BauSystem_18", "BauSystem:BauSystem_19", "BauSystem:BauSystem_20", - "BauSystem:BauSystem_Linkage", "BauSystem:BauSystem_Main" ) @@ -156,7 +155,6 @@ include("CommandFramework") include( "CommonCore", "CommonCore:SQL", - "CommonCore:Linkage", "CommonCore:Network" )