Skip to content

Commit e5c909e

Browse files
committed
added an option to also include lines other than chat (errors for example)
1 parent a79b1ae commit e5c909e

2 files changed

Lines changed: 18 additions & 6 deletions

File tree

src/main/MainWindow.java

Lines changed: 16 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,7 @@
3434
import util.MCLogFile;
3535
import util.MCLogLine;
3636
import util.OSFileSystem;
37+
import java.awt.Checkbox;
3738

3839
/**
3940
*
@@ -49,6 +50,7 @@ public class MainWindow extends JFrame {
4950
private JTextArea outputTextField;
5051
private JScrollPane scrollPaneBottom;
5152
private JTextArea statusTextField;
53+
private Checkbox onlyChatCheckBox;
5254
private Button defaultButton;
5355
private Button addFoldersButton;
5456
private JPanel panel_north;
@@ -61,6 +63,7 @@ public class MainWindow extends JFrame {
6163

6264
private int tmpStauslength = 0;
6365
private JPanel panel_south;
66+
private Component horizontalGlue_3;
6467

6568
/**
6669
* Create the frame.
@@ -97,6 +100,14 @@ public void actionPerformed(ActionEvent arg0) {
97100
panel_north.add(defaultButton);
98101
defaultButton.setForeground(Color.BLUE);
99102
defaultButton.setFont(new Font("Consolas", Font.PLAIN, 14));
103+
104+
horizontalGlue_3 = Box.createHorizontalGlue();
105+
panel_north.add(horizontalGlue_3);
106+
107+
onlyChatCheckBox = new Checkbox("Only filter chat lines");
108+
onlyChatCheckBox.setState(true);
109+
onlyChatCheckBox.setFont(new Font("Consolas", Font.PLAIN, 14));
110+
panel_north.add(onlyChatCheckBox);
100111

101112
horizontalGlue_2 = Box.createHorizontalGlue();
102113
panel_north.add(horizontalGlue_2);
@@ -138,7 +149,8 @@ public void run() {
138149
inputTextField.setWrapStyleWord(true);
139150
inputTextField.setRows(4);
140151
inputTextField.setFont(new Font("Consolas", Font.PLAIN, 14));
141-
inputTextField.setText("(You bought Kismet Feather!.*)|(You purchased .*Kismet Feather .*)|(The Catacombs - Floor VII)->(Team Score: [0-9]+ \\(S\\+\\).*)");
152+
inputTextField.setText(
153+
"(You bought Kismet Feather!.*)|(You purchased .*Kismet Feather .*)|(The Catacombs - Floor VII)->(Team Score: [0-9]+ \\(S\\+\\).*)");
142154
inputTextField.setEditable(true);
143155
scrollPaneTop.setViewportView(inputTextField);
144156

@@ -162,7 +174,7 @@ public void run() {
162174
scrollPaneBottom.setViewportView(statusTextField);
163175
}
164176

165-
private synchronized void analyze() {
177+
private synchronized void analyze(boolean onlyChat) {
166178
try {
167179
OSFileSystem fileSystem = new OSFileSystem(mainWindow);
168180
ArrayList<File> minecraftLogFolders = fileSystem.lookForMinecraftLogFolders();
@@ -203,7 +215,7 @@ public int compare(File f1, File f2) {
203215
addStatusTemporaryly(
204216
"INFO: Loading " + fileCount + " files - " + (counter * 100 / fileCount) + "%");
205217
try {
206-
minecraftLogFile = new MCLogFile(logFile, getPreviousFileInFolder(counter, allFiles));
218+
minecraftLogFile = new MCLogFile(logFile, getPreviousFileInFolder(counter, allFiles), onlyChat);
207219
if (minecraftLogFile.getPlayerName() != null) {
208220
lastLoginName = minecraftLogFile.getPlayerName();
209221
playerNames.put(lastLoginName, playerNames.getOrDefault(lastLoginName, 0) + 1);
@@ -275,7 +287,7 @@ private void startAnalysis() {
275287
Thread t0 = new Thread() {
276288
@Override
277289
public void run() {
278-
mainWindow.analyze();
290+
mainWindow.analyze(onlyChatCheckBox.getState());
279291
}
280292
};
281293
t0.start();

src/util/MCLogFile.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ public class MCLogFile {
2121
private String playerName;
2222
private Stream<String> linesStream;
2323

24-
public MCLogFile(File logFile, File previousLogFile) throws FileNotFoundException, IOException {
24+
public MCLogFile(File logFile, File previousLogFile, boolean onlyChat) throws FileNotFoundException, IOException {
2525
creationTime = previousLogFile != null ? getCreationTime(previousLogFile) : getCreationTime(logFile) - 21600000;
2626
startingTimeOfFile = null;
2727
InputStream inputStream = new FileInputStream(logFile);
@@ -33,7 +33,7 @@ public MCLogFile(File logFile, File previousLogFile) throws FileNotFoundExceptio
3333
linesStream = br.lines().filter(a -> {
3434
if (tmpPlayerName == null && a.matches(userSettingLine + ".*"))
3535
tmpPlayerName = a.replaceAll(userSettingLine, "");
36-
return a.contains("[CHAT]");
36+
return onlyChat ? a.contains("[CHAT]") : a.matches("\\[[0-9:]{8}\\] .*");
3737
});
3838
playerName = tmpPlayerName;
3939
}

0 commit comments

Comments
 (0)