SHOW:
|
|
- or go back to the newest paste.
1 | Index: net.sf.l2j;Config.java | |
2 | =================================================================== | |
3 | --- net.sf.l2j;Config.java (revision 84) | |
4 | +++ net.sf.l2j;Config.java (working copy) | |
5 | ||
6 | + public static final String ITEMS_HANDER_FILE = "./config/aCis/ItemsHander.properties"; | |
7 | ||
8 | + /** COMBATE Hero Settings */ | |
9 | + public static boolean ENABLE_HERO_COIN; | |
10 | + | |
11 | + | |
12 | + public static int HERO_COIN_ID_7DAYS; | |
13 | + public static int HERO_COIN_7DAYS; | |
14 | + | |
15 | + public static int HERO_COIN_ID_15DAYS; | |
16 | + public static int HERO_COIN_15DAYS; | |
17 | + | |
18 | + public static int HERO_COIN_ID_30DAYS; | |
19 | + public static int HERO_COIN_30DAYS; | |
20 | + | |
21 | + public static int HERO_COIN_ID_ETERNAL; | |
22 | + public static int HERO_COIN_ETERNAL; | |
23 | + | |
24 | + public static int HERO_ITEM_ID; | |
25 | ||
26 | ||
27 | + private static final void loadItemHander() | |
28 | + { | |
29 | + final ExProperties ItemHander = initProperties(ITEMS_HANDER_FILE); | |
30 | + | |
31 | + | |
32 | + ENABLE_HERO_COIN = ItemHander.getProperty("EnableHeroCoin", false); | |
33 | + | |
34 | + HERO_COIN_ID_7DAYS = ItemHander.getProperty("Hero7DaysId", 10); | |
35 | + HERO_COIN_7DAYS = ItemHander.getProperty("SetHero7Days", 10); | |
36 | + | |
37 | + HERO_COIN_ID_15DAYS = ItemHander.getProperty("Hero15DaysId", 10); | |
38 | + HERO_COIN_15DAYS = ItemHander.getProperty("SetHero15Days", 10); | |
39 | + | |
40 | + HERO_COIN_ID_30DAYS = ItemHander.getProperty("Hero30DaysId", 10); | |
41 | + HERO_COIN_30DAYS = ItemHander.getProperty("SetHero30Days", 10); | |
42 | + | |
43 | + HERO_COIN_ID_ETERNAL = ItemHander.getProperty("HeroEternalId", 10); | |
44 | + HERO_COIN_ETERNAL = ItemHander.getProperty("SetHeroEternal", 10); | |
45 | + | |
46 | + | |
47 | + HERO_ITEM_ID = ItemHander.getProperty("RewardHeroItemId", 10); | |
48 | + | |
49 | + | |
50 | + } | |
51 | ||
52 | - // players settings | |
53 | - loadPlayers(); | |
54 | ||
55 | ||
56 | + // players settings | |
57 | + loadPlayers(); | |
58 | ||
59 | + loadItemHander(); | |
60 | ||
61 | Index: Dev/HeroItem/HeroTaskManager.java | |
62 | =================================================================== | |
63 | --- Dev/HeroItem/HeroTaskManager.java (revision 84) | |
64 | +++ Dev/HeroItem/HeroTaskManager.java (working copy) | |
65 | ||
66 | + package Dev.HeroItem; | |
67 | + | |
68 | + import java.util.Map; | |
69 | + import java.util.concurrent.ConcurrentHashMap; | |
70 | + | |
71 | + import net.sf.l2j.commons.concurrent.ThreadPool; | |
72 | + | |
73 | + import net.sf.l2j.gameserver.model.actor.Creature; | |
74 | + import net.sf.l2j.gameserver.model.actor.Player; | |
75 | + | |
76 | + /** | |
77 | + * @author COMBATE | |
78 | + * | |
79 | + */ | |
80 | + public final class HeroTaskManager implements Runnable | |
81 | + { | |
82 | + private final Map<Player, Long> _players = new ConcurrentHashMap<>(); | |
83 | + | |
84 | + protected HeroTaskManager() | |
85 | + { | |
86 | + // Run task each 10 second. | |
87 | + ThreadPool.scheduleAtFixedRate(this, 1000, 1000); | |
88 | + } | |
89 | + | |
90 | + public final void add(Player player) | |
91 | + { | |
92 | + _players.put(player, System.currentTimeMillis()); | |
93 | + } | |
94 | + | |
95 | + public final void remove(Creature player) | |
96 | + { | |
97 | + _players.remove(player); | |
98 | + } | |
99 | + | |
100 | + @Override | |
101 | + public final void run() | |
102 | + { | |
103 | + if (_players.isEmpty()) | |
104 | + return; | |
105 | + | |
106 | + for (Map.Entry<Player, Long> entry : _players.entrySet()) | |
107 | + { | |
108 | + final Player player = entry.getKey(); | |
109 | + | |
110 | + if (player.getMemos().getLong("heroEndTime") < System.currentTimeMillis()) | |
111 | + { | |
112 | + AdminSetHero.removeHero(player, player); | |
113 | + remove(player); | |
114 | + } | |
115 | + } | |
116 | + } | |
117 | + | |
118 | + public static final HeroTaskManager getInstance() | |
119 | + { | |
120 | + return SingletonHolder._instance; | |
121 | + } | |
122 | + | |
123 | + private static class SingletonHolder | |
124 | + { | |
125 | + protected static final HeroTaskManager _instance = new HeroTaskManager(); | |
126 | + } | |
127 | + } | |
128 | + | |
129 | ||
130 | Index: Dev/HeroItem/AdminSetHero.java | |
131 | =================================================================== | |
132 | --- Dev/HeroItem/AdminSetHero.java (revision 84) | |
133 | +++ Dev/HeroItem/AdminSetHero.java (working copy) | |
134 | ||
135 | + package Dev.HeroItem; | |
136 | + | |
137 | + import java.util.StringTokenizer; | |
138 | + import java.util.concurrent.TimeUnit; | |
139 | + | |
140 | + import net.sf.l2j.commons.concurrent.ThreadPool; | |
141 | + | |
142 | + import net.sf.l2j.Config; | |
143 | + import net.sf.l2j.gameserver.enums.SayType; | |
144 | + import net.sf.l2j.gameserver.handler.IAdminCommandHandler; | |
145 | + import net.sf.l2j.gameserver.model.World; | |
146 | + import net.sf.l2j.gameserver.model.actor.Player; | |
147 | + import net.sf.l2j.gameserver.network.serverpackets.CreatureSay; | |
148 | + import net.sf.l2j.gameserver.network.serverpackets.SocialAction; | |
149 | + | |
150 | + /** | |
151 | + * @author COMBATE | |
152 | + * | |
153 | + */ | |
154 | + public class AdminSetHero implements IAdminCommandHandler | |
155 | + { | |
156 | + private static String[] _adminCommands = new String[] | |
157 | + { | |
158 | + "admin_sethero", | |
159 | + "admin_nohero" | |
160 | + }; | |
161 | + | |
162 | + @Override | |
163 | + public boolean useAdminCommand(String command, Player activeChar) | |
164 | + { | |
165 | + StringTokenizer st = new StringTokenizer(command); | |
166 | + st.nextToken(); | |
167 | + String player = ""; | |
168 | + int time = 1; | |
169 | + Player target = null; | |
170 | + if (st.hasMoreTokens()) | |
171 | + { | |
172 | + player = st.nextToken(); | |
173 | + target = World.getInstance().getPlayer(player); | |
174 | + if (st.hasMoreTokens()) | |
175 | + { | |
176 | + try | |
177 | + { | |
178 | + time = Integer.parseInt(st.nextToken()); | |
179 | + } | |
180 | + catch (NumberFormatException nfe) | |
181 | + { | |
182 | + activeChar.sendMessage("Invalid number format used: " + nfe); | |
183 | + return false; | |
184 | + } | |
185 | + } | |
186 | + } | |
187 | + else if (activeChar.getTarget() != null && activeChar.getTarget() instanceof Player) | |
188 | + target = (Player) activeChar.getTarget(); | |
189 | + | |
190 | + if (command.startsWith("admin_sethero")) | |
191 | + { | |
192 | + if (target == null && player.equals("")) | |
193 | + { | |
194 | + activeChar.sendMessage("Usage: //hero <char_name> [duration_days]"); | |
195 | + return false; | |
196 | + } | |
197 | + if (target != null) | |
198 | + { | |
199 | + AdminSetHero.doHero(target, activeChar, time); | |
200 | + activeChar.sendMessage(target.getName() + " Comando /hero Liberado! "); | |
201 | + activeChar.sendMessage(target.getName() + " got Hero status for " + time + " day(s)."); | |
202 | + } | |
203 | + } | |
204 | + else if (command.startsWith("admin_nohero")) | |
205 | + { | |
206 | + if (target == null && player.equals("")) | |
207 | + { | |
208 | + activeChar.sendMessage("Usage: //nohero <char_name>"); | |
209 | + return false; | |
210 | + } | |
211 | + if (target != null) | |
212 | + { | |
213 | + if (target.isHero()) | |
214 | + { | |
215 | + AdminSetHero.removeHero(target, activeChar); | |
216 | + activeChar.sendMessage("Removed the Hero status from " + target.getName() + "."); | |
217 | + } | |
218 | + activeChar.sendMessage(target.getName() + " haven't Hero status."); | |
219 | + } | |
220 | + } | |
221 | + return true; | |
222 | + } | |
223 | + | |
224 | + public static void doHero(Player target, Player player, int time) | |
225 | + { | |
226 | + target.getStat().addExp(target.getStat().getExpForLevel(81)); | |
227 | + target.broadcastPacket(new SocialAction(target, 3)); | |
228 | + target.setHero(true); | |
229 | + | |
230 | + HeroTaskManager.getInstance().add(target); | |
231 | + long remainingTime = target.getMemos().getLong("heroEndTime", 0); | |
232 | + if (remainingTime > 0) | |
233 | + { | |
234 | + target.getMemos().set("heroEndTime", remainingTime + TimeUnit.DAYS.toMillis(time)); | |
235 | + target.sendPacket(new CreatureSay(0, SayType.HERO_VOICE, "Hero Manager", "Dear " + player.getName() + ", your Hero status has been extended by " + time + " day(s).")); | |
236 | + } | |
237 | + else | |
238 | + { | |
239 | + target.getMemos().set("heroEndTime", System.currentTimeMillis() + TimeUnit.DAYS.toMillis(time)); | |
240 | + target.sendPacket(new CreatureSay(0, SayType.HERO_VOICE, "Hero Manager", "Dear " + player.getName() + ", you got Hero Status for " + time + " day(s).")); | |
241 | + | |
242 | + if (Config.HERO_ITEM_ID != 0) | |
243 | + { | |
244 | + target.addItem("Add", Config.HERO_ITEM_ID, 1, target, true); | |
245 | + target.getInventory().equipItemAndRecord(target.getInventory().getItemByItemId(Config.HERO_ITEM_ID)); | |
246 | + } | |
247 | + target.setHero(true); | |
248 | + target.broadcastUserInfo(); | |
249 | + } | |
250 | + } | |
251 | + | |
252 | + public static void removeHero(Player target, Player player) | |
253 | + { | |
254 | + HeroTaskManager.getInstance().remove(target); | |
255 | + target.getMemos().set("heroEndTime", 0); | |
256 | + target.setHero(false); | |
257 | + | |
258 | + if (Config.HERO_ITEM_ID != 0) | |
259 | + target.destroyItemByItemId("Destroy", Config.HERO_ITEM_ID, 1, target, true); | |
260 | + | |
261 | + target.sendPacket(new CreatureSay(0, SayType.HERO_VOICE, "Hero Manager", "Dear " + player.getName() + ", Your Hero period is over. You will be disconected in 3 seconds.")); | |
262 | + target.broadcastPacket(new SocialAction(target, 13)); | |
263 | + target.sendSkillList(); | |
264 | + target.broadcastUserInfo(); | |
265 | + ThreadPool.schedule(() -> target.logout(false), 3000); | |
266 | + } | |
267 | + | |
268 | + @Override | |
269 | + public String[] getAdminCommandList() | |
270 | + { | |
271 | + return _adminCommands; | |
272 | + } | |
273 | + } | |
274 | + | |
275 | ||
276 | Index: Dev/HeroItem/HeroMenu.java | |
277 | =================================================================== | |
278 | --- Dev/HeroItem/HeroMenu.java (revision 84) | |
279 | +++ Dev/HeroItem/HeroMenu.java (working copy) | |
280 | ||
281 | + package Dev.HeroItem; | |
282 | + | |
283 | + import java.text.SimpleDateFormat; | |
284 | + import java.util.StringTokenizer; | |
285 | + import java.util.concurrent.TimeUnit; | |
286 | + | |
287 | + import net.sf.l2j.gameserver.data.xml.TeleportLocationData; | |
288 | + import net.sf.l2j.gameserver.handler.IUserCommandHandler; | |
289 | + import net.sf.l2j.gameserver.model.actor.Player; | |
290 | + import net.sf.l2j.gameserver.model.location.TeleportLocation; | |
291 | + import net.sf.l2j.gameserver.network.serverpackets.ActionFailed; | |
292 | + import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage; | |
293 | + | |
294 | + /** | |
295 | + * @author COMBATE | |
296 | + * | |
297 | + */ | |
298 | + public class HeroMenu implements IUserCommandHandler | |
299 | + { | |
300 | + private static final int[] COMMAND_IDS = | |
301 | + { | |
302 | + 305 | |
303 | + }; | |
304 | + | |
305 | + @Override | |
306 | + | |
307 | + public void useUserCommand(int command, Player activeChar) | |
308 | + { | |
309 | + mainHtml(activeChar, 0); | |
310 | + return; | |
311 | + } | |
312 | + | |
313 | + | |
314 | + public static void mainHtml(Player activeChar, int time) | |
315 | + { | |
316 | + NpcHtmlMessage nhm = new NpcHtmlMessage(5); | |
317 | + StringBuilder html = new StringBuilder(""); | |
318 | + html.append("<html><head><title>Hero Menu</title></head><body><center>"); | |
319 | + html.append("<img src=\"SS_l2jNetwork.lineo\" width=300 height=3>"); | |
320 | + html.append("<table width=305 height=20 bgcolor=000000>"); | |
321 | + html.append("<tr>"); | |
322 | + html.append("<td align=center>Personal HERO Options</td>"); | |
323 | + html.append("</tr>"); | |
324 | + html.append("</table>"); | |
325 | + html.append("<img src=\"SS_l2jNetwork.lineo\" width=300 height=3>"); | |
326 | + if (activeChar.isHero()) | |
327 | + { | |
328 | + html.append("<br><br>"); | |
329 | + html.append(""); | |
330 | + html.append(""); | |
331 | + html.append("<br>"); | |
332 | + html.append("<img src=\"SS_l2jNetwork.lineo\" width=300 height=3>"); | |
333 | + html.append("<table width=305 height=20 bgcolor=000000>"); | |
334 | + html.append("<tr>"); | |
335 | + html.append("<td align=center>Color Name Options</td>"); | |
336 | + html.append("</tr>"); | |
337 | + html.append("</table>"); | |
338 | + html.append("<img src=\"SS_l2jNetwork.lineo\" width=300 height=3>"); | |
339 | + html.append("<br><br>"); | |
340 | + html.append("<a action=\"bypass -h heropanel color Green\" <font color=\"009900\">Green</font></a>"); | |
341 | + html.append("<a action=\"bypass -h heropanel color Blue\" <font color=\"3333ff\">Blue</font></a>"); | |
342 | + html.append("<a action=\"bypass -h heropanel color Purple\" <font color=\"800080\">Purple</font></a>"); | |
343 | + html.append("<a action=\"bypass -h heropanel color Yellow\" <font color=\"ffff00\">Yellow</font></a>"); | |
344 | + html.append("<a action=\"bypass -h heropanel color Gold\" <font color=\"cca300\">Gold</font></a>"); | |
345 | + html.append("<br><br><br>"); | |
346 | + html.append("<img src=\"SS_l2jNetwork.lineo\" width=300 height=3>"); | |
347 | + html.append("<table width=310 height=20 bgcolor=000000>"); | |
348 | + html.append("<tr>"); | |
349 | + html.append("<td align=center>Your HERO Status Period:</td>"); | |
350 | + html.append("</tr>"); | |
351 | + html.append("</table>"); | |
352 | + html.append("<img src=\"SS_l2jNetwork.lineo\" width=300 height=3>"); | |
353 | + long delay = activeChar.getMemos().getLong("heroEndTime", 0); | |
354 | + html.append("HERO Status ends at " + new SimpleDateFormat("dd-MM-yyyy HH:mm").format(delay) + ""); | |
355 | + } | |
356 | + else | |
357 | + { | |
358 | + html.append("<br>"); | |
359 | + html.append("Your character Isn't HERO."); | |
360 | + } | |
361 | + html.append("</center>"); | |
362 | + html.append("</body></html>"); | |
363 | + nhm.setHtml(html.toString()); | |
364 | + activeChar.sendPacket(nhm); | |
365 | + return; | |
366 | + } | |
367 | + | |
368 | + public static void Time(Player player, int time) | |
369 | + { | |
370 | + player.getMemos().set("heroEndTime", System.currentTimeMillis() + TimeUnit.DAYS.toMillis(time)); | |
371 | + } | |
372 | + | |
373 | + public static void bypass(Player activeChar, String command, StringTokenizer st) | |
374 | + { | |
375 | + if (command.equals("panelteleport")) | |
376 | + { | |
377 | + NpcHtmlMessage nhm = new NpcHtmlMessage(5); | |
378 | + StringBuilder html = new StringBuilder(""); | |
379 | + html.append("<html><head><title>AIO Teleport Menu</title></head><body><center>"); | |
380 | + html.append("<img src=\"SS_l2jNetwork.lineo\" width=300 height=3>"); | |
381 | + html.append("<table width=315 height=20 bgcolor=000000>"); | |
382 | + html.append("<tr>"); | |
383 | + html.append("<td align=center>Choose your destination</td>"); | |
384 | + html.append("</tr>"); | |
385 | + html.append("</table>"); | |
386 | + html.append("<img src=\"SS_l2jNetwork.lineo\" width=300 height=3>"); | |
387 | + if (activeChar.isHero()) | |
388 | + { | |
389 | + html.append("<br><br>"); | |
390 | + html.append("<button value=\"Giran\" action=\"bypass -h heropanel teleportTo 1040\" width=122 height=23 fore=\"SS_l2jBan.bf\" back=\"SS_l2jBan.bf\">"); | |
391 | + html.append("<button value=\"Goddard\" action=\"bypass -h heropanel teleportTo 1039\" width=122 height=23 fore=\"SS_l2jBan.bf\" back=\"SS_l2jBan.bf\">"); | |
392 | + html.append("<button value=\"Rune\" action=\"bypass -h heropanel teleportTo 1041\" width=122 height=23 fore=\"SS_l2jBan.bf\" back=\"SS_l2jBan.bf\">"); | |
393 | + html.append("<button value=\"Aden\" action=\"bypass -h heropanel teleportTo 1037\" width=122 height=23 fore=\"SS_l2jBan.bf\" back=\"SS_l2jBan.bf\">"); | |
394 | + html.append("<button value=\"Dion\" action=\"bypass -h heropanel teleportTo 6\" width=122 height=23 fore=\"SS_l2jBan.bf\" back=\"SS_l2jBan.bf\">"); | |
395 | + html.append("<button value=\"Gludio\" action=\"bypass -h heropanel teleportTo 1099\" width=122 height=23 fore=\"SS_l2jBan.bf\" back=\"SS_l2jBan.bf\">"); | |
396 | + html.append("<button value=\"Gludin\" action=\"bypass -h heropanel teleportTo 5\" width=122 height=23 fore=\"SS_l2jBan.bf\" back=\"SS_l2jBan.bf\">"); | |
397 | + html.append("<button value=\"Heine\" action=\"bypass -h heropanel teleportTo 1036\" width=122 height=23 fore=\"SS_l2jBan.bf\" back=\"SS_l2jBan.bf\">"); | |
398 | + html.append("<button value=\"Oren\" action=\"bypass -h heropanel teleportTo 1038\" width=122 height=23 fore=\"SS_l2jBan.bf\" back=\"SS_l2jBan.bf\">"); | |
399 | + html.append("<button value=\"Schuttgart\" action=\"bypass -h heropanel teleportTo 1035\" width=122 height=23 fore=\"SS_l2jBan.bf\" back=\"SS_l2jBan.bf\">"); | |
400 | + html.append("<br><br>"); | |
401 | + } | |
402 | + else | |
403 | + { | |
404 | + html.append("<br>"); | |
405 | + html.append("Your character Isn't HERO."); | |
406 | + } | |
407 | + html.append("</center>"); | |
408 | + html.append("</body></html>"); | |
409 | + nhm.setHtml(html.toString()); | |
410 | + activeChar.sendPacket(nhm); | |
411 | + } | |
412 | + else if (command.equals("teleportTo")) | |
413 | + { | |
414 | + final TeleportLocation list = TeleportLocationData.getInstance().getTeleportLocation(Integer.parseInt(st.nextToken())); | |
415 | + if (list != null) | |
416 | + { | |
417 | + if (activeChar.reduceAdena("Teleport", list.getPrice(), activeChar, true)) | |
418 | + activeChar.teleportTo(list, 0); | |
419 | + } | |
420 | + else | |
421 | + activeChar.sendMessage("No teleport destination. Contact with server Admin"); | |
422 | + | |
423 | + activeChar.sendPacket(ActionFailed.STATIC_PACKET); | |
424 | + } | |
425 | + else if (command.equals("color")) | |
426 | + | |
427 | + { | |
428 | + NpcHtmlMessage nhm = new NpcHtmlMessage(5); | |
429 | + StringBuilder html = new StringBuilder(""); | |
430 | + String type = st.nextToken(); | |
431 | + | |
432 | + switch (type) | |
433 | + { | |
434 | + case "Green": | |
435 | + | |
436 | + activeChar.getAppearance().setNameColor(0x009900); | |
437 | + activeChar.broadcastUserInfo(); | |
438 | + activeChar.sendMessage("Your color name has changed!"); | |
439 | + nhm.setHtml(html.toString()); | |
440 | + activeChar.sendPacket(nhm); | |
441 | + break; | |
442 | + case "Blue": | |
443 | + | |
444 | + activeChar.getAppearance().setNameColor(0xff7f00); | |
445 | + activeChar.broadcastUserInfo(); | |
446 | + activeChar.sendMessage("Your color name has changed!"); | |
447 | + nhm.setHtml(html.toString()); | |
448 | + activeChar.sendPacket(nhm); | |
449 | + break; | |
450 | + case "Purple": | |
451 | + | |
452 | + activeChar.getAppearance().setNameColor(0x800080); | |
453 | + activeChar.broadcastUserInfo(); | |
454 | + activeChar.sendMessage("Your color name has changed!"); | |
455 | + nhm.setHtml(html.toString()); | |
456 | + activeChar.sendPacket(nhm); | |
457 | + break; | |
458 | + case "Yellow": | |
459 | + | |
460 | + activeChar.getAppearance().setNameColor(0x00ffff); | |
461 | + activeChar.broadcastUserInfo(); | |
462 | + activeChar.sendMessage("Your color name has changed!"); | |
463 | + nhm.setHtml(html.toString()); | |
464 | + activeChar.sendPacket(nhm); | |
465 | + break; | |
466 | + case "Gold": | |
467 | + | |
468 | + activeChar.getAppearance().setNameColor(0x0099ff); | |
469 | + activeChar.broadcastUserInfo(); | |
470 | + activeChar.sendMessage("Your color name has changed!"); | |
471 | + nhm.setHtml(html.toString()); | |
472 | + activeChar.sendPacket(nhm); | |
473 | + break; | |
474 | + } | |
475 | + } | |
476 | + } | |
477 | + | |
478 | + | |
479 | + @Override | |
480 | + public int[] getUserCommandList() | |
481 | + { | |
482 | + return COMMAND_IDS; | |
483 | + } | |
484 | + } | |
485 | + | |
486 | ||
487 | Index: Dev/HeroItem/Hero7Days.java | |
488 | =================================================================== | |
489 | --- Dev/HeroItem/Hero7Days.java (revision 84) | |
490 | +++ Dev/HeroItem/Hero7Days.java (working copy) | |
491 | ||
492 | + package Dev.HeroItem; | |
493 | + | |
494 | + import net.sf.l2j.Config; | |
495 | + import net.sf.l2j.gameserver.handler.IItemHandler; | |
496 | + import net.sf.l2j.gameserver.model.actor.Playable; | |
497 | + import net.sf.l2j.gameserver.model.actor.Player; | |
498 | + import net.sf.l2j.gameserver.model.item.instance.ItemInstance; | |
499 | + import net.sf.l2j.gameserver.model.olympiad.OlympiadManager; | |
500 | + import net.sf.l2j.gameserver.network.SystemMessageId; | |
501 | + import net.sf.l2j.gameserver.network.serverpackets.SocialAction; | |
502 | + | |
503 | + /** | |
504 | + * @author COMBATE | |
505 | + * | |
506 | + */ | |
507 | + public class Hero7Days implements IItemHandler | |
508 | + { | |
509 | + private static final int[] ITEM_IDS = new int[] | |
510 | + { | |
511 | + Config.HERO_COIN_ID_7DAYS | |
512 | + }; | |
513 | + | |
514 | + @Override | |
515 | + public void useItem(Playable playable, ItemInstance item, boolean forceUse) | |
516 | + { | |
517 | + | |
518 | + if (Config.ENABLE_HERO_COIN) | |
519 | + { | |
520 | + if (!(playable instanceof Player)) | |
521 | + return; | |
522 | + | |
523 | + Player player = (Player) playable; | |
524 | + if (player.isHero()) | |
525 | + player.sendMessage("Comando /hero Liberado!"); | |
526 | + | |
527 | + else if (player.isInOlympiadMode() || OlympiadManager.getInstance().isRegisteredInComp(player)) | |
528 | + player.sendPacket(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT); | |
529 | + else if (player.destroyItemByItemId("hero", Config.HERO_COIN_ID_7DAYS, 1, null, true)) | |
530 | + AdminSetHero.doHero(player, player, Config.HERO_COIN_7DAYS); | |
531 | + HeroMenu.mainHtml(player, 0); | |
532 | + } | |
533 | + } | |
534 | + | |
535 | + public static void RemoveHeroStatus(Player target) | |
536 | + { | |
537 | + HeroTaskManager.getInstance().remove(target); | |
538 | + target.getMemos().set("heroEndTime", 0); | |
539 | + target.setHero(false); | |
540 | + target.broadcastPacket(new SocialAction(target, 13)); | |
541 | + target.broadcastUserInfo(); | |
542 | + } | |
543 | + | |
544 | + public int[] getItemIds() | |
545 | + { | |
546 | + return ITEM_IDS; | |
547 | + } | |
548 | + } | |
549 | + | |
550 | ||
551 | Index: Dev/HeroItem/Hero15Days.java | |
552 | =================================================================== | |
553 | --- Dev/HeroItem/Hero15Days.java (revision 84) | |
554 | +++ Dev/HeroItem/Hero15Days.java (working copy) | |
555 | ||
556 | + package Dev.HeroItem; | |
557 | + | |
558 | + import net.sf.l2j.Config; | |
559 | + import net.sf.l2j.gameserver.handler.IItemHandler; | |
560 | + import net.sf.l2j.gameserver.model.actor.Playable; | |
561 | + import net.sf.l2j.gameserver.model.actor.Player; | |
562 | + import net.sf.l2j.gameserver.model.item.instance.ItemInstance; | |
563 | + import net.sf.l2j.gameserver.model.olympiad.OlympiadManager; | |
564 | + import net.sf.l2j.gameserver.network.SystemMessageId; | |
565 | + import net.sf.l2j.gameserver.network.serverpackets.SocialAction; | |
566 | + | |
567 | + /** | |
568 | + * @author COMBATE | |
569 | + * | |
570 | + */ | |
571 | + public class Hero15Days implements IItemHandler | |
572 | + { | |
573 | + private static final int[] ITEM_IDS = new int[] | |
574 | + { | |
575 | + Config.HERO_COIN_ID_15DAYS | |
576 | + }; | |
577 | + | |
578 | + @Override | |
579 | + public void useItem(Playable playable, ItemInstance item, boolean forceUse) | |
580 | + { | |
581 | + | |
582 | + if (Config.ENABLE_HERO_COIN) | |
583 | + { | |
584 | + if (!(playable instanceof Player)) | |
585 | + return; | |
586 | + | |
587 | + Player player = (Player) playable; | |
588 | + if (player.isHero()) | |
589 | + player.sendMessage("Comando /hero Liberado!"); | |
590 | + | |
591 | + else if (player.isInOlympiadMode() || OlympiadManager.getInstance().isRegisteredInComp(player)) | |
592 | + player.sendPacket(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT); | |
593 | + else if (player.destroyItemByItemId("hero", Config.HERO_COIN_ID_15DAYS, 1, null, true)) | |
594 | + AdminSetHero.doHero(player, player, Config.HERO_COIN_15DAYS); | |
595 | + HeroMenu.mainHtml(player, 0); | |
596 | + } | |
597 | + } | |
598 | + | |
599 | + public static void RemoveHeroStatus(Player target) | |
600 | + { | |
601 | + HeroTaskManager.getInstance().remove(target); | |
602 | + target.getMemos().set("heroEndTime", 0); | |
603 | + target.setHero(false); | |
604 | + target.broadcastPacket(new SocialAction(target, 13)); | |
605 | + target.broadcastUserInfo(); | |
606 | + } | |
607 | + | |
608 | + public int[] getItemIds() | |
609 | + { | |
610 | + return ITEM_IDS; | |
611 | + } | |
612 | + } | |
613 | + | |
614 | ||
615 | Index: Dev/HeroItem/Hero30Days.java | |
616 | =================================================================== | |
617 | --- Dev/HeroItem/Hero30Days.java (revision 84) | |
618 | +++ Dev/HeroItem/Hero30Days.java (working copy) | |
619 | ||
620 | + package Dev.HeroItem; | |
621 | + | |
622 | + import net.sf.l2j.Config; | |
623 | + import net.sf.l2j.gameserver.handler.IItemHandler; | |
624 | + import net.sf.l2j.gameserver.model.actor.Playable; | |
625 | + import net.sf.l2j.gameserver.model.actor.Player; | |
626 | + import net.sf.l2j.gameserver.model.item.instance.ItemInstance; | |
627 | + import net.sf.l2j.gameserver.model.olympiad.OlympiadManager; | |
628 | + import net.sf.l2j.gameserver.network.SystemMessageId; | |
629 | + import net.sf.l2j.gameserver.network.serverpackets.SocialAction; | |
630 | + | |
631 | + /** | |
632 | + * @author COMBATE | |
633 | + * | |
634 | + */ | |
635 | + public class Hero30Days implements IItemHandler | |
636 | + { | |
637 | + private static final int[] ITEM_IDS = new int[] | |
638 | + { | |
639 | + Config.HERO_COIN_ID_30DAYS | |
640 | + }; | |
641 | + | |
642 | + @Override | |
643 | + public void useItem(Playable playable, ItemInstance item, boolean forceUse) | |
644 | + { | |
645 | + | |
646 | + if (Config.ENABLE_HERO_COIN) | |
647 | + { | |
648 | + if (!(playable instanceof Player)) | |
649 | + return; | |
650 | + | |
651 | + Player player = (Player) playable; | |
652 | + if (player.isHero()) | |
653 | + player.sendMessage("Comando /hero Liberado!"); | |
654 | + | |
655 | + else if (player.isInOlympiadMode() || OlympiadManager.getInstance().isRegisteredInComp(player)) | |
656 | + player.sendPacket(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT); | |
657 | + else if (player.destroyItemByItemId("hero", Config.HERO_COIN_ID_30DAYS, 1, null, true)) | |
658 | + AdminSetHero.doHero(player, player, Config.HERO_COIN_30DAYS); | |
659 | + HeroMenu.mainHtml(player, 0); | |
660 | + } | |
661 | + } | |
662 | + | |
663 | + public static void RemoveHeroStatus(Player target) | |
664 | + { | |
665 | + HeroTaskManager.getInstance().remove(target); | |
666 | + target.getMemos().set("heroEndTime", 0); | |
667 | + target.setHero(false); | |
668 | + target.broadcastPacket(new SocialAction(target, 13)); | |
669 | + target.broadcastUserInfo(); | |
670 | + } | |
671 | + | |
672 | + public int[] getItemIds() | |
673 | + { | |
674 | + return ITEM_IDS; | |
675 | + } | |
676 | + } | |
677 | ||
678 | Index: Dev/HeroItem/HeroEternal.java | |
679 | =================================================================== | |
680 | --- Dev/HeroItem/HeroEternal.java (revision 84) | |
681 | +++ Dev/HeroItem/HeroEternal.java (working copy) | |
682 | ||
683 | + package Dev.HeroItem; | |
684 | + | |
685 | + import net.sf.l2j.Config; | |
686 | + import net.sf.l2j.gameserver.handler.IItemHandler; | |
687 | + import net.sf.l2j.gameserver.model.actor.Playable; | |
688 | + import net.sf.l2j.gameserver.model.actor.Player; | |
689 | + import net.sf.l2j.gameserver.model.item.instance.ItemInstance; | |
690 | + import net.sf.l2j.gameserver.model.olympiad.OlympiadManager; | |
691 | + import net.sf.l2j.gameserver.network.SystemMessageId; | |
692 | + import net.sf.l2j.gameserver.network.serverpackets.SocialAction; | |
693 | + | |
694 | + /** | |
695 | + * @author COMBATE | |
696 | + * | |
697 | + */ | |
698 | + public class HeroEternal implements IItemHandler | |
699 | + { | |
700 | + private static final int[] ITEM_IDS = new int[] | |
701 | + { | |
702 | + Config.HERO_COIN_ID_ETERNAL | |
703 | + }; | |
704 | + | |
705 | + @Override | |
706 | + public void useItem(Playable playable, ItemInstance item, boolean forceUse) | |
707 | + { | |
708 | + | |
709 | + if (Config.ENABLE_HERO_COIN) | |
710 | + { | |
711 | + if (!(playable instanceof Player)) | |
712 | + return; | |
713 | + | |
714 | + Player player = (Player) playable; | |
715 | + if (player.isHero()) | |
716 | + player.sendMessage("Comando /hero Liberado!"); | |
717 | + | |
718 | + else if (player.isInOlympiadMode() || OlympiadManager.getInstance().isRegisteredInComp(player)) | |
719 | + player.sendPacket(SystemMessageId.YOU_ARE_NOT_AUTHORIZED_TO_DO_THAT); | |
720 | + else if (player.destroyItemByItemId("hero", Config.HERO_COIN_ID_ETERNAL, 1, null, true)) | |
721 | + AdminSetHero.doHero(player, player, Config.HERO_COIN_ETERNAL); | |
722 | + HeroMenu.mainHtml(player, 0); | |
723 | + } | |
724 | + } | |
725 | + | |
726 | + public static void RemoveHeroStatus(Player target) | |
727 | + { | |
728 | + HeroTaskManager.getInstance().remove(target); | |
729 | + target.getMemos().set("heroEndTime", 0); | |
730 | + target.setHero(false); | |
731 | + target.broadcastPacket(new SocialAction(target, 13)); | |
732 | + target.broadcastUserInfo(); | |
733 | + } | |
734 | + | |
735 | + public int[] getItemIds() | |
736 | + { | |
737 | + return ITEM_IDS; | |
738 | + } | |
739 | + } | |
740 | + | |
741 | ||
742 | Index: net.sf.l2j.gameserver.network.clientpackets;RequestBypassToServer.java | |
743 | =================================================================== | |
744 | --- net.sf.l2j.gameserver.network.clientpackets;RequestBypassToServer.java (revision 84) | |
745 | +++ net.sf.l2j.gameserver.network.clientpackets;RequestBypassToServer.java (working copy) | |
746 | ||
747 | ||
748 | + if (_command.startsWith("heropanel")) | |
749 | + { | |
750 | + String value = _command.substring(8); | |
751 | + StringTokenizer st = new StringTokenizer(value); | |
752 | + String command = st.nextToken(); | |
753 | + | |
754 | + HeroMenu.bypass(player, command, st); | |
755 | + } | |
756 | ||
757 | Index: net.sf.l2j.gameserver.network.clientpackets;EnterWorld.java | |
758 | =================================================================== | |
759 | --- net.sf.l2j.gameserver.network.clientpackets;EnterWorld.java (revision 84) | |
760 | +++ net.sf.l2j.gameserver.network.clientpackets;EnterWorld.java (working copy) | |
761 | ||
762 | + import Dev.HeroItem.Hero7Days; | |
763 | + import Dev.HeroItem.HeroMenu; | |
764 | ||
765 | ||
766 | if (player.getMemos().getLong("vipTime", 0) > 0) | |
767 | ||
768 | ||
769 | + if (player.getMemos().getLong("heroEndTime", 0) > 0) | |
770 | + onEnterHero(player); | |
771 | ||
772 | ||
773 | + private static void onEnterHero(Player activeChar) | |
774 | + { | |
775 | + long now = Calendar.getInstance().getTimeInMillis(); | |
776 | + long endDay = activeChar.getMemos().getLong("heroEndTime"); | |
777 | + | |
778 | + if (now > endDay) | |
779 | + Hero7Days.RemoveHeroStatus(activeChar); | |
780 | + else | |
781 | + { | |
782 | + | |
783 | + activeChar.setHero(true); | |
784 | + activeChar.broadcastUserInfo(); | |
785 | + HeroMenu.mainHtml(activeChar, 0); | |
786 | + sendReEnterMessageHero(activeChar); | |
787 | + | |
788 | + } | |
789 | + } | |
790 | ||
791 | + private static void sendReEnterMessageHero(Player player) | |
792 | + { | |
793 | + long delay = player.getMemos().getLong("heroEndTime", 0); | |
794 | + | |
795 | + player.sendMessage("Hero Ends In: " + new SimpleDateFormat("dd-MM-yyyy HH:mm").format(delay) + ""); | |
796 | + | |
797 | + } | |
798 | ||
799 | ||
800 | Index: net.sf.l2j.gameserver.model.actor;Player.java | |
801 | =================================================================== | |
802 | --- net.sf.l2j.gameserver.model.actor;Player.java (revision 84) | |
803 | +++ net.sf.l2j.gameserver.model.actor;Player.java (working copy) | |
804 | ||
805 | Index: Apenas Comfirme se existe! se não adicione | |
806 | ||
807 | + private boolean _isHero; | |
808 | + | |
809 | + | |
810 | + public boolean isHero() | |
811 | + { | |
812 | + return _isHero; | |
813 | + } | |
814 | + | |
815 | + | |
816 | + public void setHero(boolean hero) | |
817 | + { | |
818 | + if (hero && _baseClass == _activeClass) | |
819 | + { | |
820 | + for (L2Skill skill : SkillTable.getHeroSkills()) | |
821 | + addSkill(skill, false); | |
822 | + } | |
823 | + else | |
824 | + { | |
825 | + for (L2Skill skill : SkillTable.getHeroSkills()) | |
826 | + removeSkill(skill.getId(), false); | |
827 | + | |
828 | + HeroTaskManager.getInstance().remove(this); | |
829 | + getMemos().set("heroEndTime", 0); | |
830 | + } | |
831 | + _isHero = hero; | |
832 | + | |
833 | + broadcastUserInfo(); | |
834 | + sendSkillList(); | |
835 | + } | |
836 | ||
837 | Index: Referencia pra adicionar | |
838 | public void onPlayerEnter() | |
839 | ||
840 | ||
841 | + if (isHero()) | |
842 | + HeroTaskManager.getInstance().add(this); | |
843 | ||
844 | Index: Referencia | |
845 | // Stop all timers associated to that Player. | |
846 | ||
847 | - PvpFlagTaskManager.getInstance().remove(this); | |
848 | + PvpFlagTaskManager.getInstance().remove(this); | |
849 | + HeroTaskManager.getInstance().remove(this); | |
850 | ||
851 | Index: Referencia | |
852 | ||
853 | private void regiveTemporarySkills() | |
854 | { | |
855 | ||
856 | + // Add Hero skills if hero. | |
857 | + if (isHero()) | |
858 | + setHero(true); | |
859 | ||
860 | ||
861 | Index: Referencia pra adicionar | |
862 | PreparedStatement ps = con.prepareStatement(RESTORE_CHARACTER)) | |
863 | ||
864 | ||
865 | - // Set the position of the Player. | |
866 | - player.getPosition().set(rs.getInt("x"), rs.getInt("y"), rs.getInt("z"), rs.getInt("heading")); | |
867 | ||
868 | + // Set the position of the Player. | |
869 | + player.getPosition().set(rs.getInt("x"), rs.getInt("y"), rs.getInt("z"), rs.getInt("heading")); | |
870 | ||
871 | + // Set Hero status if it applies | |
872 | + if (HeroManager.getInstance().isActiveHero(objectId)) | |
873 | + player.setHero(true); | |
874 | ||
875 | ||
876 | Index: net.sf.l2j.gameserver.handler;AdminCommandHandler.java | |
877 | =================================================================== | |
878 | --- net.sf.l2j.gameserver.handler;AdminCommandHandler.java (revision 84) | |
879 | +++ net.sf.l2j.gameserver.handler;AdminCommandHandler.java (working copy) | |
880 | ||
881 | + import Dev.HeroItem.AdminSetHero; | |
882 | ||
883 | ||
884 | - registerHandler(new AdminTeleport()); | |
885 | + registerHandler(new AdminTeleport()); | |
886 | ||
887 | + registerHandler(new AdminSetHero()); | |
888 | ||
889 | Index: net.sf.l2j.gameserver.handler;ItemHandler.java | |
890 | =================================================================== | |
891 | --- net.sf.l2j.gameserver.network.clientpackets;ItemHandler.java (revision 84) | |
892 | +++ net.sf.l2j.gameserver.network.clientpackets;ItemHandler.java (working copy) | |
893 | ||
894 | + import Dev.HeroItem.Hero15Days; | |
895 | + import Dev.HeroItem.Hero30Days; | |
896 | + import Dev.HeroItem.Hero7Days; | |
897 | + import Dev.HeroItem.HeroEternal; | |
898 | ||
899 | + registerHandler(new Hero7Days()); | |
900 | + registerHandler(new Hero15Days()); | |
901 | + registerHandler(new Hero30Days()); | |
902 | + registerHandler(new HeroEternal()); | |
903 | ||
904 | Index: data/xml/adminCommands.xml | |
905 | =================================================================== | |
906 | --- data/xml/adminCommands.xml (revision 84) | |
907 | +++ data/xml/adminCommands.xml (working copy) | |
908 | ||
909 | - <!-- OLYMPIADS --> | |
910 | - <aCar name="admin_addolypoints" accessLevel="7"/> | |
911 | - <aCar name="admin_removeolypoints" accessLevel="7"/> | |
912 | - <aCar name="admin_endoly" accessLevel="7"/> | |
913 | + <aCar name="admin_sethero" accessLevel="7"/> | |
914 | + <aCar name="admin_nohero" accessLevel="7"/> | |
915 | - <aCar name="admin_setnoble" accessLevel="7"/> |