diff options
author | Keuin <[email protected]> | 2020-12-29 10:10:22 +0800 |
---|---|---|
committer | Keuin <[email protected]> | 2020-12-29 10:10:22 +0800 |
commit | b773bf20f143ecb31b3ea53aefd08d266707de5d (patch) | |
tree | e1eccbec74a4782b22aa4f5d5afa11b3ffb5785a /src/main/java/com/keuin | |
parent | 9ce008141191b67cc00f871299891dbd874aff1f (diff) |
Add log entry v2 and transformer
Diffstat (limited to 'src/main/java/com/keuin')
4 files changed, 13 insertions, 6 deletions
diff --git a/src/main/java/com/keuin/blame/data/entry/LogEntry.java b/src/main/java/com/keuin/blame/data/entry/LogEntry.java index 0ffaf94..77098c5 100644 --- a/src/main/java/com/keuin/blame/data/entry/LogEntry.java +++ b/src/main/java/com/keuin/blame/data/entry/LogEntry.java @@ -3,6 +3,7 @@ package com.keuin.blame.data.entry; import com.keuin.blame.data.WorldPos; import com.keuin.blame.data.enums.ActionType; import com.keuin.blame.data.enums.ObjectType; +import com.keuin.blame.util.MinecraftUtil; import com.keuin.blame.util.PrettyUtil; import com.keuin.blame.util.UuidUtils; import net.minecraft.MinecraftVersion; @@ -88,6 +89,7 @@ public class LogEntry { this.objectType = entry.objectType; this.objectId = entry.objectId; this.objectPos = entry.objectPos; + this.radius = entry.radius; } public LogEntry(long timeMillis, String subjectId, UUID subjectUUID, WorldPos subjectPos, ActionType actionType, ObjectType objectType, String objectId, WorldPos objectPos) { @@ -106,6 +108,7 @@ public class LogEntry { if (objectPos == null) throw new IllegalArgumentException("objectPos cannot be null"); + // v1 params this.subjectId = subjectId; this.timeMillis = timeMillis; this.subjectUUID = subjectUUID; @@ -114,6 +117,9 @@ public class LogEntry { this.objectType = objectType; this.objectId = objectId; this.objectPos = objectPos; + + // v2 params + this.radius = MinecraftUtil.getRadius(objectPos); } @Override diff --git a/src/main/java/com/keuin/blame/data/entry/LogEntryNames.java b/src/main/java/com/keuin/blame/data/entry/LogEntryNames.java index e375d8e..180f478 100644 --- a/src/main/java/com/keuin/blame/data/entry/LogEntryNames.java +++ b/src/main/java/com/keuin/blame/data/entry/LogEntryNames.java @@ -11,5 +11,5 @@ public class LogEntryNames { public static final String OBJECT_TYPE = "object_type"; public static final String OBJECT_ID = "object_id"; public static final String OBJECT_POS = "object_pos"; - public static final String RADIUS = "radius"; + public static final String RADIUS = "object_radius"; } diff --git a/src/main/java/com/keuin/blame/data/transformer/LogEntryV1ToV2Transformer.java b/src/main/java/com/keuin/blame/data/transformer/LogEntryV1ToV2Transformer.java index 4f5c660..5172413 100644 --- a/src/main/java/com/keuin/blame/data/transformer/LogEntryV1ToV2Transformer.java +++ b/src/main/java/com/keuin/blame/data/transformer/LogEntryV1ToV2Transformer.java @@ -1,7 +1,7 @@ package com.keuin.blame.data.transformer; -import com.keuin.blame.data.WorldPos; import com.keuin.blame.data.entry.LogEntry; +import com.keuin.blame.util.MinecraftUtil; public class LogEntryV1ToV2Transformer extends AbstractLogEntryTransformer { @@ -24,11 +24,8 @@ public class LogEntryV1ToV2Transformer extends AbstractLogEntryTransformer { entryV2.objectType = entry.objectType; entryV2.objectId = entry.objectId; entryV2.objectPos = entry.objectPos; - entryV2.radius = getRadius(entry.objectPos); + entryV2.radius = MinecraftUtil.getRadius(entry.objectPos); return entryV2; } - private static double getRadius(WorldPos objectPos) { - return Math.sqrt(Math.pow(objectPos.getX(), 2) + Math.pow(objectPos.getY(), 2) + Math.pow(objectPos.getZ(), 2)); - } } diff --git a/src/main/java/com/keuin/blame/util/MinecraftUtil.java b/src/main/java/com/keuin/blame/util/MinecraftUtil.java index ce8707e..2dc1676 100644 --- a/src/main/java/com/keuin/blame/util/MinecraftUtil.java +++ b/src/main/java/com/keuin/blame/util/MinecraftUtil.java @@ -1,5 +1,6 @@ package com.keuin.blame.util; +import com.keuin.blame.data.WorldPos; import net.minecraft.world.World; public class MinecraftUtil { @@ -8,4 +9,7 @@ public class MinecraftUtil { return world.getRegistryKey().getValue().toString(); } + public static double getRadius(WorldPos objectPos) { + return Math.sqrt(Math.pow(objectPos.getX(), 2) + Math.pow(objectPos.getY(), 2) + Math.pow(objectPos.getZ(), 2)); + } } |