String template = "<a action=\"bypass -h npc_%objectId%_support %id% %level%\">%name%</a><br1>";
String support_list = "";
int i = 0;
for(Object[] buff : getResidence().getFunction(ResidenceFunction.SUPPORT).getBuffs())
{
L2Skill s = (L2Skill) buff[0];
support_list += template.replaceAll("%id%", String.valueOf(s.getId())).replaceAll("%level%", String.valueOf(s.getLevel())).replaceAll("%name%", s.getName() + " Lv." + s.getDisplayLevel());
if(++i % 5 == 0)
{
support_list += "<br>";
}
}
html.replace("%magicList%", support_list);
html.replace("%mp%", String.valueOf(Math.round(getCurrentMp())));
html.replace("%all%", Config.ALT_CH_ALL_BUFFS ? "<a action=\"bypass -h npc_%objectId%_support all\">Give all</a><br1><a action=\"bypass -h npc_%objectId%_support allW\">Give warrior</a><br1><a action=\"bypass -h npc_%objectId%_support allM\">Give mystic</a><br>" : "");
sendHtmlMessage(player, html);
}
else if(val.equalsIgnoreCase("back"))
{
showChatWindow(player, 0);
}
else
{
NpcHtmlMessage html = new NpcHtmlMessage(player, this);
html.setFile("data/html/residence/functions.htm");
if(getResidence().isFunctionActive(ResidenceFunction.RESTORE_EXP))
{
html.replace("%xp_regen%", String.valueOf(getResidence().getFunction(ResidenceFunction.RESTORE_EXP).getLevel()) + "%");
}
else
{
html.replace("%xp_regen%", "0%");
}
if(getResidence().isFunctionActive(ResidenceFunction.RESTORE_HP))
{
html.replace("%hp_regen%", String.valueOf(getResidence().getFunction(ResidenceFunction.RESTORE_HP).getLevel()) + "%");
}
else
{
html.replace("%hp_regen%", "0%");
}
if(getResidence().isFunctionActive(ResidenceFunction.RESTORE_MP))
{
html.replace("%mp_regen%", String.valueOf(getResidence().getFunction(ResidenceFunction.RESTORE_MP).getLevel()) + "%");
}
else
{
html.replace("%mp_regen%", "0%");
}
sendHtmlMessage(player, html);
}
}
else if(actualCommand.equalsIgnoreCase("manage"))
{
if(!isHaveRigths(player, getPrivSetFunctions()))
{
player.sendMessage(new CustomMessage("l2p.gameserver.model.instances.L2ResidenceManager.NotAuthorizedToDoThis", player));
return;
}
if(val.equalsIgnoreCase("recovery"))
{
if(st.countTokens() >= 1)
{
val = st.nextToken();
boolean success = true;
if(val.equalsIgnoreCase("hp"))
{
success = getResidence().updateFunctions(ResidenceFunction.RESTORE_HP, Integer.valueOf(st.nextToken()));
}
else if(val.equalsIgnoreCase("mp"))
{
success = getResidence().updateFunctions(ResidenceFunction.RESTORE_MP, Integer.valueOf(st.nextToken()));
}
else if(val.equalsIgnoreCase("exp"))
{
success = getResidence().updateFunctions(ResidenceFunction.RESTORE_EXP, Integer.valueOf(st.nextToken()));
}
if(!success)
{
player.sendPacket(Msg.THERE_IS_NOT_ENOUGH_ADENA_IN_THE_CLAN_HALL_WAREHOUSE);
}
else
{
broadcastDecoInfo();
}
}
showManageRecovery(player);
}
else if(val.equalsIgnoreCase("other"))
{
if(st.countTokens() >= 1)
{
val = st.nextToken();
boolean success = true;
if(val.equalsIgnoreCase("item"))
{
success = getResidence().updateFunctions(ResidenceFunction.ITEM_CREATE, Integer.valueOf(st.nextToken()));
}
else if(val.equalsIgnoreCase("tele"))
{
success = getResidence().updateFunctions(ResidenceFunction.TELEPORT, Integer.valueOf(st.nextToken()));
}
else if(val.equalsIgnoreCase("support"))
{
success = getResidence().updateFunctions(ResidenceFunction.SUPPORT, Integer.valueOf(st.nextToken()));
}
if(!success)
{
player.sendPacket(Msg.THERE_IS_NOT_ENOUGH_ADENA_IN_THE_CLAN_HALL_WAREHOUSE);
}
else
{
broadcastDecoInfo();
}
}
showManageOther(player);
}
else if(val.equalsIgnoreCase("deco"))
{
if(st.countTokens() >= 1)
{
val = st.nextToken();
boolean success = true;
if(val.equalsIgnoreCase("platform"))
{
success = getResidence().updateFunctions(ResidenceFunction.PLATFORM, Integer.valueOf(st.nextToken()));
}
else if(val.equalsIgnoreCase("curtain"))
{
success = getResidence().updateFunctions(ResidenceFunction.CURTAIN, Integer.valueOf(st.nextToken()));
}
if(!success)
{
player.sendPacket(Msg.THERE_IS_NOT_ENOUGH_ADENA_IN_THE_CLAN_HALL_WAREHOUSE);
}
else
{
broadcastDecoInfo();
}
}
showManageDeco(player);
}
else if(val.equalsIgnoreCase("back"))
{
showChatWindow(player, 0);
}
else
{
NpcHtmlMessage html = new NpcHtmlMessage(player, this);
html.setFile("data/html/residence/manage.htm");
sendHtmlMessage(player, html);
}
return;
}
else if(actualCommand.equalsIgnoreCase("support"))
{
if(!isHaveRigths(player, getPrivUseFunctions()))
{
player.sendMessage(new CustomMessage("l2p.gameserver.model.instances.L2ResidenceManager.NotAuthorizedToDoThis", player));
return;
}
setTarget(player);
if(val.equals(""))
{
return;
}
if(!getResidence().isFunctionActive(ResidenceFunction.SUPPORT))
{
return;
}
if(val.startsWith("all"))
{
for(Object[] buff : getResidence().getFunction(ResidenceFunction.SUPPORT).getBuffs())
{
if(val.equals("allM") && buff[1] == ResidenceFunction.W || val.equals("allW") && buff[1] == ResidenceFunction.M)
{
continue;
}
L2Skill s = (L2Skill) buff[0];
if(!useSkill(s.getId(), s.getLevel(), player))
{
break;
}
}
}