|
|
|
@ -22,6 +22,7 @@ import java.util.logging.Level;
|
|
|
|
|
|
|
|
|
|
public class CheckCommand extends BasicCommand {
|
|
|
|
|
private static Map<SchematicType, List<String>> checkQuestions = new HashMap<>();
|
|
|
|
|
private static Map<SchematicType, List<String>> ranks = new HashMap<>();
|
|
|
|
|
|
|
|
|
|
private static Map<ProxiedPlayer, CheckSession> currentCheckers = new HashMap<>();
|
|
|
|
|
private static Map<Integer, CheckSession> currentSchems = new HashMap<>();
|
|
|
|
@ -32,6 +33,12 @@ public class CheckCommand extends BasicCommand {
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void loadRanks(Configuration config){
|
|
|
|
|
for(String schemType : config.getKeys()){
|
|
|
|
|
ranks.put(SchematicType.fromDB(schemType), config.getStringList(schemType));
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static boolean isChecking(ProxiedPlayer player){
|
|
|
|
|
return currentCheckers.containsKey(player);
|
|
|
|
|
}
|
|
|
|
@ -41,7 +48,7 @@ public class CheckCommand extends BasicCommand {
|
|
|
|
|
|
|
|
|
|
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
|
|
|
|
|
List<Schematic> schematics = getSchemsToCheck();
|
|
|
|
|
if(schematics.size() > 0)
|
|
|
|
|
if(!schematics.isEmpty())
|
|
|
|
|
ServerTeamchatCommand.sendToTeam("§7Es sind §e" + schematics.size() + " §7Schematics zu prüfen§8!");
|
|
|
|
|
}, 10, 10, TimeUnit.MINUTES);
|
|
|
|
|
}
|
|
|
|
@ -66,7 +73,7 @@ public class CheckCommand extends BasicCommand {
|
|
|
|
|
break;
|
|
|
|
|
case "next":
|
|
|
|
|
case "allow":
|
|
|
|
|
next(player);
|
|
|
|
|
next(player, args);
|
|
|
|
|
break;
|
|
|
|
|
case "cancel":
|
|
|
|
|
abort(player);
|
|
|
|
@ -136,11 +143,21 @@ public class CheckCommand extends BasicCommand {
|
|
|
|
|
return false;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void next(ProxiedPlayer player){
|
|
|
|
|
private void next(ProxiedPlayer player, String[] args){
|
|
|
|
|
if(notChecking(player))
|
|
|
|
|
return;
|
|
|
|
|
|
|
|
|
|
currentCheckers.get(player).next();
|
|
|
|
|
int rank = 0;
|
|
|
|
|
if(args.length > 1){
|
|
|
|
|
try{
|
|
|
|
|
rank = Integer.parseInt(args[1]);
|
|
|
|
|
}catch(NumberFormatException e){
|
|
|
|
|
BungeeCore.send(player, "Der angegebene Rang ist ungültig!");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
currentCheckers.get(player).next(rank);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static void abort(ProxiedPlayer player){
|
|
|
|
@ -199,13 +216,13 @@ public class CheckCommand extends BasicCommand {
|
|
|
|
|
SubserverSystem.sendToTestServer(checker, mode, FightCommand.getMap(checker, mode, "Random"), schematic.getSchemID());
|
|
|
|
|
currentCheckers.put(checker, this);
|
|
|
|
|
currentSchems.put(schematic.getSchemID(), this);
|
|
|
|
|
next();
|
|
|
|
|
next(0);
|
|
|
|
|
});
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void next() {
|
|
|
|
|
private void next(int rank) {
|
|
|
|
|
if(!checkList.hasNext()){
|
|
|
|
|
accept();
|
|
|
|
|
accept(rank);
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
@ -215,6 +232,11 @@ public class CheckCommand extends BasicCommand {
|
|
|
|
|
if(checkList.hasNext()){
|
|
|
|
|
next = new TextComponent("next ");
|
|
|
|
|
next.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check next"));
|
|
|
|
|
}else if(ranks.containsKey(schematic.getSchemType())){
|
|
|
|
|
next = new TextComponent();
|
|
|
|
|
List<String> r = ranks.get(schematic.getSchemType());
|
|
|
|
|
for(int i = 0; i < r.size(); i++)
|
|
|
|
|
BungeeCore.send(checker, "Rang " + i + ": " + r.get(i), "§aMit diesem Rang freigeben", new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check allow " + i));
|
|
|
|
|
}else{
|
|
|
|
|
next = new TextComponent("accept ");
|
|
|
|
|
next.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check allow"));
|
|
|
|
@ -229,7 +251,15 @@ public class CheckCommand extends BasicCommand {
|
|
|
|
|
checker.sendMessage(next);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void accept(){
|
|
|
|
|
private void accept(int rank){
|
|
|
|
|
if(ranks.containsKey(schematic.getSchemType())){
|
|
|
|
|
if(rank < 0 || ranks.get(schematic.getSchemType()).size() >= rank){
|
|
|
|
|
BungeeCore.send(checker, "§cUnbekannter Schematic-Rang");
|
|
|
|
|
return;
|
|
|
|
|
}
|
|
|
|
|
schematic.setRank(rank);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
schematic.setSchemType(schematic.getSchemType().fightType());
|
|
|
|
|
CheckedSchematic.create(schematic.getSchemName(), schematic.getSchemOwner(), SteamwarUser.get(checker.getUniqueId()).getId(), startTime, Timestamp.from(Instant.now()), "freigegeben");
|
|
|
|
|
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(SteamwarUser.get(schematic.getSchemOwner()).getUuid());
|
|
|
|
|