From 5100a607e4fbc7ce0f70a0d8829acba6e71ecbb6 Mon Sep 17 00:00:00 2001
From: Zealar <Zealar@users.noreply.github.com>
Date: Mon, 27 Oct 2014 21:26:32 +0000
Subject: [PATCH] BETA: Data Pack for [L6668]

---
 .../dist/game/config/adminCommands.xml        |   8 +-
 .../dist/game/data/html/admin/manor.htm       |  19 ++
 .../manormanager/manor_client_help001.htm     |   9 -
 .../manormanager/manor_client_help002.htm     |  11 --
 .../manormanager-show-procure.htm             |   4 -
 L2J_DataPack_BETA/dist/game/data/scripts.cfg  |   1 +
 .../CastleChamberlain/CastleChamberlain.java  | 105 +++++++++---
 .../ai/npc/CastleChamberlain/manor.html       |   6 +-
 .../CastleMercenaryManager.java               |  26 +--
 .../ai/npc/ManorManager/ManorManager.java     | 162 ++++++++++++++++++
 .../ai/npc/ManorManager/manager-help-01.htm   |   9 +
 .../ai/npc/ManorManager/manager-help-02.htm   |  12 ++
 .../ai/npc/ManorManager/manager-help-03.htm}  |   5 +-
 .../ai/npc/ManorManager}/manager-lord.htm     |   2 +-
 .../ai/npc/ManorManager}/manager.htm          |   8 +-
 .../data/scripts/handlers/MasterHandler.java  |   2 -
 .../admincommandhandlers/AdminManor.java      | 156 +++--------------
 .../handlers/bypasshandlers/ManorManager.java | 152 ----------------
 .../handlers/effecthandlers/Harvesting.java   | 122 +++++--------
 .../scripts/handlers/effecthandlers/Sow.java  |  27 ++-
 .../handlers/itemhandlers/Harvester.java      |  29 ++--
 .../scripts/handlers/itemhandlers/Seed.java   |  45 ++---
 .../dist/game/data/stats/npcs/35100-35200.xml |   6 +-
 .../dist/game/data/stats/npcs/35200-35300.xml |   8 +-
 .../dist/game/data/stats/npcs/35300-35400.xml |   4 +-
 .../dist/game/data/stats/npcs/35500-35600.xml |   4 +-
 .../dist/game/data/stats/npcs/35600-35700.xml |   4 +-
 .../dist/game/data/stats/npcs/36400-36500.xml |   2 +-
 .../dist/sql/game/castle_manor_procure.sql    |  16 +-
 .../dist/sql/game/castle_manor_production.sql |  14 +-
 .../dist/sql/game/updates/20140907update.sql  |  16 ++
 31 files changed, 457 insertions(+), 537 deletions(-)
 create mode 100644 L2J_DataPack_BETA/dist/game/data/html/admin/manor.htm
 delete mode 100644 L2J_DataPack_BETA/dist/game/data/html/manormanager/manor_client_help001.htm
 delete mode 100644 L2J_DataPack_BETA/dist/game/data/html/manormanager/manor_client_help002.htm
 delete mode 100644 L2J_DataPack_BETA/dist/game/data/html/manormanager/manormanager-show-procure.htm
 create mode 100644 L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ManorManager/ManorManager.java
 create mode 100644 L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ManorManager/manager-help-01.htm
 create mode 100644 L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ManorManager/manager-help-02.htm
 rename L2J_DataPack_BETA/dist/game/data/{html/manormanager/manor_client_help003.htm => scripts/ai/npc/ManorManager/manager-help-03.htm} (65%)
 rename L2J_DataPack_BETA/dist/game/data/{html/manormanager => scripts/ai/npc/ManorManager}/manager-lord.htm (95%)
 rename L2J_DataPack_BETA/dist/game/data/{html/manormanager => scripts/ai/npc/ManorManager}/manager.htm (85%)
 delete mode 100644 L2J_DataPack_BETA/dist/game/data/scripts/handlers/bypasshandlers/ManorManager.java
 create mode 100644 L2J_DataPack_BETA/dist/sql/game/updates/20140907update.sql

diff --git a/L2J_DataPack_BETA/dist/game/config/adminCommands.xml b/L2J_DataPack_BETA/dist/game/config/adminCommands.xml
index 070ed03992..dce17b54b3 100644
--- a/L2J_DataPack_BETA/dist/game/config/adminCommands.xml
+++ b/L2J_DataPack_BETA/dist/game/config/adminCommands.xml
@@ -364,13 +364,7 @@
 
 	<!-- ADMIN MANOR -->
 	<admin command="admin_manor" accessLevel="7" />
-	<admin command="admin_manor_approve" accessLevel="7" />
-	<admin command="admin_manor_setnext" accessLevel="7" />
-	<admin command="admin_manor_reset" accessLevel="7" />
-	<admin command="admin_manor_setmaintenance" accessLevel="7" />
-	<admin command="admin_manor_save" accessLevel="7" />
-	<admin command="admin_manor_disable" accessLevel="7" />
-
+	
 	<!-- ADMIN MENU -->
 	<admin command="admin_char_manage" accessLevel="7" />
 	<admin command="admin_teleport_character_to_menu" accessLevel="7" />
diff --git a/L2J_DataPack_BETA/dist/game/data/html/admin/manor.htm b/L2J_DataPack_BETA/dist/game/data/html/admin/manor.htm
new file mode 100644
index 0000000000..1afaf4017a
--- /dev/null
+++ b/L2J_DataPack_BETA/dist/game/data/html/admin/manor.htm
@@ -0,0 +1,19 @@
+<html><title>Manor Info</title><body>
+<table width=270>
+<tr>
+<td width=45><button value="Main" action="bypass -h admin_admin" width=45 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
+<td width=190><center><font color=LEVEL>--- [ Manor Status ] ---</font></center></td>
+<td width=45><button value="Back" action="bypass -h admin_admin2" width=45 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
+</tr>
+</table><br>
+<center>
+<table bgcolor="404040" width=270>
+<tr><td width=130>Current mode:</td><td width=140><font color=FF9900>%status%</font></td></tr>
+<tr><td>Next mode change:</td><td><font color=FF9900>%change%</font</td></tr>
+</table><br><br>
+<font color=LEVEL>--- [ Castle Info ] ---</font><br1>
+<table bgcolor="404040" width=270>
+%castleInfo%
+</table>
+</center>
+</body></html>
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/html/manormanager/manor_client_help001.htm b/L2J_DataPack_BETA/dist/game/data/html/manormanager/manor_client_help001.htm
deleted file mode 100644
index 4d1aeec202..0000000000
--- a/L2J_DataPack_BETA/dist/game/data/html/manormanager/manor_client_help001.htm
+++ /dev/null
@@ -1,9 +0,0 @@
-<html><body>
-A manor refers to any property owned by the lord. Anything produced within its confines remains the exclusive property of the lord.<br>
-You are to be an agricultural producer. First you must buy a &nbsp;<a action= "bypass -h npc_%objectId%_Link manormanager/manor_client_help002.htm">seed</a>&nbsp; and place it onto a monster. This is easily accomplished while targeting.<br>
-When the monster dies you will harvest a crop from its body. To harvest a crop you will target the corpse onto which a seed was sown and use the harvester. If you need one, I'll be happy to sell you a harvester. These crops are the major product of the manor. After you have harvested, bring the &nbsp;<a action="bypass -h npc_%objectId%_Link manormanager/manor_client_help003.htm">crop</a>&nbsp; to me. The crop is the specialty of our territory. For harvesting, target the monster.<br>
-I will appraise it and give you an appropriate reward for it! If you want to know what the reward will be, I will tell you about it later...<br>
-<center>
-<a action="bypass -h npc_%objectId%_Link manormanager/manager.htm">Return</a><br>
-</center>
-</body></html>
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/html/manormanager/manor_client_help002.htm b/L2J_DataPack_BETA/dist/game/data/html/manormanager/manor_client_help002.htm
deleted file mode 100644
index 065d8f70ab..0000000000
--- a/L2J_DataPack_BETA/dist/game/data/html/manormanager/manor_client_help002.htm
+++ /dev/null
@@ -1,11 +0,0 @@
-<html><body>
-The seeds can be classified into regular type and alternative type. If you plant a regular type seed, a monster will hide an item and give you a crop of equivalent value instead.<br>
-When you plant alternative type seed, you will receive a crop approximately half of the time or you will receive an item approximately half of the time.<br>
-The lord established this system so that players can choose their preferred type of gameplay by selecting the type of seed to plant in a manor.<br>
-There are four kinds of seed--coda, cobol, codran and coba. Availability of each type is based upon a character's level. Coda is the seed most appropriate for farmers whose levels are between level 10 and level 30, relatively low levels. Cobol is the seed most appropriate for farmers whose levels fall between level 31 and level 48. Codran is the seed most appropriate for high level farmers of level 49 and level 64. Coba is the seed most appropriate for high level farmers of level 65 or above.<br>
-Obviously, different seeds grow different crops. Certain seeds work better with certain monsters. If a monster is weak, he will produce a disappointing crop. On the other hand, if he is too strong, the crop could be damaged as well.<br>
-One secret of a successful crop is to pick a monster with approximately the same power as the sower. Trying to sow a seed on a non-compliant monster can have disastrous consequences.<br>
-You may purchase any seed at any time, but the lord reserves the right not to purchase any crop at his discretion. You should always check to make sure that your crop is currently in demand.<br>
-And... you've got to keep it a secret from the Lord... I hear other castles buy crops... as long as they can be also purchased there... If the Lord changes his mind, I'll have no other choice but to sell my crops to other castles... Please keep it a secret.<br>
-<a action="bypass -h npc_%objectId%_Link manormanager/manor_client_help001.htm">Return</a>
-</body></html>
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/html/manormanager/manormanager-show-procure.htm b/L2J_DataPack_BETA/dist/game/data/html/manormanager/manormanager-show-procure.htm
deleted file mode 100644
index a2f5770a8b..0000000000
--- a/L2J_DataPack_BETA/dist/game/data/html/manormanager/manormanager-show-procure.htm
+++ /dev/null
@@ -1,4 +0,0 @@
-<html><body>%npcname%:<br>
-Crop procure info table<br>
-<table border=1><tr><td width=180 bgcolor=555555>Crop Name</td><td width=35>Buy</td><td width=50>Reward</td><td width=30>#</td></tr>%table%</table>
-</body></html>
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts.cfg b/L2J_DataPack_BETA/dist/game/data/scripts.cfg
index 0665902d8f..6febcaa4e1 100644
--- a/L2J_DataPack_BETA/dist/game/data/scripts.cfg
+++ b/L2J_DataPack_BETA/dist/game/data/scripts.cfg
@@ -36,6 +36,7 @@ ai/npc/FortressSiegeManager/FortressSiegeManager.java
 ai/npc/FreyasSteward/FreyasSteward.java
 ai/npc/Jinia/Jinia.java
 ai/npc/KetraOrcSupport/KetraOrcSupport.java
