Linkage #20
36
src/de/steamwar/linkage/AllowedContexts.java
Normale Datei
36
src/de/steamwar/linkage/AllowedContexts.java
Normale Datei
@ -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 <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.
|
||||
*/
|
||||
LinkageType.Context[] value();
|
||||
|
||||
}
|
31
src/de/steamwar/linkage/DiscordMode.java
Normale Datei
31
src/de/steamwar/linkage/DiscordMode.java
Normale Datei
@ -0,0 +1,31 @@
|
||||
/*
|
||||
* This file is a part of the SteamWar software.
|
||||
*
|
||||
* Copyright (C) 2022 SteamWar.de-Serverteam
|
||||
*
|
||||
* This program is free software: you can redistribute it and/or modify
|
||||
* it under the terms of the GNU Affero General Public License as published by
|
||||
* the Free Software Foundation, either version 3 of the License, or
|
||||
* (at your option) any later version.
|
||||
*
|
||||
* This program is distributed in the hope that it will be useful,
|
||||
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
* GNU Affero General Public License for more details.
|
||||
*
|
||||
* You should have received a copy of the GNU Affero General Public License
|
||||
* along with this program. If not, see <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.linkage;
|
||||
|
||||
import java.lang.annotation.ElementType;
|
||||
import java.lang.annotation.Retention;
|
||||
import java.lang.annotation.RetentionPolicy;
|
||||
import java.lang.annotation.Target;
|
||||
|
||||
@AllowedContexts(LinkageType.Context.BUNGEE)
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@Target({ElementType.TYPE})
|
||||
public @interface DiscordMode {
|
||||
}
|
44
src/de/steamwar/linkage/EventMode.java
Normale Datei
44
src/de/steamwar/linkage/EventMode.java
Normale Datei
@ -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 <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(LinkageType.Context.BUNGEE)
|
||||
@Retention(RetentionPolicy.SOURCE)
|
||||
@Target({ElementType.TYPE})
|
||||
public @interface EventMode {
|
||||
Mode value();
|
||||
|
||||
@AllArgsConstructor
|
||||
enum Mode {
|
||||
EventOnly(""),
|
||||
NonEvent("!");
|
||||
|
||||
@Getter
|
||||
private String prefix;
|
||||
}
|
||||
}
|
@ -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("}");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -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();
|
||||
}
|
||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren