Dieser Commit ist enthalten in:
Ursprung
8b7c1e08fd
Commit
33133ed079
@ -297,44 +297,44 @@ public class LinkageProcessor extends AbstractProcessor {
|
|||||||
PluginCheck[] pluginChecks = typeElement.getAnnotationsByType(PluginCheck.class);
|
PluginCheck[] pluginChecks = typeElement.getAnnotationsByType(PluginCheck.class);
|
||||||
if (context == LinkageType.Context.SPIGOT) {
|
if (context == LinkageType.Context.SPIGOT) {
|
||||||
errorOnNonNull(typeElement, eventMode, discordMode);
|
errorOnNonNull(typeElement, eventMode, discordMode);
|
||||||
|
List<String> checks = new ArrayList<>();
|
||||||
if (minVersion != null) {
|
if (minVersion != null) {
|
||||||
buildPlan.addImport("de.steamwar.core.Core");
|
buildPlan.addImport("de.steamwar.core.Core");
|
||||||
stringConsumer.accept("if (Core.getVersion() >= " + minVersion.value() + ") {");
|
checks.add("Core.getVersion() >= " + minVersion.value());
|
||||||
}
|
}
|
||||||
if (maxVersion != null) {
|
if (maxVersion != null) {
|
||||||
buildPlan.addImport("de.steamwar.core.Core");
|
buildPlan.addImport("de.steamwar.core.Core");
|
||||||
stringConsumer.accept("if (Core.getVersion() < " + maxVersion.value() + ") {");
|
checks.add("Core.getVersion() < " + maxVersion.value());
|
||||||
}
|
}
|
||||||
if (pluginChecks.length != 0) {
|
if (pluginChecks.length != 0) {
|
||||||
buildPlan.addImport("org.bukkit.Bukkit");
|
buildPlan.addImport("org.bukkit.Bukkit");
|
||||||
stringConsumer.accept(Arrays.stream(pluginChecks).map(pluginCheck -> {
|
Arrays.stream(pluginChecks).map(pluginCheck -> {
|
||||||
return "Bukkit.getPluginManager().getPlugin(\"" + pluginCheck.value() + "\") " + (pluginCheck.has() == PluginCheck.Has.THIS ? "=" : "!") + "= null";
|
return "Bukkit.getPluginManager().getPlugin(\"" + pluginCheck.value() + "\") " + (pluginCheck.has() == PluginCheck.Has.THIS ? "=" : "!") + "= null";
|
||||||
}).collect(Collectors.joining(" && ", "if (", ") {")));
|
}).forEach(checks::add);
|
||||||
}
|
}
|
||||||
|
if (!checks.isEmpty()) stringConsumer.accept("if (" + String.join(" && ", checks) + ") {");
|
||||||
inner.run();
|
inner.run();
|
||||||
if (pluginChecks.length != 0) stringConsumer.accept("}");
|
if (!checks.isEmpty()) stringConsumer.accept("}");
|
||||||
if (maxVersion != null) stringConsumer.accept("}");
|
|
||||||
if (minVersion != null) stringConsumer.accept("}");
|
|
||||||
} else {
|
} else {
|
||||||
errorOnNonNull(typeElement, minVersion, maxVersion);
|
errorOnNonNull(typeElement, minVersion, maxVersion);
|
||||||
|
List<String> checks = new ArrayList<>();
|
||||||
if (eventMode != null) {
|
if (eventMode != null) {
|
||||||
buildPlan.addImport("de.steamwar.bungeecore.BungeeCore");
|
buildPlan.addImport("de.steamwar.bungeecore.BungeeCore");
|
||||||
stringConsumer.accept("if (" + eventMode.value().getPrefix() + "BungeeCore.EVENT_MODE) {");
|
checks.add(eventMode.value().getPrefix() + "BungeeCore.EVENT_MODE");
|
||||||
}
|
}
|
||||||
if (discordMode != null) {
|
if (discordMode != null) {
|
||||||
buildPlan.addImport("de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig");
|
buildPlan.addImport("de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig");
|
||||||
stringConsumer.accept("if (SteamwarDiscordBotConfig.loaded) {");
|
checks.add("SteamwarDiscordBotConfig.loaded");
|
||||||
}
|
}
|
||||||
if (pluginChecks.length != 0) {
|
if (pluginChecks.length != 0) {
|
||||||
buildPlan.addImport("net.md_5.bungee.BungeeCord");
|
buildPlan.addImport("net.md_5.bungee.BungeeCord");
|
||||||
stringConsumer.accept(Arrays.stream(pluginChecks).map(pluginCheck -> {
|
Arrays.stream(pluginChecks).map(pluginCheck -> {
|
||||||
return "BungeeCord.getPluginManager().getPlugin(\"" + pluginCheck.value() + "\") " + (pluginCheck.has() == PluginCheck.Has.THIS ? "=" : "!") + "= null";
|
return "BungeeCord.getPluginManager().getPlugin(\"" + pluginCheck.value() + "\") " + (pluginCheck.has() == PluginCheck.Has.THIS ? "=" : "!") + "= null";
|
||||||
}).collect(Collectors.joining(" && ", "if (", ") {")));
|
}).forEach(checks::add);
|
||||||
}
|
}
|
||||||
|
if (!checks.isEmpty()) stringConsumer.accept("if (" + String.join(" && ", checks) + ") {");
|
||||||
inner.run();
|
inner.run();
|
||||||
if (pluginChecks.length != 0) stringConsumer.accept("}");
|
if (!checks.isEmpty()) stringConsumer.accept("}");
|
||||||
if (discordMode != null) stringConsumer.accept("}");
|
|
||||||
if (eventMode != null) stringConsumer.accept("}");
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren