Admin server info improvements and minor font tag corrections.
Thanks to Trance.
This commit is contained in:
@@ -372,6 +372,9 @@
|
||||
<!-- Section: Script -->
|
||||
<admin command="admin_load_script" accessLevel="90" />
|
||||
|
||||
<!-- Section: Server Info -->
|
||||
<admin command="admin_serverinfo" accessLevel="90" />
|
||||
|
||||
<!-- Section: Shop --> <!-- Must be modified the Trade option. -->
|
||||
<admin command="admin_buy" accessLevel="80" />
|
||||
<admin command="admin_gmshop" accessLevel="80" />
|
||||
|
||||
@@ -45,7 +45,7 @@
|
||||
</table>
|
||||
<font color="aadd77">Maintenance</font>
|
||||
<table width=240><tr>
|
||||
<td><button value="Stats" action="bypass -h admin_stats" width=80 height=15 back="sek.cbui94" fore="sek.cbui92"></td>
|
||||
<td><button value="Server Info" action="bypass -h admin_serverinfo" width=80 height=15 back="sek.cbui94" fore="sek.cbui92"></td>
|
||||
<td><button value="Login" action="bypass -h admin_server_login" width=80 height=15 back="sek.cbui94" fore="sek.cbui92"></td>
|
||||
<td><button value="Shutdown" action="bypass -h admin_server_shutdown" width=80 height=15 back="sek.cbui94" fore="sek.cbui92"></td>
|
||||
<td></td>
|
||||
|
||||
129
L2J_Mobius_C6_Interlude/dist/game/data/html/admin/serverinfo.htm
vendored
Normal file
129
L2J_Mobius_C6_Interlude/dist/game/data/html/admin/serverinfo.htm
vendored
Normal file
@@ -0,0 +1,129 @@
|
||||
<html>
|
||||
<title>Admin Server Info</title>
|
||||
<body>
|
||||
<center>
|
||||
<table width=270>
|
||||
<tr>
|
||||
<td width=40><button value="Main" action="bypass admin_admin" width=40 height=15 back="sek.cbui94" fore="sek.cbui92"></td>
|
||||
<td width=180>
|
||||
<center>Server Info</center>
|
||||
</td>
|
||||
<td width=40><button value="Back" action="bypass admin_admin4" width=40 height=15 back="sek.cbui94" fore="sek.cbui92"></td></tr>
|
||||
</tr>
|
||||
</table>
|
||||
<br>
|
||||
<font color="LEVEL">Memory:</font>
|
||||
<br1>
|
||||
<table width="270" border="0" bgcolor="000000">
|
||||
<tr>
|
||||
<td>Used Memory:</td>
|
||||
<td><font color="00FF00">%usedMem%</font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Free Memory:</td>
|
||||
<td><font color="00FF00">%freeMem%</font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Total Memory:</td>
|
||||
<td><font color="00FF00">%totalMem%</font></td>
|
||||
</tr>
|
||||
</table>
|
||||
<br>
|
||||
<font color="LEVEL">Threads:</font>
|
||||
<br1>
|
||||
<table width="270" border="0" bgcolor="000000">
|
||||
<tr>
|
||||
<td>Live:</td>
|
||||
<td><font color="00FF00">%live%</font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Non-Daemon:</td>
|
||||
<td><font color="00FF00">%nondaemon%</font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Daemon:</td>
|
||||
<td><font color="00FF00">%daemon%</font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Peak:</td>
|
||||
<td><font color="00FF00">%peak%</font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Total started:</td>
|
||||
<td><font color="00FF00">%totalstarted%</font></td>
|
||||
</tr>
|
||||
</table>
|
||||
<br>
|
||||
<font color="LEVEL">Garbage Collector:</font>
|
||||
<br1>
|
||||
<table width="270" border="0" bgcolor="000000">
|
||||
<tr>
|
||||
<td>Type:</td>
|
||||
<td><font color="00FF00">%gcol%</font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Count:</td>
|
||||
<td><font color="00FF00">%colcount%</font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Time:</td>
|
||||
<td><font color="00FF00">%coltime%</font></td>
|
||||
</tr>
|
||||
</table>
|
||||
<br>
|
||||
<font color="LEVEL">Players:</font>
|
||||
<br1>
|
||||
<table width="270" border="0" bgcolor="000000">
|
||||
<tr>
|
||||
<td>Total players count:</td>
|
||||
<td><font color="00FF00">%onlineAll%</font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Offline trade count:</td>
|
||||
<td><font color="00FF00">%offlineTrade%</font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Online GM count:</td>
|
||||
<td><font color="00FF00">%onlineGM%</font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Real player count:</td>
|
||||
<td><font color="00FF00">%onlineReal%</font></td>
|
||||
</tr>
|
||||
</table>
|
||||
<br>
|
||||
<font color="LEVEL">General:</font>
|
||||
<br1>
|
||||
<table width="270" border="0" bgcolor="000000">
|
||||
<tr>
|
||||
<td>OS:</td>
|
||||
<td><font color="00FF00">%os_name%</font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>OS version:</td>
|
||||
<td><font color="00FF00">%os_ver%</font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Server slots:</td>
|
||||
<td><font color="00FF00">%slots%</font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Server UpTime:</td>
|
||||
<td><font color="00FF00">%serverUpTime%</font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Server Time:</td>
|
||||
<td><font color="00FF00">%serverTime%</font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Game Time:</td>
|
||||
<td><font color="00FF00">%gameTime% (%dayNight%)</font></td>
|
||||
</tr>
|
||||
<tr>
|
||||
<td>Pathfinding:</td>
|
||||
<td><font color="00FF00">%geodata%</font></td>
|
||||
</tr>
|
||||
</table>
|
||||
</center>
|
||||
</body>
|
||||
</html>
|
||||
@@ -1,5 +1,5 @@
|
||||
<html><body><br>
|
||||
<font color="LEVEL">[Manage Clan Hall Facilities]<font><br><br>
|
||||
<font color="LEVEL">[Manage Clan Hall Facilities]</font><br><br>
|
||||
<CENTER>
|
||||
<button value="Recovery" action="bypass -h npc_%objectId%_manage recovery" width=75 height=21 back="L2UI_ch3.Btn1_normalOn" fore="L2UI_ch3.Btn1_normal"><br>
|
||||
<button value="Other" action="bypass -h npc_%objectId%_manage other" width=75 height=21 back="L2UI_ch3.Btn1_normalOn" fore="L2UI_ch3.Btn1_normal"><br>
|
||||
|
||||
@@ -71,6 +71,7 @@ import org.l2jmobius.gameserver.handler.admincommandhandlers.AdminRepairChar;
|
||||
import org.l2jmobius.gameserver.handler.admincommandhandlers.AdminRes;
|
||||
import org.l2jmobius.gameserver.handler.admincommandhandlers.AdminRideWyvern;
|
||||
import org.l2jmobius.gameserver.handler.admincommandhandlers.AdminScript;
|
||||
import org.l2jmobius.gameserver.handler.admincommandhandlers.AdminServerInfo;
|
||||
import org.l2jmobius.gameserver.handler.admincommandhandlers.AdminShop;
|
||||
import org.l2jmobius.gameserver.handler.admincommandhandlers.AdminShutdown;
|
||||
import org.l2jmobius.gameserver.handler.admincommandhandlers.AdminSiege;
|
||||
@@ -145,6 +146,7 @@ public class AdminCommandHandler
|
||||
registerAdminCommandHandler(new AdminRes());
|
||||
registerAdminCommandHandler(new AdminRideWyvern());
|
||||
registerAdminCommandHandler(new AdminScript());
|
||||
registerAdminCommandHandler(new AdminServerInfo());
|
||||
registerAdminCommandHandler(new AdminShop());
|
||||
registerAdminCommandHandler(new AdminShutdown());
|
||||
registerAdminCommandHandler(new AdminSiege());
|
||||
|
||||
@@ -0,0 +1,168 @@
|
||||
/*
|
||||
* 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.handler.admincommandhandlers;
|
||||
|
||||
import java.lang.management.GarbageCollectorMXBean;
|
||||
import java.lang.management.ManagementFactory;
|
||||
import java.lang.management.MemoryMXBean;
|
||||
import java.lang.management.MemoryUsage;
|
||||
import java.lang.management.ThreadMXBean;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.HashSet;
|
||||
import java.util.Set;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.l2jmobius.Config;
|
||||
import org.l2jmobius.commons.util.Chronos;
|
||||
import org.l2jmobius.gameserver.GameServer;
|
||||
import org.l2jmobius.gameserver.cache.HtmCache;
|
||||
import org.l2jmobius.gameserver.data.xml.AdminData;
|
||||
import org.l2jmobius.gameserver.handler.IAdminCommandHandler;
|
||||
import org.l2jmobius.gameserver.model.World;
|
||||
import org.l2jmobius.gameserver.model.actor.instance.PlayerInstance;
|
||||
import org.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
|
||||
import org.l2jmobius.gameserver.taskmanager.GameTimeTaskManager;
|
||||
|
||||
/**
|
||||
* @author St3eT
|
||||
*/
|
||||
public class AdminServerInfo implements IAdminCommandHandler
|
||||
{
|
||||
private static final SimpleDateFormat SDF = new SimpleDateFormat("hh:mm a");
|
||||
private static final MemoryMXBean MEMORY_MX_BEAN = ManagementFactory.getMemoryMXBean();
|
||||
private static final ThreadMXBean THREAD_MX_BEAN = ManagementFactory.getThreadMXBean();
|
||||
|
||||
private static final String[] ADMIN_COMMANDS =
|
||||
{
|
||||
"admin_serverinfo"
|
||||
};
|
||||
|
||||
@Override
|
||||
public boolean useAdminCommand(String command, PlayerInstance activeChar)
|
||||
{
|
||||
if (command.equals("admin_serverinfo"))
|
||||
{
|
||||
final MemoryUsage heapMemoryUsage = MEMORY_MX_BEAN.getHeapMemoryUsage();
|
||||
final long freeMemory = heapMemoryUsage.getMax() - heapMemoryUsage.getUsed();
|
||||
final int threadCount = THREAD_MX_BEAN.getThreadCount();
|
||||
final int daemonCount = THREAD_MX_BEAN.getThreadCount();
|
||||
final int nonDaemonCount = threadCount - daemonCount;
|
||||
final int peakCount = THREAD_MX_BEAN.getPeakThreadCount();
|
||||
final long totalCount = THREAD_MX_BEAN.getTotalStartedThreadCount();
|
||||
|
||||
final NpcHtmlMessage html = new NpcHtmlMessage(5);
|
||||
html.setHtml(HtmCache.getInstance().getHtm("data/html/admin/serverinfo.htm"));
|
||||
html.replace("%os_name%", System.getProperty("os.name"));
|
||||
html.replace("%os_ver%", System.getProperty("os.version"));
|
||||
html.replace("%slots%", getPlayersCount("ALL") + "/" + Config.MAXIMUM_ONLINE_USERS);
|
||||
html.replace("%gameTime%", GameTimeTaskManager.getInstance().getGameHour() + ":" + GameTimeTaskManager.getInstance().getGameMinute());
|
||||
html.replace("%dayNight%", GameTimeTaskManager.getInstance().isNight() ? "Night" : "Day");
|
||||
html.replace("%geodata%", Config.PATHFINDING ? "Enabled" : "Disabled");
|
||||
html.replace("%serverTime%", SDF.format(new Date(Chronos.currentTimeMillis())));
|
||||
html.replace("%serverUpTime%", getServerUpTime());
|
||||
html.replace("%onlineAll%", getPlayersCount("ALL"));
|
||||
html.replace("%offlineTrade%", getPlayersCount("OFF_TRADE"));
|
||||
html.replace("%onlineGM%", getPlayersCount("GM"));
|
||||
html.replace("%onlineReal%", getPlayersCount("ALL_REAL"));
|
||||
html.replace("%usedMem%", (MEMORY_MX_BEAN.getHeapMemoryUsage().getUsed() / 0x100000) + " Mb");
|
||||
html.replace("%freeMem%", (freeMemory / 0x100000) + " Mb");
|
||||
html.replace("%totalMem%", (MEMORY_MX_BEAN.getHeapMemoryUsage().getMax() / 0x100000) + " Mb");
|
||||
html.replace("%live%", threadCount);
|
||||
html.replace("%nondaemon%", nonDaemonCount);
|
||||
html.replace("%daemon%", daemonCount);
|
||||
html.replace("%peak%", peakCount);
|
||||
html.replace("%totalstarted%", totalCount);
|
||||
for (GarbageCollectorMXBean gcBean : ManagementFactory.getGarbageCollectorMXBeans())
|
||||
{
|
||||
html.replace("%gcol%", gcBean.getName());
|
||||
html.replace("%colcount%", gcBean.getCollectionCount());
|
||||
html.replace("%coltime%", gcBean.getCollectionTime());
|
||||
}
|
||||
activeChar.sendPacket(html);
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
||||
private String getServerUpTime()
|
||||
{
|
||||
long time = Chronos.currentTimeMillis() - GameServer.dateTimeServerStarted.getTimeInMillis();
|
||||
|
||||
final long days = TimeUnit.MILLISECONDS.toDays(time);
|
||||
time -= TimeUnit.DAYS.toMillis(days);
|
||||
final long hours = TimeUnit.MILLISECONDS.toHours(time);
|
||||
time -= TimeUnit.HOURS.toMillis(hours);
|
||||
return days + " Days, " + hours + " Hours, " + TimeUnit.MILLISECONDS.toMinutes(time) + " Minutes";
|
||||
}
|
||||
|
||||
private int getPlayersCount(String type)
|
||||
{
|
||||
switch (type)
|
||||
{
|
||||
case "ALL":
|
||||
{
|
||||
return World.getInstance().getAllPlayers().size();
|
||||
}
|
||||
case "OFF_TRADE":
|
||||
{
|
||||
int offlineCount = 0;
|
||||
|
||||
final Collection<PlayerInstance> objs = World.getInstance().getAllPlayers();
|
||||
for (PlayerInstance player : objs)
|
||||
{
|
||||
if ((player.getClient() == null) || player.getClient().isDetached())
|
||||
{
|
||||
offlineCount++;
|
||||
}
|
||||
}
|
||||
return offlineCount;
|
||||
}
|
||||
case "GM":
|
||||
{
|
||||
int onlineGMcount = 0;
|
||||
for (PlayerInstance gm : AdminData.getInstance().getAllGms(true))
|
||||
{
|
||||
if ((gm != null) && gm.isOnline() && (gm.getClient() != null) && !gm.getClient().isDetached())
|
||||
{
|
||||
onlineGMcount++;
|
||||
}
|
||||
}
|
||||
return onlineGMcount;
|
||||
}
|
||||
case "ALL_REAL":
|
||||
{
|
||||
final Set<String> realPlayers = new HashSet<>();
|
||||
for (PlayerInstance onlinePlayer : World.getInstance().getAllPlayers())
|
||||
{
|
||||
if ((onlinePlayer != null) && (onlinePlayer.getClient() != null) && !onlinePlayer.getClient().isDetached())
|
||||
{
|
||||
realPlayers.add(onlinePlayer.getClient().getIpAddress());
|
||||
}
|
||||
}
|
||||
return realPlayers.size();
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
@Override
|
||||
public String[] getAdminCommandList()
|
||||
{
|
||||
return ADMIN_COMMANDS;
|
||||
}
|
||||
}
|
||||
@@ -77,6 +77,16 @@ public class GameTimeTaskManager
|
||||
return _gameTicks;
|
||||
}
|
||||
|
||||
public int getGameHour()
|
||||
{
|
||||
return getGameTime() / 60;
|
||||
}
|
||||
|
||||
public int getGameMinute()
|
||||
{
|
||||
return getGameTime() % 60;
|
||||
}
|
||||
|
||||
/**
|
||||
* Add a Creature to movingObjects of GameTimeTaskManager.<br>
|
||||
* <br>
|
||||
|
||||
Reference in New Issue
Block a user