SteamWar/BauSystem2.0
Archiviert
12
0

Made trace clear region wise
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: D4rkr34lm <darth.m.frohn@gmail.com>
Dieser Commit ist enthalten in:
D4rkr34lm 2024-04-18 16:10:15 +02:00
Ursprung 356b14d49c
Commit d170e96542
2 geänderte Dateien mit 15 neuen und 17 gelöschten Zeilen

Datei anzeigen

@ -131,14 +131,13 @@ public class TraceCommand extends SWCommand {
BauSystem.MESSAGE.send("TRACE_MESSAGE_HIDE", player); BauSystem.MESSAGE.send("TRACE_MESSAGE_HIDE", player);
} }
@Register(value = "delete", description = "TRACE_COMMAND_HELP_DELETE")
@Register(value = "clear") @Register(value = "clear")
public void delete(@Validator Player player) { public void clear(@Validator Player player) {
TraceManager.instance.clear(); TraceManager.instance.clear(Region.getRegion(player.getLocation()));
BauSystem.MESSAGE.send("TRACE_MESSAGE_DELETE", player); BauSystem.MESSAGE.send("TRACE_MESSAGE_CLEAR", player);
} }
@Register(value = "delete") @Register(value = "delete", description = "TRACE_MESSAGE_DELETE")
public void delete(@Validator Player player, Trace trace) { public void delete(@Validator Player player, Trace trace) {
TraceManager.instance.remove(trace); TraceManager.instance.remove(trace);
BauSystem.MESSAGE.send("TRACE_MESSAGE_DELETE_SPECIFIC", player); BauSystem.MESSAGE.send("TRACE_MESSAGE_DELETE_SPECIFIC", player);

Datei anzeigen

@ -131,11 +131,9 @@ public class TraceManager implements Listener {
/** /**
* Clears all traces * Clears all traces
*/ */
public void clear() { public void clear(Region region) {
showDataPerRegionPerPlayer.values() showDataPerRegionPerPlayer.getOrDefault(region, new HashMap<>())
.stream() .keySet()
.flatMap(map -> map.entrySet().stream())
.map(Map.Entry::getKey)
.forEach(player -> { .forEach(player -> {
Set<Player> players = followerMap.getOrDefault(player, Collections.emptySet()); Set<Player> players = followerMap.getOrDefault(player, Collections.emptySet());
traces.values().forEach(trace -> { traces.values().forEach(trace -> {
@ -143,13 +141,14 @@ public class TraceManager implements Listener {
players.forEach(trace::hide); players.forEach(trace::hide);
}); });
}); });
traces.forEach((i, trace) -> { tracesByRegion.getOrDefault(region, new HashMap<>())
trace.getMetadataSaveFile().delete(); .forEach((i, trace) -> {
trace.getRecordsSaveFile().delete(); if (trace.getRegion() != region) return;
}); traces.remove(i);
traces.clear(); trace.getMetadataSaveFile().delete();
tracesByRegion.clear(); trace.getRecordsSaveFile().delete();
nextOpenId = 0; });
tracesByRegion.getOrDefault(region, new HashMap<>()).clear();
} }
/** /**