+ai/npc/ManorManager/ManorManager.java
 ai/npc/MercenaryCaptain/MercenaryCaptain.java
 ai/npc/Minigame/Minigame.java
 ai/npc/MonumentOfHeroes/MonumentOfHeroes.java
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/CastleChamberlain/CastleChamberlain.java b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/CastleChamberlain/CastleChamberlain.java
index 1db2f39852..c521ce86c3 100644
--- a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/CastleChamberlain/CastleChamberlain.java
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/CastleChamberlain/CastleChamberlain.java
@@ -31,11 +31,13 @@ import com.l2jserver.Config;
 import com.l2jserver.gameserver.SevenSigns;
 import com.l2jserver.gameserver.datatables.ClanTable;
 import com.l2jserver.gameserver.datatables.TeleportLocationTable;
+import com.l2jserver.gameserver.instancemanager.CastleManorManager;
 import com.l2jserver.gameserver.instancemanager.FortManager;
 import com.l2jserver.gameserver.model.ClanPrivilege;
 import com.l2jserver.gameserver.model.L2Clan;
 import com.l2jserver.gameserver.model.L2TeleportLocation;
 import com.l2jserver.gameserver.model.PcCondOverride;
+import com.l2jserver.gameserver.model.SeedProduction;
 import com.l2jserver.gameserver.model.actor.L2Npc;
 import com.l2jserver.gameserver.model.actor.instance.L2DoorInstance;
 import com.l2jserver.gameserver.model.actor.instance.L2MerchantInstance;
@@ -43,11 +45,19 @@ import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.entity.Castle;
 import com.l2jserver.gameserver.model.entity.Castle.CastleFunction;
 import com.l2jserver.gameserver.model.entity.Fort;
+import com.l2jserver.gameserver.model.events.EventType;
+import com.l2jserver.gameserver.model.events.ListenerRegisterType;
+import com.l2jserver.gameserver.model.events.annotations.Id;
+import com.l2jserver.gameserver.model.events.annotations.RegisterEvent;
+import com.l2jserver.gameserver.model.events.annotations.RegisterType;
+import com.l2jserver.gameserver.model.events.impl.character.npc.OnNpcManorBypass;
 import com.l2jserver.gameserver.model.holders.SkillHolder;
 import com.l2jserver.gameserver.model.itemcontainer.Inventory;
 import com.l2jserver.gameserver.network.SystemMessageId;
+import com.l2jserver.gameserver.network.serverpackets.ExShowCropInfo;
 import com.l2jserver.gameserver.network.serverpackets.ExShowCropSetting;
 import com.l2jserver.gameserver.network.serverpackets.ExShowDominionRegistry;
+import com.l2jserver.gameserver.network.serverpackets.ExShowManorDefaultInfo;
 import com.l2jserver.gameserver.network.serverpackets.ExShowSeedInfo;
 import com.l2jserver.gameserver.network.serverpackets.ExShowSeedSetting;
 import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
@@ -759,10 +769,23 @@ public final class CastleChamberlain extends AbstractNpcAI
 			{
 				if (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_TAXES))
 				{
+					long seedIncome = 0;
+					if (Config.ALLOW_MANOR)
+					{
+						for (SeedProduction sp : CastleManorManager.getInstance().getSeedProduction(castle.getResidenceId(), false))
+						{
+							final long diff = sp.getStartAmount() - sp.getAmount();
+							if (diff != 0)
+							{
+								seedIncome += diff * sp.getPrice();
+							}
+						}
+					}
+					
 					final NpcHtmlMessage html = getHtmlPacket(player, npc, "castlemanagevault.html");
 					html.replace("%tax_income%", Util.formatAdena(castle.getTreasury()));
 					html.replace("%tax_income_reserved%", "0"); // TODO: Implement me!
-					html.replace("%seed_income%", "0"); // TODO: Implement me!
+					html.replace("%seed_income%", Util.formatAdena(seedIncome));
 					player.sendPacket(html);
 				}
 				else
@@ -1136,35 +1159,13 @@ public final class CastleChamberlain extends AbstractNpcAI
 			}
 			case "manor":
 			{
-				htmltext = (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_MANOR_ADMIN)) ? "manor.html" : "chamberlain-21.html";
-				break;
-			}
-			case "seed_status":
-			{
-				player.sendPacket(new ExShowSeedInfo(castle.getResidenceId(), castle.getSeedProduction(0)));
-				break;
-			}
-			case "seed_setup":
-			{
-				if (castle.isNextPeriodApproved())
+				if (Config.ALLOW_MANOR)
 				{
-					player.sendPacket(SystemMessageId.A_MANOR_CANNOT_BE_SET_UP_BETWEEN_6_AM_AND_8_PM);
+					htmltext = (isOwner(player, npc) && player.hasClanPrivilege(ClanPrivilege.CS_MANOR_ADMIN)) ? "manor.html" : "chamberlain-21.html";
 				}
 				else
 				{
-					player.sendPacket(new ExShowSeedSetting(castle.getResidenceId()));
-				}
-				break;
-			}
-			case "crop_setup":
-			{
-				if (castle.isNextPeriodApproved())
-				{
-					player.sendPacket(SystemMessageId.A_MANOR_CANNOT_BE_SET_UP_BETWEEN_6_AM_AND_8_PM);
-				}
-				else
-				{
-					player.sendPacket(new ExShowCropSetting(castle.getResidenceId()));
+					player.sendMessage("Manor system is deactivated.");
 				}
 				break;
 			}
@@ -1313,6 +1314,58 @@ public final class CastleChamberlain extends AbstractNpcAI
 		return (isOwner(player, npc)) ? "chamberlain-01.html" : "chamberlain-04.html";
 	}
 	
+	// @formatter:off
+	@RegisterEvent(EventType.ON_NPC_MANOR_BYPASS)
+	@RegisterType(ListenerRegisterType.NPC)
+	@Id({35100, 35142, 35184, 35226, 35274,	35316, 35363, 35509, 35555})
+	// @formatter:on
+	public final void onNpcManorBypass(OnNpcManorBypass evt)
+	{
+		final L2PcInstance player = evt.getActiveChar();
+		final L2Npc npc = evt.getTarget();
+		if (isOwner(player, npc))
+		{
+			final CastleManorManager manor = CastleManorManager.getInstance();
+			if (manor.isUnderMaintenance())
+			{
+				player.sendPacket(SystemMessageId.THE_MANOR_SYSTEM_IS_CURRENTLY_UNDER_MAINTENANCE);
+				return;
+			}
+			
+			final int castleId = (evt.getManorId() == -1) ? npc.getCastle().getResidenceId() : evt.getManorId();
+			switch (evt.getRequest())
+			{
+				case 3: // Seed info
+					player.sendPacket(new ExShowSeedInfo(castleId, evt.isNextPeriod(), true));
+					break;
+				case 4: // Crop info
+					player.sendPacket(new ExShowCropInfo(castleId, evt.isNextPeriod(), true));
+					break;
+				case 5: // Basic info
+					player.sendPacket(new ExShowManorDefaultInfo(true));
+					break;
+				case 7: // Seed settings
+					if (manor.isManorApproved())
+					{
+						player.sendPacket(SystemMessageId.A_MANOR_CANNOT_BE_SET_UP_BETWEEN_4_30_AM_AND_8_PM);
+						return;
+					}
+					player.sendPacket(new ExShowSeedSetting(castleId));
+					break;
+				case 8: // Crop settings
+					if (manor.isManorApproved())
+					{
+						player.sendPacket(SystemMessageId.A_MANOR_CANNOT_BE_SET_UP_BETWEEN_4_30_AM_AND_8_PM);
+						return;
+					}
+					player.sendPacket(new ExShowCropSetting(castleId));
+					break;
+				default:
+					_log.warning(getClass().getSimpleName() + ": Player " + player.getName() + " (" + player.getObjectId() + ") send unknown request id " + evt.getRequest() + "!");
+			}
+		}
+	}
+	
 	public static void main(String[] args)
 	{
 		new CastleChamberlain();
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/CastleChamberlain/manor.html b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/CastleChamberlain/manor.html
index 998c393ef3..332ea6d22d 100644
--- a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/CastleChamberlain/manor.html
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/CastleChamberlain/manor.html
@@ -1,9 +1,9 @@
 <html><body>
 Here are some things you'll need to know about to manage the Manor.<br>
 <center><br><br>
-<a action="bypass -h Quest CastleChamberlain seed_status">View the Status of Seeds/Crops</a><br>
-<a action="bypass -h Quest CastleChamberlain seed_setup">Edit Seed Setup</a><br>
-<a action="bypass -h Quest CastleChamberlain crop_setup">Edit Crop Setup</a><br>
+<a action="bypass manor_menu_select?ask=3&state=-1&time=0">View the Status of Seeds/Crops</a><br>
+<a action="bypass manor_menu_select?ask=7&state=-1&time=0">Edit Seed Setup</a><br>
+<a action="bypass manor_menu_select?ask=8&state=-1&time=0">Edit Crop Setup</a><br>
 <a action="bypass -h Quest CastleChamberlain manor-help-01.html">View Descriptions</a><br>
 <a action="bypass -h Quest CastleChamberlain chamberlain-01.html">Return</a>
 </center>
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/CastleMercenaryManager/CastleMercenaryManager.java b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/CastleMercenaryManager/CastleMercenaryManager.java
index 3daccda0ce..da6ce8fd85 100644
--- a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/CastleMercenaryManager/CastleMercenaryManager.java
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/CastleMercenaryManager/CastleMercenaryManager.java
@@ -90,12 +90,12 @@ public final class CastleMercenaryManager extends AbstractNpcAI
 			{
 				if (SevenSigns.getInstance().isSealValidationPeriod())
 				{
-					htmltext = "mercmanager-ssq.html";
+					final int listId = Integer.parseInt(npc.getId() + st.nextToken());
+					((L2MerchantInstance) npc).showBuyWindow(player, listId, false); // NOTE: Not affected by Castle Taxes, baseTax is 20% (done in merchant buylists)
 				}
 				else
 				{
-					final int listId = Integer.parseInt(npc.getId() + st.nextToken());
-					((L2MerchantInstance) npc).showBuyWindow(player, listId, false); // NOTE: Not affected by Castle Taxes, baseTax is 20% (done in merchant buylists)
+					htmltext = "mercmanager-ssq.html";
 				}
 				break;
 			}
@@ -123,17 +123,19 @@ public final class CastleMercenaryManager extends AbstractNpcAI
 			{
 				htmltext = "mercmanager-siege.html";
 			}
-			else if (SevenSigns.getInstance().getSealOwner(SevenSigns.SEAL_STRIFE) == SevenSigns.CABAL_DUSK)
-			{
-				htmltext = "mercmanager-dusk.html";
-			}
-			else if (SevenSigns.getInstance().getSealOwner(SevenSigns.SEAL_STRIFE) == SevenSigns.CABAL_DAWN)
-			{
-				htmltext = "mercmanager-dawn.html";
-			}
 			else
 			{
-				htmltext = "mercmanager.html";
+				switch (SevenSigns.getInstance().getSealOwner(SevenSigns.SEAL_STRIFE))
+				{
+					case SevenSigns.CABAL_DUSK:
+						htmltext = "mercmanager-dusk.html";
+						break;
+					case SevenSigns.CABAL_DAWN:
+						htmltext = "mercmanager-dawn.html";
+						break;
+					default:
+						htmltext = "mercmanager.html";
+				}
 			}
 		}
 		else
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ManorManager/ManorManager.java b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ManorManager/ManorManager.java
new file mode 100644
index 0000000000..eccb0ea311
--- /dev/null
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ManorManager/ManorManager.java
@@ -0,0 +1,162 @@
+/*
+ * Copyright (C) 2004-2014 L2J DataPack
+ * 
+ * This file is part of L2J DataPack.
+ * 
+ * L2J DataPack 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.
+ * 
+ * L2J DataPack 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 ai.npc.ManorManager;
+
+import ai.npc.AbstractNpcAI;
+
+import com.l2jserver.Config;
+import com.l2jserver.gameserver.instancemanager.CastleManorManager;
+import com.l2jserver.gameserver.model.PcCondOverride;
+import com.l2jserver.gameserver.model.actor.L2Npc;
+import com.l2jserver.gameserver.model.actor.instance.L2MerchantInstance;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.model.events.EventType;
+import com.l2jserver.gameserver.model.events.ListenerRegisterType;
+import com.l2jserver.gameserver.model.events.annotations.Id;
+import com.l2jserver.gameserver.model.events.annotations.RegisterEvent;
+import com.l2jserver.gameserver.model.events.annotations.RegisterType;
+import com.l2jserver.gameserver.model.events.impl.character.npc.OnNpcManorBypass;
+import com.l2jserver.gameserver.network.SystemMessageId;
+import com.l2jserver.gameserver.network.serverpackets.BuyListSeed;
+import com.l2jserver.gameserver.network.serverpackets.ExShowCropInfo;
+import com.l2jserver.gameserver.network.serverpackets.ExShowManorDefaultInfo;
+import com.l2jserver.gameserver.network.serverpackets.ExShowProcureCropDetail;
+import com.l2jserver.gameserver.network.serverpackets.ExShowSeedInfo;
+import com.l2jserver.gameserver.network.serverpackets.ExShowSellCropList;
+import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
+
+/**
+ * Manor manager AI.
+ * @author malyelfik
+ */
+public final class ManorManager extends AbstractNpcAI
+{
+	private static final int[] NPC =
+	{
+		35644,
+		35645,
+		35319,
+		35366,
+		36456,
+		35512,
+		35558,
+		35229,
+		35230,
+		35231,
+		35277,
+		35103,
+		35145,
+		35187
+	};
+	
+	public ManorManager()
+	{
+		super(ManorManager.class.getSimpleName(), "ai/npc");
+		addStartNpc(NPC);
+		addFirstTalkId(NPC);
+		addTalkId(NPC);
+	}
+	
+	@Override
+	public String onAdvEvent(String event, L2Npc npc, L2PcInstance player)
+	{
+		String htmltext = null;
+		switch (event)
+		{
+			case "manager-help-01.htm":
+			case "manager-help-02.htm":
+			case "manager-help-03.htm":
+				htmltext = event;
+				break;
+		}
+		return htmltext;
+	}
+	
+	@Override
+	public String onFirstTalk(L2Npc npc, L2PcInstance player)
+	{
+		if (Config.ALLOW_MANOR)
+		{
+			final int castleId = npc.getTemplate().getParameters().getInt("manor_id", -1);
+			if (!player.canOverrideCond(PcCondOverride.CASTLE_CONDITIONS) && player.isClanLeader() && (castleId == player.getClan().getCastleId()))
+			{
+				return "manager-lord.htm";
+			}
+			return "manager.htm";
+		}
+		return getHtm(player.getHtmlPrefix(), "data/html/npcdefault.htm");
+	}
+	
+	// @formatter:off
+	@RegisterEvent(EventType.ON_NPC_MANOR_BYPASS)
+	@RegisterType(ListenerRegisterType.NPC)
+	@Id({35644, 35645, 35319, 35366, 36456, 35512, 35558, 35229, 35230, 35231, 35277, 35103, 35145, 35187})
+	// @formatter:on
+	public final void onNpcManorBypass(OnNpcManorBypass evt)
+	{
+		final L2PcInstance player = evt.getActiveChar();
+		if (CastleManorManager.getInstance().isUnderMaintenance())
+		{
+			player.sendPacket(SystemMessageId.THE_MANOR_SYSTEM_IS_CURRENTLY_UNDER_MAINTENANCE);
+			return;
+		}
+		
+		final L2Npc npc = evt.getTarget();
+		final int templateId = npc.getTemplate().getParameters().getInt("manor_id", -1);
+		final int castleId = (evt.getManorId() == -1) ? templateId : evt.getManorId();
+		switch (evt.getRequest())
+		{
+			case 1: // Seed purchase
+			{
+				if (templateId != castleId)
+				{
+					player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.HERE_YOU_CAN_BUY_ONLY_SEEDS_OF_S1_MANOR).addCastleId(templateId));
+					return;
+				}
+				player.sendPacket(new BuyListSeed(player.getAdena(), castleId));
+				break;
+			}
+			case 2: // Crop sales
+				player.sendPacket(new ExShowSellCropList(player.getInventory(), castleId));
+				break;
+			case 3: // Seed info
+				player.sendPacket(new ExShowSeedInfo(castleId, evt.isNextPeriod(), false));
+				break;
+			case 4: // Crop info
+				player.sendPacket(new ExShowCropInfo(castleId, evt.isNextPeriod(), false));
+				break;
+			case 5: // Basic info
+				player.sendPacket(new ExShowManorDefaultInfo(false));
+				break;
+			case 6: // Buy harvester
+				((L2MerchantInstance) npc).showBuyWindow(player, 300000 + npc.getId());
+				break;
+			case 9: // Edit sales (Crop sales)
+				player.sendPacket(new ExShowProcureCropDetail(evt.getManorId()));
+				break;
+			default:
+				_log.warning(getClass().getSimpleName() + ": Player " + player.getName() + " (" + player.getObjectId() + ") send unknown request id " + evt.getRequest() + "!");
+		}
+	}
+	
+	public static void main(String[] args)
+	{
+		new ManorManager();
+	}
+}
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ManorManager/manager-help-01.htm b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ManorManager/manager-help-01.htm
new file mode 100644
index 0000000000..5a9f74df82
--- /dev/null
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ManorManager/manager-help-01.htm
@@ -0,0 +1,9 @@
+<html><body>
+A manor refers to any property owned by the lord.  Anything produced within its confines remains the exclusive property of the lord.<br> 
+You are to be an agricultural producer. First you must buy a &nbsp;<a action="bypass -h Quest ManorManager manager-help-02.htm">seed</a>&nbsp;and place it onto a monster.  This is easily accomplished while targeting.<br> 
+When the monster dies you will harvest a crop from its body. To harvest a crop you will target the corpse onto which a seed was sown and use the harvester. If you need one, I'll be happy to sell you a harvester.  These crops are the major product of the manor.  After you have harvested, bring the &nbsp;<a action="bypass -h Quest ManorManager manager-help-03.htm">crop</a>&nbsp;to me.  The crop is the specialty of our territory. For harvesting, target the monster.<br> 
+I will appraise it and give you an appropriate reward for it!  If you want to know what the reward will be, I will tell you about it later... <br> 
+<center>
+<a action="bypass -h npc_%objectId%_Chat 0">Return</a>
+</center>
+</body></html>
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ManorManager/manager-help-02.htm b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ManorManager/manager-help-02.htm
new file mode 100644
index 0000000000..b052faeab8
--- /dev/null
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ManorManager/manager-help-02.htm
@@ -0,0 +1,12 @@
+<html><body>
+The seeds can be classified into regular type and alternative type.  If you plant a regular type seed, a monster will hide an item and give you a crop of equivalent value instead.<br>  
+When you plant alternative type seed, you will receive a crop approximately half of the time  or you will receive an item  approximately half of the time.<br>  
+The lord established this system so that players can choose their preferred type of gameplay by selecting the type of seed to plant in a manor.<br>  
+There are four kinds of seed--coda, cobol, codran and coba. Availability of each type is based upon a character's level.  Coda is the seed most appropriate for farmers whose levels are between level 10 and level 30, relatively low levels. Cobol is the seed most appropriate for farmers whose levels fall between level 31 and level 48. Codran is the seed most appropriate for high level farmers of level 49 and level 64. Coba is the seed most appropriate for high level farmers of level 65 or above.<br> 
+Obviously, different seeds grow different crops.  Certain seeds work better with certain monsters.  If a monster is weak, he will produce a disappointing crop. On the other hand, if he is too strong, the crop could be damaged as well.<br> 
+One secret of a successful crop is to pick a monster with approximately the same power as the sower.  Trying to sow a seed on a non-compliant monster can have disastrous consequences.<br> 
+You may purchase any seed at any time, but the lord reserves the right not to purchase any crop at his discretion. You should always check to make sure that your crop is currently in demand.<br> 
+And... you've got to keep it a secret fro the Lord... I hear other castles buy crops... as long as they can be also purchased there... If the Lord changes his mind, I'll have no other choice but to sell my crops to other castles... Please keep it a secret.<br>
+<a action="bypass -h Quest ManorManager manager-help-01.htm">Return</a>
+</center>
+</body></html>
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/html/manormanager/manor_client_help003.htm b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ManorManager/manager-help-03.htm
similarity index 65%
rename from L2J_DataPack_BETA/dist/game/data/html/manormanager/manor_client_help003.htm
rename to L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ManorManager/manager-help-03.htm
index 14400bedae..3f8d945056 100644
--- a/L2J_DataPack_BETA/dist/game/data/html/manormanager/manor_client_help003.htm
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ManorManager/manager-help-03.htm
@@ -1,8 +1,9 @@
 <html><body>
