SteamWar/BauSystem2.0
Archiviert
12
0

Fixed inverse x required flags
Einige Prüfungen sind fehlgeschlagen
SteamWarCI Build failed

Fixed exeption handeling in record ClassMapper
Fixed advanced flag
Added flag aliasses
Dieser Commit ist enthalten in:
D4rkr34lm 2024-03-21 16:29:51 +01:00
Ursprung 2d7ae67335
Commit d80e4cf3e0
4 geänderte Dateien mit 49 neuen und 24 gelöschten Zeilen

Datei anzeigen

@ -55,6 +55,12 @@ public class Trace {
@Getter @Getter
private int nextOpenRecordId = -1; private int nextOpenRecordId = -1;
/**
* List of all used ids
*/
@Getter
private final List<String> usedIds = new ArrayList();
/** /**
* A map of players -> REntityServers for rendering traces to a player * A map of players -> REntityServers for rendering traces to a player
*/ */
@ -80,6 +86,7 @@ public class Trace {
*/ */
protected int getAndIncrementNextOpenRecordId(){ protected int getAndIncrementNextOpenRecordId(){
nextOpenRecordId++; nextOpenRecordId++;
usedIds.add(Integer.toString(nextOpenRecordId));
return nextOpenRecordId; return nextOpenRecordId;
} }
@ -158,21 +165,20 @@ public class Trace {
List<TNTRecord> workingRecords = records; List<TNTRecord> workingRecords = records;
List<ViewFlag> flagList = new ArrayList<>(); //Manage flags and required flags
Set<ViewFlag> flagList = new HashSet<>(Arrays.asList(flags));
//Manage required flags for (ViewFlag flag : flags) {
for(ViewFlag flag: flags) if (flag.required != null) {
if(flag.required != null) flagList.addAll(Arrays.asList(flag.required));
flagList.add(flag.required); }
}
//Manage inverse flags //Manage inverse flags
flagList.addAll(ViewFlag.inverseFlags); ViewFlag.inverseFlags.forEach(viewFlag -> {
for(ViewFlag flag: flags){ if (!flagList.remove(viewFlag)) {
if(flagList.contains(flag)) flagList.add(viewFlag);
flagList.remove(flag); }
else });
flagList.add(flag);
}
//Apply filters //Apply filters
for(ViewFlag flag : flagList) for(ViewFlag flag : flagList)

Datei anzeigen

@ -94,22 +94,28 @@ public class TraceCommand extends SWCommand {
IsolateFlag isolationFlag = null; IsolateFlag isolationFlag = null;
ViewFlag[] viewFlags = trace.getViewFlags(player); ViewFlag[] viewFlags = trace.getViewFlags(player);
if(viewFlags != null) if(viewFlags != null) {
for(ViewFlag flag: viewFlags) isolationFlag = Stream.of(viewFlags)
if(flag.name.equals("isolate")) .filter(IsolateFlag.class::isInstance)
isolationFlag = (IsolateFlag) flag; .map(IsolateFlag.class::cast)
.findFirst()
.orElse(null);
}
if(isolationFlag == null) if (viewFlags == null || isolationFlag == null) {
viewFlags = new ViewFlag[1];
}
if (isolationFlag == null) {
isolationFlag = new IsolateFlag(); isolationFlag = new IsolateFlag();
}
viewFlags[0] = isolationFlag;
for(TNTRecord record: records) for(TNTRecord record: records)
isolationFlag.toggleId(record.getTntId()); isolationFlag.toggleId(record.getTntId());
ViewFlag[] flags = new ViewFlag [1];
flags[0] = isolationFlag;
trace.render(player, viewFlags, BundleFilter.STRICT); trace.render(player, viewFlags, BundleFilter.STRICT);
} }
//TODO warning if nothing is shown
@ClassMapper(value = Trace.class, local = true) @ClassMapper(value = Trace.class, local = true)
public TypeMapper<Trace> traceClassMapper(){ public TypeMapper<Trace> traceClassMapper(){
@ -147,6 +153,15 @@ public class TraceCommand extends SWCommand {
.findFirst() .findFirst()
.orElse(null); .orElse(null);
} }
//TODO change when new command framework update
@Override
public Collection<String> tabCompletes(CommandSender sender, PreviousArguments previousArguments, String s) {
Trace trace = previousArguments.getFirst(Trace.class).orElse(null);
if(trace == null) return null;
return trace.getUsedIds();
}
}; };
} }

Datei anzeigen

@ -104,7 +104,8 @@ public abstract class ViewFlag {
public void modify(REntityServer server, List<TraceEntity> entities) {} public void modify(REntityServer server, List<TraceEntity> entities) {}
}; };
public static ViewFlag MICROMOTION = new ViewFlag(true, false, "micromotion") { //TODO fix?
public static ViewFlag MICROMOTION = new ViewFlag(true, false, "micromotion", "m") {
@Override @Override
public List<TNTRecord> filter(List<TNTRecord> records) { public List<TNTRecord> filter(List<TNTRecord> records) {
Set<Integer> seen = new HashSet<>(); Set<Integer> seen = new HashSet<>();
@ -139,7 +140,8 @@ public abstract class ViewFlag {
public void modify(REntityServer server, List<TraceEntity> entities) {} public void modify(REntityServer server, List<TraceEntity> entities) {}
}; };
public static ViewFlag ADVANCED = new ViewFlag(true, false, "advanced") { //TODO fix?
public static ViewFlag ADVANCED = new ViewFlag(true, false, "advanced", "a") {
@Override @Override
public List<TNTRecord> filter(List<TNTRecord> records) {return records;} public List<TNTRecord> filter(List<TNTRecord> records) {return records;}

Datei anzeigen

@ -25,12 +25,14 @@ import de.steamwar.bausystem.features.tracer.rendering.ViewFlag;
import de.steamwar.entity.REntityServer; import de.steamwar.entity.REntityServer;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.HashSet;
import java.util.List; import java.util.List;
import java.util.Set;
import java.util.stream.Collectors; import java.util.stream.Collectors;
public class IsolateFlag extends ViewFlag { public class IsolateFlag extends ViewFlag {
private final List<Integer> tntToIsolate = new ArrayList<>(); private final Set<Integer> tntToIsolate = new HashSet<>();
public IsolateFlag(){ public IsolateFlag(){
super(false, false, ViewFlag.IGNITE, "isolate"); super(false, false, ViewFlag.IGNITE, "isolate");