Помогите Идиоту(

Art

Легенда форума
Administrator
Крестный отец
Венец Хмелевара
Участник Новогоднего Фонда 2023
Победитель в номинации 2023
Победитель в номинации 2022
Победитель в номинации 2021
Участник Новогоднего Фонда 2021
Победитель в номинации 2019
На страже закона
Знаток Lineage2
Суровый спец
Знак Форума за коммерческие успехи
Часть системы
Боевая финансовая поддержка
Орден Почета
Магистр реакций
Мастер реакций
Любитель реакций
Знаток письма высшего ранга
Знаток великого письма
Медаль Благодарности
Старожил I степени
Клиент разработчик
Разработчик
За веру и верность форуму
За заслуги перед форумом
Победитель в номинации 2018
Победитель в номинации 2017
Победитель в номинации 2016
Сообщения
2 180
Розыгрыши
3
Решения
4
Репутация
2 426
Реакции
2 188
Баллы
2 258
package services.community;

import java.text.NumberFormat;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
import java.util.StringTokenizer;

import org.mmocore.gameserver.Config;
import org.mmocore.gameserver.data.htm.HtmCache;
import org.mmocore.gameserver.data.xml.holder.NpcHolder;
import org.mmocore.gameserver.handler.bbs.BbsHandlerHolder;
import org.mmocore.gameserver.handler.bbs.IBbsHandler;
import org.mmocore.gameserver.model.GameObjectsStorage;
import org.mmocore.gameserver.model.Player;
import org.mmocore.gameserver.model.Spawner;
import org.mmocore.gameserver.model.base.Experience;
import org.mmocore.gameserver.model.instances.NpcInstance;
import org.mmocore.gameserver.model.instances.RaidBossInstance;
import org.mmocore.gameserver.model.reward.RewardData;
import org.mmocore.gameserver.model.reward.RewardGroup;
import org.mmocore.gameserver.model.reward.RewardList;
import org.mmocore.gameserver.model.reward.RewardType;
import org.mmocore.gameserver.network.l2.serverpackets.ShowBoard;
import org.mmocore.gameserver.stats.Stats;
import org.mmocore.gameserver.templates.npc.NpcTemplate;
import org.mmocore.gameserver.utils.HtmlUtils;

import org.apache.commons.lang3.StringUtils;

public class CommunityBoardDropList extends ScriptBbsHandler implements IBbsHandler
{

private static CommunityBoardDropList _Instance = null;
private static final NumberFormat pf = NumberFormat.getPercentInstance(Locale.ENGLISH);
private static final NumberFormat df = NumberFormat.getInstance(Locale.ENGLISH);
private static final Map<Integer, String> list = new HashMap<Integer, String>();
private static final Map<Integer, String> list2 = new HashMap<Integer, String>();
private static final Map<Integer, String> list3 = new HashMap<Integer, String>();
private String val1 = "";
private String val2 = "";
private String val3 = "";
private String val4 = "";

static
{
pf.setMaximumFractionDigits(4);
df.setMinimumFractionDigits(2);
}

public static CommunityBoardDropList getInstance()
{
if (_Instance == null)
{
_Instance = new CommunityBoardDropList();
}
return _Instance;
}

@Override
public void onInit()
{
if(Config.COMMUNITYBOARD_ENABLED)
BbsHandlerHolder.getInstance().registerHandler(this);
}

@Override
public String[] getBypassCommands()
{
return new String[]
{
"_bbsdroplist",
"_bbsrewardspage",
"_bbsdropnpcnamepage",
"_bbsdroppage",
"_bbsdropid",
"_bbsdropname",
"_bbsdropnpcid",
"_bbsdropnpcname",
"_bbsrewards",
"_bbsrewardradar"
};
}

@Override
public void onBypassCommand(Player activeChar, String command)
{
StringTokenizer st = new StringTokenizer(command, " ");
String cmd = st.nextToken();
val1 = "";
val2 = "";
val3 = "";
val4 = "";
if (st.countTokens() == 1)
{
val1 = st.nextToken();
} else if (st.countTokens() == 2)
{
val1 = st.nextToken();
val2 = st.nextToken();
} else if (st.countTokens() == 3)
{
val1 = st.nextToken();
val2 = st.nextToken();
val3 = st.nextToken();
} else if (st.countTokens() == 4)
{
val1 = st.nextToken();
val2 = st.nextToken();
val3 = st.nextToken();
val4 = st.nextToken();
}

//First page with search
if (cmd.equalsIgnoreCase("_bbsdroplist"))
{
String content = HtmCache.getInstance().getHtml(Config.BBS_HOME_DIR + "pages/rewards/list.htm", activeChar);
content = content.replace("<?copyright?>", HtmCache.getInstance().getHtml(Config.BBS_HOME_DIR + "block/copyright.htm", activeChar));
ShowBoard.separateAndSend(content, activeChar);
}

else if (cmd.equalsIgnoreCase("_bbsdropid"))
{
String content = HtmCache.getInstance().getHtml(Config.BBS_HOME_DIR + "pages/rewards/rewards.htm", activeChar);
content = content.replace("<?copyright?>", HtmCache.getInstance().getHtml(Config.BBS_HOME_DIR + "block/copyright.htm", activeChar));
if (!val1.equals(""))
{
generateNpcList(activeChar, Integer.parseInt(val1));
String str = list.get(1);
StringBuilder result2 = new StringBuilder();
content = content.replace("<?rewards?>", str);

result2.append("<center><table width=690>");
result2.append("<tr>");
result2.append("<td WIDTH=690 align=center valign=top>");
result2.append("<center><button value=\"");
result2.append("Next page");
result2.append("\" action=\"bypass _bbsdroppage " + 2 + "\" width=200 height=29 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center>");
result2.append("</td>");
result2.append("</tr>");
result2.append("</table></center>");
content = content.replace("<?pagenext?>", list.get(2) != null ? result2.toString() : "");
ShowBoard.separateAndSend(content, activeChar);
}
else
{
activeChar.sendMessage("Please enter the Etc Item ID. Example: 57");
}
}
else if (cmd.equalsIgnoreCase("_bbsdropname"))
{
String content = HtmCache.getInstance().getHtml(Config.BBS_HOME_DIR + "pages/rewards/rewards.htm", activeChar);
content = content.replace("<?copyright?>", HtmCache.getInstance().getHtml(Config.BBS_HOME_DIR + "block/copyright.htm", activeChar));

if (!val1.equals(""))
{
String str1 = null;

if (!val1.equals(""))
{
str1 = val1;
}

if (!val2.equals(""))
{
str1 = val1 + " " + val2;
}

if (!val3.equals(""))
{
str1 = val1 + " " + val2 + " " + val3;
}

if (!val4.equals(""))
{
str1 = val1 + " " + val2 + " " + val3 + " " + val4;
}

generateNpcList(activeChar, str1);
String str = list.get(1);
StringBuilder result2 = new StringBuilder();
content = content.replace("<?rewards?>", str);

result2.append("<center><table width=690>");
result2.append("<tr>");
result2.append("<td WIDTH=690 align=center valign=top>");
result2.append("<center><button value=\"");
result2.append("Next page");
result2.append("\" action=\"bypass _bbsdroppage " + 2 + "\" width=200 height=29 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center>");
result2.append("</td>");
result2.append("</tr>");
result2.append("</table></center>");
content = content.replace("<?pagenext?>", result2.toString());
ShowBoard.separateAndSend(content, activeChar);
}
else
{
activeChar.sendMessage("Please enter Object Etc Item Name. Example: Animal Bone");
}

}
else if (cmd.equalsIgnoreCase("_bbsdroppage"))
{
int page = Integer.parseInt(val1);
int backpage = page - 1;
int nextpage = page + 1;

String content = HtmCache.getInstance().getHtml(Config.BBS_HOME_DIR + "pages/rewards/rewardspage.htm", activeChar);
String str = list.get(page);
StringBuilder result = new StringBuilder();
if (str != null)
{
content = content.replace("<?rewards?>", str);
}

content = content.replace("<?copyright?>", HtmCache.getInstance().getHtml(Config.BBS_HOME_DIR + "block/copyright.htm", activeChar));

String strback = list.get(backpage);
if (strback != null)
{
result.append("<center><table width=690>");
result.append("<tr>");
result.append("<td WIDTH=120 align=center>");
result.append("<center><button value=\"");
result.append("Previous page");
result.append("\" action=\"bypass _bbsdroppage ").append(backpage).append("\" width=200 height=29 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center>");
result.append("</td>");
result.append("</tr>");
result.append("</table></center>");
}
content = content.replace("<?pageback?>", result.length() > 0 ? result.toString() : "");

result = new StringBuilder();
String strnext = list.get(nextpage);

if (strnext != null)
{
result.append("<center><table width=690>");
result.append("<tr>");
result.append("<td WIDTH=120 align=center>");
result.append("<center><button value=\"");
result.append("Next page");
result.append("\" action=\"bypass _bbsdroppage ").append(nextpage).append("\" width=200 height=29 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center>");
result.append("</td>");
result.append("</tr>");
result.append("</table></center>");
}

content = content.replace("<?pagenext?>", result.length() > 0 ? result.toString() : "");

ShowBoard.separateAndSend(content, activeChar);
}
else if (cmd.equalsIgnoreCase("_bbsdropnpcid"))
{
if (!val1.equals(""))
{
String content = HtmCache.getInstance().getHtml(Config.BBS_HOME_DIR + "pages/rewards/mobsid.htm", activeChar);
content = content.replace("<?copyright?>", HtmCache.getInstance().getHtml(Config.BBS_HOME_DIR + "block/copyright.htm", activeChar));

content = content.replace("<?mobs?>", generateDropListAll(activeChar, Integer.parseInt(val1)));

ShowBoard.separateAndSend(content, activeChar);
}
else
{
activeChar.sendMessage("Please enter the monster ID!");
}
}
else if (cmd.equalsIgnoreCase("_bbsdropnpcname"))
{

String content = HtmCache.getInstance().getHtml(Config.BBS_HOME_DIR + "pages/rewards/mobs.htm", activeChar);
content = content.replace("<?copyright?>", HtmCache.getInstance().getHtml(Config.BBS_HOME_DIR + "block/copyright.htm", activeChar));
if (!val1.equals(""))
{
String str1 = null;

if (!val1.equals(""))
{
str1 = val1;
}

if (!val2.equals(""))
{
str1 = val1 + " " + val2;
}

if (!val3.equals(""))
{
str1 = val1 + " " + val2 + " " + val3;
}

if (!val4.equals(""))
{
str1 = val1 + " " + val2 + " " + val3 + " " + val4;
}

generateDropListAll(activeChar, str1);
String str = list2.get(1);
StringBuilder result2 = new StringBuilder();
content = content.replace("<?mobs?>", str);

result2.append("<center><table width=690>");
result2.append("<tr>");
result2.append("<td WIDTH=690 align=center valign=top>");
result2.append("<center><button value=\"");
result2.append("Next page");
result2.append("\" action=\"bypass _bbsdropnpcnamepage " + 2 + "\" width=200 height=29 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center>");
result2.append("</td>");
result2.append("</tr>");
result2.append("</table></center>");

result2.append("<center><table width=690>");
result2.append("<tr>");
result2.append("<td WIDTH=690 align=center valign=top>");
result2.append("<center><button value=\"");
result2.append("New search");
result2.append("\" action=\"bypass _bbsdroplist" + "\" width=200 height=29 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center>");
result2.append("</td>");
result2.append("</tr>");
result2.append("</table></center>");
content = content.replace("<?pagenext?>", list2.get(2) != null ? result2.toString() : "");
ShowBoard.separateAndSend(content, activeChar);
}
else
{
activeChar.sendMessage("Please Enter the Monster name!");
}
}
else if (cmd.equalsIgnoreCase("_bbsdropnpcnamepage"))
{
int page = Integer.parseInt(val1);
int backpage = page - 1;
int nextpage = page + 1;
String content = HtmCache.getInstance().getHtml(Config.BBS_HOME_DIR + "pages/rewards/mobspage.htm", activeChar);
content = content.replace("<?copyright?>", HtmCache.getInstance().getHtml(Config.BBS_HOME_DIR + "block/copyright.htm", activeChar));

String str = list2.get(page);
StringBuilder result = new StringBuilder();
content = content.replace("<?mobs?>", str);

String strback = list2.get(backpage);

if (strback != null)
{
result.append("<center><table width=690>");
result.append("<tr>");
result.append("<td WIDTH=120 align=center>");
result.append("<center><button value=\"");
result.append("Previous page");
result.append("\" action=\"bypass _bbsdropnpcnamepage ").append(backpage).append("\" width=200 height=29 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center>");
result.append("</td>");
result.append("</tr>");
result.append("</table></center>");
}

content = content.replace("<?pageback?>", result.length() > 0 ? result.toString() : "");

result = new StringBuilder();
String strnext = list2.get(nextpage);
if (strnext != null)
{
result.append("<center><table width=690>");
result.append("<tr>");
result.append("<td WIDTH=120 align=center>");
result.append("<center><button value=\"");
result.append("Next page");
result.append("\" action=\"bypass _bbsdropnpcnamepage ").append(nextpage).append("\" width=200 height=29 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center>");
result.append("</td>");
result.append("</tr>");
result.append("</table></center>");
}

content = content.replace("<?pagenext?>", result.length() > 0 ? result.toString() : "");
ShowBoard.separateAndSend(content, activeChar);
}

else if (cmd.equalsIgnoreCase("_bbsrewards"))
{
String content = HtmCache.getInstance().getHtml(Config.BBS_HOME_DIR + "pages/rewards/rewards.htm", activeChar);
content = content.replace("<?copyright?>", HtmCache.getInstance().getHtml(Config.BBS_HOME_DIR + "block/copyright.htm", activeChar));
RewardType type = RewardType.valueOf(val2);
if (!val1.equals(""))
{
generateDropListAll(activeChar, Integer.parseInt(val1), type);
String str = list3.get(1);
StringBuilder result = new StringBuilder();
content = content.replace("<?rewards?>", str);

result.append("<center><table width=690>");
result.append("<tr>");
result.append("<td WIDTH=690 align=center valign=top>");
result.append("<center><button value=\"");
result.append("Next page");
result.append("\" action=\"bypass _bbsrewardspage " + 2 + "\" width=200 height=29 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center>");
result.append("</td>");
result.append("</tr>");
result.append("</table></center>");

content = content.replace("<?pagenext?>", list3.get(2) != null ? result.toString() : "");
}

ShowBoard.separateAndSend(content, activeChar);
}

else if (cmd.equalsIgnoreCase("_bbsrewardspage"))
{
int page = Integer.parseInt(val1);
int backpage = page - 1;
int nextpage = page + 1;

String content = HtmCache.getInstance().getHtml(Config.BBS_HOME_DIR + "pages/rewards/rewardspage.htm", activeChar);
content = content.replace("<?copyright?>", HtmCache.getInstance().getHtml(Config.BBS_HOME_DIR + "block/copyright.htm", activeChar));
String str = list3.get(page);
StringBuilder result = new StringBuilder();
content = content.replace("<?rewards?>", str);

String strback = list3.get(backpage);
if (strback != null)
{
result.append("<center><table width=690>");
result.append("<tr>");
result.append("<td WIDTH=120 align=center>");
result.append("<center><button value=\"");
result.append("Previous page");
result.append("\" action=\"bypass _bbsrewardspage ").append(backpage).append("\" width=200 height=29 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center>");
result.append("</td>");
result.append("</tr>");
result.append("</table></center>");
}

content = content.replace("<?pageback?>", result.length() > 0 ? result.toString() : "");

result = new StringBuilder();

String strnext = list3.get(nextpage);
if (strnext != null)
{
result.append("<center><table width=690>");
result.append("<tr>");
result.append("<td WIDTH=120 align=center>");
result.append("<center><button value=\"");
result.append("Next page");
result.append("\" action=\"bypass _bbsrewardspage ").append(nextpage).append("\" width=200 height=29 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center>");
result.append("</td>");
result.append("</tr>");
result.append("</table></center>");
}

content = content.replace("<?pagenext?>", result.length() > 0 ? result.toString() : "");

ShowBoard.separateAndSend(content, activeChar);
}

else if (cmd.equalsIgnoreCase("_bbsrewardradar"))
{
String content = HtmCache.getInstance().getHtml(Config.BBS_HOME_DIR + "pages/rewards/rewards.htm", activeChar);
content = content.replace("<?copyright?>", HtmCache.getInstance().getHtml(Config.BBS_HOME_DIR + "block/copyright.htm", activeChar));
content = content.replace("<?rewards?>", generateDropListAll(activeChar, Integer.parseInt(val1)));
content = content.replace("<?pagenext?>", "");

ShowBoard.separateAndSend(content, activeChar);

NpcInstance npc = GameObjectsStorage.getByNpcId(Integer.parseInt(val1));
if (npc != null)
{
Spawner sp = npc.getSpawn();
if (sp != null)
{
for (NpcInstance spawn : sp.getAllSpawned())
{
if (spawn != null)
{
activeChar.addRadar(spawn.getSpawnedLoc().getX(), spawn.getSpawnedLoc().getY(), spawn.getSpawnedLoc().getZ());
activeChar.addRadarWithMap(spawn.getSpawnedLoc().getX(), spawn.getSpawnedLoc().getY(), spawn.getSpawnedLoc().getZ());
break;
}
}
}
}
}
}

/**
* - Generates a list of all the monsters on the object ID
*
* @param player
* @param id
* Return
*/
private void generateNpcList(Player player, int id)
{
list.clear();
StringBuilder result = new StringBuilder();
int count = 0;
int count2 = 0;
int page = 0;

for (NpcTemplate npc : NpcHolder.getInstance().getAll()) {
if (npc != null) {
boolean next = false;

if (npc.getRewards() == null || npc.getRewards().isEmpty() || npc.getRewards().size() == 0) {
continue;
}

for (Map.Entry<RewardType, RewardList> entry : npc.getRewards().entrySet()) {
if (next) {
break;
}

for (RewardGroup group : entry.getValue()) {
if (next) {
break;
}

if (group != null) {
for (RewardData dat : group.getItems()) {
if (dat.getItem().getItemId() == id) {
result.append("<center><table width=690>");
result.append("<tr>");
result.append("<td WIDTH=200 align=center>");
result.append(" Level: ").append(npc.level);
result.append("</td>");
result.append("<td WIDTH=200 align=center>");
result.append("<button value=\"");
result.append(npc.getName());
result.append("\" action=\"bypass _bbsdropnpcid ").append(npc.getNpcId()).append("\" width=200 height=29 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"><br1>");
result.append("</td>");
result.append("</tr>");
result.append("</table></center>");

count++;
count2++;
if (count == 5) {
count = 0;
page++;
list.put(page, result.toString());
result = new StringBuilder();
}

next = true;
break;
}
}
}
}
}
}
}

if (count2 < 5 && count > 0)
{
page++;
list.put(page, result.toString());
return;
}

if (list.isEmpty() || list == null || list.size() == 0)
{
page++;

result = new StringBuilder();

result.append("<table width=690><tr><td width=690><center><font name=\"hs12\" color=\"FF0000\">Item not found</font></center></td></tr></table><br>");
result.append("<center><table width=690>");
result.append("<tr>");
result.append("<td WIDTH=690 align=center valign=top>");
result.append("<center><button value=\"");
result.append("Search again");
result.append("\" action=\"bypass _bbsdroplist" + "\" width=200 height=29 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center>");
result.append("</td>");
result.append("</tr>");
result.append("</table></center>");

list.put(page, result.toString());
return;
}

list.put(page, result.toString());
}

private void generateNpcList(Player player, String name)
{
list.clear();
StringBuilder result = new StringBuilder();
int count = 0;
int count2 = 0;
int page = 0;

for (NpcTemplate npc : NpcHolder.getInstance().getAll())
{
if (npc != null)
{
boolean next = false;

if (npc.getRewards() == null || npc.getRewards().isEmpty() || npc.getRewards().size() == 0)
{
continue;
}

for (Map.Entry<RewardType, RewardList> entry : npc.getRewards().entrySet())
{
if (next)
{
break;
}

for (RewardGroup group : entry.getValue())
{
if (next)
{
break;
}

if (group != null)
{
for (RewardData dat : group.getItems())
{
if (dat.getItem().getName() != null && (dat.getItem().getName() == name || val2.equals("") ? dat.getItem().getName().startsWith(name) : dat.getItem().getName().contains(name) || dat.getItem().getName().equals(name) || dat.getItem().getName().equalsIgnoreCase(name)))
{

result.append("<center><table width=690>");
result.append("<tr>");
result.append("<td WIDTH=200 align=center>");
result.append(" Level: ").append(npc.level);
result.append("</td>");
result.append("<td WIDTH=200 align=center>");
result.append("<button value=\"");
result.append(npc.getName());
result.append("\" action=\"bypass _bbsdropnpcid ").append(npc.getNpcId()).append("\" width=200 height=29 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"><br1>");
result.append("</td>");
result.append("</tr>");
result.append("</table></center>");

count++;
count2++;
if (count == 5)
{
count = 0;
page++;
list.put(page, result.toString());
result = new StringBuilder();
}

next = true;
break;
}
}
}
}
}
}
}

if (count2 < 5 && count > 0)
{
page++;
list.put(page, result.toString());
return;
}

if (list.isEmpty() || list == null || list.size() == 0)
{
page++;

result = new StringBuilder();

result.append("<table width=690><tr><td width=690><center><font name=\"hs12\" color=\"FF0000\">Item not found</font></center></td></tr></table><br>");
result.append("<center><table width=690>");
result.append("<tr>");
result.append("<td WIDTH=690 align=center valign=top>");
result.append("<center><button value=\"");
result.append("New search");
result.append("\" action=\"bypass _bbsdroplist" + "\" width=200 height=29 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center>");
result.append("</td>");
result.append("</tr>");
result.append("</table></center>");
list.put(page, result.toString());
return;
}

list.put(page, result.toString());
}

private String generateDropListAll(Player player, int id)
{
StringBuilder result = new StringBuilder();

NpcInstance npc = GameObjectsStorage.getByNpcId(id);
if (npc != null)
{
if (npc.getTemplate().getRewardList(RewardType.RATED_GROUPED) != null && !npc.getTemplate().getRewardList(RewardType.RATED_GROUPED).isEmpty())
{
result.append("<center><table width=690>");
result.append("<tr>");
result.append("<td WIDTH=690 align=center valign=top>");
result.append("<center><button value=\"");
result.append("Home Rewards");
result.append("\" action=\"bypass _bbsrewards ").append(npc.getNpcId()).append(" ").append(RewardType.RATED_GROUPED).append("\" width=200 height=29 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center>");
result.append("</td>");
result.append("</tr>");
result.append("</table></center>");
}

if (npc.getTemplate().getRewardList(RewardType.NOT_RATED_NOT_GROUPED) != null && !npc.getTemplate().getRewardList(RewardType.NOT_RATED_NOT_GROUPED).isEmpty())
{
result.append("<center><table width=690>");
result.append("<tr>");
result.append("<td WIDTH=690 align=center valign=top>");
result.append("<center><button value=\"");
result.append("Additional reward");
result.append("\" action=\"bypass _bbsrewards ").append(npc.getNpcId()).append(" ").append(RewardType.NOT_RATED_NOT_GROUPED).append("\" width=200 height=29 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center>");
result.append("</td>");
result.append("</tr>");
result.append("</table></center>");
}

if (npc.getTemplate().getRewardList(RewardType.NOT_RATED_GROUPED) != null && !npc.getTemplate().getRewardList(RewardType.NOT_RATED_GROUPED).isEmpty())
{
result.append("<center><table width=690>");
result.append("<tr>");
result.append("<td WIDTH=690 align=center valign=top>");
result.append("<center><button value=\"");
result.append("Herbs");
result.append("\" action=\"bypass _bbsrewards ").append(npc.getNpcId()).append(" ").append(RewardType.NOT_RATED_GROUPED).append("\" width=200 height=29 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center>");
result.append("</td>");
result.append("</tr>");
result.append("</table></center>");
}

if (npc.getTemplate().getRewardList(RewardType.SWEEP) != null && !npc.getTemplate().getRewardList(RewardType.SWEEP).isEmpty())
{
result.append("<center><table width=690>");
result.append("<tr>");
result.append("<td WIDTH=690 align=center valign=top>");
result.append("<center><button value=\"");
result.append("Sweep Spoil");
result.append("\" action=\"bypass _bbsrewards ").append(npc.getNpcId()).append(" ").append(RewardType.SWEEP).append("\" width=200 height=29 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center>");
result.append("</td>");
result.append("</tr>");
result.append("</table></center>");
}

result.append("<center><table width=690>");
result.append("<tr>");
result.append("<td WIDTH=690 align=center valign=top>");
result.append("<center><button value=\"");
result.append("Place Radar");
result.append("\" action=\"bypass _bbsrewardradar ").append(npc.getNpcId()).append("\" width=200 height=29 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center>");
result.append("</td>");
result.append("</tr>");
result.append("</table></center>");
}
else
{
result.append("<table width=690><tr><td width=690><center><font name=\"hs12\" color=\"FF0000\">Monster not found</font></center></td></tr></table><br>");

result.append("<center><table width=690>");
result.append("<tr>");
result.append("<td WIDTH=690 align=center valign=top>");
result.append("<center><button value=\"");
result.append("New search");
result.append("\" action=\"bypass _bbsdroplist" + "\" width=200 height=29 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center>");
result.append("</td>");
result.append("</tr>");
result.append("</table></center>");
}

return result.toString();
}

private void generateDropListAll(Player player, String name)
{
list2.clear();
StringBuilder result = new StringBuilder();
int count = 0;
int count2 = 0;
int page = 0;

// show in raw
for (NpcTemplate npc : NpcHolder.getInstance().getAll())
{
if (npc != null && (npc.getName() == name || val2.equals("") ? npc.getName().startsWith(name) : npc.getName().contains(name) || npc.getName().equals(name) || npc.getName().equalsIgnoreCase(name)))
{
result.append("<center><table border=0 bgcolor=333549 width=690>");
result.append("<tr>");
result.append("<td width=110 align=center>");
result.append("<center><font color=\"b09979\">").append(npc.getName()).append("</font></center>");
result.append("</td>");

if (npc.getRewardList(RewardType.RATED_GROUPED) != null && !npc.getRewardList(RewardType.RATED_GROUPED).isEmpty())
{
result.append("<td width=110 align=center>");
result.append("<center><button value=\"");
result.append("Home reward");
result.append("\" action=\"bypass _bbsrewards ").append(npc.getNpcId()).append(" ").append(RewardType.RATED_GROUPED).append("\" width=100 height=29 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center>");
result.append("</td>");
}

if (npc.getRewardList(RewardType.NOT_RATED_NOT_GROUPED) != null && !npc.getRewardList(RewardType.NOT_RATED_NOT_GROUPED).isEmpty())
{
result.append("<td width=110 align=center>");
result.append("<center><button value=\"");
result.append("Additional reward");
result.append("\" action=\"bypass _bbsrewards ").append(npc.getNpcId()).append(" ").append(RewardType.NOT_RATED_NOT_GROUPED).append("\" width=100 height=29 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center>");
result.append("</td>");
}

if (npc.getRewardList(RewardType.NOT_RATED_GROUPED) != null && !npc.getRewardList(RewardType.NOT_RATED_GROUPED).isEmpty())
{
result.append("<td width=110 align=center>");
result.append("<center><button value=\"");
result.append("Herbs");
result.append("\" action=\"bypass _bbsrewards ").append(npc.getNpcId()).append(" ").append(RewardType.NOT_RATED_GROUPED).append("\" width=100 height=29 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center>");
result.append("</td>");
}

if (npc.getRewardList(RewardType.SWEEP) != null && !npc.getRewardList(RewardType.SWEEP).isEmpty())
{
result.append("<td width=110 align=center>");
result.append("<center><button value=\"");
result.append("Spoil");
result.append("\" action=\"bypass _bbsrewards ").append(npc.getNpcId()).append(" ").append(RewardType.SWEEP).append("\" width=100 height=29 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center>");
result.append("</td>");
}
result.append("<td width=110 align=center>");
result.append("<center><button value=\"");
result.append("Place the Radar");
result.append("\" action=\"bypass _bbsrewardradar ").append(npc.getNpcId()).append("\" width=100 height=29 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center>");
result.append("</td>");
result.append("</tr>");
result.append("</table></center><br>");

count++;
count2++;
if (count == 5)
{
count = 0;
page++;
list2.put(page, result.toString());
result = new StringBuilder();
}
}
}

if (count2 < 5 && count > 0)
{
page++;
list2.put(page, result.toString());
return;
}

if (list2.isEmpty() || list2 == null || list2.size() == 0)
{
page++;
result = new StringBuilder();

result.append("<table width=690><tr><td width=690><center><font name=\"hs12\" color=\"FF0000\">Monster not found</font></center></td></tr></table><br>");
result.append("<center><table width=690>");
result.append("<tr>");
result.append("<td WIDTH=690 align=center valign=top>");
result.append("<center><br><br><button value=\"");
result.append("Search again");
result.append("\" action=\"bypass _bbsdroplist" + "\" width=200 height=29 back=\"L2UI_CT1.Button_DF_Down\" fore=\"L2UI_CT1.Button_DF\"></center>");
result.append("</td>");
result.append("</tr>");
result.append("</table></center>");

list2.put(page, result.toString());
return;
}

page++;
list2.put(page, result.toString());
}

private void generateDropListAll(Player player, int id, RewardType type)
{
list3.clear();
NpcInstance npc = GameObjectsStorage.getByNpcId(id);
if (npc != null)
{
final int diff = npc.calculateLevelDiffForDrop(player.isInParty() ? player.getParty().getLevel() : player.getLevel());
double mod = npc.calcStat(Stats.REWARD_MULTIPLIER, 1., player, null);
mod *= Experience.penaltyModifier(diff, 9);

switch (type)
{
case RATED_GROUPED:
generateDropList(player, npc, mod);
break;
case NOT_RATED_GROUPED:
generateDropListContinue(player, npc, mod);
break;
case NOT_RATED_NOT_GROUPED:
generateDropListHerbs(player, npc, mod);
break;
case SWEEP:
generateSpoilList(player, npc, mod);
break;
}
}
}

/**
* - A list of all items from the monster
*
* @param player
* @param
* Return
*/
private void generateDropList(Player player, NpcInstance npc, double mod)
{
list3.clear();
int page = 0;

if (npc != null)
{
for (RewardGroup g : npc.getTemplate().getRewardList(RewardType.RATED_GROUPED))
{
StringBuilder result = new StringBuilder();

double gchance = g.getChance();
double gmod = mod;
double grate;
double gmult;

double rateDrop = npc instanceof RaidBossInstance ? Config.RATE_DROP_RAIDBOSS : npc.isSiegeGuard() ? Config.RATE_DROP_SIEGE_GUARD : Config.RATE_DROP_ITEMS * player.getRateItems();
double rateAdena = Config.RATE_DROP_ADENA * player.getRateAdena();

if (g.isAdena())
{
if (rateAdena == 0)
{
continue;
}

grate = rateAdena;

if (gmod > 5)
{
gmod *= gchance / RewardList.MAX_CHANCE;
gchance = RewardList.MAX_CHANCE;
}

grate *= gmod;
}
else
{
if (rateDrop == 0)
{
continue;
}

grate = rateDrop;

if (g.notRate())
{
grate = Math.min(gmod, 1.0);
} else
{
grate *= gmod;
}
}

gmult = Math.ceil(grate);

for (RewardData d : g.getItems())
{
double imult = d.notRate() ? 1.0 : gmult;
String icon = d.getItem().getIcon();
if (icon == null || icon.equals(StringUtils.EMPTY))
{
icon = "icon.etc_question_mark_i00";
}

result.append("<center><table bgcolor=333549 width=690>");
result.append("<tr>");
result.append("<td WIDTH=690 align=center valign=top>");
result.append("<table border=0 cellspacing=4 cellpadding=3>");
result.append("<tr>");
result.append("<td FIXWIDTH=50 align=right valign=top>");
result.append("<img src=\"").append(icon).append("\" width=32 height=32>");
result.append("</td>");
result.append("<td FIXWIDTH=671 align=left valign=top>");
result.append("<font color=\"0099FF\">Item Name:</font> ").append(HtmlUtils.htmlItemName(d.getItemId())).append("<br1><font color=\"LEVEL\">Drop rate:</font> ").append(pf.format(d.getChance() / RewardList.MAX_CHANCE)).append(" <font color=\"b09979\">[Min: ").append(Math.round(d.getMinDrop() * (g.isAdena() ? gmult : 1.0))).append(" | Max: ").append(Math.round(d.getMaxDrop() * imult)).append("]</font>");
result.append("</td>");
result.append("</tr>");
result.append("</table>");
result.append("<table border=0 cellspacing=0 cellpadding=0>");
result.append("<tr>");
result.append("<td width=690>");
result.append("<img src=\"l2ui.squaregray\" width=\"690\" height=\"1\">");
result.append("</td>");
result.append("</tr>");
result.append("</table>");
result.append("</td>");
result.append("</tr>");
result.append("</table></center>");
}

page++;
list3.put(page, result.toString());
}
}
}

public static void generateDropListContinue(Player player, NpcInstance npc, double mod)
{
list3.clear();
StringBuilder result = new StringBuilder();
int count = 0;
int page = 0;

if (npc != null)
{
for (RewardGroup g : npc.getTemplate().getRewardList(RewardType.NOT_RATED_GROUPED))
{
double gchance = g.getChance();

result.append("<table><tr><td width=170><font color=\"a2a0a2\">Grup Chance: </font><font color=\"b09979\">").append(pf.format(gchance / RewardList.MAX_CHANCE)).append("</font></td></tr><table>");

for (RewardData d : g.getItems())
{
String icon = d.getItem().getIcon();
if (icon == null || icon.equals(StringUtils.EMPTY))
{
icon = "icon.etc_question_mark_i00";
}

result.append("<center><table bgcolor=333549 width=690>");
result.append("<tr>");
result.append("<td WIDTH=690 align=center valign=top>");
result.append("<table border=0 cellspacing=4 cellpadding=3>");
result.append("<tr>");
result.append("<td FIXWIDTH=50 align=right valign=top>");
result.append("<img src=\"").append(icon).append("\" width=32 height=32>");
result.append("</td>");
result.append("<td FIXWIDTH=671 align=left valign=top>");
result.append("<font color=\"0099FF\">Item Name:</font> ").append(HtmlUtils.htmlItemName(d.getItemId())).append("<br1><font color=\"LEVEL\">Drop rate:</font> ").append(pf.format(d.getChance() / RewardList.MAX_CHANCE)).append(" <font color=\"b09979\">[Min: ").append(Math.round(d.getMinDrop())).append(" | Max: ").append(Math.round(d.getMaxDrop())).append("]</font>");
result.append("</td>");
result.append("</tr>");
result.append("</table>");
result.append("<table border=0 cellspacing=0 cellpadding=0>");
result.append("<tr>");
result.append("<td width=690>");
result.append("<img src=\"l2ui.squaregray\" width=\"690\" height=\"1\">");
result.append("</td>");
result.append("</tr>");
result.append("</table>");
result.append("</td>");
result.append("</tr>");
result.append("</table></center>");

count++;
if (count == 5)
{
count = 0;
page++;
list3.put(page, result.toString());
result = new StringBuilder();

result.append("<table><tr><td width=170><font color=\"a2a0a2\">Grup chance: </font><font color=\"b09979\">").append(pf.format(gchance / RewardList.MAX_CHANCE)).append("</font></td></tr></table>");
}
}
}
}
page++;
list3.put(page, result.toString());
}

public static void generateDropListHerbs(Player player, NpcInstance npc, double mod)
{
list3.clear();
StringBuilder result = new StringBuilder();
int count = 0;
int page = 0;

if (npc != null)
{
for (RewardGroup g : npc.getTemplate().getRewardList(RewardType.NOT_RATED_NOT_GROUPED))
{
double grate;
double gmult;

grate = 1;

if (g.notRate())
{
grate = Math.min(mod, 1.0);
} else
{
grate *= mod;
}

gmult = Math.ceil(grate);

for (RewardData d : g.getItems())
{
double imult = d.notRate() ? 1.0 : gmult;
String icon = d.getItem().getIcon();
if (icon == null || icon.equals(StringUtils.EMPTY))
{
icon = "icon.etc_question_mark_i00";
}

result.append("<center><table bgcolor=333549 width=690>");
result.append("<tr>");
result.append("<td WIDTH=690 align=center valign=top>");
result.append("<table border=0 cellspacing=4 cellpadding=3>");
result.append("<tr>");
result.append("<td FIXWIDTH=50 align=right valign=top>");
result.append("<img src=\"").append(icon).append("\" width=32 height=32>");
result.append("</td>");
result.append("<td FIXWIDTH=671 align=left valign=top>");
result.append("<font color=\"0099FF\">Item Name:</font> ").append(HtmlUtils.htmlItemName(d.getItemId())).append("<br1><font color=\"LEVEL\">Drop rate:</font> ").append(pf.format(d.getChance() / RewardList.MAX_CHANCE)).append(" <font color=\"b09979\">[Min: ").append(Math.round(d.getMaxDrop() * imult)).append(" | Max: ").append(Math.round(d.getMaxDrop() * imult)).append("]</font>");
result.append("</td>");
result.append("</tr>");
result.append("</table>");
result.append("<table border=0 cellspacing=0 cellpadding=0>");
result.append("<tr>");
result.append("<td width=690>");
result.append("<img src=\"l2ui.squaregray\" width=\"690\" height=\"1\">");
result.append("</td>");
result.append("</tr>");
result.append("</table>");
result.append("</td>");
result.append("</tr>");
result.append("</table></center>");
count++;
if (count == 5)
{
count = 0;
page++;
list3.put(page, result.toString());
result = new StringBuilder();

result.append("<table><tr><td><table width=270 border=0><tr><td><font color=\"aaccff\">Herb List:</font></td></tr></table></td></tr></table>");
}
}
}
}
page++;
list3.put(page, result.toString());
}

public static void generateSpoilList(Player player, NpcInstance npc, double mod)
{
list3.clear();
StringBuilder result = new StringBuilder();
int count = 0;
int page = 0;
result.append("<table><tr><td><table width=270 border=0><tr><td><font color=\"aaccff\">Spoil list:</font></td></tr></table></td></tr></table>");

if (npc != null)
{
for (RewardGroup g : npc.getTemplate().getRewardList(RewardType.SWEEP))
{
double grate;
double gmult;

grate = Config.RATE_DROP_SPOIL * player.getRateSpoil();

if (g.notRate())
{
grate = Math.min(mod, 1.0);
} else
{
grate *= mod;
}

gmult = Math.ceil(grate);

for (RewardData d : g.getItems())
{
double imult = d.notRate() ? 1.0 : gmult;
String icon = d.getItem().getIcon();
if (icon == null || icon.equals(StringUtils.EMPTY))
{
icon = "icon.etc_question_mark_i00";
}

result.append("<center><table bgcolor=333549 width=690>");
result.append("<tr>");
result.append("<td WIDTH=690 align=center valign=top>");
result.append("<table border=0 cellspacing=4 cellpadding=3>");
result.append("<tr>");
result.append("<td FIXWIDTH=50 align=right valign=top>");
result.append("<img src=\"").append(icon).append("\" width=32 height=32>");
result.append("</td>");
result.append("<td FIXWIDTH=671 align=left valign=top>");
result.append("<font color=\"0099FF\">Item Name:</font> ").append(HtmlUtils.htmlItemName(d.getItemId())).append("<br1><font color=\"LEVEL\">Drop rate:</font> ").append(pf.format(d.getChance() / RewardList.MAX_CHANCE)).append(" <font color=\"b09979\">[Min: ").append(d.getMinDrop()).append(" | Max: ").append(Math.round(d.getMaxDrop() * imult)).append("]</font>");
result.append("</td>");
result.append("</tr>");
result.append("</table>");
result.append("<table border=0 cellspacing=0 cellpadding=0>");
result.append("<tr>");
result.append("<td width=690>");
result.append("<img src=\"l2ui.squaregray\" width=\"690\" height=\"1\">");
result.append("</td>");
result.append("</tr>");
result.append("</table>");
result.append("</td>");
result.append("</tr>");
result.append("</table></center>");

count++;
if (count == 5)
{
count = 0;
page++;
list3.put(page, result.toString());
result = new StringBuilder();
result.append("<table><tr><td><table width=270 border=0><tr><td><font color=\"aaccff\">Spoil list:</font></td></tr></table></td></tr></table>");

}
}
}
}

page++;
list3.put(page, result.toString());
}

@Override
public void onWriteCommand(Player player, String bypass, String arg1, String arg2, String arg3, String arg4, String arg5)
{}
}
проблема тут( переношу кб с исходов FandC на lost world.не могу исправить ошибку(
for (Map.Entry<RewardType, RewardList> entry : npc.getRewards().entrySet()) {
 
Последнее редактирование:

Обратите внимание, что данный пользователь заблокирован! Не совершайте с ним никаких сделок! Перейдите в его профиль, чтобы узнать причину блокировки.
споилер,нет не слышал
 
сразу видно личинг работы сссра
 
переношу с исходников fandc
 
сразу видно личинг работы сссра
Могу и ошибиться но больше похоже на работу PaInKiLlEr с j develop station, в последствии данное сие чудо было продано друзьям l2-scripts у которых он и работал патом.
 
сразу видно личинг работы сссра
Могу и ошибиться но больше похоже на работу PaInKiLlEr с j develop station, в последствии данное сие чудо было продано друзьям l2-scripts у которых он и работал патом.
открыл исходы СССР и кажись FandC взяли их от туда, по теме мне дадут ответ или бессмысленно?
 
Текст ошибки надо, ибо лень пересматривать весь исходник.
 
Возвращаемый тип getRewards будет дядя "Вася" смотреть?
 
Возвращаемый тип getRewards будет дядя "Вася" смотреть?
спасибо...посмотрел, не заметил когда в прошлый раз там смотрел...
public Map<RewardType, RewardList> getRewards() FandC
public Collection<RewardList> getRewards() lostworld
 
спасибо...посмотрел, не заметил когда в прошлый раз там смотрел...
public Map<RewardType, RewardList> getRewards() FandC
public Collection<RewardList> getRewards() lostworld
При наведении курсором на кусочек, подчеркнутый волнистой красной линией, высвечивает ошибку. В эклипсе вообще ошибки высвечивает все в панельке ошибок/варнингов.
 
При наведении курсором на кусочек, подчеркнутый волнистой красной линией, высвечивает ошибку. В эклипсе вообще ошибки высвечивает все в панельке ошибок/варнингов.
Да глупость писало в идее типа нет метода ентри сет...
 
Да глупость писало в идее типа нет метода ентри сет...
Не глупость же. :) Это как раз проясняет, что получаемый результат getRewards() - не мапа, так как у коллекций-наследников Collection нет метода entrySet().
 
Назад
Сверху Снизу