-
Posts
3,908 -
Credits
0 -
Joined
-
Last visited
-
Days Won
64 -
Feedback
0%
Content Type
Articles
Profiles
Forums
Store
Everything posted by Trance
-
Hi, Admin command, scans a specified range around the admin. It gathers about players within the specified range, including their clan names, party leaders, and class names. Counting all players around can be a helpful task for admins. You could limit the scanning to players within the same region or zone as the admin - this would reduce the number of players to be processed and improve performance. Index: /main/L2GoldClassic/dist/game/config/AdminCommands.xml =================================================================== --- /main/L2GoldClassic/dist/game/config/AdminCommands.xml (revision 26) +++ /main/L2GoldClassic/dist/game/config/AdminCommands.xml (revision 27) @@ -626,4 +626,5 @@ <admin command="admin_scan" accessLevel="100" /> <admin command="admin_deleteNpcByObjectId" accessLevel="100" confirmDlg="true" /> + <admin command="admin_scan_players" accessLevel="50" /> <!-- ADMIN SERVERINFO --> Index: /main/L2GoldClassic/dist/game/data/scripts/handlers/MasterHandler.java =================================================================== --- /main/L2GoldClassic/dist/game/data/scripts/handlers/MasterHandler.java (revision 26) +++ /main/L2GoldClassic/dist/game/data/scripts/handlers/MasterHandler.java (revision 27) @@ -124,4 +124,5 @@ import handlers.admincommandhandlers.AdminRide; import handlers.admincommandhandlers.AdminScan; +import handlers.admincommandhandlers.AdminScanPlayers; import handlers.admincommandhandlers.AdminServerInfo; import handlers.admincommandhandlers.AdminShop; @@ -463,4 +464,5 @@ AdminRide.class, AdminScan.class, + AdminScanPlayers.class, AdminServerInfo.class, AdminShop.class, Index: /main/L2GoldClassic/dist/game/data/scripts/handlers/admincommandhandlers/AdminScanPlayers.java =================================================================== --- /main/L2GoldClassic/dist/game/data/scripts/handlers/admincommandhandlers/AdminScanPlayers.java (revision 27) +++ /main/L2GoldClassic/dist/game/data/scripts/handlers/admincommandhandlers/AdminScanPlayers.java (revision 27) @@ -0,0 +1,134 @@ +/* + * This file is part of the L2Gold Classic 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 handlers.admincommandhandlers; + +import java.util.ArrayList; +import java.util.HashMap; +import java.util.HashSet; +import java.util.List; +import java.util.Map; +import java.util.Set; +import java.util.stream.Collectors; + +import gold.lineage2.gameserver.data.sql.ClanTable; +import gold.lineage2.gameserver.handler.IAdminCommandHandler; +import gold.lineage2.gameserver.model.Location; +import gold.lineage2.gameserver.model.World; +import gold.lineage2.gameserver.model.actor.instance.PlayerInstance; +import gold.lineage2.gameserver.model.clan.Clan; +import gold.lineage2.gameserver.util.Util; + +/** + * @author Trance + */ +public class AdminScanPlayers implements IAdminCommandHandler +{ + private static final String[] ADMIN_COMMANDS = + { + "admin_scan_players" + }; + + @Override + public boolean useAdminCommand(String command, PlayerInstance player) + { + if (command.startsWith("admin_scan_players")) + { + String[] args = command.split(" "); + if (args.length > 1) + { + String rangeStr = args[1]; + scanPlayers(player, rangeStr); + } + else + { + player.sendMessage("Usage: //admin_scan_players <range>"); + } + } + return true; + } + + private void scanPlayers(PlayerInstance player, String rangeStr) + { + // Parse the range from the command arguments + int range = Util.parseNextInt(rangeStr, 0); + + // Get the player's location + Location playerLocation = player.getLocation(); + + // Initialize data structures for storing the scan results + Map<String, Set<String>> clanMembers = new HashMap<>(); + Map<String, Set<String>> partyMembers = new HashMap<>(); + Map<String, List<String>> classMembers = new HashMap<>(); + + // Iterate through all players in the game world + for (PlayerInstance otherPlayer : World.getInstance().getPlayers()) + { + // Check if the other player is within the specified range of the player + if (playerLocation.distanceTo(otherPlayer.getLocation()) <= range) + { + // Gather data for clans, parties, and classes + String clanName = otherPlayer.getClan() != null ? otherPlayer.getClan().getName() : "No Clan"; + String partyLeaderName = otherPlayer.getParty() != null ? otherPlayer.getParty().getLeader().getName() : null; + String className = otherPlayer.getTemplate().getClassId().name(); + + // Update the player lists for clans, parties, and classes + clanMembers.computeIfAbsent(clanName, k -> new HashSet<>()).add(otherPlayer.getName()); + if (partyLeaderName != null) + { + partyMembers.computeIfAbsent(partyLeaderName, k -> new HashSet<>()).add(otherPlayer.getName()); + } + classMembers.computeIfAbsent(className, k -> new ArrayList<>()).add(otherPlayer.getName()); + } + } + + // Display the scan results to the player + player.sendMessage("Scan Results:"); + player.sendMessage("Range: " + range); + player.sendMessage("Clans (" + clanMembers.size() + "):"); + for (Map.Entry<String, Set<String>> entry : clanMembers.entrySet()) + { + String clanLeaderName = "Unknown"; + Clan clan = ClanTable.getInstance().getClanByName(entry.getKey()); + if (clan != null) + { + PlayerInstance clanLeader = World.getInstance().getPlayer(clan.getLeaderId()); + if (clanLeader != null) + { + clanLeaderName = clanLeader.getName(); + } + } + player.sendMessage(" - " + entry.getKey() + " (Leader: " + clanLeaderName + "): " + entry.getValue().size() + " members"); + player.sendMessage(" Members: " + String.join(", ", entry.getValue())); + } + player.sendMessage("Parties (" + partyMembers.size() + "):"); + for (Map.Entry<String, Set<String>> entry : partyMembers.entrySet()) + { + player.sendMessage(" - Leader: " + entry.getKey() + ", " + entry.getValue().size() + " members"); + player.sendMessage(" Members: " + String.join(", ", entry.getValue())); + } + player.sendMessage("Classes (" + classMembers.size() + "):"); + for (Map.Entry<String, List<String>> entry : classMembers.entrySet()) + { + player.sendMessage(" - " + entry.getKey() + ": " + entry.getValue().size() + " players " + entry.getValue().stream().collect(Collectors.joining(", ", "(", ")"))); + } + } + + @Override + public String[] getAdminCommandList() + { + return ADMIN_COMMANDS; + } +} Index: /main/L2GoldClassic/java/gold/lineage2/gameserver/model/Location.java =================================================================== --- /main/L2GoldClassic/java/gold/lineage2/gameserver/model/Location.java (revision 26) +++ /main/L2GoldClassic/java/gold/lineage2/gameserver/model/Location.java (revision 27) @@ -56,4 +56,17 @@ _z = set.getInt("z"); _heading = set.getInt("heading", 0); + } + + /** + * Calculates the Euclidean distance between two 3D points in the world + * @param other + * @return + */ + public double distanceTo(Location other) + { + int dx = _x - other._x; + int dy = _y - other._y; + int dz = _z - other._z; + return Math.sqrt((dx * dx) + (dy * dy) + (dz * dz)); } Index: /main/L2GoldClassic/java/gold/lineage2/gameserver/util/Util.java =================================================================== --- /main/L2GoldClassic/java/gold/lineage2/gameserver/util/Util.java (revision 26) +++ /main/L2GoldClassic/java/gold/lineage2/gameserver/util/Util.java (revision 27) @@ -266,4 +266,22 @@ /** + * Tries to parse an integer from a string. If it fails, it returns the default value provided. + * @param value + * @param defaultValue + * @return + */ + public static int parseNextInt(String value, int defaultValue) + { + try + { + return Integer.parseInt(value); + } + catch (NumberFormatException e) + { + return defaultValue; + } + } + + /** * @param text - the text to check * @return {@code true} if {@code text} is float, {@code false} otherwise
-
- 4
-
-
-
The client side only changes the information and skill category. What you need to change on the server side is the target, skill type, operation type and effect to be Damage Over Time instead of Buff.
-
Help L2 J Mobius H5 Help
Trance replied to andy1984's question in Request Server Development Help [L2J]
I didn't read the whole code: final Player tmp = _player.getClient().getPlayer(); final Party party = tmp.getParty(); -
Help L2J Attack Delay
Trance replied to MoetsukiDansei's question in Request Server Development Help [L2J]
Kindly delete this code permanently. I'm not kidding. -
Help problem to create custom items (high five l2jserver)
Trance replied to Hadriel's question in Request Server Development Help [L2J]
You need the client side as well. -
Request WORKING HWID FOR L2JSERVER GRACIA FINAL
Trance replied to VegaBoy's question in Request Server Development Help [L2J]
It's necessary for you to indicate the pack and the type of client protection you're using. By default, I don't believe the client is capable of supporting that. -
Moved to client section.
-
Help L2 J Mobius H5 Help
Trance replied to andy1984's question in Request Server Development Help [L2J]
You don't need: final Player tmp = getClient().getPlayer(); Change: final Party party = tmp.getParty(); To: final Party party = _player.getParty(); -
stackType=""
-
Why would you even want to do that?
-
I have refreshed the GitHub repositories referenced in the main topic to enhance the coherence between the guides.
-
I've added Webmin Installation Guide - a web-based system administration tool.
-
WTS FullAccounts.net #1 Gaming Account Shop - 100+ Games
Trance replied to Manfruity's topic in Marketplace [Items & Chars]
Not related to Lineage 2. -
WTS PTS Vanganth C4 - Classic Interlude
Trance replied to ZOUMHS's topic in Marketplace [L2Packs & Files]
@ZOUMHS Please follow the rules: 10) Prices must be displayed (and visible) in public on the main topic. -
L2Gold Interlude on Essence Client - Dec 7 to May 7
Trance replied to Trance's topic in Private Servers
Topic renamed from L2Gold Classic to L2Gold Essence. We are excited to announce the expansion of our team for the remastered Essence chronicle. Our goal is to adopt a classic, long-lasting playstyle while still maintaining the legacy of the gold-style. With that in mind, we are thrilled to introduce the following members who will help us achieve this vision: Electronica: Our new Community Manager, Electronica brings a wealth of experience in community management to our team. He will represent the community and ensure that player needs and concerns are addressed to the Developer and other staff members. Electronica will also assist with communication and other aspects of the server. Psy: A Game Master with experience in various custom private servers, Psy will help ensure fair gameplay and assist with dispute resolution. He has a deep understanding of the server and its customizations. Techno: Another Game Master with experience in Interlude and all the latest chronicles, Techno brings a passion for gaming to our team. He will work alongside Psy and House to monitor gameplay and help maintain a fair and enjoyable game environment for all players. House: Another Game Master, our seasoned veteran, House, has been part of the World of Lineage community since the official release of Chronical C3 in 2005. As a project manager in real life, he brings his organizational skills and attention to detail to our team. He will work closely with the Game Masters to ensure that everything runs smoothly. AskForMore: Our Community Helper, AskForMore, is a familiar face to many players. He knows the server inside out and is always ready to assist with any questions or concerns. He will continue to be an essential part of our team. We are still looking for one more Game Master and two GM Helpers to join our team. Game Masters will be responsible for monitoring gameplay, resolving disputes, and ensuring a fair and enjoyable game environment. GM Helpers will assist the Game Masters with their duties and help monitor game activity. We are confident that our team of experienced and dedicated individuals will help us achieve our goal of providing a classic and enjoyable gaming experience. We look forward to working together and hope that you'll join us on this journey. Discord: https://discord.gg/zA5KWH8cMc -
WTS ETINA X4 or WTT for reborn x1
Trance replied to ScreamForMe's topic in Marketplace [Items & Chars]
Please follow the rules: 10) Prices must be displayed (and visible) in public on the main topic. -
WTS Epic set//Items//Augs on la2dream main
Trance replied to Dim23's topic in Marketplace [Items & Chars]
Please follow the rules: 10) Prices must be displayed (and visible) in public on the main topic. -
Please follow the rules: 10) Prices must be displayed (and visible) in public on the main topic.
-
Cool.
-
Thanks for pointing out that I forgot to add the installation of conntrack in my GitHub repository, as it is already integrated into this repository. To install conntrack, you can use the following command: sudo apt-get install conntrack -y it's possible that your system has some restrictions on the maximum allowed values for net.ipv4.tcp_rmem and net.ipv4.tcp_wmem, try to lower the values. It's basically min, default, max - receive buffer space for TCP connections. Which configuration did you try to apply? P.S. I've updated the GitHub repo.
-
It's time to focus on the most popular Linux distro. I've shared the following repositories on GitHub: Installing IPTables, Ipset, Conntrack and netfilter-persistent on Ubuntu Server 22.04 This guide will walk you through the process of installing IPTables, Ipset, Conntrack and netfilter-persistent on Ubuntu Server 22.04. netfilter-persistent: allow you to save and load your IPSET and IPTABLES rules automatically on boot. This ensures that your firewall settings are always loaded, even after a reboot. Optimizing Ubuntu 22.04 for Low Latency and High Performance This guide will walk you through the steps for optimizing your Ubuntu 22.04 system for low latency and high performance. The optimizations aim to improve the performance of a Linux-based system by modifying various network settings. Some of the changes include increasing the maximum number of open file descriptors, increasing the maximum number of processes, enabling TCP time-wait reuse, adjusting TCP keepalive time, setting the local port range for TCP connections, and increasing the maximum number of allowed concurrent network connections. Additionally, the values for the system's network buffer sizes are also increased to improve network performance. The optimizations aim to improve the system's overall stability and responsiveness in handling high network traffic. MariaDB installation and optimization on Ubuntu This guide explains how to install and optimize MariaDB on Ubuntu Checking if the script is run as root Checking if the script has been run before Updating package lists and upgrading packages Installing MariaDB if it's not already installed Prompting the user to select an optimization level (either to use up to 50% of total RAM and CPU, or up to 100% if MariaDB is the sole service on the server) Backing up the original MariaDB configuration file Calculating hardware-based settings (based on total memory and CPU cores) Configuring MariaDB performance settings based on the chosen optimization level and hardware Restarting the MariaDB service if the user agrees MariaDB Management Script for Ubuntu This shell script provides a simple way to manage MariaDB on Ubuntu 22.04 or newer. Creating, deleting, and flushing MariaDB users. Creating, deleting, and updating databases. Importing and exporting SQL files. Webmin Installation Guide for Ubuntu Server 22.04 Webmin is a web-based system administration tool for Unix/Linux systems that allows users to manage their system resources and services through a web interface. It provides a graphical user interface (GUI) for many common administrative tasks and simplifies the management of a Linux system for both novice and experienced users. System configuration: Webmin provides a GUI for configuring many aspects of your system, including network settings, user accounts, system services, and hardware settings. Package management: Webmin makes it easy to manage software packages on your system. You can view and install available packages, update installed packages, and configure package repositories. Server management: Webmin supports a variety of server applications, including Apache, MySQL, and PostgreSQL. You can configure server settings, manage virtual hosts and databases, and view server logs. File management: Webmin includes a file manager that allows you to browse and manage files on your system, including copying, moving, and deleting files. Monitoring: Webmin provides real-time monitoring of system resources such as CPU usage, memory usage, and disk space. You can also set up alerts to be notified when resource usage exceeds specified thresholds. Security: Webmin includes a variety of security features, including SSL/TLS encryption for web traffic, authentication and authorization for user accounts, and firewall configuration. Your feedback is welcome.
-
Use computeIfAbsent() to avoid creating empty effect maps for players with no effects. Use Entry in the forEach() loop instead of two parameters.
-
Code Bots prevention system, version 2.0!
Trance replied to Caparso's topic in Server Shares & Files [L2J]
My reply is strictly referring to server side.