getCastle().getSiege().listRegisterClan(player); // List current register clan
return;
}
else if (actualCommand.equalsIgnoreCase("receive_report"))
{
NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
html.setFile("data/html/chamberlain/chamberlain-report.htm");
html.replace("%objectId%", String.valueOf(getObjectId()));
L2Clan clan = ClanTable.getInstance().getClan(getCastle().getOwnerId());
html.replace("%clanname%", clan.getName());
html.replace("%clanleadername%", clan.getLeaderName());
html.replace("%castlename%", getCastle().getName());
{
int currentPeriod = SevenSigns.getInstance().getCurrentPeriod();
switch (currentPeriod)
{
case SevenSigns.PERIOD_COMP_RECRUITING:
html.replace("%ss_event%", "Quest Event Initialization");
break;
case SevenSigns.PERIOD_COMPETITION:
html.replace("%ss_event%", "Competition (Quest Event)");
break;
case SevenSigns.PERIOD_COMP_RESULTS:
html.replace("%ss_event%", "Quest Event Results");
break;
case SevenSigns.PERIOD_SEAL_VALIDATION:
html.replace("%ss_event%", "Seal Validation");
break;
}
}
{
int sealOwner1 = SevenSigns.getInstance().getSealOwner(1);
switch (sealOwner1)
{
case SevenSigns.CABAL_NULL:
html.replace("%ss_avarice%", "Not in Possession");
break;
case SevenSigns.CABAL_DAWN:
html.replace("%ss_avarice%", "Lords of Dawn");
break;
case SevenSigns.CABAL_DUSK:
html.replace("%ss_avarice%", "Revolutionaries of Dusk");
break;
}
}
{
int sealOwner2 = SevenSigns.getInstance().getSealOwner(2);
switch (sealOwner2)
{
case SevenSigns.CABAL_NULL:
html.replace("%ss_gnosis%", "Not in Possession");
break;
case SevenSigns.CABAL_DAWN:
html.replace("%ss_gnosis%", "Lords of Dawn");
break;
case SevenSigns.CABAL_DUSK:
html.replace("%ss_gnosis%", "Revolutionaries of Dusk");
break;
}
}
{
int sealOwner3 = SevenSigns.getInstance().getSealOwner(3);
switch (sealOwner3)
{
case SevenSigns.CABAL_NULL:
html.replace("%ss_strife%", "Not in Possession");
break;
case SevenSigns.CABAL_DAWN:
html.replace("%ss_strife%", "Lords of Dawn");
break;
case SevenSigns.CABAL_DUSK:
html.replace("%ss_strife%", "Revolutionaries of Dusk");
break;
}
}
player.sendPacket(html);
return;
}
else if (actualCommand.equalsIgnoreCase("items"))
{
if (val == "") return;
player.tempInvetoryDisable();
if (Config.DEBUG) _log.fine("Showing chamberlain buylist");
int buy;
{
int castleId = getCastle().getCastleId();
int circlet = CastleManager.getInstance().getCircletByCastleId(castleId);
PcInventory s = player.getInventory();
if (s.getItemByItemId(circlet)==null)
{
buy = (Integer.parseInt(val+"1"));
}
else
{
buy = (Integer.parseInt(val+"2"));
}
}
L2TradeList list = TradeController.getInstance().getBuyList(buy);
if (list != null && list.getNpcId().equals(String.valueOf(getNpcId())))
{
BuyList bl = new BuyList(list, player.getAdena(), 0);
player.sendPacket(bl);
}
else
{
_log.warning("player: " + player.getName()
+ " attempting to buy from chamberlain that don't have buylist!");
_log.warning("buylist id:" + buy);
}
player.sendPacket(new ActionFailed());
}
else if (actualCommand.equalsIgnoreCase("manage_siege_defender"))
{
getCastle().getSiege().listRegisterClan(player);
return;
}
else if (actualCommand.equalsIgnoreCase("manage_vault")) {
String filename = "data/html/chamberlain/chamberlain-vault.htm";
int amount = 0;
if (val.equalsIgnoreCase("deposit")) {
try {
amount = Integer.parseInt(st.nextToken());
} catch(NoSuchElementException e) {}
if (amount > 0 && (long)getCastle().getTreasury() + amount < Integer.MAX_VALUE) {
if (player.reduceAdena("Castle", amount, this, true)) {
getCastle().addToTreasuryNoTax(amount);
} else {
sendPacket(new SystemMessage(SystemMessageId.YOU_NOT_ENOUGH_ADENA));
}
}
} else if (val.equalsIgnoreCase("withdraw")) {
try {
amount = Integer.parseInt(st.nextToken());
} catch(NoSuchElementException e) {}
if (amount > 0) {
if (getCastle().getTreasury() < amount) {
filename = "data/html/chamberlain/chamberlain-vault-no.htm";
} else {
if (getCastle().addToTreasuryNoTax((-1)*amount))
player.addAdena("Castle", amount, this, true);
}
}
}
NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
html.setFile(filename);
html.replace("%objectId%", String.valueOf(getObjectId()));
html.replace("%npcname%", getName());
html.replace("%tax_income%", Util.formatAdena(getCastle().getTreasury()));
html.replace("%withdraw_amount%", Util.formatAdena(amount));
player.sendPacket(html);
return;
}
else if(actualCommand.equalsIgnoreCase("manor")) {
String filename = "";
if (CastleManorManager.getInstance().isDisabled()) {
filename = "data/html/npcdefault.htm";
} else {
int cmd = Integer.parseInt(val);
switch(cmd) {
case 0:
filename = "data/html/chamberlain/manor/manor.htm";
break;
// TODO: correct in html's to 1
case 4:
filename = "data/html/chamberlain/manor/manor_help00"+st.nextToken()+".htm";
break;
default:
filename = "data/html/chamberlain/chamberlain-no.htm";
break;
}
}
if (filename.length()!=0) {
NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
html.setFile(filename);
html.replace("%objectId%", String.valueOf(getObjectId()));
html.replace("%npcname%", getName());
player.sendPacket(html);
}
return;
}
else if (command.startsWith("manor_menu_select"))
{// input string format:
// manor_menu_select?ask=X&state=Y&time=X
if (CastleManorManager.getInstance().isUnderMaintenance())
{
player.sendPacket(new ActionFailed());
player.sendPacket(new SystemMessage(SystemMessageId.THE_MANOR_SYSTEM_IS_CURRENTLY_UNDER_MAINTENANCE));
return;
}
String params = command.substring(command.indexOf("?")+1);
StringTokenizer str = new StringTokenizer(params, "&");
int ask = Integer.parseInt(str.nextToken().split("=")[1]);
int state = Integer.parseInt(str.nextToken().split("=")[1]);
int time = Integer.parseInt(str.nextToken().split("=")[1]);
int castleId;
if (state == -1) // info for current manor
castleId = getCastle().getCastleId();
else // info for requested manor
castleId = state;
switch (ask) { // Main action
case 3: // Current seeds (Manor info)
if (time == 1 && !CastleManager.getInstance().getCastleById(castleId).isNextPeriodApproved())
player.sendPacket(new ExShowSeedInfo(castleId, null));
else
player.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())
player.sendPacket(new ExShowCropInfo(castleId, null));
else
player.sendPacket(new ExShowCropInfo(castleId, CastleManager.getInstance().getCastleById(castleId).getCropProcure(time)));
break;
case 5: // Basic info (Manor info)
player.sendPacket(new ExShowManorDefaultInfo());
break;
case 7: // Edit seed setup
if (getCastle().isNextPeriodApproved()) {
player.sendPacket(new SystemMessage(SystemMessageId.A_MANOR_CANNOT_BE_SET_UP_BETWEEN_6_AM_AND_8_PM));
} else {
player.sendPacket(new ExShowSeedSetting(getCastle().getCastleId()));
}
break;
case 8: // Edit crop setup
if (getCastle().isNextPeriodApproved()) {
player.sendPacket(new SystemMessage(SystemMessageId.A_MANOR_CANNOT_BE_SET_UP_BETWEEN_6_AM_AND_8_PM));
} else {
player.sendPacket(new ExShowCropSetting(getCastle().getCastleId()));
}
break;
}
}
else if(actualCommand.equalsIgnoreCase("operate_door")) // door control
{
if (val != "")
{
boolean open = (Integer.parseInt(val) == 1);
while (st.hasMoreTokens())
{
getCastle().openCloseDoor(player, Integer.parseInt(st.nextToken()), open);
}
}
NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
html.setFile("data/html/chamberlain/" + getTemplate().npcId + "-d.htm");
html.replace("%objectId%", String.valueOf(getObjectId()));
html.replace("%npcname%", getName());
player.sendPacket(html);
return;
}
else if(actualCommand.equalsIgnoreCase("tax_set")) // tax rates control
{