From b4669baf9cc14f19f2f83a250d5d3c732b645b89 Mon Sep 17 00:00:00 2001
From: St3eT <St3eT@users.noreply.github.com>
Date: Fri, 11 Jul 2014 17:43:06 +0000
Subject: [PATCH] BETA: Added admin command to debug geodata (!//geogrid)

---
 .../dist/game/config/adminCommands.xml        |   1 +
 .../admincommandhandlers/AdminGeodata.java    | 125 ++++++++++--------
 2 files changed, 70 insertions(+), 56 deletions(-)

diff --git a/L2J_DataPack_BETA/dist/game/config/adminCommands.xml b/L2J_DataPack_BETA/dist/game/config/adminCommands.xml
index 50f23bd97f..845ae929d2 100644
--- a/L2J_DataPack_BETA/dist/game/config/adminCommands.xml
+++ b/L2J_DataPack_BETA/dist/game/config/adminCommands.xml
@@ -283,6 +283,7 @@
 	<admin command="admin_geo_spawn_pos" accessLevel="7" />
 	<admin command="admin_geo_can_see" accessLevel="7" />
 	<admin command="admin_geo_can_move" accessLevel="7" />
+	<admin command="admin_geogrid" accessLevel="7" />
 
 	<!-- ADMIN GEO EDITOR -->
 	<admin command="admin_ge_status" accessLevel="7" />
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/handlers/admincommandhandlers/AdminGeodata.java b/L2J_DataPack_BETA/dist/game/data/scripts/handlers/admincommandhandlers/AdminGeodata.java
index dd5e2bb890..87f3f8815e 100644
--- a/L2J_DataPack_BETA/dist/game/data/scripts/handlers/admincommandhandlers/AdminGeodata.java
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/handlers/admincommandhandlers/AdminGeodata.java
@@ -18,12 +18,15 @@
  */
 package handlers.admincommandhandlers;
 
+import java.util.StringTokenizer;
+
 import com.l2jserver.gameserver.GeoData;
 import com.l2jserver.gameserver.handler.IAdminCommandHandler;
 import com.l2jserver.gameserver.model.L2Object;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.network.SystemMessageId;
 import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
+import com.l2jserver.gameserver.util.GeoUtils;
 
 /**
  * @author -Nemesiss-
@@ -36,89 +39,99 @@ public class AdminGeodata implements IAdminCommandHandler
 		"admin_geo_pos",
 		"admin_geo_spawn_pos",
 		"admin_geo_can_move",
-		"admin_geo_can_see"
+		"admin_geo_can_see",
+		"admin_geogrid",
 	};
 	
 	@Override
 	public boolean useAdminCommand(String command, L2PcInstance activeChar)
 	{
-		if ("admin_geo_pos".equals(command))
-		{
-			int worldX = activeChar.getX();
-			int worldY = activeChar.getY();
-			int worldZ = activeChar.getZ();
-			int geoX = GeoData.getInstance().getGeoX(worldX);
-			int geoY = GeoData.getInstance().getGeoY(worldY);
-			
-			if (GeoData.getInstance().hasGeoPos(geoX, geoY))
-			{
-				activeChar.sendMessage("WorldX: " + worldX + ", WorldY: " + worldY + ", WorldZ: " + worldZ + ", GeoX: " + geoX + ", GeoY: " + geoY + ", GeoZ: " + GeoData.getInstance().getNearestZ(geoX, geoY, worldZ));
-			}
-			else
-			{
-				activeChar.sendMessage("There is no geodata at this position.");
-			}
-		}
-		else if ("admin_geo_spawn_pos".equals(command))
+		final StringTokenizer st = new StringTokenizer(command, " ");
+		final String actualCommand = st.nextToken();
+		switch (actualCommand.toLowerCase())
 		{
-			int worldX = activeChar.getX();
-			int worldY = activeChar.getY();
-			int worldZ = activeChar.getZ();
-			int geoX = GeoData.getInstance().getGeoX(worldX);
-			int geoY = GeoData.getInstance().getGeoY(worldY);
-			
-			if (GeoData.getInstance().hasGeoPos(geoX, geoY))
+			case "admin_geo_pos":
 			{
-				activeChar.sendMessage("WorldX: " + worldX + ", WorldY: " + worldY + ", WorldZ: " + worldZ + ", GeoX: " + geoX + ", GeoY: " + geoY + ", GeoZ: " + GeoData.getInstance().getSpawnHeight(worldX, worldY, worldZ, worldZ));
-			}
-			else
-			{
-				activeChar.sendMessage("There is no geodata at this position.");
+				final int worldX = activeChar.getX();
+				final int worldY = activeChar.getY();
+				final int worldZ = activeChar.getZ();
+				final int geoX = GeoData.getInstance().getGeoX(worldX);
+				final int geoY = GeoData.getInstance().getGeoY(worldY);
+				
+				if (GeoData.getInstance().hasGeoPos(geoX, geoY))
+				{
+					activeChar.sendMessage("WorldX: " + worldX + ", WorldY: " + worldY + ", WorldZ: " + worldZ + ", GeoX: " + geoX + ", GeoY: " + geoY + ", GeoZ: " + GeoData.getInstance().getNearestZ(geoX, geoY, worldZ));
+				}
+				else
+				{
+					activeChar.sendMessage("There is no geodata at this position.");
+				}
+				break;
 			}
-		}
-		else if ("admin_geo_can_move".equals(command))
-		{
-			L2Object target = activeChar.getTarget();
-			if (target != null)
+			case "admin_geo_spawn_pos":
 			{
-				if (GeoData.getInstance().canSeeTarget(activeChar, target))
+				final int worldX = activeChar.getX();
+				final int worldY = activeChar.getY();
+				final int worldZ = activeChar.getZ();
+				final int geoX = GeoData.getInstance().getGeoX(worldX);
+				final int geoY = GeoData.getInstance().getGeoY(worldY);
+				
+				if (GeoData.getInstance().hasGeoPos(geoX, geoY))
 				{
-					activeChar.sendMessage("Can move beeline.");
+					activeChar.sendMessage("WorldX: " + worldX + ", WorldY: " + worldY + ", WorldZ: " + worldZ + ", GeoX: " + geoX + ", GeoY: " + geoY + ", GeoZ: " + GeoData.getInstance().getSpawnHeight(worldX, worldY, worldZ, worldZ));
 				}
 				else
 				{
-					activeChar.sendMessage("Can not move beeline!");
+					activeChar.sendMessage("There is no geodata at this position.");
 				}
+				break;
 			}
-			else
+			case "admin_geo_can_move":
 			{
-				activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
+				final L2Object target = activeChar.getTarget();
+				if (target != null)
+				{
+					if (GeoData.getInstance().canSeeTarget(activeChar, target))
+					{
+						activeChar.sendMessage("Can move beeline.");
+					}
+					else
+					{
+						activeChar.sendMessage("Can not move beeline!");
+					}
+				}
+				else
+				{
+					activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
+				}
+				break;
 			}
-		}
-		else if ("admin_geo_can_see".equals(command))
-		{
-			L2Object target = activeChar.getTarget();
-			if (target != null)
+			case "admin_geo_can_see":
 			{
-				if (GeoData.getInstance().canSeeTarget(activeChar, target))
+				final L2Object target = activeChar.getTarget();
+				if (target != null)
 				{
-					activeChar.sendMessage("Can see target.");
+					if (GeoData.getInstance().canSeeTarget(activeChar, target))
+					{
+						activeChar.sendMessage("Can see target.");
+					}
+					else
+					{
+						activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANT_SEE_TARGET));
+					}
 				}
 				else
 				{
-					activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.CANT_SEE_TARGET));
+					activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
 				}
+				break;
 			}
-			else
+			case "admin_geogrid":
 			{
-				activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
+				GeoUtils.debugGrid(activeChar);
+				break;
 			}
 		}
-		else
-		{
-			return false;
-		}
-		
 		return true;
 	}
 	
-- 
GitLab