Trace Refactor #233
@ -217,6 +217,8 @@ public class Trace {
|
||||
REntityServer server = serverMap.get(player);
|
||||
if(server == null) return;
|
||||
|
||||
bundleFilterMap.remove(player);
|
||||
viewFlagMap.remove(player);
|
||||
server.close();
|
||||
}
|
||||
|
||||
|
@ -60,17 +60,20 @@ public class TraceCommand extends SWCommand {
|
||||
BauSystem.MESSAGE.send("TRACE_MESSAGE_STOP", player);
|
||||
}
|
||||
|
||||
@Register(value = "auto", description = "TRACE_COMMAND_HELP_SHOW")
|
||||
public void auto (Player player) {
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
recorder.toggleAutoTrace(region);
|
||||
}
|
||||
|
||||
@Register(value = "show", description = "TRACE_COMMAND_HELP_SHOW")
|
||||
public void show(Player player, @OptionalValue("STRICT") BundleFilter filter, ViewFlag... flags){
|
||||
Region region = Region.getRegion(player.getLocation());
|
||||
|
||||
for(Trace trace : manager.get(region)){
|
||||
trace.render(player, flags, filter);
|
||||
}
|
||||
|
||||
manager.show(player, flags, filter);
|
||||
BauSystem.MESSAGE.send("TRACE_MESSAGE_SHOW", player);
|
||||
}
|
||||
|
||||
|
||||
|
||||
@ClassMapper(value = BundleFilter.class, local = true)
|
||||
public TypeMapper<BundleFilter> bundleFilterClassMapper() {
|
||||
return new TypeMapper<BundleFilter>() {
|
||||
|
@ -19,9 +19,14 @@
|
||||
|
||||
package de.steamwar.bausystem.features.tracer;
|
||||
|
||||
import de.steamwar.bausystem.features.tracer.rendering.BundleFilter;
|
||||
import de.steamwar.bausystem.features.tracer.rendering.ViewFlag;
|
||||
import de.steamwar.bausystem.region.Region;
|
||||
import de.steamwar.linkage.Linked;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.event.EventHandler;
|
||||
import org.bukkit.event.Listener;
|
||||
import org.bukkit.event.player.PlayerQuitEvent;
|
||||
|
||||
import java.util.*;
|
||||
import java.util.stream.Collectors;
|
||||
@ -33,11 +38,23 @@ public class TraceManager implements Listener {
|
||||
*/
|
||||
private final List<Trace> traces = new ArrayList<>();
|
||||
|
||||
/**
|
||||
* A map saving the view flags used by Players
|
||||
*/
|
||||
private final Map<Player, ViewFlag[]> viewFlagMap = new HashMap<>();
|
||||
|
||||
/**
|
||||
* A map saving the bundle filter used by Players
|
||||
*/
|
||||
private final Map<Player, BundleFilter> bundleFilterMap = new HashMap<>();
|
||||
|
||||
/** Adds a new trace to the global record
|
||||
*
|
||||
* @param trace Trace to be added
|
||||
*/
|
||||
protected void add(Trace trace){
|
||||
for(Player player: viewFlagMap.keySet())
|
||||
trace.render(player, viewFlagMap.get(player), bundleFilterMap.get(player));
|
||||
traces.add(trace);
|
||||
}
|
||||
|
||||
@ -46,6 +63,8 @@ public class TraceManager implements Listener {
|
||||
* @param index index of the trace to be removed
|
||||
*/
|
||||
public void remove(int index){
|
||||
for(Player player: viewFlagMap.keySet())
|
||||
traces.get(index).hide(player);
|
||||
traces.remove(index);
|
||||
}
|
||||
|
||||
@ -53,6 +72,9 @@ public class TraceManager implements Listener {
|
||||
*
|
||||
*/
|
||||
public void clear(){
|
||||
for (Player player: viewFlagMap.keySet())
|
||||
for(Trace trace: traces)
|
||||
trace.hide(player);
|
||||
traces.clear();
|
||||
}
|
||||
|
||||
@ -85,4 +107,20 @@ public class TraceManager implements Listener {
|
||||
public List<Trace> getAll(){
|
||||
return new ArrayList<>(traces);
|
||||
}
|
||||
|
||||
public void show(Player player, ViewFlag[] viewFlags, BundleFilter bundleFilter) {
|
||||
viewFlagMap.put(player, viewFlags);
|
||||
bundleFilterMap.put(player, bundleFilter);
|
||||
|
||||
for(Trace trace: traces)
|
||||
trace.render(player, viewFlags, bundleFilter);
|
||||
}
|
||||
|
||||
public void hide(Player player){
|
||||
for(Trace trace: traces)
|
||||
trace.hide(player);
|
||||
|
||||
viewFlagMap.remove(player);
|
||||
bundleFilterMap.remove(player);
|
||||
};
|
||||
}
|
||||
|
In neuem Issue referenzieren
Einen Benutzer sperren