Created
May 30, 2020 11:14
-
-
Save clienthax/30c4e59f9d9fe65d7ce92901e4bfb453 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package uk.co.haxyshideout.logparser; | |
import java.io.File; | |
import java.io.Serializable; | |
import java.nio.file.Files; | |
import java.util.*; | |
import static java.util.Map.Entry.comparingByValue; | |
import static java.util.stream.Collectors.toMap; | |
public class ChunkLoads { | |
public static void main(String[] args) throws Exception { | |
new ChunkLoads(); | |
} | |
public ChunkLoads() throws Exception { | |
File logFile = new File("C:\\Users\\clienthax\\Downloads\\latest (35).log"); | |
List<String> lines = Files.readAllLines(logFile.toPath()); | |
lines.add("YEET");//Incase we downloaded log half way through a trace | |
HashMap<List<String>, List<String>> stacksToLocations = new HashMap<>(); | |
for (int i = 0; i < lines.size(); i++) { | |
String s = lines.get(i); | |
if (!s.contains("[Sponge]: Load Chunk At")) { | |
continue; | |
} | |
//[14:33:31] [Server thread/INFO] [Sponge]: Load Chunk At [0] (602, -1,762) | |
s = s.replaceAll(",", ""); | |
s = s.substring(s.indexOf("(")+1, s.length()-1); | |
final String[] s1 = s.split(" "); | |
final String chunkX = s1[0]; | |
final String chunkY = s1[1]; | |
List<String> stack = new ArrayList<>(); | |
i += 3; | |
while ((s = lines.get(i)).contains("\tat ")) { | |
stack.add(s); | |
i++; | |
} | |
boolean foundIgnoreStack = false; | |
for (String s2 : stack) { | |
if (s2.contains("Spawn") || s2.contains("XUChunkLoaderManager")) { | |
foundIgnoreStack = true; | |
} | |
} | |
if (!foundIgnoreStack) { | |
//System.out.println(chunkX+" "+chunkY); | |
for (String s2 : stack) { | |
//System.out.println(s2); | |
} | |
//System.out.println(); | |
} | |
//System.out.println(chunkX +" "+chunkY); | |
//System.out.println(stack); | |
final List<String> list = stacksToLocations.getOrDefault(stack, new ArrayList<>()); | |
list.add(chunkX+" "+chunkY); | |
stacksToLocations.put(stack, list); | |
} | |
Map<List<String>, List<String>> sorted = stacksToLocations | |
.entrySet() | |
.stream() | |
.sorted(comparingByValue(Comparator.comparingInt(List::size))) | |
.collect(toMap( | |
Map.Entry::getKey, | |
Map.Entry::getValue, | |
(a, b) -> { throw new AssertionError(); }, | |
LinkedHashMap::new | |
)); | |
for (Map.Entry<List<String>, List<String>> entry : sorted.entrySet()) { | |
System.out.println("Chunks loaded "+ entry.getValue().size() + " "+ entry.getValue()); | |
for (String s : entry.getKey()) { | |
System.out.println(s); | |
} | |
System.out.println(); | |
} | |
} | |
class Info { | |
List<String> chunksLoaded; | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment