Addition of topspawncount admin command.

This commit is contained in:
MobiusDev
2019-01-10 17:49:26 +00:00
parent 97b4148a7d
commit fdf51df12a
26 changed files with 713 additions and 12 deletions

View File

@@ -532,6 +532,8 @@
<admin command="admin_spawn_debug_menu" accessLevel="100" /> <admin command="admin_spawn_debug_menu" accessLevel="100" />
<admin command="admin_spawn_debug_print" accessLevel="100" /> <admin command="admin_spawn_debug_print" accessLevel="100" />
<admin command="admin_spawn_debug_print_menu" accessLevel="100" /> <admin command="admin_spawn_debug_print_menu" accessLevel="100" />
<admin command="admin_topspawncount" accessLevel="100" />
<admin command="admin_top_spawn_count" accessLevel="100" />
<!-- ADMIN SUMMON --> <!-- ADMIN SUMMON -->
<admin command="admin_summon" accessLevel="100" /> <admin command="admin_summon" accessLevel="100" />

View File

@@ -16,7 +16,10 @@
*/ */
package handlers.admincommandhandlers; package handlers.admincommandhandlers;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -45,6 +48,7 @@ import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage; import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.util.Broadcast; import com.l2jmobius.gameserver.util.Broadcast;
import com.l2jmobius.gameserver.util.BuilderUtil; import com.l2jmobius.gameserver.util.BuilderUtil;
import com.l2jmobius.gameserver.util.Util;
/** /**
* This class handles following admin commands: - show_spawns = shows menu - spawn_index lvl = shows menu for monsters with respective level - spawn_monster id = spawns monster id on target * This class handles following admin commands: - show_spawns = shows menu - spawn_index lvl = shows menu for monsters with respective level - spawn_monster id = spawns monster id on target
@@ -72,7 +76,9 @@ public class AdminSpawn implements IAdminCommandHandler
"admin_list_positions", "admin_list_positions",
"admin_spawn_debug_menu", "admin_spawn_debug_menu",
"admin_spawn_debug_print", "admin_spawn_debug_print",
"admin_spawn_debug_print_menu" "admin_spawn_debug_print_menu",
"admin_topspawncount",
"admin_top_spawn_count"
}; };
@Override @Override
@@ -370,6 +376,52 @@ public class AdminSpawn implements IAdminCommandHandler
findNPCInstances(activeChar, npcId, teleportIndex, false); findNPCInstances(activeChar, npcId, teleportIndex, false);
} }
} }
else if (command.startsWith("admin_topspawncount") || command.startsWith("admin_top_spawn_count"))
{
final StringTokenizer st = new StringTokenizer(command, " ");
st.nextToken();
int count = 5;
if (st.hasMoreTokens())
{
final String nextToken = st.nextToken();
if (Util.isDigit(nextToken))
{
count = Integer.parseInt(nextToken);
}
if (count <= 0)
{
return true;
}
}
final Map<Integer, Integer> npcsFound = new HashMap<>();
for (L2Object obj : L2World.getInstance().getVisibleObjects())
{
if (!obj.isNpc())
{
continue;
}
final int npcId = obj.getId();
if (npcsFound.containsKey(npcId))
{
npcsFound.put(npcId, npcsFound.get(npcId) + 1);
}
else
{
npcsFound.put(npcId, 1);
}
}
BuilderUtil.sendSysMessage(activeChar, "Top " + count + " spawn count.");
for (Entry<Integer, Integer> entry : Util.sortByValue(npcsFound, true).entrySet())
{
count--;
if (count < 0)
{
break;
}
final int npcId = entry.getKey();
BuilderUtil.sendSysMessage(activeChar, NpcData.getInstance().getTemplate(npcId).getName() + " (" + npcId + "): " + entry.getValue());
}
}
return true; return true;
} }

View File

@@ -532,6 +532,8 @@
<admin command="admin_spawn_debug_menu" accessLevel="100" /> <admin command="admin_spawn_debug_menu" accessLevel="100" />
<admin command="admin_spawn_debug_print" accessLevel="100" /> <admin command="admin_spawn_debug_print" accessLevel="100" />
<admin command="admin_spawn_debug_print_menu" accessLevel="100" /> <admin command="admin_spawn_debug_print_menu" accessLevel="100" />
<admin command="admin_topspawncount" accessLevel="100" />
<admin command="admin_top_spawn_count" accessLevel="100" />
<!-- ADMIN SUMMON --> <!-- ADMIN SUMMON -->
<admin command="admin_summon" accessLevel="100" /> <admin command="admin_summon" accessLevel="100" />

View File

@@ -16,7 +16,10 @@
*/ */
package handlers.admincommandhandlers; package handlers.admincommandhandlers;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -45,6 +48,7 @@ import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage; import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.util.Broadcast; import com.l2jmobius.gameserver.util.Broadcast;
import com.l2jmobius.gameserver.util.BuilderUtil; import com.l2jmobius.gameserver.util.BuilderUtil;
import com.l2jmobius.gameserver.util.Util;
/** /**
* This class handles following admin commands: - show_spawns = shows menu - spawn_index lvl = shows menu for monsters with respective level - spawn_monster id = spawns monster id on target * This class handles following admin commands: - show_spawns = shows menu - spawn_index lvl = shows menu for monsters with respective level - spawn_monster id = spawns monster id on target
@@ -72,7 +76,9 @@ public class AdminSpawn implements IAdminCommandHandler
"admin_list_positions", "admin_list_positions",
"admin_spawn_debug_menu", "admin_spawn_debug_menu",
"admin_spawn_debug_print", "admin_spawn_debug_print",
"admin_spawn_debug_print_menu" "admin_spawn_debug_print_menu",
"admin_topspawncount",
"admin_top_spawn_count"
}; };
@Override @Override
@@ -370,6 +376,52 @@ public class AdminSpawn implements IAdminCommandHandler
findNPCInstances(activeChar, npcId, teleportIndex, false); findNPCInstances(activeChar, npcId, teleportIndex, false);
} }
} }
else if (command.startsWith("admin_topspawncount") || command.startsWith("admin_top_spawn_count"))
{
final StringTokenizer st = new StringTokenizer(command, " ");
st.nextToken();
int count = 5;
if (st.hasMoreTokens())
{
final String nextToken = st.nextToken();
if (Util.isDigit(nextToken))
{
count = Integer.parseInt(nextToken);
}
if (count <= 0)
{
return true;
}
}
final Map<Integer, Integer> npcsFound = new HashMap<>();
for (L2Object obj : L2World.getInstance().getVisibleObjects())
{
if (!obj.isNpc())
{
continue;
}
final int npcId = obj.getId();
if (npcsFound.containsKey(npcId))
{
npcsFound.put(npcId, npcsFound.get(npcId) + 1);
}
else
{
npcsFound.put(npcId, 1);
}
}
BuilderUtil.sendSysMessage(activeChar, "Top " + count + " spawn count.");
for (Entry<Integer, Integer> entry : Util.sortByValue(npcsFound, true).entrySet())
{
count--;
if (count < 0)
{
break;
}
final int npcId = entry.getKey();
BuilderUtil.sendSysMessage(activeChar, NpcData.getInstance().getTemplate(npcId).getName() + " (" + npcId + "): " + entry.getValue());
}
}
return true; return true;
} }

View File

@@ -532,6 +532,8 @@
<admin command="admin_spawn_debug_menu" accessLevel="100" /> <admin command="admin_spawn_debug_menu" accessLevel="100" />
<admin command="admin_spawn_debug_print" accessLevel="100" /> <admin command="admin_spawn_debug_print" accessLevel="100" />
<admin command="admin_spawn_debug_print_menu" accessLevel="100" /> <admin command="admin_spawn_debug_print_menu" accessLevel="100" />
<admin command="admin_topspawncount" accessLevel="100" />
<admin command="admin_top_spawn_count" accessLevel="100" />
<!-- ADMIN SUMMON --> <!-- ADMIN SUMMON -->
<admin command="admin_summon" accessLevel="100" /> <admin command="admin_summon" accessLevel="100" />

View File

@@ -16,7 +16,10 @@
*/ */
package handlers.admincommandhandlers; package handlers.admincommandhandlers;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -45,6 +48,7 @@ import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage; import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.util.Broadcast; import com.l2jmobius.gameserver.util.Broadcast;
import com.l2jmobius.gameserver.util.BuilderUtil; import com.l2jmobius.gameserver.util.BuilderUtil;
import com.l2jmobius.gameserver.util.Util;
/** /**
* This class handles following admin commands: - show_spawns = shows menu - spawn_index lvl = shows menu for monsters with respective level - spawn_monster id = spawns monster id on target * This class handles following admin commands: - show_spawns = shows menu - spawn_index lvl = shows menu for monsters with respective level - spawn_monster id = spawns monster id on target
@@ -72,7 +76,9 @@ public class AdminSpawn implements IAdminCommandHandler
"admin_list_positions", "admin_list_positions",
"admin_spawn_debug_menu", "admin_spawn_debug_menu",
"admin_spawn_debug_print", "admin_spawn_debug_print",
"admin_spawn_debug_print_menu" "admin_spawn_debug_print_menu",
"admin_topspawncount",
"admin_top_spawn_count"
}; };
@Override @Override
@@ -370,6 +376,52 @@ public class AdminSpawn implements IAdminCommandHandler
findNPCInstances(activeChar, npcId, teleportIndex, false); findNPCInstances(activeChar, npcId, teleportIndex, false);
} }
} }
else if (command.startsWith("admin_topspawncount") || command.startsWith("admin_top_spawn_count"))
{
final StringTokenizer st = new StringTokenizer(command, " ");
st.nextToken();
int count = 5;
if (st.hasMoreTokens())
{
final String nextToken = st.nextToken();
if (Util.isDigit(nextToken))
{
count = Integer.parseInt(nextToken);
}
if (count <= 0)
{
return true;
}
}
final Map<Integer, Integer> npcsFound = new HashMap<>();
for (L2Object obj : L2World.getInstance().getVisibleObjects())
{
if (!obj.isNpc())
{
continue;
}
final int npcId = obj.getId();
if (npcsFound.containsKey(npcId))
{
npcsFound.put(npcId, npcsFound.get(npcId) + 1);
}
else
{
npcsFound.put(npcId, 1);
}
}
BuilderUtil.sendSysMessage(activeChar, "Top " + count + " spawn count.");
for (Entry<Integer, Integer> entry : Util.sortByValue(npcsFound, true).entrySet())
{
count--;
if (count < 0)
{
break;
}
final int npcId = entry.getKey();
BuilderUtil.sendSysMessage(activeChar, NpcData.getInstance().getTemplate(npcId).getName() + " (" + npcId + "): " + entry.getValue());
}
}
return true; return true;
} }

View File

@@ -532,6 +532,8 @@
<admin command="admin_spawn_debug_menu" accessLevel="100" /> <admin command="admin_spawn_debug_menu" accessLevel="100" />
<admin command="admin_spawn_debug_print" accessLevel="100" /> <admin command="admin_spawn_debug_print" accessLevel="100" />
<admin command="admin_spawn_debug_print_menu" accessLevel="100" /> <admin command="admin_spawn_debug_print_menu" accessLevel="100" />
<admin command="admin_topspawncount" accessLevel="100" />
<admin command="admin_top_spawn_count" accessLevel="100" />
<!-- ADMIN SUMMON --> <!-- ADMIN SUMMON -->
<admin command="admin_summon" accessLevel="100" /> <admin command="admin_summon" accessLevel="100" />

View File

@@ -16,7 +16,10 @@
*/ */
package handlers.admincommandhandlers; package handlers.admincommandhandlers;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -45,6 +48,7 @@ import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage; import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.util.Broadcast; import com.l2jmobius.gameserver.util.Broadcast;
import com.l2jmobius.gameserver.util.BuilderUtil; import com.l2jmobius.gameserver.util.BuilderUtil;
import com.l2jmobius.gameserver.util.Util;
/** /**
* This class handles following admin commands: - show_spawns = shows menu - spawn_index lvl = shows menu for monsters with respective level - spawn_monster id = spawns monster id on target * This class handles following admin commands: - show_spawns = shows menu - spawn_index lvl = shows menu for monsters with respective level - spawn_monster id = spawns monster id on target
@@ -72,7 +76,9 @@ public class AdminSpawn implements IAdminCommandHandler
"admin_list_positions", "admin_list_positions",
"admin_spawn_debug_menu", "admin_spawn_debug_menu",
"admin_spawn_debug_print", "admin_spawn_debug_print",
"admin_spawn_debug_print_menu" "admin_spawn_debug_print_menu",
"admin_topspawncount",
"admin_top_spawn_count"
}; };
@Override @Override
@@ -370,6 +376,52 @@ public class AdminSpawn implements IAdminCommandHandler
findNPCInstances(activeChar, npcId, teleportIndex, false); findNPCInstances(activeChar, npcId, teleportIndex, false);
} }
} }
else if (command.startsWith("admin_topspawncount") || command.startsWith("admin_top_spawn_count"))
{
final StringTokenizer st = new StringTokenizer(command, " ");
st.nextToken();
int count = 5;
if (st.hasMoreTokens())
{
final String nextToken = st.nextToken();
if (Util.isDigit(nextToken))
{
count = Integer.parseInt(nextToken);
}
if (count <= 0)
{
return true;
}
}
final Map<Integer, Integer> npcsFound = new HashMap<>();
for (L2Object obj : L2World.getInstance().getVisibleObjects())
{
if (!obj.isNpc())
{
continue;
}
final int npcId = obj.getId();
if (npcsFound.containsKey(npcId))
{
npcsFound.put(npcId, npcsFound.get(npcId) + 1);
}
else
{
npcsFound.put(npcId, 1);
}
}
BuilderUtil.sendSysMessage(activeChar, "Top " + count + " spawn count.");
for (Entry<Integer, Integer> entry : Util.sortByValue(npcsFound, true).entrySet())
{
count--;
if (count < 0)
{
break;
}
final int npcId = entry.getKey();
BuilderUtil.sendSysMessage(activeChar, NpcData.getInstance().getTemplate(npcId).getName() + " (" + npcId + "): " + entry.getValue());
}
}
return true; return true;
} }

View File

@@ -532,6 +532,8 @@
<admin command="admin_spawn_debug_menu" accessLevel="100" /> <admin command="admin_spawn_debug_menu" accessLevel="100" />
<admin command="admin_spawn_debug_print" accessLevel="100" /> <admin command="admin_spawn_debug_print" accessLevel="100" />
<admin command="admin_spawn_debug_print_menu" accessLevel="100" /> <admin command="admin_spawn_debug_print_menu" accessLevel="100" />
<admin command="admin_topspawncount" accessLevel="100" />
<admin command="admin_top_spawn_count" accessLevel="100" />
<!-- ADMIN SUMMON --> <!-- ADMIN SUMMON -->
<admin command="admin_summon" accessLevel="100" /> <admin command="admin_summon" accessLevel="100" />

View File

@@ -16,7 +16,10 @@
*/ */
package handlers.admincommandhandlers; package handlers.admincommandhandlers;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -45,6 +48,7 @@ import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage; import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.util.Broadcast; import com.l2jmobius.gameserver.util.Broadcast;
import com.l2jmobius.gameserver.util.BuilderUtil; import com.l2jmobius.gameserver.util.BuilderUtil;
import com.l2jmobius.gameserver.util.Util;
/** /**
* This class handles following admin commands: - show_spawns = shows menu - spawn_index lvl = shows menu for monsters with respective level - spawn_monster id = spawns monster id on target * This class handles following admin commands: - show_spawns = shows menu - spawn_index lvl = shows menu for monsters with respective level - spawn_monster id = spawns monster id on target
@@ -72,7 +76,9 @@ public class AdminSpawn implements IAdminCommandHandler
"admin_list_positions", "admin_list_positions",
"admin_spawn_debug_menu", "admin_spawn_debug_menu",
"admin_spawn_debug_print", "admin_spawn_debug_print",
"admin_spawn_debug_print_menu" "admin_spawn_debug_print_menu",
"admin_topspawncount",
"admin_top_spawn_count"
}; };
@Override @Override
@@ -370,6 +376,52 @@ public class AdminSpawn implements IAdminCommandHandler
findNPCInstances(activeChar, npcId, teleportIndex, false); findNPCInstances(activeChar, npcId, teleportIndex, false);
} }
} }
else if (command.startsWith("admin_topspawncount") || command.startsWith("admin_top_spawn_count"))
{
final StringTokenizer st = new StringTokenizer(command, " ");
st.nextToken();
int count = 5;
if (st.hasMoreTokens())
{
final String nextToken = st.nextToken();
if (Util.isDigit(nextToken))
{
count = Integer.parseInt(nextToken);
}
if (count <= 0)
{
return true;
}
}
final Map<Integer, Integer> npcsFound = new HashMap<>();
for (L2Object obj : L2World.getInstance().getVisibleObjects())
{
if (!obj.isNpc())
{
continue;
}
final int npcId = obj.getId();
if (npcsFound.containsKey(npcId))
{
npcsFound.put(npcId, npcsFound.get(npcId) + 1);
}
else
{
npcsFound.put(npcId, 1);
}
}
BuilderUtil.sendSysMessage(activeChar, "Top " + count + " spawn count.");
for (Entry<Integer, Integer> entry : Util.sortByValue(npcsFound, true).entrySet())
{
count--;
if (count < 0)
{
break;
}
final int npcId = entry.getKey();
BuilderUtil.sendSysMessage(activeChar, NpcData.getInstance().getTemplate(npcId).getName() + " (" + npcId + "): " + entry.getValue());
}
}
return true; return true;
} }

View File

@@ -532,6 +532,8 @@
<admin command="admin_spawn_debug_menu" accessLevel="100" /> <admin command="admin_spawn_debug_menu" accessLevel="100" />
<admin command="admin_spawn_debug_print" accessLevel="100" /> <admin command="admin_spawn_debug_print" accessLevel="100" />
<admin command="admin_spawn_debug_print_menu" accessLevel="100" /> <admin command="admin_spawn_debug_print_menu" accessLevel="100" />
<admin command="admin_topspawncount" accessLevel="100" />
<admin command="admin_top_spawn_count" accessLevel="100" />
<!-- ADMIN SUMMON --> <!-- ADMIN SUMMON -->
<admin command="admin_summon" accessLevel="100" /> <admin command="admin_summon" accessLevel="100" />

View File

@@ -16,7 +16,10 @@
*/ */
package handlers.admincommandhandlers; package handlers.admincommandhandlers;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -45,6 +48,7 @@ import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage; import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.util.Broadcast; import com.l2jmobius.gameserver.util.Broadcast;
import com.l2jmobius.gameserver.util.BuilderUtil; import com.l2jmobius.gameserver.util.BuilderUtil;
import com.l2jmobius.gameserver.util.Util;
/** /**
* This class handles following admin commands: - show_spawns = shows menu - spawn_index lvl = shows menu for monsters with respective level - spawn_monster id = spawns monster id on target * This class handles following admin commands: - show_spawns = shows menu - spawn_index lvl = shows menu for monsters with respective level - spawn_monster id = spawns monster id on target
@@ -72,7 +76,9 @@ public class AdminSpawn implements IAdminCommandHandler
"admin_list_positions", "admin_list_positions",
"admin_spawn_debug_menu", "admin_spawn_debug_menu",
"admin_spawn_debug_print", "admin_spawn_debug_print",
"admin_spawn_debug_print_menu" "admin_spawn_debug_print_menu",
"admin_topspawncount",
"admin_top_spawn_count"
}; };
@Override @Override
@@ -370,6 +376,52 @@ public class AdminSpawn implements IAdminCommandHandler
findNPCInstances(activeChar, npcId, teleportIndex, false); findNPCInstances(activeChar, npcId, teleportIndex, false);
} }
} }
else if (command.startsWith("admin_topspawncount") || command.startsWith("admin_top_spawn_count"))
{
final StringTokenizer st = new StringTokenizer(command, " ");
st.nextToken();
int count = 5;
if (st.hasMoreTokens())
{
final String nextToken = st.nextToken();
if (Util.isDigit(nextToken))
{
count = Integer.parseInt(nextToken);
}
if (count <= 0)
{
return true;
}
}
final Map<Integer, Integer> npcsFound = new HashMap<>();
for (L2Object obj : L2World.getInstance().getVisibleObjects())
{
if (!obj.isNpc())
{
continue;
}
final int npcId = obj.getId();
if (npcsFound.containsKey(npcId))
{
npcsFound.put(npcId, npcsFound.get(npcId) + 1);
}
else
{
npcsFound.put(npcId, 1);
}
}
BuilderUtil.sendSysMessage(activeChar, "Top " + count + " spawn count.");
for (Entry<Integer, Integer> entry : Util.sortByValue(npcsFound, true).entrySet())
{
count--;
if (count < 0)
{
break;
}
final int npcId = entry.getKey();
BuilderUtil.sendSysMessage(activeChar, NpcData.getInstance().getTemplate(npcId).getName() + " (" + npcId + "): " + entry.getValue());
}
}
return true; return true;
} }

View File

@@ -528,6 +528,8 @@ INSERT IGNORE INTO `admin_command_access_rights` VALUES
('admin_teleport_reload','3'), ('admin_teleport_reload','3'),
('admin_spawnnight','3'), ('admin_spawnnight','3'),
('admin_spawnday','3'), ('admin_spawnday','3'),
('admin_topspawncount','3'),
('admin_top_spawn_count','3'),
-- Section: Target -- Section: Target
('admin_target','3'), ('admin_target','3'),

View File

@@ -16,6 +16,9 @@
*/ */
package com.l2jmobius.gameserver.handler.admincommandhandlers; package com.l2jmobius.gameserver.handler.admincommandhandlers;
import java.util.HashMap;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -31,6 +34,7 @@ import com.l2jmobius.gameserver.instancemanager.GrandBossManager;
import com.l2jmobius.gameserver.instancemanager.RaidBossSpawnManager; import com.l2jmobius.gameserver.instancemanager.RaidBossSpawnManager;
import com.l2jmobius.gameserver.model.L2Object; import com.l2jmobius.gameserver.model.L2Object;
import com.l2jmobius.gameserver.model.L2World; import com.l2jmobius.gameserver.model.L2World;
import com.l2jmobius.gameserver.model.actor.instance.L2NpcInstance;
import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance; import com.l2jmobius.gameserver.model.actor.instance.L2PcInstance;
import com.l2jmobius.gameserver.model.entity.sevensigns.SevenSigns; import com.l2jmobius.gameserver.model.entity.sevensigns.SevenSigns;
import com.l2jmobius.gameserver.model.spawn.L2Spawn; import com.l2jmobius.gameserver.model.spawn.L2Spawn;
@@ -38,6 +42,7 @@ import com.l2jmobius.gameserver.network.SystemMessageId;
import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage; import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jmobius.gameserver.templates.chars.L2NpcTemplate; import com.l2jmobius.gameserver.templates.chars.L2NpcTemplate;
import com.l2jmobius.gameserver.util.BuilderUtil; import com.l2jmobius.gameserver.util.BuilderUtil;
import com.l2jmobius.gameserver.util.Util;
/** /**
* This class handles following admin commands: - show_spawns = shows menu - spawn_index lvl = shows menu for monsters with respective level - spawn_monster id = spawns monster id on target * This class handles following admin commands: - show_spawns = shows menu - spawn_index lvl = shows menu for monsters with respective level - spawn_monster id = spawns monster id on target
@@ -59,7 +64,9 @@ public class AdminSpawn implements IAdminCommandHandler
"admin_show_npcs", "admin_show_npcs",
"admin_teleport_reload", "admin_teleport_reload",
"admin_spawnnight", "admin_spawnnight",
"admin_spawnday" "admin_spawnday",
"admin_topspawncount",
"admin_top_spawn_count"
}; };
public static Logger LOGGER = Logger.getLogger(AdminSpawn.class.getName()); public static Logger LOGGER = Logger.getLogger(AdminSpawn.class.getName());
@@ -199,6 +206,52 @@ public class AdminSpawn implements IAdminCommandHandler
TeleportLocationTable.getInstance().reloadAll(); TeleportLocationTable.getInstance().reloadAll();
GmListTable.broadcastMessageToGMs("Teleport List Table reloaded."); GmListTable.broadcastMessageToGMs("Teleport List Table reloaded.");
} }
else if (command.startsWith("admin_topspawncount") || command.startsWith("admin_top_spawn_count"))
{
final StringTokenizer st = new StringTokenizer(command, " ");
st.nextToken();
int count = 5;
if (st.hasMoreTokens())
{
final String nextToken = st.nextToken();
if (Util.isDigit(nextToken))
{
count = Integer.parseInt(nextToken);
}
if (count <= 0)
{
return true;
}
}
final Map<Integer, Integer> npcsFound = new HashMap<>();
for (L2Object obj : L2World.getInstance().getAllVisibleObjects())
{
if (!(obj instanceof L2NpcInstance))
{
continue;
}
final int npcId = ((L2NpcInstance) obj).getNpcId();
if (npcsFound.containsKey(npcId))
{
npcsFound.put(npcId, npcsFound.get(npcId) + 1);
}
else
{
npcsFound.put(npcId, 1);
}
}
BuilderUtil.sendSysMessage(activeChar, "Top " + count + " spawn count.");
for (Entry<Integer, Integer> entry : Util.sortByValue(npcsFound, true).entrySet())
{
count--;
if (count < 0)
{
break;
}
final int npcId = entry.getKey();
BuilderUtil.sendSysMessage(activeChar, NpcTable.getInstance().getTemplate(npcId).getName() + " (" + npcId + "): " + entry.getValue());
}
}
return true; return true;
} }

View File

@@ -19,6 +19,10 @@ package com.l2jmobius.gameserver.util;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Collection; import java.util.Collection;
import java.util.Collections;
import java.util.LinkedHashMap;
import java.util.Map;
import java.util.stream.Collectors;
import com.l2jmobius.commons.concurrent.ThreadPool; import com.l2jmobius.commons.concurrent.ThreadPool;
import com.l2jmobius.gameserver.model.L2Object; import com.l2jmobius.gameserver.model.L2Object;
@@ -542,4 +546,26 @@ public final class Util
{ {
return (objectsSize / pageSize) + ((objectsSize % pageSize) == 0 ? 0 : 1); return (objectsSize / pageSize) + ((objectsSize % pageSize) == 0 ? 0 : 1);
} }
/**
* This will sort a Map according to the values. Default sort direction is ascending.
* @param <K> keyType
* @param <V> valueType
* @param map Map to be sorted.
* @param descending If you want to sort descending.
* @return A new Map sorted by the values.
*/
public static <K, V extends Comparable<? super V>> Map<K, V> sortByValue(Map<K, V> map, boolean descending)
{
if (descending)
{
return map.entrySet().stream().sorted(Map.Entry.comparingByValue(Collections.reverseOrder())).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
}
return map.entrySet().stream().sorted(Map.Entry.comparingByValue()).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
}
public static <K, V extends Comparable<? super V>> Map<K, V> sortByValue(Map<K, V> map)
{
return map.entrySet().stream().sorted(Map.Entry.comparingByValue()).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
}
} }

