Signed-off-by: D4rkr34lm <darth.m.frohn@gmail.com>
Dieser Commit ist enthalten in:
Ursprung
80967ab4e7
Commit
43a04a68bf
@ -23,7 +23,7 @@ import com.sk89q.worldedit.EditSession;
|
|||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
|
import de.steamwar.bausystem.features.slaves.laufbau.BlockBoundingBox;
|
||||||
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
|
import de.steamwar.bausystem.features.slaves.laufbau.Cuboid;
|
||||||
import de.steamwar.bausystem.features.tracer.TraceRecord;
|
import de.steamwar.bausystem.features.tracer.TNTPoint;
|
||||||
import de.steamwar.bausystem.features.tracer.TraceRecorder;
|
import de.steamwar.bausystem.features.tracer.TraceRecorder;
|
||||||
import de.steamwar.bausystem.region.Point;
|
import de.steamwar.bausystem.region.Point;
|
||||||
import de.steamwar.bausystem.utils.FlatteningWrapper;
|
import de.steamwar.bausystem.utils.FlatteningWrapper;
|
||||||
@ -45,7 +45,7 @@ public class ProcessingTracesState implements LaufbauState {
|
|||||||
private final List<BlockBoundingBox> elements;
|
private final List<BlockBoundingBox> elements;
|
||||||
private final int factor;
|
private final int factor;
|
||||||
|
|
||||||
private final List<TraceRecord> traceRecords;
|
private final List<TNTPoint> TNTPoints;
|
||||||
private final int totalTntRecords;
|
private final int totalTntRecords;
|
||||||
|
|
||||||
private final Set<Point> affectedBlocks = new HashSet<>();
|
private final Set<Point> affectedBlocks = new HashSet<>();
|
||||||
@ -59,17 +59,17 @@ public class ProcessingTracesState implements LaufbauState {
|
|||||||
this.factor = factor;
|
this.factor = factor;
|
||||||
|
|
||||||
// TODO: Optimize only retrieving traces inside of the affected regions!
|
// TODO: Optimize only retrieving traces inside of the affected regions!
|
||||||
traceRecords = TraceRecorder.instance.manager.getAll()
|
TNTPoints = TraceRecorder.instance.manager.getAll()
|
||||||
.stream()
|
.stream()
|
||||||
.flatMap(trace -> trace.getHistories().stream())
|
.flatMap(trace -> trace.getHistories().stream())
|
||||||
.flatMap(Collection::stream)
|
.flatMap(Collection::stream)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
totalTntRecords = traceRecords.size();
|
totalTntRecords = TNTPoints.size();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public String actionBarMessage(Player p) {
|
public String actionBarMessage(Player p) {
|
||||||
return BauSystem.MESSAGE.parse("LAUFBAU_SIMPLE_PROGRESS", p, BauSystem.MESSAGE.parse("LAUFBAU_STATE_PROCESSING_TRACES", p), totalTntRecords - traceRecords.size(), totalTntRecords, eta(p, start, totalTntRecords - traceRecords.size(), totalTntRecords));
|
return BauSystem.MESSAGE.parse("LAUFBAU_SIMPLE_PROGRESS", p, BauSystem.MESSAGE.parse("LAUFBAU_STATE_PROCESSING_TRACES", p), totalTntRecords - TNTPoints.size(), totalTntRecords, eta(p, start, totalTntRecords - TNTPoints.size(), totalTntRecords));
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean inRegion(Vector location, int expansion) {
|
private boolean inRegion(Vector location, int expansion) {
|
||||||
@ -78,12 +78,12 @@ public class ProcessingTracesState implements LaufbauState {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean hasNext() {
|
public boolean hasNext() {
|
||||||
return !traceRecords.isEmpty();
|
return !TNTPoints.isEmpty();
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void next() {
|
public void next() {
|
||||||
TraceRecord current = traceRecords.remove(0);
|
TNTPoint current = TNTPoints.remove(0);
|
||||||
if (FlatteningWrapper.impl.inWater(world, current.getLocation().toVector())) return;
|
if (FlatteningWrapper.impl.inWater(world, current.getLocation().toVector())) return;
|
||||||
if (!(inRegion(current.getLocation().toVector(), 1) || (current.getPrevious().isPresent() && inRegion(current.getPrevious().get().getLocation().toVector(), 1))))
|
if (!(inRegion(current.getLocation().toVector(), 1) || (current.getPrevious().isPresent() && inRegion(current.getPrevious().get().getLocation().toVector(), 1))))
|
||||||
return;
|
return;
|
||||||
|
@ -32,7 +32,7 @@ import java.util.List;
|
|||||||
import java.util.Optional;
|
import java.util.Optional;
|
||||||
|
|
||||||
@Getter
|
@Getter
|
||||||
public class TraceRecord {
|
public class TNTPoint {
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Unique number to identify records being of the same tnt
|
* Unique number to identify records being of the same tnt
|
||||||
@ -87,9 +87,9 @@ public class TraceRecord {
|
|||||||
/**
|
/**
|
||||||
* List of all tnt records, that are represent the same tnt
|
* List of all tnt records, that are represent the same tnt
|
||||||
*/
|
*/
|
||||||
private final List<TraceRecord> history;
|
private final List<TNTPoint> history;
|
||||||
|
|
||||||
public TraceRecord(int tntId, TNTPrimed tnt, boolean explosion, boolean afterFirstExplosion, long ticksSinceStart, List<TraceRecord> history, List<Block> destroyedBlocks) {
|
public TNTPoint(int tntId, TNTPrimed tnt, boolean explosion, boolean afterFirstExplosion, long ticksSinceStart, List<TNTPoint> history, List<Block> destroyedBlocks) {
|
||||||
this.tntId = tntId;
|
this.tntId = tntId;
|
||||||
this.explosion = explosion;
|
this.explosion = explosion;
|
||||||
this.inWater = tnt.isInWater();
|
this.inWater = tnt.isInWater();
|
||||||
@ -115,12 +115,12 @@ public class TraceRecord {
|
|||||||
destroyedTestBlock = testblockDestroy;
|
destroyedTestBlock = testblockDestroy;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<TraceRecord> getNext() {
|
public Optional<TNTPoint> getNext() {
|
||||||
int index = history.indexOf(this);
|
int index = history.indexOf(this);
|
||||||
return index == history.size() - 1 ? Optional.empty() : Optional.of(history.get(index + 1));
|
return index == history.size() - 1 ? Optional.empty() : Optional.of(history.get(index + 1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<TraceRecord> getPrevious() {
|
public Optional<TNTPoint> getPrevious() {
|
||||||
int index = history.indexOf(this);
|
int index = history.indexOf(this);
|
||||||
return index == 0 ? Optional.empty() : Optional.of(history.get(index - 1));
|
return index == 0 ? Optional.empty() : Optional.of(history.get(index - 1));
|
||||||
}
|
}
|
||||||
@ -138,8 +138,8 @@ public class TraceRecord {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public boolean equals(Object obj) {
|
public boolean equals(Object obj) {
|
||||||
if (!(obj instanceof TraceRecord)) return false;
|
if (!(obj instanceof TNTPoint)) return false;
|
||||||
TraceRecord record = (TraceRecord) obj;
|
TNTPoint record = (TNTPoint) obj;
|
||||||
if (record.isExplosion() != explosion) return false;
|
if (record.isExplosion() != explosion) return false;
|
||||||
if (!record.getLocation().equals(location)) return false;
|
if (!record.getLocation().equals(location)) return false;
|
||||||
if (!record.getVelocity().equals(velocity)) return false;
|
if (!record.getVelocity().equals(velocity)) return false;
|
@ -56,7 +56,7 @@ public class Trace { // TODO: Add UUID for file saving and so on!
|
|||||||
* Records of TNTs, making up the trace
|
* Records of TNTs, making up the trace
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
private List<TraceRecord> records = new ArrayList<>();
|
private List<TNTPoint> records = new ArrayList<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* ID that should be assigned to the next record of a unique tnt
|
* ID that should be assigned to the next record of a unique tnt
|
||||||
@ -72,7 +72,7 @@ public class Trace { // TODO: Add UUID for file saving and so on!
|
|||||||
public List<String> getUsedIds() {
|
public List<String> getUsedIds() {
|
||||||
return getRecords()
|
return getRecords()
|
||||||
.stream()
|
.stream()
|
||||||
.map(TraceRecord::getTntId)
|
.map(TNTPoint::getTntId)
|
||||||
.map(i -> i + "")
|
.map(i -> i + "")
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
@ -93,7 +93,7 @@ public class Trace { // TODO: Add UUID for file saving and so on!
|
|||||||
/**
|
/**
|
||||||
* Adds the given records and updates potential trace renderings
|
* Adds the given records and updates potential trace renderings
|
||||||
*/
|
*/
|
||||||
protected void addAll(List<TraceRecord> records, Function<Player, PlayerTraceShowData> getter) {
|
protected void addAll(List<TNTPoint> records, Function<Player, PlayerTraceShowData> getter) {
|
||||||
this.records.addAll(records);
|
this.records.addAll(records);
|
||||||
Iterator<Player> keySetIterator = entityServerMap.keySet().iterator();
|
Iterator<Player> keySetIterator = entityServerMap.keySet().iterator();
|
||||||
while (keySetIterator.hasNext()) {
|
while (keySetIterator.hasNext()) {
|
||||||
@ -112,7 +112,7 @@ public class Trace { // TODO: Add UUID for file saving and so on!
|
|||||||
*
|
*
|
||||||
* @param records immutable records list
|
* @param records immutable records list
|
||||||
*/
|
*/
|
||||||
protected void setRecords(List<TraceRecord> records) {
|
protected void setRecords(List<TNTPoint> records) {
|
||||||
this.records = records;
|
this.records = records;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -121,10 +121,10 @@ public class Trace { // TODO: Add UUID for file saving and so on!
|
|||||||
*
|
*
|
||||||
* @return the historys of this trace
|
* @return the historys of this trace
|
||||||
*/
|
*/
|
||||||
public Set<List<TraceRecord>> getHistories() {
|
public Set<List<TNTPoint>> getHistories() {
|
||||||
Set<List<TraceRecord>> histories = new HashSet<>();
|
Set<List<TNTPoint>> histories = new HashSet<>();
|
||||||
|
|
||||||
for (TraceRecord record : getRecords()) {
|
for (TNTPoint record : getRecords()) {
|
||||||
histories.add(record.getHistory());
|
histories.add(record.getHistory());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -155,10 +155,10 @@ public class Trace { // TODO: Add UUID for file saving and so on!
|
|||||||
* @param records Records to render
|
* @param records Records to render
|
||||||
* @param playerTraceShowData The showData for modifying the rendering
|
* @param playerTraceShowData The showData for modifying the rendering
|
||||||
*/
|
*/
|
||||||
private void render(List<TraceRecord> records, REntityServer entityServer, PlayerTraceShowData playerTraceShowData) {
|
private void render(List<TNTPoint> records, REntityServer entityServer, PlayerTraceShowData playerTraceShowData) {
|
||||||
if (records.isEmpty()) return;
|
if (records.isEmpty()) return;
|
||||||
|
|
||||||
List<TraceRecord> workingRecords = records;
|
List<TNTPoint> workingRecords = records;
|
||||||
Set<ViewFlag> flagList = playerTraceShowData.getEffectiveViewFlags();
|
Set<ViewFlag> flagList = playerTraceShowData.getEffectiveViewFlags();
|
||||||
|
|
||||||
//Apply filters
|
//Apply filters
|
||||||
@ -167,12 +167,12 @@ public class Trace { // TODO: Add UUID for file saving and so on!
|
|||||||
}
|
}
|
||||||
|
|
||||||
//Bundle records at unique positions
|
//Bundle records at unique positions
|
||||||
List<List<TraceRecord>> bundles = bundleRecords(workingRecords, playerTraceShowData.getBundleFilter());
|
List<List<TNTPoint>> bundles = bundleRecords(workingRecords, playerTraceShowData.getBundleFilter());
|
||||||
|
|
||||||
//Render bundled records
|
//Render bundled records
|
||||||
List<TraceEntity> entities = new LinkedList<>();
|
List<TraceEntity> entities = new LinkedList<>();
|
||||||
|
|
||||||
for (List<TraceRecord> bundle : bundles) {
|
for (List<TNTPoint> bundle : bundles) {
|
||||||
entities.add(new TraceEntity(entityServer, bundle.get(0).getLocation(), bundle.get(0).isExplosion(), bundle));
|
entities.add(new TraceEntity(entityServer, bundle.get(0).getLocation(), bundle.get(0).isExplosion(), bundle));
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -196,23 +196,23 @@ public class Trace { // TODO: Add UUID for file saving and so on!
|
|||||||
* @param records The TNTRecords that are supposed to be bundled
|
* @param records The TNTRecords that are supposed to be bundled
|
||||||
* @return A list of bundles
|
* @return A list of bundles
|
||||||
*/
|
*/
|
||||||
private List<List<TraceRecord>> bundleRecords(List<TraceRecord> records, BundleFilter filter) {
|
private List<List<TNTPoint>> bundleRecords(List<TNTPoint> records, BundleFilter filter) {
|
||||||
List<List<TraceRecord>> bundles = new ArrayList<>();
|
List<List<TNTPoint>> bundles = new ArrayList<>();
|
||||||
|
|
||||||
recordsLoop:
|
recordsLoop:
|
||||||
for (TraceRecord record : records) {
|
for (TNTPoint record : records) {
|
||||||
if (bundles.isEmpty()) {
|
if (bundles.isEmpty()) {
|
||||||
List<TraceRecord> firstBundle = new ArrayList<>();
|
List<TNTPoint> firstBundle = new ArrayList<>();
|
||||||
firstBundle.add(record);
|
firstBundle.add(record);
|
||||||
bundles.add(firstBundle);
|
bundles.add(firstBundle);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (int i = bundles.size() - 1; i >= 0; i--) {
|
for (int i = bundles.size() - 1; i >= 0; i--) {
|
||||||
List<TraceRecord> bundle = bundles.get(i);
|
List<TNTPoint> bundle = bundles.get(i);
|
||||||
|
|
||||||
Boolean filterResult = filter.function.apply(record, bundle.get(0));
|
Boolean filterResult = filter.function.apply(record, bundle.get(0));
|
||||||
if (filterResult == null || !filterResult) {
|
if (filterResult == null || !filterResult) {
|
||||||
ArrayList<TraceRecord> newBundle = new ArrayList<>();
|
ArrayList<TNTPoint> newBundle = new ArrayList<>();
|
||||||
newBundle.add(record);
|
newBundle.add(record);
|
||||||
bundles.add(newBundle);
|
bundles.add(newBundle);
|
||||||
continue recordsLoop;
|
continue recordsLoop;
|
||||||
|
@ -143,7 +143,7 @@ public class TraceCommand extends SWCommand {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Register(value = "isolate", description = "TRACE_COMMAND_HELP_ISOLATE")
|
@Register(value = "isolate", description = "TRACE_COMMAND_HELP_ISOLATE")
|
||||||
public void isolate(@Validator Player player, Trace trace, @ErrorMessage("TRACE_RECORD_ID_INVALID") TraceRecord... records) {
|
public void isolate(@Validator Player player, Trace trace, @ErrorMessage("TRACE_RECORD_ID_INVALID") TNTPoint... records) {
|
||||||
manager.isolate(player, records);
|
manager.isolate(player, records);
|
||||||
// TODO: Add Message!
|
// TODO: Add Message!
|
||||||
}
|
}
|
||||||
@ -186,11 +186,11 @@ public class TraceCommand extends SWCommand {
|
|||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
@ClassMapper(value = TraceRecord.class, local = true)
|
@ClassMapper(value = TNTPoint.class, local = true)
|
||||||
public TypeMapper<TraceRecord> recordMapper() {
|
public TypeMapper<TNTPoint> recordMapper() {
|
||||||
return new TypeMapper<>() {
|
return new TypeMapper<>() {
|
||||||
@Override
|
@Override
|
||||||
public TraceRecord map(CommandSender commandSender, PreviousArguments previousArguments, String s) {
|
public TNTPoint map(CommandSender commandSender, PreviousArguments previousArguments, String s) {
|
||||||
Trace trace = previousArguments.getFirst(Trace.class).orElse(null);
|
Trace trace = previousArguments.getFirst(Trace.class).orElse(null);
|
||||||
if (trace == null) return null;
|
if (trace == null) return null;
|
||||||
|
|
||||||
|
@ -61,8 +61,8 @@ public class TraceManager implements Listener {
|
|||||||
return nextOpenId;
|
return nextOpenId;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void addAll(Trace trace, List<TraceRecord> traceRecords) {
|
protected void addAll(Trace trace, List<TNTPoint> TNTPoints) {
|
||||||
trace.addAll(traceRecords, player -> {
|
trace.addAll(TNTPoints, player -> {
|
||||||
return showDataPerRegionPerPlayer.getOrDefault(trace.getRegion(), Collections.emptyMap()).get(player);
|
return showDataPerRegionPerPlayer.getOrDefault(trace.getRegion(), Collections.emptyMap()).get(player);
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@ -195,7 +195,7 @@ public class TraceManager implements Listener {
|
|||||||
* @param player the player the trace is shown to
|
* @param player the player the trace is shown to
|
||||||
* @param records the record for which isolation is toggled
|
* @param records the record for which isolation is toggled
|
||||||
*/
|
*/
|
||||||
public void isolate(Player player, TraceRecord... records) {
|
public void isolate(Player player, TNTPoint... records) {
|
||||||
Region region = Region.getRegion(player.getLocation());
|
Region region = Region.getRegion(player.getLocation());
|
||||||
PlayerTraceShowData playerTraceShowData = showDataPerRegionPerPlayer.computeIfAbsent(region, ignored -> new HashMap<>()).computeIfAbsent(player, ignored -> new PlayerTraceShowData(BundleFilter.STRICT));
|
PlayerTraceShowData playerTraceShowData = showDataPerRegionPerPlayer.computeIfAbsent(region, ignored -> new HashMap<>()).computeIfAbsent(player, ignored -> new PlayerTraceShowData(BundleFilter.STRICT));
|
||||||
|
|
||||||
@ -212,7 +212,7 @@ public class TraceManager implements Listener {
|
|||||||
showDataPerRegionPerPlayer.get(region).put(player, playerTraceShowData);
|
showDataPerRegionPerPlayer.get(region).put(player, playerTraceShowData);
|
||||||
}
|
}
|
||||||
|
|
||||||
for (TraceRecord record : records) {
|
for (TNTPoint record : records) {
|
||||||
isolateFlag.toggleId(record.getTntId());
|
isolateFlag.toggleId(record.getTntId());
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -72,12 +72,12 @@ public class TraceRecorder implements Listener {
|
|||||||
/**
|
/**
|
||||||
* A map for records that have been taken in the same tick and now have to be added to the traces
|
* A map for records that have been taken in the same tick and now have to be added to the traces
|
||||||
*/
|
*/
|
||||||
private final Map<Trace, List<TraceRecord>> recordsToAddMap = new HashMap<>();
|
private final Map<Trace, List<TNTPoint>> recordsToAddMap = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Maps a tracked tnt entity to its entire recording history
|
* Maps a tracked tnt entity to its entire recording history
|
||||||
*/
|
*/
|
||||||
private final Map<TNTPrimed, List<TraceRecord>> historyMap = new HashMap<>();
|
private final Map<TNTPrimed, List<TNTPoint>> historyMap = new HashMap<>();
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Regions where auto-trace is enabled
|
* Regions where auto-trace is enabled
|
||||||
@ -160,9 +160,9 @@ public class TraceRecorder implements Listener {
|
|||||||
record(tnt, trace, Collections.emptyList());
|
record(tnt, trace, Collections.emptyList());
|
||||||
}
|
}
|
||||||
|
|
||||||
List<TraceRecord> traceRecords = recordsToAddMap.get(trace);
|
List<TNTPoint> TNTPoints = recordsToAddMap.get(trace);
|
||||||
manager.addAll(trace, traceRecords);
|
manager.addAll(trace, TNTPoints);
|
||||||
traceRecords.clear();
|
TNTPoints.clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -173,7 +173,7 @@ public class TraceRecorder implements Listener {
|
|||||||
* @param trace trace to record the tnt for
|
* @param trace trace to record the tnt for
|
||||||
*/
|
*/
|
||||||
private void record(TNTPrimed tntPrimed, Trace trace, List<Block> destroyedBlocks) {
|
private void record(TNTPrimed tntPrimed, Trace trace, List<Block> destroyedBlocks) {
|
||||||
List<TraceRecord> history = historyMap.getOrDefault(tntPrimed, new ArrayList<>());
|
List<TNTPoint> history = historyMap.getOrDefault(tntPrimed, new ArrayList<>());
|
||||||
int tntID;
|
int tntID;
|
||||||
|
|
||||||
if (history.size() == 0) {
|
if (history.size() == 0) {
|
||||||
@ -189,7 +189,7 @@ public class TraceRecorder implements Listener {
|
|||||||
}
|
}
|
||||||
boolean afterFirstExplosion = noExplosionRecorded.contains(trace);
|
boolean afterFirstExplosion = noExplosionRecorded.contains(trace);
|
||||||
|
|
||||||
TraceRecord record = new TraceRecord(tntID, tntPrimed, isExplosion, afterFirstExplosion, TPSUtils.currentTick.get() - trace.getStartTime(), history, destroyedBlocks);
|
TNTPoint record = new TNTPoint(tntID, tntPrimed, isExplosion, afterFirstExplosion, TPSUtils.currentTick.get() - trace.getStartTime(), history, destroyedBlocks);
|
||||||
history.add(record);
|
history.add(record);
|
||||||
|
|
||||||
recordsToAddMap.get(trace).add(record);
|
recordsToAddMap.get(trace).add(record);
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.tracer.rendering;
|
package de.steamwar.bausystem.features.tracer.rendering;
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.tracer.TraceRecord;
|
import de.steamwar.bausystem.features.tracer.TNTPoint;
|
||||||
import lombok.RequiredArgsConstructor;
|
import lombok.RequiredArgsConstructor;
|
||||||
|
|
||||||
import java.util.function.BiFunction;
|
import java.util.function.BiFunction;
|
||||||
@ -27,14 +27,14 @@ import java.util.function.BiFunction;
|
|||||||
@RequiredArgsConstructor
|
@RequiredArgsConstructor
|
||||||
public enum BundleFilter {
|
public enum BundleFilter {
|
||||||
|
|
||||||
LOOSE((TraceRecord a, TraceRecord b) -> {
|
LOOSE((TNTPoint a, TNTPoint b) -> {
|
||||||
if (a.isExplosion() != b.isExplosion()) return false;
|
if (a.isExplosion() != b.isExplosion()) return false;
|
||||||
if (a.getLocation().distanceSquared(b.getLocation()) <= BundleFilter.pixelSizeSquared) return false;
|
if (a.getLocation().distanceSquared(b.getLocation()) <= BundleFilter.pixelSizeSquared) return false;
|
||||||
if (a.getVelocity().distanceSquared(b.getVelocity()) <= BundleFilter.pixelSizeSquared) return false;
|
if (a.getVelocity().distanceSquared(b.getVelocity()) <= BundleFilter.pixelSizeSquared) return false;
|
||||||
return true;
|
return true;
|
||||||
}),
|
}),
|
||||||
|
|
||||||
DEFAULT((TraceRecord a, TraceRecord b) -> {
|
DEFAULT((TNTPoint a, TNTPoint b) -> {
|
||||||
if (a.isExplosion() != b.isExplosion()) return false;
|
if (a.isExplosion() != b.isExplosion()) return false;
|
||||||
if (a.getTicksSinceStart() != b.getTicksSinceStart()) return null;
|
if (a.getTicksSinceStart() != b.getTicksSinceStart()) return null;
|
||||||
if (a.getLocation().distanceSquared(b.getLocation()) <= BundleFilter.pixelSizeSquared) return false;
|
if (a.getLocation().distanceSquared(b.getLocation()) <= BundleFilter.pixelSizeSquared) return false;
|
||||||
@ -42,7 +42,7 @@ public enum BundleFilter {
|
|||||||
return true;
|
return true;
|
||||||
}),
|
}),
|
||||||
|
|
||||||
STRICT((TraceRecord a, TraceRecord b) -> {
|
STRICT((TNTPoint a, TNTPoint b) -> {
|
||||||
if (a.isExplosion() != b.isExplosion()) return false;
|
if (a.isExplosion() != b.isExplosion()) return false;
|
||||||
if (!a.getLocation().equals(b.getLocation())) return false;
|
if (!a.getLocation().equals(b.getLocation())) return false;
|
||||||
if (!a.getVelocity().equals(b.getVelocity())) return false;
|
if (!a.getVelocity().equals(b.getVelocity())) return false;
|
||||||
@ -50,7 +50,7 @@ public enum BundleFilter {
|
|||||||
return true;
|
return true;
|
||||||
}),
|
}),
|
||||||
|
|
||||||
NONE((TraceRecord a, TraceRecord b) -> {
|
NONE((TNTPoint a, TNTPoint b) -> {
|
||||||
return null;
|
return null;
|
||||||
});
|
});
|
||||||
|
|
||||||
@ -59,7 +59,7 @@ public enum BundleFilter {
|
|||||||
* {@code false}: No bundling allowed
|
* {@code false}: No bundling allowed
|
||||||
* {@code true}: Bundling should be applied
|
* {@code true}: Bundling should be applied
|
||||||
*/
|
*/
|
||||||
public final BiFunction<TraceRecord, TraceRecord, Boolean> function;
|
public final BiFunction<TNTPoint, TNTPoint, Boolean> function;
|
||||||
|
|
||||||
private static final double pixelSize = 0.0625;
|
private static final double pixelSize = 0.0625;
|
||||||
private static final double pixelSizeSquared = pixelSize * pixelSize;
|
private static final double pixelSizeSquared = pixelSize * pixelSize;
|
||||||
|
@ -20,7 +20,7 @@
|
|||||||
package de.steamwar.bausystem.features.tracer.rendering;
|
package de.steamwar.bausystem.features.tracer.rendering;
|
||||||
|
|
||||||
import de.steamwar.bausystem.BauSystem;
|
import de.steamwar.bausystem.BauSystem;
|
||||||
import de.steamwar.bausystem.features.tracer.TraceRecord;
|
import de.steamwar.bausystem.features.tracer.TNTPoint;
|
||||||
import de.steamwar.entity.REntityServer;
|
import de.steamwar.entity.REntityServer;
|
||||||
import de.steamwar.entity.RFallingBlockEntity;
|
import de.steamwar.entity.RFallingBlockEntity;
|
||||||
import lombok.Getter;
|
import lombok.Getter;
|
||||||
@ -36,16 +36,16 @@ public class TraceEntity extends RFallingBlockEntity {
|
|||||||
* The records represented by this REntity
|
* The records represented by this REntity
|
||||||
*/
|
*/
|
||||||
@Getter
|
@Getter
|
||||||
private final List<TraceRecord> records;
|
private final List<TNTPoint> records;
|
||||||
|
|
||||||
public TraceEntity(REntityServer server, Location location, boolean isExplosion, List<TraceRecord> records) {
|
public TraceEntity(REntityServer server, Location location, boolean isExplosion, List<TNTPoint> records) {
|
||||||
super(server, location, isExplosion ? Material.RED_STAINED_GLASS : Material.TNT);
|
super(server, location, isExplosion ? Material.RED_STAINED_GLASS : Material.TNT);
|
||||||
setNoGravity(true);
|
setNoGravity(true);
|
||||||
this.records = records;
|
this.records = records;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void printIntoChat(Player player) {
|
public void printIntoChat(Player player) {
|
||||||
TraceRecord representative = records.get(0);
|
TNTPoint representative = records.get(0);
|
||||||
|
|
||||||
BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_HEADER", player);
|
BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_HEADER", player);
|
||||||
BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_FUSE_TIME", player, representative.getFuse());
|
BauSystem.MESSAGE.sendPrefixless("TNT_CLICK_FUSE_TIME", player, representative.getFuse());
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.tracer.rendering;
|
package de.steamwar.bausystem.features.tracer.rendering;
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.tracer.TraceRecord;
|
import de.steamwar.bausystem.features.tracer.TNTPoint;
|
||||||
import de.steamwar.entity.REntityServer;
|
import de.steamwar.entity.REntityServer;
|
||||||
import de.steamwar.entity.RFallingBlockEntity;
|
import de.steamwar.entity.RFallingBlockEntity;
|
||||||
import org.bukkit.Location;
|
import org.bukkit.Location;
|
||||||
@ -45,16 +45,16 @@ public abstract class ViewFlag {
|
|||||||
|
|
||||||
public static ViewFlag EXPLOSION = new ViewFlag(true, false, "explosion", "e") {
|
public static ViewFlag EXPLOSION = new ViewFlag(true, false, "explosion", "e") {
|
||||||
@Override
|
@Override
|
||||||
public List<TraceRecord> filter(List<TraceRecord> records) {
|
public List<TNTPoint> filter(List<TNTPoint> records) {
|
||||||
return records.stream()
|
return records.stream()
|
||||||
.filter(TraceRecord::isExplosion)
|
.filter(TNTPoint::isExplosion)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
public static ViewFlag IGNITE = new ViewFlag(true, true, "ignite", "i") {
|
public static ViewFlag IGNITE = new ViewFlag(true, true, "ignite", "i") {
|
||||||
@Override
|
@Override
|
||||||
public List<TraceRecord> filter(List<TraceRecord> records) {
|
public List<TNTPoint> filter(List<TNTPoint> records) {
|
||||||
return records.stream()
|
return records.stream()
|
||||||
.filter(record -> !record.isAfterFirstExplosion())
|
.filter(record -> !record.isAfterFirstExplosion())
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
@ -63,7 +63,7 @@ public abstract class ViewFlag {
|
|||||||
|
|
||||||
public static ViewFlag SOURCE = new ViewFlag(true, false, IGNITE, "source", "s") {
|
public static ViewFlag SOURCE = new ViewFlag(true, false, IGNITE, "source", "s") {
|
||||||
@Override
|
@Override
|
||||||
public List<TraceRecord> filter(List<TraceRecord> records) {
|
public List<TNTPoint> filter(List<TNTPoint> records) {
|
||||||
return records.stream()
|
return records.stream()
|
||||||
.filter(record -> record.getFuse() == 80)
|
.filter(record -> record.getFuse() == 80)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
@ -72,7 +72,7 @@ public abstract class ViewFlag {
|
|||||||
|
|
||||||
public static ViewFlag BUILD_DESTROY_ONLY = new ViewFlag(true, false, "build-destroy-only") {
|
public static ViewFlag BUILD_DESTROY_ONLY = new ViewFlag(true, false, "build-destroy-only") {
|
||||||
@Override
|
@Override
|
||||||
public List<TraceRecord> filter(List<TraceRecord> records) {
|
public List<TNTPoint> filter(List<TNTPoint> records) {
|
||||||
return records.stream()
|
return records.stream()
|
||||||
.filter(record -> record.getHistory().get(record.getHistory().size() - 1).isDestroyedBuildArea())
|
.filter(record -> record.getHistory().get(record.getHistory().size() - 1).isDestroyedBuildArea())
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
@ -81,7 +81,7 @@ public abstract class ViewFlag {
|
|||||||
|
|
||||||
public static ViewFlag TESTBLOCK_DESTROY_ONLY = new ViewFlag(true, false, "testblock-destroy-only") {
|
public static ViewFlag TESTBLOCK_DESTROY_ONLY = new ViewFlag(true, false, "testblock-destroy-only") {
|
||||||
@Override
|
@Override
|
||||||
public List<TraceRecord> filter(List<TraceRecord> records) {
|
public List<TNTPoint> filter(List<TNTPoint> records) {
|
||||||
return records.stream()
|
return records.stream()
|
||||||
.filter(record -> record.getHistory().get(record.getHistory().size() - 1).isDestroyedTestBlock())
|
.filter(record -> record.getHistory().get(record.getHistory().size() - 1).isDestroyedTestBlock())
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
@ -90,15 +90,15 @@ public abstract class ViewFlag {
|
|||||||
|
|
||||||
public static ViewFlag MICROMOTION = new ViewFlag(true, false, "micromotion", "m") {
|
public static ViewFlag MICROMOTION = new ViewFlag(true, false, "micromotion", "m") {
|
||||||
@Override
|
@Override
|
||||||
public List<TraceRecord> filter(List<TraceRecord> records) {
|
public List<TNTPoint> filter(List<TNTPoint> records) {
|
||||||
Set<Integer> seen = new HashSet<>();
|
Set<Integer> seen = new HashSet<>();
|
||||||
Set<TraceRecord> toRemove = new HashSet<>();
|
Set<TNTPoint> toRemove = new HashSet<>();
|
||||||
|
|
||||||
for (TraceRecord uniqueRecord : records) {
|
for (TNTPoint uniqueRecord : records) {
|
||||||
if (seen.contains(uniqueRecord.getTntId())) continue;
|
if (seen.contains(uniqueRecord.getTntId())) continue;
|
||||||
|
|
||||||
boolean hasMicromotion = false;
|
boolean hasMicromotion = false;
|
||||||
for (TraceRecord record : uniqueRecord.getHistory()) {
|
for (TNTPoint record : uniqueRecord.getHistory()) {
|
||||||
Vector velocity = record.getVelocity();
|
Vector velocity = record.getVelocity();
|
||||||
if (velocity.getY() == 0 && (Math.abs(velocity.getX()) < 0.001 || Math.abs(velocity.getZ()) < 0.001)) {
|
if (velocity.getY() == 0 && (Math.abs(velocity.getX()) < 0.001 || Math.abs(velocity.getZ()) < 0.001)) {
|
||||||
hasMicromotion = true;
|
hasMicromotion = true;
|
||||||
@ -112,7 +112,7 @@ public abstract class ViewFlag {
|
|||||||
seen.add(uniqueRecord.getTntId());
|
seen.add(uniqueRecord.getTntId());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (TraceRecord record : toRemove) {
|
for (TNTPoint record : toRemove) {
|
||||||
records.removeAll(record.getHistory());
|
records.removeAll(record.getHistory());
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -124,9 +124,9 @@ public abstract class ViewFlag {
|
|||||||
@Override
|
@Override
|
||||||
public void modify(REntityServer server, List<TraceEntity> entities) {
|
public void modify(REntityServer server, List<TraceEntity> entities) {
|
||||||
for (TraceEntity entity : entities) {
|
for (TraceEntity entity : entities) {
|
||||||
TraceRecord current = entity.getRecords().get(0);
|
TNTPoint current = entity.getRecords().get(0);
|
||||||
if (current.isExplosion()) continue;
|
if (current.isExplosion()) continue;
|
||||||
TraceRecord next = current.getNext().orElse(null);
|
TNTPoint next = current.getNext().orElse(null);
|
||||||
if (next == null) continue;
|
if (next == null) continue;
|
||||||
|
|
||||||
Location pos = current.getLocation().clone();
|
Location pos = current.getLocation().clone();
|
||||||
@ -214,7 +214,7 @@ public abstract class ViewFlag {
|
|||||||
* @param records Records to be filtered
|
* @param records Records to be filtered
|
||||||
* @return Filtered records
|
* @return Filtered records
|
||||||
*/
|
*/
|
||||||
public List<TraceRecord> filter(List<TraceRecord> records) {
|
public List<TNTPoint> filter(List<TNTPoint> records) {
|
||||||
return records;
|
return records;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.tracer.rendering.dynamicflags;
|
package de.steamwar.bausystem.features.tracer.rendering.dynamicflags;
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.tracer.TraceRecord;
|
import de.steamwar.bausystem.features.tracer.TNTPoint;
|
||||||
import de.steamwar.bausystem.features.tracer.rendering.ViewFlag;
|
import de.steamwar.bausystem.features.tracer.rendering.ViewFlag;
|
||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
@ -47,7 +47,7 @@ public class AtFlag extends ViewFlag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TraceRecord> filter(List<TraceRecord> records) {
|
public List<TNTPoint> filter(List<TNTPoint> records) {
|
||||||
return records.stream()
|
return records.stream()
|
||||||
.filter(record -> record.getTicksSinceStart() >= start && record.getTicksSinceStart() <= end)
|
.filter(record -> record.getTicksSinceStart() >= start && record.getTicksSinceStart() <= end)
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
@ -19,7 +19,7 @@
|
|||||||
|
|
||||||
package de.steamwar.bausystem.features.tracer.rendering.dynamicflags;
|
package de.steamwar.bausystem.features.tracer.rendering.dynamicflags;
|
||||||
|
|
||||||
import de.steamwar.bausystem.features.tracer.TraceRecord;
|
import de.steamwar.bausystem.features.tracer.TNTPoint;
|
||||||
import de.steamwar.bausystem.features.tracer.rendering.ViewFlag;
|
import de.steamwar.bausystem.features.tracer.rendering.ViewFlag;
|
||||||
|
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
@ -50,7 +50,7 @@ public class IsolateFlag extends ViewFlag {
|
|||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public List<TraceRecord> filter(List<TraceRecord> records) {
|
public List<TNTPoint> filter(List<TNTPoint> records) {
|
||||||
return records.stream()
|
return records.stream()
|
||||||
.filter(record -> tntToIsolate.contains(record.getTntId()))
|
.filter(record -> tntToIsolate.contains(record.getTntId()))
|
||||||
.collect(Collectors.toList());
|
.collect(Collectors.toList());
|
||||||
|
In neuem Issue referenzieren
Einen Benutzer sperren