SHOW:
|
|
- or go back to the newest paste.
1 | diff --git a/aCis_datapack/data/html/CommunityBoard/ranking/ranklist.htm b/aCis_datapack/data/html/CommunityBoard/ranking/ranklist.htm | |
2 | new file mode 100644 | |
3 | index 0000000..0f5f88d | |
4 | --- /dev/null | |
5 | +++ b/aCis_datapack/data/html/CommunityBoard/ranking/ranklist.htm | |
6 | @@ -0,0 +1,41 @@ | |
7 | +<html><body><center><img height=20> | |
8 | + <img src=l2ui.squaregray width=630 height=1> | |
9 | + <table width=630 height=40 bgcolor=000000> | |
10 | + <tr> | |
11 | + <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> | |
12 | + <td width=590>Welcome <font color=LEVEL>%name%</font> to server Ranking Dashboard. | |
13 | + <br1><font color=B09878>Here are listed top 15 pvp and pk players of our server.</font></td> | |
14 | + </tr> | |
15 | + </table> | |
16 | + <img src=l2ui.squaregray width=630 height=1> | |
17 | + <img height=24> | |
18 | + <table width=630><tr> | |
19 | + <td width=315 align=center> | |
20 | + <img src=L2UI.SquareWhite width=296 height=1> | |
21 | + <table width=300 bgcolor=000000><tr> | |
22 | + <td width=20 align=center><font color=A9A9A9>#</td> | |
23 | + <td width=20 height=18></td> | |
24 | + <td width=160 align=left>Player Name</td> | |
25 | + <td width=100 align=right>PVP</font></td> | |
26 | + </tr></table><img src=L2UI.SquareWhite width=296 height=1> | |
27 | + %pvp% | |
28 | + <img src=L2UI.SquareWhite width=296 height=1> | |
29 | + </td> | |
30 | + | |
31 | + <td width=315 align=center> | |
32 | + <img src=L2UI.SquareWhite width=296 height=1> | |
33 | + <table width=300 bgcolor=000000><tr> | |
34 | + <td width=20 align=center><font color=A9A9A9>#</td> | |
35 | + <td width=20 height=18 align=center></td> | |
36 | + <td width=160 align=left>Player Name</td> | |
37 | + <td width=100 align=right>PK</font></td> | |
38 | + </tr></table><img src=L2UI.SquareWhite width=296 height=1> | |
39 | + %pks% | |
40 | + <img src=L2UI.SquareWhite width=296 height=1> | |
41 | + </td> | |
42 | + </tr></table> | |
43 | + <img height=20> | |
44 | + <img src=L2UI.SquareWhite width=300 height=1> | |
45 | + <table width=300 bgcolor=000000><tr><td width=300 align=center><font color=AAAAAA>Next update in %time% second(s)</font></td></tr></table> | |
46 | + <img src=L2UI.SquareWhite width=300 height=1> | |
47 | +</center></body></html> | |
48 | \ No newline at end of file | |
49 | diff --git a/aCis_datapack/data/html/CommunityBoard/top/index.htm b/aCis_datapack/data/html/CommunityBoard/top/index.htm | |
50 | index e54aa7d..177e787 100644 | |
51 | --- a/aCis_datapack/data/html/CommunityBoard/top/index.htm | |
52 | +++ b/aCis_datapack/data/html/CommunityBoard/top/index.htm | |
53 | @@ -64,4 +64,5 @@ | |
54 | <td width=610><img src="l2ui.squaregray" width="600" height="1"></td> | |
55 | </tr> | |
56 | </table> | |
57 | + <br><br><center><a action="bypass _bbsranking">Ranking System</a> | |
58 | </center></body></html> | |
59 | \ No newline at end of file | |
60 | diff --git a/aCis_gameserver/java/net/sf/l2j/gameserver/communitybbs/CommunityBoard.java b/aCis_gameserver/java/net/sf/l2j/gameserver/communitybbs/CommunityBoard.java | |
61 | index a9da4a0..9338d3b 100644 | |
62 | --- a/aCis_gameserver/java/net/sf/l2j/gameserver/communitybbs/CommunityBoard.java | |
63 | +++ b/aCis_gameserver/java/net/sf/l2j/gameserver/communitybbs/CommunityBoard.java | |
64 | @@ -16,6 +16,7 @@ | |
65 | import net.sf.l2j.gameserver.communitybbs.manager.FriendsBBSManager; | |
66 | import net.sf.l2j.gameserver.communitybbs.manager.MailBBSManager; | |
67 | import net.sf.l2j.gameserver.communitybbs.manager.PostBBSManager; | |
68 | +import net.sf.l2j.gameserver.communitybbs.manager.RankingBBSManager; | |
69 | import net.sf.l2j.gameserver.communitybbs.manager.RegionBBSManager; | |
70 | import net.sf.l2j.gameserver.communitybbs.manager.TopBBSManager; | |
71 | import net.sf.l2j.gameserver.communitybbs.manager.TopicBBSManager; | |
72 | @@ -121,6 +122,8 @@ | |
73 | TopicBBSManager.getInstance().parseCmd(command, player); | |
74 | else if (command.startsWith("_bbsposts")) | |
75 | PostBBSManager.getInstance().parseCmd(command, player); | |
76 | + else if (command.startsWith("_bbsranking")) | |
77 | + RankingBBSManager.getInstance().parseCmd(command, player); | |
78 | else | |
79 | BaseBBSManager.separateAndSend("<html><body><br><br><center>The command: " + command + " isn't implemented.</center></body></html>", player); | |
80 | } | |
81 | 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 | |
82 | new file mode 100644 | |
83 | index 0000000..d4def7f | |
84 | --- /dev/null | |
85 | +++ b/aCis_gameserver/java/net/sf/l2j/gameserver/communitybbs/manager/RankingBBSManager.java | |
86 | @@ -0,0 +1,137 @@ | |
87 | +package net.sf.l2j.gameserver.communitybbs.manager; | |
88 | + | |
89 | +import java.sql.Connection; | |
90 | +import java.sql.PreparedStatement; | |
91 | +import java.sql.ResultSet; | |
92 | +import java.util.stream.IntStream; | |
93 | + | |
94 | +import net.sf.l2j.commons.lang.StringUtil; | |
95 | +import net.sf.l2j.commons.pool.ConnectionPool; | |
96 | + | |
97 | +import net.sf.l2j.gameserver.data.cache.HtmCache; | |
98 | +import net.sf.l2j.gameserver.model.World; | |
99 | +import net.sf.l2j.gameserver.model.actor.Player; | |
100 | + | |
101 | +public class RankingBBSManager extends BaseBBSManager | |
102 | +{ | |
103 | + private static final StringBuilder PVP = new StringBuilder(); | |
104 | + private static final StringBuilder PKS = new StringBuilder(); | |
105 | + | |
106 | + private static final int PAGE_LIMIT_15 = 15; | |
107 | + | |
108 | + private long _nextUpdate; | |
109 | + | |
110 | + protected RankingBBSManager() | |
111 | + { | |
112 | + } | |
113 | + | |
114 | + @Override | |
115 | + public void parseCmd(String command, Player player) | |
116 | + { | |
117 | + if (command.equals("_bbsranking")) | |
118 | + showRakingList(player); | |
119 | + else | |
120 | + super.parseCmd(command, player); | |
121 | + } | |
122 | + | |
123 | + public void showRakingList(Player player) | |
124 | + { | |
125 | + if (_nextUpdate < System.currentTimeMillis()) | |
126 | + { | |
127 | + PVP.setLength(0); | |
128 | + PKS.setLength(0); | |
129 | + | |
130 | + try (Connection con = ConnectionPool.getConnection()) | |
131 | + { | |
132 | + try (PreparedStatement ps = con.prepareStatement("SELECT char_name, pvpkills FROM characters WHERE pvpkills > 0 ORDER BY pvpkills DESC LIMIT " + PAGE_LIMIT_15); | |
133 | + ResultSet rs = ps.executeQuery()) | |
134 | + { | |
135 | + int index = 1; | |
136 | + while (rs.next()) | |
137 | + { | |
138 | + final String name = rs.getString("char_name"); | |
139 | + final Player databasePlayer = World.getInstance().getPlayer(name); | |
140 | + final String status = "L2UI_CH3.msnicon" + (databasePlayer != null && databasePlayer.isOnline() ? "1" : "4"); | |
141 | + | |
142 | + StringUtil.append(PVP, "<table width=300 bgcolor=000000><tr><td width=20 align=right>", getColor(index), String.format("%02d", index), "</td>"); | |
143 | + StringUtil.append(PVP, "<td width=20 height=18><img src=", status, " width=16 height=16></td><td width=160 align=left>", name, "</td>"); | |
144 | + 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>"); | |
145 | + index++; | |
146 | + } | |
147 | + IntStream.range(index - 1, PAGE_LIMIT_15).forEach(x -> applyEmpty(PVP)); | |
148 | + } | |
149 | + | |
150 | + try (PreparedStatement ps = con.prepareStatement("SELECT char_name, pkkills FROM characters WHERE pkkills > 0 ORDER BY pkkills DESC LIMIT " + PAGE_LIMIT_15); | |
151 | + ResultSet rs = ps.executeQuery()) | |
152 | + { | |
153 | + int index = 1; | |
154 | + while (rs.next()) | |
155 | + { | |
156 | + final String name = rs.getString("char_name"); | |
157 | + final Player databasePlayer = World.getInstance().getPlayer(name); | |
158 | + final String status = "L2UI_CH3.msnicon" + (databasePlayer != null && databasePlayer.isOnline() ? "1" : "4"); | |
159 | + | |
160 | + StringUtil.append(PKS, "<table width=300 bgcolor=000000><tr><td width=20 align=right>", getColor(index), String.format("%02d", index), "</td>"); | |
161 | + StringUtil.append(PKS, "<td width=20 height=18><img src=", status, " width=16 height=16></td><td width=160 align=left>", name, "</td>"); | |
162 | + 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>"); | |
163 | + index++; | |
164 | + } | |
165 | + IntStream.range(index - 1, PAGE_LIMIT_15).forEach(x -> applyEmpty(PKS)); | |
166 | + } | |
167 | + } | |
168 | + catch (Exception e) | |
169 | + { | |
170 | + LOGGER.warn("There was problem while updating ranking system.", e); | |
171 | + } | |
172 | + | |
173 | + _nextUpdate = System.currentTimeMillis() + 60000L; | |
174 | + } | |
175 | + | |
176 | + String content = HtmCache.getInstance().getHtm(CB_PATH + getFolder() + "ranklist.htm"); | |
177 | + content = content.replaceAll("%name%", player.getName()); | |
178 | + content = content.replaceAll("%pvp%", PVP.toString()); | |
179 | + content = content.replaceAll("%pks%", PKS.toString()); | |
180 | + | |
181 | + content = content.replaceAll("%time%", String.valueOf((_nextUpdate - System.currentTimeMillis()) / 1000)); | |
182 | + separateAndSend(content, player); | |
183 | + } | |
184 | + | |
185 | + protected void applyEmpty(StringBuilder sb) | |
186 | + { | |
187 | + sb.append("<table width=300 bgcolor=000000><tr>"); | |
188 | + sb.append("<td width=20 align=right><font color=B09878>--</font></td><td width=20 height=18></td>"); | |
189 | + sb.append("<td width=160 align=left><font color=B09878>----------------</font></td>"); | |
190 | + sb.append("<td width=100 align=right><font color=FF0000>0</font></td>"); | |
191 | + sb.append("</tr></table><img src=L2UI.SquareGray width=296 height=1>"); | |
192 | + } | |
193 | + | |
194 | + protected String getColor(int index) | |
195 | + { | |
196 | + switch (index) | |
197 | + { | |
198 | + case 1: | |
199 | + return "<font color=FFFF00>"; | |
200 | + case 2: | |
201 | + return "<font color=FFA500>"; | |
202 | + case 3: | |
203 | + return "<font color=E9967A>"; | |
204 | + } | |
205 | + return ""; | |
206 | + } | |
207 | + | |
208 | + @Override | |
209 | + protected String getFolder() | |
210 | + { | |
211 | + return "ranking/"; | |
212 | + } | |
213 | + | |
214 | + public static RankingBBSManager getInstance() | |
215 | + { | |
216 | + return SingletonHolder.INSTANCE; | |
217 | + } | |
218 | + | |
219 | + private static class SingletonHolder | |
220 | + { | |
221 | + protected static final RankingBBSManager INSTANCE = new RankingBBSManager(); | |
222 | + } | |
223 | +} | |
224 | \ No newline at end of file |