### Eclipse Workspace Patch 1.0
#P L2j
Index: dist/game/data/html/admin/charinfo.htm
===================================================================
--- dist/game/data/html/admin/charinfo.htm (revision 37)
+++ dist/game/data/html/admin/charinfo.htm (working copy)
@@ -34,6 +34,9 @@
<tr>
<td>Account IP: </td><td><font color="LEVEL"><a action="bypass -h admin_find_ip %ip%">%ip%</a></font></td>
</tr>
+<tr>
+<td>HWID: </td><td><font color="LEVEL"><a action="bypass -h admin_find_hwid %hwid%">%hwid%</a></font></td>
+</tr>
<tr>
<td>Punishment: </td><td><font color="LEVEL"><a action="bypass -h admin_punishment player %name%">Info</a></font></td>
</tr>
Index: dist/game/data/html/admin/hwidfind.htm
===================================================================
--- dist/game/data/html/admin/hwidfind.htm (revision 0)
+++ dist/game/data/html/admin/hwidfind.htm (working copy)
@@ -0,0 +1,21 @@
+<html><body>
+<table width=270><tr>
+<td width=45><button value="Main" action="bypass -h admin_admin" width=45 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
+<td width=180><center>HWID Menu</center></td>
+<td width=45><button value="Back" action="bypass -h admin_find_dualbox" width=45 height=21 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF"></td>
+</tr></table><br>
+Characters logged from <font color="LEVEL">%hwid%</font>:<br>
+Found %number% character%end%<br><br>
+<table width=270>
+<tr><td width=80><font color="LEVEL">Name</font></td><td width=110><font color="LEVEL">Class</font></td><td width=40><font color="LEVEL">Level</font></td></tr>
+%results%
+</table>
+<center>
+<br>
+<br>
+<font color="LEVEL">Ban HWID</font><br>
+Reason:
+<edit var="reason" width=200><br>
+<button value="Ban HWID!" action="bypass -h admin_ban_hwid %hwid% $reason" width=100 height=23 back="L2UI_CT1.Button_DF_Down" fore="L2UI_CT1.Button_DF">
+</center>
+</body></html>
\ No newline at end of file
Index: dist/game/data/scripts/handlers/MasterHandler.java
===================================================================
--- dist/game/data/scripts/handlers/MasterHandler.java (revision 37)
+++ dist/game/data/scripts/handlers/MasterHandler.java (working copy)
@@ -85,6 +85,7 @@
import handlers.admincommandhandlers.AdminGmChat;
import handlers.admincommandhandlers.AdminGraciaSeeds;
import handlers.admincommandhandlers.AdminGrandBoss;
+import handlers.admincommandhandlers.AdminHWID;
import handlers.admincommandhandlers.AdminHeal;
import handlers.admincommandhandlers.AdminHtml;
import handlers.admincommandhandlers.AdminInstance;
@@ -366,6 +367,7 @@
AdminGrandBoss.class,
AdminHeal.class,
AdminHtml.class,
+ AdminHWID.class,
AdminInstance.class,
AdminInstanceZone.class,
AdminInvul.class,
Index: dist/game/data/scripts/handlers/admincommandhandlers/AdminHWID.java
===================================================================
--- dist/game/data/scripts/handlers/admincommandhandlers/AdminHWID.java (revision 0)
+++ dist/game/data/scripts/handlers/admincommandhandlers/AdminHWID.java (working copy)
@@ -0,0 +1,183 @@
+/*
+ * Copyright © 2004-2014 L2J DataPack
+ *
+ * This file is part of L2J DataPack.
+ *
+ * L2J DataPack 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.
+ *
+ * L2J DataPack 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.Comparator;
+import java.util.StringTokenizer;
+
+import com.l2jserver.gameserver.datatables.ClassListData;
+import com.l2jserver.gameserver.handler.IAdminCommandHandler;
+import com.l2jserver.gameserver.model.L2World;
+import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
+import com.l2jserver.gameserver.network.serverpackets.NpcHtmlMessage;
+import com.l2jserver.util.StringUtil;
+
+/**
+ * HWID manage admin commands.
+ * @author St3eT
+ */
+public class AdminHWID implements IAdminCommandHandler
+{
+ private static final String[] ADMIN_COMMANDS =
+ {
+ "admin_find_hwid",
+ "admin_ban_hwid",
+ };
+
+ @Override
+ public boolean useAdminCommand(String command, L2PcInstance activeChar)
+ {
+ final StringTokenizer st = new StringTokenizer(command, " ");
+ final String actualCommand = st.nextToken();
+
+ switch (actualCommand)
+ {
+ case "admin_find_hwid":
+ {
+ if (st.hasMoreTokens())
+ {
+ findPlayersByHWID(activeChar, st.nextToken());
+ }
+ else
+ {
+ activeChar.sendMessage("Usage: //find_hwid <hwid>");
+ }
+ break;
+ }
+ case "admin_ban_hwid":
+ {
+ if (st.countTokens() >= 2)
+ {
+ String hwid = st.nextToken();
+ String reason = "";
+
+ while (st.hasMoreTokens())
+ {
+ reason += st.nextToken() + " ";
+ }
+ banHWID(activeChar, hwid, reason);
+ }
+ else
+ {
+ activeChar.sendMessage("Usage: //ban_hwid <hwid>");
+ }
+ }
+ }
+ return true;
+ }
+
+ private void findPlayersByHWID(L2PcInstance activeChar, String searchHWID) throws IllegalArgumentException
+ {
+ int CharactersFound = 0;
+ final StringBuilder replyMSG = new StringBuilder(1000);
+ final NpcHtmlMessage adminReply = new NpcHtmlMessage(0, 1);
+ adminReply.setFile(activeChar.getHtmlPrefix(), "data/html/admin/hwidfind.htm");
+ for (L2PcInstance player : L2World.getInstance().getPlayersSortedBy(Comparator.comparingLong(L2PcInstance::getUptime)))
+ {
+ final String hwid = player.getHWID();
+ if (!hwid.equals(searchHWID))
+ {
+ continue;
+ }
+
+ final String name = player.getName();
+ CharactersFound = CharactersFound + 1;
+ StringUtil.append(replyMSG, "<tr><td width=80><a action=\"bypass -h admin_character_info ", name, "\">", name, "</a></td><td width=110>", ClassListData.getInstance().getClass(player.getClassId()).getClientCode(), "</td><td width=40>", String.valueOf(player.getLevel()), "</td></tr>");
+
+ if (CharactersFound > 20)
+ {
+ break;
+ }
+ }
+ adminReply.replace("%results%", replyMSG.toString());
+
+ final String replyMSG2;
+
+ if (CharactersFound == 0)
+ {
+ replyMSG2 = "s. Maybe they got d/c? :)";
+ }
+ else if (CharactersFound > 20)
+ {
+ adminReply.replace("%number%", " more than " + String.valueOf(CharactersFound));
+ replyMSG2 = "s.<br>In order to avoid you a client crash I won't <br1>display results beyond the 20th character.";
+ }
+ else if (CharactersFound == 1)
+ {
+ replyMSG2 = ".";
+ }
+ else
+ {
+ replyMSG2 = "s.";
+ }
+ adminReply.replace("%hwid%", searchHWID);
+ adminReply.replace("%number%", String.valueOf(CharactersFound));
+ adminReply.replace("%end%", replyMSG2);
+ activeChar.sendPacket(adminReply);
+ }
+
+ private L2PcInstance getFirstPlayerHWID(String HWID)
+ {
+ L2PcInstance player = null;
+ for (L2PcInstance searchPlayer : L2World.getInstance().getPlayersSortedBy(Comparator.comparingLong(L2PcInstance::getUptime)))
+ {
+ final String hwid = searchPlayer.getHWID();
+ if (!hwid.equals(HWID))
+ {
+ continue;
+ }
+ player = searchPlayer;
+ }
+ return player;
+ }
+
+ private void kickAllBanned(String HWID)
+ {
+ for (L2PcInstance player : L2World.getInstance().getPlayers())
+ {
+ if (player.getHWID().equals(HWID))
+ {
+ player.logout(true);
+ }
+ }
+ }
+
+ private void banHWID(L2PcInstance activeChar, String HWID, String reason)
+ {
+ final L2PcInstance player = getFirstPlayerHWID(HWID);
+
+ if ((player != null) && (player.getClient() != null))
+ {
+ com.lameguard.BanList.getInstance().addHWID(HWID, player.getClient().getConnection().getInetAddress().getHostAddress(), player.getAccountName(), reason);
+ com.lameguard.BanList.getInstance().reload();
+ kickAllBanned(HWID);
+ activeChar.sendMessage("HWID " + HWID + " has been banned!");
+ }
+ else
+ {
+ activeChar.sendMessage("Error! Player or player's client is null!");
+ }
+ }
+
+ @Override
+ public String[] getAdminCommandList()
+ {
+ return ADMIN_COMMANDS;
+ }
+}
\ No newline at end of file
Index: dist/game/config/adminCommands.xml
===================================================================
--- dist/game/config/adminCommands.xml (revision 37)
+++ dist/game/config/adminCommands.xml (working copy)
@@ -604,6 +604,10 @@
<!-- ADMIN NEXUS EVENT ENGINE -->
<admin command="admin_event_manage" accessLevel="7" />
+ <!-- ADMIN HWID -->
+ <admin command="admin_find_hwid" accessLevel="7" />
+ <admin command="admin_ban_hwid" accessLevel="7" confirmDlg="true" />
+
<!-- VOICE COMMANDS -->
<admin command="banchat" accessLevel="7" />
<admin command="debug" accessLevel="7" />