nakashimi Posted June 3, 2012 Posted June 3, 2012 Index: /Trunk/L2_GameServer/java/net/sf/l2j/Config.java =================================================================== --- /Trunk/L2_GameServer/java/net/sf/l2j/Config.java (revision 144) +++ /Trunk/L2_GameServer/java/net/sf/l2j/Config.java (revision 147) @@ -760,4 +760,5 @@ public static int ADD_EXP; public static int ADD_SP; + public static boolean PETICION_LOGGING; //-------------------------------------------------- @@ -1507,4 +1508,5 @@ ADD_EXP = Integer.parseInt(altsettingsSettings.getProperty("AddExpAtPvp", "0")); ADD_SP = Integer.parseInt(altsettingsSettings.getProperty("AddSpAtPvp", "0")); + PETICION_LOGGING = Boolean.parseBoolean(altsettingsSettings.getProperty("EnablePeticionLogging", "False")); } catch (Exception e) Index: /Trunk/L2_GameServer/java/net/sf/l2j/gameserver/instancemanager/PetitionManager.java =================================================================== --- /Trunk/L2_GameServer/java/net/sf/l2j/gameserver/instancemanager/PetitionManager.java (revision 124) +++ /Trunk/L2_GameServer/java/net/sf/l2j/gameserver/instancemanager/PetitionManager.java (revision 147) @@ -15,8 +15,12 @@ package net.sf.l2j.gameserver.instancemanager; +import java.io.File; +import java.io.FileWriter; +import java.io.IOException; import java.text.SimpleDateFormat; import java.util.Date; import java.util.List; import java.util.Map; +import java.util.logging.Level; import java.util.logging.Logger; @@ -606,3 +610,46 @@ activeChar.sendPacket(htmlMsg); } + + public static synchronized void logResult(String petitioner, String responder, long submitTime, long endTime, String content) + { + if (!Config.PETICION_LOGGING) return; + + SimpleDateFormat formatter; + formatter = new SimpleDateFormat("dd/MM/yyyy H:mm:ss"); + String date = formatter.format(new Date()); + FileWriter save = null; + try + { + File file = new File("log/peticion.csv"); + + boolean writeHead = false; + if (!file.exists()) + writeHead = true; + + save = new FileWriter(file, true); + + if (writeHead) + { + String header = "Date,petitioner,responder,submitTime,endTime,content\r\n"; + save.write(header); + } + + String out = date + "," + petitioner + "," + responder + "," + submitTime + "," + endTime + "," + content + "\r\n"; + save.write(out); + } + catch (IOException e) + { + _log.log(Level.WARNING, "Peticion System: Peticion log could not be saved: ", e); + } + finally + { + try + { + save.close(); + } + catch (Exception e) + { + } + } + } } config/AltSettings.properties + +#--------------------------------------------------------------- +# Peticion settings - +#--------------------------------------------------------------- +# Log peticions to log/peticions.csv +# Only for testing yet! +EnablePeticionLogging = False
[DEV]DjSt3rios Posted June 6, 2012 Posted June 6, 2012 Ehmm.. didn't you forget something? The function looks cool, but you never used it somewhere. Probably you didn't post it. Not everybody knows where to place the command with the right arguments. You should fix your post. Except that, It looks pretty good.
niko001 Posted June 7, 2012 Posted June 7, 2012 sorry, but Index are not l2jserver are L2JFree pack or other the imports L2JServer are: com/l2jserver/ not net/sf/l2j fix the code or title. regards EDIT: You should also accommodate some Imports for l2jserver
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now