Dropped player count manager.
This commit is contained in:
@ -27,7 +27,6 @@ import java.util.logging.Logger;
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.database.DatabaseFactory;
|
||||
import org.l2jmobius.gameserver.enums.PrivateStoreType;
|
||||
import org.l2jmobius.gameserver.instancemanager.PlayerCountManager;
|
||||
import org.l2jmobius.gameserver.model.ManufactureItem;
|
||||
import org.l2jmobius.gameserver.model.TradeItem;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
@ -35,6 +34,7 @@ import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.holders.SellBuffHolder;
|
||||
import org.l2jmobius.gameserver.network.Disconnection;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.ui.SystemPanel;
|
||||
|
||||
public class OfflineTraderTable
|
||||
{
|
||||
@ -294,7 +294,6 @@ public class OfflineTraderTable
|
||||
player.setOnlineStatus(true, true);
|
||||
player.restoreEffects();
|
||||
player.broadcastUserInfo();
|
||||
PlayerCountManager.getInstance().incOfflineTradeCount();
|
||||
nTraders++;
|
||||
}
|
||||
catch (Exception e)
|
||||
@ -307,7 +306,9 @@ public class OfflineTraderTable
|
||||
}
|
||||
}
|
||||
|
||||
SystemPanel.OFFLINE_TRADE_COUNT = nTraders;
|
||||
LOGGER.info(getClass().getSimpleName() + ": Loaded " + nTraders + " offline traders.");
|
||||
|
||||
if (!Config.STORE_OFFLINE_TRADE_IN_REALTIME)
|
||||
{
|
||||
try (Statement stm1 = con.createStatement())
|
||||
@ -446,7 +447,7 @@ public class OfflineTraderTable
|
||||
|
||||
public static synchronized void removeTrader(int traderObjId)
|
||||
{
|
||||
PlayerCountManager.getInstance().decOfflineTradeCount();
|
||||
SystemPanel.OFFLINE_TRADE_COUNT--;
|
||||
|
||||
try (Connection con = DatabaseFactory.getConnection();
|
||||
PreparedStatement stm1 = con.prepareStatement(CLEAR_OFFLINE_TABLE_ITEMS_PLAYER);
|
||||
|
@ -1,77 +0,0 @@
|
||||
/*
|
||||
* This file is part of the L2J Mobius project.
|
||||
*
|
||||
* 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 org.l2jmobius.gameserver.instancemanager;
|
||||
|
||||
/**
|
||||
* @author Mobius
|
||||
*/
|
||||
public class PlayerCountManager
|
||||
{
|
||||
private static volatile int connectedCount = 0;
|
||||
private static volatile int maxConnectedCount = 0;
|
||||
private static volatile int offlineTradeCount = 0;
|
||||
|
||||
protected PlayerCountManager()
|
||||
{
|
||||
}
|
||||
|
||||
public int getConnectedCount()
|
||||
{
|
||||
return connectedCount;
|
||||
}
|
||||
|
||||
public int getMaxConnectedCount()
|
||||
{
|
||||
return maxConnectedCount;
|
||||
}
|
||||
|
||||
public int getOfflineTradeCount()
|
||||
{
|
||||
return offlineTradeCount;
|
||||
}
|
||||
|
||||
public synchronized void incConnectedCount()
|
||||
{
|
||||
connectedCount++;
|
||||
maxConnectedCount = Math.max(maxConnectedCount, connectedCount);
|
||||
}
|
||||
|
||||
public void decConnectedCount()
|
||||
{
|
||||
connectedCount--;
|
||||
}
|
||||
|
||||
public void incOfflineTradeCount()
|
||||
{
|
||||
offlineTradeCount++;
|
||||
}
|
||||
|
||||
public synchronized void decOfflineTradeCount()
|
||||
{
|
||||
offlineTradeCount = Math.max(0, offlineTradeCount - 1);
|
||||
}
|
||||
|
||||
public static PlayerCountManager getInstance()
|
||||
{
|
||||
return SingletonHolder.INSTANCE;
|
||||
}
|
||||
|
||||
private static class SingletonHolder
|
||||
{
|
||||
protected static final PlayerCountManager INSTANCE = new PlayerCountManager();
|
||||
}
|
||||
}
|
@ -32,7 +32,6 @@ import org.l2jmobius.gameserver.ai.CreatureAI;
|
||||
import org.l2jmobius.gameserver.ai.CtrlEvent;
|
||||
import org.l2jmobius.gameserver.ai.CtrlIntention;
|
||||
import org.l2jmobius.gameserver.data.sql.impl.CharNameTable;
|
||||
import org.l2jmobius.gameserver.instancemanager.PlayerCountManager;
|
||||
import org.l2jmobius.gameserver.model.actor.Creature;
|
||||
import org.l2jmobius.gameserver.model.actor.Npc;
|
||||
import org.l2jmobius.gameserver.model.actor.Summon;
|
||||
@ -149,8 +148,6 @@ public class World
|
||||
|
||||
if (object.isPlayer())
|
||||
{
|
||||
PlayerCountManager.getInstance().incConnectedCount();
|
||||
|
||||
final PlayerInstance newPlayer = (PlayerInstance) object;
|
||||
if (newPlayer.isTeleporting()) // TODO: Drop when we stop removing player from the world while teleporting.
|
||||
{
|
||||
@ -187,8 +184,6 @@ public class World
|
||||
_allObjects.remove(object.getObjectId());
|
||||
if (object.isPlayer())
|
||||
{
|
||||
PlayerCountManager.getInstance().decConnectedCount();
|
||||
|
||||
final PlayerInstance player = (PlayerInstance) object;
|
||||
if (player.isTeleporting()) // TODO: Drop when we stop removing player from the world while teleporting.
|
||||
{
|
||||
|
@ -31,7 +31,7 @@ import javax.swing.border.LineBorder;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.gameserver.GameServer;
|
||||
import org.l2jmobius.gameserver.instancemanager.PlayerCountManager;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.util.Locator;
|
||||
|
||||
/**
|
||||
@ -39,7 +39,10 @@ import org.l2jmobius.gameserver.util.Locator;
|
||||
*/
|
||||
public class SystemPanel extends JPanel
|
||||
{
|
||||
static final long START_TIME = System.currentTimeMillis();
|
||||
private static final long START_TIME = System.currentTimeMillis();
|
||||
|
||||
public static volatile int MAX_CONNECTED_COUNT = 0;
|
||||
public static volatile int OFFLINE_TRADE_COUNT = 0;
|
||||
|
||||
public SystemPanel()
|
||||
{
|
||||
@ -121,9 +124,14 @@ public class SystemPanel extends JPanel
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
lblConnected.setText("Connected: " + PlayerCountManager.getInstance().getConnectedCount());
|
||||
lblMaxConnected.setText("Max connected: " + PlayerCountManager.getInstance().getMaxConnectedCount());
|
||||
lblOfflineShops.setText("Offline trade: " + PlayerCountManager.getInstance().getOfflineTradeCount());
|
||||
final int playerCount = World.getInstance().getPlayers().size();
|
||||
if (MAX_CONNECTED_COUNT < playerCount)
|
||||
{
|
||||
MAX_CONNECTED_COUNT = playerCount;
|
||||
}
|
||||
lblConnected.setText("Connected: " + playerCount);
|
||||
lblMaxConnected.setText("Max connected: " + MAX_CONNECTED_COUNT);
|
||||
lblOfflineShops.setText("Offline trade: " + OFFLINE_TRADE_COUNT);
|
||||
lblElapsedTime.setText("Elapsed: " + getDurationBreakdown(System.currentTimeMillis() - START_TIME));
|
||||
}
|
||||
}, 1000, 1000);
|
||||
|
@ -20,12 +20,12 @@ import java.util.logging.Logger;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.gameserver.data.sql.impl.OfflineTraderTable;
|
||||
import org.l2jmobius.gameserver.instancemanager.PlayerCountManager;
|
||||
import org.l2jmobius.gameserver.model.actor.Summon;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.model.olympiad.OlympiadManager;
|
||||
import org.l2jmobius.gameserver.model.zone.ZoneId;
|
||||
import org.l2jmobius.gameserver.network.GameClient;
|
||||
import org.l2jmobius.gameserver.ui.SystemPanel;
|
||||
|
||||
/**
|
||||
* @author lord_rex
|
||||
@ -100,7 +100,7 @@ public class OfflineTradeUtil
|
||||
return false;
|
||||
}
|
||||
|
||||
PlayerCountManager.getInstance().incOfflineTradeCount();
|
||||
SystemPanel.OFFLINE_TRADE_COUNT++;
|
||||
|
||||
final GameClient client = player.getClient();
|
||||
client.close(true);
|
||||
|
Reference in New Issue
Block a user