SteamWar/BauSystem2.0
Archiviert
12
0

Docs at 90 Percent
Alle Prüfungen waren erfolgreich
SteamWarCI Build successful

Signed-off-by: D4rkr34lm <darth.m.frohn@gmail.com>
Dieser Commit ist enthalten in:
D4rkr34lm 2024-04-20 00:51:51 +02:00
Ursprung 47772ad23d
Commit 0d09db2284
9 geänderte Dateien mit 107 neuen und 4 gelöschten Zeilen

Datei anzeigen

@ -36,6 +36,9 @@ import java.io.ObjectOutput;
import java.util.List;
import java.util.Optional;
/**
* Recording of a tnt at a specific tick
*/
@Getter
public class TNTPoint implements Externalizable {
/**
@ -93,6 +96,9 @@ public class TNTPoint implements Externalizable {
*/
private List<TNTPoint> history;
/**
* Constructor for deserialization only !! Do not Call !!
*/
public TNTPoint() {
}
@ -125,16 +131,32 @@ public class TNTPoint implements Externalizable {
destroyedTestBlock = testblockDestroy;
}
/**
* Method for getting the next record of the tnt represented by this record
*
* @return the next record
*/
public Optional<TNTPoint> getNext() {
int index = history.indexOf(this);
return index == history.size() - 1 ? Optional.empty() : Optional.of(history.get(index + 1));
}
/**
* Method for getting the previous record of the tnt represented by this record
*
* @return the previous record
*/
public Optional<TNTPoint> getPrevious() {
int index = history.indexOf(this);
return index == 0 ? Optional.empty() : Optional.of(history.get(index - 1));
}
/**
* Internal methode for setting the history of this record
* during deserialization.
*
* @param history
*/
void setHistory(List<TNTPoint> history) {
this.history = history;
}
@ -158,7 +180,7 @@ public class TNTPoint implements Externalizable {
}
@Override
public void readExternal(ObjectInput objectInput) throws IOException, ClassNotFoundException {
public void readExternal(ObjectInput objectInput) throws IOException {
tntId = objectInput.readInt();
explosion = objectInput.readBoolean();
inWater = objectInput.readBoolean();

Datei anzeigen

@ -73,8 +73,17 @@ public class Trace {
*/
private SoftReference<List<TNTPoint>> records;
/**
* A map of all REntityServers rendering this trace
*/
private final Map<Player, REntityServer> entityServerMap = new HashMap<>();
/**
* Constructor for the creation of a new trace
*
* @param region the region the trace is created at
* @param recordList the list for the records making up this trace
*/
@SneakyThrows
public Trace(Region region, List<TNTPoint> recordList) {
this.uuid = UUID.randomUUID();
@ -91,6 +100,11 @@ public class Trace {
outputStream.writeObject(date);
}
/**
* Constructor for serialising a trace from the file system
*
* @param metadataSaveFile the file for this traces metadata
*/
@SneakyThrows
public Trace(File metadataSaveFile) {
String uuid = null;
@ -116,9 +130,9 @@ public class Trace {
}
/**
* Gets the historys of all tnts in this trace
* Gets the histories of all tnts in this trace
*
* @return the historys of this trace
* @return the histories of this trace
*/
public Set<List<TNTPoint>> getHistories() {
Set<List<TNTPoint>> histories = new HashSet<>();
@ -165,6 +179,13 @@ public class Trace {
render(getRecords(), entityServer, playerTraceShowData);
}
/**
* Renders specific records to this trace rendering
*
* @param records The records to be rendered
* @param player The player the records are rendered to
* @param playerTraceShowData The showData for modifying the rendering
*/
protected void render(List<TNTPoint> records, Player player, PlayerTraceShowData playerTraceShowData) {
render(records, entityServerMap.get(player), playerTraceShowData);
}
@ -260,6 +281,9 @@ public class Trace {
}
}
/**
* Hides this trace for all players
*/
public void hide() {
entityServerMap.forEach((player, entityServer) -> {
entityServer.close();
@ -267,6 +291,9 @@ public class Trace {
entityServerMap.clear();
}
/**
* Loads the records of this trace from storage to memory
*/
@SneakyThrows
private void loadRecords() {
List<TNTPoint> records = new ArrayList<>();

Datei anzeigen

@ -97,6 +97,12 @@ public class TraceManager implements Listener {
return nextOpenId;
}
/**
* Renders only the given records to the specified trace
*
* @param trace
* @param recordsToAdd
*/
protected void showPartial(Trace trace, List<TNTPoint> recordsToAdd) {
showDataPerRegionPerPlayer.getOrDefault(trace.getRegion(), Collections.emptyMap()).forEach((player, playerTraceShowData) -> {
trace.render(recordsToAdd, player, playerTraceShowData);
@ -223,6 +229,13 @@ public class TraceManager implements Listener {
});
}
/**
* Makes the given player
*
* @param follower
* @param following
* @return
*/
public boolean follow(Player follower, Player following) {
if (followerMap.containsKey(follower)) return false;
if (followerMap.entrySet().stream().anyMatch(playerSetEntry -> playerSetEntry.getValue().contains(follower))) {

Datei anzeigen

@ -24,6 +24,9 @@ import lombok.RequiredArgsConstructor;
import java.util.function.BiFunction;
/**
* A Comparator for determining whether two records should be bundled
*/
@RequiredArgsConstructor
public enum BundleFilter {

Datei anzeigen

@ -24,12 +24,21 @@ import lombok.Setter;
import java.util.*;
/**
* A holder for the view data of a player trace render
*/
public class PlayerTraceShowData {
/**
* The bundle filter applied by this class
*/
@Getter
@Setter
private BundleFilter bundleFilter;
/**
* A map for stating whether a flag is contained in this holder or not
*/
private final Map<Class<? extends ViewFlag>, ViewFlag> viewFlags = new HashMap<>();
public PlayerTraceShowData(BundleFilter bundleFilter, ViewFlag... viewFlags) {
@ -39,6 +48,12 @@ public class PlayerTraceShowData {
}
}
/**
* A methode that returns the flags that should be used by renders according
* to this holder. Especially handles inverse and required flags
*
* @return the flags that should be used in a render according to this holder
*/
public Set<ViewFlag> getEffectiveViewFlags() {
// Manage flags and required flags
Set<ViewFlag> flagList = new HashSet<>();

Datei anzeigen

@ -34,6 +34,9 @@ import org.bukkit.entity.Player;
import java.util.List;
/**
* Wrapper for the rendering of a record bundle
*/
public class TraceEntity extends REntity {
private static final Reflection.MethodInvoker addEntityMethod = Reflection.getMethod(REntityServer.class, "addEntity", REntity.class);
@ -51,6 +54,11 @@ public class TraceEntity extends REntity {
addEntityMethod.invoke(server, this);
}
/**
* Message for printing the data contained in this wrapper into player chat
*
* @param player the player the message should be printed for
*/
public void printIntoChat(Player player) {
TNTPoint representative = records.get(0);

Datei anzeigen

@ -32,6 +32,9 @@ import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* A settable flag that changes how a trace is rendered
*/
public abstract class ViewFlag {
/**
* Static registry of static flags
@ -39,7 +42,7 @@ public abstract class ViewFlag {
public static final List<ViewFlag> flags = new ArrayList<>();
/**
* Inverse flags are used by trace render by default, as long as they are not explicidly added as argument
* Inverse flags are used by trace render by default, as long as they are not explicitly added as argument
*/
public static final List<ViewFlag> inverseFlags = new ArrayList<>();

Datei anzeigen

@ -25,8 +25,17 @@ import de.steamwar.bausystem.features.tracer.rendering.ViewFlag;
import java.util.List;
import java.util.stream.Collectors;
/**
* A view flag for rendering a trace only in a given time intervall
*/
public class AtFlag extends ViewFlag {
/**
* Start of the time interval
*/
private int start;
/**
* End of the time interval
*/
private int end;
public AtFlag(int start, int end) {

Datei anzeigen

@ -27,6 +27,9 @@ import java.util.List;
import java.util.Set;
import java.util.stream.Collectors;
/**
* A flag for rendering only the records of specific tnts
*/
public class IsolateFlag extends ViewFlag {
/**