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:
Commit
232c6571fb
@ -199,6 +199,7 @@ public class BungeeCore extends Plugin {
|
|||||||
Broadcaster.setBroadCastMsgs(config.getStringList("broadcasts").toArray(new String[1]));
|
Broadcaster.setBroadCastMsgs(config.getStringList("broadcasts").toArray(new String[1]));
|
||||||
PollSystem.init(config.getString("poll.question"), config.getStringList("poll.answers"));
|
PollSystem.init(config.getString("poll.question"), config.getStringList("poll.answers"));
|
||||||
CheckCommand.loadCheckQuestions(config.getSection("checkquestions"));
|
CheckCommand.loadCheckQuestions(config.getSection("checkquestions"));
|
||||||
|
CheckCommand.loadRanks(config.getSection("checkranks"));
|
||||||
Persistent.setChatPrefix(CHAT_PREFIX);
|
Persistent.setChatPrefix(CHAT_PREFIX);
|
||||||
Persistent.setLobbyServer(LOBBY_SERVER);
|
Persistent.setLobbyServer(LOBBY_SERVER);
|
||||||
|
|
||||||
|
@ -22,6 +22,7 @@ import java.util.logging.Level;
|
|||||||
|
|
||||||
public class CheckCommand extends BasicCommand {
|
public class CheckCommand extends BasicCommand {
|
||||||
private static Map<SchematicType, List<String>> checkQuestions = new HashMap<>();
|
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<ProxiedPlayer, CheckSession> currentCheckers = new HashMap<>();
|
||||||
private static Map<Integer, CheckSession> currentSchems = 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){
|
public static boolean isChecking(ProxiedPlayer player){
|
||||||
return currentCheckers.containsKey(player);
|
return currentCheckers.containsKey(player);
|
||||||
}
|
}
|
||||||
@ -41,7 +48,7 @@ public class CheckCommand extends BasicCommand {
|
|||||||
|
|
||||||
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
|
ProxyServer.getInstance().getScheduler().schedule(BungeeCore.get(), () -> {
|
||||||
List<Schematic> schematics = getSchemsToCheck();
|
List<Schematic> schematics = getSchemsToCheck();
|
||||||
if(schematics.size() > 0)
|
if(!schematics.isEmpty())
|
||||||
ServerTeamchatCommand.sendToTeam("§7Es sind §e" + schematics.size() + " §7Schematics zu prüfen§8!");
|
ServerTeamchatCommand.sendToTeam("§7Es sind §e" + schematics.size() + " §7Schematics zu prüfen§8!");
|
||||||
}, 10, 10, TimeUnit.MINUTES);
|
}, 10, 10, TimeUnit.MINUTES);
|
||||||
}
|
}
|
||||||
@ -66,7 +73,7 @@ public class CheckCommand extends BasicCommand {
|
|||||||
break;
|
break;
|
||||||
case "next":
|
case "next":
|
||||||
case "allow":
|
case "allow":
|
||||||
next(player);
|
next(player, args);
|
||||||
break;
|
break;
|
||||||
case "cancel":
|
case "cancel":
|
||||||
abort(player);
|
abort(player);
|
||||||
@ -136,11 +143,21 @@ public class CheckCommand extends BasicCommand {
|
|||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
private void next(ProxiedPlayer player){
|
private void next(ProxiedPlayer player, String[] args){
|
||||||
if(notChecking(player))
|
if(notChecking(player))
|
||||||
return;
|
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){
|
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());
|
SubserverSystem.sendToTestServer(checker, mode, FightCommand.getMap(checker, mode, "Random"), schematic.getSchemID());
|
||||||
currentCheckers.put(checker, this);
|
currentCheckers.put(checker, this);
|
||||||
currentSchems.put(schematic.getSchemID(), this);
|
currentSchems.put(schematic.getSchemID(), this);
|
||||||
next();
|
next(0);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
private void next() {
|
private void next(int rank) {
|
||||||
if(!checkList.hasNext()){
|
if(!checkList.hasNext()){
|
||||||
accept();
|
accept(rank);
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -215,6 +232,11 @@ public class CheckCommand extends BasicCommand {
|
|||||||
if(checkList.hasNext()){
|
if(checkList.hasNext()){
|
||||||
next = new TextComponent("next ");
|
next = new TextComponent("next ");
|
||||||
next.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check 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{
|
}else{
|
||||||
next = new TextComponent("accept ");
|
next = new TextComponent("accept ");
|
||||||
next.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check allow"));
|
next.setClickEvent(new ClickEvent(ClickEvent.Action.RUN_COMMAND, "/check allow"));
|
||||||
@ -229,7 +251,15 @@ public class CheckCommand extends BasicCommand {
|
|||||||
checker.sendMessage(next);
|
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());
|
schematic.setSchemType(schematic.getSchemType().fightType());
|
||||||
CheckedSchematic.create(schematic.getSchemName(), schematic.getSchemOwner(), SteamwarUser.get(checker.getUniqueId()).getId(), startTime, Timestamp.from(Instant.now()), "freigegeben");
|
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());
|
ProxiedPlayer player = ProxyServer.getInstance().getPlayer(SteamwarUser.get(schematic.getSchemOwner()).getUuid());
|
||||||
|
@ -92,4 +92,8 @@ public class Schematic {
|
|||||||
this.schemType = schemType;
|
this.schemType = schemType;
|
||||||
SQL.update("UPDATE Schematic SET SchemType = ? WHERE SchemID = ?", schemType.toDB(), schemID);
|
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);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren