Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- diff --git a/aCis_datapack/data/html/CommunityBoard/ranking/ranklist.htm b/aCis_datapack/data/html/CommunityBoard/ranking/ranklist.htm
- new file mode 100644
- index 0000000..0f5f88d
- --- /dev/null
- +++ b/aCis_datapack/data/html/CommunityBoard/ranking/ranklist.htm
- @@ -0,0 +1,41 @@
- +<html><body><center><img height=20>
- + <img src=l2ui.squaregray width=630 height=1>
- + <table width=630 height=40 bgcolor=000000>
- + <tr>
- + <td width=40 align=center><table bgcolor=FFFFFF cellpadding=6 cellspacing="-5"><tr><td><button width=32 height=32 back=icon.skill1028 fore=icon.skill1028></td></tr></table></td>
- + <td width=590>Welcome <font color=LEVEL>%name%</font> to server Ranking Dashboard.
- + <br1><font color=B09878>Here are listed top 15 pvp and pk players of our server.</font></td>
- + </tr>
- + </table>
- + <img src=l2ui.squaregray width=630 height=1>
- + <img height=24>
- + <table width=630><tr>
- + <td width=315 align=center>
- + <img src=L2UI.SquareWhite width=296 height=1>
- + <table width=300 bgcolor=000000><tr>
- + <td width=20 align=center><font color=A9A9A9>#</td>
- + <td width=20 height=18></td>
- + <td width=160 align=left>Player Name</td>
- + <td width=100 align=right>PVP</font></td>
- + </tr></table><img src=L2UI.SquareWhite width=296 height=1>
- + %pvp%
- + <img src=L2UI.SquareWhite width=296 height=1>
- + </td>
- +
- + <td width=315 align=center>
- + <img src=L2UI.SquareWhite width=296 height=1>
- + <table width=300 bgcolor=000000><tr>
- + <td width=20 align=center><font color=A9A9A9>#</td>
- + <td width=20 height=18 align=center></td>
- + <td width=160 align=left>Player Name</td>
- + <td width=100 align=right>PK</font></td>
- + </tr></table><img src=L2UI.SquareWhite width=296 height=1>
- + %pks%
- + <img src=L2UI.SquareWhite width=296 height=1>
- + </td>
- + </tr></table>
- + <img height=20>
- + <img src=L2UI.SquareWhite width=300 height=1>
- + <table width=300 bgcolor=000000><tr><td width=300 align=center><font color=AAAAAA>Next update in %time% second(s)</font></td></tr></table>
- + <img src=L2UI.SquareWhite width=300 height=1>
- +</center></body></html>
- \ No newline at end of file
- diff --git a/aCis_datapack/data/html/CommunityBoard/top/index.htm b/aCis_datapack/data/html/CommunityBoard/top/index.htm
- index e54aa7d..177e787 100644
- --- a/aCis_datapack/data/html/CommunityBoard/top/index.htm
- +++ b/aCis_datapack/data/html/CommunityBoard/top/index.htm
- @@ -64,4 +64,5 @@
- <td width=610><img src="l2ui.squaregray" width="600" height="1"></td>
- </tr>
- </table>
- + <br><br><center><a action="bypass _bbsranking">Ranking System</a>
- </center></body></html>
- \ No newline at end of file
- diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/communitybbs/CommunityBoard.java b/aCis_gameserver/java/net/sf/l2j/gameserver/communitybbs/CommunityBoard.java
- index a9da4a0..9338d3b 100644
- --- a/aCis_gameserver/java/net/sf/l2j/gameserver/communitybbs/CommunityBoard.java
- +++ b/aCis_gameserver/java/net/sf/l2j/gameserver/communitybbs/CommunityBoard.java
- @@ -16,6 +16,7 @@
- import net.sf.l2j.gameserver.communitybbs.manager.FriendsBBSManager;
- import net.sf.l2j.gameserver.communitybbs.manager.MailBBSManager;
- import net.sf.l2j.gameserver.communitybbs.manager.PostBBSManager;
- +import net.sf.l2j.gameserver.communitybbs.manager.RankingBBSManager;
- import net.sf.l2j.gameserver.communitybbs.manager.RegionBBSManager;
- import net.sf.l2j.gameserver.communitybbs.manager.TopBBSManager;
- import net.sf.l2j.gameserver.communitybbs.manager.TopicBBSManager;
- @@ -121,6 +122,8 @@
- TopicBBSManager.getInstance().parseCmd(command, player);
- else if (command.startsWith("_bbsposts"))
- PostBBSManager.getInstance().parseCmd(command, player);
- + else if (command.startsWith("_bbsranking"))
- + RankingBBSManager.getInstance().parseCmd(command, player);
- else
- BaseBBSManager.separateAndSend("<html><body><br><br><center>The command: " + command + " isn't implemented.</center></body></html>", player);
- }
- diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/communitybbs/manager/RankingBBSManager.java b/aCis_gameserver/java/net/sf/l2j/gameserver/communitybbs/manager/RankingBBSManager.java
- new file mode 100644
- index 0000000..d4def7f
- --- /dev/null
- +++ b/aCis_gameserver/java/net/sf/l2j/gameserver/communitybbs/manager/RankingBBSManager.java
- @@ -0,0 +1,137 @@
- +package net.sf.l2j.gameserver.communitybbs.manager;
- +
- +import java.sql.Connection;
- +import java.sql.PreparedStatement;
- +import java.sql.ResultSet;
- +import java.util.stream.IntStream;
- +
- +import net.sf.l2j.commons.lang.StringUtil;
- +import net.sf.l2j.commons.pool.ConnectionPool;
- +
- +import net.sf.l2j.gameserver.data.cache.HtmCache;
- +import net.sf.l2j.gameserver.model.World;
- +import net.sf.l2j.gameserver.model.actor.Player;
- +
- +public class RankingBBSManager extends BaseBBSManager
- +{
- + private static final StringBuilder PVP = new StringBuilder();
- + private static final StringBuilder PKS = new StringBuilder();
- +
- + private static final int PAGE_LIMIT_15 = 15;
- +
- + private long _nextUpdate;
- +
- + protected RankingBBSManager()
- + {
- + }
- +
- + @Override
- + public void parseCmd(String command, Player player)
- + {
- + if (command.equals("_bbsranking"))
- + showRakingList(player);
- + else
- + super.parseCmd(command, player);
- + }
- +
- + public void showRakingList(Player player)
- + {
- + if (_nextUpdate < System.currentTimeMillis())
- + {
- + PVP.setLength(0);
- + PKS.setLength(0);
- +
- + try (Connection con = ConnectionPool.getConnection())
- + {
- + try (PreparedStatement ps = con.prepareStatement("SELECT char_name, pvpkills FROM characters WHERE pvpkills > 0 ORDER BY pvpkills DESC LIMIT " + PAGE_LIMIT_15);
- + ResultSet rs = ps.executeQuery())
- + {
- + int index = 1;
- + while (rs.next())
- + {
- + final String name = rs.getString("char_name");
- + final Player databasePlayer = World.getInstance().getPlayer(name);
- + final String status = "L2UI_CH3.msnicon" + (databasePlayer != null && databasePlayer.isOnline() ? "1" : "4");
- +
- + StringUtil.append(PVP, "<table width=300 bgcolor=000000><tr><td width=20 align=right>", getColor(index), String.format("%02d", index), "</td>");
- + StringUtil.append(PVP, "<td width=20 height=18><img src=", status, " width=16 height=16></td><td width=160 align=left>", name, "</td>");
- + StringUtil.append(PVP, "<td width=100 align=right>", StringUtil.formatNumber(rs.getInt("pvpkills")), "</font></td></tr></table><img src=L2UI.SquareGray width=296 height=1>");
- + index++;
- + }
- + IntStream.range(index - 1, PAGE_LIMIT_15).forEach(x -> applyEmpty(PVP));
- + }
- +
- + try (PreparedStatement ps = con.prepareStatement("SELECT char_name, pkkills FROM characters WHERE pkkills > 0 ORDER BY pkkills DESC LIMIT " + PAGE_LIMIT_15);
- + ResultSet rs = ps.executeQuery())
- + {
- + int index = 1;
- + while (rs.next())
- + {
- + final String name = rs.getString("char_name");
- + final Player databasePlayer = World.getInstance().getPlayer(name);
- + final String status = "L2UI_CH3.msnicon" + (databasePlayer != null && databasePlayer.isOnline() ? "1" : "4");
- +
- + StringUtil.append(PKS, "<table width=300 bgcolor=000000><tr><td width=20 align=right>", getColor(index), String.format("%02d", index), "</td>");
- + StringUtil.append(PKS, "<td width=20 height=18><img src=", status, " width=16 height=16></td><td width=160 align=left>", name, "</td>");
- + StringUtil.append(PKS, "<td width=100 align=right>", StringUtil.formatNumber(rs.getInt("pkkills")), "</font></td></tr></table><img src=L2UI.SquareGray width=296 height=1>");
- + index++;
- + }
- + IntStream.range(index - 1, PAGE_LIMIT_15).forEach(x -> applyEmpty(PKS));
- + }
- + }
- + catch (Exception e)
- + {
- + LOGGER.warn("There was problem while updating ranking system.", e);
- + }
- +
- + _nextUpdate = System.currentTimeMillis() + 60000L;
- + }
- +
- + String content = HtmCache.getInstance().getHtm(CB_PATH + getFolder() + "ranklist.htm");
- + content = content.replaceAll("%name%", player.getName());
- + content = content.replaceAll("%pvp%", PVP.toString());
- + content = content.replaceAll("%pks%", PKS.toString());
- +
- + content = content.replaceAll("%time%", String.valueOf((_nextUpdate - System.currentTimeMillis()) / 1000));
- + separateAndSend(content, player);
- + }
- +
- + protected void applyEmpty(StringBuilder sb)
- + {
- + sb.append("<table width=300 bgcolor=000000><tr>");
- + sb.append("<td width=20 align=right><font color=B09878>--</font></td><td width=20 height=18></td>");
- + sb.append("<td width=160 align=left><font color=B09878>----------------</font></td>");
- + sb.append("<td width=100 align=right><font color=FF0000>0</font></td>");
- + sb.append("</tr></table><img src=L2UI.SquareGray width=296 height=1>");
- + }
- +
- + protected String getColor(int index)
- + {
- + switch (index)
- + {
- + case 1:
- + return "<font color=FFFF00>";
- + case 2:
- + return "<font color=FFA500>";
- + case 3:
- + return "<font color=E9967A>";
- + }
- + return "";
- + }
- +
- + @Override
- + protected String getFolder()
- + {
- + return "ranking/";
- + }
- +
- + public static RankingBBSManager getInstance()
- + {
- + return SingletonHolder.INSTANCE;
- + }
- +
- + private static class SingletonHolder
- + {
- + protected static final RankingBBSManager INSTANCE = new RankingBBSManager();
- + }
- +}
- \ No newline at end of file
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement