First of all, I want to mention that I am a beginner.
I am trying to modify a java buffer. I want to put an if condition that checks if the player has (for example) item 1234(a permanent item, not a consumable) in inventory.
And if he has that item, he can add in the scheme buffs with option "canUse = 1" and buffs with option "canUse = 0".
Can anyone please help me or try to explain how can I put the condition that checks if the player has the item?
Thank you very much.
private String viewAllSchemeBuffs(String scheme, String page, String action)
{
List<String> buffList = new ArrayList<>();
String HTML_MESSAGE = "<html><head><title>" + TITLE_NAME + "</title></head><body><center><br>";
String[] eventSplit = viewAllSchemeBuffs$getBuffCount(scheme).split(" ");
int TOTAL_BUFF = Integer.parseInt(eventSplit[0]);
int BUFF_COUNT = Integer.parseInt(eventSplit[1]);
int DANCE_SONG = Integer.parseInt(eventSplit[2]);
try (Connection con = L2DatabaseFactory.getInstance().getConnection())
{
if (action.equals("add"))
{
HTML_MESSAGE += "You can add <font color=LEVEL>" + (MAX_SCHEME_BUFFS - BUFF_COUNT) + "</font> Buffs and <font color=LEVEL>" + (MAX_SCHEME_DANCES - DANCE_SONG) + "</font> Dances more!";
String QUERY = "SELECT * FROM npcbuffer_buff_list WHERE buffType IN (" + generateQuery(BUFF_COUNT, DANCE_SONG) + ") AND canUse=1 ORDER BY Buff_Class ASC, id";
PreparedStatement getBuffCount = con.prepareStatement(QUERY);
ResultSet rss = getBuffCount.executeQuery();
while (rss.next())
{
String name = SkillTable.getInstance().getInfo(rss.getInt("buffId"), rss.getInt("buffLevel")).getName();
name = name.replace(" ", "+");
buffList.add(name + "_" + rss.getInt("buffId") + "_" + rss.getInt("buffLevel"));
}
}
else if (action.equals("remove"))
{
HTML_MESSAGE += "You have <font color=LEVEL>" + BUFF_COUNT + "</font> Buffs and <font color=LEVEL>" + DANCE_SONG + "</font> Dances";
String QUERY = "SELECT * FROM npcbuffer_scheme_contents WHERE scheme_id=? ORDER BY Buff_Class ASC, id";
PreparedStatement getBuffCount = con.prepareStatement(QUERY);
getBuffCount.setString(1, scheme);
ResultSet rss = getBuffCount.executeQuery();
while (rss.next())
{
String name = SkillTable.getInstance().getInfo(rss.getInt("skill_id"), rss.getInt("skill_level")).getName();
name = name.replace(" ", "+");
buffList.add(name + "_" + rss.getInt("skill_id") + "_" + rss.getInt("skill_level"));
}
}
else if (DEBUG)
{
throw new RuntimeException();
}
}
catch (SQLException e)
{
print(e);
}
HTML_MESSAGE += "<BR1><table border=0><tr>";
final int buffsPerPage = 16;
final String width, pageName;
int pc = ((buffList.size() - 1) / buffsPerPage) + 1;
if (pc > 5)
{
width = "25";
pageName = "P";
}
else
{
width = "50";
pageName = "Page ";
}
for (int ii = 1; ii <= pc; ++ii)
{
if (ii == Integer.parseInt(page))
{
HTML_MESSAGE += "<td width=" + width + " align=center><font color=LEVEL>" + pageName + ii + "</font></td>";
}
else if (action.equals("add"))
{
HTML_MESSAGE += "<td width=" + width + ">" + "<button value=\"" + pageName + ii + "\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " manage_scheme_1 " + scheme + " " + ii + " x\" width=" + width + " height=20 back=\"L2UI_ch3.Btn1_normalOn\" fore=\"L2UI_ch3.Btn1_normal\"></td>";
}
else if (action.equals("remove"))
{
HTML_MESSAGE += "<td width=" + width + ">" + "<button value=\"" + pageName + ii + "\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " manage_scheme_2 " + scheme + " " + ii + " x\" width=" + width + " height=20 back=\"L2UI_ch3.Btn1_normalOn\" fore=\"L2UI_ch3.Btn1_normal\"></td>";
}
else if (DEBUG)
{
throw new RuntimeException();
}
}
HTML_MESSAGE += "</tr></table>";
int limit = buffsPerPage * Integer.parseInt(page);
int start = limit - buffsPerPage;
int end = Math.min(limit, buffList.size());
int k = 0;
for (int i = start; i < end; ++i)
{
String value = buffList.get(i);
value = value.replace("_", " ");
String[] extr = value.split(" ");
String name = extr[0];
name = name.replace("+", " ");
int id = Integer.parseInt(extr[1]);
int level = Integer.parseInt(extr[2]);
/*--String page = extr[3];--*/
if (action.equals("add"))
{
if (!isUsed(scheme, id, level))
{
if ((k % 2) != 0)
{
HTML_MESSAGE += "<BR1><table border=0 bgcolor=333333>";
}
else
{
HTML_MESSAGE += "<BR1><table border=0 bgcolor=000000>";
}
HTML_MESSAGE += "<tr><td width=35>" + getSkillIconHtml(id, level) + "</td><td fixwidth=170>" + name + "</td><td><button value=\"Add\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " add_buff " + scheme + "_" + id + "_" + level + " " + page + " " + TOTAL_BUFF + "\" width=75 height=21 back=\"L2UI_ch3.Btn1_normalOn\" fore=\"L2UI_ch3.Btn1_normal\"></td>" + "</tr></table>";
k += 1;
}
}
else if (action.equals("remove"))
{
if ((k % 2) != 0)
{
HTML_MESSAGE += "<BR1><table border=0 bgcolor=333333>";
}
else
{
HTML_MESSAGE += "<BR1><table border=0 bgcolor=000000>";
}
HTML_MESSAGE += "<tr><td width=35>" + getSkillIconHtml(id, level) + "</td><td fixwidth=170>" + name + "</td><td><button value=\"Remove\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " remove_buff " + scheme + "_" + id + "_" + level + " " + page + " " + TOTAL_BUFF + "\" width=75 height=21 back=\"L2UI_ch3.Btn1_normalOn\" fore=\"L2UI_ch3.Btn1_normal\"></td>" + "</table>";
k += 1;
}
}
HTML_MESSAGE += "<br><br><button value=\"Back\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " manage_scheme_select " + scheme + " x x\" width=75 height=21 back=\"L2UI_ch3.Btn1_normalOn\" fore=\"L2UI_ch3.Btn1_normal\">" + "<button value=\"Home\" action=\"bypass -h Quest " + QUEST_LOADING_INFO + " redirect main 0 0\" width=75 height=21 back=\"L2UI_ch3.Btn1_normalOn\" fore=\"L2UI_ch3.Btn1_normal\">" + "<br><font color=303030>" + TITLE_NAME + "</font></center></body></html>";
return HTML_MESSAGE;
}