Jump to content

[SHARE] Mammon Search Command


Recommended Posts

Patch

 

Index: /trunk/L2EmuProject-Game/config/main/services.properties
===================================================================
--- /trunk/L2EmuProject-Game/config/main/services.properties (revision 73)
+++ /trunk/L2EmuProject-Game/config/main/services.properties (revision 101)
@@ -1,3 +1,3 @@
+# ---------------------------
+# Mammon Search Voice Command
+# ---------------------------
+# Allow players to search Mammon With commands:
+# .mammon, .mmammon, .bmammon
+# Default: false
+AllowSearchMammon = false
+
Index: /trunk/L2EmuProject-Game/src/main/java/net/l2emuproject/gameserver/handler/VoicedCommandHandler.java
===================================================================
--- /trunk/L2EmuProject-Game/src/main/java/net/l2emuproject/gameserver/handler/VoicedCommandHandler.java (revision 30)
+++ /trunk/L2EmuProject-Game/src/main/java/net/l2emuproject/gameserver/handler/VoicedCommandHandler.java (revision 101)
@@ -47,20 +47,25 @@
		_datatable = new FastMap<String, IVoicedCommandHandler>();
		if (Config.ALLOW_MAMMON_SEARCH)
+			registerVoicedCommandHandler(new Mammon());
		registerVoicedCommandHandler(new Hellbound());
		registerVoicedCommandHandler(new CastleDoors());

		_log.info("VoicedCommandHandler: Loaded " + _datatable.size() + " handlers.");
Index: /trunk/L2EmuProject-Game/src/main/java/net/l2emuproject/gameserver/handler/voicedcommandhandlers/Mammon.java
===================================================================
--- /trunk/L2EmuProject-Game/src/main/java/net/l2emuproject/gameserver/handler/voicedcommandhandlers/Mammon.java (revision 101)
+++ /trunk/L2EmuProject-Game/src/main/java/net/l2emuproject/gameserver/handler/voicedcommandhandlers/Mammon.java (revision 101)
@@ -0,0 +1,106 @@
+/*
+* This program is free software: you can redistribute it and/or modify it under
+* the terms of the GNU General Public License as published by the Free Software
+* Foundation, either version 3 of the License, or (at your option) any later
+* version.
+* 
+* This program is distributed in the hope that it will be useful, but WITHOUT
+* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+* FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+* details.
+* 
+* You should have received a copy of the GNU General Public License along with
+* this program. If not, see <http://www.gnu.org/licenses/>.
+*/
+package net.l2emuproject.gameserver.handler.voicedcommandhandlers;
+
+import net.l2emuproject.gameserver.SevenSigns;
+import net.l2emuproject.gameserver.datatables.SpawnTable;
+import net.l2emuproject.gameserver.handler.IVoicedCommandHandler;
+import net.l2emuproject.gameserver.instancemanager.TownManager;
+import net.l2emuproject.gameserver.model.actor.instance.L2PcInstance;
+import net.l2emuproject.gameserver.model.entity.Town;
+import net.l2emuproject.gameserver.model.L2Spawn;
+
+/*
+* @author  EverDreaM,Ph@t3
+* @Edit by M-095 for L2Emu-RT
+*/
+
+public class Mammon implements IVoicedCommandHandler
+{
+	private static String[] _voicedCommands = { "mammon", "mmammon", "bmammon" };
+	private String mnearestTown, bnearestTown;
+	private SpawnTable s = SpawnTable.getInstance();
+
+	public boolean useVoicedCommand(String command, L2PcInstance activeChar, String target)
+	{
+		if(command.startsWith("mammon"))
+			return MammonInfo(activeChar);
+		else if(command.startsWith("mmammon"))
+			return MMammonInfo(activeChar);
+		else if(command.startsWith("bmammon"))
+			return BMammonInfo(activeChar);
+		return false;
+	}
+
+	public boolean initMammon(L2PcInstance activeChar)
+	{
+		if (!SevenSigns.getInstance().isSealValidationPeriod())
+		{
+			activeChar.sendMessage("Search unavailable. Wrong period.");
+			return false;
+		}
+		else
+		{
+			mnearestTown = findNPCLocTown(SevenSigns.MAMMON_MERCHANT_ID);
+			bnearestTown = findNPCLocTown(SevenSigns.MAMMON_BLACKSMITH_ID);
+			return true;
+		}
+	}
+
+	public String findNPCLocTown(int npcId)
+	{
+		String nearestTown = "";
+		for (L2Spawn spawn : s.getSpawnTable().values())
+			if (npcId == spawn.getNpcid()) {
+				Town town = TownManager.getInstance().getClosestTown(spawn.getLocx(), spawn.getLocy(), spawn.getLocz());
+			if (town != null)
+				nearestTown = TownManager.getInstance().getTownName(town.getTownId());
+			else
+				nearestTown = "None";
+			}
+			return nearestTown;
+	}
+
+	public boolean MammonInfo(L2PcInstance activeChar)
+	{
+		if (initMammon(activeChar))
+		{
+			activeChar.sendMessage("Mammon merchant now is in : " + mnearestTown);
+			activeChar.sendMessage("Mammon blacksmith now is in : " + bnearestTown);
+		}
+		return true;
+	}
+	public boolean MMammonInfo(L2PcInstance activeChar)
+	{
+		if (initMammon(activeChar))
+		{
+			activeChar.sendMessage("Mammon merchant now is in " + mnearestTown);
+		}
+		return true;
+	}
+	public boolean BMammonInfo(L2PcInstance activeChar)
+	{
+		if (initMammon(activeChar))
+		{
+			activeChar.sendMessage("Mammon blacksmith now is in " + bnearestTown);
+		}	
+		return true;
+	}
+
+	public String[] getVoicedCommandList()
+	{
+		return _voicedCommands;
+	}
+}
Index: /trunk/L2EmuProject-Game/src/main/java/net/l2emuproject/Config.java
===================================================================
--- /trunk/L2EmuProject-Game/src/main/java/net/l2emuproject/Config.java (revision 95)
+++ /trunk/L2EmuProject-Game/src/main/java/net/l2emuproject/Config.java (revision 101)
@@ -1732,5 +1732,8 @@
	public static int			KAMA_TIME_COUNTER;
	public static int			KAMA_COUNTER_TYPE;
+	public static boolean		ALLOW_MAMMON_SEARCH;


@@ -1760,4 +1763,7 @@
			KAMA_TIME_COUNTER = Integer.parseInt(servicesSettings.getProperty("KamaTimeCounter", "5"));
			KAMA_GM_COUNTER = Boolean.parseBoolean(servicesSettings.getProperty("USEKamaGMCounter", "false"));
+			ALLOW_MAMMON_SEARCH = Boolean.parseBoolean(servicesSettings.getProperty("AllowSearchMammon", "false"));
		}
		catch (Exception e)

Credits To L2Emu-RT Team

Link to comment
Share on other sites

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