Advertisement
VANPER

Cafe_Point

Jan 14th, 2020
1,779
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Java 27.67 KB | None | 0 0
  1. Index: /Gs folder/java/l2jban/com/gameserver/PcPoint.java
  2. ===================================================================
  3. --- /Gs folder/java/l2jban/com/gameserver/PcPoint.java (revision 2031)
  4. +++ /Gs folder/java/l2jban/com/gameserver/pcbang.java (revision `2031)
  5. @@ -0,0 +1,78 @@
  6. +package l2jban.pcbang;
  7. +
  8. +import java.util.logging.Logger;
  9. +
  10. +import net.sf.l2j.commons.random.Rnd;
  11. +
  12. +import net.sf.l2j.Config;
  13. +import net.sf.l2j.gameserver.model.World;
  14. +import net.sf.l2j.gameserver.model.actor.Player;
  15. +
  16. +/**
  17. + * @author Juvenil Walker
  18. + *
  19. + */
  20. +public class pcbang implements Runnable
  21. +{
  22. +   Logger _log = Logger.getLogger(pcbang.class.getName());
  23. +   private static pcbang _instance;
  24. +  
  25. +   public static pcbang getInstance()
  26. +  
  27. +    {
  28. +   if(_instance == null)
  29. +    {
  30. +        _instance = new pcbang();
  31. +         }
  32. +      
  33. +    return _instance;
  34. +    }
  35. +  
  36. +    private pcbang()
  37. +       {
  38. +          _log.info("PcBang point event started.");
  39. +       }
  40. +    
  41. +    @Override
  42. +    public void run()
  43. +    {
  44. +
  45. +            int score = 0;
  46. +            for (Player activeChar: World.getInstance().getAllPlayers().values())
  47. +            {
  48. +
  49. +                    if(activeChar.getLevel() > Config.PCB_MIN_LEVEL )
  50. +                    {
  51. +                            score = Rnd.get(Config.PCB_POINT_MIN, Config.PCB_POINT_MAX);
  52. +
  53. +                            if(Rnd.get(100) <= Config.PCB_CHANCE_DUAL_POINT)
  54. +                            {
  55. +                                    score *= 2;
  56. +
  57. +                                    activeChar.addPcBangScore(score);
  58. +                                    
  59. +                                    activeChar.sendMessage("Your PC Bang Point had doubled 1 hour.");
  60. +                                    activeChar.updatePcBangWnd(score, true, true);
  61. +                            }
  62. +                            else
  63. +                            {
  64. +           activeChar.addPcBangScore(score);
  65. +           activeChar.sendMessage("You recevied PC Bang Point 1 hour.");
  66. +           activeChar.updatePcBangWnd(score, true, false);
  67. +                            }
  68. +                    }
  69. +
  70. +                    activeChar = null;
  71. +            }
  72. +    }
  73. +}
  74.  
  75. Index: /Gs folder/java/net/sf/l2j/Config.java
  76. ===================================================================
  77. --- /Gs folder/java/net/sf/l2j/Config.java (revision 2028)
  78. +++ /Gs folder/java/net/sf/l2j/Config.java (revision 2031)
  79. @@ -1687,55 +1687,48 @@
  80.  
  81.  
  82. +   public static final String PCBANGPOINT_FILE = "./config/PcBanG.properties";
  83.    
  84.    
  85. +  //============================================================
  86. +  public static boolean PCB_ENABLE;
  87. +
  88. +  public static int PCB_COIN_ID;
  89. +  
  90. +  public static int PCB_MIN_LEVEL;
  91. +  public static int PCB_POINT_MIN;
  92. +  public static int PCB_POINT_MAX;
  93. +  public static int PCB_CHANCE_DUAL_POINT;
  94. +  public static int PCB_INTERVAL;
  95. +   public static int THREAD_P_EFFECTS = 6; // default 6
  96. +   public static int THREAD_P_GENERAL = 15; // default 15
  97. +   public static int GENERAL_PACKET_THREAD_CORE_SIZE = 4; // default 4
  98. +   public static int IO_PACKET_THREAD_CORE_SIZE = 2; // default 2
  99. +   public static int GENERAL_THREAD_CORE_SIZE = 4; // default 4
  100. +   public static int AI_MAX_THREAD = 10; // default 10
  101. +   //============================================================
  102.  
  103. +  public static void loadPCBPointConfig()
  104. +   {
  105. +       final ExProperties PcBanG = initProperties(Config.PCBANGPOINT_FILE);
  106. +      
  107. +        PCB_ENABLE = Boolean.parseBoolean(PcBanG.getProperty("PcBangPointEnable", "true"));
  108. +        PCB_MIN_LEVEL = Integer.parseInt(PcBanG.getProperty("PcBangPointMinLevel", "20"));
  109. +        PCB_POINT_MIN = Integer.parseInt(PcBanG.getProperty("PcBangPointMinCount", "20"));
  110. +        PCB_POINT_MAX = Integer.parseInt(PcBanG.getProperty("PcBangPointMaxCount", "1000000"));
  111. +        PCB_COIN_ID = Integer.parseInt(PcBanG.getProperty("PCBCoinId", "0"));
  112. +        
  113. +
  114. +        if(PCB_POINT_MAX < 1)
  115. +      {
  116. +        PCB_POINT_MAX = Integer.MAX_VALUE;
  117. +        
  118. +      }
  119. +
  120. +         PCB_CHANCE_DUAL_POINT = Integer.parseInt(PcBanG.getProperty("PcBangPointDualChance", "20"));
  121. +         PCB_INTERVAL = Integer.parseInt(PcBanG.getProperty("PcBangPointTimeStamp", "900"));
  122. +                  
  123. +           }
  124. +
  125. +
  126. +  
  127. +   //============================================================
  128.  
  129.  
  130. +loadPCBPointConfig();
  131.  
  132.  
  133. Index: /Gs folder/java/net/sf/l2j/gameserver/clientpackets/MultiSellChoose.java
  134. ===================================================================
  135. --- /Gs folder/java/net/sf/l2j/gameserver/clientpackets/MultiSellChoose.java (revision 107)
  136. +++ /Gs folder/java/net/sf/l2j/gameserver/clientpackets/MultiSellChoose.java (revision 2031)
  137. @@ -200,4 +200,9 @@
  138.  
  139. +   private static final int PC_BANG_POINTS = Config.PCB_COIN_ID;
  140.    
  141.    
  142. {
  143.  
  144.     if (player.getClan().getReputationScore() < e.getItemCount() * _amount)
  145.     {
  146.     player.sendPacket(SystemMessageId.THE_CLAN_REPUTATION_SCORE_IS_TOO_LOW);
  147.     return;
  148.     }
  149. }          
  150.                
  151. +           else if (e.getItemId() == PC_BANG_POINTS)
  152. +           {
  153. +               if (player.getPcBang() < (e.getItemCount() * _amount))
  154. +               {
  155. +                   player.sendMessage("You don't have enough Territory War Points.");
  156. +                   return;
  157. +               }
  158. +           }
  159.  
  160.     List<L2Augmentation> augmentation = new ArrayList<>();
  161.        
  162.     for (Ingredient e : entry.getIngredients())
  163.     {
  164.     if (e.getItemId() == CLAN_REPUTATION)
  165.     {
  166.     final int amount = e.getItemCount() * _amount;
  167.                
  168.     player.getClan().takeReputationScore(amount);
  169.     player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.S1_DEDUCTED_FROM_CLAN_REP).addNumber(amount));
  170.     }
  171.    
  172. +               else if (e.getItemId() == PC_BANG_POINTS)
  173. +           {
  174. +               int totalTWPoints = e.getItemCount() * _amount;
  175. +               player.setPcBang(player.getPcBang()-totalTWPoints);
  176. +           }      
  177.  
  178.     // Generate the appropriate items
  179.     for (Ingredient e : entry.getProducts())
  180.     {
  181.     if (e.getItemId() == CLAN_REPUTATION)
  182.     player.getClan().addReputationScore(e.getItemCount() * _amount);
  183.    
  184. +  
  185. +           else if (e.getItemId() == PC_BANG_POINTS)
  186. +               player.setPcBang(player.getPcBang()+(e.getItemCount()*_amount));
  187. +              
  188. }
  189. Index: /Gs folder/java/net/sf/l2j/gameserver/clientpackets/EnterWorld.java
  190. ===================================================================
  191. --- /Gs folder/java/net/sf/l2j/gameserver/clientpackets/EnterWorld.java (revision 1726)
  192. +++ /Gs folder/java/net/sf/l2j/gameserver/clientpackets/EnterWorld.java (revision 2031)
  193.  
  194. activeChar.onPlayerEnter();
  195.  
  196.  
  197. +    if(Config.PCB_ENABLE)
  198. +    {
  199. +    activeChar.showPcBangWindow();
  200. +    }
  201.  
  202.  
  203. Index: /Gs folder/java/net/sf/l2j/gameserver/network/serverpackets/ExPCCafePointInfo.java
  204. ===================================================================
  205. --- /Gs folder/java/net/sf/l2j/gameserver/network/serverpackets/ExPCCafePointInfo.java (revision 7)
  206. +++ /Gs folder/java/net/sf/l2j/gameserver/network/serverpackets/ExPCCafePointInfo.java (revision 2031)
  207. @@ -15,4 +15,6 @@
  208. +package net.sf.l2j.gameserver.network.serverpackets;
  209. +
  210. +import net.sf.l2j.gameserver.model.actor.Player;
  211. +
  212. +public class ExPCCafePointInfo extends L2GameServerPacket
  213. +{
  214. +   private Player _character;
  215. +   private int m_AddPoint;
  216. +   private int m_PeriodType;
  217. +   private int RemainTime;
  218. +   private int PointType;
  219. +
  220. +   public ExPCCafePointInfo(Player user, int modify, boolean add, int hour, boolean _double)
  221. +   {
  222. +       _character = user;
  223. +       m_AddPoint = modify;
  224. +      
  225. +       if (add)
  226. +       {
  227. +             m_PeriodType = 1;
  228. +             PointType = 1;
  229. +       }
  230. +       else
  231. +       {
  232. +             if (add && _double)
  233. +             {
  234. +                     m_PeriodType = 1;
  235. +                     PointType = 0;
  236. +             }
  237. +             else
  238. +             {
  239. +                     m_PeriodType = 2;
  240. +                     PointType = 2;
  241. +             }
  242. +       }
  243. +      
  244. +   RemainTime = hour;
  245. +
  246. +   }
  247. +  
  248. +   @Override
  249. +   protected void writeImpl()
  250. +   {
  251. +       writeC(0xFE);
  252. +       writeH(0x31);
  253. +       writeD(_character.getPcBangScore());
  254. +       writeD(m_AddPoint);
  255. +       writeC(m_PeriodType);
  256. +       writeD(RemainTime);
  257. +       writeC(PointType);
  258. +   }
  259. +}
  260.  
  261. Index: /Gs folder/java/net/sf/l2j/gameserver/model/actor/Player.java
  262. ===================================================================
  263. --- /Gs folder/java/net/sf/l2j/gameserver/model/actor/Player.java (revision 2029)
  264. +++ /Gs folder/java/net/sf/l2j/gameserver/model/actor/Player.java (revision 2031)
  265. @@ -93,5 +93,4 @@
  266.  
  267. +   private static final String UPDATE_CHARACTER = "UPDATE characters SET level=?,maxHp=?,curHp=?,maxCp=?,curCp=?,maxMp=?,curMp=?,face=?,hairStyle=?,hairColor=?,sex=?,heading=?,x=?,y=?,z=?,exp=?,expBeforeDeath=?,sp=?,karma=?,pvpkills=?,pkkills=?,clanid=?,race=?,classid=?,deletetime=?,title=?,accesslevel=?,online=?,isin7sdungeon=?,clan_privs=?,wantspeace=?,base_class=?,onlinetime=?,punish_level=?,punish_timer=?,nobless=?,power_grade=?,subpledge=?,lvl_joined_academy=?,apprentice=?,sponsor=?,varka_ketra_ally=?,clan_join_expiry_time=?,clan_create_expiry_time=?,char_name=?,death_penalty_level=?,pc_point=? WHERE obj_id=?";
  268. +   private static final String RESTORE_CHARACTER = "SELECT account_name, obj_Id, char_name, level, maxHp, curHp, maxCp, curCp, maxMp, curMp, face, hairStyle, hairColor, sex, heading, x, y, z, exp, expBeforeDeath, sp, karma, pvpkills, pkkills, clanid, race, classid, deletetime, cancraft, title, rec_have, rec_left, accesslevel, online, lastAccess, clan_privs, wantspeace, base_class, onlinetime, isin7sdungeon, punish_level, punish_timer, nobless, power_grade, subpledge, lvl_joined_academy, apprentice, sponsor, varka_ketra_ally,clan_join_expiry_time,clan_create_expiry_time,death_penalty_level,pc_point FROM characters WHERE obj_id=?";
  269.  
  270. No final da Linha esta adicionado pc_point
  271.  
  272.  
  273. - PreparedStatement ps = con.prepareStatement(UPDATE_CHARACTER))
  274. + PreparedStatement ps = con.prepareStatement(UPDATE_CHARACTER))
  275.  
  276. -   ps.setLong(46, getDeathPenaltyBuffLevel());
  277. +   ps.setLong(46, getDeathPenaltyBuffLevel());
  278. +   ps.setInt(47, getPcBangScore());
  279. +   ps.execute();
  280. +   ps.close()
  281.  
  282. -   PreparedStatement ps = con.prepareStatement(RESTORE_CHARACTER))
  283. +   PreparedStatement ps = con.prepareStatement(RESTORE_CHARACTER))
  284.  
  285. -   player.setDeathPenaltyBuffLevel(rs.getInt("death_penalty_level"));
  286. +   player.setDeathPenaltyBuffLevel(rs.getInt("death_penalty_level")); 
  287.  
  288. +   player.setPcBang(rs.getInt("pc_point"));
  289.  
  290. +           private int pcBangPoint = 0;
  291. +                      
  292. +
  293. +           public int getPcBang()
  294. +           {
  295. +               return pcBangPoint;
  296. +           }
  297. +          
  298. +           public void setPcBang(int val)
  299. +           {
  300. +               pcBangPoint = val;
  301. +              
  302. +               ExPCCafePointInfo wnd = new ExPCCafePointInfo(this, 0, false, 24, false);
  303. +                sendPacket(wnd);
  304. +           }
  305. +              
  306. +          
  307. +            public int getPcBangScore()
  308. +            {
  309. +                    return pcBangPoint;
  310. +            }
  311. +
  312. +            public void reducePcBangScore(int to)
  313. +            {
  314. +                    pcBangPoint -= to;
  315. +                    updatePcBangWnd(to, false, false);
  316. +            }
  317. +
  318. +            public void addPcBangScore(int to)
  319. +            {
  320. +                    pcBangPoint += to;
  321. +            }
  322. +
  323. +            public void updatePcBangWnd(int score, boolean add, boolean duble)
  324. +            {
  325. +                    ExPCCafePointInfo wnd = new ExPCCafePointInfo(this, score, add, 24, duble);
  326. +                    sendPacket(wnd);
  327. +            }
  328. +
  329. +            public void showPcBangWindow()
  330. +            {
  331. +                    ExPCCafePointInfo wnd = new ExPCCafePointInfo(this, 0, false, 24, false);
  332. +                    sendPacket(wnd);
  333. +            }
  334. +          
  335.            
  336. Index: /Gs folder/java/net/sf/l2j/gameserver/GameServer.java
  337. ===================================================================
  338. --- /Gs folder/java/net/sf/l2j/gameserver/GameServer.java (revision 1999)
  339. +++ /Gs folder/java/net/sf/l2j/gameserver/GameServer.java (revision 2031)
  340. @@ -24,7 +24,9 @@
  341.  
  342.  
  343.  
  344. OnlinePlayers.getInstance();
  345.  
  346.  
  347. + if(Config.PCB_ENABLE)
  348. + {
  349. + System.out.println("############PCB_ENABLE################");
  350. + ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(PcPoint.getInstance(), Config.PCB_INTERVAL * 1000, Config.PCB_INTERVAL * 1000);
  351. +
  352. }
  353.  
  354. Index: /Gs folder/java/net/sf/l2j/gameserver/ThreadPoolManager.java
  355. ===================================================================
  356. --- /Gs folder/java/net/sf/l2j/gameserver/ThreadPoolManager.java (revision 1999)
  357. +++ /Gs folder/java/net/sf/l2j/gameserver/ThreadPoolManager.java (revision 2031)
  358.  
  359. + /*
  360. +  * This program is free software: you can redistribute it and/or modify it under
  361. +  * the terms of the GNU General Public License as published by the Free Software
  362. +  * Foundation, either version 3 of the License, or (at your option) any later
  363. +  * version.
  364. +  *
  365. +  * This program is distributed in the hope that it will be useful, but WITHOUT
  366. +  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
  367. +  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
  368. +  * details.
  369. +  *
  370. +  * You should have received a copy of the GNU General Public License along with
  371. +  * this program. If not, see <http://www.gnu.org/licenses/>.
  372. +  */
  373. + package net.sf.l2j.gameserver;
  374. +
  375. + import java.lang.Thread.UncaughtExceptionHandler;
  376. + import java.util.concurrent.LinkedBlockingQueue;
  377. + import java.util.concurrent.RejectedExecutionException;
  378. + import java.util.concurrent.RunnableScheduledFuture;
  379. + import java.util.concurrent.ScheduledFuture;
  380. + import java.util.concurrent.ScheduledThreadPoolExecutor;
  381. + import java.util.concurrent.ThreadFactory;
  382. + import java.util.concurrent.ThreadPoolExecutor;
  383. + import java.util.concurrent.TimeUnit;
  384. + import java.util.concurrent.atomic.AtomicInteger;
  385. + import java.util.logging.Logger;
  386. +
  387. + import net.sf.l2j.commons.util.StringUtil;
  388. +
  389. + import net.sf.l2j.Config;
  390. +
  391. +
  392. + /**
  393. +  * <p>
  394. +  * This class is made to handle all the ThreadPools used in L2j.
  395. +  * </p>
  396. +  * <p>
  397. +  * Scheduled Tasks can either be sent to a {@link #_generalScheduledThreadPool "general"} or {@link #_effectsScheduledThreadPool "effects"} {@link ScheduledThreadPoolExecutor ScheduledThreadPool}: The "effects" one is used for every effects (skills, hp/mp regen ...) while the "general" one is used
  398. +  * for everything else that needs to be scheduled.<br>
  399. +  * There also is an {@link #_aiScheduledThreadPool "ai"} {@link ScheduledThreadPoolExecutor ScheduledThreadPool} used for AI Tasks.
  400. +  * </p>
  401. +  * <p>
  402. +  * Tasks can be sent to {@link ScheduledThreadPoolExecutor ScheduledThreadPool} either with:
  403. +  * <ul>
  404. +  * <li>{@link #scheduleEffect(Runnable, long)} : for effects Tasks that needs to be executed only once.</li>
  405. +  * <li>{@link #scheduleGeneral(Runnable, long)} : for scheduled Tasks that needs to be executed once.</li>
  406. +  * <li>{@link #scheduleAi(Runnable, long)} : for AI Tasks that needs to be executed once</li>
  407. +  * </ul>
  408. +  * or
  409. +  * <ul>
  410. +  * <li>{@link #scheduleEffectAtFixedRate(Runnable, long, long)} : for effects Tasks that needs to be executed periodicaly.</li>
  411. +  * <li>{@link #scheduleGeneralAtFixedRate(Runnable, long, long)} : for scheduled Tasks that needs to be executed periodicaly.</li>
  412. +  * <li>{@link #scheduleAiAtFixedRate(Runnable, long, long)} : for AI Tasks that needs to be executed periodicaly</li>
  413. +  * </ul>
  414. +  * </p>
  415. +  * <p>
  416. +  * For all Tasks that should be executed with no delay asynchronously in a ThreadPool there also are usual {@link ThreadPoolExecutor ThreadPools} that can grow/shrink according to their load.:
  417. +  * <ul>
  418. +  * <li>{@link #_generalPacketsThreadPool GeneralPackets} where most packets handler are executed.</li>
  419. +  * <li>
  420. +  * {@link #_ioPacketsThreadPool I/O Packets} where all the i/o packets are executed.</li>
  421. +  * <li>There will be an AI ThreadPool where AI events should be executed</li>
  422. +  * <li>A general ThreadPool where everything else that needs to run asynchronously with no delay should be executed ( {} updates, SQL updates/inserts...)?</li>
  423. +  * </ul>
  424. +  * </p>
  425. +  * @author -Wooden-
  426. +  */
  427. + public class ThreadPoolManager
  428. + {
  429. +   protected static final Logger _log = Logger.getLogger(ThreadPoolManager.class.getName());
  430. +  
  431. +   private static final class RunnableWrapper implements Runnable
  432. +   {
  433. +       private final Runnable _r;
  434. +      
  435. +       public RunnableWrapper(final Runnable r)
  436. +       {
  437. +           _r = r;
  438. +       }
  439. +      
  440. +       @Override
  441. +       public final void run()
  442. +       {
  443. +           try
  444. +           {
  445. +               _r.run();
  446. +           }
  447. +           catch (final Throwable e)
  448. +           {
  449. +               final Thread t = Thread.currentThread();
  450. +               final UncaughtExceptionHandler h = t.getUncaughtExceptionHandler();
  451. +               if (h != null)
  452. +                   h.uncaughtException(t, e);
  453. +           }
  454. +       }
  455. +   }
  456. +  
  457. +   protected ScheduledThreadPoolExecutor _effectsScheduledThreadPool;
  458. +   protected ScheduledThreadPoolExecutor _generalScheduledThreadPool;
  459. +   protected static ScheduledThreadPoolExecutor _aiScheduledThreadPool;
  460. +   private final ThreadPoolExecutor _generalPacketsThreadPool;
  461. +   private final ThreadPoolExecutor _ioPacketsThreadPool;
  462. +   private final ThreadPoolExecutor _generalThreadPool;
  463. +  
  464. +   /** temp workaround for VM issue */
  465. +   private static final long MAX_DELAY = Long.MAX_VALUE / 1000000 / 2;
  466. +  
  467. +   private boolean _shutdown;
  468. +  
  469. +   public static ThreadPoolManager getInstance()
  470. +   {
  471. +       return SingletonHolder._instance;
  472. +   }
  473. +  
  474. +   protected ThreadPoolManager()
  475. +   {
  476. +       _effectsScheduledThreadPool = new ScheduledThreadPoolExecutor(Config.THREAD_P_EFFECTS, new PriorityThreadFactory("EffectsSTPool", Thread.NORM_PRIORITY));
  477. +       _generalScheduledThreadPool = new ScheduledThreadPoolExecutor(Config.THREAD_P_GENERAL, new PriorityThreadFactory("GeneralSTPool", Thread.NORM_PRIORITY));
  478. +       _ioPacketsThreadPool = new ThreadPoolExecutor(Config.IO_PACKET_THREAD_CORE_SIZE, Integer.MAX_VALUE, 5L, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), new PriorityThreadFactory("I/O Packet Pool", Thread.NORM_PRIORITY + 1));
  479. +       _generalPacketsThreadPool = new ThreadPoolExecutor(Config.GENERAL_PACKET_THREAD_CORE_SIZE, Config.GENERAL_PACKET_THREAD_CORE_SIZE + 2, 15L, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), new PriorityThreadFactory("Normal Packet Pool", Thread.NORM_PRIORITY + 1));
  480. +       _generalThreadPool = new ThreadPoolExecutor(Config.GENERAL_THREAD_CORE_SIZE, Config.GENERAL_THREAD_CORE_SIZE + 2, 5L, TimeUnit.SECONDS, new LinkedBlockingQueue<Runnable>(), new PriorityThreadFactory("General Pool", Thread.NORM_PRIORITY));
  481. +       _aiScheduledThreadPool = new ScheduledThreadPoolExecutor(Config.AI_MAX_THREAD, new PriorityThreadFactory("AISTPool", Thread.NORM_PRIORITY));
  482. +      
  483. +       scheduleGeneralAtFixedRate(new PurgeTask(), 10 * 60 * 1000l, 5 * 60 * 1000l);
  484. +   }
  485. +  
  486. +   public static long validateDelay(long delay)
  487. +   {
  488. +       if (delay < 0)
  489. +           delay = 0;
  490. +       else if (delay > MAX_DELAY)
  491. +           delay = MAX_DELAY;
  492. +       return delay;
  493. +   }
  494. +  
  495. +   public ScheduledFuture<?> scheduleEffect(Runnable r, long delay)
  496. +   {
  497. +       try
  498. +       {
  499. +           delay = ThreadPoolManager.validateDelay(delay);
  500. +           return _effectsScheduledThreadPool.schedule(new RunnableWrapper(r), delay, TimeUnit.MILLISECONDS);
  501. +       }
  502. +       catch (RejectedExecutionException e)
  503. +       {
  504. +           return null;
  505. +       }
  506. +   }
  507. +  
  508. +   public ScheduledFuture<?> scheduleEffectAtFixedRate(Runnable r, long initial, long delay)
  509. +   {
  510. +       try
  511. +       {
  512. +           delay = ThreadPoolManager.validateDelay(delay);
  513. +           initial = ThreadPoolManager.validateDelay(initial);
  514. +           return _effectsScheduledThreadPool.scheduleAtFixedRate(new RunnableWrapper(r), initial, delay, TimeUnit.MILLISECONDS);
  515. +       }
  516. +       catch (RejectedExecutionException e)
  517. +       {
  518. +           return null; /* shutdown, ignore */
  519. +       }
  520. +   }
  521. +  
  522. +   @Deprecated
  523. +   public boolean removeEffect(RunnableScheduledFuture<?> r)
  524. +   {
  525. +       return _effectsScheduledThreadPool.remove(r);
  526. +   }
  527. +  
  528. +   public ScheduledFuture<?> scheduleGeneral(Runnable r, long delay)
  529. +   {
  530. +       try
  531. +       {
  532. +           delay = ThreadPoolManager.validateDelay(delay);
  533. +           return _generalScheduledThreadPool.schedule(new RunnableWrapper(r), delay, TimeUnit.MILLISECONDS);
  534. +       }
  535. +       catch (RejectedExecutionException e)
  536. +       {
  537. +           return null; /* shutdown, ignore */
  538. +       }
  539. +   }
  540. +  
  541. +   public ScheduledFuture<?> scheduleGeneralAtFixedRate(Runnable r, long initial, long delay)
  542. +   {
  543. +       try
  544. +       {
  545. +           delay = ThreadPoolManager.validateDelay(delay);
  546. +           initial = ThreadPoolManager.validateDelay(initial);
  547. +           return _generalScheduledThreadPool.scheduleAtFixedRate(new RunnableWrapper(r), initial, delay, TimeUnit.MILLISECONDS);
  548. +       }
  549. +       catch (RejectedExecutionException e)
  550. +       {
  551. +           return null; /* shutdown, ignore */
  552. +       }
  553. +   }
  554. +  
  555. +   @Deprecated
  556. +   public boolean removeGeneral(RunnableScheduledFuture<?> r)
  557. +   {
  558. +       return _generalScheduledThreadPool.remove(r);
  559. +   }
  560. +  
  561. +   public ScheduledFuture<?> scheduleAi(Runnable r, long delay)
  562. +   {
  563. +       try
  564. +       {
  565. +           delay = ThreadPoolManager.validateDelay(delay);
  566. +           return _aiScheduledThreadPool.schedule(new RunnableWrapper(r), delay, TimeUnit.MILLISECONDS);
  567. +       }
  568. +       catch (RejectedExecutionException e)
  569. +       {
  570. +           return null; /* shutdown, ignore */
  571. +       }
  572. +   }
  573. +  
  574. +   public static ScheduledFuture<?> scheduleAiAtFixedRate(Runnable r, long initial, long delay)
  575. +   {
  576. +       try
  577. +       {
  578. +           delay = ThreadPoolManager.validateDelay(delay);
  579. +           initial = ThreadPoolManager.validateDelay(initial);
  580. +           return _aiScheduledThreadPool.scheduleAtFixedRate(new RunnableWrapper(r), initial, delay, TimeUnit.MILLISECONDS);
  581. +       }
  582. +       catch (RejectedExecutionException e)
  583. +       {
  584. +           return null; /* shutdown, ignore */
  585. +       }
  586. +   }
  587. +  
  588. +   public void executePacket(Runnable pkt)
  589. +   {
  590. +       _generalPacketsThreadPool.execute(pkt);
  591. +   }
  592. +  
  593. +   public void executeCommunityPacket(Runnable r)
  594. +   {
  595. +       _generalPacketsThreadPool.execute(r);
  596. +   }
  597. +  
  598. +   public void executeIOPacket(Runnable pkt)
  599. +   {
  600. +       _ioPacketsThreadPool.execute(pkt);
  601. +   }
  602. +  
  603. +   public void executeTask(Runnable r)
  604. +   {
  605. +       _generalThreadPool.execute(r);
  606. +   }
  607. +  
  608. +   public static void executeAi(Runnable r)
  609. +   {
  610. +       _aiScheduledThreadPool.execute(new RunnableWrapper(r));
  611. +   }
  612. +  
  613. +   private static class PriorityThreadFactory implements ThreadFactory
  614. +   {
  615. +       private final int _prio;
  616. +       private final String _name;
  617. +       private final AtomicInteger _threadNumber = new AtomicInteger(1);
  618. +       private final ThreadGroup _group;
  619. +      
  620. +       public PriorityThreadFactory(String name, int prio)
  621. +       {
  622. +           _prio = prio;
  623. +           _name = name;
  624. +           _group = new ThreadGroup(_name);
  625. +       }
  626. +      
  627. +       @Override
  628. +       public Thread newThread(Runnable r)
  629. +       {
  630. +           Thread t = new Thread(_group, r);
  631. +           t.setName(_name + "-" + _threadNumber.getAndIncrement());
  632. +           t.setPriority(_prio);
  633. +           return t;
  634. +       }
  635. +      
  636. +       public ThreadGroup getGroup()
  637. +       {
  638. +           return _group;
  639. +       }
  640. +   }
  641. +  
  642. +   public void shutdown()
  643. +   {
  644. +       _shutdown = true;
  645. +      
  646. +       _effectsScheduledThreadPool.shutdown();
  647. +       _generalScheduledThreadPool.shutdown();
  648. +       _generalPacketsThreadPool.shutdown();
  649. +       _ioPacketsThreadPool.shutdown();
  650. +       _generalThreadPool.shutdown();
  651. +      
  652. +       _log.info("All ThreadPools are now stopped.");
  653. +   }
  654. +  
  655. +   public boolean isShutdown()
  656. +   {
  657. +       return _shutdown;
  658. +   }
  659. +  
  660. +   public void purge()
  661. +   {
  662. +       _effectsScheduledThreadPool.purge();
  663. +       _generalScheduledThreadPool.purge();
  664. +       _aiScheduledThreadPool.purge();
  665. +       _ioPacketsThreadPool.purge();
  666. +       _generalPacketsThreadPool.purge();
  667. +       _generalThreadPool.purge();
  668. +   }
  669. +  
  670. +   public String getPacketStats()
  671. +   {
  672. +       final StringBuilder sb = new StringBuilder(1000);
  673. +       ThreadFactory tf = _generalPacketsThreadPool.getThreadFactory();
  674. +       if (tf instanceof PriorityThreadFactory)
  675. +       {
  676. +           PriorityThreadFactory ptf = (PriorityThreadFactory) tf;
  677. +           int count = ptf.getGroup().activeCount();
  678. +           Thread[] threads = new Thread[count + 2];
  679. +           ptf.getGroup().enumerate(threads);
  680. +           StringUtil.append(sb, "General Packet Thread Pool:\r\n" + "Tasks in the queue: ", String.valueOf(_generalPacketsThreadPool.getQueue().size()), "\r\n" + "Showing threads stack trace:\r\n" + "There should be ", String.valueOf(count), " Threads\r\n");
  681. +           for (Thread t : threads)
  682. +           {
  683. +               if (t == null)
  684. +                   continue;
  685. +              
  686. +               StringUtil.append(sb, t.getName(), "\r\n");
  687. +               for (StackTraceElement ste : t.getStackTrace())
  688. +               {
  689. +                   StringUtil.append(sb, ste.toString(), "\r\n");
  690. +               }
  691. +           }
  692. +       }
  693. +      
  694. +       sb.append("Packet Tp stack traces printed.\r\n");
  695. +      
  696. +       return sb.toString();
  697. +   }
  698. +  
  699. +   public String getIOPacketStats()
  700. +   {
  701. +       final StringBuilder sb = new StringBuilder(1000);
  702. +       ThreadFactory tf = _ioPacketsThreadPool.getThreadFactory();
  703. +      
  704. +       if (tf instanceof PriorityThreadFactory)
  705. +       {
  706. +           PriorityThreadFactory ptf = (PriorityThreadFactory) tf;
  707. +           int count = ptf.getGroup().activeCount();
  708. +           Thread[] threads = new Thread[count + 2];
  709. +           ptf.getGroup().enumerate(threads);
  710. +           StringUtil.append(sb, "I/O Packet Thread Pool:\r\n" + "Tasks in the queue: ", String.valueOf(_ioPacketsThreadPool.getQueue().size()), "\r\n" + "Showing threads stack trace:\r\n" + "There should be ", String.valueOf(count), " Threads\r\n");
  711. +          
  712. +           for (Thread t : threads)
  713. +           {
  714. +               if (t == null)
  715. +                   continue;
  716. +              
  717. +               StringUtil.append(sb, t.getName(), "\r\n");
  718. +              
  719. +               for (StackTraceElement ste : t.getStackTrace())
  720. +               {
  721. +                   StringUtil.append(sb, ste.toString(), "\r\n");
  722. +               }
  723. +           }
  724. +       }
  725. +      
  726. +       sb.append("Packet Tp stack traces printed.\r\n");
  727. +      
  728. +       return sb.toString();
  729. +   }
  730. +  
  731. +   public String getGeneralStats()
  732. +   {
  733. +       final StringBuilder sb = new StringBuilder(1000);
  734. +       ThreadFactory tf = _generalThreadPool.getThreadFactory();
  735. +      
  736. +       if (tf instanceof PriorityThreadFactory)
  737. +       {
  738. +           PriorityThreadFactory ptf = (PriorityThreadFactory) tf;
  739. +           int count = ptf.getGroup().activeCount();
  740. +           Thread[] threads = new Thread[count + 2];
  741. +           ptf.getGroup().enumerate(threads);
  742. +           StringUtil.append(sb, "General Thread Pool:\r\n" + "Tasks in the queue: ", String.valueOf(_generalThreadPool.getQueue().size()), "\r\n" + "Showing threads stack trace:\r\n" + "There should be ", String.valueOf(count), " Threads\r\n");
  743. +          
  744. +           for (Thread t : threads)
  745. +           {
  746. +               if (t == null)
  747. +                   continue;
  748. +              
  749. +               StringUtil.append(sb, t.getName(), "\r\n");
  750. +              
  751. +               for (StackTraceElement ste : t.getStackTrace())
  752. +               {
  753. +                   StringUtil.append(sb, ste.toString(), "\r\n");
  754. +               }
  755. +           }
  756. +       }
  757. +      
  758. +       sb.append("Packet Tp stack traces printed.\r\n");
  759. +      
  760. +       return sb.toString();
  761. +   }
  762. +  
  763. +   protected class PurgeTask implements Runnable
  764. +   {
  765. +       @Override
  766. +       public void run()
  767. +       {
  768. +           _effectsScheduledThreadPool.purge();
  769. +           _generalScheduledThreadPool.purge();
  770. +           _aiScheduledThreadPool.purge();
  771. +       }
  772. +   }
  773. +  
  774. +   private static class SingletonHolder
  775. +   {
  776. +       protected static final ThreadPoolManager _instance = new ThreadPoolManager();
  777. +   }
  778. + }
  779.  
  780. Index: /Gs folder/java/config/Custom/pcBang.properties
  781. ===================================================================
  782. --- /Gs folder/java/config/Custom/pcBang.properties (revision 2031)
  783. +++ /Gs folder/java/config/Custom/pcBang.properties (revision 2031)
  784.  
  785.  
  786. Index: /Gs folder/java/gameserver/model/world.java
  787. ===================================================================
  788. --- /Gs folder/java/gameserver/model/world.java (revision 2031)
  789. +++ /Gs folder/java/gameserver/model/world.java (revision 2031)
  790.  
  791. +   /**
  792. +    * @return a collection containing all players in game.
  793. +    */
  794. +   public Map<Integer, Player> getAllPlayers()
  795. +   {
  796. +       return _players;
  797. +   }
  798.    
  799.    
  800. +#============================================================#
  801. +#                         PC Bang Point                     -#
  802. +#------------------------------------------------------------#
  803. +BangPointEnable = True
  804. +
  805. +cBangPointMinLevel = 76
  806. +
  807. +PcBangPointMinCount = 1
  808. +
  809. +PcBangPointMaxCount = 1
  810. +
  811. +PcBangPointDualChance = 1
  812. +
  813. +PcBangPointTimeStamp = 3600
  814. +
  815. +PCBCoinId = 65436
  816.  
  817. Na SQL characters
  818. Adicione na ultima linha
  819.  
  820. + pc_point` int(5) NOT NULL DEFAULT '0',
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement