public class ShowBoard extends L2GameServerPacket
{
private static final String _S__6E_SHOWBOARD = "[S] 6e ShowBoard";
private String _htmlCode;
private String _id;
private List<String> _arg;
public ShowBoard(String htmlCode, String id)
{
_id = id;
_htmlCode = htmlCode;
}
public ShowBoard(List<String> arg)
{
_id = "1002";
_htmlCode = null;
_arg = arg;
}
private byte[] get1002()
{
int len = _id.getBytes().length * 2 + 2;
for (String arg : _arg)
{
len += (arg.getBytes().length + 4) * 2;
}
byte data[] = new byte[len];
int i = 0;
for (int j = 0; j < _id.getBytes().length; j++, i += 2)
{
data[i] = _id.getBytes()[j];
data[i + 1] = 0;
}
data[i++] = 8;
data[i++] = 0;
for (String arg : _arg)
{
for (int j = 0; j < arg.getBytes().length; j++, i += 2)
{
data[i] = arg.getBytes()[j];
data[i + 1] = 0;
}
data[i++] = 0x20;
data[i++] = 0x0;
data[i++] = 0x8;
data[i++] = 0x0;
}
return data;
}
@Override
protected final void writeImpl()
{
writeC(0x6E);
writeC(0x01);
writeS("bypass _bbshome");
writeS("bypass _bbsgetfav");
writeS("bypass _bbsloc");
writeS("bypass _bbsclan");
writeS("bypass _bbsmemo");
writeS("bypass _bbsmail");
writeS("bypass _bbsfriends");
writeS("bypass bbs_add_fav");
if(_htmlCode!=null)
_htmlCode = HTMParser.parseHTM(_htmlCode, getClient().getActiveChar());
if (!_id.equals("1002"))
{
byte[] htmlBytes = new byte[0];
if (_htmlCode != null) {
htmlBytes = _htmlCode.getBytes();
}
byte[] idBytes = _id.getBytes();
byte data[] = new byte[2 + 2 + 2 + idBytes.length * 2 + 2 * ((_htmlCode != null) ? htmlBytes.length : 0)];
int i = 0;
for (int j = 0; j < idBytes.length; j++, i += 2)
{
data[i] = idBytes[j];
data[i + 1] = 0;
}
data[i++] = 8;
data[i++] = 0;
byte[] html = new byte[0];
if (_htmlCode != null)
{
try
{
html = _htmlCode.getBytes("UTF-16LE");
}
catch (UnsupportedEncodingException e)
{
html = new byte[_htmlCode.length() * 2];
for (int j = 0; j < htmlBytes.length; i += 2, j++)
{
data[i] = htmlBytes[j];
data[i + 1] = 0;
}
}
}
System.arraycopy(html, 0, data, i, html.length);
i += html.length;
data[i++] = 0;
data[i] = 0;
writeB(data);
}
else
{
writeB(get1002());
}
}
@Override
public String getType()
{
return _S__6E_SHOWBOARD;
}
}