forked from SteamWar/SteamWar
Merge pull request 'Remove compile time linkage in favour of class index' (#6) from BauSystem/RemoveLinkage into main
Reviewed-on: https://steamwar.de/devlabs/SteamWar/SteamWar/pulls/6 Reviewed-by: Lixfel <lixfel@steamwar.de>
This commit is contained in:
@@ -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 <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 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 + ");");
|
||||
}
|
||||
}
|
||||
-39
@@ -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 <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 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();");
|
||||
}
|
||||
}
|
||||
-40
@@ -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 <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 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 + ");");
|
||||
}
|
||||
}
|
||||
@@ -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("}");
|
||||
}
|
||||
}
|
||||
-41
@@ -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 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 + ");");
|
||||
}
|
||||
}
|
||||
-40
@@ -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 <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 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 + ");");
|
||||
}
|
||||
}
|
||||
-40
@@ -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 + ");");
|
||||
}
|
||||
}
|
||||
@@ -23,7 +23,6 @@ plugins {
|
||||
|
||||
tasks.compileJava {
|
||||
options.isWarnings = false
|
||||
options.compilerArgs.add("-AprojectDir=$projectDir")
|
||||
}
|
||||
|
||||
java {
|
||||
@@ -32,8 +31,8 @@ java {
|
||||
}
|
||||
|
||||
dependencies {
|
||||
annotationProcessor(project(":BauSystem:BauSystem_Linkage"))
|
||||
annotationProcessor(project(":SpigotCore"))
|
||||
compileOnly(libs.classindex)
|
||||
annotationProcessor(libs.classindex)
|
||||
compileOnly(project(":SpigotCore"))
|
||||
|
||||
compileOnly(libs.spigotapi)
|
||||
@@ -43,7 +42,6 @@ dependencies {
|
||||
compileOnly(libs.nms20)
|
||||
compileOnly(libs.fawe18)
|
||||
|
||||
implementation(project(":BauSystem:BauSystem_Linkage"))
|
||||
implementation(libs.luaj)
|
||||
implementation(files("$projectDir/../libs/YAPION-SNAPSHOT.jar"))
|
||||
}
|
||||
|
||||
@@ -19,34 +19,56 @@
|
||||
|
||||
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.LinkedInstance;
|
||||
import de.steamwar.linkage.MaxVersion;
|
||||
import de.steamwar.linkage.MinVersion;
|
||||
import de.steamwar.linkage.PluginCheck;
|
||||
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.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 +79,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 +109,108 @@ 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) {
|
||||
Bukkit.shutdown();
|
||||
throw new SecurityException(e.getMessage(), e);
|
||||
}
|
||||
})
|
||||
.filter(Objects::nonNull)
|
||||
.collect(Collectors.toList());
|
||||
classes.forEach(clazz -> {
|
||||
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;
|
||||
}
|
||||
|
||||
Object any;
|
||||
try {
|
||||
any = clazz.newInstance();
|
||||
} catch (InstantiationException | IllegalAccessException e) {
|
||||
getLogger().log(Level.SEVERE, e.getMessage(), e);
|
||||
Bukkit.shutdown();
|
||||
throw new SecurityException(e.getMessage());
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
});
|
||||
|
||||
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();
|
||||
}
|
||||
|
||||
private <T extends CommandSender> AbstractValidator<T, ?> validator(Permission permission) {
|
||||
return (commandSender, object, messageSender) -> {
|
||||
if (commandSender instanceof Player) {
|
||||
@@ -109,15 +224,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;
|
||||
|
||||
|
||||
+2
-3
@@ -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;
|
||||
|
||||
+5
-9
@@ -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) {
|
||||
|
||||
-4
@@ -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);
|
||||
}
|
||||
|
||||
+1
-2
@@ -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<>();
|
||||
|
||||
+1
-2
@@ -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) -> {
|
||||
|
||||
+1
@@ -32,6 +32,7 @@ import javax.annotation.Nonnull;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Linked
|
||||
@PluginCheck("FastAsyncWorldEdit")
|
||||
public class FAWEAboveMaskParser extends FAWEMaskParser {
|
||||
|
||||
public FAWEAboveMaskParser() {
|
||||
|
||||
+1
@@ -32,6 +32,7 @@ import javax.annotation.Nonnull;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Linked
|
||||
@PluginCheck("FastAsyncWorldEdit")
|
||||
public class FAWEBelowMaskParser extends FAWEMaskParser {
|
||||
|
||||
public FAWEBelowMaskParser() {
|
||||
|
||||
+1
@@ -31,6 +31,7 @@ import javax.annotation.Nonnull;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Linked
|
||||
@PluginCheck("FastAsyncWorldEdit")
|
||||
public class FAWECheckerboard3DMaskParser extends FAWEMaskParser {
|
||||
|
||||
public FAWECheckerboard3DMaskParser() {
|
||||
|
||||
+2
@@ -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() {
|
||||
|
||||
+1
@@ -31,6 +31,7 @@ import javax.annotation.Nonnull;
|
||||
import java.util.stream.Stream;
|
||||
|
||||
@Linked
|
||||
@PluginCheck("FastAsyncWorldEdit")
|
||||
public class FAWEGridMaskParser extends FAWEMaskParser {
|
||||
|
||||
public FAWEGridMaskParser() {
|
||||
|
||||
+2
@@ -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() {
|
||||
|
||||
+7
-2
@@ -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 "";
|
||||
}
|
||||
+1
-1
@@ -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 {
|
||||
}
|
||||
+1
-2
@@ -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();
|
||||
+1
-2
@@ -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();
|
||||
+2
-3
@@ -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 {};
|
||||
+3
-10
@@ -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();
|
||||
}
|
||||
+3
-16
@@ -17,21 +17,8 @@
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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")
|
||||
}
|
||||
@@ -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 <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;
|
||||
|
||||
@Target(ElementType.ANNOTATION_TYPE)
|
||||
@Retention(RetentionPolicy.CLASS)
|
||||
public @interface AllowedContexts {
|
||||
|
||||
/**
|
||||
* The context in which this annotation is valid.
|
||||
*/
|
||||
Context[] value();
|
||||
|
||||
}
|
||||
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.linkage;
|
||||
|
||||
public enum Context {
|
||||
BUNGEE,
|
||||
SPIGOT
|
||||
}
|
||||
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<String> 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<File> 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<String> 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<? extends TypeElement> 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<TypeElement> disabledElements = new HashSet<>();
|
||||
|
||||
Set<TypeElement> 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<Set<String>, List<TypeElement>> groupedByChecks = elements.stream()
|
||||
.collect(Collectors.groupingBy(element -> checks(element, buildPlan)));
|
||||
|
||||
Map<String, TypeElement> neededFields = new HashMap<>();
|
||||
Set<Runnable> fieldInjections = new HashSet<>();
|
||||
for (TypeElement typeElement : elements) {
|
||||
if (getLinkagesOfType(typeElement).size() > 1) {
|
||||
neededFields.put(typeElement.getQualifiedName().toString(), typeElement);
|
||||
}
|
||||
|
||||
List<VariableElement> 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<String, MethodBuilder> methods = new HashMap<>();
|
||||
for (Map.Entry<Set<String>, List<TypeElement>> entry : groupedByChecks.entrySet()) {
|
||||
Map<String, Map<TypeElement, List<LinkageType>>> groupedByMethod = new HashMap<>();
|
||||
for (TypeElement typeElement : entry.getValue()) {
|
||||
for (Map.Entry<String, List<LinkageType>> linkages : getLinkagesOfType(typeElement).entrySet()) {
|
||||
groupedByMethod.computeIfAbsent(linkages.getKey(), ignored -> new HashMap<>())
|
||||
.put(typeElement, linkages.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
for (Map.Entry<String, Map<TypeElement, List<LinkageType>>> 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<TypeElement, List<LinkageType>> 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<String, TypeElement> 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<String> checks(TypeElement typeElement, BuildPlan buildPlan) {
|
||||
Set<String> 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<String> stringConsumer, Runnable inner) {
|
||||
Set<String> 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<String, List<LinkageType>> getLinkagesOfType(TypeElement typeElement) {
|
||||
Map<String, List<LinkageType>> 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;
|
||||
}
|
||||
}
|
||||
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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);
|
||||
}
|
||||
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.linkage.api;
|
||||
|
||||
public interface Disable {
|
||||
void disable();
|
||||
}
|
||||
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.linkage.api;
|
||||
|
||||
public interface Enable {
|
||||
void enable();
|
||||
}
|
||||
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.linkage.api;
|
||||
|
||||
public interface Plain {
|
||||
}
|
||||
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<String> imports = new HashSet<>();
|
||||
private final String className;
|
||||
|
||||
private List<FieldBuilder> fieldBuilders = new ArrayList<>();
|
||||
private Map<String, MethodBuilder> methodBuilderMap = new HashMap<>();
|
||||
private List<String> 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");
|
||||
}
|
||||
}
|
||||
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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");
|
||||
}
|
||||
}
|
||||
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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<ParameterBuilder> parameters = new ArrayList<>();
|
||||
private List<String> 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");
|
||||
}
|
||||
}
|
||||
@@ -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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -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 <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 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();");
|
||||
}
|
||||
}
|
||||
@@ -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 <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 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();");
|
||||
}
|
||||
}
|
||||
@@ -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 <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 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 + ");");
|
||||
}
|
||||
}
|
||||
@@ -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 <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.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<String, TypeElement> eventClasses = new HashMap<>();
|
||||
Map<TypeElement, ExecutableElement> 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<? extends ExecutableElement, ? extends AnnotationValue> 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 + ");");
|
||||
});
|
||||
}
|
||||
}
|
||||
@@ -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 <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 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();");
|
||||
}
|
||||
}
|
||||
@@ -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 <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 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 + ";");
|
||||
}
|
||||
}
|
||||
@@ -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 <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 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 + ";");
|
||||
}
|
||||
}
|
||||
@@ -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 <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 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);");
|
||||
}
|
||||
}
|
||||
@@ -23,6 +23,5 @@ plugins {
|
||||
|
||||
dependencies {
|
||||
api(project(":CommonCore:SQL"))
|
||||
api(project(":CommonCore:Linkage"))
|
||||
api(project(":CommonCore:Network"))
|
||||
}
|
||||
|
||||
@@ -33,7 +33,7 @@ tasks.compileJava {
|
||||
sourceSets {
|
||||
main {
|
||||
java {
|
||||
srcDirs("src/", "build/generated/sources/annotationProcessor/java/main/") //TODO remove generated when LinkageUtils removed
|
||||
srcDirs("src/")
|
||||
}
|
||||
resources {
|
||||
srcDirs("src/")
|
||||
|
||||
+1
-2
@@ -108,6 +108,7 @@ dependencyResolutionManagement {
|
||||
library("hamcrest", "org.hamcrest:hamcrest:2.2")
|
||||
library("jda", "net.dv8tion:JDA:4.4.0_352")
|
||||
library("msgpack", "org.msgpack:msgpack-core:0.9.8")
|
||||
library("classindex", "org.atteo.classindex:classindex:3.13")
|
||||
|
||||
library("spigotapi", "org.spigotmc:spigot-api:1.20-R0.1-SNAPSHOT")
|
||||
library("spigotannotations", "org.spigotmc:plugin-annotations:1.2.3-SNAPSHOT")
|
||||
@@ -147,7 +148,6 @@ include(
|
||||
"BauSystem:BauSystem_18",
|
||||
"BauSystem:BauSystem_19",
|
||||
"BauSystem:BauSystem_20",
|
||||
"BauSystem:BauSystem_Linkage",
|
||||
"BauSystem:BauSystem_Main"
|
||||
)
|
||||
|
||||
@@ -156,7 +156,6 @@ include("CommandFramework")
|
||||
include(
|
||||
"CommonCore",
|
||||
"CommonCore:SQL",
|
||||
"CommonCore:Linkage",
|
||||
"CommonCore:Network"
|
||||
)
|
||||
|
||||
|
||||
Reference in New Issue
Block a user