geforkt von SteamWar/BungeeCore
Encapsulate DiscordBot errors
Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Ursprung
f9b42ad0c1
Commit
c3c666c305
@ -157,7 +157,11 @@ public class BungeeCore extends Plugin {
|
||||
}, 1, 1, TimeUnit.HOURS);
|
||||
|
||||
if (SteamwarDiscordBotConfig.loaded) {
|
||||
try {
|
||||
new SteamwarDiscordBot();
|
||||
} catch (Exception e) {
|
||||
getLogger().log(Level.SEVERE, "Could not initialize discord bot", e);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@ -168,6 +172,8 @@ public class BungeeCore extends Plugin {
|
||||
SteamwarDiscordBot.instance().getJda().awaitStatus(JDA.Status.SHUTDOWN);
|
||||
} catch (InterruptedException e) {
|
||||
Thread.currentThread().interrupt();
|
||||
} catch (Exception e) {
|
||||
getLogger().log(Level.SEVERE, "Could not shutdown discord bot", e);
|
||||
}
|
||||
|
||||
errorLogger.unregister();
|
||||
|
@ -44,6 +44,7 @@ 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 {
|
||||
|
||||
@ -84,7 +85,11 @@ public class SteamwarDiscordBot {
|
||||
} 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(), () -> {
|
||||
|
@ -19,6 +19,7 @@
|
||||
|
||||
package de.steamwar.bungeecore.commands;
|
||||
|
||||
import de.steamwar.bungeecore.BungeeCore;
|
||||
import de.steamwar.bungeecore.Message;
|
||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||
import de.steamwar.bungeecore.listeners.ChatListener;
|
||||
@ -28,6 +29,8 @@ import net.md_5.bungee.api.CommandSender;
|
||||
import net.md_5.bungee.api.ProxyServer;
|
||||
import net.md_5.bungee.api.connection.ProxiedPlayer;
|
||||
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class ServerTeamchatCommand extends BasicCommand {
|
||||
|
||||
public ServerTeamchatCommand() {
|
||||
@ -51,7 +54,11 @@ public class ServerTeamchatCommand extends BasicCommand {
|
||||
String msg = msgBuilder.toString();
|
||||
msg = ChatColor.translateAlternateColorCodes('&', msg);
|
||||
|
||||
try {
|
||||
SteamwarDiscordBot.instance().getServerTeamChatListener().send("<t:" + (System.currentTimeMillis() / 1000) + "> " + (player.getName() + "» " + msg).replaceAll("§[a-f0-9r]", ""));
|
||||
} catch (Exception e) {
|
||||
BungeeCore.get().getLogger().log(Level.SEVERE, "Could not send stc message to discord", e);
|
||||
}
|
||||
sendToTeam(msg, player);
|
||||
}
|
||||
}
|
||||
|
@ -37,6 +37,7 @@ import net.md_5.bungee.event.EventHandler;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
import java.util.logging.Level;
|
||||
|
||||
public class ChatListener extends BasicListener {
|
||||
|
||||
@ -203,7 +204,11 @@ public class ChatListener extends BasicListener {
|
||||
msg = "§" + team.getTeamColor() + team.getTeamKuerzel() + " §r" + msg;
|
||||
}
|
||||
|
||||
try {
|
||||
SteamwarDiscordBot.instance().getIngameChatListener().send("<t:" + (System.currentTimeMillis() / 1000) + "> " + msg.replaceAll("§[a-f0-9r]", ""));
|
||||
} catch (Exception e) {
|
||||
BungeeCore.get().getLogger().log(Level.SEVERE, "Could not send chat message to discord", e);
|
||||
}
|
||||
for(ProxiedPlayer target : ProxyServer.getInstance().getPlayers()){
|
||||
Subserver targetServer = Subserver.getSubserver(target);
|
||||
if(!(targetServer == null || targetServer.getType() != Servertype.ARENA || targetServer.getServer() != target.getServer().getInfo())) continue;
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren