diff options
| author | Cow <cow@volloeko.de> | 2021-04-23 14:43:24 +0200 |
|---|---|---|
| committer | Cow <cow@volloeko.de> | 2021-04-23 14:43:24 +0200 |
| commit | c4392eb697e507340454a8735e7b4d3bd297f5f1 (patch) | |
| tree | f5cc857d8b9e5c8f9032d590b456663d5ad3123b /src/main/java/de/cowtipper/cowlection/search | |
| parent | 35f5d00656a968a003dd42b9150c9f19b1f3c9fd (diff) | |
| download | Cowlection-c4392eb697e507340454a8735e7b4d3bd297f5f1.tar.gz Cowlection-c4392eb697e507340454a8735e7b4d3bd297f5f1.tar.bz2 Cowlection-c4392eb697e507340454a8735e7b4d3bd297f5f1.zip | |
Added Chest Tracker & Analyzer
Diffstat (limited to 'src/main/java/de/cowtipper/cowlection/search')
3 files changed, 82 insertions, 2 deletions
diff --git a/src/main/java/de/cowtipper/cowlection/search/GuiSearch.java b/src/main/java/de/cowtipper/cowlection/search/GuiSearch.java index ae17d32..21059ca 100644 --- a/src/main/java/de/cowtipper/cowlection/search/GuiSearch.java +++ b/src/main/java/de/cowtipper/cowlection/search/GuiSearch.java @@ -4,7 +4,6 @@ import com.google.common.util.concurrent.ThreadFactoryBuilder; import com.mojang.realmsclient.util.Pair; import de.cowtipper.cowlection.Cowlection; import de.cowtipper.cowlection.config.MooConfig; -import de.cowtipper.cowlection.data.LogEntry; import de.cowtipper.cowlection.util.GuiHelper; import de.cowtipper.cowlection.util.Utils; import net.minecraft.client.Minecraft; diff --git a/src/main/java/de/cowtipper/cowlection/search/LogEntry.java b/src/main/java/de/cowtipper/cowlection/search/LogEntry.java new file mode 100644 index 0000000..cd86a78 --- /dev/null +++ b/src/main/java/de/cowtipper/cowlection/search/LogEntry.java @@ -0,0 +1,82 @@ +package de.cowtipper.cowlection.search; + +import net.minecraft.util.EnumChatFormatting; +import org.apache.commons.lang3.builder.EqualsBuilder; +import org.apache.commons.lang3.builder.HashCodeBuilder; + +import java.nio.file.Path; +import java.time.LocalDateTime; +import java.util.regex.Pattern; + +public class LogEntry { + private static final Pattern UTF_PARAGRAPH_SYMBOL = Pattern.compile("§"); + private LocalDateTime time; + private Path filePath; + private String message; + + public LogEntry(LocalDateTime time, Path filePath, String logEntry) { + this.time = time; + this.filePath = filePath; + this.message = logEntry; + } + + public LogEntry(String message) { + this.message = message; + } + + public LocalDateTime getTime() { + return time; + } + + public Path getFilePath() { + return filePath; + } + + public String getMessage() { + return message; + } + + public void addLogLine(String logLine) { + message += "\n" + logLine; + } + + public void removeFormatting() { + this.message = EnumChatFormatting.getTextWithoutFormattingCodes(message); + } + + public void fixWeirdCharacters() { + if (message.contains("§")) { + message = UTF_PARAGRAPH_SYMBOL.matcher(message).replaceAll("§"); + } + } + + /** + * Is this log entry a 'real' log entry or just an error message from the search process? + * + * @return true if error message, otherwise false + */ + public boolean isError() { + return time == null && filePath == null; + } + + @Override + public boolean equals(Object o) { + if (this == o) return true; + if (o == null || getClass() != o.getClass()) return false; + LogEntry logEntry = (LogEntry) o; + return new EqualsBuilder() + .append(time, logEntry.time) + .append(filePath, logEntry.filePath) + .append(message, logEntry.message) + .isEquals(); + } + + @Override + public int hashCode() { + return new HashCodeBuilder(17, 37) + .append(time) + .append(filePath) + .append(message) + .toHashCode(); + } +} diff --git a/src/main/java/de/cowtipper/cowlection/search/LogFilesSearcher.java b/src/main/java/de/cowtipper/cowlection/search/LogFilesSearcher.java index 0d292ae..a3ed781 100644 --- a/src/main/java/de/cowtipper/cowlection/search/LogFilesSearcher.java +++ b/src/main/java/de/cowtipper/cowlection/search/LogFilesSearcher.java @@ -2,7 +2,6 @@ package de.cowtipper.cowlection.search; import com.mojang.realmsclient.util.Pair; import de.cowtipper.cowlection.config.MooConfig; -import de.cowtipper.cowlection.data.LogEntry; import net.minecraft.util.EnumChatFormatting; import org.apache.commons.lang3.StringUtils; import org.apache.commons.lang3.tuple.ImmutableTriple; |
