rendered paste bodyIndex: java/net/sf/l2j/gameserver/CastleUpdater.java
===================================================================
--- java/net/sf/l2j/gameserver/CastleUpdater.java (revision 1212)
+++ java/net/sf/l2j/gameserver/CastleUpdater.java (working copy)
@@ -17,7 +17,9 @@
*/
package net.sf.l2j.gameserver;
+import net.sf.l2j.Config;
import net.sf.l2j.gameserver.instancemanager.CastleManager;
+import net.sf.l2j.gameserver.instancemanager.CastleManorManager;
import net.sf.l2j.gameserver.model.ItemContainer;
import net.sf.l2j.gameserver.model.L2Clan;
import net.sf.l2j.gameserver.model.entity.Castle;
@@ -52,18 +54,19 @@
{
Castle castle = CastleManager.getInstance().getCastleById(_clan.getHasCastle());
+ int manorCost = castle.getManorCost(CastleManorManager.PERIOD_NEXT);
int amount = castle.getTreasury();
- if (amount > 0)
+ if (manorCost < amount && amount > 0)
{
// Move the current treasury amount to clan warehouse
- warehouse.addItem("Castle", 57, amount, null, null);
- castle.addToTreasury(amount * -1);
+ warehouse.addItem("Castle", 57, (amount - manorCost), null, null);
+ castle.addToTreasury((amount - manorCost) * -1);
}
}
// 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);
Index: java/net/sf/l2j/gameserver/model/entity/Castle.java
===================================================================
--- java/net/sf/l2j/gameserver/model/entity/Castle.java (revision 1212)
+++ java/net/sf/l2j/gameserver/model/entity/Castle.java (working copy)
@@ -102,27 +102,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);
}
@@ -132,7 +135,7 @@
{
if (getOwnerId() <= 0) return;
- if (Integer.MAX_VALUE - amount < _treasury)
+ if (amount > 0 && Integer.MAX_VALUE - amount < _treasury)
return;
_treasury += amount; // Add to the current treasury total. Use "-" to substract from treasury