Jump to content

[SHARE]Log petition


Recommended Posts

Save peticions into the log/peticion.csv

 

UNTESTED i code it 2min ago give me feedback about it.

 

credits to me.

 

Index: /Trunk/L2_GameServer/java/config/Maxcheaters.properties
===================================================================
--- /Trunk/L2_GameServer/java/config/Maxcheaters.properties (revision 144)
+++ /Trunk/L2_GameServer/java/config/Maxcheaters.properties (revision 147)
@@ -313,2 +313,9 @@
EvilBaseY = -112524
EvilBaseZ = -235
+
+#---------------------------------------------------------------
+# Peticion settings                                            -
+#---------------------------------------------------------------
+# Log peticions to log/peticions.csv
+# Only for testing yet!
+EnablePeticionLogging = False
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(maxcheatersSettings.getProperty("AddExpAtPvp", "0"));
					ADD_SP = Integer.parseInt(maxcheatersSettings.getProperty("AddSpAtPvp", "0"));
+					PETICION_LOGGING = Boolean.parseBoolean(maxcheatersSettings.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)
+					{
+					}
+				}
+			}
}

Link to comment
Share on other sites

  • 2 months later...
  • 10 months later...

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...