Got Rid of Exception, replaced with BRUTE FORCE SEARCH
I am going to find that *god damn metrics file* if it's the last thing I do
This commit is contained in:
parent
e01e9d3f3e
commit
96ed0ffc07
2 changed files with 53 additions and 16 deletions
|
@ -11,7 +11,7 @@ import alisolarflare.components.metrics.files.MetricsFile;
|
||||||
import alisolarflare.components.metrics.output.GetLoginMetrics;
|
import alisolarflare.components.metrics.output.GetLoginMetrics;
|
||||||
|
|
||||||
public class MetricsComponent extends Component{
|
public class MetricsComponent extends Component{
|
||||||
String defaultPath = "/AliPresents/metrics";
|
String defaultPath = "metrics";
|
||||||
String defaultFilePath = (defaultPath + "/metrics.txt");
|
String defaultFilePath = (defaultPath + "/metrics.txt");
|
||||||
String playerLoginsFilePath = (defaultPath + "/playerLogins.txt");
|
String playerLoginsFilePath = (defaultPath + "/playerLogins.txt");
|
||||||
|
|
||||||
|
|
|
@ -13,41 +13,78 @@ import java.util.List;
|
||||||
import buttondevteam.lib.TBMCCoreAPI;
|
import buttondevteam.lib.TBMCCoreAPI;
|
||||||
|
|
||||||
public class MetricsFile {
|
public class MetricsFile {
|
||||||
private String fileName = "/AliPresents/metrics/playerLogins.txt";
|
private String fileName = "AliPresents/metrics/playerLogins.txt";
|
||||||
public MetricsFile(String directory){
|
public MetricsFile(String directory){
|
||||||
this.fileName = directory;
|
this.fileName = directory;
|
||||||
}
|
}
|
||||||
public void AddLine(String string){
|
public void AddLine(String string){
|
||||||
BufferedWriter inputStream = null;
|
BufferedWriter inputStream = null;
|
||||||
try {
|
String[] fileNames = {
|
||||||
File file = new File(fileName);
|
"/AliPresents/metrics/playerLogins.txt",
|
||||||
TBMCCoreAPI.sendDebugMessage("Metrics File Exists: " + file.exists());
|
"AliPresents/metrics/playerLogins.txt",
|
||||||
inputStream = new BufferedWriter(new FileWriter(fileName, true));
|
"/metrics/playerLogins.txt",
|
||||||
TBMCCoreAPI.sendDebugMessage("Input Stream Created!");
|
"metrics/playerLogins.txt",
|
||||||
inputStream.write(string);
|
"/playerLogins.txt",
|
||||||
inputStream.newLine();
|
"playerLogins.txt",
|
||||||
inputStream.close();
|
|
||||||
} catch (IOException e) {
|
|
||||||
TBMCCoreAPI.SendException(fileName +" Input Stream could not be created! ", e);
|
"/AliPresents/metrics/playerLogins",
|
||||||
|
"AliPresents/metrics/playerLogins",
|
||||||
|
"/metrics/playerLogins",
|
||||||
|
"metrics/playerLogins",
|
||||||
|
"/playerLogins",
|
||||||
|
"playerLogins",
|
||||||
|
|
||||||
|
".AliPresents.metrics.playerLogins.txt",
|
||||||
|
"AliPresents.metrics.playerLogins.txt",
|
||||||
|
".metrics.playerLogins.txt",
|
||||||
|
"metrics.playerLogins.txt",
|
||||||
|
".playerLogins.txt",
|
||||||
|
"playerLogins.txt",
|
||||||
|
|
||||||
|
};
|
||||||
|
for(String fileName: fileNames){
|
||||||
|
try {
|
||||||
|
TBMCCoreAPI.sendDebugMessage("Trying to Open File: "+fileName+"...");
|
||||||
|
File file = new File(fileName);
|
||||||
|
TBMCCoreAPI.sendDebugMessage("File Exists: " + file.exists());
|
||||||
|
inputStream = new BufferedWriter(new FileWriter(fileName, true));
|
||||||
|
TBMCCoreAPI.sendDebugMessage("Input Stream Created!");
|
||||||
|
TBMCCoreAPI.sendDebugMessage("Trying to write to file...");
|
||||||
|
inputStream.write(string);
|
||||||
|
TBMCCoreAPI.sendDebugMessage("Ending with newLine...");
|
||||||
|
inputStream.newLine();
|
||||||
|
TBMCCoreAPI.sendDebugMessage("Closing File...");
|
||||||
|
inputStream.close();
|
||||||
|
TBMCCoreAPI.sendDebugMessage("File Closed!");
|
||||||
|
} catch (IOException e) {
|
||||||
|
TBMCCoreAPI.sendDebugMessage(fileName +" Input Stream could not be created! ");
|
||||||
|
TBMCCoreAPI.sendDebugMessage(e.toString());
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
public List<String> toArrayList(){
|
public List<String> toArrayList(){
|
||||||
BufferedReader outputStream = null;
|
BufferedReader outputStream = null;
|
||||||
try {
|
try {
|
||||||
outputStream = new BufferedReader(new FileReader(fileName));
|
TBMCCoreAPI.sendDebugMessage("Creating FileReader: "+fileName);
|
||||||
|
FileReader reader = new FileReader(fileName);
|
||||||
|
TBMCCoreAPI.sendDebugMessage("Creating BufferedReader...");
|
||||||
|
outputStream = new BufferedReader(reader);
|
||||||
|
|
||||||
List<String> outputList = new ArrayList<String>();
|
List<String> outputList = new ArrayList<String>();
|
||||||
String currentLine;
|
String currentLine;
|
||||||
|
|
||||||
while ((currentLine = outputStream.readLine()) != null){
|
while ((currentLine = outputStream.readLine()) != null){
|
||||||
outputList.add(currentLine);
|
outputList.add(currentLine);
|
||||||
}
|
}
|
||||||
|
TBMCCoreAPI.sendDebugMessage("Message! "+outputList.toString());
|
||||||
outputStream.close();
|
outputStream.close();
|
||||||
return outputList;
|
return outputList;
|
||||||
} catch (FileNotFoundException e) {
|
} catch (FileNotFoundException e) {
|
||||||
TBMCCoreAPI.SendException(fileName + " could not be found", e);
|
TBMCCoreAPI.sendDebugMessage(fileName + " could not be found");
|
||||||
|
TBMCCoreAPI.sendDebugMessage(e.toString());
|
||||||
} catch (IOException e1) {
|
} catch (IOException e1) {
|
||||||
TBMCCoreAPI.SendException(fileName + "encountered an I/O Exception!", e1);
|
TBMCCoreAPI.SendException(fileName + "encountered an I/O Exception!", e1);
|
||||||
|
TBMCCoreAPI.sendDebugMessage(e1.toString());
|
||||||
}
|
}
|
||||||
return new ArrayList<String>();
|
return new ArrayList<String>();
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue