Jump to content

[L2JServer] Log Petitions


Recommended Posts

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

Link to comment
Share on other sites

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.

Link to comment
Share on other sites

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

Link to comment
Share on other sites

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.



×
×
  • Create New...