diff --git a/src/de/steamwar/linkage/AllowedContexts.java b/src/de/steamwar/linkage/AllowedContexts.java
new file mode 100644
index 0000000..775aaf5
--- /dev/null
+++ b/src/de/steamwar/linkage/AllowedContexts.java
@@ -0,0 +1,36 @@
+/*
+ * This file is a part of the SteamWar software.
+ *
+ * Copyright (C) 2022 SteamWar.de-Serverteam
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package de.steamwar.linkage;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@Target(ElementType.ANNOTATION_TYPE)
+@Retention(RetentionPolicy.CLASS)
+public @interface AllowedContexts {
+
+ /**
+ * The context in which this annotation is valid.
+ */
+ LinkageType.Context[] value();
+
+}
diff --git a/src/de/steamwar/linkage/DiscordMode.java b/src/de/steamwar/linkage/DiscordMode.java
new file mode 100644
index 0000000..f30bab8
--- /dev/null
+++ b/src/de/steamwar/linkage/DiscordMode.java
@@ -0,0 +1,31 @@
+/*
+ * This file is a part of the SteamWar software.
+ *
+ * Copyright (C) 2022 SteamWar.de-Serverteam
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package de.steamwar.linkage;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@AllowedContexts(LinkageType.Context.BUNGEE)
+@Retention(RetentionPolicy.SOURCE)
+@Target({ElementType.TYPE})
+public @interface DiscordMode {
+}
diff --git a/src/de/steamwar/linkage/EventMode.java b/src/de/steamwar/linkage/EventMode.java
new file mode 100644
index 0000000..86c8528
--- /dev/null
+++ b/src/de/steamwar/linkage/EventMode.java
@@ -0,0 +1,44 @@
+/*
+ * This file is a part of the SteamWar software.
+ *
+ * Copyright (C) 2022 SteamWar.de-Serverteam
+ *
+ * This program is free software: you can redistribute it and/or modify
+ * it under the terms of the GNU Affero General Public License as published by
+ * the Free Software Foundation, either version 3 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU Affero General Public License for more details.
+ *
+ * You should have received a copy of the GNU Affero General Public License
+ * along with this program. If not, see .
+ */
+
+package de.steamwar.linkage;
+
+import lombok.AllArgsConstructor;
+import lombok.Getter;
+
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@AllowedContexts(LinkageType.Context.BUNGEE)
+@Retention(RetentionPolicy.SOURCE)
+@Target({ElementType.TYPE})
+public @interface EventMode {
+ Mode value();
+
+ @AllArgsConstructor
+ enum Mode {
+ EventOnly(""),
+ NonEvent("!");
+
+ @Getter
+ private String prefix;
+ }
+}
diff --git a/src/de/steamwar/linkage/LinkageProcessor.java b/src/de/steamwar/linkage/LinkageProcessor.java
index 6b59e3b..14249ad 100644
--- a/src/de/steamwar/linkage/LinkageProcessor.java
+++ b/src/de/steamwar/linkage/LinkageProcessor.java
@@ -298,7 +298,19 @@ public class LinkageProcessor extends AbstractProcessor {
inner.run();
if (minVersion != null) stringConsumer.accept("}");
} else {
+ EventMode eventMode = typeElement.getAnnotation(EventMode.class);
+ DiscordMode discordMode = typeElement.getAnnotation(DiscordMode.class);
+ if (eventMode != null) {
+ buildPlan.addImport("de.steamwar.bungeecore.BungeeCore");
+ stringConsumer.accept("if (" + eventMode.value().getPrefix() + "BungeeCore.EVENT_MODE) {");
+ }
+ if (discordMode != null) {
+ buildPlan.addImport("de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig");
+ stringConsumer.accept("if (SteamwarDiscordBotConfig.loaded) {");
+ }
inner.run();
+ if (discordMode != null) stringConsumer.accept("}");
+ if (eventMode != null) stringConsumer.accept("}");
}
}
}
diff --git a/src/de/steamwar/linkage/MinVersion.java b/src/de/steamwar/linkage/MinVersion.java
index 6e396d7..d897935 100644
--- a/src/de/steamwar/linkage/MinVersion.java
+++ b/src/de/steamwar/linkage/MinVersion.java
@@ -19,9 +19,14 @@
package de.steamwar.linkage;
-/**
- * Only applicable in Spigot context. Will be ignored in other contexts.
- */
+import java.lang.annotation.ElementType;
+import java.lang.annotation.Retention;
+import java.lang.annotation.RetentionPolicy;
+import java.lang.annotation.Target;
+
+@AllowedContexts(LinkageType.Context.SPIGOT)
+@Retention(RetentionPolicy.SOURCE)
+@Target({ElementType.TYPE})
public @interface MinVersion {
int value();
}