Jump to content

Recommended Posts

Posted

Hey guys, I came up with this idea while needing to write down multiple locations.

When you use the /loc command, a text file is created (only the first time) and stores all the locations you debug.

 

Output:

image.png.821ff0cf2017c8880d0c5af006f6d0bc.png

 

--- a/aCis_gameserver/java/net/sf/l2j/gameserver/handler/usercommandhandlers/Loc.java
+++ b/aCis_gameserver/java/net/sf/l2j/gameserver/handler/usercommandhandlers/Loc.java
@@ -1,5 +1,10 @@
 package net.sf.l2j.gameserver.handler.usercommandhandlers;
 
+import java.io.BufferedWriter;
+import java.io.File;
+import java.io.FileWriter;
+import java.io.IOException;
+
 import net.sf.l2j.gameserver.data.xml.MapRegionData;
 import net.sf.l2j.gameserver.handler.IUserCommandHandler;
 import net.sf.l2j.gameserver.model.actor.Player;
@@ -13,6 +18,7 @@
 		0
 	};
 	
+	@SuppressWarnings("resource")
 	@Override
 	public void useUserCommand(int id, Player player)
 	{
@@ -100,6 +106,26 @@
 		}
 		
 		player.sendPacket(SystemMessage.getSystemMessage(msg).addNumber(player.getX()).addNumber(player.getY()).addNumber(player.getZ()));
+		
+		if (player.isGM())
+		{
+			try
+			{
+				String fileLoc = "./data/locations.txt";
+				final File file = new File(fileLoc);
+				file.createNewFile();
+				
+				FileWriter fw = new FileWriter(fileLoc, true);
+				BufferedWriter bw = new BufferedWriter(fw);
+				bw.write(player.getX() + ", " + player.getY() + ", " + player.getZ());
+				bw.newLine();
+				bw.close();
+			}
+			catch (IOException e)
+			{
+				e.printStackTrace();
+			}
+		}
 	}
 	
 	@Override

 

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