View File

@@ -530,6 +530,8 @@
<admin command="admin_spawn_debug_menu" accessLevel="100" /> <admin command="admin_spawn_debug_menu" accessLevel="100" />
<admin command="admin_spawn_debug_print" accessLevel="100" /> <admin command="admin_spawn_debug_print" accessLevel="100" />
<admin command="admin_spawn_debug_print_menu" accessLevel="100" /> <admin command="admin_spawn_debug_print_menu" accessLevel="100" />
<admin command="admin_topspawncount" accessLevel="100" />
<admin command="admin_top_spawn_count" accessLevel="100" />
<!-- ADMIN SUMMON --> <!-- ADMIN SUMMON -->
<admin command="admin_summon" accessLevel="100" /> <admin command="admin_summon" accessLevel="100" />

View File

@@ -16,7 +16,10 @@
*/ */
package handlers.admincommandhandlers; package handlers.admincommandhandlers;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -46,6 +49,7 @@ import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage; import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.util.Broadcast; import com.l2jmobius.gameserver.util.Broadcast;
import com.l2jmobius.gameserver.util.BuilderUtil; import com.l2jmobius.gameserver.util.BuilderUtil;
import com.l2jmobius.gameserver.util.Util;
/** /**
* This class handles following admin commands: - show_spawns = shows menu - spawn_index lvl = shows menu for monsters with respective level - spawn_monster id = spawns monster id on target * This class handles following admin commands: - show_spawns = shows menu - spawn_index lvl = shows menu for monsters with respective level - spawn_monster id = spawns monster id on target
@@ -74,7 +78,9 @@ public class AdminSpawn implements IAdminCommandHandler
"admin_list_positions", "admin_list_positions",
"admin_spawn_debug_menu", "admin_spawn_debug_menu",
"admin_spawn_debug_print", "admin_spawn_debug_print",
"admin_spawn_debug_print_menu" "admin_spawn_debug_print_menu",
"admin_topspawncount",
"admin_top_spawn_count"
}; };
@Override @Override
@@ -345,6 +351,52 @@ public class AdminSpawn implements IAdminCommandHandler
findNPCInstances(activeChar, npcId, teleportIndex, false); findNPCInstances(activeChar, npcId, teleportIndex, false);
} }
} }
else if (command.startsWith("admin_topspawncount") || command.startsWith("admin_top_spawn_count"))
{
final StringTokenizer st = new StringTokenizer(command, " ");
st.nextToken();
int count = 5;
if (st.hasMoreTokens())
{
final String nextToken = st.nextToken();
if (Util.isDigit(nextToken))
{
count = Integer.parseInt(nextToken);
}
if (count <= 0)
{
return true;
}
}
final Map<Integer, Integer> npcsFound = new HashMap<>();
for (L2Object obj : L2World.getInstance().getVisibleObjects())
{
if (!obj.isNpc())
{
continue;
}
final int npcId = obj.getId();
if (npcsFound.containsKey(npcId))
{
npcsFound.put(npcId, npcsFound.get(npcId) + 1);
}
else
{
npcsFound.put(npcId, 1);
}
}
BuilderUtil.sendSysMessage(activeChar, "Top " + count + " spawn count.");
for (Entry<Integer, Integer> entry : Util.sortByValue(npcsFound, true).entrySet())
{
count--;
if (count < 0)
{
break;
}
final int npcId = entry.getKey();
BuilderUtil.sendSysMessage(activeChar, NpcData.getInstance().getTemplate(npcId).getName() + " (" + npcId + "): " + entry.getValue());
}
}
return true; return true;
} }

View File

@@ -22,11 +22,15 @@ import java.text.DecimalFormatSymbols;
import java.text.NumberFormat; import java.text.NumberFormat;
import java.text.SimpleDateFormat; import java.text.SimpleDateFormat;
import java.util.Arrays; import java.util.Arrays;
import java.util.Collections;
import java.util.Date; import java.util.Date;
import java.util.LinkedHashMap;
import java.util.Locale; import java.util.Locale;
import java.util.Map;
import java.util.StringJoiner; import java.util.StringJoiner;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.logging.Logger; import java.util.logging.Logger;
import java.util.stream.Collectors;
import com.l2jmobius.Config; import com.l2jmobius.Config;
import com.l2jmobius.commons.concurrent.ThreadPool; import com.l2jmobius.commons.concurrent.ThreadPool;
@@ -958,4 +962,26 @@ public final class Util
return defaultVal; return defaultVal;
} }
} }
/**
* This will sort a Map according to the values. Default sort direction is ascending.
* @param <K> keyType
* @param <V> valueType
* @param map Map to be sorted.
* @param descending If you want to sort descending.
* @return A new Map sorted by the values.
*/
public static <K, V extends Comparable<? super V>> Map<K, V> sortByValue(Map<K, V> map, boolean descending)
{
if (descending)
{
return map.entrySet().stream().sorted(Map.Entry.comparingByValue(Collections.reverseOrder())).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
}
return map.entrySet().stream().sorted(Map.Entry.comparingByValue()).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
}
public static <K, V extends Comparable<? super V>> Map<K, V> sortByValue(Map<K, V> map)
{
return map.entrySet().stream().sorted(Map.Entry.comparingByValue()).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
}
} }

