(https://www.united-extreme.com/u3games/foro/proxy.php?request=http%3A%2F%2Fi49.tinypic.com%2Fintq2t.jpg&hash=348a8f58d5fdde9ce1400e3ce262c4c06fd12335)
CitarStatbbsmanager.java
private void showCastle(L2PcInstance player)
{
SimpleDateFormat sdf = new SimpleDateFormat("dd.MM.yyyy HH:mm:ss");
PreparedStatement statement = null;
ResultSet rs = null;
try (Connection con = L2DatabaseFactory.getInstance().getConnection();)
{
statement = con.prepareStatement("SELECT * FROM castle ORDER BY name DESC LIMIT 10;");
rs = statement.executeQuery();
TextBuilder html = new TextBuilder();
html.append("<center>Castles</center>");
html.append("<img src=L2UI.SquareWhite width=600 height=1>");
html.append("<table width=598 bgcolor=CCCCCC>");
html.append("<tr>");
html.append("<td width=150>Castle Name</td>");
html.append("<td width=100>Tax Percent</td>");
html.append("<td width=200>Owner</td>");
html.append("<td width=150>Siege Date</td>");
html.append("</tr>");
html.append("</table>");
html.append("<img src=L2UI.SquareWhite width=600 height=1>");
html.append("<table width=600>");
String Owner = null;
String color = "FFFFFF";
while (rs.next())
{
CBStatMan tp = new CBStatMan();
tp.id = rs.getInt("Id");
tp.NameCastl = rs.getString("name");
tp.Percent = (rs.getString("taxPercent") + "%");
tp.siegeDate = sdf.format(new Date(rs.getLong("siegeDate")));
Owner = CastleManorManager.getInstance().getOwner(tp.id);
if (Owner != null)
{
color = "00CC00";
}
else
{
color = "FFFFFF";
Owner = "Not Owned";
}
html.append("<tr>");
html.append((new StringBuilder()).append("<td width=150>").append(tp.NameCastl).append("</td>").toString());
html.append((new StringBuilder()).append("<td width=100>").append(tp.Percent).append("</td>").toString());
html.append((new StringBuilder()).append("<td width=200><font color=" + color + ">" + Owner + "</font>").append("</td>").toString());
html.append((new StringBuilder()).append("<td width=150>").append(tp.siegeDate).append("</td>").toString());
html.append("</tr>");
}
html.append("</table>");
NpcHtmlMessage adminReply = new NpcHtmlMessage(5);
adminReply.setFile(player.getLang(), "data/html/CommunityBoard/11.htm");
adminReply.replace("%stat%", html.toString());
separateAndSend(adminReply.getHtm(), player);
statement.close();
rs.close();
return;
}
catch (Exception e)
{
e.printStackTrace();
}
}
CitarCastleManorManager.java
/**
* Method getOwner.
* @param castleId int
* @return String
*/
public String getOwner(int castleId)
{
PreparedStatement statement = null;
ResultSet rs = null;
try (Connection con = L2DatabaseFactory.getInstance().getConnection();)
{
statement = con.prepareStatement("SELECT clan_id FROM clan_data WHERE hasCastle = ? LIMIT 1");
statement.setInt(1, castleId);
rs = statement.executeQuery();
if (rs.next())
{
return ClanTable.getInstance().getClan(rs.getInt("clan_id")).getName();
}
}
catch (Exception e)
{
e.printStackTrace();
}
return null;
}