SteamWar/BungeeCore
Archiviert
13
2

Fix CheckCommand schematic deleted
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: Lixfel <agga-games@gmx.de>
Dieser Commit ist enthalten in:
Lixfel 2023-02-17 11:54:20 +01:00
Ursprung 6e2546a596
Commit 27c241f2d4
2 geänderte Dateien mit 38 neuen und 28 gelöschten Zeilen

@ -1 +1 @@
Subproject commit 69024c3bb9a432b71d94d28e7f5485e69d976b3f Subproject commit 89b0c14da664589a7c9699d73bf72028cdf9dd0d

Datei anzeigen

@ -28,7 +28,6 @@ import de.steamwar.bungeecore.sql.SchematicType;
import de.steamwar.bungeecore.sql.SteamwarUser; import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.command.SWCommand; import de.steamwar.command.SWCommand;
import net.md_5.bungee.api.ChatColor; import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer; import net.md_5.bungee.api.ProxyServer;
import net.md_5.bungee.api.chat.ClickEvent; import net.md_5.bungee.api.chat.ClickEvent;
import net.md_5.bungee.api.chat.TextComponent; import net.md_5.bungee.api.chat.TextComponent;
@ -37,7 +36,6 @@ import net.md_5.bungee.config.Configuration;
import java.sql.Timestamp; import java.sql.Timestamp;
import java.time.Instant; import java.time.Instant;
import java.time.format.DateTimeFormatter;
import java.util.*; import java.util.*;
import java.util.concurrent.TimeUnit; import java.util.concurrent.TimeUnit;
import java.util.logging.Level; import java.util.logging.Level;
@ -265,43 +263,47 @@ public class CheckCommand extends SWCommand {
} }
private void accept(int rank){ private void accept(int rank){
if(ranks.containsKey(schematic.getSchemtype())){ if(createLog("freigegeben")) {
if(rank <= 0 || ranks.get(schematic.getSchemtype()).size() < rank){ if(ranks.containsKey(schematic.getSchemtype())){
Message.send("CHECK_INVALID_RANK", checker); if(rank <= 0 || ranks.get(schematic.getSchemtype()).size() < rank){
return; Message.send("CHECK_INVALID_RANK", checker);
return;
}
schematic.setRank(rank);
} }
schematic.setRank(rank);
schematic.setType(schematic.getSchemtype().fightType().toDB());
SteamwarUser user = SteamwarUser.get(schematic.getOwner());
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(user.getUuid());
if(player != null) {
Message.send("CHECK_ACCEPTED", player, schematic.getSchemtype().name(), schematic.getName());
} else {
DiscordSchemAlert.sendAccept(schematic, user);
}
Message.team("CHECK_ACCEPTED_TEAM", schematic.getName(), user.getUserName());
} }
schematic.setType(schematic.getSchemtype().fightType().toDB());
CheckedSchematic.create(schematic, SteamwarUser.get(checker.getUniqueId()).getId(), startTime, Timestamp.from(Instant.now()), "freigegeben");
SteamwarUser user = SteamwarUser.get(schematic.getOwner());
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(user.getUuid());
if(player != null) {
Message.send("CHECK_ACCEPTED", player, schematic.getSchemtype().name(), schematic.getName());
} else {
DiscordSchemAlert.sendAccept(schematic, user);
}
Message.team("CHECK_ACCEPTED_TEAM", schematic.getName(), user.getUserName());
stop(); stop();
} }
private void decline(String reason){ private void decline(String reason){
CheckedSchematic.create(schematic, SteamwarUser.get(checker.getUniqueId()).getId(), startTime, Timestamp.from(Instant.now()), reason); if(createLog(reason)) {
SteamwarUser user = SteamwarUser.get(schematic.getOwner()); SteamwarUser user = SteamwarUser.get(schematic.getOwner());
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(user.getUuid()); ProxiedPlayer player = ProxyServer.getInstance().getPlayer(user.getUuid());
if(player != null) { if(player != null) {
Message.send("CHECK_DECLINED", player, schematic.getSchemtype().name(), schematic.getName(), reason); Message.send("CHECK_DECLINED", player, schematic.getSchemtype().name(), schematic.getName(), reason);
} else { } else {
DiscordSchemAlert.sendDecline(schematic, user, reason); DiscordSchemAlert.sendDecline(schematic, user, reason);
}
Message.team("CHECK_DECLINED_TEAM", schematic.getName(), user.getUserName(), reason);
schematic.setType(SchematicType.Normal.toDB());
} }
Message.team("CHECK_DECLINED_TEAM", schematic.getName(), user.getUserName(), reason);
schematic.setType(SchematicType.Normal.toDB());
stop(); stop();
} }
private void abort(){ private void abort(){
CheckedSchematic.create(schematic, SteamwarUser.get(checker.getUniqueId()).getId(), startTime, Timestamp.from(Instant.now()), "Prüfvorgang abgebrochen"); createLog("Prüfvorgang abgebrochen");
stop(); stop();
} }
@ -322,5 +324,13 @@ public class CheckCommand extends SWCommand {
currentCheckers.remove(checker.getUniqueId()); currentCheckers.remove(checker.getUniqueId());
currentSchems.remove(schematic.getId()); currentSchems.remove(schematic.getId());
} }
private boolean createLog(String reason) {
if(SchematicNode.getSchematicNode(schematic.getId()) == null) // Schematic was deleted
return false;
CheckedSchematic.create(schematic, SteamwarUser.get(checker.getUniqueId()).getId(), startTime, Timestamp.from(Instant.now()), reason);
return true;
}
} }
} }