Remove compile time linkage in favour of class index

Optimize build time when no change happened for the BauSystem
This commit is contained in:
2024-08-06 11:09:19 +02:00
parent b4ff8726af
commit 412971af4d
52 changed files with 165 additions and 1602 deletions
@@ -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 <https://www.gnu.org/licenses/>.
*/
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("}");
}
}
@@ -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 <https://www.gnu.org/licenses/>.
*/
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("}");
}
}
@@ -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 <https://www.gnu.org/licenses/>.
*/
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 + ");");
}
}
+3 -4
View File
@@ -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"))
}
@@ -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<Class<?>, 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<Class<?>> 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 <T extends CommandSender> AbstractValidator<T, ?> 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();
@@ -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;
@@ -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<Integer, BauGuiItem> ITEMS = new HashMap<>();
public static Map<Integer, BauGuiItem> getITEMS() {
if (ITEMS.isEmpty()) LinkageUtils.linkGUIItems();
return ITEMS;
}
private static final Set<Player> OPEN_INVS = new HashSet<>();
private static boolean updating = false;
@@ -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;
@@ -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<String> 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) {
@@ -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<PanzernAlgorithm> panzernAlgorithmList = new ArrayList<>();
static {
LinkageUtils.linkPanzern();
}
public static void add(PanzernAlgorithm panzernAlgorithm) {
panzernAlgorithmList.add(panzernAlgorithm);
}
@@ -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<Material> CONTAINERS = new HashSet<>();
private static final Set<Material> IGNORED = new HashSet<>();
@@ -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) -> {
@@ -32,6 +32,7 @@ import javax.annotation.Nonnull;
import java.util.stream.Stream;
@Linked
@PluginCheck("FastAsyncWorldEdit")
public class FAWEAboveMaskParser extends FAWEMaskParser {
public FAWEAboveMaskParser() {
@@ -32,6 +32,7 @@ import javax.annotation.Nonnull;
import java.util.stream.Stream;
@Linked
@PluginCheck("FastAsyncWorldEdit")
public class FAWEBelowMaskParser extends FAWEMaskParser {
public FAWEBelowMaskParser() {
@@ -31,6 +31,7 @@ import javax.annotation.Nonnull;
import java.util.stream.Stream;
@Linked
@PluginCheck("FastAsyncWorldEdit")
public class FAWECheckerboard3DMaskParser extends FAWEMaskParser {
public FAWECheckerboard3DMaskParser() {
@@ -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() {
@@ -31,6 +31,7 @@ import javax.annotation.Nonnull;
import java.util.stream.Stream;
@Linked
@PluginCheck("FastAsyncWorldEdit")
public class FAWEGridMaskParser extends FAWEMaskParser {
public FAWEGridMaskParser() {
@@ -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() {
@@ -17,24 +17,17 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.linkage.types;
package de.steamwar.linkage;
import de.steamwar.linkage.LinkageType;
import de.steamwar.linkage.plan.BuildPlan;
import de.steamwar.linkage.plan.MethodBuilder;
import org.atteo.classindex.IndexAnnotated;
import javax.lang.model.element.TypeElement;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
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 + ");");
}
@IndexAnnotated
@Retention(RetentionPolicy.SOURCE)
@Target({ElementType.TYPE})
public @interface Linked {
}
@@ -17,24 +17,14 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.linkage.types;
package de.steamwar.linkage;
import de.steamwar.linkage.LinkageType;
import de.steamwar.linkage.plan.BuildPlan;
import de.steamwar.linkage.plan.MethodBuilder;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
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 + ");");
}
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.FIELD})
public @interface LinkedInstance {
}
@@ -17,24 +17,15 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.linkage.types;
package de.steamwar.linkage;
import de.steamwar.linkage.LinkageType;
import de.steamwar.linkage.plan.BuildPlan;
import de.steamwar.linkage.plan.MethodBuilder;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
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 + ");");
}
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
public @interface MaxVersion {
int value();
}
@@ -0,0 +1,31 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2022 SteamWar.de-Serverteam
*
* This program is free software: you can redistribute it and/or modify
* it under the terms of the GNU Affero General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* This program is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU Affero General Public License for more details.
*
* You should have received a copy of the GNU Affero General Public License
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.linkage;
import java.lang.annotation.ElementType;
import java.lang.annotation.Retention;
import java.lang.annotation.RetentionPolicy;
import java.lang.annotation.Target;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
public @interface MinVersion {
int value();
}
@@ -17,23 +17,25 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.linkage.types;
package de.steamwar.linkage;
import de.steamwar.linkage.LinkageType;
import de.steamwar.linkage.plan.BuildPlan;
import de.steamwar.linkage.plan.MethodBuilder;
import java.lang.annotation.*;
import javax.lang.model.element.TypeElement;
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
@Repeatable(PluginCheck.PluginChecks.class)
public @interface PluginCheck {
Has has() default Has.THIS;
String value();
public class BoundingBoxLoader_GENERIC implements LinkageType {
@Override
public String method() {
return "linkBoundingBox";
enum Has {
THIS,
NOT
}
@Override
public void generateCode(BuildPlan buildPlan, MethodBuilder method, String instance, TypeElement typeElement) {
method.addLine(instance + ".load();");
@Retention(RetentionPolicy.RUNTIME)
@Target({ElementType.TYPE})
@interface PluginChecks {
@SuppressWarnings("unused") PluginCheck[] value() default {};
}
}
@@ -17,15 +17,8 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
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();
}
@@ -1,7 +1,7 @@
/*
* This file is a part of the SteamWar software.
*
* Copyright (C) 2023 SteamWar.de-Serverteam
* 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
@@ -17,24 +17,8 @@
* along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
package de.steamwar.linkage.types;
package de.steamwar.linkage.api;
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 + ");");
}
public interface Enable {
void enable();
}