From 0d09db2284861f6c46a5c2b33afa57e906fca175 Mon Sep 17 00:00:00 2001 From: D4rkr34lm Date: Sat, 20 Apr 2024 00:51:51 +0200 Subject: [PATCH] Docs at 90 Percent Signed-off-by: D4rkr34lm --- .../bausystem/features/tracer/TNTPoint.java | 24 +++++++++++++- .../bausystem/features/tracer/Trace.java | 31 +++++++++++++++++-- .../features/tracer/TraceManager.java | 13 ++++++++ .../tracer/rendering/BundleFilter.java | 3 ++ .../tracer/rendering/PlayerTraceShowData.java | 15 +++++++++ .../tracer/rendering/TraceEntity.java | 8 +++++ .../features/tracer/rendering/ViewFlag.java | 5 ++- .../tracer/rendering/dynamicflags/AtFlag.java | 9 ++++++ .../rendering/dynamicflags/IsolateFlag.java | 3 ++ 9 files changed, 107 insertions(+), 4 deletions(-) diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TNTPoint.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TNTPoint.java index 42c6d662..7a5d5425 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TNTPoint.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TNTPoint.java @@ -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 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 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 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 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(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/Trace.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/Trace.java index 655cab4c..fd2c9cf4 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/Trace.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/Trace.java @@ -73,8 +73,17 @@ public class Trace { */ private SoftReference> records; + /** + * A map of all REntityServers rendering this trace + */ private final Map 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 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> getHistories() { Set> 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 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 records = new ArrayList<>(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceManager.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceManager.java index bf853943..e6dd941c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceManager.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/TraceManager.java @@ -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 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))) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/BundleFilter.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/BundleFilter.java index d6ba6b8b..9380b3f8 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/BundleFilter.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/BundleFilter.java @@ -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 { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/PlayerTraceShowData.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/PlayerTraceShowData.java index aedfba16..4029f2e2 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/PlayerTraceShowData.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/PlayerTraceShowData.java @@ -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, 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 getEffectiveViewFlags() { // Manage flags and required flags Set flagList = new HashSet<>(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/TraceEntity.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/TraceEntity.java index f88d0eab..273d9ecc 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/TraceEntity.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/TraceEntity.java @@ -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); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/ViewFlag.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/ViewFlag.java index 5e2c4626..d8910c4e 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/ViewFlag.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/ViewFlag.java @@ -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 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 inverseFlags = new ArrayList<>(); diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/dynamicflags/AtFlag.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/dynamicflags/AtFlag.java index d57c36e0..5ad1157b 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/dynamicflags/AtFlag.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/dynamicflags/AtFlag.java @@ -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) { diff --git a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/dynamicflags/IsolateFlag.java b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/dynamicflags/IsolateFlag.java index 9fafd7a7..723e7d9c 100644 --- a/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/dynamicflags/IsolateFlag.java +++ b/BauSystem_Main/src/de/steamwar/bausystem/features/tracer/rendering/dynamicflags/IsolateFlag.java @@ -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 { /**