SteamWar/BungeeCore
Archiviert
13
2

Merge pull request 'Enables checking with the ranksystem' (#92) from rank-Checksystem into master

Reviewed-by: YoyoNow <jwsteam@nidido.de>
Dieser Commit ist enthalten in:
Lixfel 2020-05-31 17:14:53 +02:00
Commit 232c6571fb
3 geänderte Dateien mit 43 neuen und 8 gelöschten Zeilen

Datei anzeigen

@ -199,6 +199,7 @@ public class BungeeCore extends Plugin {
Broadcaster.setBroadCastMsgs(config.getStringList("broadcasts").toArray(new String[1]));
PollSystem.init(config.getString("poll.question"), config.getStringList("poll.answers"));
CheckCommand.loadCheckQuestions(config.getSection("checkquestions"));
CheckCommand.loadRanks(config.getSection("checkranks"));
Persistent.setChatPrefix(CHAT_PREFIX);
Persistent.setLobbyServer(LOBBY_SERVER);

Datei anzeigen

@ -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());

Datei anzeigen

@ -92,4 +92,8 @@ public class Schematic {
this.schemType = schemType;
SQL.update("UPDATE Schematic SET SchemType = ? WHERE SchemID = ?", schemType.toDB(), schemID);
}
public void setRank(int rank) {
SQL.update("UPDATE Schematic SET Rank = ? WHERE SchemID = ?", rank, schemID);
}
}