SteamWar/BauSystem2.0
Archiviert
12
0

Fix TraceCommand.delete
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Dieser Commit ist enthalten in:
yoyosource 2024-04-12 17:58:20 +02:00
Ursprung c4296a3781
Commit 39d2205b85
3 geänderte Dateien mit 19 neuen und 11 gelöschten Zeilen

Datei anzeigen

@ -237,6 +237,13 @@ public class Trace { // TODO: Add UUID for file saving and so on!
entityServer.close(); entityServer.close();
} }
public void hide() {
entityServerMap.forEach((player, entityServer) -> {
entityServer.close();
});
entityServerMap.clear();
}
@Override @Override
public String toString() { public String toString() {
return "Trace{" + return "Trace{" +

Datei anzeigen

@ -139,7 +139,7 @@ public class TraceCommand extends SWCommand {
@Register(value = "delete") @Register(value = "delete")
public void delete(@Validator Player player, Trace trace) { public void delete(@Validator Player player, Trace trace) {
// TODO: Reimplement manager.remove(trace); manager.remove(trace);
BauSystem.MESSAGE.send("TRACE_MESSAGE_DELETE_SPECIFIC", player); BauSystem.MESSAGE.send("TRACE_MESSAGE_DELETE_SPECIFIC", player);
} }

Datei anzeigen

@ -86,17 +86,18 @@ public class TraceManager implements Listener {
/** /**
* Removes the trace with the given id * Removes the trace with the given id
* *
* @param id id of the trace to be removed * @param trace the trace to be removed
*/ */
public boolean remove(int id) { public boolean remove(Trace trace) {
if (id >= nextOpenId) return false; Integer traceId = traces.entrySet().stream()
if (traces.get(id) == null) return false; .filter(entry -> entry.getValue() == trace)
Trace trace = traces.remove(id); .map(Map.Entry::getKey)
showDataPerRegionPerPlayer.get(trace.getRegion()).forEach((player, playerTraceShowData) -> { .findFirst()
trace.hide(player); .orElse(null);
followerMap.getOrDefault(player, Collections.emptySet()).forEach(trace::hide); if (traceId == null) return false;
}); traces.remove(traceId);
tracesByRegion.get(trace.getRegion()).remove(id); tracesByRegion.getOrDefault(trace.getRegion(), Collections.emptyMap()).remove(traceId);
trace.hide();
return true; return true;
} }