Trace Refactor #233
@ -25,7 +25,9 @@ import de.steamwar.bausystem.features.tracer.rendering.dynamicflags.IsolateFlag;
|
|||||||
import de.steamwar.bausystem.region.Region;
|
import de.steamwar.bausystem.region.Region;
|
||||||
import de.steamwar.linkage.Linked;
|
import de.steamwar.linkage.Linked;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.event.EventHandler;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
|
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
|
|
||||||
@ -190,10 +192,6 @@ public class TraceManager implements Listener {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasFollower(Player player) {
|
|
||||||
return followerMap.containsKey(player);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean follow(Player follower, Player following) {
|
public boolean follow(Player follower, Player following) {
|
||||||
if (followerMap.containsKey(follower)) return false;
|
if (followerMap.containsKey(follower)) return false;
|
||||||
followerMap.computeIfAbsent(following, ignored -> new HashSet<>()).add(follower);
|
followerMap.computeIfAbsent(following, ignored -> new HashSet<>()).add(follower);
|
||||||
@ -298,4 +296,20 @@ public class TraceManager implements Listener {
|
|||||||
});
|
});
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@EventHandler
|
||||||
|
public void onPlayerQuit(PlayerQuitEvent event) {
|
||||||
|
unfollow(event.getPlayer());
|
||||||
|
new ArrayList<>(followerMap.getOrDefault(event.getPlayer(), Collections.emptySet())).forEach(this::unfollow);
|
||||||
|
|
||||||
|
showDataPerRegionPerPlayer.forEach((region, playerPlayerTraceShowDataMap) -> {
|
||||||
|
playerPlayerTraceShowDataMap.remove(event.getPlayer());
|
||||||
|
});
|
||||||
|
|
||||||
|
tracesByRegion.forEach((region, integerTraceMap) -> {
|
||||||
|
integerTraceMap.forEach((integer, trace) -> {
|
||||||
|
trace.hide(event.getPlayer());
|
||||||
|
});
|
||||||
|
});
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren