SteamWar/BungeeCore
Archiviert
13
2

Add Discord Bot Upload #277

Zusammengeführt
Lixfel hat 10 Commits von bot_upload nach master 2022-03-10 11:43:38 +01:00 zusammengeführt
6 geänderte Dateien mit 24 neuen und 16 gelöschten Zeilen
Nur Änderungen aus Commit 5249b0aee6 werden angezeigt - Alle Commits anzeigen

Datei anzeigen

@ -172,10 +172,12 @@ public class BungeeCore extends Plugin {
@Override
public void onDisable(){
try {
SteamwarDiscordBot.instance().getJda().shutdown();
} catch (Throwable e) {
getLogger().log(Level.SEVERE, "Could not shutdown discord bot", e);
if (SteamwarDiscordBotConfig.loaded) {
try {
SteamwarDiscordBot.instance().getJda().shutdown();
} catch (Throwable e) {
getLogger().log(Level.SEVERE, "Could not shutdown discord bot", e);
}
}
errorLogger.unregister();
@ -278,7 +280,7 @@ public class BungeeCore extends Plugin {
config.getString("db.password")
);
if (config.getSection("discord") != null) {
if (config.contains("discord")) {
SteamwarDiscordBotConfig.loadConfig(config.getSection("discord"));
}

Datei anzeigen

@ -51,7 +51,7 @@ public class AlertCommand extends BasicCommand {
}
Message.broadcast("ALERT", ChatColor.translateAlternateColorCodes('&', s));
if (discordAnnounce) {
if (discordAnnounce && SteamwarDiscordBot.instance() != null) {
SteamwarDiscordBot.instance().getAnnouncementListener().announce(s);
}
}

Datei anzeigen

@ -54,10 +54,12 @@ 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);
if (SteamwarDiscordBot.instance() != null) {
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);
}

Datei anzeigen

@ -212,10 +212,12 @@ 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);
if (SteamwarDiscordBot.instance() != null) {
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);

Datei anzeigen

@ -23,6 +23,7 @@ import de.steamwar.bungeecore.BungeeCore;
import de.steamwar.bungeecore.Message;
import de.steamwar.bungeecore.Servertype;
import de.steamwar.bungeecore.Subserver;
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
import de.steamwar.bungeecore.bot.util.DiscordRanks;
import de.steamwar.bungeecore.commands.ChallengeCommand;
import de.steamwar.bungeecore.commands.CheckCommand;
@ -96,7 +97,8 @@ public class ConnectionListener extends BasicListener {
newPlayers.remove(player.getUniqueId());
}
DiscordRanks.update(user);
if(SteamwarDiscordBotConfig.loaded)
DiscordRanks.update(user);
}
/** To redirect players to the lobby in case of server closure. */

Datei anzeigen

@ -61,7 +61,7 @@ public class Forge extends BasicListener {
@EventHandler
public void onServerConnected(LoginEvent event){
if(event.getConnection().getVersion() < 340) return; //1.13+
if(event.getConnection().getVersion() < 341) return; //1.13+
//fml:handshake without mods, channels and registries
//for more information see https://wiki.vg/Minecraft_Forge_Handshake#FML2_protocol_.281.13_-_Current.29