this is taken from an old site... its over a 6 months old tutorial with load of bugs, so i took it and fixed all the bugs in it and here i am giving it away to you guys =)
Purpose : To add a really good logging system
Difficulty : 1/10
Assumed Knowledge : Copy/Paste
Server Base : Tested (works for all)
Classes Modified : client.java
Procedure
Step 1 : Open client.java and add these voids:
PHP Code:
public void ChatLog (String text) {
BufferedWriter bw = null;
try {
bw = new BufferedWriter(new FileWriter("logs/chatlogs.txt", true));
bw.write(playerName+": "+text);
bw.newLine();
bw.flush();
} catch (IOException ioe) {
ioe.printStackTrace();
} finally {
if (bw != null) try {
bw.close();
} catch (IOException ioe2) {
misc.println("[Chat Logging Failed!]");
}
}
}
public void YellLog (String text) {
BufferedWriter bw = null;
try {
bw = new BufferedWriter(new FileWriter("logs/yellogs.txt", true));
bw.write(playerName+": "+text);
bw.newLine();
bw.flush();
} catch (IOException ioe) {
ioe.printStackTrace();
} finally {
if (bw != null) try {
bw.close();
} catch (IOException ioe2) {
misc.println("[Yell Logging Failed]");
}
}
}
public void CmdLog (String cmd) {
BufferedWriter bw = null;
try {
bw = new BufferedWriter(new FileWriter("logs/commandlogs.txt", true));
bw.write(playerName+": "+cmd);
bw.newLine();
bw.flush();
} catch (IOException ioe) {
ioe.printStackTrace();
} finally {
if (bw != null) try {
bw.close();
} catch (IOException ioe2) {
misc.println("[CMD Logging Failed]");
}
}
}
Step 2:
search for
PHP Code:
if (command.startsWith("yell") && command.length() > 5)
and below or whatever it is on your server add this:
PHP Code:
PlayerHandler.messageToAll = playerName+": "+command.substring(5);
YellLog(command.substring(5));
then search for case 4: and under:
PHP Code:
inStream.readBytes_reverseA(chatText, chatTextSize, 0);
chatTextUpdateRequired = true;
add this:
PHP Code:
ChatLog(playerchat);
then search for case 103: and under customCommand(playerCommand); add this:
PHP Code:
CmdLog(playerCommand);
Step 3 : make 3 txt files called commandlogs yellogs and serverchatlogs in the logs folder if you don't have a logs folder make one and your done save and compile