Dropped player count manager.

This commit is contained in:
MobiusDevelopment
2020-03-31 00:35:39 +00:00
parent 755e00e30e
commit 38cb67fad2
112 changed files with 391 additions and 1769 deletions

View File

@@ -1,66 +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.managers;
/**
* @author Mobius
*/
public class PlayerCountManager
{
private static volatile int connectedCount = 0;
private static volatile int maxConnectedCount = 0;
protected PlayerCountManager()
{
}
public int getConnectedCount()
{
return connectedCount;
}
public int getMaxConnectedCount()
{
return maxConnectedCount;
}
public synchronized void incConnectedCount()
{
connectedCount++;
maxConnectedCount = Math.max(maxConnectedCount, connectedCount);
}
public void decConnectedCount()
{
connectedCount--;
}
public static PlayerCountManager getInstance()
{
return SingletonHolder.INSTANCE;
}
private static class SingletonHolder
{
protected static final PlayerCountManager INSTANCE = new PlayerCountManager();
}
public void setConnectedCount(int count)
{
connectedCount = count;
}
}

View File

@@ -23,7 +23,6 @@ import java.util.List;
import java.util.Map;
import java.util.concurrent.ConcurrentHashMap;
import org.l2jmobius.gameserver.managers.PlayerCountManager;
import org.l2jmobius.gameserver.model.actor.instance.ItemInstance;
import org.l2jmobius.gameserver.model.actor.instance.PetInstance;
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
@@ -88,7 +87,6 @@ public class World
}
element.addKnownObject(object);
}
PlayerCountManager.getInstance().incConnectedCount();
}
else if ((_allPlayers.size() != 0) && !(object instanceof PetInstance) && !(object instanceof ItemInstance))
{
@@ -123,10 +121,6 @@ public class World
if (object instanceof PlayerInstance)
{
_allPlayers.remove(((PlayerInstance) object).getName().toLowerCase());
// TODO: Make sure the normal way works.
// PlayerCountManager.getInstance().decConnectedCount();
PlayerCountManager.getInstance().setConnectedCount(_allPlayers.size());
}
}

View File

@@ -32,7 +32,6 @@ import javax.swing.border.LineBorder;
import org.l2jmobius.Config;
import org.l2jmobius.gameserver.GameServer;
import org.l2jmobius.gameserver.managers.PlayerCountManager;
import org.l2jmobius.gameserver.model.World;
import org.l2jmobius.util.Locator;
@@ -41,7 +40,10 @@ import org.l2jmobius.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()
{
@@ -117,8 +119,13 @@ public class SystemPanel extends JPanel
@Override
public void run()
{
lblConnected.setText("Connected: " + World.getInstance().getAllPlayers().size());
lblMaxConnected.setText("Max connected: " + PlayerCountManager.getInstance().getMaxConnectedCount());
final int playerCount = World.getInstance().getAllPlayers().size();
if (MAX_CONNECTED_COUNT < playerCount)
{
MAX_CONNECTED_COUNT = playerCount;
}
lblConnected.setText("Connected: " + playerCount);
lblMaxConnected.setText("Max connected: " + MAX_CONNECTED_COUNT);
lblElapsedTime.setText("Elapsed: " + getDurationBreakdown(System.currentTimeMillis() - START_TIME));
}
}, 1000, 1000);