SteamWar/BauSystem2.0
Archiviert
12
0

Trace Refactor #233

Zusammengeführt
YoyoNow hat 121 Commits von TracerGUI nach master 2024-04-21 16:03:26 +02:00 zusammengeführt
3 geänderte Dateien mit 19 neuen und 11 gelöschten Zeilen
Nur Änderungen aus Commit 39d2205b85 werden angezeigt - Alle Commits anzeigen

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;
}