View File

@@ -529,6 +529,8 @@
<admin command="admin_spawn_debug_menu" accessLevel="100" /> <admin command="admin_spawn_debug_menu" accessLevel="100" />
<admin command="admin_spawn_debug_print" accessLevel="100" /> <admin command="admin_spawn_debug_print" accessLevel="100" />
<admin command="admin_spawn_debug_print_menu" accessLevel="100" /> <admin command="admin_spawn_debug_print_menu" accessLevel="100" />
<admin command="admin_topspawncount" accessLevel="100" />
<admin command="admin_top_spawn_count" accessLevel="100" />
<!-- ADMIN SUMMON --> <!-- ADMIN SUMMON -->
<admin command="admin_summon" accessLevel="100" /> <admin command="admin_summon" accessLevel="100" />

View File

@@ -16,7 +16,10 @@
*/ */
package handlers.admincommandhandlers; package handlers.admincommandhandlers;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -45,6 +48,7 @@ import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage; import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.util.Broadcast; import com.l2jmobius.gameserver.util.Broadcast;
import com.l2jmobius.gameserver.util.BuilderUtil; import com.l2jmobius.gameserver.util.BuilderUtil;
import com.l2jmobius.gameserver.util.Util;
/** /**
* This class handles following admin commands: - show_spawns = shows menu - spawn_index lvl = shows menu for monsters with respective level - spawn_monster id = spawns monster id on target * This class handles following admin commands: - show_spawns = shows menu - spawn_index lvl = shows menu for monsters with respective level - spawn_monster id = spawns monster id on target
@@ -72,7 +76,9 @@ public class AdminSpawn implements IAdminCommandHandler
"admin_list_positions", "admin_list_positions",
"admin_spawn_debug_menu", "admin_spawn_debug_menu",
"admin_spawn_debug_print", "admin_spawn_debug_print",
"admin_spawn_debug_print_menu" "admin_spawn_debug_print_menu",
"admin_topspawncount",
"admin_top_spawn_count"
}; };
@Override @Override
@@ -370,6 +376,52 @@ public class AdminSpawn implements IAdminCommandHandler
findNPCInstances(activeChar, npcId, teleportIndex, false); findNPCInstances(activeChar, npcId, teleportIndex, false);
} }
} }
else if (command.startsWith("admin_topspawncount") || command.startsWith("admin_top_spawn_count"))
{
final StringTokenizer st = new StringTokenizer(command, " ");
st.nextToken();
int count = 5;
if (st.hasMoreTokens())
{
final String nextToken = st.nextToken();
if (Util.isDigit(nextToken))
{
count = Integer.parseInt(nextToken);
}
if (count <= 0)
{
return true;
}
}
final Map<Integer, Integer> npcsFound = new HashMap<>();
for (L2Object obj : L2World.getInstance().getVisibleObjects())
{
if (!obj.isNpc())
{
continue;
}
final int npcId = obj.getId();
if (npcsFound.containsKey(npcId))
{
npcsFound.put(npcId, npcsFound.get(npcId) + 1);
}
else
{
npcsFound.put(npcId, 1);
}
}
BuilderUtil.sendSysMessage(activeChar, "Top " + count + " spawn count.");
for (Entry<Integer, Integer> entry : Util.sortByValue(npcsFound, true).entrySet())
{
count--;
if (count < 0)
{
break;
}
final int npcId = entry.getKey();
BuilderUtil.sendSysMessage(activeChar, NpcData.getInstance().getTemplate(npcId).getName() + " (" + npcId + "): " + entry.getValue());
}
}
return true; return true;
} }

View File

@@ -529,6 +529,8 @@
<admin command="admin_spawn_debug_menu" accessLevel="100" /> <admin command="admin_spawn_debug_menu" accessLevel="100" />
<admin command="admin_spawn_debug_print" accessLevel="100" /> <admin command="admin_spawn_debug_print" accessLevel="100" />
<admin command="admin_spawn_debug_print_menu" accessLevel="100" /> <admin command="admin_spawn_debug_print_menu" accessLevel="100" />
<admin command="admin_topspawncount" accessLevel="100" />
<admin command="admin_top_spawn_count" accessLevel="100" />
<!-- ADMIN SUMMON --> <!-- ADMIN SUMMON -->
<admin command="admin_summon" accessLevel="100" /> <admin command="admin_summon" accessLevel="100" />

View File

@@ -16,7 +16,10 @@
*/ */
package handlers.admincommandhandlers; package handlers.admincommandhandlers;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -45,6 +48,7 @@ import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage; import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.util.Broadcast; import com.l2jmobius.gameserver.util.Broadcast;
import com.l2jmobius.gameserver.util.BuilderUtil; import com.l2jmobius.gameserver.util.BuilderUtil;
import com.l2jmobius.gameserver.util.Util;
/** /**
* This class handles following admin commands: - show_spawns = shows menu - spawn_index lvl = shows menu for monsters with respective level - spawn_monster id = spawns monster id on target * This class handles following admin commands: - show_spawns = shows menu - spawn_index lvl = shows menu for monsters with respective level - spawn_monster id = spawns monster id on target
@@ -72,7 +76,9 @@ public class AdminSpawn implements IAdminCommandHandler
"admin_list_positions", "admin_list_positions",
"admin_spawn_debug_menu", "admin_spawn_debug_menu",
"admin_spawn_debug_print", "admin_spawn_debug_print",
"admin_spawn_debug_print_menu" "admin_spawn_debug_print_menu",
"admin_topspawncount",
"admin_top_spawn_count"
}; };
@Override @Override
@@ -370,6 +376,52 @@ public class AdminSpawn implements IAdminCommandHandler
findNPCInstances(activeChar, npcId, teleportIndex, false); findNPCInstances(activeChar, npcId, teleportIndex, false);
} }
} }
else if (command.startsWith("admin_topspawncount") || command.startsWith("admin_top_spawn_count"))
{
final StringTokenizer st = new StringTokenizer(command, " ");
st.nextToken();
int count = 5;
if (st.hasMoreTokens())
{
final String nextToken = st.nextToken();
if (Util.isDigit(nextToken))
{
count = Integer.parseInt(nextToken);
}
if (count <= 0)
{
return true;
}
}
final Map<Integer, Integer> npcsFound = new HashMap<>();
for (L2Object obj : L2World.getInstance().getVisibleObjects())
{
if (!obj.isNpc())
{
continue;
}
final int npcId = obj.getId();
if (npcsFound.containsKey(npcId))
{
npcsFound.put(npcId, npcsFound.get(npcId) + 1);
}
else
{
npcsFound.put(npcId, 1);
}
}
BuilderUtil.sendSysMessage(activeChar, "Top " + count + " spawn count.");
for (Entry<Integer, Integer> entry : Util.sortByValue(npcsFound, true).entrySet())
{
count--;
if (count < 0)
{
break;
}
final int npcId = entry.getKey();
BuilderUtil.sendSysMessage(activeChar, NpcData.getInstance().getTemplate(npcId).getName() + " (" + npcId + "): " + entry.getValue());
}
}
return true; return true;
} }

View File

@@ -529,6 +529,8 @@
<admin command="admin_spawn_debug_menu" accessLevel="100" /> <admin command="admin_spawn_debug_menu" accessLevel="100" />
<admin command="admin_spawn_debug_print" accessLevel="100" /> <admin command="admin_spawn_debug_print" accessLevel="100" />
<admin command="admin_spawn_debug_print_menu" accessLevel="100" /> <admin command="admin_spawn_debug_print_menu" accessLevel="100" />
<admin command="admin_topspawncount" accessLevel="100" />
<admin command="admin_top_spawn_count" accessLevel="100" />
<!-- ADMIN SUMMON --> <!-- ADMIN SUMMON -->
<admin command="admin_summon" accessLevel="100" /> <admin command="admin_summon" accessLevel="100" />

View File

@@ -16,7 +16,10 @@
*/ */
package handlers.admincommandhandlers; package handlers.admincommandhandlers;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -45,6 +48,7 @@ import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage; import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.util.Broadcast; import com.l2jmobius.gameserver.util.Broadcast;
import com.l2jmobius.gameserver.util.BuilderUtil; import com.l2jmobius.gameserver.util.BuilderUtil;
import com.l2jmobius.gameserver.util.Util;
/** /**
* This class handles following admin commands: - show_spawns = shows menu - spawn_index lvl = shows menu for monsters with respective level - spawn_monster id = spawns monster id on target * This class handles following admin commands: - show_spawns = shows menu - spawn_index lvl = shows menu for monsters with respective level - spawn_monster id = spawns monster id on target
@@ -72,7 +76,9 @@ public class AdminSpawn implements IAdminCommandHandler
"admin_list_positions", "admin_list_positions",
"admin_spawn_debug_menu", "admin_spawn_debug_menu",
"admin_spawn_debug_print", "admin_spawn_debug_print",
"admin_spawn_debug_print_menu" "admin_spawn_debug_print_menu",
"admin_topspawncount",
"admin_top_spawn_count"
}; };
@Override @Override
@@ -370,6 +376,52 @@ public class AdminSpawn implements IAdminCommandHandler
findNPCInstances(activeChar, npcId, teleportIndex, false); findNPCInstances(activeChar, npcId, teleportIndex, false);
} }
} }
else if (command.startsWith("admin_topspawncount") || command.startsWith("admin_top_spawn_count"))
{
final StringTokenizer st = new StringTokenizer(command, " ");
st.nextToken();
int count = 5;
if (st.hasMoreTokens())
{
final String nextToken = st.nextToken();
if (Util.isDigit(nextToken))
{
count = Integer.parseInt(nextToken);
}
if (count <= 0)
{
return true;
}
}
final Map<Integer, Integer> npcsFound = new HashMap<>();
for (L2Object obj : L2World.getInstance().getVisibleObjects())
{
if (!obj.isNpc())
{
continue;
}
final int npcId = obj.getId();
if (npcsFound.containsKey(npcId))
{
npcsFound.put(npcId, npcsFound.get(npcId) + 1);
}
else
{
npcsFound.put(npcId, 1);
}
}
BuilderUtil.sendSysMessage(activeChar, "Top " + count + " spawn count.");
for (Entry<Integer, Integer> entry : Util.sortByValue(npcsFound, true).entrySet())
{
count--;
if (count < 0)
{
break;
}
final int npcId = entry.getKey();
BuilderUtil.sendSysMessage(activeChar, NpcData.getInstance().getTemplate(npcId).getName() + " (" + npcId + "): " + entry.getValue());
}
}
return true; return true;
} }

View File

@@ -529,6 +529,8 @@
<admin command="admin_spawn_debug_menu" accessLevel="100" /> <admin command="admin_spawn_debug_menu" accessLevel="100" />
<admin command="admin_spawn_debug_print" accessLevel="100" /> <admin command="admin_spawn_debug_print" accessLevel="100" />
<admin command="admin_spawn_debug_print_menu" accessLevel="100" /> <admin command="admin_spawn_debug_print_menu" accessLevel="100" />
<admin command="admin_topspawncount" accessLevel="100" />
<admin command="admin_top_spawn_count" accessLevel="100" />
<!-- ADMIN SUMMON --> <!-- ADMIN SUMMON -->
<admin command="admin_summon" accessLevel="100" /> <admin command="admin_summon" accessLevel="100" />

View File

@@ -16,7 +16,10 @@
*/ */
package handlers.admincommandhandlers; package handlers.admincommandhandlers;
import java.util.HashMap;
import java.util.List; import java.util.List;
import java.util.Map;
import java.util.Map.Entry;
import java.util.NoSuchElementException; import java.util.NoSuchElementException;
import java.util.StringTokenizer; import java.util.StringTokenizer;
import java.util.logging.Logger; import java.util.logging.Logger;
@@ -45,6 +48,7 @@ import com.l2jmobius.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jmobius.gameserver.network.serverpackets.SystemMessage; import com.l2jmobius.gameserver.network.serverpackets.SystemMessage;
import com.l2jmobius.gameserver.util.Broadcast; import com.l2jmobius.gameserver.util.Broadcast;
import com.l2jmobius.gameserver.util.BuilderUtil; import com.l2jmobius.gameserver.util.BuilderUtil;
import com.l2jmobius.gameserver.util.Util;
/** /**
* This class handles following admin commands: - show_spawns = shows menu - spawn_index lvl = shows menu for monsters with respective level - spawn_monster id = spawns monster id on target * This class handles following admin commands: - show_spawns = shows menu - spawn_index lvl = shows menu for monsters with respective level - spawn_monster id = spawns monster id on target
@@ -72,7 +76,9 @@ public class AdminSpawn implements IAdminCommandHandler
"admin_list_positions", "admin_list_positions",
"admin_spawn_debug_menu", "admin_spawn_debug_menu",
"admin_spawn_debug_print", "admin_spawn_debug_print",
"admin_spawn_debug_print_menu" "admin_spawn_debug_print_menu",
"admin_topspawncount",
"admin_top_spawn_count"
}; };
@Override @Override
@@ -370,6 +376,52 @@ public class AdminSpawn implements IAdminCommandHandler
findNPCInstances(activeChar, npcId, teleportIndex, false); findNPCInstances(activeChar, npcId, teleportIndex, false);
} }
} }
else if (command.startsWith("admin_topspawncount") || command.startsWith("admin_top_spawn_count"))
{
final StringTokenizer st = new StringTokenizer(command, " ");
st.nextToken();
int count = 5;
if (st.hasMoreTokens())
{
final String nextToken = st.nextToken();
if (Util.isDigit(nextToken))
{
count = Integer.parseInt(nextToken);
}
if (count <= 0)
{
return true;
}
}
final Map<Integer, Integer> npcsFound = new HashMap<>();
for (L2Object obj : L2World.getInstance().getVisibleObjects())
{
if (!obj.isNpc())
{
continue;
}
final int npcId = obj.getId();
if (npcsFound.containsKey(npcId))
{
npcsFound.put(npcId, npcsFound.get(npcId) + 1);
}
else
{
npcsFound.put(npcId, 1);
}
}
BuilderUtil.sendSysMessage(activeChar, "Top " + count + " spawn count.");
for (Entry<Integer, Integer> entry : Util.sortByValue(npcsFound, true).entrySet())
{
count--;
if (count < 0)
{
break;
}
final int npcId = entry.getKey();
BuilderUtil.sendSysMessage(activeChar, NpcData.getInstance().getTemplate(npcId).getName() + " (" + npcId + "): " + entry.getValue());
}
}
return true; return true;
} }