Add SchematicsManager
Fix '1 Spielern' to '1 Spieler'
Dieser Commit ist enthalten in:
Ursprung
54499a7c3e
Commit
1a8e8690ac
@ -158,8 +158,8 @@ public class BungeeCore extends Plugin {
|
||||
public void onDisable(){
|
||||
ErrorLogger.stop();
|
||||
SQL.close();
|
||||
SteamwarDiscordBot.instance().getJda().shutdownNow();
|
||||
try {
|
||||
SteamwarDiscordBot.instance().getJda().shutdownNow();
|
||||
SteamwarDiscordBot.instance().getJda().awaitStatus(JDA.Status.SHUTDOWN);
|
||||
} catch (Exception e) {
|
||||
// Ignored
|
||||
|
@ -24,6 +24,7 @@ import de.steamwar.bungeecore.bot.commands.BanCommand;
|
||||
import de.steamwar.bungeecore.bot.commands.MuteCommand;
|
||||
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;
|
||||
@ -79,9 +80,11 @@ public class SteamwarDiscordBot {
|
||||
}
|
||||
activity();
|
||||
EventManager.update();
|
||||
SchematicsManager.update();
|
||||
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
|
||||
activity();
|
||||
EventManager.update();
|
||||
SchematicsManager.update();
|
||||
}, 30, 30, TimeUnit.SECONDS);
|
||||
DiscordRolesMessage.sendMessage();
|
||||
DiscordRulesMessage.sendMessage();
|
||||
@ -113,7 +116,12 @@ public class SteamwarDiscordBot {
|
||||
}
|
||||
break;
|
||||
case 1:
|
||||
jda.getPresence().setActivity(Activity.playing("mit " + BungeeCore.get().getProxy().getOnlineCount() + " Spielern"));
|
||||
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;
|
||||
}
|
||||
|
@ -35,6 +35,7 @@ public class SteamwarDiscordBotConfig {
|
||||
public static String EVENTS_CHANNEL;
|
||||
public static String INGAME_CHANNEL;
|
||||
public static String SERVER_TEAM_CHANNEL;
|
||||
public static String SCHEMATICS_CHANNEL;
|
||||
public static String ROLES_CHANNEL;
|
||||
public static String ROLES_BASE_MESSAGE;
|
||||
public static String ROLES_ADDED;
|
||||
@ -59,6 +60,7 @@ public class SteamwarDiscordBotConfig {
|
||||
EVENTS_CHANNEL = config.getString("events-channel");
|
||||
INGAME_CHANNEL = config.getString("ingame-channel");
|
||||
SERVER_TEAM_CHANNEL = config.getString("server-team-channel");
|
||||
SCHEMATICS_CHANNEL = config.getString("schematics-channel");
|
||||
Configuration rolesSection = config.getSection("roles-claim");
|
||||
ROLES_CHANNEL = rolesSection.getString("channel");
|
||||
ROLES_BASE_MESSAGE = rolesSection.getString("base");
|
||||
|
73
src/de/steamwar/bungeecore/bot/events/SchematicsManager.java
Normale Datei
73
src/de/steamwar/bungeecore/bot/events/SchematicsManager.java
Normale Datei
@ -0,0 +1,73 @@
|
||||
/*
|
||||
* 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 <https://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
package de.steamwar.bungeecore.bot.events;
|
||||
|
||||
import de.steamwar.bungeecore.bot.SteamwarDiscordBot;
|
||||
import de.steamwar.bungeecore.bot.config.SteamwarDiscordBotConfig;
|
||||
import de.steamwar.bungeecore.commands.CheckCommand;
|
||||
import de.steamwar.bungeecore.sql.SteamwarUser;
|
||||
import lombok.experimental.UtilityClass;
|
||||
import net.dv8tion.jda.api.EmbedBuilder;
|
||||
import net.dv8tion.jda.api.MessageBuilder;
|
||||
import net.dv8tion.jda.api.entities.Message;
|
||||
import net.dv8tion.jda.api.entities.TextChannel;
|
||||
|
||||
import java.awt.*;
|
||||
|
||||
@UtilityClass
|
||||
public class SchematicsManager {
|
||||
|
||||
private Message message;
|
||||
private TextChannel textChannel;
|
||||
|
||||
static {
|
||||
textChannel = SteamwarDiscordBot.instance().getJda().getGuildById(SteamwarDiscordBotConfig.GUILD).getTextChannelById(SteamwarDiscordBotConfig.SCHEMATICS_CHANNEL);
|
||||
assert textChannel != null;
|
||||
if(textChannel.hasLatestMessage()) {
|
||||
message = textChannel.getIterableHistory().complete().stream().filter(m -> m.getAuthor().isBot()).findFirst().orElse(null);
|
||||
}
|
||||
}
|
||||
|
||||
public void update() {
|
||||
EmbedBuilder embedBuilder = new EmbedBuilder();
|
||||
embedBuilder.setColor(Color.GRAY);
|
||||
embedBuilder.setTitle("Check List");
|
||||
embedBuilder.setAuthor("SteamWar", "https://www.steamwar.de");
|
||||
|
||||
CheckCommand.getSchemsToCheck().forEach(schematic -> {
|
||||
StringBuilder st = new StringBuilder();
|
||||
st.append("Typ: ").append(schematic.getSchemType().getKuerzel());
|
||||
st.append("\nVon: ").append(SteamwarUser.get(schematic.getSchemOwner()).getUserName());
|
||||
String checker = CheckCommand.getChecker(schematic);
|
||||
if (checker != null) {
|
||||
st.append("\nGeprüft durch: ").append(checker);
|
||||
}
|
||||
embedBuilder.addField(schematic.getSchemName(), st.toString(), true);
|
||||
});
|
||||
|
||||
MessageBuilder messageBuilder = new MessageBuilder();
|
||||
messageBuilder.setEmbeds(embedBuilder.build());
|
||||
if (message == null) {
|
||||
message = textChannel.sendMessage(messageBuilder.build()).complete();
|
||||
} else {
|
||||
message.editMessage(messageBuilder.build()).complete();
|
||||
}
|
||||
}
|
||||
}
|
@ -111,7 +111,7 @@ public class CheckCommand extends BasicCommand {
|
||||
}
|
||||
}
|
||||
|
||||
private static List<Schematic> getSchemsToCheck(){
|
||||
public static List<Schematic> getSchemsToCheck(){
|
||||
List<Schematic> schematicList = new LinkedList<>();
|
||||
|
||||
for (SchematicType type : SchematicType.values()) {
|
||||
@ -121,6 +121,11 @@ public class CheckCommand extends BasicCommand {
|
||||
return schematicList;
|
||||
}
|
||||
|
||||
public static String getChecker(Schematic schematic) {
|
||||
if (currentSchems.get(schematic.getSchemID()) == null) return null;
|
||||
return currentSchems.get(schematic.getSchemID()).checker.getName();
|
||||
}
|
||||
|
||||
private void list(ProxiedPlayer player) {
|
||||
List<Schematic> schematicList = getSchemsToCheck();
|
||||
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren