Noticias:

No tienes permiso para ver los enlaces. Para poder verlos Registrate o Conectate.

Menú Principal

Item Name Color

Iniciado por Swarlog, Jul 27, 2025, 12:34 AM

Tema anterior - Siguiente tema

Swarlog


CitarCORE:

Index: java/net/sf/l2j/gameserver/handler/ItemHandler.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/ItemHandler.java	(revision 21)
+++ java/net/sf/l2j/gameserver/handler/ItemHandler.java	(working copy)
@@ -31,6 +31,7 @@
 import net.sf.l2j.gameserver.handler.itemhandlers.Keys;
 import net.sf.l2j.gameserver.handler.itemhandlers.Maps;
 import net.sf.l2j.gameserver.handler.itemhandlers.MercTicket;
+import net.sf.l2j.gameserver.handler.itemhandlers.NameChange;
 import net.sf.l2j.gameserver.handler.itemhandlers.PaganKeys;
 import net.sf.l2j.gameserver.handler.itemhandlers.PetFood;
 import net.sf.l2j.gameserver.handler.itemhandlers.Recipes;
@@ -70,6 +71,7 @@
 		registerItemHandler(new Keys());
 		registerItemHandler(new Maps());
 		registerItemHandler(new MercTicket());
+		registerItemHandler(new NameChange());
 		registerItemHandler(new PaganKeys());
 		registerItemHandler(new PetFood());
 		registerItemHandler(new Recipes());
Index: java/net/sf/l2j/gameserver/handler/itemhandlers/NameChange.java
===================================================================
--- java/net/sf/l2j/gameserver/handler/itemhandlers/NameChange.java	(revision 0)
+++ java/net/sf/l2j/gameserver/handler/itemhandlers/NameChange.java	(working copy)
@@ -0,0 +1,43 @@
+/*
+ * 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 net.sf.l2j.gameserver.handler.itemhandlers;
+
+import net.sf.l2j.gameserver.handler.IItemHandler;
+import net.sf.l2j.gameserver.model.actor.L2Playable;
+import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
+import net.sf.l2j.gameserver.model.item.instance.ItemInstance;
+import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
+import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
+
+/**
+ * @author rapfersan92
+ */
+public class NameChange implements IItemHandler
+{
+	@Override
+	public void useItem(L2Playable playable, ItemInstance item, boolean forceUse)
+	{
+		if (!(playable instanceof L2PcInstance))
+			return;
+		
+		final L2PcInstance activeChar = (L2PcInstance) playable;
+		activeChar.setNameChangeItemId(item.getItemId());
+		
+		final NpcHtmlMessage html = new NpcHtmlMessage(0);
+		html.setFile("data/html/mods/NameChange.htm");
+		activeChar.sendPacket(html);
+		activeChar.sendPacket(ActionFailed.STATIC_PACKET);
+	}
+}
\ No newline at end of file
Index: java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java
===================================================================
--- java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java	(revision 21)
+++ java/net/sf/l2j/gameserver/model/actor/instance/L2PcInstance.java	(working copy)
@@ -10705,4 +10705,16 @@
 				break;
 		}
 	}
+	
+	private int _nameChangeItemId = 0;
+	
+	public int getNameChangeItemId()
+	{
+		return _nameChangeItemId;
+	}
+	
+	public void setNameChangeItemId(int itemId)
+	{
+		_nameChangeItemId = itemId;
+	}
 }
\ No newline at end of file
Index: java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java
===================================================================
--- java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java	(revision 21)
+++ java/net/sf/l2j/gameserver/network/clientpackets/RequestBypassToServer.java	(working copy)
@@ -18,8 +18,10 @@
 import java.util.logging.Level;
 
 import net.sf.l2j.Config;
+import net.sf.l2j.commons.lang.StringUtil;
 import net.sf.l2j.gameserver.communitybbs.CommunityBoard;
 import net.sf.l2j.gameserver.datatables.AdminCommandAccessRights;
+import net.sf.l2j.gameserver.datatables.CharNameTable;
 import net.sf.l2j.gameserver.handler.AdminCommandHandler;
 import net.sf.l2j.gameserver.handler.IAdminCommandHandler;
 import net.sf.l2j.gameserver.model.L2Object;
@@ -31,7 +33,9 @@
 import net.sf.l2j.gameserver.model.olympiad.OlympiadManager;
 import net.sf.l2j.gameserver.network.SystemMessageId;
 import net.sf.l2j.gameserver.network.serverpackets.ActionFailed;
+import net.sf.l2j.gameserver.network.serverpackets.ExShowScreenMessage;
 import net.sf.l2j.gameserver.network.serverpackets.NpcHtmlMessage;
+import net.sf.l2j.gameserver.network.serverpackets.PlaySound;
 import net.sf.l2j.gameserver.util.FloodProtectors;
 import net.sf.l2j.gameserver.util.FloodProtectors.Action;
 import net.sf.l2j.gameserver.util.GMAudit;
@@ -181,6 +185,46 @@
 				final int arenaId = Integer.parseInt(_command.substring(12).trim());
 				activeChar.enterOlympiadObserverMode(arenaId);
 			}
+			else if (_command.startsWith("name_change"))
+			{
+				try
+				{
+					String name = _command.substring(12);
+					if (name.length() > 16)
+					{
+						activeChar.sendMessage("The chosen name cannot exceed 16 characters in length.");
+						return;
+					}
+					
+					if (!StringUtil.isValidPlayerName(name))
+					{
+						activeChar.sendMessage("The chosen name does not fit with the regex pattern.");
+						return;
+					}
+					
+					synchronized (CharNameTable.getInstance())
+					{
+						if (CharNameTable.doesCharNameExist(name))
+						{
+							activeChar.sendMessage("The chosen name already exists.");
+							return;
+						}
+					}
+					
+					if (activeChar.destroyItemByItemId("Name Change", activeChar.getNameChangeItemId(), 1, null, true))
+					{
+						activeChar.setName(name);
+						activeChar.sendPacket(new ExShowScreenMessage("Congratulations. Your name has been changed.", 10000));
+						activeChar.sendPacket(new PlaySound("ItemSound.quest_finish"));
+						activeChar.broadcastUserInfo();
+						activeChar.store();
+					}
+				}
+				catch (Exception e)
+				{
+					activeChar.sendMessage("Fill out the field correctly.");
+				}
+			}
 		}
 		catch (Exception e)
 		{

CitarDATA:

Index: data/html/mods/NameChange.htm
===================================================================
--- data/html/mods/NameChange.htm	(revision 0)
+++ data/html/mods/NameChange.htm	(working copy)
@@ -0,0 +1,26 @@
+<html>
+	<body>
+		<center>
+			<table width="256">
+				<tr><td width="256" align="center">Name Change</td></tr>
+			</table>
+			<br>
+			<table width="256">
+				<tr><td width="256" align="left">The name change service allows you to change the name of your character as it appears in-game.</td></tr>
+			</table>
+			<br>
+			<table width="160" cellspacing="2">
+				<tr><td width="160" align="center">Name</td></tr>
+				<tr><td width="160" align="center"><edit var="name" width="160" height="12"></td>
+			</table>
+			<br>
+			<table width="95" cellspacing="2">
+				<tr><td width="95" align="center"><button action="bypass -h name_change $name" value="Change!" width="95" height="21" back="bigbutton_over" fore="bigbutton"></td></tr>
+			</table>
+			<br>
+			<table width="256">
+				<tr><td width="256" align="center">L2jBrasil</td></tr>
+			</table>
+		</center>
+	</body>
+</html>
\ No newline at end of file