rendered paste bodyIndex: java/net/sf/l2j/gameserver/CastleUpdater.java
===================================================================
--- java/net/sf/l2j/gameserver/CastleUpdater.java (revision 1224)
+++ java/net/sf/l2j/gameserver/CastleUpdater.java (working copy)
@@ -17,10 +17,9 @@
*/
package net.sf.l2j.gameserver;
-import net.sf.l2j.gameserver.instancemanager.CastleManager;
+import net.sf.l2j.Config;
import net.sf.l2j.gameserver.model.ItemContainer;
import net.sf.l2j.gameserver.model.L2Clan;
-import net.sf.l2j.gameserver.model.entity.Castle;
import net.sf.l2j.util.Rnd;
@@ -44,30 +43,13 @@
public void run()
{
try {
- // Move current castle treasury to clan warehouse every 2 hour
ItemContainer warehouse = _clan.getWarehouse();
if ((warehouse != null)&&(_clan.getHasCastle() > 0))
{
- if (_runCount % 2 == 0)
- {
- Castle castle = CastleManager.getInstance().getCastleById(_clan.getHasCastle());
-
- int amount = castle.getTreasury();
- if (amount > 0)
- {
- // Move the current treasury amount to clan warehouse
- if (castle.addToTreasuryNoTax(amount * -1))
- warehouse.addItem("Castle", 57, amount, null, null);
-
- }
- }
-
- // TODO: Check if those free items to clanWH are correct. As far as I can find,
- // castle owners normally earn these items via the manor system! -- Fulminus
-
+ // If Manor System is disabled:
// Give clan 1 Dualsword Craft Stamp every 3 hour (8 per day)
// Give clan ~1 Secret Book of Giants daily (it's been confirmed that castle owners get these, but method is unknown)
- if (_runCount % 3 == 0)
+ if (_runCount % 3 == 0 && !Config.ALLOW_MANOR)
{
warehouse.addItem("Castle", 5126, 1, null, null);
if (Rnd.get(100) < 25) warehouse.addItem("Castle", 6622, 1, null, null);
@@ -76,7 +58,6 @@
_runCount++;
if (_runCount == 7) _runCount = 1;
- // FIXME: Why are we rescheduling in this manner, instead of scheduling with fixed rate from the beginning?
// re-run again in 1 hours
CastleUpdater cu = new CastleUpdater(_clan, _runCount);
ThreadPoolManager.getInstance().scheduleGeneral(cu, 3600000);
Index: java/net/sf/l2j/gameserver/model/entity/Castle.java
===================================================================
--- java/net/sf/l2j/gameserver/model/entity/Castle.java (revision 1224)
+++ java/net/sf/l2j/gameserver/model/entity/Castle.java (working copy)
@@ -25,6 +25,7 @@
import java.util.logging.Logger;
import javolution.util.FastList;
+import net.sf.l2j.Config;
import net.sf.l2j.L2DatabaseFactory;
import net.sf.l2j.gameserver.Announcements;
import net.sf.l2j.gameserver.CastleUpdater;
@@ -102,27 +103,30 @@
{
if (getOwnerId() <= 0) return;
- if (_name.equalsIgnoreCase("Schuttgart") || _name.equalsIgnoreCase("Goddard"))
+ if (amount > 0)
{
- Castle rune = CastleManager.getInstance().getCastle("rune");
- if (rune != null )
- {
- int runeTax = (int)(amount * rune.getTaxRate());
- if (rune.getOwnerId() > 0 ) rune.addToTreasury(runeTax);
- amount -= runeTax;
- }
+ if (_name.equalsIgnoreCase("Schuttgart") || _name.equalsIgnoreCase("Goddard"))
+ {
+ Castle rune = CastleManager.getInstance().getCastle("rune");
+ if (rune != null )
+ {
+ int runeTax = (int)(amount * rune.getTaxRate());
+ if (rune.getOwnerId() > 0 ) rune.addToTreasury(runeTax);
+ amount -= runeTax;
+ }
+ }
+ if (!_name.equalsIgnoreCase("aden") && !_name.equalsIgnoreCase("Rune") && !_name.equalsIgnoreCase("Schuttgart") && !_name.equalsIgnoreCase("Goddard")) // If current castle instance is not Aden, Rune, Goddard or Schuttgart.
+ {
+ Castle aden = CastleManager.getInstance().getCastle("aden");
+ if (aden != null)
+ {
+ int adenTax = (int)(amount * aden.getTaxRate()); // Find out what Aden gets from the current castle instance's income
+ if (aden.getOwnerId() > 0) aden.addToTreasury(adenTax); // Only bother to really add the tax to the treasury if not npc owned
+
+ amount -= adenTax; // Subtract Aden's income from current castle instance's income
+ }
+ }
}
- if (!_name.equalsIgnoreCase("aden") && !_name.equalsIgnoreCase("Rune") && !_name.equalsIgnoreCase("Schuttgart") && !_name.equalsIgnoreCase("Goddard")) // If current castle instance is not Aden, Rune, Goddard or Schuttgart.
- {
- Castle aden = CastleManager.getInstance().getCastle("aden");
- if (aden != null)
- {
- int adenTax = (int)(amount * aden.getTaxRate()); // Find out what Aden gets from the current castle instance's income
- if (aden.getOwnerId() > 0) aden.addToTreasury(adenTax); // Only bother to really add the tax to the treasury if not npc owned
-
- amount -= adenTax; // Subtract Aden's income from current castle instance's income
- }
- }
addToTreasuryNoTax(amount);
}
@@ -410,7 +414,7 @@
_ownerId = rs.getInt("clan_id");
}
- if (getOwnerId() > 0)
+ if (!Config.ALLOW_MANOR && getOwnerId() > 0)
{
L2Clan clan = ClanTable.getInstance().getClan(getOwnerId()); // Try to find clan instance
ThreadPoolManager.getInstance().scheduleGeneral(new CastleUpdater(clan, 1), 3600000); // Schedule owner tasks to start running
@@ -576,7 +580,8 @@
new Announcements().announceToAll(clan.getName() + " has taken " + getName() + " castle!");
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
- ThreadPoolManager.getInstance().scheduleGeneral(new CastleUpdater(clan, 1), 3600000); // Schedule owner tasks to start running
+ if (!Config.ALLOW_MANOR)
+ ThreadPoolManager.getInstance().scheduleGeneral(new CastleUpdater(clan, 1), 3600000); // Schedule owner tasks to start running
}
}
catch (Exception e)