-When a seed germinates inside a monster it becomes a crop. The best crops are harvested from monsters of a level similar to the sower.<br>
+When a seed germinates inside a monster it becomes a crop. The best crops 
+are harvested from monsters of a level similar to the sower.<br>
 Bring your harvested crops to me and you will be rewarded. The lord usually compensates farmers with items, some much more valuable than the crops.<br>
 Of course, you should be willing to gamble a little, right?<br><br>
 <center>
-<a action="bypass -h npc_%objectId%_Link manormanager/manor_client_help001.htm">Back</a><br>
+<a action="bypass -h Quest ManorManager manager-help-01.htm">Back</a>
 </center>
 </body></html>
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/html/manormanager/manager-lord.htm b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ManorManager/manager-lord.htm
similarity index 95%
rename from L2J_DataPack_BETA/dist/game/data/html/manormanager/manager-lord.htm
rename to L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ManorManager/manager-lord.htm
index 076b94314c..ae5f65626d 100644
--- a/L2J_DataPack_BETA/dist/game/data/html/manormanager/manager-lord.htm
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ManorManager/manager-lord.htm
@@ -1,5 +1,5 @@
 <html><body>
 My Lord! To what do I owe the honor of a personal visit?<br>
 I serve at your pleasure, my Lord!<br>
-I would never even think of stealing from you! Please believe me!
+I would never even think of stealing from you! Please believe me!<br>
 </body></html>
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/html/manormanager/manager.htm b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ManorManager/manager.htm
similarity index 85%
rename from L2J_DataPack_BETA/dist/game/data/html/manormanager/manager.htm
rename to L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ManorManager/manager.htm
index 485aac079a..5e785567e8 100644
--- a/L2J_DataPack_BETA/dist/game/data/html/manormanager/manager.htm
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/ai/npc/ManorManager/manager.htm
@@ -1,8 +1,8 @@
 <html><body>
 I'm a merchant dispatched by the Lord in order to sell Seeds from the Manor and purchase Special Products.<br>
-The seeds I'm selling can be sowed only in the Manor. But the Special Products can be sold in any castle. When selling to another castle, I will sell to another Manor on your behalf for a small fee.<br>
-The buying and selling of seeds for Special Products begin each day at 8 pm. Prepare in advance by referring to the Manor information begins to be displayed from 4:30 am, and come back at 8 pm. If you don't hurry, items can be sold out. Huh Huh<br>
-If you also have Special Products, sell them to me. The Lord will be glad.<br>
+The seeds I'm selling can be sowed only in the Manor. But the Special Products can be sold in any castle. When selling to another castle, I will sell to another Manor on your behalf for a small fee.<br> 
+The buying and selling of seeds for Special Products begin each day at 8 pm. Prepare in advance by referring to the Manor information begins to be displayed from 4:30 am, and come back at 8 pm. If you don't hurry, items can be sold out. Huh Huh<br> 
+If you also have Special Products, sell them to me. The Lord will be glad.<br> 
 If you perhaps don't know what the Manor or Special Product is, ask me anytime -- I will explain them to you in detail.<br>
 <center>
 <a action="bypass manor_menu_select?ask=1&state=-1&time=0">Purchase the Seed.</a><br>
@@ -11,6 +11,6 @@ If you perhaps don't know what the Manor or Special Product is, ask me anytime -
 <a action="bypass manor_menu_select?ask=5&state=-1&time=0">View the basic Seed information.</a><br>
 <a action="bypass manor_menu_select?ask=6&state=-1&time=0">Purchase a harvester.</a><br>
 <a action="bypass -h npc_%objectId%_TerritoryStatus">Ask about the current territory status.</a><br>
-<a action="bypass -h npc_%objectId%_Link manormanager/manor_client_help001.htm">Listen to the explanation.</a><br>
+<a action="bypass -h Quest ManorManager manager-help-01.htm">Listen to the explanation.</a>
 </center>
 </body></html>
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/handlers/MasterHandler.java b/L2J_DataPack_BETA/dist/game/data/scripts/handlers/MasterHandler.java
index 5111f7770c..943aec0592 100644
--- a/L2J_DataPack_BETA/dist/game/data/scripts/handlers/MasterHandler.java
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/handlers/MasterHandler.java
@@ -139,7 +139,6 @@ import handlers.bypasshandlers.Freight;
 import handlers.bypasshandlers.ItemAuctionLink;
 import handlers.bypasshandlers.Link;
 import handlers.bypasshandlers.Loto;
-import handlers.bypasshandlers.ManorManager;
 import handlers.bypasshandlers.Multisell;
 import handlers.bypasshandlers.NpcViewMod;
 import handlers.bypasshandlers.Observation;
@@ -407,7 +406,6 @@ public class MasterHandler
 			ItemAuctionLink.class,
 			Link.class,
 			Loto.class,
-			ManorManager.class,
 			Multisell.class,
 			NpcViewMod.class,
 			Observation.class,
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/handlers/admincommandhandlers/AdminManor.java b/L2J_DataPack_BETA/dist/game/data/scripts/handlers/admincommandhandlers/AdminManor.java
index 82d9551409..9e6ac7d594 100644
--- a/L2J_DataPack_BETA/dist/game/data/scripts/handlers/admincommandhandlers/AdminManor.java
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/handlers/admincommandhandlers/AdminManor.java
@@ -18,164 +18,50 @@
  */
 package handlers.admincommandhandlers;
 
-import java.util.List;
-import java.util.StringTokenizer;
-
 import com.l2jserver.gameserver.handler.IAdminCommandHandler;
 import com.l2jserver.gameserver.instancemanager.CastleManager;
 import com.l2jserver.gameserver.instancemanager.CastleManorManager;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.entity.Castle;
 import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
+import com.l2jserver.gameserver.util.Util;
 import com.l2jserver.util.StringUtil;
 
 /**
- * Admin comand handler for Manor System This class handles following admin commands: - manor_info = shows info about current manor state - manor_approve = approves settings for the next manor period - manor_setnext = changes manor settings to the next day's - manor_reset castle = resets all manor
- * data for specified castle (or all) - manor_setmaintenance = sets manor system under maintenance mode - manor_save = saves all manor data into database - manor_disable = disables manor system
- * @author l3x
+ * @author malyelfik
  */
-public class AdminManor implements IAdminCommandHandler
+public final class AdminManor implements IAdminCommandHandler
 {
-	private static final String[] _adminCommands =
-	{
-		"admin_manor",
-		"admin_manor_approve",
-		"admin_manor_setnext",
-		"admin_manor_reset",
-		"admin_manor_setmaintenance",
-		"admin_manor_save",
-		"admin_manor_disable"
-	};
-	
 	@Override
 	public boolean useAdminCommand(String command, L2PcInstance activeChar)
 	{
-		StringTokenizer st = new StringTokenizer(command);
-		command = st.nextToken();
+		final CastleManorManager manor = CastleManorManager.getInstance();
+		final NpcHtmlMessage msg = new NpcHtmlMessage();
+		msg.setFile(activeChar.getHtmlPrefix(), "data/html/admin/manor.htm");
+		msg.replace("%status%", manor.getCurrentModeName());
+		msg.replace("%change%", manor.getNextModeChange());
 		
-		if (command.equals("admin_manor"))
-		{
-			showMainPage(activeChar);
-		}
-		else if (command.equals("admin_manor_setnext"))
-		{
-			CastleManorManager.getInstance().setNextPeriod();
-			CastleManorManager.getInstance().setNewManorRefresh();
-			CastleManorManager.getInstance().updateManorRefresh();
-			activeChar.sendMessage("Manor System: set to next period");
-			showMainPage(activeChar);
-		}
-		else if (command.equals("admin_manor_approve"))
-		{
-			CastleManorManager.getInstance().approveNextPeriod();
-			CastleManorManager.getInstance().setNewPeriodApprove();
-			CastleManorManager.getInstance().updatePeriodApprove();
-			activeChar.sendMessage("Manor System: next period approved");
-			showMainPage(activeChar);
-		}
-		else if (command.equals("admin_manor_reset"))
-		{
-			int castleId = 0;
-			try
-			{
-				castleId = Integer.parseInt(st.nextToken());
-			}
-			catch (Exception e)
-			{
-			}
-			
-			if (castleId > 0)
-			{
-				Castle castle = CastleManager.getInstance().getCastleById(castleId);
-				castle.resetManor();
-				activeChar.sendMessage("Manor data for " + castle.getName() + " was nulled");
-			}
-			else
-			{
-				for (Castle castle : CastleManager.getInstance().getCastles())
-				{
-					castle.resetManor();
-				}
-				activeChar.sendMessage("Manor data was nulled");
-			}
-			showMainPage(activeChar);
-		}
-		else if (command.equals("admin_manor_setmaintenance"))
-		{
-			boolean mode = CastleManorManager.getInstance().isUnderMaintenance();
-			CastleManorManager.getInstance().setUnderMaintenance(!mode);
-			if (mode)
-			{
-				activeChar.sendMessage("Manor System: not under maintenance");
-			}
-			else
-			{
-				activeChar.sendMessage("Manor System: under maintenance");
-			}
-			showMainPage(activeChar);
-		}
-		else if (command.equals("admin_manor_save"))
-		{
-			CastleManorManager.getInstance().save();
-			activeChar.sendMessage("Manor System: all data saved");
-			showMainPage(activeChar);
-		}
-		else if (command.equals("admin_manor_disable"))
+		final StringBuilder sb = new StringBuilder(3400);
+		for (Castle c : CastleManager.getInstance().getCastles())
 		{
-			boolean mode = CastleManorManager.getInstance().isDisabled();
-			CastleManorManager.getInstance().setDisabled(!mode);
-			if (mode)
-			{
-				activeChar.sendMessage("Manor System: enabled");
-			}
-			else
-			{
-				activeChar.sendMessage("Manor System: disabled");
-			}
-			showMainPage(activeChar);
+			StringUtil.append(sb, "<tr><td>Name:</td><td><font color=008000>" + c.getName() + "</font></td></tr>");
+			StringUtil.append(sb, "<tr><td>Current period cost:</td><td><font color=FF9900>", Util.formatAdena(manor.getManorCost(c.getResidenceId(), false)), " Adena</font></td></tr>");
+			StringUtil.append(sb, "<tr><td>Next period cost:</td><td><font color=FF9900>", Util.formatAdena(manor.getManorCost(c.getResidenceId(), true)), " Adena</font></td></tr>");
+			StringUtil.append(sb, "<tr><td><font color=808080>--------------------------</font></td><td><font color=808080>--------------------------</font></td></tr>");
 		}
+		msg.replace("%castleInfo%", sb.toString());
+		activeChar.sendPacket(msg);
 		
+		sb.setLength(0);
 		return true;
 	}
 	
 	@Override
 	public String[] getAdminCommandList()
 	{
-		return _adminCommands;
-	}
-	
-	private String formatTime(long millis)
-	{
-		String s = "";
-		int secs = (int) millis / 1000;
-		int mins = secs / 60;
-		secs -= mins * 60;
-		int hours = mins / 60;
-		mins -= hours * 60;
-		
-		if (hours > 0)
+		return new String[]
 		{
-			s += hours + ":";
-		}
-		s += mins + ":";
-		s += secs;
-		return s;
-	}
-	
-	private void showMainPage(L2PcInstance activeChar)
-	{
-		final NpcHtmlMessage adminReply = new NpcHtmlMessage();
-		final List<Castle> castles = CastleManager.getInstance().getCastles();
-		final StringBuilder replyMSG = StringUtil.startAppend(1000 + (castles.size() * 50), "<html><body>" + "<center><table width=270><tr>" + "<td width=45><button value=\"Main\" action=\"bypass -h admin_admin\" width=45 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>" + "<td width=180><center>Manor Info</center></td>" + "<td width=45><button value=\"Back\" action=\"bypass -h admin_admin2\" width=45 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td>" + "</tr></table><font color=\"LEVEL\"> [Manor System] </font></center><br>" + "<table width=\"100%\"><tr><td>" + "Disabled: ", CastleManorManager.getInstance().isDisabled() ? "yes" : "no", "</td><td>" + "Under Maintenance: ", CastleManorManager.getInstance().isUnderMaintenance() ? "yes" : "no", "</td></tr><tr><td>" + "Time to refresh: ", formatTime(CastleManorManager.getInstance().getMillisToManorRefresh()), "</td><td>" + "Time to approve: ", formatTime(CastleManorManager.getInstance().getMillisToNextPeriodApprove()), "</td></tr>" + "</table>" + "<center><table><tr><td>" + "<button value=\"Set Next\" action=\"bypass -h admin_manor_setnext\" width=110 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td>" + "<button value=\"Approve Next\" action=\"bypass -h admin_manor_approve\" width=110 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr><tr><td>" + "<button value=\"", CastleManorManager.getInstance().isUnderMaintenance() ? "Set normal" : "Set mainteance", "\" action=\"bypass -h admin_manor_setmaintenance\" width=110 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td>" + "<button value=\"", CastleManorManager.getInstance().isDisabled() ? "Enable" : "Disable", "\" action=\"bypass -h admin_manor_disable\" width=110 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr><tr><td>" + "<button value=\"Refresh\" action=\"bypass -h admin_manor\" width=110 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td><td>" + "<button value=\"Back\" action=\"bypass -h admin_admin\" width=110 height=21 back=\"L2UI_ct1.button_df\" fore=\"L2UI_ct1.button_df\"></td></tr>" + "</table></center>" + "<br><center>Castle Information:<table width=\"100%\">" + "<tr><td></td><td>Current Period</td><td>Next Period</td></tr>");
-		
-		for (Castle c : CastleManager.getInstance().getCastles())
-		{
-			StringUtil.append(replyMSG, "<tr><td>", c.getName(), "</td>" + "<td>", String.valueOf(c.getManorCost(CastleManorManager.PERIOD_CURRENT)), "a</td>" + "<td>", String.valueOf(c.getManorCost(CastleManorManager.PERIOD_NEXT)), "a</td>" + "</tr>");
-		}
-		
-		replyMSG.append("</table><br>" + "</body></html>");
-		
-		adminReply.setHtml(replyMSG.toString());
-		activeChar.sendPacket(adminReply);
+			"admin_manor"
+		};
 	}
-}
+}
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/handlers/bypasshandlers/ManorManager.java b/L2J_DataPack_BETA/dist/game/data/scripts/handlers/bypasshandlers/ManorManager.java
deleted file mode 100644
index 33c3e35943..0000000000
--- a/L2J_DataPack_BETA/dist/game/data/scripts/handlers/bypasshandlers/ManorManager.java
+++ /dev/null
@@ -1,152 +0,0 @@
-/*
- * Copyright (C) 2004-2014 L2J DataPack
- * 
- * This file is part of L2J DataPack.
- * 
- * L2J DataPack 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.
- * 
- * L2J DataPack 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 handlers.bypasshandlers;
-
-import java.util.StringTokenizer;
-import java.util.logging.Level;
-
-import com.l2jserver.gameserver.handler.IBypassHandler;
-import com.l2jserver.gameserver.instancemanager.CastleManager;
-import com.l2jserver.gameserver.instancemanager.CastleManorManager;
-import com.l2jserver.gameserver.model.actor.L2Character;
-import com.l2jserver.gameserver.model.actor.L2Npc;
-import com.l2jserver.gameserver.model.actor.instance.L2ManorManagerInstance;
-import com.l2jserver.gameserver.model.actor.instance.L2MerchantInstance;
-import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
-import com.l2jserver.gameserver.model.entity.Castle;
-import com.l2jserver.gameserver.network.SystemMessageId;
-import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
-import com.l2jserver.gameserver.network.serverpackets.BuyListSeed;
-import com.l2jserver.gameserver.network.serverpackets.ExShowCropInfo;
-import com.l2jserver.gameserver.network.serverpackets.ExShowManorDefaultInfo;
-import com.l2jserver.gameserver.network.serverpackets.ExShowProcureCropDetail;
-import com.l2jserver.gameserver.network.serverpackets.ExShowSeedInfo;
-import com.l2jserver.gameserver.network.serverpackets.ExShowSellCropList;
-import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
-
-public class ManorManager implements IBypassHandler
-{
-	private static final String[] COMMANDS =
-	{
-		"manor_menu_select"
-	};
-	
-	@Override
-	public boolean useBypass(String command, L2PcInstance activeChar, L2Character target)
-	{
-		final L2Npc manager = activeChar.getLastFolkNPC();
-		if (!((manager instanceof L2ManorManagerInstance)))
-		{
-			return false;
-		}
-		
-		if (!activeChar.isInsideRadius(manager, L2Npc.INTERACTION_DISTANCE, true, false))
-		{
-			return false;
-		}
-		
-		try
-		{
-			final Castle castle = manager.getCastle();
-			if (CastleManorManager.getInstance().isUnderMaintenance())
-			{
-				activeChar.sendPacket(ActionFailed.STATIC_PACKET);
-				activeChar.sendPacket(SystemMessageId.THE_MANOR_SYSTEM_IS_CURRENTLY_UNDER_MAINTENANCE);
-				return true;
-			}
-			
-			final StringTokenizer st = new StringTokenizer(command, "&");
-			final int ask = Integer.parseInt(st.nextToken().split("=")[1]);
-			final int state = Integer.parseInt(st.nextToken().split("=")[1]);
-			final int time = Integer.parseInt(st.nextToken().split("=")[1]);
-			
-			final int castleId;
-			if (state < 0)
-			{
-				castleId = castle.getResidenceId(); // info for current manor
-			}
-			else
-			{
-				castleId = state; // info for requested manor
-			}
-			
-			switch (ask)
-			{
-				case 1: // Seed purchase
-					if (castleId != castle.getResidenceId())
-					{
-						SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.HERE_YOU_CAN_BUY_ONLY_SEEDS_OF_S1_MANOR);
-						sm.addString(manager.getCastle().getName());
-						activeChar.sendPacket(sm);
-					}
-					else
-					{
-						activeChar.sendPacket(new BuyListSeed(activeChar.getAdena(), castleId, castle.getSeedProduction(CastleManorManager.PERIOD_CURRENT)));
-					}
-					break;
-				case 2: // Crop sales
-					activeChar.sendPacket(new ExShowSellCropList(activeChar, castleId, castle.getCropProcure(CastleManorManager.PERIOD_CURRENT)));
-					break;
-				case 3: // Current seeds (Manor info)
-					if ((time == 1) && !CastleManager.getInstance().getCastleById(castleId).isNextPeriodApproved())
-					{
-						activeChar.sendPacket(new ExShowSeedInfo(castleId, null));
-					}
-					else
-					{
-						activeChar.sendPacket(new ExShowSeedInfo(castleId, CastleManager.getInstance().getCastleById(castleId).getSeedProduction(time)));
-					}
-					break;
-				case 4: // Current crops (Manor info)
-					if ((time == 1) && !CastleManager.getInstance().getCastleById(castleId).isNextPeriodApproved())
-					{
-						activeChar.sendPacket(new ExShowCropInfo(castleId, null));
-					}
-					else
-					{
-						activeChar.sendPacket(new ExShowCropInfo(castleId, CastleManager.getInstance().getCastleById(castleId).getCropProcure(time)));
-					}
-					break;
-				case 5: // Basic info (Manor info)
-					activeChar.sendPacket(new ExShowManorDefaultInfo());
-					break;
-				case 6: // Buy harvester
-					((L2MerchantInstance) manager).showBuyWindow(activeChar, 300000 + manager.getId());
-					break;
-				case 9: // Edit sales (Crop sales)
-					activeChar.sendPacket(new ExShowProcureCropDetail(state));
-					break;
-				default:
-					return false;
-			}
-			return true;
-		}
-		catch (Exception e)
-		{
-			_log.log(Level.WARNING, "Exception in " + getClass().getSimpleName(), e);
-		}
-		return false;
-	}
-	
-	@Override
-	public String[] getBypassList()
-	{
-		return COMMANDS;
-	}
-}
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/handlers/effecthandlers/Harvesting.java b/L2J_DataPack_BETA/dist/game/data/scripts/handlers/effecthandlers/Harvesting.java
index 0aaf6483c9..e259d86611 100644
--- a/L2J_DataPack_BETA/dist/game/data/scripts/handlers/effecthandlers/Harvesting.java
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/handlers/effecthandlers/Harvesting.java
@@ -18,8 +18,6 @@
  */
 package handlers.effecthandlers;
 
