diff --git a/src/de/steamwar/bungeecore/Broadcaster.java b/src/de/steamwar/bungeecore/Broadcaster.java
index 3020d013..6a06f7f0 100644
--- a/src/de/steamwar/bungeecore/Broadcaster.java
+++ b/src/de/steamwar/bungeecore/Broadcaster.java
@@ -19,6 +19,7 @@
package de.steamwar.bungeecore;
+import de.steamwar.messages.Chatter;
import net.md_5.bungee.api.ProxyServer;
import java.util.concurrent.TimeUnit;
@@ -28,10 +29,10 @@ class Broadcaster {
private static String [] broadCastMsgs;
private int lastBroadCast = 0;
- Broadcaster(){
+ Broadcaster() {
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
if(!ProxyServer.getInstance().getPlayers().isEmpty() && broadCastMsgs.length > 0)
- BungeeCore.broadcast(BungeeCore.CHAT_PREFIX + broadCastMsgs[lastBroadCast]);
+ Chatter.broadcast().system("PLAIN_STRING", broadCastMsgs[lastBroadCast]);
lastBroadCast++;
if(lastBroadCast == broadCastMsgs.length){
lastBroadCast = 0;
diff --git a/src/de/steamwar/bungeecore/BungeeCore.java b/src/de/steamwar/bungeecore/BungeeCore.java
index f005033b..1dd3eae6 100644
--- a/src/de/steamwar/bungeecore/BungeeCore.java
+++ b/src/de/steamwar/bungeecore/BungeeCore.java
@@ -19,29 +19,23 @@
package de.steamwar.bungeecore;
-import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
-import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
import de.steamwar.bungeecore.commands.*;
+import de.steamwar.bungeecore.discord.DiscordBot;
+import de.steamwar.bungeecore.discord.config.DiscordConfig;
import de.steamwar.bungeecore.listeners.*;
-import de.steamwar.bungeecore.mods.ServerListPing;
import de.steamwar.bungeecore.mods.*;
-import de.steamwar.bungeecore.network.BungeeNetworkHandler;
+import de.steamwar.bungeecore.network.handlers.*;
import de.steamwar.bungeecore.tablist.TablistManager;
import de.steamwar.command.*;
import de.steamwar.messages.Chatter;
+import de.steamwar.network.packets.PacketHandler;
import de.steamwar.sql.Punishment;
import de.steamwar.sql.SteamwarUser;
import de.steamwar.sql.Team;
import de.steamwar.sql.UserElo;
import de.steamwar.sql.internal.Statement;
-import net.md_5.bungee.api.ChatMessageType;
-import net.md_5.bungee.api.CommandSender;
+import lombok.Getter;
import net.md_5.bungee.api.ProxyServer;
-import net.md_5.bungee.api.chat.ClickEvent;
-import net.md_5.bungee.api.chat.HoverEvent;
-import net.md_5.bungee.api.chat.TextComponent;
-import net.md_5.bungee.api.config.ServerInfo;
-import net.md_5.bungee.api.connection.ProxiedPlayer;
import net.md_5.bungee.api.plugin.Plugin;
import net.md_5.bungee.config.Configuration;
import net.md_5.bungee.config.ConfigurationProvider;
@@ -58,18 +52,19 @@ import java.util.logging.Level;
public class BungeeCore extends Plugin {
public static boolean MAIN_SERVER;
-
- @Deprecated
- public static String CHAT_PREFIX;
- public static String LOBBY_SERVER;
public static boolean EVENT_MODE;
+ public static String LOBBY_SERVER;
+
private static BungeeCore instance;
public static Node local;
private ErrorLogger errorLogger;
private TablistManager tablistManager;
+ @Getter
+ private TeamCommand teamCommand;
+
@Override
public void onEnable(){
setInstance(this);
@@ -120,7 +115,7 @@ public class BungeeCore extends Plugin {
new JoinmeCommand();
new TpCommand();
HelpCommand helpCommand = new HelpCommand();
- new TeamCommand();
+ teamCommand = new TeamCommand();
new ServerTeamchatCommand();
new DevCommand();
new EventCommand();
@@ -129,7 +124,7 @@ public class BungeeCore extends Plugin {
new PollCommand();
new BugCommand();
new WhoisCommand();
- new RegelnCommand();
+ new RulesCommand();
new IgnoreCommand();
new UnIgnoreCommand();
new PollresultCommand();
@@ -143,6 +138,7 @@ public class BungeeCore extends Plugin {
new LocalCommand();
new SetLocaleCommand();
new BuilderCloudCommand();
+ new CheckCommand();
new ModCommand();
@@ -163,7 +159,6 @@ public class BungeeCore extends Plugin {
new FightCommand();
new ChallengeCommand();
new HistoricCommand();
- new CheckCommand();
new ReplayCommand();
new TutorialCommand();
@@ -172,9 +167,14 @@ public class BungeeCore extends Plugin {
new EventModeListener();
}
+ for(PacketHandler handler : new PacketHandler[] {
+ new EloPlayerHandler(), new EloSchemHandler(), new ExecuteCommandHandler(), new FightInfoHandler(),
+ new ImALobbyHandler(), new InventoryCallbackHandler(), new PrepareSchemHandler()
+ })
+ handler.register();
+
new EventStarter();
new SessionManager();
- BungeeNetworkHandler.register();
tablistManager = new TablistManager();
new SettingsChangedListener();
@@ -184,9 +184,9 @@ public class BungeeCore extends Plugin {
Team.clear();
}, 1, 1, TimeUnit.HOURS);
- if (SteamwarDiscordBotConfig.loaded) {
+ if (DiscordConfig.loaded) {
try {
- new SteamwarDiscordBot();
+ new DiscordBot();
} catch (Throwable e) {
getLogger().log(Level.SEVERE, "Could not initialize discord bot", e);
}
@@ -195,12 +195,10 @@ public class BungeeCore extends Plugin {
@Override
public void onDisable(){
- if (SteamwarDiscordBotConfig.loaded) {
- try {
- SteamwarDiscordBot.instance().getJda().shutdown();
- } catch (Throwable e) {
- getLogger().log(Level.SEVERE, "Could not shutdown discord bot", e);
- }
+ try {
+ DiscordBot.withBot(bot -> bot.getJda().shutdown());
+ } catch (Throwable e) {
+ getLogger().log(Level.SEVERE, "Could not shutdown discord bot", e);
}
if(tablistManager != null)
@@ -213,73 +211,6 @@ public class BungeeCore extends Plugin {
return instance;
}
- @Deprecated
- public static TextComponent stringToText(String msg){
- return new TextComponent(TextComponent.fromLegacyText(msg));
- }
- @Deprecated
- public static void send(ProxiedPlayer player, String msg){
- send(player, msg, null, null);
- }
- @Deprecated
- public static void send(CommandSender sender, String msg){
- sender.sendMessage(stringToText(msg));
- }
- @Deprecated
- public static void send(ProxiedPlayer player, ChatMessageType type, String msg){
- send(player, type, msg, null, null);
- }
- @Deprecated
- public static void send(ProxiedPlayer player, String msg, String onHover, ClickEvent onClick){
- send(player, ChatMessageType.SYSTEM, msg, onHover, onClick);
- }
- @Deprecated
- public static void send(ProxiedPlayer player, ChatMessageType type, String msg, String onHover, ClickEvent onClick){
- if(type == ChatMessageType.CHAT && player.getChatMode() != ProxiedPlayer.ChatMode.SHOWN)
- return;
- TextComponent message = stringToText(msg);
- if(onHover != null)
- message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(onHover)));
- if(onClick != null)
- message.setClickEvent(onClick);
- player.sendMessage(type, message);
- }
- @Deprecated
- public static void broadcast(String msg){
- ProxyServer.getInstance().broadcast(stringToText(msg));
- }
- @Deprecated
- public static void broadcast(String msg, String onHover, ClickEvent onClick){
- TextComponent message = stringToText(msg);
- if(onHover != null)
- message.setHoverEvent(new HoverEvent(HoverEvent.Action.SHOW_TEXT, TextComponent.fromLegacyText(onHover)));
- if(onClick != null)
- message.setClickEvent(onClick);
- ProxyServer.getInstance().broadcast(message);
- }
-
- @Deprecated
- public static void log(final ServerInfo server, final String msg){
- log(server.getName() + ": " + msg);
- }
- @Deprecated
- public static void log(final ProxiedPlayer player, final String msg){
- log(player.getName() + ": " + msg);
- }
- @Deprecated
- public static void log(final String msg){
- log(Level.INFO, msg);
- }
- @Deprecated
- public static void log(final Level logLevel, final String msg){
- get().getLogger().log(logLevel, msg);
- }
- @Deprecated
- public static void log(final String msg, final Throwable e){
- get().getLogger().log(Level.SEVERE, msg, e);
- }
-
-
private static void loadConfig(){
Configuration config;
try{
@@ -296,12 +227,11 @@ public class BungeeCore extends Plugin {
}
config = ConfigurationProvider.getProvider(YamlConfiguration.class).load(configFile);
}catch(Exception e){
- log("Could not save/load config.yml", e);
+ get().getLogger().log(Level.SEVERE, "Could not save/load config.yml", e);
ProxyServer.getInstance().stop();
return;
}
- CHAT_PREFIX = config.getString("prefix");
LOBBY_SERVER = config.getString("lobbyserver");
EVENT_MODE = config.getBoolean("eventmode");
Broadcaster.setBroadCastMsgs(config.getStringList("broadcasts").toArray(new String[1]));
@@ -322,15 +252,6 @@ public class BungeeCore extends Plugin {
cmds.toArray(new String[0])
);
}
-
- File discordFile = new File(System.getProperty("user.home"), "discord.yml");
- if(discordFile.exists() && !EVENT_MODE) {
- try {
- SteamwarDiscordBotConfig.loadConfig(ConfigurationProvider.getProvider(YamlConfiguration.class).load(discordFile));
- } catch (IOException e) {
- get().getLogger().log(Level.SEVERE, "Could not load discord bot configuration", e);
- }
- }
}
private static void setInstance(BungeeCore core){
diff --git a/src/de/steamwar/bungeecore/Message.java b/src/de/steamwar/bungeecore/Message.java
deleted file mode 100644
index e1073667..00000000
--- a/src/de/steamwar/bungeecore/Message.java
+++ /dev/null
@@ -1,118 +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 .
-*/
-
-package de.steamwar.bungeecore;
-
-import de.steamwar.messages.Chatter;
-import de.steamwar.messages.SteamwarResourceBundle;
-import net.md_5.bungee.api.ChatMessageType;
-import net.md_5.bungee.api.CommandSender;
-import net.md_5.bungee.api.chat.ClickEvent;
-
-import java.text.DateFormat;
-import java.text.MessageFormat;
-import java.util.Date;
-import java.util.Locale;
-import java.util.ResourceBundle;
-
-public class Message {
-
- @Deprecated
- public static String parse(String message, CommandSender sender, Object... params){
- return parse(message, false, locale(sender), params);
- }
-
- @Deprecated
- public static String parse(String message, Locale locale, Object... params){
- return parse(message, false, locale, params);
- }
-
- @Deprecated
- private static Locale locale(CommandSender sender) {
- return Chatter.of(sender).getLocale();
- }
-
- @Deprecated
- private static String parse(String message, boolean prefixed, Locale locale, Object... params){
- if(locale == null)
- locale = Locale.getDefault();
- ResourceBundle resourceBundle = SteamwarResourceBundle.getResourceBundle(locale);
- String pattern = "";
- if(prefixed)
- pattern = resourceBundle.getObject("PREFIX") + " ";
- pattern += (String)resourceBundle.getObject(message);
-
- MessageFormat format = new MessageFormat(pattern, locale);
- for (int i = 0; i < params.length; i++) {
- if(params[i] instanceof Message) {
- Message msg = (Message) params[i];
- params[i] = parse(msg.getFormat(), false, locale, msg.getParams());
- } else if(params[i] instanceof Date) {
- params[i] = DateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT, locale).format((Date) params[i]);
- }
- }
- return format.format(params);
- }
-
- @Deprecated
- public static void send(String message, CommandSender sender, Object... params){
- send(message, true, sender, ChatMessageType.SYSTEM, null, null, params);
- }
-
- @Deprecated
- public static void sendPrefixless(String message, CommandSender sender, Object... params){
- send(message, false, sender, ChatMessageType.SYSTEM, null, null, params);
- }
-
- @Deprecated
- public static void send(String message, CommandSender sender, String onHover, ClickEvent onClick, Object... params){
- send(message, true, sender, ChatMessageType.SYSTEM, onHover, onClick, params);
- }
-
- @Deprecated
- public static void sendPrefixless(String message, CommandSender sender, String onHover, ClickEvent onClick, Object... params){
- send(message, false, sender, ChatMessageType.SYSTEM, onHover, onClick, params);
- }
-
- @Deprecated
- private static void send(String message, boolean prefixed, CommandSender s, ChatMessageType type, String onHover, ClickEvent onClick, Object... params){
- Chatter sender = Chatter.of(s);
- if(type == ChatMessageType.CHAT && !sender.chatShown())
- return;
-
- sender.send(prefixed, type, onHover != null ? new Message("PLAIN_STRING", onHover) : null, onClick, new Message(message, params));
- }
-
- private final String format;
- private final Object[] params;
-
- public Message(String format, Object... params) {
- this.format = format;
- this.params = params;
- }
-
- public String getFormat() {
- return format;
- }
-
- public Object[] getParams() {
- return params;
- }
-
-}
\ No newline at end of file
diff --git a/src/de/steamwar/bungeecore/SubserverSystem.java b/src/de/steamwar/bungeecore/SubserverSystem.java
index b134e6d3..13321a1f 100644
--- a/src/de/steamwar/bungeecore/SubserverSystem.java
+++ b/src/de/steamwar/bungeecore/SubserverSystem.java
@@ -22,10 +22,10 @@ package de.steamwar.bungeecore;
import de.steamwar.bungeecore.network.NetworkSender;
import de.steamwar.bungeecore.network.handlers.FightInfoHandler;
import de.steamwar.messages.Chatter;
+import de.steamwar.messages.Message;
import de.steamwar.network.packets.server.StartingServerPacket;
import de.steamwar.sql.IgnoreSystem;
import de.steamwar.sql.SteamwarUser;
-import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.connection.ProxiedPlayer;
@@ -38,22 +38,20 @@ public class SubserverSystem {
node.execute("rm", "-r", worldName);
}
- public static void sendDeniedMessage(Chatter p, UUID owner){
- ProxiedPlayer o = ProxyServer.getInstance().getPlayer(owner);
- if(o == null)
- return;
+ public static void sendDeniedMessage(Chatter p, UUID owner) {
if(IgnoreSystem.isIgnored(owner, p.user().getUUID())){
p.system("SERVER_IGNORED");
return;
}
- Message.send("SERVER_ADD_MEMBER", o, p);
- Message.sendPrefixless("SERVER_ADD_MESSAGE", o, "SERVER_ADD_MESSAGE_HOVER", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/bau addmember " + p.user().getUserName()));
+ Chatter o = Chatter.of(owner);
+ o.system("SERVER_ADD_MEMBER", p);
+ o.prefixless("SERVER_ADD_MESSAGE", new Message("SERVER_ADD_MESSAGE_HOVER"), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/bau addmember " + p.user().getUserName()));
}
public static void sendPlayer(Subserver subserver, ProxiedPlayer player) {
subserver.sendPlayer(player);
- if(!subserver.hasStarted() && FightInfoHandler.onLobby(player))
+ if(!subserver.isStarted() && FightInfoHandler.onLobby(player))
NetworkSender.send(player, new StartingServerPacket(SteamwarUser.get(player.getUniqueId()).getId()));
}
}
diff --git a/src/de/steamwar/bungeecore/bot/AuthManager.java b/src/de/steamwar/bungeecore/bot/AuthManager.java
deleted file mode 100644
index 8500f12a..00000000
--- a/src/de/steamwar/bungeecore/bot/AuthManager.java
+++ /dev/null
@@ -1,81 +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 .
- */
-
-package de.steamwar.bungeecore.bot;
-
-import de.steamwar.bungeecore.BungeeCore;
-import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
-import de.steamwar.sql.SteamwarUser;
-import net.dv8tion.jda.api.MessageBuilder;
-import net.dv8tion.jda.api.entities.Emoji;
-import net.dv8tion.jda.api.entities.Member;
-import net.dv8tion.jda.api.interactions.components.ActionRow;
-import net.dv8tion.jda.api.interactions.components.Button;
-
-import java.util.*;
-import java.util.concurrent.TimeUnit;
-
-public class AuthManager {
-
- private static final Map TOKENS = new HashMap<>();
- private static final Random rand = new Random();
-
- public static String createDiscordAuthToken(Member member) {
- if(TOKENS.containsValue(member.getIdLong())) return null;
-
- byte[] randBytes = new byte[16];
- rand.nextBytes(randBytes);
- randBytes[0] = 'D';
- randBytes[1] = 'C';
- String code = Base64.getEncoder().encodeToString(randBytes);
-
- TOKENS.put(code, member.getIdLong());
- BungeeCore.log("Created Discord Auth-Token: " + code + " for: " + member.getUser().getAsTag());
- BungeeCore.get().getProxy().getScheduler().schedule(BungeeCore.get(), () -> TOKENS.remove(code), 10, TimeUnit.MINUTES);
- return code;
- }
-
- public static Member connectAuth(SteamwarUser user, String code) {
- if (TOKENS.containsKey(code)) {
- Member member = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).retrieveMemberById(TOKENS.get(code).longValue()).complete();
- if(member == null) return null;
- user.setDiscordId(member.getIdLong());
- MessageBuilder builder = new MessageBuilder();
- builder.setContent(":white_check_mark: Dein Discord Konto wurde mit **" + user.getUserName() + "** verknüpft");
- builder.setActionRows(ActionRow.of(Button.success("tada", Emoji.fromUnicode("U+1F389")), Button.danger("invalid", "Ich war das nicht")));
-
- try {
- member.getUser().openPrivateChannel().queue(privateChannel -> privateChannel.sendMessage(builder.build()).queue());
- if (member.getNickname() == null) {
- try {
- member.getGuild().modifyNickname(member, user.getUserName()).queue();
- } catch (Exception e) {
- // Ignored
- }
- }
- TOKENS.remove(code);
- return member;
- } catch (Exception e) {
- return null;
- }
- } else {
- return null;
- }
- }
-}
diff --git a/src/de/steamwar/bungeecore/bot/SteamwarDiscordBot.java b/src/de/steamwar/bungeecore/bot/SteamwarDiscordBot.java
deleted file mode 100644
index c9628e76..00000000
--- a/src/de/steamwar/bungeecore/bot/SteamwarDiscordBot.java
+++ /dev/null
@@ -1,166 +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 .
- */
-
-package de.steamwar.bungeecore.bot;
-
-import de.steamwar.bungeecore.BungeeCore;
-import de.steamwar.bungeecore.bot.commands.*;
-import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
-import de.steamwar.bungeecore.bot.events.EventManager;
-import de.steamwar.bungeecore.bot.events.SchematicsManager;
-import de.steamwar.bungeecore.bot.listeners.*;
-import de.steamwar.bungeecore.bot.util.DiscordRolesMessage;
-import de.steamwar.bungeecore.bot.util.DiscordRulesMessage;
-import de.steamwar.bungeecore.bot.util.DiscordTicketMessage;
-import de.steamwar.messages.Chatter;
-import de.steamwar.sql.Event;
-import lombok.Getter;
-import net.dv8tion.jda.api.JDA;
-import net.dv8tion.jda.api.JDABuilder;
-import net.dv8tion.jda.api.OnlineStatus;
-import net.dv8tion.jda.api.entities.Activity;
-import net.dv8tion.jda.api.entities.Guild;
-import net.dv8tion.jda.api.exceptions.ErrorResponseException;
-import net.dv8tion.jda.api.hooks.ListenerAdapter;
-import net.dv8tion.jda.api.requests.restaction.CommandListUpdateAction;
-import net.dv8tion.jda.api.utils.MemberCachePolicy;
-import net.md_5.bungee.api.ProxyServer;
-
-import javax.security.auth.login.LoginException;
-import java.util.HashMap;
-import java.util.Map;
-import java.util.concurrent.TimeUnit;
-import java.util.logging.Level;
-
-public class SteamwarDiscordBot {
-
- private static SteamwarDiscordBot INSTANCE;
-
- public static SteamwarDiscordBot instance() {
- return INSTANCE;
- }
-
- @Getter
- private volatile AnnouncementListener announcementListener;
-
- @Getter
- private volatile DiscordChatListener ingameChatListener;
-
- @Getter
- private volatile DiscordChatListener serverTeamChatListener;
-
- @Getter
- private final JDA jda;
-
- @Getter
- private static Map discordCommandMap = new HashMap<>();
-
- public SteamwarDiscordBot() {
- INSTANCE = this;
- JDABuilder builder = JDABuilder.createDefault(SteamwarDiscordBotConfig.TOKEN);
- builder.setStatus(OnlineStatus.ONLINE);
- builder.setMemberCachePolicy(MemberCachePolicy.ONLINE);
- try {
- jda = builder.build();
- } catch (LoginException e) {
- throw new SecurityException("Could not Login: " + SteamwarDiscordBotConfig.TOKEN, e);
- }
- ProxyServer.getInstance().getScheduler().runAsync(BungeeCore.get(), () -> {
- try {
- jda.awaitReady();
- } catch (InterruptedException e) {
- e.printStackTrace();
- }
- try {
- activity();
- } catch (Exception e) {
- BungeeCore.get().getLogger().log(Level.SEVERE, "Could not set initial activity to discord", e);
- }
- EventManager.update();
- SchematicsManager.update();
- ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
- try {
- activity();
- EventManager.update();
- SchematicsManager.update();
- } catch (ErrorResponseException e) {
- //ignored
- }
- }, 30, 30, TimeUnit.SECONDS);
- DiscordRolesMessage.sendMessage();
- DiscordRulesMessage.sendMessage();
- DiscordTicketMessage.sendMessage();
- new RolesInteractionButtonListener();
- new DiscordTicketListener();
- new DiscordAuthListener();
- new DiscordEventListener();
- new PrivateMessageListener();
- announcementListener = new AnnouncementListener();
- ingameChatListener = new DiscordChatListener(SteamwarDiscordBotConfig.INGAME_CHANNEL, "CHAT_DISCORD_GLOBAL", Chatter::broadcast);
- serverTeamChatListener = new DiscordChatListener(SteamwarDiscordBotConfig.SERVER_TEAM_CHANNEL, "CHAT_SERVERTEAM", Chatter::serverteam);
- new SlashCommandListener();
- jda.retrieveCommands().complete().forEach(command -> jda.deleteCommandById(command.getId()).queue());
-
- Guild guild = jda.getGuildById(SteamwarDiscordBotConfig.GUILD);
- guild.retrieveCommands().complete().forEach(command -> guild.deleteCommandById(command.getId()).complete());
- CommandListUpdateAction commands = jda.getGuildById(SteamwarDiscordBotConfig.GUILD).updateCommands();
- addCommand(commands, new MuteCommand());
- addCommand(commands, new BanCommand());
- addCommand(commands, new WhoisCommand());
- addCommand(commands, new TeamCommand());
- addCommand(commands, new ListCommand());
- addCommand(commands, new UnbanCommand());
- commands.complete();
- });
- }
-
- private void addCommand(CommandListUpdateAction commands, BasicDiscordCommand basicDiscordCommand) {
- commands.addCommands(basicDiscordCommand);
- discordCommandMap.put(basicDiscordCommand.getName(), basicDiscordCommand);
- }
-
- private int index = 0;
-
- private void activity() {
- switch (index) {
- case 0:
- Event event = Event.get();
- if (event != null) {
- jda.getPresence().setActivity(Activity.competing("dem Event " + event.getEventName()));
- } else {
- jda.getPresence().setActivity(Activity.playing("auf SteamWar.de"));
- }
- break;
- case 1:
- int count = BungeeCore.get().getProxy().getOnlineCount();
- if (count == 1) {
- jda.getPresence().setActivity(Activity.playing("mit 1 Spieler"));
- } else {
- jda.getPresence().setActivity(Activity.playing("mit " + count + " Spielern"));
- }
- index = 0;
- return;
- }
- index++;
- }
-
- public void addListener(ListenerAdapter listenerAdapter) {
- jda.addEventListener(listenerAdapter);
- }
-}
diff --git a/src/de/steamwar/bungeecore/bot/commands/BanCommand.java b/src/de/steamwar/bungeecore/bot/commands/BanCommand.java
deleted file mode 100644
index 987866cf..00000000
--- a/src/de/steamwar/bungeecore/bot/commands/BanCommand.java
+++ /dev/null
@@ -1,67 +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 .
- */
-
-package de.steamwar.bungeecore.bot.commands;
-
-import de.steamwar.bungeecore.Message;
-import de.steamwar.bungeecore.commands.PunishmentCommand;
-import de.steamwar.messages.Chatter;
-import de.steamwar.sql.SteamwarUser;
-import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
-import net.dv8tion.jda.api.interactions.commands.OptionType;
-
-import java.sql.Timestamp;
-
-public class BanCommand extends BasicDiscordCommand {
-
- public BanCommand() {
- super("ban", "Banne einen Nutzer, wenn du die Rechte hast.");
-
- addOption(OptionType.STRING, "user", "Der Benutzer", true);
- addOption(OptionType.STRING, "time", "Bis Wann", true);
- addOption(OptionType.STRING, "reason", "Warum", true);
- }
-
- @Override
- public void run(SlashCommandEvent event) {
- if (!testPermission(event)) {
- return;
- }
-
- SteamwarUser sender = SteamwarUser.get(event.getMember().getIdLong());
- SteamwarUser target = PunishmentCommand.getOrCreateOfflinePlayer(event.getOption("user").getAsString());
- if (target == null) {
- event.reply("Angegebener User invalide").setEphemeral(true).queue();
- return;
- }
-
- Timestamp time = PunishmentCommand.parseTime(null, event.getOption("time").getAsString());
- if (time == null) {
- event.reply("Angegebene Zeit invalide").setEphemeral(true).queue();
- return;
- }
-
- String msg = event.getOption("reason").getAsString();
- boolean isPerma = event.getOption("time").getAsString().equals("perma");
-
- PunishmentCommand.ban(target, time, msg, sender, isPerma);
- Chatter.serverteam().system("BAN_TEAM", new Message("PREFIX"), target.getUserName(), sender.getUserName(), new Message((isPerma ? "BAN_PERMA" : "BAN_UNTIL"), time), msg);
- event.reply("Erfolgreich " + target.getUserName() + (isPerma ? " permanent" : " bis " + time) + " gebannt").setEphemeral(true).queue();
- }
-}
diff --git a/src/de/steamwar/bungeecore/bot/commands/BasicDiscordCommand.java b/src/de/steamwar/bungeecore/bot/commands/BasicDiscordCommand.java
deleted file mode 100644
index 16df83d2..00000000
--- a/src/de/steamwar/bungeecore/bot/commands/BasicDiscordCommand.java
+++ /dev/null
@@ -1,54 +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 .
- */
-
-package de.steamwar.bungeecore.bot.commands;
-
-import de.steamwar.sql.SteamwarUser;
-import de.steamwar.sql.UserPerm;
-import net.dv8tion.jda.api.entities.Member;
-import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
-import net.dv8tion.jda.api.interactions.commands.build.CommandData;
-
-public abstract class BasicDiscordCommand extends CommandData {
-
- protected BasicDiscordCommand(String name, String description) {
- super(name, description);
- }
-
- public abstract void run(SlashCommandEvent event);
-
- protected SteamwarUser getSteamwarUser(SlashCommandEvent event) {
- Member member = event.getMember();
- SteamwarUser steamwarUser = SteamwarUser.get(member.getIdLong());
- if (steamwarUser == null) {
- return null;
- }
- return steamwarUser;
- }
-
- protected boolean testPermission(SlashCommandEvent event) {
- Member member = event.getMember();
- SteamwarUser steamwarUser = SteamwarUser.get(member.getIdLong());
- if (steamwarUser == null || (!steamwarUser.hasPerm(UserPerm.TEAM))) {
- event.reply("Du hast für " + event.getName() + " keine Rechte oder es existiert keine Verknüpfung für dich.").setEphemeral(true).queue();
- return false;
- }
- return true;
- }
-}
diff --git a/src/de/steamwar/bungeecore/bot/commands/ListCommand.java b/src/de/steamwar/bungeecore/bot/commands/ListCommand.java
deleted file mode 100644
index 746bb026..00000000
--- a/src/de/steamwar/bungeecore/bot/commands/ListCommand.java
+++ /dev/null
@@ -1,43 +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 .
- */
-
-package de.steamwar.bungeecore.bot.commands;
-
-import net.dv8tion.jda.api.EmbedBuilder;
-import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
-
-import java.util.stream.Collectors;
-
-public class ListCommand extends BasicDiscordCommand {
-
- public ListCommand() {
- super("list", "Gebe eine Liste aller online Spieler");
- }
-
- @Override
- public void run(SlashCommandEvent event) {
- de.steamwar.bungeecore.commands.ListCommand.getCustomTablist();
- EmbedBuilder embedBuilder = new EmbedBuilder();
- embedBuilder.setTitle("List");
- de.steamwar.bungeecore.commands.ListCommand.getCustomTablist().forEach((s, proxiedPlayers) -> {
- embedBuilder.addField(s, proxiedPlayers.stream().map(player -> "`" + player.getName() + "`").collect(Collectors.joining(", ")), true);
- });
- event.replyEmbeds(embedBuilder.build()).setEphemeral(true).queue();
- }
-}
diff --git a/src/de/steamwar/bungeecore/bot/commands/MuteCommand.java b/src/de/steamwar/bungeecore/bot/commands/MuteCommand.java
deleted file mode 100644
index 154152fa..00000000
--- a/src/de/steamwar/bungeecore/bot/commands/MuteCommand.java
+++ /dev/null
@@ -1,68 +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 .
- */
-
-package de.steamwar.bungeecore.bot.commands;
-
-import de.steamwar.bungeecore.Message;
-import de.steamwar.bungeecore.commands.PunishmentCommand;
-import de.steamwar.messages.Chatter;
-import de.steamwar.sql.Punishment;
-import de.steamwar.sql.SteamwarUser;
-import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
-import net.dv8tion.jda.api.interactions.commands.OptionType;
-
-import java.sql.Timestamp;
-
-public class MuteCommand extends BasicDiscordCommand {
-
- public MuteCommand() {
- super("mute", "Mute einen Nutzer, wenn du die Rechte hast.");
-
- addOption(OptionType.STRING, "user", "Der Benutzer", true);
- addOption(OptionType.STRING, "time", "Bis Wann", true);
- addOption(OptionType.STRING, "reason", "Warum", true);
- }
-
- @Override
- public void run(SlashCommandEvent event) {
- if (!testPermission(event)) {
- return;
- }
-
- SteamwarUser sender = SteamwarUser.get(event.getMember().getIdLong());
- SteamwarUser target = PunishmentCommand.getOrCreateOfflinePlayer(event.getOption("user").getAsString());
- if (target == null) {
- event.reply("Angegebener User invalide").setEphemeral(true).complete();
- return;
- }
-
- Timestamp time = PunishmentCommand.parseTime(null, event.getOption("time").getAsString());
- if (time == null) {
- event.reply("Angegebene Zeit invalide").setEphemeral(true).complete();
- return;
- }
-
- String msg = event.getOption("reason").getAsString();
- boolean isPerma = event.getOption("time").getAsString().equals("perma");
-
- target.punish(Punishment.PunishmentType.Mute, time, msg, sender.getId(), isPerma);
- Chatter.serverteam().system("MUTE_TEAM", new Message("PREFIX"), target.getUserName(), sender.getUserName(), new Message((isPerma ? "BAN_PERMA" : "BAN_UNTIL"), time), msg);
- event.reply("Erfolgreich " + target.getUserName() + (isPerma ? " permanent" : " bis " + time) + " gemutet").setEphemeral(true).queue();
- }
-}
diff --git a/src/de/steamwar/bungeecore/bot/commands/TeamCommand.java b/src/de/steamwar/bungeecore/bot/commands/TeamCommand.java
deleted file mode 100644
index c07dbf2f..00000000
--- a/src/de/steamwar/bungeecore/bot/commands/TeamCommand.java
+++ /dev/null
@@ -1,96 +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 .
- */
-
-package de.steamwar.bungeecore.bot.commands;
-
-import de.steamwar.sql.Event;
-import de.steamwar.sql.SteamwarUser;
-import de.steamwar.sql.Team;
-import de.steamwar.sql.TeamTeilnahme;
-import net.dv8tion.jda.api.EmbedBuilder;
-import net.dv8tion.jda.api.entities.Emoji;
-import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
-import net.dv8tion.jda.api.interactions.commands.OptionMapping;
-import net.dv8tion.jda.api.interactions.commands.OptionType;
-import net.dv8tion.jda.api.interactions.commands.build.SubcommandData;
-import net.md_5.bungee.api.ProxyServer;
-
-import java.awt.*;
-import java.util.List;
-import java.util.stream.Collectors;
-
-public class TeamCommand extends BasicDiscordCommand {
-
- public TeamCommand() {
- super("team", "Alle Team bezogenen Befehle");
-
- addSubcommands(new SubcommandData("info", "Infos über das Team oder deins")
- .addOption(OptionType.STRING, "team", "Name oder Kuerzel", false)
- );
- }
-
- private Emoji emoji = Emoji.fromUnicode("U+1F7E2");
-
- @Override
- public void run(SlashCommandEvent event) {
- SteamwarUser steamwarUser = getSteamwarUser(event);
-
- if (event.getSubcommandName() != null) {
- switch (event.getSubcommandName()) {
- case "info":
- OptionMapping optionMapping = event.getOption("team");
- Team team;
- if (optionMapping == null) {
- if (steamwarUser == null) {
- event.reply("Dein Discord ist nicht verknüpft").setEphemeral(true).queue();
- return;
- }
- if (steamwarUser.getTeam() == 0) {
- event.reply("Du bist in keinem Team").setEphemeral(true).queue();
- return;
- }
- team = Team.get(steamwarUser.getTeam());
- } else {
- team = Team.get(optionMapping.getAsString());
- }
- if (team == null) {
- event.reply("Unbekanntes Team").setEphemeral(true).queue();
- return;
- }
- EmbedBuilder embedBuilder = new EmbedBuilder();
- embedBuilder.setTitle("Team: " + team.getTeamName() + " [" + team.getTeamKuerzel() + "]");
- embedBuilder.setColor(Color.GRAY);
- List members = team.getMembers().stream().map(SteamwarUser::get).collect(Collectors.toList());
-
- embedBuilder.addField("Leader", members.stream().filter(SteamwarUser::isLeader).map(user -> "`" + (isOnline(user) ? emoji.getAsMention() : "") + user.getUserName() + "`").collect(Collectors.joining(" ")), false);
- embedBuilder.addField("Member", members.stream().filter(user -> !user.isLeader()).map(user -> "`" + (isOnline(user) ? emoji.getAsMention() : "") + user.getUserName() + "`").collect(Collectors.joining(" ")), false);
- embedBuilder.addField("Events", "`" + TeamTeilnahme.getEvents(team.getTeamId()).stream().map(Event::getEventName).collect(Collectors.joining("` `")) + "`", false);
- event.replyEmbeds(embedBuilder.build()).setEphemeral(true).queue();
- return;
- default:
- event.reply("Unbekannter Befehl").setEphemeral(true).queue();
- return;
- }
- }
- }
-
- private boolean isOnline(SteamwarUser user) {
- return ProxyServer.getInstance().getPlayer(user.getUUID()) != null;
- }
-}
diff --git a/src/de/steamwar/bungeecore/bot/commands/UnbanCommand.java b/src/de/steamwar/bungeecore/bot/commands/UnbanCommand.java
deleted file mode 100644
index 61d5c0de..00000000
--- a/src/de/steamwar/bungeecore/bot/commands/UnbanCommand.java
+++ /dev/null
@@ -1,62 +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 .
- */
-
-package de.steamwar.bungeecore.bot.commands;
-
-import de.steamwar.bungeecore.commands.PunishmentCommand;
-import de.steamwar.sql.BannedUserIPs;
-import de.steamwar.sql.Punishment;
-import de.steamwar.sql.SteamwarUser;
-import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
-import net.dv8tion.jda.api.interactions.commands.OptionType;
-
-import java.sql.Timestamp;
-import java.util.Date;
-
-public class UnbanCommand extends BasicDiscordCommand {
-
- public UnbanCommand() {
- super("unban", "Entbannt einen Nutzer, wenn du die Rechte hast.");
-
- addOption(OptionType.STRING, "user", "Der Benutzer", true);
- }
-
- @Override
- public void run(SlashCommandEvent event) {
- if (!testPermission(event)) {
- return;
- }
-
- SteamwarUser sender = SteamwarUser.get(event.getMember().getIdLong());
- SteamwarUser target = PunishmentCommand.getOrCreateOfflinePlayer(event.getOption("user").getAsString());
- if (target == null) {
- event.reply("Angegebener User invalide").setEphemeral(true).queue();
- return;
- }
-
- if (!target.isPunished(Punishment.PunishmentType.Ban)) {
- event.reply("Angegebener User ist nicht gebannt").setEphemeral(true).queue();
- return;
- }
-
- target.punish(Punishment.PunishmentType.Ban, Timestamp.from(new Date().toInstant()), "Unban", sender.getId(), false);
- BannedUserIPs.unbanIPs(target.getId());
- event.reply("Erfolgreich " + target.getUserName() + " entbannt").setEphemeral(true).queue();
- }
-}
diff --git a/src/de/steamwar/bungeecore/bot/commands/WhoisCommand.java b/src/de/steamwar/bungeecore/bot/commands/WhoisCommand.java
deleted file mode 100644
index d2533727..00000000
--- a/src/de/steamwar/bungeecore/bot/commands/WhoisCommand.java
+++ /dev/null
@@ -1,94 +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 .
- */
-
-package de.steamwar.bungeecore.bot.commands;
-
-import de.steamwar.sql.Punishment;
-import de.steamwar.sql.SteamwarUser;
-import de.steamwar.sql.Team;
-import net.dv8tion.jda.api.EmbedBuilder;
-import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
-import net.dv8tion.jda.api.interactions.commands.OptionType;
-
-import java.sql.Timestamp;
-import java.text.DecimalFormat;
-import java.util.List;
-
-public class WhoisCommand extends BasicDiscordCommand {
-
- public WhoisCommand() {
- super("whois", "Der whois Befehl");
-
- addOption(OptionType.STRING, "user", "Der Benutzer", true);
- }
-
- @Override
- public void run(SlashCommandEvent event) {
- if (!testPermission(event)) {
- return;
- }
-
- String s = event.getOption("user").getAsString();
-
- SteamwarUser user = SteamwarUser.get(s);
- if (user == null) {
- try {
- int id = Integer.parseInt(s);
- user = SteamwarUser.get(id);
- } catch (NumberFormatException ignored) {
- // Ignored
- }
- }
- if (user == null) {
- try {
- long id = Long.parseLong(s);
- user = SteamwarUser.get(id);
- } catch (NumberFormatException ignored) {
- // Ignored
- }
- }
-
- if (user == null) {
- event.reply("Der angegebene Spieler ist unbekannt").setEphemeral(true).complete();
- return;
- }
-
- EmbedBuilder embedBuilder = new EmbedBuilder();
- embedBuilder.setTitle("Whois: " + user.getUserName());
- StringBuilder st = new StringBuilder();
- st.append("UUID: ").append(user.getUUID()).append("\n");
- st.append("ID: ").append(user.getId()).append("\n");
- if (user.getDiscordId() != null) {
- st.append("DiscordID: ").append(user.getDiscordId()).append("\n");
- }
- Timestamp timestamp = user.getFirstjoin();
- st.append("Beigetreten am: ").append(timestamp == null ? "0000-00-00 00:00:00" : timestamp.toString()).append("\n");
- st.append("Online Time: ").append(new DecimalFormat("###.##").format(user.getOnlinetime() / (double) 3600)).append("h\n");
- Team team = Team.get(user.getTeam());
- st.append("Team: [").append(team.getTeamKuerzel()).append("] ").append(team.getTeamName());
- embedBuilder.addField("Daten:", st.toString(), false);
-
- List punishmentList = Punishment.getAllPunishmentsOfPlayer(user.getId());
- for (Punishment punishment : punishmentList) {
- embedBuilder.addField(punishment.getType().name() + " von " + SteamwarUser.get(punishment.getPunisher()).getUserName(), "Von: " + punishment.getBantime(punishment.getStartTime(), false) + "\nBis: " + punishment.getBantime(punishment.getEndTime(), punishment.isPerma()) + "\nGrund: " + punishment.getReason(), true);
- }
-
- event.replyEmbeds(embedBuilder.build()).setEphemeral(true).queue();
- }
-}
diff --git a/src/de/steamwar/bungeecore/bot/listeners/AnnouncementListener.java b/src/de/steamwar/bungeecore/bot/listeners/AnnouncementListener.java
deleted file mode 100644
index 5a72baeb..00000000
--- a/src/de/steamwar/bungeecore/bot/listeners/AnnouncementListener.java
+++ /dev/null
@@ -1,50 +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 .
- */
-
-package de.steamwar.bungeecore.bot.listeners;
-
-import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
-import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
-import de.steamwar.messages.Chatter;
-import net.dv8tion.jda.api.MessageBuilder;
-import net.dv8tion.jda.api.entities.TextChannel;
-import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
-import org.jetbrains.annotations.NotNull;
-
-public class AnnouncementListener extends BasicDiscordListener {
-
- @Override
- public void onGuildMessageReceived(@NotNull GuildMessageReceivedEvent event) {
- if (!event.getChannel().getId().equals(SteamwarDiscordBotConfig.ANNOUNCEMENTS_CHANNEL)) {
- return;
- }
- if (event.getAuthor().isBot()) {
- return;
- }
- Chatter.broadcast().system("ALERT", event.getMessage().getContentDisplay());
- }
-
- public void announce(String message) {
- TextChannel textChannel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.ANNOUNCEMENTS_CHANNEL);
- assert textChannel != null;
- MessageBuilder messageBuilder = new MessageBuilder();
- messageBuilder.append(message.replace("&", ""));
- textChannel.sendMessage(messageBuilder.build()).queue();
- }
-}
diff --git a/src/de/steamwar/bungeecore/bot/listeners/BasicDiscordListener.java b/src/de/steamwar/bungeecore/bot/listeners/BasicDiscordListener.java
deleted file mode 100644
index 1c8a5ffd..00000000
--- a/src/de/steamwar/bungeecore/bot/listeners/BasicDiscordListener.java
+++ /dev/null
@@ -1,30 +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 .
- */
-
-package de.steamwar.bungeecore.bot.listeners;
-
-import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
-import net.dv8tion.jda.api.hooks.ListenerAdapter;
-
-public abstract class BasicDiscordListener extends ListenerAdapter {
-
- BasicDiscordListener() {
- SteamwarDiscordBot.instance().addListener(this);
- }
-}
diff --git a/src/de/steamwar/bungeecore/bot/listeners/DiscordAuthListener.java b/src/de/steamwar/bungeecore/bot/listeners/DiscordAuthListener.java
deleted file mode 100644
index 947ed5e5..00000000
--- a/src/de/steamwar/bungeecore/bot/listeners/DiscordAuthListener.java
+++ /dev/null
@@ -1,59 +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 .
- */
-
-package de.steamwar.bungeecore.bot.listeners;
-
-import de.steamwar.bungeecore.bot.AuthManager;
-import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
-import de.steamwar.sql.SteamwarUser;
-import net.dv8tion.jda.api.entities.ChannelType;
-import net.dv8tion.jda.api.events.interaction.GenericComponentInteractionCreateEvent;
-import net.dv8tion.jda.api.interactions.InteractionType;
-import org.jetbrains.annotations.NotNull;
-
-public class DiscordAuthListener extends BasicDiscordListener {
-
- @Override
- public void onGenericComponentInteractionCreate(@NotNull GenericComponentInteractionCreateEvent event) {
- if(event.getType() == InteractionType.COMPONENT) {
- if(event.getChannel().getId().equals(SteamwarDiscordBotConfig.RULES_CHANNEL) && event.getComponentId().equals("auth")) {
- String authMessage = AuthManager.createDiscordAuthToken(event.getMember());
- if(authMessage != null) {
- event.reply("Gebe innerhalb der nächsten 10 Minuten ``/verify " + authMessage + "`` auf dem Minecraft Server ein").setEphemeral(true).queue();
- } else {
- event.reply("Du hast bereits einen Code am laufen").setEphemeral(true).queue();
- }
- }
-
- if(event.getComponentId().equals("tada") && event.getChannelType() == ChannelType.PRIVATE) {
- event.reply(":tada:").setEphemeral(false).queue();
- }
-
- if(event.getComponentId().equals("invalid") && event.getChannelType() == ChannelType.PRIVATE) {
- SteamwarUser user = SteamwarUser.get(event.getUser().getIdLong());
- if(user == null) {
- event.reply(":question: Da ist keine verknüpfung?").setEphemeral(false).queue();
- } else {
- user.setDiscordId(null);
- event.reply(":x: Die Verknüpfung wurde beendet").setEphemeral(false).queue();
- }
- }
- }
- }
-}
diff --git a/src/de/steamwar/bungeecore/bot/listeners/DiscordChatListener.java b/src/de/steamwar/bungeecore/bot/listeners/DiscordChatListener.java
deleted file mode 100644
index 1803d94b..00000000
--- a/src/de/steamwar/bungeecore/bot/listeners/DiscordChatListener.java
+++ /dev/null
@@ -1,71 +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 .
- */
-
-package de.steamwar.bungeecore.bot.listeners;
-
-import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
-import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
-import de.steamwar.bungeecore.listeners.ChatListener;
-import de.steamwar.messages.Chatter;
-import de.steamwar.messages.ChatterGroup;
-import de.steamwar.sql.Punishment;
-import de.steamwar.sql.SteamwarUser;
-import net.dv8tion.jda.api.MessageBuilder;
-import net.dv8tion.jda.api.entities.Member;
-import net.dv8tion.jda.api.entities.TextChannel;
-import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
-import org.jetbrains.annotations.NotNull;
-
-import java.util.function.Supplier;
-
-public class DiscordChatListener extends BasicDiscordListener {
-
- private final String channel;
- private final String format;
-
- private final Supplier targets;
-
- public DiscordChatListener(String channel, String format, Supplier targets) {
- this.channel = channel;
- this.format = format;
- this.targets = targets;
- }
-
- @Override
- public void onGuildMessageReceived(@NotNull GuildMessageReceivedEvent event) {
- if (!event.getChannel().getId().equals(channel) || event.getAuthor().isBot())
- return;
-
- Member member = event.getMember();
- SteamwarUser steamwarUser = SteamwarUser.get(member.getIdLong());
- if (steamwarUser == null || event.getMessage().getContentRaw().length() > 250 || steamwarUser.isPunished(Punishment.PunishmentType.Ban)) {
- event.getMessage().delete().queue();
- } else {
- ChatListener.sendChat(Chatter.of(event.getMessage(), steamwarUser), targets.get(), format, null, event.getMessage().getContentDisplay().replace('§', '&').replace('\n', ' '));
- }
- }
-
- public void send(String message) {
- TextChannel textChannel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(channel);
- assert textChannel != null;
- MessageBuilder messageBuilder = new MessageBuilder();
- messageBuilder.append(message.replace("&", "").replace("@everyone", "`@everyone`").replace("@here", "`@here`").replaceAll("<[@#]!?\\d+>", "`$0`"));
- textChannel.sendMessage(messageBuilder.build()).queue();
- }
-}
diff --git a/src/de/steamwar/bungeecore/bot/listeners/DiscordEventListener.java b/src/de/steamwar/bungeecore/bot/listeners/DiscordEventListener.java
deleted file mode 100644
index b21f427c..00000000
--- a/src/de/steamwar/bungeecore/bot/listeners/DiscordEventListener.java
+++ /dev/null
@@ -1,93 +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 .
- */
-
-package de.steamwar.bungeecore.bot.listeners;
-
-import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
-import de.steamwar.bungeecore.bot.events.EventManager;
-import de.steamwar.sql.SteamwarUser;
-import de.steamwar.sql.Team;
-import de.steamwar.sql.TeamTeilnahme;
-import de.steamwar.sql.Event;
-import net.dv8tion.jda.api.events.interaction.SelectionMenuEvent;
-import net.dv8tion.jda.api.interactions.components.Component;
-import org.jetbrains.annotations.NotNull;
-
-import java.time.Instant;
-
-public class DiscordEventListener extends BasicDiscordListener {
-
-
- @Override
- public void onSelectionMenu(@NotNull SelectionMenuEvent event) {
- if(event.getChannel().getId().equals(SteamwarDiscordBotConfig.EVENTS_CHANNEL) && event.getComponentType() == Component.Type.SELECTION_MENU) {
- if(event.getSelectedOptions().isEmpty()) {
- event.deferReply(true).queue();
- return;
- }
- if(event.getSelectedOptions().get(0).getValue().matches("([0-9]+)")) {
- SteamwarUser user = SteamwarUser.get(event.getUser().getIdLong());
- if(user == null) {
- event.reply("Du hast dein Minecraft nicht verknüpft").setEphemeral(true).queue();
- return;
- }
-
- if(user.getTeam() == 0) {
- event.reply("Du bist in keinem Team").setEphemeral(true).queue();
- return;
- }
-
- if(!user.isLeader()) {
- event.reply("Du bist kein Leader in deinem Team").setEphemeral(true).queue();
- return;
- }
-
- if(Event.get() != null) {
- event.reply("Du kannst dich nicht während einem Event an einem Event anmelden").setEphemeral(true).queue();
- return;
- }
-
- Event swEvent = Event.get(Integer.decode(event.getSelectedOptions().get(0).getValue()));
- if(swEvent == null){
- event.reply("Das Event gibt es nicht").setEphemeral(true).queue();
- return;
- }
-
- if(Instant.now().isAfter(swEvent.getDeadline().toInstant())){
- event.reply("Du kannst dich nicht mehr an diesen Event anmelden").setEphemeral(true).queue();
- return;
- }
-
- Team team = Team.get(user.getTeam());
-
- if(TeamTeilnahme.nimmtTeil(team.getTeamId(), swEvent.getEventID())){
- TeamTeilnahme.notTeilnehmen(team.getTeamId(), swEvent.getEventID());
- event.reply("Dein Team **" + team.getTeamName() + "** nimmt nun nicht mehr an **" + swEvent.getEventName() + "** teil!").setEphemeral(true).queue();
- }else{
- TeamTeilnahme.teilnehmen(team.getTeamId(), swEvent.getEventID());
- event.reply("Dein Team **" + team.getTeamName() + "** nimmt nun an **" + swEvent.getEventName() + "** teil!").setEphemeral(true).queue();
- }
-
- EventManager.update();
- } else {
- event.reply("Lefuq?").setEphemeral(true).queue();
- }
- }
- }
-}
diff --git a/src/de/steamwar/bungeecore/bot/listeners/DiscordTicketListener.java b/src/de/steamwar/bungeecore/bot/listeners/DiscordTicketListener.java
deleted file mode 100644
index c6bb73ca..00000000
--- a/src/de/steamwar/bungeecore/bot/listeners/DiscordTicketListener.java
+++ /dev/null
@@ -1,158 +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 .
- */
-
-package de.steamwar.bungeecore.bot.listeners;
-
-import de.steamwar.bungeecore.BungeeCore;
-import de.steamwar.bungeecore.Message;
-import de.steamwar.bungeecore.bot.config.DiscordTicketType;
-import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
-import de.steamwar.messages.Chatter;
-import de.steamwar.sql.SteamwarUser;
-import de.steamwar.sql.UserPerm;
-import net.dv8tion.jda.api.EmbedBuilder;
-import net.dv8tion.jda.api.MessageBuilder;
-import net.dv8tion.jda.api.Permission;
-import net.dv8tion.jda.api.entities.*;
-import net.dv8tion.jda.api.events.interaction.GenericComponentInteractionCreateEvent;
-import net.dv8tion.jda.api.events.message.guild.GuildMessageReceivedEvent;
-import net.dv8tion.jda.api.interactions.InteractionType;
-import net.dv8tion.jda.api.interactions.components.ActionRow;
-import net.dv8tion.jda.api.interactions.components.Button;
-import net.md_5.bungee.api.chat.ClickEvent;
-import org.jetbrains.annotations.NotNull;
-
-import java.awt.*;
-import java.time.Instant;
-import java.util.LinkedList;
-
-public class DiscordTicketListener extends BasicDiscordListener {
-
- @Override
- public void onGenericComponentInteractionCreate(@NotNull GenericComponentInteractionCreateEvent event) {
- if(event.getType() == InteractionType.COMPONENT && event.getChannelType() == ChannelType.TEXT && event.getTextChannel().getParent() != null && event.getTextChannel().getParent().getId().equals(SteamwarDiscordBotConfig.TICKET_CATEGORY)) {
- if(event.getTextChannel().getId().equals(SteamwarDiscordBotConfig.TICKET_CHANNEL) && SteamwarDiscordBotConfig.TICKET_TYPES.containsKey(event.getComponentId())) {
- DiscordTicketType ticketType = SteamwarDiscordBotConfig.TICKET_TYPES.get(event.getComponentId());
- Category ct = event.getGuild().getCategoryById(SteamwarDiscordBotConfig.TICKET_CATEGORY);
- SteamwarUser swUser = SteamwarUser.get(event.getUser().getIdLong());
- TextChannel ticketChannel = ct.createTextChannel((swUser == null?event.getUser().getName():swUser.getUserName()) + "-" + event.getComponentId() + "-" + System.currentTimeMillis() % 1000).complete();
- ticketChannel.createPermissionOverride(event.getMember()).setAllow(Permission.VIEW_CHANNEL,
- Permission.MESSAGE_WRITE,
- Permission.MESSAGE_ATTACH_FILES,
- Permission.MESSAGE_ADD_REACTION,
- Permission.MESSAGE_READ,
- Permission.MESSAGE_EMBED_LINKS,
- Permission.MESSAGE_HISTORY).complete();
- ticketChannel.getManager().setTopic(event.getUser().getId()).complete();
-
- MessageBuilder messageBuilder = new MessageBuilder();
- EmbedBuilder builder = new EmbedBuilder();
- builder.setDescription(ticketType.getPreMessage());
- builder.setTitle("Steamwar Ticket");
- builder.setColor(Color.GREEN);
-
- Button closeButton = Button.danger("close-" + ticketChannel.getName(), "Schließen").withEmoji(Emoji.fromUnicode("U+26A0"));
- messageBuilder.setEmbeds(builder.build());
- messageBuilder.setActionRows(ActionRow.of(closeButton));
-
- ticketChannel.sendMessage(messageBuilder.build()).complete();
- event.reply(SteamwarDiscordBotConfig.TICKET_CREATED.replace("%channel%", ticketChannel.getAsMention())).setEphemeral(true).complete();
- Chatter.serverteam().prefixless("DISCORD_TICKET_NEW", ticketChannel.getName());
- } else if(event.getComponentId().startsWith("close-")) {
- TextChannel logChannel = event.getGuild().getTextChannelById(SteamwarDiscordBotConfig.TICKET_LOG);
-
- LinkedList stringBuilders = new LinkedList<>();
- stringBuilders.add(new StringBuilder());
-
- new LinkedList<>(event.getTextChannel().getIterableHistory().complete()).descendingIterator().forEachRemaining(message -> {
- if(message.getAuthor().isSystem() || message.getAuthor().isBot()) return;
- StringBuilder currentBuilder = new StringBuilder();
- currentBuilder.append(" ")
- .append("**")
- .append(message.getAuthor().getName())
- .append("**: ")
- .append(message.getContentRaw());
- if(!message.getAttachments().isEmpty()) {
- currentBuilder.append("\n")
- .append("Files: ").append("\n");
- message.getAttachments().forEach(attachment -> currentBuilder.append(attachment.getUrl()).append("\n"));
- }
-
- currentBuilder.append("\n");
- if(currentBuilder.length() >= 4096) {
- stringBuilders.getLast().append(currentBuilder.substring(0, 4090));
- stringBuilders.add(new StringBuilder(currentBuilder.substring(4090, currentBuilder.length() - 1)));
- } else if (currentBuilder.length() + stringBuilders.getLast().length() >= 4096) {
- stringBuilders.add(new StringBuilder(currentBuilder.toString()));
- } else {
- stringBuilders.getLast().append(currentBuilder);
- }
- });
-
- String footer = " **" + event.getUser().getName() + "**: Ticket geschlossen";
- if(stringBuilders.getLast().length() + footer.length() > 4090) {
- stringBuilders.add(new StringBuilder(footer));
- } else {
- stringBuilders.getLast().append(footer);
- }
-
- EmbedBuilder embedBuilder = new EmbedBuilder();
- embedBuilder.setColor(Color.GREEN);
- User user = event.getJDA().retrieveUserById(event.getTextChannel().getTopic()).complete();
- SteamwarUser swuser = SteamwarUser.get(user.getIdLong());
-
- embedBuilder.setAuthor(user.getName(), swuser==null?"https://steamwar.de/":("https://steamwar.de/users/" + swuser.getUserName().toLowerCase() + "/"), user.getAvatarUrl());
- embedBuilder.setTimestamp(Instant.now());
- embedBuilder.setTitle(event.getTextChannel().getName());
- stringBuilders.forEach(stringBuilder -> {
- embedBuilder.setDescription(stringBuilder.toString());
- MessageBuilder builder = new MessageBuilder();
- builder.setEmbeds(embedBuilder.build());
-
- logChannel.sendMessage(builder.build()).queue();
- });
-
- Chatter.serverteam().prefixless("DISCORD_TICKET_CLOSED", event.getTextChannel().getName());
- event.getTextChannel().delete().reason("Closed").queue();
- }
- }
- }
-
- @Override
- public void onGuildMessageReceived(@NotNull GuildMessageReceivedEvent event) {
- if(event.getChannel().getParent() != null && event.getChannel().getParent().getId().equals(SteamwarDiscordBotConfig.TICKET_CATEGORY)) {
- if(!event.getChannel().getId().equals(SteamwarDiscordBotConfig.TICKET_CHANNEL) && !event.getChannel().getId().equals(SteamwarDiscordBotConfig.TICKET_LOG)) {
- BungeeCore.get().getProxy().getPlayers().forEach(player -> {
- if(event.getAuthor().isBot() || event.getAuthor().isSystem()) return;
- SteamwarUser user = SteamwarUser.get(player.getUniqueId());
- boolean sendMessage;
- if(user.getDiscordId() == null) {
- sendMessage = user.hasPerm(UserPerm.CHECK);
- } else {
- if(event.getAuthor().getId().equals(user.getDiscordId())) return;
- sendMessage = user.getDiscordId().equals(event.getChannel().getTopic()) || user.hasPerm(UserPerm.CHECK);
- }
- if(sendMessage) {
- Message.sendPrefixless("DISCORD_TICKET_MESSAGE", player, "Zur nachricht", new ClickEvent(ClickEvent.Action.OPEN_URL, event.getMessage().getJumpUrl()), event.getChannel().getName(), event.getAuthor().getName(), event.getMessage().getContentRaw());
- }
- });
- }
- }
- }
-}
diff --git a/src/de/steamwar/bungeecore/bot/listeners/PrivateMessageListener.java b/src/de/steamwar/bungeecore/bot/listeners/PrivateMessageListener.java
deleted file mode 100644
index 58800d0c..00000000
--- a/src/de/steamwar/bungeecore/bot/listeners/PrivateMessageListener.java
+++ /dev/null
@@ -1,80 +0,0 @@
-/*
- * This file is a part of the SteamWar software.
- *
- * Copyright (C) 2021 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.bungeecore.bot.listeners;
-
-import de.steamwar.bungeecore.BungeeCore;
-import de.steamwar.sql.NodeData;
-import de.steamwar.sql.Punishment;
-import de.steamwar.sql.SchematicNode;
-import de.steamwar.sql.SteamwarUser;
-import net.dv8tion.jda.api.entities.Message;
-import net.dv8tion.jda.api.events.message.priv.PrivateMessageReceivedEvent;
-
-import java.io.InputStream;
-
-public class PrivateMessageListener extends BasicDiscordListener {
-
- @Override
- public void onPrivateMessageReceived(PrivateMessageReceivedEvent event) {
- if(!event.getMessage().getAttachments().isEmpty()) {
- SteamwarUser user = SteamwarUser.get(event.getAuthor().getIdLong());
- if (user == null) {
- event.getMessage().reply("Du must dein Minecraft Account mit dem Bot verbinden, gehe dazu auf dem SteamWar Discord in den `regeln-infos` Channel und Klicke auf `Minecraft Verknüpfen`").complete();
- return;
- }
-
- if(user.isPunished(Punishment.PunishmentType.NoSchemReceiving)) {
- event.getMessage().reply("Du darfst keine Schematics hochladen").complete();
- return;
- }
-
- for (Message.Attachment attachment : event.getMessage().getAttachments()) {
- if(attachment.getFileExtension() == null ||
- (!attachment.getFileExtension().equalsIgnoreCase("schem") &&
- !attachment.getFileExtension().equalsIgnoreCase("schematic"))) {
- event.getMessage().reply("`" + attachment.getFileName() + "` wird ignoriert, da die Datei keine Schematic ist").queue();
- continue;
- }
-
- boolean newFormat = attachment.getFileExtension().equalsIgnoreCase("schem");
- int dot = attachment.getFileName().lastIndexOf(".");
- String name = attachment.getFileName().substring(0, dot);
- if(SchematicNode.invalidSchemName(new String[] {name})) {
- event.getMessage().reply("`" + name + "` hat nicht zugelassene Zeichen im Namen").queue();
- continue;
- }
-
- SchematicNode node = SchematicNode.getSchematicNode(user.getId(), name, (Integer) null);
- if(node == null) {
- node = SchematicNode.createSchematic(user.getId(), name, null);
- }
-
- try {
- InputStream in = attachment.retrieveInputStream().get();
- NodeData.get(node).saveFromStream(in, newFormat);
- in.close();
- event.getMessage().reply("`" + name + "` wurde erfolgreich hochgeladen").queue();
- } catch (Exception e) {
- event.getMessage().reply("`" + name + "` konnte nicht hochgeladen werden, bitte versuche es später nochmal oder wende dich an einen Developer").queue();
- BungeeCore.log("Could not Upload Schem \"" + name + "\" from User \"" + user.getUserName() + "\"", e);
- }
- }
- }
- }
-}
diff --git a/src/de/steamwar/bungeecore/bot/listeners/RolesInteractionButtonListener.java b/src/de/steamwar/bungeecore/bot/listeners/RolesInteractionButtonListener.java
deleted file mode 100644
index ae0e44de..00000000
--- a/src/de/steamwar/bungeecore/bot/listeners/RolesInteractionButtonListener.java
+++ /dev/null
@@ -1,42 +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 .
- */
-
-package de.steamwar.bungeecore.bot.listeners;
-
-import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
-import net.dv8tion.jda.api.entities.ChannelType;
-import net.dv8tion.jda.api.events.interaction.GenericComponentInteractionCreateEvent;
-import net.dv8tion.jda.api.interactions.InteractionType;
-import org.jetbrains.annotations.NotNull;
-
-public class RolesInteractionButtonListener extends BasicDiscordListener {
-
- @Override
- public void onGenericComponentInteractionCreate(@NotNull GenericComponentInteractionCreateEvent event) {
- if(event.getType() == InteractionType.COMPONENT && event.getChannelType() == ChannelType.TEXT && event.getTextChannel().getId().equals(SteamwarDiscordBotConfig.ROLES_CHANNEL) && SteamwarDiscordBotConfig.ROLES.stream().anyMatch(discordRole -> discordRole.getRoleId().equals(event.getComponentId()))) {
- if (event.getMember().getRoles().stream().anyMatch(role -> role.getId().equals(event.getComponentId()))) {
- event.getGuild().removeRoleFromMember(event.getMember(), event.getGuild().getRoleById(event.getComponentId())).complete();
- event.reply(SteamwarDiscordBotConfig.ROLES_REMOVED.replace("%role%", event.getGuild().getRoleById(event.getComponentId()).getAsMention())).setEphemeral(true).queue();
- } else {
- event.getGuild().addRoleToMember(event.getMember(), event.getGuild().getRoleById(event.getComponentId())).complete();
- event.reply(SteamwarDiscordBotConfig.ROLES_ADDED.replace("%role%", event.getGuild().getRoleById(event.getComponentId()).getAsMention())).setEphemeral(true).queue();
- }
- }
- }
-}
diff --git a/src/de/steamwar/bungeecore/bot/listeners/SlashCommandListener.java b/src/de/steamwar/bungeecore/bot/listeners/SlashCommandListener.java
deleted file mode 100644
index 565ca442..00000000
--- a/src/de/steamwar/bungeecore/bot/listeners/SlashCommandListener.java
+++ /dev/null
@@ -1,32 +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 .
- */
-
-package de.steamwar.bungeecore.bot.listeners;
-
-import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
-import net.dv8tion.jda.api.events.interaction.SlashCommandEvent;
-import org.jetbrains.annotations.NotNull;
-
-public class SlashCommandListener extends BasicDiscordListener {
-
- @Override
- public void onSlashCommand(@NotNull SlashCommandEvent event) {
- SteamwarDiscordBot.getDiscordCommandMap().get(event.getName()).run(event);
- }
-}
diff --git a/src/de/steamwar/bungeecore/bot/util/DiscordRanks.java b/src/de/steamwar/bungeecore/bot/util/DiscordRanks.java
deleted file mode 100644
index f62dea0f..00000000
--- a/src/de/steamwar/bungeecore/bot/util/DiscordRanks.java
+++ /dev/null
@@ -1,69 +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 .
- */
-
-package de.steamwar.bungeecore.bot.util;
-
-import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
-import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
-import de.steamwar.sql.SteamwarUser;
-import lombok.experimental.UtilityClass;
-import net.dv8tion.jda.api.entities.Guild;
-import net.dv8tion.jda.api.entities.Role;
-import net.dv8tion.jda.api.exceptions.ErrorResponseException;
-
-import java.util.HashSet;
-import java.util.List;
-import java.util.Set;
-
-@UtilityClass
-public class DiscordRanks {
-
- public void update(SteamwarUser steamwarUser) {
- if (steamwarUser.getDiscordId() == null) {
- return;
- }
- Guild guild = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD);
- guild.retrieveMemberById(steamwarUser.getDiscordId()).queue(member -> {
- List roleList = member.getRoles();
- Set strings = new HashSet<>(SteamwarDiscordBotConfig.RANKS.values());
- String needed = SteamwarDiscordBotConfig.RANKS.get(steamwarUser.prefix());
- for (Role role : roleList) {
- if (!strings.contains(role.getId())) {
- continue;
- }
- if (role.getId().equals(needed)) {
- needed = "";
- continue;
- }
- guild.removeRoleFromMember(member, role).complete();
- }
-
- if (needed != null && !needed.isEmpty()) {
- guild.addRoleToMember(member, guild.getRoleById(needed)).complete();
- }
- }, throwable -> {
- if(throwable instanceof ErrorResponseException) {
- ErrorResponseException e = (ErrorResponseException) throwable;
- if(e.getErrorCode() == 10007) {
- steamwarUser.setDiscordId(null);
- }
- }
- });
- }
-}
diff --git a/src/de/steamwar/bungeecore/bot/util/DiscordRolesMessage.java b/src/de/steamwar/bungeecore/bot/util/DiscordRolesMessage.java
deleted file mode 100644
index 1486debd..00000000
--- a/src/de/steamwar/bungeecore/bot/util/DiscordRolesMessage.java
+++ /dev/null
@@ -1,61 +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 .
- */
-
-package de.steamwar.bungeecore.bot.util;
-
-import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
-import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
-import lombok.experimental.UtilityClass;
-import net.dv8tion.jda.api.MessageBuilder;
-import net.dv8tion.jda.api.entities.Message;
-import net.dv8tion.jda.api.entities.TextChannel;
-import net.dv8tion.jda.api.interactions.components.ActionRow;
-import net.dv8tion.jda.api.interactions.components.Button;
-
-import java.util.ArrayList;
-import java.util.List;
-
-@UtilityClass
-public class DiscordRolesMessage {
-
-
- public void sendMessage() {
- TextChannel channel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.ROLES_CHANNEL);
- assert channel != null;
-
- MessageBuilder builder = new MessageBuilder();
- builder.setContent(SteamwarDiscordBotConfig.ROLES_BASE_MESSAGE);
- List