Jump to content
  • 0

Npcclanhallinstance - L2Jfrozen


Question

Posted

Good afternoon maxcheaters! I am adding a java mod in my project, and am having this following error:

2vlpjza.png

 

Could someone help me solve it? If I rename the same one suggests the eclipse, nothing happens in the game, only one message appears:  Ocorreu uma falha no buffer

6 answers to this question

Recommended Posts

  • 0
Posted

You tried to define twice this constant. Rename her for this IF part.

Yes, I tried, but I did not succeed. Here is the complete code:

 

 

 

package net.l2jpx.gameserver.model.actor.instance;

 
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.sql.ResultSet;
import java.text.SimpleDateFormat;
import java.util.Date;
import java.util.Iterator;
import java.util.Random;
import java.util.StringTokenizer;
 
import javolution.text.TextBuilder;
import javolution.util.FastMap;
import net.l2jpx.Config;
import net.l2jpx.gameserver.custom.StartLeilao;
import net.l2jpx.gameserver.custom.TabelaDeLances;
import net.l2jpx.gameserver.custom.TabelasDeClanHalls;
import net.l2jpx.gameserver.datatables.sql.ClanTable;
import net.l2jpx.gameserver.datatables.sql.ItemTable;
import net.l2jpx.gameserver.managers.ClanHallManager;
import net.l2jpx.gameserver.model.L2Clan;
import net.l2jpx.gameserver.model.L2World;
import net.l2jpx.gameserver.model.entity.ClanHall;
import net.l2jpx.gameserver.network.serverpackets.CreatureSay;
import net.l2jpx.gameserver.network.serverpackets.InventoryUpdate;
import net.l2jpx.gameserver.network.serverpackets.L2GameServerPacket;
import net.l2jpx.gameserver.network.serverpackets.NpcHtmlMessage;
import net.l2jpx.gameserver.network.serverpackets.PledgeShowInfoUpdate;
import net.l2jpx.gameserver.templates.L2NpcTemplate;
import net.l2jpx.util.CloseUtil;
import net.l2jpx.util.database.L2DatabaseFactory;
 
public class L2NpcClanHallInstance extends L2NpcInstance
{
private static final String REDIRECT_HALL = "data/html/default/";
 
public L2NpcClanHallInstance(int objectID, L2NpcTemplate template)
{
super(objectID, template);
}
 
@Override
public void onBypassFeedback(L2PcInstance player, String command)
{
StringTokenizer st = new StringTokenizer(command, " ");
String currentcommand = st.nextToken();
try
{
if (currentcommand.startsWith("ver_halls"))
{
int page = Integer.parseInt(st.nextToken());
showHtmlWindow(player, 1, page, 0, false);
}
else if (currentcommand.startsWith("infohall"))
{
int hallId = Integer.parseInt(st.nextToken());
int page = Integer.parseInt(st.nextToken());
 
showHtmlWindow(player, 1, page, hallId, false);
}
else if (currentcommand.startsWith("obterhall"))
{
int hallId = Integer.parseInt(st.nextToken());
 
L2Clan clan = player.getClan();
ClanHall clanHall = ClanHallManager.getInstance().getClanHallByOwner(player.getClan());
TabelasDeClanHalls objeto = _mapHalls.get(Integer.valueOf(hallId));
if ((clan != null) && (objeto != null))
{
if (clan.getLeaderId() == player.getObjectId())
{
if (clan.getLevel() < Config.MIN_LEVEL_PARA_LANCE)
{
player.sendMessage("O level do seu clan nao esta apropriado.Deve estar igual a " + Config.MIN_LEVEL_PARA_LANCE + ".");
showHtmlWindow(player, 1, 1, 0, false);
return;
}
if (clanHall != null)
{
player.sendMessage("Voce ja e proprietario de uma hall (" + clanHall.getName() + ").");
showHtmlWindow(player, 1, 1, 0, false);
return;
}
if (objeto.isDisponivel())
{
ClanHallManager.getInstance().setOwner(hallId, clan);
 
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
 
TabelasDeClanHalls hall = _mapHalls.get(Integer.valueOf(hallId));
 
hall.setHallDispoFor(clan.getClanId(), false);
 
showHtmlWindow(player, 1, 1, 0, false);
}
else
{
player.sendMessage("Hall indisponivel! Faca seu lance!");
showHtmlWindow(player, 1, 1, 0, false);
}
}
else
{
player.sendMessage("Voce nao e lider.");
 
showHtmlWindow(player, 1, 1, 0, false);
}
}
else
{
player.sendMessage("Voce nao tem clan.");
 
showHtmlWindow(player, 1, 1, 0, false);
}
}
else if (currentcommand.startsWith("novolance"))
{
int hallId = Integer.parseInt(st.nextToken());
int page = Integer.parseInt(st.nextToken());
 
showHtmlWindow(player, 2, page, hallId, true);
}
else if (currentcommand.startsWith("map"))
{
String map = st.nextToken();
int page = Integer.parseInt(st.nextToken());
 
showHtmlWindow2(player, 3, page, 0, false, map);
}
else if (currentcommand.startsWith("lance"))
{
int lance = Integer.parseInt(st.nextToken());
int hallId = Integer.parseInt(st.nextToken());
int page = Integer.parseInt(st.nextToken());
if (StartLeilao._endLances)
{
player.sendMessage("O periodo de lances foi finalizado!\nNormalmente 1 hora antes do leilao os lances sao encerrados.");
showHtmlWindow(player, 1, page, hallId, false);
return;
}
if (lance == 0)
{
player.sendMessage("Lance nao apropriado.");
showHtmlWindow(player, 1, page, hallId, false);
return;
}
if (lance < Config.MIN_LANCE_VALOR)
{
player.sendMessage("Lance nao apropriado, ele deve ser maior que " + Config.MIN_LANCE_VALOR + " " + ItemTable.getInstance().getTemplate(Config.ITEM_LEILAO).getName() + ".");
showHtmlWindow(player, 1, page, hallId, false);
return;
}
L2Clan clan = player.getClan();
ClanHall clanHall = ClanHallManager.getInstance().getClanHallByOwner(player.getClan());
if (clan != null)
{
if (clan.getLeaderId() == player.getObjectId())
{
if (clan.getLevel() < Config.MIN_LEVEL_PARA_LANCE)
{
player.sendMessage("O level do seu clan nao esta apropriado.Deve estar igual a " + Config.MIN_LEVEL_PARA_LANCE + ".");
showHtmlWindow(player, 1, 1, 0, false);
return;
}
Object iu;
if (clanHall != null)
{
if (clanHall.getId() == hallId)
{
boolean aceito = true;
boolean lanceMaior = true;
int lancesNesteHall = 0;
TabelaDeLances maior_lances = null;
for (TabelaDeLances objeto : _mapLeiloes.values())
{
if (objeto.getHallId() == hallId)
{
lancesNesteHall++;
if (objeto.getCharId() == player.getObjectId())
{
aceito = false;
}
}
}
if (lancesNesteHall >= Config.MAX_LANCE)
{
player.sendMessage("Este hall nao pode mais receber lances, o maximo de lances por clan hall e " + Config.MAX_LANCE + ".");
showHtmlWindow(player, 1, page, hallId, false);
return;
}
if (lancesNesteHall > 0)
{
maior_lances = getMaiorLanceInMap(hallId);
if (lance <= maior_lances.getValorDoLance())
{
lanceMaior = false;
}
}
if ((aceito) && (lanceMaior))
{
if (player.getInventory().getInventoryItemCount(Config.ITEM_LEILAO, 0) >= lance)
{
if (!Config.IN_TEST)
{
                   InventoryUpdate iu = new InventoryUpdate();
                   player.getInventory().destroyItemByItemId("ITEM REQUERIDO DO LEILAO", Config.ITEM_LEILAO, lance, player, null);
                   player.getInventory().updateDatabase();
                   player.sendPacket(iu);
}
saveLance(player, hallId, lance);
showHtmlWindow(player, 1, page, hallId, false);
}
else
{
player.sendMessage("Voce nao tem " + lance + " " + ItemTable.getInstance().getTemplate(Config.ITEM_LEILAO).getName() + ".");
showHtmlWindow(player, 1, page, hallId, false);
}
}
else
{
if (!aceito)
{
player.sendMessage("Voce so pode dar um lance!");
showHtmlWindow(player, 1, page, hallId, false);
return;
}
if (!lanceMaior)
{
player.sendMessage("Seu lance nao esta apropriado, ele deve ser maior que " + maior_lances.getValorDoLance() + " " + ItemTable.getInstance().getTemplate(Config.ITEM_LEILAO).getName() + ".");
showHtmlWindow(player, 1, page, hallId, false);
return;
}
}
}
else
{
player.sendMessage("Voce ja tem como base " + clanHall.getName() + ", nao pode dar lance em  hall diferente!");
showHtmlWindow(player, 1, page, hallId, false);
}
}
else
{
boolean aceito = true;
boolean lanceMaior = true;
int lancesNesteHall = 0;
TabelaDeLances maior_lances = null;
for (iu = _mapLeiloes.values().iterator(); ((Iterator<?>) iu).hasNext();)
{
TabelaDeLances objeto = (TabelaDeLances) ((Iterator<?>) iu).next();
if (objeto.getHallId() == hallId)
{
lancesNesteHall++;
}
if (objeto.getCharId() == player.getObjectId())
{
aceito = false;
}
}
if (lancesNesteHall >= Config.MAX_LANCE)
{
player.sendMessage("Este hall nao pode mais receber lances, o maximo de lances por clan hall e " + Config.MAX_LANCE + ".");
showHtmlWindow(player, 1, page, hallId, false);
return;
}
if (lancesNesteHall > 0)
{
maior_lances = getMaiorLanceInMap(hallId);
if (lance <= maior_lances.getValorDoLance())
{
lanceMaior = false;
}
}
if ((aceito) && (lanceMaior))
{
if (player.getInventory().getInventoryItemCount(Config.ITEM_LEILAO, 0) >= lance)
{
if (!Config.IN_TEST)
{
                   InventoryUpdate iu = new InventoryUpdate();
                   player.getInventory().destroyItemByItemId("ITEM REQUERIDO DO LEILAO", Config.ITEM_LEILAO, lance, player, null);
                   player.getInventory().updateDatabase();
                   player.sendPacket(iu);
}
saveLance(player, hallId, lance);
showHtmlWindow(player, 1, page, hallId, false);
}
else
{
player.sendMessage("Voce nao tem " + lance + " " + ItemTable.getInstance().getTemplate(Config.ITEM_LEILAO).getName() + ".");
showHtmlWindow(player, 1, page, hallId, false);
}
}
else
{
if (!aceito)
{
player.sendMessage("Voce so pode dar um lance!");
showHtmlWindow(player, 1, page, hallId, false);
return;
}
if (!lanceMaior)
{
player.sendMessage("Seu lance nao esta apropriado, ele deve ser maior que " + maior_lances.getValorDoLance() + " " + ItemTable.getInstance().getTemplate(Config.ITEM_LEILAO).getName() + ".");
showHtmlWindow(player, 1, page, hallId, false);
return;
}
}
maior_lances = null;
}
}
else
{
player.sendMessage("Para dar um lance em um clan hall e necessario que voce seja lider de clan.");
showHtmlWindow(player, 1, page, hallId, false);
}
}
else
{
player.sendMessage("Voce nao tem clan!");
showHtmlWindow(player, 1, page, hallId, false);
return;
}
}
else if (currentcommand.startsWith("closelance"))
{
int charId = Integer.parseInt(st.nextToken());
 
int hallId = Integer.parseInt(st.nextToken());
 
int page = Integer.parseInt(st.nextToken());
if (player.getObjectId() == charId)
{
TabelaDeLances plLance = _mapLeiloes.get(Integer.valueOf(player.getObjectId()));
if (plLance != null)
{
deleteLance(player.getObjectId());
 
_mapLeiloes.remove(Integer.valueOf(player.getObjectId()));
showHtmlWindow(player, 1, page, hallId, false);
}
else
{
player.sendMessage("Hacker detected, gm informed.");
}
}
}
else
{
super.onBypassFeedback(player, command);
}
}
catch (Exception e)
{
player.sendMessage("Ocorreu uma falha no buffer!");
}
}
 
public boolean isValidateByPass()
{
return false;
}
 
protected Random rand = new Random();
protected String[] cores =
{
"<center><font color=\"FF7744\">L I N E A G E - H A L L<br1><br1>Manager Instance<br1>Interlude ForEver</font><br1></center>",
"<center><font color=\"66FF66\">L I N E A G E - H A L L<br1><br1>Best Instance<br1>Interlude ForEver</font><br1></center>",
"<center><font color=\"5555FF\">L I N E A G E - H A L L<br1><br1>Best Instance<br1>News Interlude</font><br1></center>",
"<center><font color=\"FF77FF\">L I N E A G E - H A L L<br1><br1>Best Instance<br1>Best Server</font><br1></center>",
"<center><font color=\"33FFFF\">L I N E A G E - H A L L<br1><br1>Best Instance<br1>Interlude ForEver</font><br1></center>",
"<center><font color=\"A20055\">L I N E A G E - H A L L<br1><br1>Best Instance<br1>Interlude ForEver</font><br1></center>",
"<center><font color=\"66FF66\">L I N E A G E - H A L L<br1><br1>Best Instance<br1>Interlude ForEver</font><br1></center>",
"<center><font color=\"0000FF\">L I N E A G E - H A L L<br1><br1>Best Instance<br1>Interlude ForEver</font><br1></center>",
"<center><font color=\"77DDFF\">L I N E A G E - H A L L<br1><br1>Best Instance<br1>Interlude ForEver</font><br1></center>",
"<center><font color=\"7A0099\">L I N E A G E - H A L L<br1><br1>Best Instance<br1>Interlude ForEver</font><br1></center>",
"<center><font color=\"000088\">L I N E A G E - H A L L<br1><br1>Best Instance<br1>Interlude ForEver</font><br1></center>",
"<center><font color=\"888888\">L I N E A G E - H A L L<br1><br1>Best Instance<br1>Interlude ForEver</font><br1></center>",
"<center><font color=\"66FF66\">L I N E A G E - H A L L<br1><br1>Best Instance<br1>Interlude ForEver</font><br1></center>"
};
private static String SQL_SELECT_HALLS = "select id, name, ownerId,location, disponibilidade,skill_name,skill_id from clanhall";
public static FastMap<Integer, TabelasDeClanHalls> _mapHalls = new FastMap<Integer, TabelasDeClanHalls>();
public static FastMap<Integer, TabelaDeLances> _mapLeiloes = new FastMap<Integer, TabelaDeLances>();
private static String SQL_SELECT_LANCES = "select char_id, charName, hall_id, lance, data_hora, clan_id from clanhall_leilao";
 
private void showHtmlWindow(L2PcInstance player, int htm, int page, int hallId, boolean novoLance)
{
NpcHtmlMessage html = new NpcHtmlMessage(1);
if (htm == 0)
{
html.setFile("data/html/default/76550.htm");
}
if (htm >= 1)
{
html.setFile("data/html/default/76550-" + htm + ".htm");
}
sendHtmlMessage(player, html, page, hallId, novoLance);
}
 
private void sendHtmlMessage(L2PcInstance player, NpcHtmlMessage html, int page, int hallId, boolean novoLance)
{
html.replace("%objectId%", String.valueOf(getObjectId()));
html.replace("%npcId%", String.valueOf(getNpcId()));
html.replace("%hallId%", String.valueOf(hallId));
html.replace("%halls%", ClanHalls(player, page, hallId, novoLance));
html.replace("%page%", String.valueOf(page));
html.replace("%wel%", RandoMizeText());
html.replace("%data%", String.valueOf(StartLeilao._startDate.getTime()));
player.sendPacket(html);
}
 
private void showHtmlWindow2(L2PcInstance player, int htm, int page, int hallId, boolean novoLance, String map)
{
NpcHtmlMessage html = new NpcHtmlMessage(1);
if (htm == 0)
{
html.setFile("data/html/default/76550.htm");
}
if (htm >= 1)
{
html.setFile("data/html/default/76550-" + htm + ".htm");
}
sendHtmlMessage2(player, html, page, hallId, novoLance, map);
}
 
private void sendHtmlMessage2(L2PcInstance player, NpcHtmlMessage html, int page, int hallId, boolean novoLance, String map)
{
html.replace("%objectId%", String.valueOf(getObjectId()));
html.replace("%npcId%", String.valueOf(getNpcId()));
html.replace("%hallId%", String.valueOf(hallId));
html.replace("%halls%", ClanHalls(player, page, hallId, novoLance));
html.replace("%page%", String.valueOf(page));
html.replace("%wel%", RandoMizeText());
html.replace("%loc%", map.equals("GODDARD") ? "GODARD" : map);
html.replace("%data%", String.valueOf(StartLeilao._startDate.getTime()));
player.sendPacket(html);
}
 
private static int verificaAntigoDono(int hallId)
{
TabelasDeClanHalls objeto = _mapHalls.get(Integer.valueOf(hallId));
if (!objeto.isDisponivel())
{
return objeto.getOwnerId();
}
return 0;
}
 
private String ClanHalls(L2PcInstance player, int page, int hallId, boolean novoLance)
{
try
{
int count = 1;
int colors = 1;
 
int maiorOuIgual = page == 4 ? 54 : page == 3 ? 43 : page == 2 ? 32 : page == 1 ? 21 : 1;
int menorOuIgual = page == 4 ? 64 : page == 3 ? 53 : page == 2 ? 42 : page == 1 ? 31 : 1;
 
String BB = "FFFFBB";
String SELECTED = "FF0000";
 
String local1 = "ERRO";
String local2 = "ERRO";
 
TextBuilder tb = new TextBuilder();
if (hallId == 0)
{
tb.append("<center><table width=280 border=0 bgcolor=\"#000000\">");
for (TabelasDeClanHalls objeto : _mapHalls.values())
{
if (((objeto.getId() >= maiorOuIgual ? 1 : 0) & (objeto.getId() <= menorOuIgual ? 1 : 0)) != 0)
{
if (colors == 1)
{
local1 = objeto.getLocal();
}
if (colors == 2)
{
local2 = objeto.getLocal();
}
if ((!local1.equals(local2)) && (!local1.equals(local2)))
{
tb.append("<tr>");
tb.append("<td width=\"100\" align=center><img src=\"L2UI.SquareWhite\" width=99 height=1> <img src=\"L2UI.SquareBlank\" width=1 height=3></td>");
tb.append("</tr>");
 
tb.append("<tr>");
tb.append("<td width=\"100\" align=center><a action=\"bypass -h npc_" + String.valueOf(getObjectId()) + "_map " + objeto.getLocal() + " " + String.valueOf(page) + " \">" + objeto.getLocal() + "</a></font></td>");
tb.append("</tr>");
 
tb.append("<tr>");
tb.append("<td width=\"100\" align=center><img src=\"L2UI.SquareWhite\" width=99 height=1> <img src=\"L2UI.SquareBlank\" width=1 height=3></td>");
tb.append("</tr>");
}
tb.append("<tr>");
tb.append("<td width=\"90\"><font color=" + getCor(colors) + ">" + objeto.getName() + "</font></td>");
if (objeto.isDisponivel())
{
tb.append("<td width=\"50\"><font color=\"00FF00\">Disponivel</font></td>");
}
if (!objeto.isDisponivel())
{
tb.append("<td width=\"50\"><font color=\"FF0000\">Tomada</font></td>");
}
tb.append("<td width=\"50\"><a action=\"bypass -h npc_" + String.valueOf(getObjectId()) + "_infohall " + objeto.getId() + " " + page + " \"><font color=" + getCor(colors) + ">INFO</font></a></td>");
tb.append("</tr>");
count++;
if (colors == 2)
{
colors = 1;
}
else
{
colors++;
}
}
}
if (!tb.toString().endsWith("</tr>"))
{
tb.append("</tr>");
}
tb.append("</table></center>");
tb.append("<br1><center><table>");
tb.append("<tr>");
tb.append("<td width=\"21\"><a action=\"bypass -h npc_" + String.valueOf(getObjectId()) + "_ver_halls " + String.valueOf(1) + "\"><font color=" + (page == 1 ? SELECTED : BB) + ">[" + String.valueOf(1) + "]</font></a></td>");
tb.append("<td width=\"21\"><a action=\"bypass -h npc_" + String.valueOf(getObjectId()) + "_ver_halls " + String.valueOf(2) + "\"><font color=" + (page == 2 ? SELECTED : BB) + ">[" + String.valueOf(2) + "]</font></a></td>");
tb.append("<td width=\"21\"><a action=\"bypass -h npc_" + String.valueOf(getObjectId()) + "_ver_halls " + String.valueOf(3) + "\"><font color=" + (page == 3 ? SELECTED : BB) + ">[" + String.valueOf(3) + "]</font></a></td>");
tb.append("<td width=\"21\"><a action=\"bypass -h npc_" + String.valueOf(getObjectId()) + "_ver_halls " + String.valueOf(4) + "\"><font color=" + (page == 4 ? SELECTED : BB) + ">[" + String.valueOf(4) + "]</font></a></td>");
tb.append("</tr></table></center>");
}
else if ((hallId != 0) && (!novoLance))
{
TabelasDeClanHalls hall = _mapHalls.get(Integer.valueOf(hallId));
if (hall != null)
{
tb.append("<center><table width=200 border=0 bgcolor=\"333333\">");
tb.append("<tr>");
tb.append("<td width=\"130\" align=center>Clan Hall: <font color=\"00FF00\">" + hall.getName() + " </font></td>");
tb.append("</tr>");
 
tb.append("<tr>");
tb.append("<td width=\"130\" align=center>Localizada: <font color=\"00FF00\">" + hall.getLocal() + " </font></td>");
tb.append("</tr>");
 
tb.append("<tr>");
tb.append("<td width=\"130\" align=center>Clan proprietario: <font color=\"00FF00\">" + (hall.isDisponivel() ? "Nenhum" : ClanName(hall.getOwnerId())) + " </font></td>");
tb.append("</tr>");
 
tb.append("<tr>");
tb.append("<td width=\"130\" align=center>Hall Buff: <font color=\"00FF00\">" + hall.getSkillName() + "</font></td>");
tb.append("</tr>");
 
tb.append("<tr>");
tb.append("<td width=\"130\" align=center>" + (hall.isDisponivel() ? "<a action=\"bypass -h npc_" + String.valueOf(getObjectId()) + "_obterhall " + String.valueOf(hallId) + "\"><font color=\"000000\">OBTER</font></a>" : new StringBuilder().append("<a action=\"bypass -h npc_").append(String.valueOf(getObjectId())).append("_novolance ").append(String.valueOf(hallId)).append(" ").append(String.valueOf(page)).append(" \"><font color=\"000000\">NOVO LANCE</font></a>").toString()) + "  " + "<a action=\"bypass -h npc_" + String.valueOf(getObjectId()) + "_ver_halls " + String.valueOf(page) + "\"><font color=\"000000\">VOLTAR</font></a></td>");
tb.append("</tr>");
 
tb.append("</table><br1>");
tb.append("<img src=\"L2UI.SquareWhite\" width=280 height=1> <img src=\"L2UI.SquareBlank\" width=1 height=3><br>");
tb.append(temLances(hallId) ? "Atuais Lances<br1>" : "<font color=\"FF0000\">Este hall nao tem lances.</font>");
tb.append("</center>");
if (temLances(hallId))
{
int num = 0;
 
tb.append("<center><table>");
tb.append("<tr>");
tb.append("<td width=\"25\"><font color=AAAAAA>NUM</font></td>");
tb.append("<td width=\"55\"><font color=AAAAAA>NAME</font></td>");
tb.append("<td width=\"45\">VALOR</td>");
tb.append("<td width=\"55\"><font color=AAAAAA>DATA</font></td>");
tb.append("</tr>");
tb.append("</table></center>");
 
tb.append("<center><table height=10 bgcolor=0x000000 border=1>");
for (TabelaDeLances lance : _mapLeiloes.values())
{
if (lance.getHallId() == hallId)
{
num++;
boolean meulance = player.getObjectId() == lance.getCharId();
tb.append("<tr>");
tb.append("<td width=\"18\"><font color=AAAAAA>" + num + ".</font></td>");
tb.append("<td width=\"90\"><font color=FFAA33>" + lance.getCharName() + "</font></td>");
tb.append("<td width=\"45\">" + lance.getValorDoLance() + "</td>");
tb.append("<td width=\"78\"><font color=AAAAAA>" + lance.getDataEHora() + "</font></td>");
tb.append(meulance ? "<td width=\"10\"><a action=\"bypass -h npc_" + String.valueOf(getObjectId()) + "_closelance " + String.valueOf(lance.getCharId()) + " " + String.valueOf(hallId) + " " + String.valueOf(page) + " \"><font color=\"FFAA33\">X</font></a></td>" : "");
tb.append("</tr>");
}
}
if (!tb.toString().endsWith("</tr>"))
{
tb.append("</tr>");
}
tb.append("</table></center>");
}
}
else
{
tb.append("<center>Este hall nao existe</center>");
}
}
else if (novoLance)
{
TabelasDeClanHalls hallparalance = _mapHalls.get(Integer.valueOf(hallId));
try
{
tb.append("<center>");
 
tb.append(!Config.IN_TEST ? "A T E N C A O:<br1> <font color=\"00FF00\"> Seu lance NAO sera devolvido!!!<br1>Todo lance FICA com o hall!!! </font><br1>" : "A T E N C A O:<br> <font color=\"00FF00\">O SISTEMA ESTA EM MODO TESTE<br1> DEPURACAO DE ERROS</font><br1>NOTE: EM MODO DE TESTES<br1>O SISTEMA  <font color=\"00FF00\">NAO RETIRA</font> A QUANTIA DO LANCE!<br1>");
 
tb.append("<a action=\"bypass -h npc_" + String.valueOf(getObjectId()) + "_ver_halls " + String.valueOf(page) + "\"><font color=\"FFAA33\">CANCELAR LANCE</font></a><br>");
tb.append("Novo lance para: <font color=\"00FF00\">" + hallparalance.getName() + " </font><br1>");
tb.append("Moeda para lance: <font color=\"00FF00\">" + ItemTable.getInstance().getTemplate(Config.ITEM_LEILAO).getName() + " </font><br1>");
tb.append("</center>");
}
catch (Exception e)
{
e.printStackTrace();
return "Erro! (novoLance) > " + e.toString();
}
}
return tb.toString();
}
catch (Exception e)
{
e.printStackTrace();
}
return "Algum erro inesperado ocorreu - Contacte forum";
}
 
public static void leiloar()
{
int HALL = 21;
int valorDeHallsVendidas = 0;
L2Clan clan = null;
TabelaDeLances maior_lance = null;
TabelasDeClanHalls base = null;
while (HALL <= 64)
{
try
{
base = _mapHalls.get(Integer.valueOf(HALL));
maior_lance = getMaiorLanceInMap(HALL);
if (base != null)
{
if (maior_lance != null)
{
int identificacao_do_antigo_dono = verificaAntigoDono(maior_lance.getHallId());
 
clan = ClanTable.getInstance().getClan(maior_lance.getClanId());
if ((clan != null) && (identificacao_do_antigo_dono != clan.getLeaderId()))
{
ClanHallManager.getInstance().setOwner(maior_lance.getHallId(), clan);
 
base.setClanOwnerId(clan.getClanId());
 
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
 
CreatureSay na = new CreatureSay(0, 4, "Clan Hall", "Seu clan venceu o leilao da base " + HallName(maior_lance.getHallId()) + ".");
 
clan.broadcastToOnlineMembers(na);
if (identificacao_do_antigo_dono != 0)
{
atualizeclan(identificacao_do_antigo_dono, HallName(maior_lance.getHallId()));
}
valorDeHallsVendidas++;
}
else if ((clan != null) && (maior_lance.getClanId() == clan.getClanId()))
{
CreatureSay na = new CreatureSay(0, 4, "Clan Hall", "Seu clan continua com a base " + HallName(maior_lance.getHallId()) + ".");
clan.broadcastToOnlineMembers(na);
}
}
}
else
{
LOGGER.info("ClanHallInstance: Hall id " + HALL + " nao existe na venda...");
}
HALL++;
}
catch (Exception e)
{
HALL++;
e.printStackTrace();
}
}
StartLeilao._endLances = false;
 
LOGGER.info("ClanHallInstance: Foram leiloadas 43 clan halls e " + valorDeHallsVendidas + " lances foram aceitos.");
}
 
private static void atualizeclan(int clanId, String hallName)
{
try
{
L2Clan clan = ClanTable.getInstance().getClan(clanId);
 
ClanTable.getInstance().getClan(clanId).setHasHideout(0);
 
clan.broadcastToOnlineMembers(new PledgeShowInfoUpdate(clan));
 
CreatureSay na = new CreatureSay(0, 4, "Clan Hall", "Seu clan perdeu a base " + hallName + ".");
 
clan.broadcastToOnlineMembers(na);
}
catch (Exception e)
{
LOGGER.info("[ClanHallInstance]-atualizeclan(int clanId, String hallName):Erro: " + e);
}
}
 
public static void Announce(String anunciante, String announce, int clanId)
{
CreatureSay cs = new CreatureSay(0, 15, "" + anunciante, "" + announce);
for (L2PcInstance player : L2World.getInstance().getAllPlayers())
{
if ((player != null) && (player.isOnline() != 0))
{
if (((player.getClan() != null ? 1 : 0) & (player.getClan().getClanId() == clanId ? 1 : 0)) != 0)
{
player.sendPacket(cs);
}
}
}
}
 
private boolean temLances(int hallId)
{
for (TabelaDeLances lance : _mapLeiloes.values())
{
if (lance.getHallId() == hallId)
{
return true;
}
}
return false;
}
 
public static String getCor(int cor)
{
if (cor == 1)
{
return "FFFFFF";
}
if (cor == 2)
{
return "AAAAAA";
}
return "FF33CC";
}
 
public static void TruncateLeiloes()
{
String GAME_DELETE = "TRUNCATE TABLE clanhall_leilao";
 
Connection con = null;
PreparedStatement statement = null;
try
{
System.out.println("Truncate table clanhall_leilao...");
con = L2DatabaseFactory.getInstance().getConnection();
statement = con.prepareStatement(GAME_DELETE);
statement.execute();
 
statement.close();
}
catch (Exception e)
{
System.out.println("Ocorreu um erro ao limpar os dados da table clanhall_leilao: " + e);
}
finally
{
CloseUtil.close(con);
con = null;
}
}
 
public String RandoMizeText()
{
return this.cores[this.rand.nextInt(this.cores.length)];
}
 
public static void setHall(int idHall, int objetoId, String disponibilidade)
{
Connection con = null;
try
{
con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("UPDATE clanhall SET ownerId=?, disponibilidade=? WHERE id=?");
statement.setInt(1, objetoId);
statement.setString(2, disponibilidade);
statement.setInt(3, idHall);
statement.execute();
statement.close();
}
catch (Exception localException)
{
}
finally
{
CloseUtil.close(con);
con = null;
}
}
 
public static int getMaiorLanceinData(int HallId)
{
int i = 0;
Connection con = null;
PreparedStatement statement = null;
ResultSet rset = null;
try
{
con = L2DatabaseFactory.getInstance().getConnection();
statement = con.prepareStatement("SELECT max(lance) FROM clanhall_leilao where hall_id =?");
statement.setInt(1, HallId);
rset = statement.executeQuery();
while (rset.next())
{
i = rset.getInt("max(lance)");
}
rset.close();
statement.close();
}
catch (Exception e)
{
LOGGER.info("Erro: " + e);
}
finally
{
CloseUtil.close(con);
con = null;
}
return i;
}
 
public static TabelaDeLances getMaiorLanceInMap(int hallid)
{
TabelaDeLances objeto = null;
int maior = 0;
for (TabelaDeLances lance : _mapLeiloes.values())
{
if ((lance.getHallId() == hallid) && (lance.getValorDoLance() > maior))
{
objeto = lance;
maior = lance.getValorDoLance();
}
}
return objeto;
}
 
/* Error */
public static void deleteLance(int charId)
{
// Byte code:
// 0: aconst_null
// 1: astore_1
// 2: invokestatic 264 com/l2jnews/util/database/L2DatabaseFactory:getInstance ()Lcom/l2jnews/util/database/L2DatabaseFactory;
// 5: invokevirtual 265 com/l2jnews/util/database/L2DatabaseFactory:getConnection ()Ljava/sql/Connection;
// 8: astore_1
// 9: aload_1
// 10: ldc_w 282
// 13: invokeinterface 266 2 0
// 18: astore_2
// 19: aload_2
// 20: iconst_1
// 21: iload_0
// 22: invokeinterface 273 3 0
// 27: aload_2
// 28: invokeinterface 267 1 0
// 33: pop
// 34: aload_2
// 35: invokeinterface 268 1 0
// 40: aload_1
// 41: invokestatic 269 com/l2jnews/util/CloseUtil:close (Ljava/sql/Connection;)V
// 44: aconst_null
// 45: astore_1
// 46: goto +22 -> 68
// 49: astore_2
// 50: aload_1
// 51: invokestatic 269 com/l2jnews/util/CloseUtil:close (Ljava/sql/Connection;)V
// 54: aconst_null
// 55: astore_1
// 56: goto +12 -> 68
// 59: astore_3
// 60: aload_1
// 61: invokestatic 269 com/l2jnews/util/CloseUtil:close (Ljava/sql/Connection;)V
// 64: aconst_null
// 65: astore_1
// 66: aload_3
// 67: athrow
// 68: return
// Line number table:
// Java source line #990 -> byte code offset #0
// Java source line #993 -> byte code offset #2
// Java source line #994 -> byte code offset #9
// Java source line #995 -> byte code offset #19
// Java source line #996 -> byte code offset #27
// Java source line #997 -> byte code offset #34
// Java source line #1007 -> byte code offset #40
// Java source line #1008 -> byte code offset #44
// Java source line #1009 -> byte code offset #46
// Java source line #999 -> byte code offset #49
// Java source line #1007 -> byte code offset #50
// Java source line #1008 -> byte code offset #54
// Java source line #1009 -> byte code offset #56
// Java source line #1007 -> byte code offset #59
// Java source line #1008 -> byte code offset #64
// Java source line #1010 -> byte code offset #68
// Local variable table:
// start length slot name signature
// 0 69 0 charId int
// 1 65 1 con Connection
// 18 17 2 statement PreparedStatement
// 49 1 2 localException Exception
// 59 8 3 localObject Object
// Exception table:
// from to target type
// 2 40 49 java/lang/Exception
// 2 40 59 finally
}
 
public static void loadLances()
{
Connection con = null;
try
{
con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement st = con.prepareStatement(SQL_SELECT_LANCES);
ResultSet rs = st.executeQuery();
while (rs.next())
{
int charId = rs.getInt("char_id");
String nameChar = rs.getString("charName");
int hallId = rs.getInt("hall_id");
int lance = rs.getInt("lance");
String data_hora = rs.getString("data_hora");
int clan_id = rs.getInt("clan_id");
 
_mapLeiloes.put(Integer.valueOf(charId), new TabelaDeLances(charId, nameChar, hallId, lance, data_hora, clan_id));
}
LOGGER.info("loadLances: Carregado " + _mapLeiloes.size() + " Lances.");
rs.close();
st.close();
}
catch (Exception localException)
{
}
finally
{
CloseUtil.close(con);
con = null;
}
}
 
public static void loadHalls()
{
Connection con = null;
try
{
con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement st = con.prepareStatement(SQL_SELECT_HALLS);
ResultSet rs = st.executeQuery();
while (rs.next())
{
int Id = rs.getInt("id");
String name = rs.getString("name");
int ownerId = rs.getInt("ownerId");
String local = rs.getString("location");
boolean disponibilidade = rs.getBoolean("disponibilidade");
String skill_name = rs.getString("skill_name");
int skill_id = rs.getInt("skill_id");
if (!name.equals("Bandit Stronghold"))
{
_mapHalls.put(Integer.valueOf(Id), new TabelasDeClanHalls(Id, name, ownerId, "null", local, disponibilidade, skill_name, skill_id));
}
}
LOGGER.info("loadHalls: Carregado " + _mapHalls.size() + " Clan Halls.");
rs.close();
st.close();
}
catch (Exception localException)
{
}
finally
{
CloseUtil.close(con);
con = null;
}
}
 
public static void saveLance(L2PcInstance player, int hallId, int lance)
{
Date data = new Date();
SimpleDateFormat status = new SimpleDateFormat("dd/MM/yyyy");
String hh = status.format(data);
Connection con = null;
try
{
con = L2DatabaseFactory.getInstance().getConnection();
 
PreparedStatement statement = con.prepareStatement("INSERT INTO clanhall_leilao (char_id,charName,hall_id,lance,data_hora,clan_id ) VALUES (?, ?, ?, ?, ?, ? )");
 
statement.setInt(1, player.getObjectId());
statement.setString(2, player.getName());
statement.setInt(3, hallId);
statement.setInt(4, lance);
statement.setString(5, hh);
statement.setInt(6, player.getClanId());
 
statement.execute();
statement.close();
 
LOGGER.info("Hall Manager: Um novo lance foi enviado por " + player.getName() + ".");
 
_mapLeiloes.put(Integer.valueOf(player.getObjectId()), new TabelaDeLances(player.getObjectId(), player.getName(), hallId, lance, hh, player.getCharId()));
}
catch (Exception localException)
{
}
finally
{
CloseUtil.close(con);
con = null;
}
}
 
private String ClanName(int clanId)
{
L2Clan clan = ClanTable.getInstance().getClan(clanId);
return clan.getName();
}
 
private static String HallName(int hallId)
{
ClanHall clanHall = ClanHallManager.getInstance().getClanHallById(hallId);
return clanHall.getName();
}
}

  • 0
Posted

Can i ask why you need inventory update there since destroyItemByItemId sends update ?

I actually got this code and am just adding .. got this error there .

Create an account or sign in to comment

You need to be a member in order to leave a comment

Create an account

Sign up for a new account in our community. It's easy!

Register a new account

Sign in

Already have an account? Sign in here.

Sign In Now


×
×
  • Create New...

AdBlock Extension Detected!

Our website is made possible by displaying online advertisements to our members.

Please disable AdBlock browser extension first, to be able to use our community.

I've Disabled AdBlock