SteamWar/BauSystem2.0
Archiviert
12
0

Optimize listener injection
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: yoyosource <yoyosource@nidido.de>
Dieser Commit ist enthalten in:
yoyosource 2022-08-27 21:04:35 +02:00
Ursprung 3e38e27b73
Commit 456f7dd660

Datei anzeigen

@ -131,6 +131,10 @@ public class LinkageProcessor extends AbstractProcessor {
if (!eventMethods.isEmpty()) { if (!eventMethods.isEmpty()) {
List<String> eventLines = new ArrayList<>(); List<String> eventLines = new ArrayList<>();
linkLines.put(LinkageType.LISTENER, eventLines); linkLines.put(LinkageType.LISTENER, eventLines);
eventClasses.forEach((s, typeElement) -> {
eventLines.add("handlerList" + typeElement.getSimpleName().toString() + " = " + typeElement.getQualifiedName().toString() + ".getHandlerList()");
});
eventLines.add("");
eventMethods.forEach((typeElement, map) -> { eventMethods.forEach((typeElement, map) -> {
String instance = "local" + typeElement.getSimpleName().toString(); String instance = "local" + typeElement.getSimpleName().toString();
eventLines.add(typeElement.getQualifiedName().toString() + " " + instance + " = " + getElement(typeElement, neededFields)); eventLines.add(typeElement.getQualifiedName().toString() + " " + instance + " = " + getElement(typeElement, neededFields));
@ -227,7 +231,7 @@ public class LinkageProcessor extends AbstractProcessor {
writer.write("\n"); writer.write("\n");
} }
for (Map.Entry<String, TypeElement> entry : eventClasses.entrySet()) { for (Map.Entry<String, TypeElement> entry : eventClasses.entrySet()) {
writer.write(" private static org.bukkit.event.HandlerList handlerList" + entry.getValue().getSimpleName().toString() + " = " + entry.getKey() + ".getHandlerList();\n"); writer.write(" private static org.bukkit.event.HandlerList handlerList" + entry.getValue().getSimpleName().toString() + ";\n");
writer.write(" private static void " + entry.getValue().getSimpleName().toString() + "(org.bukkit.event.Listener listener, java.util.function.Consumer<" + entry.getKey() + "> consumer, org.bukkit.event.EventPriority eventPriority, boolean ignoreCancelled) {\n"); writer.write(" private static void " + entry.getValue().getSimpleName().toString() + "(org.bukkit.event.Listener listener, java.util.function.Consumer<" + entry.getKey() + "> consumer, org.bukkit.event.EventPriority eventPriority, boolean ignoreCancelled) {\n");
writer.write(" org.bukkit.plugin.EventExecutor eventExecutor = (l, event) -> {\n"); writer.write(" org.bukkit.plugin.EventExecutor eventExecutor = (l, event) -> {\n");
writer.write(" if (event instanceof " + entry.getKey() + ") {\n"); writer.write(" if (event instanceof " + entry.getKey() + ") {\n");