U3Games

Games | Desarrollo & Soporte => L2 | Sección de Servidores => Lineage => L2 | Implementaciones => Mensaje iniciado por: Jerry en Ago 02, 2025, 07:38 PM

Título: Cafe Point - aCis
Publicado por: Jerry en Ago 02, 2025, 07:38 PM
Index: /Gs folder/java/l2jban/com/gameserver/PcPoint.java
===================================================================
--- /Gs folder/java/l2jban/com/gameserver/PcPoint.java (revision 2031)
+++ /Gs folder/java/l2jban/com/gameserver/pcbang.java (revision `2031)
@@ -0,0 +1,78 @@
+package l2jban.pcbang;
+
+import java.util.logging.Logger;
+
+import net.sf.l2j.commons.random.Rnd;
+
+import net.sf.l2j.Config;
+import net.sf.l2j.gameserver.model.World;
+import net.sf.l2j.gameserver.model.actor.Player;
+
+/**
+ * @author Juvenil Walker
+ *
+ */
+public class pcbang implements Runnable
+{
+ Logger _log = Logger.getLogger(pcbang.class.getName());
+ private static pcbang _instance;
+
+ public static pcbang getInstance()
+
+ {
+ if(_instance == null)
+ {
+ _instance = new pcbang();
+   }
+
+ return _instance;
+ }
+
+    private pcbang()
+       {
+          _log.info("PcBang point event started.");
+       }
+   
+    @Override
+    public void run()
+    {
+
+            int score = 0;
+            for (Player activeChar: World.getInstance().getAllPlayers().values())
+            {
+
+                    if(activeChar.getLevel() > Config.PCB_MIN_LEVEL )
+                    {
+                            score = Rnd.get(Config.PCB_POINT_MIN, Config.PCB_POINT_MAX);
+
+                            if(Rnd.get(100) <= Config.PCB_CHANCE_DUAL_POINT)
+                            {
+                                    score *= 2;
+
+                                    activeChar.addPcBangScore(score);
+                                   
+                                    activeChar.sendMessage("Your PC Bang Point had doubled 1 hour.");
+                                    activeChar.updatePcBangWnd(score, true, true);
+                            }
+                            else
+                            {
+           activeChar.addPcBangScore(score);
+           activeChar.sendMessage("You recevied PC Bang Point 1 hour.");
+           activeChar.updatePcBangWnd(score, true, false);
+                            }
+                    }
+
+                    activeChar = null;
+            }
+    }
+}

Index: /Gs folder/java/net/sf/l2j/Config.java
===================================================================
--- /Gs folder/java/net/sf/l2j/Config.java (revision 2028)
+++ /Gs folder/java/net/sf/l2j/Config.java (revision 2031)
@@ -1687,55 +1687,48 @@


+ public static final String PCBANGPOINT_FILE = "./config/PcBanG.properties";


+  //============================================================
+  public static boolean PCB_ENABLE;
+
+  public static int PCB_COIN_ID;

+  public static int PCB_MIN_LEVEL;
+  public static int PCB_POINT_MIN;
+  public static int PCB_POINT_MAX;
+  public static int PCB_CHANCE_DUAL_POINT;
+  public static int PCB_INTERVAL;
+ public static int THREAD_P_EFFECTS = 6; // default 6
+ public static int THREAD_P_GENERAL = 15; // default 15
+ public static int GENERAL_PACKET_THREAD_CORE_SIZE = 4; // default 4
+ public static int IO_PACKET_THREAD_CORE_SIZE = 2; // default 2
+ public static int GENERAL_THREAD_CORE_SIZE = 4; // default 4
+ public static int AI_MAX_THREAD = 10; // default 10
+   //============================================================

+  public static void loadPCBPointConfig()
+   {
+    final ExProperties PcBanG = initProperties(Config.PCBANGPOINT_FILE);
+   
+        PCB_ENABLE = Boolean.parseBoolean(PcBanG.getProperty("PcBangPointEnable", "true"));
+        PCB_MIN_LEVEL = Integer.parseInt(PcBanG.getProperty("PcBangPointMinLevel", "20"));
+        PCB_POINT_MIN = Integer.parseInt(PcBanG.getProperty("PcBangPointMinCount", "20"));
+        PCB_POINT_MAX = Integer.parseInt(PcBanG.getProperty("PcBangPointMaxCount", "1000000"));
+        PCB_COIN_ID = Integer.parseInt(PcBanG.getProperty("PCBCoinId", "0"));
+       
+
+        if(PCB_POINT_MAX < 1)
+      {
+        PCB_POINT_MAX = Integer.MAX_VALUE;
+       
+      }
+
+         PCB_CHANCE_DUAL_POINT = Integer.parseInt(PcBanG.getProperty("PcBangPointDualChance", "20"));
+         PCB_INTERVAL = Integer.parseInt(PcBanG.getProperty("PcBangPointTimeStamp", "900"));
+                   
+           }
+
+
+   
+   //============================================================


+loadPCBPointConfig();


Index: /Gs folder/java/net/sf/l2j/gameserver/clientpackets/MultiSellChoose.java
===================================================================
--- /Gs folder/java/net/sf/l2j/gameserver/clientpackets/MultiSellChoose.java (revision 107)
+++ /Gs folder/java/net/sf/l2j/gameserver/clientpackets/MultiSellChoose.java (revision 2031)
@@ -200,4 +200,9 @@

+ private static final int PC_BANG_POINTS = Config.PCB_COIN_ID;


{

if (player.getClan().getReputationScore() < e.getItemCount() * _amount)
{
player.sendPacket(SystemMessageId.THE_CLAN_REPUTATION_SCORE_IS_TOO_LOW);
return;
}
}

+ else if (e.getItemId() == PC_BANG_POINTS)
+ {
+ if (player.getPcBang() < (e.getItemCount() * _amount))
+ {
+ player.sendMessage("You don't have enough Territory War Points.");
+ return;
+ }
+ }

List<L2Augmentation> augmentation = new ArrayList<>();

for (Ingredient e : entry.getIngredients())
{
if (e.getItemId() == CLAN_REPUTATION)
{
final int amount = e.getItemCount() * _amount;

player.getClan().takeReputationScore(amount);
player.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.S1_DEDUCTED_FROM_CLAN_REP).addNumber(amount));
}

+ else if (e.getItemId() == PC_BANG_POINTS)
+ {
+ int totalTWPoints = e.getItemCount() * _amount;
+ player.setPcBang(player.getPcBang()-totalTWPoints);
+ }

// Generate the appropriate items
for (Ingredient e : entry.getProducts())
{
if (e.getItemId() == CLAN_REPUTATION)
player.getClan().addReputationScore(e.getItemCount() * _amount);

+
+ else if (e.getItemId() == PC_BANG_POINTS)
+ player.setPcBang(player.getPcBang()+(e.getItemCount()*_amount));
+
}
Index: /Gs folder/java/net/sf/l2j/gameserver/clientpackets/EnterWorld.java
===================================================================
--- /Gs folder/java/net/sf/l2j/gameserver/clientpackets/EnterWorld.java (revision 1726)
+++ /Gs folder/java/net/sf/l2j/gameserver/clientpackets/EnterWorld.java (revision 2031)

activeChar.onPlayerEnter();


+ if(Config.PCB_ENABLE)
+ {
+ activeChar.showPcBangWindow();
+ }


Index: /Gs folder/java/net/sf/l2j/gameserver/network/serverpackets/ExPCCafePointInfo.java
===================================================================
--- /Gs folder/java/net/sf/l2j/gameserver/network/serverpackets/ExPCCafePointInfo.java (revision 7)
+++ /Gs folder/java/net/sf/l2j/gameserver/network/serverpackets/ExPCCafePointInfo.java (revision 2031)
@@ -15,4 +15,6 @@
+package net.sf.l2j.gameserver.network.serverpackets;
+
+import net.sf.l2j.gameserver.model.actor.Player;
+
+public class ExPCCafePointInfo extends L2GameServerPacket
+{
+ private Player _character;
+ private int m_AddPoint;
+ private int m_PeriodType;
+ private int RemainTime;
+ private int PointType;
+
+ public ExPCCafePointInfo(Player user, int modify, boolean add, int hour, boolean _double)
+ {
+ _character = user;
+ m_AddPoint = modify;
+
+     if (add)
+ {
+       m_PeriodType = 1;
+       PointType = 1;
+ }
+ else
+ {
+       if (add && _double)
+       {
+               m_PeriodType = 1;
+               PointType = 0;
+       }
+       else
+       {
+               m_PeriodType = 2;
+               PointType = 2;
+       }
+ }
+
+ RemainTime = hour;
+
+ }
+
+ @Override
+ protected void writeImpl()
+ {
+ writeC(0xFE);
+ writeH(0x31);
+ writeD(_character.getPcBangScore());
+ writeD(m_AddPoint);
+ writeC(m_PeriodType);
+ writeD(RemainTime);
+ writeC(PointType);
+ }
+}

Index: /Gs folder/java/net/sf/l2j/gameserver/model/actor/Player.java
===================================================================
--- /Gs folder/java/net/sf/l2j/gameserver/model/actor/Player.java (revision 2029)
+++ /Gs folder/java/net/sf/l2j/gameserver/model/actor/Player.java (revision 2031)
@@ -93,5 +93,4 @@

+ 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=?";
+ 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=?";

No final da Linha esta adicionado pc_point


- PreparedStatement ps = con.prepareStatement(UPDATE_CHARACTER))
+ PreparedStatement ps = con.prepareStatement(UPDATE_CHARACTER))

- ps.setLong(46, getDeathPenaltyBuffLevel());
+ ps.setLong(46, getDeathPenaltyBuffLevel());
+ ps.setInt(47, getPcBangScore());
+ ps.execute();
+ ps.close()

- PreparedStatement ps = con.prepareStatement(RESTORE_CHARACTER))
+ PreparedStatement ps = con.prepareStatement(RESTORE_CHARACTER))

- player.setDeathPenaltyBuffLevel(rs.getInt("death_penalty_level"));
+ player.setDeathPenaltyBuffLevel(rs.getInt("death_penalty_level"));

+ player.setPcBang(rs.getInt("pc_point"));

+ private int pcBangPoint = 0;
+
+
+     public int getPcBang()
+ {
+ return pcBangPoint;
+ }
+    
+ public void setPcBang(int val)
+ {
+ pcBangPoint = val;
+
+ ExPCCafePointInfo wnd = new ExPCCafePointInfo(this, 0, false, 24, false);
+                sendPacket(wnd);
+ }
+        
+
+            public int getPcBangScore()
+            {
+                    return pcBangPoint;
+            }
+
+            public void reducePcBangScore(int to)
+            {
+                    pcBangPoint -= to;
+                    updatePcBangWnd(to, false, false);
+            }
+
+            public void addPcBangScore(int to)
+            {
+                    pcBangPoint += to;
+            }
+
+            public void updatePcBangWnd(int score, boolean add, boolean duble)
+            {
+                    ExPCCafePointInfo wnd = new ExPCCafePointInfo(this, score, add, 24, duble);
+                    sendPacket(wnd);
+            }
+
+            public void showPcBangWindow()
+            {
+                    ExPCCafePointInfo wnd = new ExPCCafePointInfo(this, 0, false, 24, false);
+                    sendPacket(wnd);
+            }
+

Index: /Gs folder/java/net/sf/l2j/gameserver/GameServer.java
===================================================================
--- /Gs folder/java/net/sf/l2j/gameserver/GameServer.java (revision 1999)
+++ /Gs folder/java/net/sf/l2j/gameserver/GameServer.java (revision 2031)
@@ -24,7 +24,9 @@



OnlinePlayers.getInstance();


+ if(Config.PCB_ENABLE)
+ {
+ System.out.println("############PCB_ENABLE################");
+ ThreadPoolManager.getInstance().scheduleGeneralAtFixedRate(PcPoint.getInstance(), Config.PCB_INTERVAL * 1000, Config.PCB_INTERVAL * 1000);
+
}

Index: /Gs folder/java/net/sf/l2j/gameserver/ThreadPoolManager.java
===================================================================
--- /Gs folder/java/net/sf/l2j/gameserver/ThreadPoolManager.java (revision 1999)
+++ /Gs folder/java/net/sf/l2j/gameserver/ThreadPoolManager.java (revision 2031)

+ /*
+  * This program is free software: you can redistribute it and/or modify it under
+  * the terms of the GNU General Public License as published by the Free Software
+  * Foundation, either version 3 of the License, or (at your option) any later
+  * version.
+  *
+  * This program is distributed in the hope that it will be useful, but WITHOUT
+  * ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS
+  * FOR A PARTICULAR PURPOSE. See the GNU General Public License for more
+  * details.
+  *
+  * You should have received a copy of the GNU General Public License along with
+  * this program. If not, see <http://www.gnu.org/licenses/>.
+  */
+ package net.sf.l2j.gameserver;
+
+ import java.lang.Thread.UncaughtExceptionHandler;
+ import java.util.concurrent.LinkedBlockingQueue;
+ import java.util.concurrent.RejectedExecutionException;
+ import java.util.concurrent.RunnableScheduledFuture;
+ import java.util.concurrent.ScheduledFuture;
+ import java.util.concurrent.ScheduledThreadPoolExecutor;
+ import java.util.concurrent.ThreadFactory;
+ import java.util.concurrent.ThreadPoolExecutor;
+ import java.util.concurrent.TimeUnit;
+ import java.util.concurrent.atomic.AtomicInteger;
+ import java.util.logging.Logger;
+
+ import net.sf.l2j.commons.util.StringUtil;
+
+ import net.sf.l2j.Config;
+
+
+ /**
+  * <p>
+  * This class is made to handle all the ThreadPools used in L2j.
+  * </p>
+  * <p>
+  * 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
+  * for everything else that needs to be scheduled.<br>
+  * There also is an {@link #_aiScheduledThreadPool "ai"} {@link ScheduledThreadPoolExecutor ScheduledThreadPool} used for AI Tasks.
+  * </p>
+  * <p>
+  * Tasks can be sent to {@link ScheduledThreadPoolExecutor ScheduledThreadPool} either with:
+  * <ul>
+  * <li>{@link #scheduleEffect(Runnable, long)} : for effects Tasks that needs to be executed only once.</li>
+  * <li>{@link #scheduleGeneral(Runnable, long)} : for scheduled Tasks that needs to be executed once.</li>
+  * <li>{@link #scheduleAi(Runnable, long)} : for AI Tasks that needs to be executed once</li>
+  * </ul>
+  * or
+  * <ul>
+  * <li>{@link #scheduleEffectAtFixedRate(Runnable, long, long)} : for effects Tasks that needs to be executed periodicaly.</li>
+  * <li>{@link #scheduleGeneralAtFixedRate(Runnable, long, long)} : for scheduled Tasks that needs to be executed periodicaly.</li>
+  * <li>{@link #scheduleAiAtFixedRate(Runnable, long, long)} : for AI Tasks that needs to be executed periodicaly</li>
+  * </ul>
+  * </p>
+  * <p>
+  * 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.:
+  * <ul>
+  * <li>{@link #_generalPacketsThreadPool GeneralPackets} where most packets handler are executed.</li>
+  * <li>
+  * {@link #_ioPacketsThreadPool I/O Packets} where all the i/o packets are executed.</li>
+  * <li>There will be an AI ThreadPool where AI events should be executed</li>
+  * <li>A general ThreadPool where everything else that needs to run asynchronously with no delay should be executed ( {} updates, SQL updates/inserts...)?</li>
+  * </ul>
+  * </p>
+  * @author -Wooden-
+  */
+ public class ThreadPoolManager
+ {
+ protected static final Logger _log = Logger.getLogger(ThreadPoolManager.class.getName());
+
+ private static final class RunnableWrapper implements Runnable
+ {
+ private final Runnable _r;
+
+ public RunnableWrapper(final Runnable r)
+ {
+ _r = r;
+ }
+
+ @Override
+ public final void run()
+ {
+ try
+ {
+ _r.run();
+ }
+ catch (final Throwable e)
+ {
+ final Thread t = Thread.currentThread();
+ final UncaughtExceptionHandler h = t.getUncaughtExceptionHandler();
+ if (h != null)
+ h.uncaughtException(t, e);
+ }
+ }
+ }
+
+ protected ScheduledThreadPoolExecutor _effectsScheduledThreadPool;
+ protected ScheduledThreadPoolExecutor _generalScheduledThreadPool;
+ protected static ScheduledThreadPoolExecutor _aiScheduledThreadPool;
+ private final ThreadPoolExecutor _generalPacketsThreadPool;
+ private final ThreadPoolExecutor _ioPacketsThreadPool;
+ private final ThreadPoolExecutor _generalThreadPool;
+
+ /** temp workaround for VM issue */
+ private static final long MAX_DELAY = Long.MAX_VALUE / 1000000 / 2;
+
+ private boolean _shutdown;
+
+ public static ThreadPoolManager getInstance()
+ {
+ return SingletonHolder._instance;
+ }
+
+ protected ThreadPoolManager()
+ {
+ _effectsScheduledThreadPool = new ScheduledThreadPoolExecutor(Config.THREAD_P_EFFECTS, new PriorityThreadFactory("EffectsSTPool", Thread.NORM_PRIORITY));
+ _generalScheduledThreadPool = new ScheduledThreadPoolExecutor(Config.THREAD_P_GENERAL, new PriorityThreadFactory("GeneralSTPool", Thread.NORM_PRIORITY));
+ _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));
+ _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));
+ _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));
+ _aiScheduledThreadPool = new ScheduledThreadPoolExecutor(Config.AI_MAX_THREAD, new PriorityThreadFactory("AISTPool", Thread.NORM_PRIORITY));
+
+ scheduleGeneralAtFixedRate(new PurgeTask(), 10 * 60 * 1000l, 5 * 60 * 1000l);
+ }
+
+ public static long validateDelay(long delay)
+ {
+ if (delay < 0)
+ delay = 0;
+ else if (delay > MAX_DELAY)
+ delay = MAX_DELAY;
+ return delay;
+ }
+
+ public ScheduledFuture<?> scheduleEffect(Runnable r, long delay)
+ {
+ try
+ {
+ delay = ThreadPoolManager.validateDelay(delay);
+ return _effectsScheduledThreadPool.schedule(new RunnableWrapper(r), delay, TimeUnit.MILLISECONDS);
+ }
+ catch (RejectedExecutionException e)
+ {
+ return null;
+ }
+ }
+
+ public ScheduledFuture<?> scheduleEffectAtFixedRate(Runnable r, long initial, long delay)
+ {
+ try
+ {
+ delay = ThreadPoolManager.validateDelay(delay);
+ initial = ThreadPoolManager.validateDelay(initial);
+ return _effectsScheduledThreadPool.scheduleAtFixedRate(new RunnableWrapper(r), initial, delay, TimeUnit.MILLISECONDS);
+ }
+ catch (RejectedExecutionException e)
+ {
+ return null; /* shutdown, ignore */
+ }
+ }
+
+ @Deprecated
+ public boolean removeEffect(RunnableScheduledFuture<?> r)
+ {
+ return _effectsScheduledThreadPool.remove(r);
+ }
+
+ public ScheduledFuture<?> scheduleGeneral(Runnable r, long delay)
+ {
+ try
+ {
+ delay = ThreadPoolManager.validateDelay(delay);
+ return _generalScheduledThreadPool.schedule(new RunnableWrapper(r), delay, TimeUnit.MILLISECONDS);
+ }
+ catch (RejectedExecutionException e)
+ {
+ return null; /* shutdown, ignore */
+ }
+ }
+
+ public ScheduledFuture<?> scheduleGeneralAtFixedRate(Runnable r, long initial, long delay)
+ {
+ try
+ {
+ delay = ThreadPoolManager.validateDelay(delay);
+ initial = ThreadPoolManager.validateDelay(initial);
+ return _generalScheduledThreadPool.scheduleAtFixedRate(new RunnableWrapper(r), initial, delay, TimeUnit.MILLISECONDS);
+ }
+ catch (RejectedExecutionException e)
+ {
+ return null; /* shutdown, ignore */
+ }
+ }
+
+ @Deprecated
+ public boolean removeGeneral(RunnableScheduledFuture<?> r)
+ {
+ return _generalScheduledThreadPool.remove(r);
+ }
+
+ public ScheduledFuture<?> scheduleAi(Runnable r, long delay)
+ {
+ try
+ {
+ delay = ThreadPoolManager.validateDelay(delay);
+ return _aiScheduledThreadPool.schedule(new RunnableWrapper(r), delay, TimeUnit.MILLISECONDS);
+ }
+ catch (RejectedExecutionException e)
+ {
+ return null; /* shutdown, ignore */
+ }
+ }
+
+ public static ScheduledFuture<?> scheduleAiAtFixedRate(Runnable r, long initial, long delay)
+ {
+ try
+ {
+ delay = ThreadPoolManager.validateDelay(delay);
+ initial = ThreadPoolManager.validateDelay(initial);
+ return _aiScheduledThreadPool.scheduleAtFixedRate(new RunnableWrapper(r), initial, delay, TimeUnit.MILLISECONDS);
+ }
+ catch (RejectedExecutionException e)
+ {
+ return null; /* shutdown, ignore */
+ }
+ }
+
+ public void executePacket(Runnable pkt)
+ {
+ _generalPacketsThreadPool.execute(pkt);
+ }
+
+ public void executeCommunityPacket(Runnable r)
+ {
+ _generalPacketsThreadPool.execute(r);
+ }
+
+ public void executeIOPacket(Runnable pkt)
+ {
+ _ioPacketsThreadPool.execute(pkt);
+ }
+
+ public void executeTask(Runnable r)
+ {
+ _generalThreadPool.execute(r);
+ }
+
+ public static void executeAi(Runnable r)
+ {
+ _aiScheduledThreadPool.execute(new RunnableWrapper(r));
+ }
+
+ private static class PriorityThreadFactory implements ThreadFactory
+ {
+ private final int _prio;
+ private final String _name;
+ private final AtomicInteger _threadNumber = new AtomicInteger(1);
+ private final ThreadGroup _group;
+
+ public PriorityThreadFactory(String name, int prio)
+ {
+ _prio = prio;
+ _name = name;
+ _group = new ThreadGroup(_name);
+ }
+
+ @Override
+ public Thread newThread(Runnable r)
+ {
+ Thread t = new Thread(_group, r);
+ t.setName(_name + "-" + _threadNumber.getAndIncrement());
+ t.setPriority(_prio);
+ return t;
+ }
+
+ public ThreadGroup getGroup()
+ {
+ return _group;
+ }
+ }
+
+ public void shutdown()
+ {
+ _shutdown = true;
+
+ _effectsScheduledThreadPool.shutdown();
+ _generalScheduledThreadPool.shutdown();
+ _generalPacketsThreadPool.shutdown();
+ _ioPacketsThreadPool.shutdown();
+ _generalThreadPool.shutdown();
+
+ _log.info("All ThreadPools are now stopped.");
+ }
+
+ public boolean isShutdown()
+ {
+ return _shutdown;
+ }
+
+ public void purge()
+ {
+ _effectsScheduledThreadPool.purge();
+ _generalScheduledThreadPool.purge();
+ _aiScheduledThreadPool.purge();
+ _ioPacketsThreadPool.purge();
+ _generalPacketsThreadPool.purge();
+ _generalThreadPool.purge();
+ }
+
+ public String getPacketStats()
+ {
+ final StringBuilder sb = new StringBuilder(1000);
+ ThreadFactory tf = _generalPacketsThreadPool.getThreadFactory();
+ if (tf instanceof PriorityThreadFactory)
+ {
+ PriorityThreadFactory ptf = (PriorityThreadFactory) tf;
+ int count = ptf.getGroup().activeCount();
+ Thread[] threads = new Thread[count + 2];
+ ptf.getGroup().enumerate(threads);
+ 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");
+ for (Thread t : threads)
+ {
+ if (t == null)
+ continue;
+
+ StringUtil.append(sb, t.getName(), "\r\n");
+ for (StackTraceElement ste : t.getStackTrace())
+ {
+ StringUtil.append(sb, ste.toString(), "\r\n");
+ }
+ }
+ }
+
+ sb.append("Packet Tp stack traces printed.\r\n");
+
+ return sb.toString();
+ }
+
+ public String getIOPacketStats()
+ {
+ final StringBuilder sb = new StringBuilder(1000);
+ ThreadFactory tf = _ioPacketsThreadPool.getThreadFactory();
+
+ if (tf instanceof PriorityThreadFactory)
+ {
+ PriorityThreadFactory ptf = (PriorityThreadFactory) tf;
+ int count = ptf.getGroup().activeCount();
+ Thread[] threads = new Thread[count + 2];
+ ptf.getGroup().enumerate(threads);
+ 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");
+
+ for (Thread t : threads)
+ {
+ if (t == null)
+ continue;
+
+ StringUtil.append(sb, t.getName(), "\r\n");
+
+ for (StackTraceElement ste : t.getStackTrace())
+ {
+ StringUtil.append(sb, ste.toString(), "\r\n");
+ }
+ }
+ }
+
+ sb.append("Packet Tp stack traces printed.\r\n");
+
+ return sb.toString();
+ }
+
+ public String getGeneralStats()
+ {
+ final StringBuilder sb = new StringBuilder(1000);
+ ThreadFactory tf = _generalThreadPool.getThreadFactory();
+
+ if (tf instanceof PriorityThreadFactory)
+ {
+ PriorityThreadFactory ptf = (PriorityThreadFactory) tf;
+ int count = ptf.getGroup().activeCount();
+ Thread[] threads = new Thread[count + 2];
+ ptf.getGroup().enumerate(threads);
+ 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");
+
+ for (Thread t : threads)
+ {
+ if (t == null)
+ continue;
+
+ StringUtil.append(sb, t.getName(), "\r\n");
+
+ for (StackTraceElement ste : t.getStackTrace())
+ {
+ StringUtil.append(sb, ste.toString(), "\r\n");
+ }
+ }
+ }
+
+ sb.append("Packet Tp stack traces printed.\r\n");
+
+ return sb.toString();
+ }
+
+ protected class PurgeTask implements Runnable
+ {
+ @Override
+ public void run()
+ {
+ _effectsScheduledThreadPool.purge();
+ _generalScheduledThreadPool.purge();
+ _aiScheduledThreadPool.purge();
+ }
+ }
+
+ private static class SingletonHolder
+ {
+ protected static final ThreadPoolManager _instance = new ThreadPoolManager();
+ }
+ }

Index: /Gs folder/java/config/Custom/pcBang.properties
===================================================================
--- /Gs folder/java/config/Custom/pcBang.properties (revision 2031)
+++ /Gs folder/java/config/Custom/pcBang.properties (revision 2031)


Index: /Gs folder/java/gameserver/model/world.java
===================================================================
--- /Gs folder/java/gameserver/model/world.java (revision 2031)
+++ /Gs folder/java/gameserver/model/world.java (revision 2031)

+ /**
+ * @return a collection containing all players in game.
+ */
+ public Map<Integer, Player> getAllPlayers()
+ {
+ return _players;
+ }


+#============================================================#
+#                         PC Bang Point                     -#
+#------------------------------------------------------------#
+BangPointEnable = True
+
+cBangPointMinLevel = 76
+
+PcBangPointMinCount = 1
+
+PcBangPointMaxCount = 1
+
+PcBangPointDualChance = 1
+
+PcBangPointTimeStamp = 3600
+
+PCBCoinId = 65436

Na SQL characters
Adicione na ultima linha

+ pc_point` int(5) NOT NULL DEFAULT '0',