Question

Ok! so I am developing a console filter plugin for my server (FTB, Monster, 1.6.4). Ive been fairly succesful in blocking the console log that i set up, However thier are a few logs im having difficulty with. Here is a section from my console:

21.04 12:43:02 [Server] Startup [2.0.2] Recieved client info from DirtyRedz
21.04 12:43:00 [Server] INFO [ConsoleFilter] Message was blocked: Sending serverside check to: DirtyRedz
21.04 12:43:00 [Server] INFO [ConsoleFilter] Checking message: Sending serverside check to: DirtyRedz
21.04 12:43:00 [Server] INFO [ConsoleFilter] Message was blocked: Loading Player: DirtyRedz
21.04 12:43:00 [Server] INFO [ConsoleFilter] Checking message: Loading Player: DirtyRedz
21.04 12:43:00 [Server] INFO Sending config data to DirtyRedz
21.04 12:43:00 [Multicraft] DirtyRedz ran command Message of the Day
21.04 12:43:00 [ConsoleFilter] Checking message: DirtyRedz ran command Message of the Day
21.04 12:43:00 [Connect] User DirtyRedz, IP 11.1.1.111
21.04 12:43:00 [Connect] User [ConsoleFilter] Checking message: DirtyRedz, IP 11.1.1.111

The logs with "[ConsoleFilter] Checking message:" im using for testing, anything that still runs after this message is becuase im allowing it. Im only having trouble with the logs below:

I have 2 problems here: 1. [Multicraft] DirtyRedz ran command Message of the Day, is being run through the logger, however it being approved before my code has a chance to check the log and stop it. whats realy curious about this log, is that if you test it if getMessage() == null, it passes true, however you can still call it with record.getMessage() and it will display.

  1. [Server] INFO Sending config data to DirtyRedz & [Server] Startup [2.0.2] Recieved client info from DirtyRedz, Are not even being processed through my logger, thus i dont have the chance to stop them.

Here is my code chunk that is relevant:

@Override
public void onEnable() {
getLogger().info("[ConsoleFilter] onEnable has been invoked!");//Bukkit has initialized ConsoleFilter

fillFromConfig();
Bukkit.getLogger().setFilter(new Filter() {

@Override
public boolean isLoggable(LogRecord record) {
getLogger().info("[ConsoleFilter] Checking message: " + record.getMessage());
Set<String> keyset=nodesHashMap.keySet();
for(String i:keyset){
String str = i;
if(consoleFiltering && !nodesHashMap.get(i).getDelete()){
if(nodesHashMap.get(i).getList() == "Contains"){
if(record.getMessage().toLowerCase().contains(str.toLowerCase())){
Date time = Calendar.getInstance().getTime();
logToFile(time + " | " + record.getLevel() +
" | " +record.getMessage(),nodesHashMap.get(i).getFile(),"Logs");
getLogger().info("[ConsoleFilter] Message was blocked: " + record.getMessage());
return false;
}
}else if(nodesHashMap.get(i).getList() == "Ends_With"){
if(record.getMessage().toLowerCase().endsWith(str.toLowerCase())){
Date time = Calendar.getInstance().getTime();
logToFile(time + " | " + record.getLevel() +
" | " +record.getMessage(),nodesHashMap.get(i).getFile(),"Logs");
getLogger().info("[ConsoleFilter] Message was blocked: " + record.getMessage());
return false;
}
}else if(nodesHashMap.get(i).getList() == "Equals"){
if(record.getMessage().toLowerCase().equals(str.toLowerCase())){
Date time = Calendar.getInstance().getTime();
logToFile(time + " | " + record.getLevel() +
" | " +record.getMessage(),nodesHashMap.get(i).getFile(),"Logs");
getLogger().info("[ConsoleFilter] Message was blocked: " + record.getMessage());
return false;
}
}
}
}
return true;
}
});
Was it helpful?

Solution

This is becuase multicraft doesnt support log filtering api's thus is written to the log no matter the case.

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top