diff --git a/L2J_Mobius_1.0_Ertheia/dist/game/config/AdminCommands.xml b/L2J_Mobius_1.0_Ertheia/dist/game/config/AdminCommands.xml
index 820bdab5c2..02a5780011 100644
--- a/L2J_Mobius_1.0_Ertheia/dist/game/config/AdminCommands.xml
+++ b/L2J_Mobius_1.0_Ertheia/dist/game/config/AdminCommands.xml
@@ -532,6 +532,8 @@
+
+
diff --git a/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java b/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java
index 60bcced355..cebb103ccb 100644
--- a/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java
+++ b/L2J_Mobius_1.0_Ertheia/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java
@@ -16,7 +16,10 @@
*/
package handlers.admincommandhandlers;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.StringTokenizer;
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.util.Broadcast;
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
@@ -72,7 +76,9 @@ public class AdminSpawn implements IAdminCommandHandler
"admin_list_positions",
"admin_spawn_debug_menu",
"admin_spawn_debug_print",
- "admin_spawn_debug_print_menu"
+ "admin_spawn_debug_print_menu",
+ "admin_topspawncount",
+ "admin_top_spawn_count"
};
@Override
@@ -370,6 +376,52 @@ public class AdminSpawn implements IAdminCommandHandler
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 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 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;
}
diff --git a/L2J_Mobius_2.5_Underground/dist/game/config/AdminCommands.xml b/L2J_Mobius_2.5_Underground/dist/game/config/AdminCommands.xml
index 820bdab5c2..02a5780011 100644
--- a/L2J_Mobius_2.5_Underground/dist/game/config/AdminCommands.xml
+++ b/L2J_Mobius_2.5_Underground/dist/game/config/AdminCommands.xml
@@ -532,6 +532,8 @@
+
+
diff --git a/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java b/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java
index 60bcced355..cebb103ccb 100644
--- a/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java
+++ b/L2J_Mobius_2.5_Underground/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java
@@ -16,7 +16,10 @@
*/
package handlers.admincommandhandlers;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.StringTokenizer;
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.util.Broadcast;
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
@@ -72,7 +76,9 @@ public class AdminSpawn implements IAdminCommandHandler
"admin_list_positions",
"admin_spawn_debug_menu",
"admin_spawn_debug_print",
- "admin_spawn_debug_print_menu"
+ "admin_spawn_debug_print_menu",
+ "admin_topspawncount",
+ "admin_top_spawn_count"
};
@Override
@@ -370,6 +376,52 @@ public class AdminSpawn implements IAdminCommandHandler
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 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 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;
}
diff --git a/L2J_Mobius_3.0_Helios/dist/game/config/AdminCommands.xml b/L2J_Mobius_3.0_Helios/dist/game/config/AdminCommands.xml
index 820bdab5c2..02a5780011 100644
--- a/L2J_Mobius_3.0_Helios/dist/game/config/AdminCommands.xml
+++ b/L2J_Mobius_3.0_Helios/dist/game/config/AdminCommands.xml
@@ -532,6 +532,8 @@
+
+
diff --git a/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java b/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java
index 60bcced355..cebb103ccb 100644
--- a/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java
+++ b/L2J_Mobius_3.0_Helios/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java
@@ -16,7 +16,10 @@
*/
package handlers.admincommandhandlers;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.StringTokenizer;
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.util.Broadcast;
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
@@ -72,7 +76,9 @@ public class AdminSpawn implements IAdminCommandHandler
"admin_list_positions",
"admin_spawn_debug_menu",
"admin_spawn_debug_print",
- "admin_spawn_debug_print_menu"
+ "admin_spawn_debug_print_menu",
+ "admin_topspawncount",
+ "admin_top_spawn_count"
};
@Override
@@ -370,6 +376,52 @@ public class AdminSpawn implements IAdminCommandHandler
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 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 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;
}
diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/game/config/AdminCommands.xml b/L2J_Mobius_4.0_GrandCrusade/dist/game/config/AdminCommands.xml
index 820bdab5c2..02a5780011 100644
--- a/L2J_Mobius_4.0_GrandCrusade/dist/game/config/AdminCommands.xml
+++ b/L2J_Mobius_4.0_GrandCrusade/dist/game/config/AdminCommands.xml
@@ -532,6 +532,8 @@
+
+
diff --git a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java
index 60bcced355..cebb103ccb 100644
--- a/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java
+++ b/L2J_Mobius_4.0_GrandCrusade/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java
@@ -16,7 +16,10 @@
*/
package handlers.admincommandhandlers;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.StringTokenizer;
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.util.Broadcast;
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
@@ -72,7 +76,9 @@ public class AdminSpawn implements IAdminCommandHandler
"admin_list_positions",
"admin_spawn_debug_menu",
"admin_spawn_debug_print",
- "admin_spawn_debug_print_menu"
+ "admin_spawn_debug_print_menu",
+ "admin_topspawncount",
+ "admin_top_spawn_count"
};
@Override
@@ -370,6 +376,52 @@ public class AdminSpawn implements IAdminCommandHandler
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 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 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;
}
diff --git a/L2J_Mobius_5.0_Salvation/dist/game/config/AdminCommands.xml b/L2J_Mobius_5.0_Salvation/dist/game/config/AdminCommands.xml
index 820bdab5c2..02a5780011 100644
--- a/L2J_Mobius_5.0_Salvation/dist/game/config/AdminCommands.xml
+++ b/L2J_Mobius_5.0_Salvation/dist/game/config/AdminCommands.xml
@@ -532,6 +532,8 @@
+
+
diff --git a/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java b/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java
index 60bcced355..cebb103ccb 100644
--- a/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java
+++ b/L2J_Mobius_5.0_Salvation/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java
@@ -16,7 +16,10 @@
*/
package handlers.admincommandhandlers;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.StringTokenizer;
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.util.Broadcast;
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
@@ -72,7 +76,9 @@ public class AdminSpawn implements IAdminCommandHandler
"admin_list_positions",
"admin_spawn_debug_menu",
"admin_spawn_debug_print",
- "admin_spawn_debug_print_menu"
+ "admin_spawn_debug_print_menu",
+ "admin_topspawncount",
+ "admin_top_spawn_count"
};
@Override
@@ -370,6 +376,52 @@ public class AdminSpawn implements IAdminCommandHandler
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 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 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;
}
diff --git a/L2J_Mobius_5.5_EtinasFate/dist/game/config/AdminCommands.xml b/L2J_Mobius_5.5_EtinasFate/dist/game/config/AdminCommands.xml
index 820bdab5c2..02a5780011 100644
--- a/L2J_Mobius_5.5_EtinasFate/dist/game/config/AdminCommands.xml
+++ b/L2J_Mobius_5.5_EtinasFate/dist/game/config/AdminCommands.xml
@@ -532,6 +532,8 @@
+
+
diff --git a/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java b/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java
index 60bcced355..cebb103ccb 100644
--- a/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java
+++ b/L2J_Mobius_5.5_EtinasFate/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java
@@ -16,7 +16,10 @@
*/
package handlers.admincommandhandlers;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.StringTokenizer;
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.util.Broadcast;
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
@@ -72,7 +76,9 @@ public class AdminSpawn implements IAdminCommandHandler
"admin_list_positions",
"admin_spawn_debug_menu",
"admin_spawn_debug_print",
- "admin_spawn_debug_print_menu"
+ "admin_spawn_debug_print_menu",
+ "admin_topspawncount",
+ "admin_top_spawn_count"
};
@Override
@@ -370,6 +376,52 @@ public class AdminSpawn implements IAdminCommandHandler
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 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 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;
}
diff --git a/L2J_Mobius_C6_Interlude/dist/db_installer/sql/game/admin_command_access_rights.sql b/L2J_Mobius_C6_Interlude/dist/db_installer/sql/game/admin_command_access_rights.sql
index 95e88ecbdc..e73a4514c2 100644
--- a/L2J_Mobius_C6_Interlude/dist/db_installer/sql/game/admin_command_access_rights.sql
+++ b/L2J_Mobius_C6_Interlude/dist/db_installer/sql/game/admin_command_access_rights.sql
@@ -528,6 +528,8 @@ INSERT IGNORE INTO `admin_command_access_rights` VALUES
('admin_teleport_reload','3'),
('admin_spawnnight','3'),
('admin_spawnday','3'),
+('admin_topspawncount','3'),
+('admin_top_spawn_count','3'),
-- Section: Target
('admin_target','3'),
diff --git a/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/handler/admincommandhandlers/AdminSpawn.java b/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/handler/admincommandhandlers/AdminSpawn.java
index e25cf853bf..d4feaee701 100644
--- a/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/handler/admincommandhandlers/AdminSpawn.java
+++ b/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/handler/admincommandhandlers/AdminSpawn.java
@@ -16,6 +16,9 @@
*/
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.StringTokenizer;
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.model.L2Object;
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.entity.sevensigns.SevenSigns;
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.templates.chars.L2NpcTemplate;
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
@@ -59,7 +64,9 @@ public class AdminSpawn implements IAdminCommandHandler
"admin_show_npcs",
"admin_teleport_reload",
"admin_spawnnight",
- "admin_spawnday"
+ "admin_spawnday",
+ "admin_topspawncount",
+ "admin_top_spawn_count"
};
public static Logger LOGGER = Logger.getLogger(AdminSpawn.class.getName());
@@ -199,6 +206,52 @@ public class AdminSpawn implements IAdminCommandHandler
TeleportLocationTable.getInstance().reloadAll();
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 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 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;
}
diff --git a/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/util/Util.java b/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/util/Util.java
index d413849e72..6e2fc0c25a 100644
--- a/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/util/Util.java
+++ b/L2J_Mobius_C6_Interlude/java/com/l2jmobius/gameserver/util/Util.java
@@ -19,6 +19,10 @@ package com.l2jmobius.gameserver.util;
import java.io.File;
import java.io.IOException;
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.gameserver.model.L2Object;
@@ -542,4 +546,26 @@ public final class Util
{
return (objectsSize / pageSize) + ((objectsSize % pageSize) == 0 ? 0 : 1);
}
+
+ /**
+ * This will sort a Map according to the values. Default sort direction is ascending.
+ * @param keyType
+ * @param 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 > Map sortByValue(Map 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 > Map sortByValue(Map map)
+ {
+ return map.entrySet().stream().sorted(Map.Entry.comparingByValue()).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
+ }
}
diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/config/AdminCommands.xml b/L2J_Mobius_CT_2.6_HighFive/dist/game/config/AdminCommands.xml
index a6a4dc3e62..851032f0de 100644
--- a/L2J_Mobius_CT_2.6_HighFive/dist/game/config/AdminCommands.xml
+++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/config/AdminCommands.xml
@@ -530,6 +530,8 @@
+
+
diff --git a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java
index 847782ed0c..0ab9cb04d5 100644
--- a/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java
+++ b/L2J_Mobius_CT_2.6_HighFive/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java
@@ -16,7 +16,10 @@
*/
package handlers.admincommandhandlers;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.StringTokenizer;
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.util.Broadcast;
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
@@ -74,7 +78,9 @@ public class AdminSpawn implements IAdminCommandHandler
"admin_list_positions",
"admin_spawn_debug_menu",
"admin_spawn_debug_print",
- "admin_spawn_debug_print_menu"
+ "admin_spawn_debug_print_menu",
+ "admin_topspawncount",
+ "admin_top_spawn_count"
};
@Override
@@ -345,6 +351,52 @@ public class AdminSpawn implements IAdminCommandHandler
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 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 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;
}
diff --git a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/util/Util.java b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/util/Util.java
index 884c1d9557..6d4e5f0b18 100644
--- a/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/util/Util.java
+++ b/L2J_Mobius_CT_2.6_HighFive/java/com/l2jmobius/gameserver/util/Util.java
@@ -22,11 +22,15 @@ import java.text.DecimalFormatSymbols;
import java.text.NumberFormat;
import java.text.SimpleDateFormat;
import java.util.Arrays;
+import java.util.Collections;
import java.util.Date;
+import java.util.LinkedHashMap;
import java.util.Locale;
+import java.util.Map;
import java.util.StringJoiner;
import java.util.StringTokenizer;
import java.util.logging.Logger;
+import java.util.stream.Collectors;
import com.l2jmobius.Config;
import com.l2jmobius.commons.concurrent.ThreadPool;
@@ -958,4 +962,26 @@ public final class Util
return defaultVal;
}
}
+
+ /**
+ * This will sort a Map according to the values. Default sort direction is ascending.
+ * @param keyType
+ * @param 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 > Map sortByValue(Map 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 > Map sortByValue(Map map)
+ {
+ return map.entrySet().stream().sorted(Map.Entry.comparingByValue()).collect(Collectors.toMap(Map.Entry::getKey, Map.Entry::getValue, (e1, e2) -> e1, LinkedHashMap::new));
+ }
}
diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/AdminCommands.xml b/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/AdminCommands.xml
index bf744ea4c2..db0c13051b 100644
--- a/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/AdminCommands.xml
+++ b/L2J_Mobius_Classic_2.0_Saviors/dist/game/config/AdminCommands.xml
@@ -529,6 +529,8 @@
+
+
diff --git a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java
index 60bcced355..cebb103ccb 100644
--- a/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java
+++ b/L2J_Mobius_Classic_2.0_Saviors/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java
@@ -16,7 +16,10 @@
*/
package handlers.admincommandhandlers;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.StringTokenizer;
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.util.Broadcast;
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
@@ -72,7 +76,9 @@ public class AdminSpawn implements IAdminCommandHandler
"admin_list_positions",
"admin_spawn_debug_menu",
"admin_spawn_debug_print",
- "admin_spawn_debug_print_menu"
+ "admin_spawn_debug_print_menu",
+ "admin_topspawncount",
+ "admin_top_spawn_count"
};
@Override
@@ -370,6 +376,52 @@ public class AdminSpawn implements IAdminCommandHandler
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 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 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;
}
diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/game/config/AdminCommands.xml b/L2J_Mobius_Classic_2.1_Zaken/dist/game/config/AdminCommands.xml
index bf744ea4c2..db0c13051b 100644
--- a/L2J_Mobius_Classic_2.1_Zaken/dist/game/config/AdminCommands.xml
+++ b/L2J_Mobius_Classic_2.1_Zaken/dist/game/config/AdminCommands.xml
@@ -529,6 +529,8 @@
+
+
diff --git a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java
index 60bcced355..cebb103ccb 100644
--- a/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java
+++ b/L2J_Mobius_Classic_2.1_Zaken/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java
@@ -16,7 +16,10 @@
*/
package handlers.admincommandhandlers;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.StringTokenizer;
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.util.Broadcast;
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
@@ -72,7 +76,9 @@ public class AdminSpawn implements IAdminCommandHandler
"admin_list_positions",
"admin_spawn_debug_menu",
"admin_spawn_debug_print",
- "admin_spawn_debug_print_menu"
+ "admin_spawn_debug_print_menu",
+ "admin_topspawncount",
+ "admin_top_spawn_count"
};
@Override
@@ -370,6 +376,52 @@ public class AdminSpawn implements IAdminCommandHandler
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 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 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;
}
diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/game/config/AdminCommands.xml b/L2J_Mobius_Classic_2.2_Antharas/dist/game/config/AdminCommands.xml
index bf744ea4c2..db0c13051b 100644
--- a/L2J_Mobius_Classic_2.2_Antharas/dist/game/config/AdminCommands.xml
+++ b/L2J_Mobius_Classic_2.2_Antharas/dist/game/config/AdminCommands.xml
@@ -529,6 +529,8 @@
+
+
diff --git a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java
index 60bcced355..cebb103ccb 100644
--- a/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java
+++ b/L2J_Mobius_Classic_2.2_Antharas/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java
@@ -16,7 +16,10 @@
*/
package handlers.admincommandhandlers;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.StringTokenizer;
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.util.Broadcast;
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
@@ -72,7 +76,9 @@ public class AdminSpawn implements IAdminCommandHandler
"admin_list_positions",
"admin_spawn_debug_menu",
"admin_spawn_debug_print",
- "admin_spawn_debug_print_menu"
+ "admin_spawn_debug_print_menu",
+ "admin_topspawncount",
+ "admin_top_spawn_count"
};
@Override
@@ -370,6 +376,52 @@ public class AdminSpawn implements IAdminCommandHandler
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 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 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;
}
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/config/AdminCommands.xml b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/config/AdminCommands.xml
index bf744ea4c2..db0c13051b 100644
--- a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/config/AdminCommands.xml
+++ b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/config/AdminCommands.xml
@@ -529,6 +529,8 @@
+
+
diff --git a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java
index 60bcced355..cebb103ccb 100644
--- a/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java
+++ b/L2J_Mobius_Classic_2.3_SevenSigns/dist/game/data/scripts/handlers/admincommandhandlers/AdminSpawn.java
@@ -16,7 +16,10 @@
*/
package handlers.admincommandhandlers;
+import java.util.HashMap;
import java.util.List;
+import java.util.Map;
+import java.util.Map.Entry;
import java.util.NoSuchElementException;
import java.util.StringTokenizer;
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.util.Broadcast;
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
@@ -72,7 +76,9 @@ public class AdminSpawn implements IAdminCommandHandler
"admin_list_positions",
"admin_spawn_debug_menu",
"admin_spawn_debug_print",
- "admin_spawn_debug_print_menu"
+ "admin_spawn_debug_print_menu",
+ "admin_topspawncount",
+ "admin_top_spawn_count"
};
@Override
@@ -370,6 +376,52 @@ public class AdminSpawn implements IAdminCommandHandler
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 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 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;
}