-import com.l2jserver.Config;
-import com.l2jserver.gameserver.model.L2Object;
 import com.l2jserver.gameserver.model.StatsSet;
 import com.l2jserver.gameserver.model.actor.instance.L2MonsterInstance;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
@@ -28,8 +26,6 @@ import com.l2jserver.gameserver.model.effects.AbstractEffect;
 import com.l2jserver.gameserver.model.holders.ItemHolder;
 import com.l2jserver.gameserver.model.skills.BuffInfo;
 import com.l2jserver.gameserver.network.SystemMessageId;
-import com.l2jserver.gameserver.network.serverpackets.InventoryUpdate;
-import com.l2jserver.gameserver.network.serverpackets.ItemList;
 import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
 import com.l2jserver.util.Rnd;
 
@@ -53,106 +49,75 @@ public final class Harvesting extends AbstractEffect
 	@Override
 	public void onStart(BuffInfo info)
 	{
-		if ((info.getEffector() == null) || (info.getEffected() == null) || !info.getEffector().isPlayer() || !info.getEffected().isNpc() || !info.getEffected().isDead())
+		if ((info.getEffector() == null) || (info.getEffected() == null) || !info.getEffector().isPlayer() || !info.getEffected().isMonster() || !info.getEffected().isDead())
 		{
 			return;
 		}
 		
 		final L2PcInstance player = info.getEffector().getActingPlayer();
-		final L2Object[] targets = info.getSkill().getTargetList(player, false, info.getEffected());
-		if ((targets == null) || (targets.length == 0))
+		final L2MonsterInstance monster = (L2MonsterInstance) info.getEffected();
+		if (player.getObjectId() != monster.getSeederId())
 		{
-			return;
+			player.sendPacket(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_HARVEST);
 		}
-		
-		L2MonsterInstance monster;
-		final InventoryUpdate iu = Config.FORCE_INVENTORY_UPDATE ? null : new InventoryUpdate();
-		for (L2Object target : targets)
+		else if (monster.isSeeded())
 		{
-			if ((target == null) || !target.isMonster())
-			{
-				continue;
-			}
-			
-			monster = (L2MonsterInstance) target;
-			
-			if (player.getObjectId() != monster.getSeederId())
+			if (calcSuccess(player, monster))
 			{
-				SystemMessage sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_HARVEST);
-				player.sendPacket(sm);
-				continue;
-			}
-			
-			boolean send = false;
-			int total = 0;
-			int cropId = 0;
-			
-			if (monster.isSeeded())
-			{
-				if (calcSuccess(player, monster))
+				final ItemHolder item = monster.takeHarvest();
+				if (item != null)
 				{
-					final ItemHolder[] items = monster.takeHarvest();
-					if ((items != null) && (items.length > 0))
+					// Add item
+					player.getInventory().addItem("Harvesting", item.getId(), item.getCount(), player, monster);
+					
+					// Send system msg
+					SystemMessage sm = null;
+					if (item.getCount() == 1)
+					{
+						sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_PICKED_UP_S1);
+						sm.addItemName(item.getId());
+					}
+					else
 					{
-						for (ItemHolder reward : items)
+						sm = SystemMessage.getSystemMessage(SystemMessageId.YOU_PICKED_UP_S1_S2);
+						sm.addItemName(item.getId());
+						sm.addLong(item.getCount());
+					}
+					player.sendPacket(sm);
+					
+					// Send msg to party
+					if (player.isInParty())
+					{
+						if (item.getCount() == 1)
 						{
-							cropId = reward.getId(); // always got 1 type of crop as reward
-							if (player.isInParty())
-							{
-								player.getParty().distributeItem(player, reward, true, monster);
-							}
-							else
-							{
-								if (iu != null)
-								{
-									iu.addItem(player.getInventory().addItem("Harvesting", reward.getId(), reward.getCount(), player, monster));
-								}
-								send = true;
-								total += reward.getCount();
-							}
+							sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HARVESTED_S2S);
+							sm.addString(player.getName());
+							sm.addItemName(item.getId());
 						}
-						
-						if (send)
+						else
 						{
-							SystemMessage smsg = SystemMessage.getSystemMessage(SystemMessageId.YOU_PICKED_UP_S1_S2);
-							smsg.addInt(total);
-							smsg.addItemName(cropId);
-							player.sendPacket(smsg);
-							if (player.isInParty())
-							{
-								smsg = SystemMessage.getSystemMessage(SystemMessageId.C1_HARVESTED_S3_S2S);
-								smsg.addString(player.getName());
-								smsg.addInt(total);
-								smsg.addItemName(cropId);
-								player.getParty().broadcastToPartyMembers(player, smsg);
-							}
-							
-							if (iu != null)
-							{
-								player.sendPacket(iu);
-							}
-							else
-							{
-								player.sendPacket(new ItemList(player, false));
-							}
+							sm = SystemMessage.getSystemMessage(SystemMessageId.C1_HARVESTED_S3_S2S);
+							sm.addString(player.getName());
+							sm.addLong(item.getCount());
+							sm.addItemName(item.getId());
 						}
+						player.getParty().broadcastToPartyMembers(player, sm);
 					}
 				}
-				else
-				{
-					player.sendPacket(SystemMessageId.THE_HARVEST_HAS_FAILED);
-				}
 			}
 			else
 			{
-				player.sendPacket(SystemMessageId.THE_HARVEST_FAILED_BECAUSE_THE_SEED_WAS_NOT_SOWN);
+				player.sendPacket(SystemMessageId.THE_HARVEST_HAS_FAILED);
 			}
 		}
+		else
+		{
+			player.sendPacket(SystemMessageId.THE_HARVEST_FAILED_BECAUSE_THE_SEED_WAS_NOT_SOWN);
+		}
 	}
 	
 	private static boolean calcSuccess(L2PcInstance activeChar, L2MonsterInstance target)
 	{
-		int basicSuccess = 100;
 		final int levelPlayer = activeChar.getLevel();
 		final int levelTarget = target.getLevel();
 		
@@ -164,6 +129,7 @@ public final class Harvesting extends AbstractEffect
 		
 		// apply penalty, target <=> player levels
 		// 5% penalty for each level
+		int basicSuccess = 100;
 		if (diff > 5)
 		{
 			basicSuccess -= (diff - 5) * 5;
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/handlers/effecthandlers/Sow.java b/L2J_DataPack_BETA/dist/game/data/scripts/handlers/effecthandlers/Sow.java
index 14e12ff1d5..deca1de52c 100644
--- a/L2J_DataPack_BETA/dist/game/data/scripts/handlers/effecthandlers/Sow.java
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/handlers/effecthandlers/Sow.java
@@ -19,8 +19,8 @@
 package handlers.effecthandlers;
 
 import com.l2jserver.gameserver.ai.CtrlIntention;
-import com.l2jserver.gameserver.datatables.ManorData;
 import com.l2jserver.gameserver.enums.QuestSound;
+import com.l2jserver.gameserver.model.L2Seed;
 import com.l2jserver.gameserver.model.StatsSet;
 import com.l2jserver.gameserver.model.actor.L2Character;
 import com.l2jserver.gameserver.model.actor.instance.L2MonsterInstance;
@@ -65,20 +65,15 @@ public final class Sow extends AbstractEffect
 			return;
 		}
 		
-		final int seedId = target.getSeedType();
-		if (seedId == 0)
-		{
-			return;
-		}
-		
 		// Consuming used seed
-		if (!player.destroyItemByItemId("Consume", seedId, 1, target, false))
+		final L2Seed seed = target.getSeed();
+		if (!player.destroyItemByItemId("Consume", seed.getSeedId(), 1, target, false))
 		{
 			return;
 		}
 		
 		final SystemMessage sm;
-		if (calcSuccess(player, target, seedId))
+		if (calcSuccess(player, target, seed))
 		{
 			player.sendPacket(QuestSound.ITEMSOUND_QUEST_ITEMGET.getPacket());
 			target.setSeeded(player.getActingPlayer());
@@ -89,27 +84,27 @@ public final class Sow extends AbstractEffect
 			sm = SystemMessage.getSystemMessage(SystemMessageId.THE_SEED_WAS_NOT_SOWN);
 		}
 		
-		if (player.getParty() == null)
+		if (player.isInParty())
 		{
-			player.sendPacket(sm);
+			player.getParty().broadcastPacket(sm);
 		}
 		else
 		{
-			player.getParty().broadcastPacket(sm);
+			player.sendPacket(sm);
 		}
 		
 		// TODO: Mob should not aggro on player, this way doesn't work really nice
 		target.getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE);
 	}
 	
