SteamWar/BungeeCore
Archiviert
13
2

Update CheckCommand
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed

Dieser Commit ist enthalten in:
yoyosource 2022-06-14 21:20:45 +02:00
Ursprung 8823368f0d
Commit d94080a0cb

Datei anzeigen

@ -26,6 +26,7 @@ import de.steamwar.bungeecore.sql.CheckedSchematic;
import de.steamwar.bungeecore.sql.SchematicNode;
import de.steamwar.bungeecore.sql.SchematicType;
import de.steamwar.bungeecore.sql.SteamwarUser;
import de.steamwar.command.SWCommand;
import net.md_5.bungee.api.ChatColor;
import net.md_5.bungee.api.CommandSender;
import net.md_5.bungee.api.ProxyServer;
@ -41,7 +42,7 @@ import java.util.*;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level;
public class CheckCommand extends BasicCommand {
public class CheckCommand extends SWCommand {
private static Map<SchematicType, List<String>> checkQuestions = new HashMap<>();
private static Map<SchematicType, List<String>> ranks = new HashMap<>();
@ -77,55 +78,8 @@ public class CheckCommand extends BasicCommand {
Message.send("CHECK_REMINDER", player, Message.parse("CHECK_REMINDER_HOVER", player), new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check list"), schematics.size() - currentCheckers.size());
}
@Override
public void execute(CommandSender sender, String[] args) {
if(!(sender instanceof ProxiedPlayer))
return;
ProxiedPlayer player = (ProxiedPlayer) sender;
if(args.length == 0){
help(sender);
return;
}
switch(args[0].toLowerCase()){
case "list":
list(player);
break;
case "schematic":
schematic(player, args[1]);
break;
case "next":
case "accept":
next(player, args);
break;
case "cancel":
abort(player);
break;
case "decline":
decline(player, args);
break;
default:
help(player);
}
}
public static List<SchematicNode> getSchemsToCheck(){
List<SchematicNode> schematicList = new LinkedList<>();
for (SchematicType type : SchematicType.values()) {
if (type.check())
schematicList.addAll(SchematicNode.getAllSchematicsOfType(type.toDB()));
}
return schematicList;
}
public static String getChecker(SchematicNode schematic) {
if (currentSchems.get(schematic.getId()) == null) return null;
return currentSchems.get(schematic.getId()).checker.getName();
}
private void list(ProxiedPlayer player) {
@Register(value = "list", description = "CHECK_HELP_LIST")
public void list(ProxiedPlayer player) {
List<SchematicNode> schematicList = getSchemsToCheck();
Message.sendPrefixless("CHECK_LIST_HEADER", player, schematicList.size());
@ -153,7 +107,8 @@ public class CheckCommand extends BasicCommand {
}
}
private void schematic(ProxiedPlayer player, String schemID){
@Register(value = "schematic", noTabComplete = true)
public void schematic(ProxiedPlayer player, String schemID) {
if(isChecking(player)){
Message.send("CHECK_SCHEMATIC_ALREADY_CHECKING", player);
return;
@ -171,6 +126,57 @@ public class CheckCommand extends BasicCommand {
new CheckSession(player, schem);
}
@Register(value = "cancel", description = "CHECK_HELP_CANCEL")
@Register("abort")
public void abortCommand(ProxiedPlayer player) {
abort(player);
}
public static void abort(ProxiedPlayer player) {
if(notChecking(player))
return;
Message.send("CHECK_ABORT", player);
currentCheckers.get(player.getUniqueId()).abort();
}
@Register(value = "next", description = "CHECK_HELP_NEXT")
public void next(ProxiedPlayer player) {
next(player, new String[0]);
}
@Register(value = "accept")
public void accept(ProxiedPlayer player, @OptionalValue("") String rank) {
if (rank.equals("")) {
next(player, new String[0]);
} else {
next(player, new String[]{rank});
}
}
@Register(value = "decline", description = "CHECK_HELP_DECLINE")
public void decline(ProxiedPlayer player, String... message) {
if(notChecking(player))
return;
currentCheckers.get(player.getUniqueId()).decline(String.join(" ", message));
}
public static List<SchematicNode> getSchemsToCheck(){
List<SchematicNode> schematicList = new LinkedList<>();
for (SchematicType type : SchematicType.values()) {
if (type.check())
schematicList.addAll(SchematicNode.getAllSchematicsOfType(type.toDB()));
}
return schematicList;
}
public static String getChecker(SchematicNode schematic) {
if (currentSchems.get(schematic.getId()) == null) return null;
return currentSchems.get(schematic.getId()).checker.getName();
}
private static boolean notChecking(ProxiedPlayer player){
if(!isChecking(player)){
Message.send("CHECK_NOT_CHECKING", player);
@ -184,9 +190,9 @@ public class CheckCommand extends BasicCommand {
return;
int rank = 0;
if(args.length > 1){
if(args.length > 0){
try{
rank = Integer.parseInt(args[1]);
rank = Integer.parseInt(args[0]);
}catch(NumberFormatException e){
Message.send("CHECK_INVALID_RANK", player);
return;
@ -196,37 +202,6 @@ public class CheckCommand extends BasicCommand {
currentCheckers.get(player.getUniqueId()).next(rank);
}
public static void abort(ProxiedPlayer player){
if(notChecking(player))
return;
Message.send("CHECK_ABORT", player);
currentCheckers.get(player.getUniqueId()).abort();
}
private void decline(ProxiedPlayer player, String[] args){
if(notChecking(player))
return;
if(args.length < 2) {
help(player);
return;
}
StringBuilder message = new StringBuilder();
for (int i = 1; i < args.length; i++)
message.append(args[i]).append(" ");
currentCheckers.get(player.getUniqueId()).decline(message.toString());
}
private void help(CommandSender sender){
Message.sendPrefixless("CHECK_HELP_LIST", sender);
Message.sendPrefixless("CHECK_HELP_NEXT", sender);
Message.sendPrefixless("CHECK_HELP_DECLINE", sender);
Message.sendPrefixless("CHECK_HELP_CANCEL", sender);
}
private static class CheckSession{
private final ProxiedPlayer checker;
private final SchematicNode schematic;