SteamWar/BauSystem2.0
Archiviert
12
0

Made for easier interfacing with api by allowing to toggle
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

show from manager
Dieser Commit ist enthalten in:
D4rkr34lm 2024-03-02 22:10:36 +01:00
Ursprung ccf155d500
Commit 75edfc8375
3 geänderte Dateien mit 49 neuen und 6 gelöschten Zeilen

Datei anzeigen

@ -217,6 +217,8 @@ public class Trace {
REntityServer server = serverMap.get(player); REntityServer server = serverMap.get(player);
if(server == null) return; if(server == null) return;
bundleFilterMap.remove(player);
viewFlagMap.remove(player);
server.close(); server.close();
} }

Datei anzeigen

@ -60,17 +60,20 @@ public class TraceCommand extends SWCommand {
BauSystem.MESSAGE.send("TRACE_MESSAGE_STOP", player); 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") @Register(value = "show", description = "TRACE_COMMAND_HELP_SHOW")
public void show(Player player, @OptionalValue("STRICT") BundleFilter filter, ViewFlag... flags){ public void show(Player player, @OptionalValue("STRICT") BundleFilter filter, ViewFlag... flags){
Region region = Region.getRegion(player.getLocation()); manager.show(player, flags, filter);
for(Trace trace : manager.get(region)){
trace.render(player, flags, filter);
}
BauSystem.MESSAGE.send("TRACE_MESSAGE_SHOW", player); BauSystem.MESSAGE.send("TRACE_MESSAGE_SHOW", player);
} }
@ClassMapper(value = BundleFilter.class, local = true) @ClassMapper(value = BundleFilter.class, local = true)
public TypeMapper<BundleFilter> bundleFilterClassMapper() { public TypeMapper<BundleFilter> bundleFilterClassMapper() {
return new TypeMapper<BundleFilter>() { return new TypeMapper<BundleFilter>() {

Datei anzeigen

@ -19,9 +19,14 @@
package de.steamwar.bausystem.features.tracer; 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.bausystem.region.Region;
import de.steamwar.linkage.Linked; import de.steamwar.linkage.Linked;
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.*;
import java.util.stream.Collectors; import java.util.stream.Collectors;
@ -33,11 +38,23 @@ public class TraceManager implements Listener {
*/ */
private final List<Trace> traces = new ArrayList<>(); 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 /** Adds a new trace to the global record
* *
* @param trace Trace to be added * @param trace Trace to be added
*/ */
protected void add(Trace trace){ protected void add(Trace trace){
for(Player player: viewFlagMap.keySet())
trace.render(player, viewFlagMap.get(player), bundleFilterMap.get(player));
traces.add(trace); traces.add(trace);
} }
@ -46,6 +63,8 @@ public class TraceManager implements Listener {
* @param index index of the trace to be removed * @param index index of the trace to be removed
*/ */
public void remove(int index){ public void remove(int index){
for(Player player: viewFlagMap.keySet())
traces.get(index).hide(player);
traces.remove(index); traces.remove(index);
} }
@ -53,6 +72,9 @@ public class TraceManager implements Listener {
* *
*/ */
public void clear(){ public void clear(){
for (Player player: viewFlagMap.keySet())
for(Trace trace: traces)
trace.hide(player);
traces.clear(); traces.clear();
} }
@ -85,4 +107,20 @@ public class TraceManager implements Listener {
public List<Trace> getAll(){ public List<Trace> getAll(){
return new ArrayList<>(traces); 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);
};
} }