-	private static boolean calcSuccess(L2Character activeChar, L2Character target, int seedId)
+	private static boolean calcSuccess(L2Character activeChar, L2Character target, L2Seed seed)
 	{
 		// TODO: check all the chances
-		int basicSuccess = (ManorData.getInstance().isAlternative(seedId) ? 20 : 90);
-		final int minlevelSeed = ManorData.getInstance().getSeedMinLevel(seedId);
-		final int maxlevelSeed = ManorData.getInstance().getSeedMaxLevel(seedId);
+		final int minlevelSeed = seed.getLevel() - 5;
+		final int maxlevelSeed = seed.getLevel() + 5;
 		final int levelPlayer = activeChar.getLevel(); // Attacker Level
 		final int levelTarget = target.getLevel(); // target Level
+		int basicSuccess = seed.isAlternative() ? 20 : 90;
 		
 		// seed level
 		if (levelTarget < minlevelSeed)
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/handlers/itemhandlers/Harvester.java b/L2J_DataPack_BETA/dist/game/data/scripts/handlers/itemhandlers/Harvester.java
index 0884414b57..b49603b0ea 100644
--- a/L2J_DataPack_BETA/dist/game/data/scripts/handlers/itemhandlers/Harvester.java
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/handlers/itemhandlers/Harvester.java
@@ -18,12 +18,11 @@
  */
 package handlers.itemhandlers;
 
-import java.util.logging.Level;
-
+import com.l2jserver.Config;
 import com.l2jserver.gameserver.handler.IItemHandler;
-import com.l2jserver.gameserver.instancemanager.CastleManorManager;
+import com.l2jserver.gameserver.model.L2Object;
+import com.l2jserver.gameserver.model.actor.L2Character;
 import com.l2jserver.gameserver.model.actor.L2Playable;
-import com.l2jserver.gameserver.model.actor.instance.L2MonsterInstance;
 import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
 import com.l2jserver.gameserver.model.holders.SkillHolder;
 import com.l2jserver.gameserver.model.items.instance.L2ItemInstance;
@@ -33,37 +32,31 @@ import com.l2jserver.gameserver.network.serverpackets.ActionFailed;
 /**
  * @author l3x
  */
-public class Harvester implements IItemHandler
+public final class Harvester implements IItemHandler
 {
 	@Override
 	public boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
 	{
-		if (!playable.isPlayer())
+		if (!Config.ALLOW_MANOR)
 		{
-			playable.sendPacket(SystemMessageId.ITEM_NOT_FOR_PETS);
 			return false;
 		}
-		
-		if (CastleManorManager.getInstance().isDisabled())
+		else if (!playable.isPlayer())
 		{
+			playable.sendPacket(SystemMessageId.ITEM_NOT_FOR_PETS);
 			return false;
 		}
 		
-		final L2PcInstance activeChar = playable.getActingPlayer();
 		final SkillHolder[] skills = item.getItem().getSkills();
-		L2MonsterInstance target = null;
-		if ((activeChar.getTarget() != null) && activeChar.getTarget().isMonster())
-		{
-			target = (L2MonsterInstance) activeChar.getTarget();
-		}
-		
 		if (skills == null)
 		{
-			_log.log(Level.WARNING, getClass().getSimpleName() + ": is missing skills!");
+			_log.warning(getClass().getSimpleName() + ": is missing skills!");
 			return false;
 		}
 		
-		if ((target == null) || !target.isDead())
+		final L2PcInstance activeChar = playable.getActingPlayer();
+		final L2Object target = activeChar.getTarget();
+		if ((target == null) || !target.isMonster() || !((L2Character) target).isDead())
 		{
 			activeChar.sendPacket(SystemMessageId.INCORRECT_TARGET);
 			activeChar.sendPacket(ActionFailed.STATIC_PACKET);
diff --git a/L2J_DataPack_BETA/dist/game/data/scripts/handlers/itemhandlers/Seed.java b/L2J_DataPack_BETA/dist/game/data/scripts/handlers/itemhandlers/Seed.java
index 4e3db66c9e..e44733a703 100644
--- a/L2J_DataPack_BETA/dist/game/data/scripts/handlers/itemhandlers/Seed.java
+++ b/L2J_DataPack_BETA/dist/game/data/scripts/handlers/itemhandlers/Seed.java
@@ -18,13 +18,12 @@
  */
 package handlers.itemhandlers;
 
-import com.l2jserver.gameserver.datatables.ManorData;
+import com.l2jserver.Config;
 import com.l2jserver.gameserver.handler.IItemHandler;
 import com.l2jserver.gameserver.instancemanager.CastleManorManager;
 import com.l2jserver.gameserver.instancemanager.MapRegionManager;
 import com.l2jserver.gameserver.model.L2Object;
-import com.l2jserver.gameserver.model.actor.L2Character;
-import com.l2jserver.gameserver.model.actor.L2Npc;
+import com.l2jserver.gameserver.model.L2Seed;
 import com.l2jserver.gameserver.model.actor.L2Playable;
 import com.l2jserver.gameserver.model.actor.instance.L2ChestInstance;
 import com.l2jserver.gameserver.model.actor.instance.L2MonsterInstance;
@@ -42,28 +41,25 @@ public class Seed implements IItemHandler
 	@Override
 	public boolean useItem(L2Playable playable, L2ItemInstance item, boolean forceUse)
 	{
-		if (!playable.isPlayer())
+		if (!Config.ALLOW_MANOR)
 		{
-			playable.sendPacket(SystemMessageId.ITEM_NOT_FOR_PETS);
 			return false;
 		}
-		
-		if (CastleManorManager.getInstance().isDisabled())
+		else if (!playable.isPlayer())
 		{
+			playable.sendPacket(SystemMessageId.ITEM_NOT_FOR_PETS);
 			return false;
 		}
 		
 		final L2Object tgt = playable.getTarget();
-		if (!(tgt instanceof L2Npc))
+		if (!tgt.isNpc())
 		{
 			playable.sendPacket(SystemMessageId.INCORRECT_TARGET);
-			playable.sendPacket(ActionFailed.STATIC_PACKET);
 			return false;
 		}
-		if (!(tgt instanceof L2MonsterInstance) || (tgt instanceof L2ChestInstance) || ((L2Character) tgt).isRaid())
+		else if (!tgt.isMonster() || ((L2MonsterInstance) tgt).isRaid() || (tgt instanceof L2ChestInstance))
 		{
 			playable.sendPacket(SystemMessageId.THE_TARGET_IS_UNAVAILABLE_FOR_SEEDING);
-			playable.sendPacket(ActionFailed.STATIC_PACKET);
 			return false;
 		}
 		
@@ -71,26 +67,29 @@ public class Seed implements IItemHandler
 		if (target.isDead())
 		{
 			playable.sendPacket(SystemMessageId.INCORRECT_TARGET);
-			playable.sendPacket(ActionFailed.STATIC_PACKET);
 			return false;
 		}
-		
-		if (target.isSeeded())
+		else if (target.isSeeded())
 		{
 			playable.sendPacket(ActionFailed.STATIC_PACKET);
 			return false;
 		}
 		
-		final int seedId = item.getId();
-		if (!areaValid(seedId, MapRegionManager.getInstance().getAreaCastle(playable)))
+		final L2Seed seed = CastleManorManager.getInstance().getSeed(item.getId());
+		if (seed == null)
+		{
+			return false;
+		}
+		else if (seed.getCastleId() != MapRegionManager.getInstance().getAreaCastle(playable)) // TODO: replace me with tax zone
 		{
 			playable.sendPacket(SystemMessageId.THIS_SEED_MAY_NOT_BE_SOWN_HERE);
 			return false;
 		}
 		
-		target.setSeeded(seedId, (L2PcInstance) playable);
-		final SkillHolder[] skills = item.getItem().getSkills();
 		final L2PcInstance activeChar = playable.getActingPlayer();
+		target.setSeeded(seed, activeChar);
+		
+		final SkillHolder[] skills = item.getItem().getSkills();
 		if (skills != null)
 		{
 			for (SkillHolder sk : skills)
@@ -100,14 +99,4 @@ public class Seed implements IItemHandler
 		}
 		return true;
 	}
-	
-	/**
-	 * @param seedId
-	 * @param castleId
-	 * @return
-	 */
-	private boolean areaValid(int seedId, int castleId)
-	{
-		return (ManorData.getInstance().getCastleIdForSeed(seedId) == castleId);
-	}
 }
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/game/data/stats/npcs/35100-35200.xml b/L2J_DataPack_BETA/dist/game/data/stats/npcs/35100-35200.xml
index 52d655e393..942edd67bf 100644
--- a/L2J_DataPack_BETA/dist/game/data/stats/npcs/35100-35200.xml
+++ b/L2J_DataPack_BETA/dist/game/data/stats/npcs/35100-35200.xml
@@ -137,7 +137,7 @@
 			<height normal="21.5" />
 		</collision>
 	</npc>
-	<npc id="35103" level="75" type="L2ManorManager" name="Manor Manager" title="Gludio">
+	<npc id="35103" level="75" type="L2Merchant" name="Manor Manager" title="Gludio">
 		<!-- Confirmed CT2.5 -->
 		<parameters>
 			<param name="MoveAroundSocial" value="0" />
@@ -2060,7 +2060,7 @@
 			<height normal="21.5" />
 		</collision>
 	</npc>
-	<npc id="35145" level="75" type="L2ManorManager" name="Manor Manager" title="Dion">
+	<npc id="35145" level="75" type="L2Merchant" name="Manor Manager" title="Dion">
 		<!-- Confirmed CT2.5 -->
 		<parameters>
 			<param name="MoveAroundSocial" value="0" />
@@ -3984,7 +3984,7 @@
 			<height normal="21.5" />
 		</collision>
 	</npc>
-	<npc id="35187" level="75" type="L2ManorManager" name="Manor Manager" title="Giran">
+	<npc id="35187" level="75" type="L2Merchant" name="Manor Manager" title="Giran">
 		<!-- Confirmed CT2.5 -->
 		<parameters>
 			<param name="MoveAroundSocial" value="0" />
diff --git a/L2J_DataPack_BETA/dist/game/data/stats/npcs/35200-35300.xml b/L2J_DataPack_BETA/dist/game/data/stats/npcs/35200-35300.xml
index ab7045ba3c..2a79478153 100644
--- a/L2J_DataPack_BETA/dist/game/data/stats/npcs/35200-35300.xml
+++ b/L2J_DataPack_BETA/dist/game/data/stats/npcs/35200-35300.xml
@@ -1355,7 +1355,7 @@
 			<height normal="21.5" />
 		</collision>
 	</npc>
-	<npc id="35229" level="75" type="L2ManorManager" name="Manor Manager" title="Oren">
+	<npc id="35229" level="75" type="L2Merchant" name="Manor Manager" title="Oren">
 		<!-- Confirmed CT2.5 -->
 		<parameters>
 			<param name="MoveAroundSocial" value="0" />
@@ -1396,7 +1396,7 @@
 			<height normal="22.5" />
 		</collision>
 	</npc>
-	<npc id="35230" level="75" type="L2ManorManager" name="Manor Manager" title="Oren">
+	<npc id="35230" level="75" type="L2Merchant" name="Manor Manager" title="Oren">
 		<!-- Confirmed CT2.5 -->
 		<parameters>
 			<param name="MoveAroundSocial" value="0" />
@@ -1437,7 +1437,7 @@
 			<height normal="24.5" />
 		</collision>
 	</npc>
-	<npc id="35231" level="75" type="L2ManorManager" name="Manor Manager" title="Oren">
+	<npc id="35231" level="75" type="L2Merchant" name="Manor Manager" title="Oren">
 		<!-- Confirmed CT2.5 -->
 		<parameters>
 			<param name="MoveAroundSocial" value="0" />
@@ -3667,7 +3667,7 @@
 			<height normal="21.5" />
 		</collision>
 	</npc>
-	<npc id="35277" level="75" type="L2ManorManager" name="Manor Manager" title="Aden">
+	<npc id="35277" level="75" type="L2Merchant" name="Manor Manager" title="Aden">
 		<!-- Confirmed CT2.5 -->
 		<parameters>
 			<param name="MoveAroundSocial" value="0" />
diff --git a/L2J_DataPack_BETA/dist/game/data/stats/npcs/35300-35400.xml b/L2J_DataPack_BETA/dist/game/data/stats/npcs/35300-35400.xml
index 69a26aa511..4213300397 100644
--- a/L2J_DataPack_BETA/dist/game/data/stats/npcs/35300-35400.xml
+++ b/L2J_DataPack_BETA/dist/game/data/stats/npcs/35300-35400.xml
@@ -904,7 +904,7 @@
 			<height normal="21.5" />
 		</collision>
 	</npc>
-	<npc id="35319" level="75" type="L2ManorManager" name="Manor Manager" title="Innadril">
+	<npc id="35319" level="75" type="L2Merchant" name="Manor Manager" title="Innadril">
 		<!-- Confirmed CT2.5 -->
 		<parameters>
 			<param name="MoveAroundSocial" value="0" />
@@ -3000,7 +3000,7 @@
 			<height normal="24" />
 		</collision>
 	</npc>
-	<npc id="35366" level="75" type="L2ManorManager" name="Manor Manager" title="Goddard">
+	<npc id="35366" level="75" type="L2Merchant" name="Manor Manager" title="Goddard">
 		<!-- Confirmed CT2.5 -->
 		<parameters>
 			<param name="MoveAroundSocial" value="0" />
diff --git a/L2J_DataPack_BETA/dist/game/data/stats/npcs/35500-35600.xml b/L2J_DataPack_BETA/dist/game/data/stats/npcs/35500-35600.xml
index 971972ebe7..57220211ac 100644
--- a/L2J_DataPack_BETA/dist/game/data/stats/npcs/35500-35600.xml
+++ b/L2J_DataPack_BETA/dist/game/data/stats/npcs/35500-35600.xml
@@ -603,7 +603,7 @@
 			<height normal="24" />
 		</collision>
 	</npc>
-	<npc id="35512" level="75" type="L2ManorManager" name="Manor Manager" title="Rune">
+	<npc id="35512" level="75" type="L2Merchant" name="Manor Manager" title="Rune">
 		<!-- Confirmed CT2.5 -->
 		<parameters>
 			<param name="MoveAroundSocial" value="0" />
@@ -2667,7 +2667,7 @@
 			<height normal="24" />
 		</collision>
 	</npc>
-	<npc id="35558" level="75" type="L2ManorManager" name="Manor Manager" title="Schuttgart ">
+	<npc id="35558" level="75" type="L2Merchant" name="Manor Manager" title="Schuttgart ">
 		<!-- Confirmed CT2.5 -->
 		<parameters>
 			<param name="MoveAroundSocial" value="0" />
diff --git a/L2J_DataPack_BETA/dist/game/data/stats/npcs/35600-35700.xml b/L2J_DataPack_BETA/dist/game/data/stats/npcs/35600-35700.xml
index 94364ee2bc..a6e5bc6447 100644
--- a/L2J_DataPack_BETA/dist/game/data/stats/npcs/35600-35700.xml
+++ b/L2J_DataPack_BETA/dist/game/data/stats/npcs/35600-35700.xml
@@ -2003,7 +2003,7 @@
 			<height normal="24" />
 		</collision>
 	</npc>
-	<npc id="35644" level="70" type="L2ManorManager" name="Manor Manager" title="Schuttgart">
+	<npc id="35644" level="70" type="L2Merchant" name="Manor Manager" title="Schuttgart">
 		<!-- Confirmed CT2.5 -->
 		<parameters>
 			<param name="MoveAroundSocial" value="0" />
@@ -2044,7 +2044,7 @@
 			<height normal="17" />
 		</collision>
 	</npc>
-	<npc id="35645" level="70" type="L2ManorManager" name="Manor Manager" title="Schuttgart">
+	<npc id="35645" level="70" type="L2Merchant" name="Manor Manager" title="Schuttgart">
 		<!-- Confirmed CT2.5 -->
 		<parameters>
 			<param name="MoveAroundSocial" value="0" />
diff --git a/L2J_DataPack_BETA/dist/game/data/stats/npcs/36400-36500.xml b/L2J_DataPack_BETA/dist/game/data/stats/npcs/36400-36500.xml
index 1eb39d21bf..a5de31fce6 100644
--- a/L2J_DataPack_BETA/dist/game/data/stats/npcs/36400-36500.xml
+++ b/L2J_DataPack_BETA/dist/game/data/stats/npcs/36400-36500.xml
@@ -2409,7 +2409,7 @@
 			<height normal="18.5" />
 		</collision>
 	</npc>
-	<npc id="36456" level="75" type="L2ManorManager" name="Manor Manager" title="Aden">
+	<npc id="36456" level="75" type="L2Merchant" name="Manor Manager" title="Aden">
 		<!-- Confirmed CT2.5 -->
 		<parameters>
 			<param name="MoveAroundSocial" value="0" />
diff --git a/L2J_DataPack_BETA/dist/sql/game/castle_manor_procure.sql b/L2J_DataPack_BETA/dist/sql/game/castle_manor_procure.sql
index 12c07075c8..f158bf03a5 100644
--- a/L2J_DataPack_BETA/dist/sql/game/castle_manor_procure.sql
+++ b/L2J_DataPack_BETA/dist/sql/game/castle_manor_procure.sql
@@ -1,10 +1,10 @@
 CREATE TABLE IF NOT EXISTS `castle_manor_procure` (
-  `castle_id` INT NOT NULL DEFAULT '0',
-  `crop_id` int(11) NOT NULL DEFAULT '0',
-  `can_buy` int(11) NOT NULL DEFAULT '0',
-  `start_buy` int(11) NOT NULL DEFAULT '0',
-  `price` int(11) NOT NULL DEFAULT '0',
-  `reward_type` int(11) NOT NULL DEFAULT '0',
-  `period` INT NOT NULL DEFAULT '1',
-  PRIMARY KEY (`castle_id`,`crop_id`,`period`)
+ `castle_id` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
+ `crop_id` INT(11) UNSIGNED NOT NULL DEFAULT '0',
+ `amount` INT(11) UNSIGNED NOT NULL DEFAULT '0',
+ `start_amount` INT(11) UNSIGNED NOT NULL DEFAULT '0',
+ `price` INT(11) UNSIGNED NOT NULL DEFAULT '0',
+ `reward_type` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0',
+ `next_period` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1',
+  PRIMARY KEY (`castle_id`,`crop_id`,`next_period`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/sql/game/castle_manor_production.sql b/L2J_DataPack_BETA/dist/sql/game/castle_manor_production.sql
index dcc6be5ed9..7ccdbf827c 100644
--- a/L2J_DataPack_BETA/dist/sql/game/castle_manor_production.sql
+++ b/L2J_DataPack_BETA/dist/sql/game/castle_manor_production.sql
@@ -1,9 +1,9 @@
 CREATE TABLE IF NOT EXISTS `castle_manor_production` (
-  `castle_id` INT NOT NULL DEFAULT '0',
-  `seed_id` int(11) NOT NULL DEFAULT '0',
-  `can_produce` int(11) NOT NULL DEFAULT '0',
-  `start_produce` int(11) NOT NULL DEFAULT '0',
-  `seed_price` int(11) NOT NULL DEFAULT '0',
-  `period` INT NOT NULL DEFAULT '1',
-  PRIMARY KEY (`castle_id`,`seed_id`,`period`)
+ `castle_id` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0',
+ `seed_id` INT(11) UNSIGNED NOT NULL DEFAULT '0',
+ `amount` INT(11) UNSIGNED NOT NULL DEFAULT '0',
+ `start_amount` INT(11) UNSIGNED NOT NULL DEFAULT '0',
+ `price` INT(11) UNSIGNED NOT NULL DEFAULT '0',
+ `next_period` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1',
+ PRIMARY KEY (`castle_id`, `seed_id`, `next_period`)
 ) ENGINE=InnoDB DEFAULT CHARSET=utf8;
\ No newline at end of file
diff --git a/L2J_DataPack_BETA/dist/sql/game/updates/20140907update.sql b/L2J_DataPack_BETA/dist/sql/game/updates/20140907update.sql
new file mode 100644
index 0000000000..dd098fd51e
--- /dev/null
+++ b/L2J_DataPack_BETA/dist/sql/game/updates/20140907update.sql
@@ -0,0 +1,16 @@
+ALTER TABLE `castle_manor_procure`
+	CHANGE COLUMN `castle_id` `castle_id` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' FIRST,
+	CHANGE COLUMN `crop_id` `crop_id` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `castle_id`,
+	CHANGE COLUMN `can_buy` `amount` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `crop_id`,
+	CHANGE COLUMN `start_buy` `start_amount` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `amount`,
+	CHANGE COLUMN `price` `price` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `start_amount`,
+	CHANGE COLUMN `reward_type` `reward_type` TINYINT(1) UNSIGNED NOT NULL DEFAULT '0' AFTER `price`,
+	CHANGE COLUMN `period` `next_period` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1' AFTER `reward_type`;
+
+ALTER TABLE `castle_manor_production`
+	CHANGE COLUMN `castle_id` `castle_id` TINYINT(3) UNSIGNED NOT NULL DEFAULT '0' FIRST,
+	CHANGE COLUMN `seed_id` `seed_id` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `castle_id`,
+	CHANGE COLUMN `can_produce` `amount` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `seed_id`,
+	CHANGE COLUMN `start_produce` `start_amount` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `amount`,
+	CHANGE COLUMN `seed_price` `price` INT(11) UNSIGNED NOT NULL DEFAULT '0' AFTER `start_amount`,
+	CHANGE COLUMN `period` `next_period` TINYINT(1) UNSIGNED NOT NULL DEFAULT '1' AFTER `price`;
\ No newline at end of file
-- 
GitLab