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();
}
public void hide() {
entityServerMap.forEach((player, entityServer) -> {
entityServer.close();
});
entityServerMap.clear();
}
@Override
public String toString() {
return "Trace{" +

Datei anzeigen

@ -139,7 +139,7 @@ public class TraceCommand extends SWCommand {
@Register(value = "delete")
public void delete(@Validator Player player, Trace trace) {
// TODO: Reimplement manager.remove(trace);
manager.remove(trace);
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
*
* @param id id of the trace to be removed
* @param trace the trace to be removed
*/
public boolean remove(int id) {
if (id >= nextOpenId) return false;
if (traces.get(id) == null) return false;
Trace trace = traces.remove(id);
showDataPerRegionPerPlayer.get(trace.getRegion()).forEach((player, playerTraceShowData) -> {
trace.hide(player);
followerMap.getOrDefault(player, Collections.emptySet()).forEach(trace::hide);
});
tracesByRegion.get(trace.getRegion()).remove(id);
public boolean remove(Trace trace) {
Integer traceId = traces.entrySet().stream()
.filter(entry -> entry.getValue() == trace)
.map(Map.Entry::getKey)
.findFirst()
.orElse(null);
if (traceId == null) return false;
traces.remove(traceId);
tracesByRegion.getOrDefault(trace.getRegion(), Collections.emptyMap()).remove(traceId);
trace.hide();
return true;
}