Change nickname, emote and color.

Contributed by Serenitty.
This commit is contained in:
MobiusDevelopment 2022-10-15 01:54:25 +00:00
parent 232c2d37aa
commit eff401ff2a
7 changed files with 171 additions and 9 deletions

View File

@ -20,7 +20,7 @@ import org.l2jmobius.gameserver.handler.IItemHandler;
import org.l2jmobius.gameserver.model.actor.Playable;
import org.l2jmobius.gameserver.model.item.instance.Item;
import org.l2jmobius.gameserver.network.SystemMessageId;
import org.l2jmobius.gameserver.network.serverpackets.ExRequestChangeNicknameColor;
import org.l2jmobius.gameserver.network.serverpackets.ExChangeNicknameEmote;
public class NicknameColor implements IItemHandler
{
@ -33,7 +33,7 @@ public class NicknameColor implements IItemHandler
return false;
}
playable.sendPacket(new ExRequestChangeNicknameColor(item.getId()));
playable.sendPacket(new ExChangeNicknameEmote(item.getId()));
return true;
}
}

View File

@ -873,9 +873,10 @@
<set name="material" val="PAPER" />
<set name="weight" val="5" />
<set name="is_dropable" val="false" />
<set name="is_stackable" val="true" />
<set name="is_tradable" val="false" />
<set name="is_sellable" val="false" />
<set name="is_stackable" val="true" />
<set name="is_freightable" val="true" />
<set name="handler" val="NicknameColor" />
</item>
<item id="49663" name="Special HP Recovery Potion" type="EtcItem">
<!-- Momentarily recovers 500 HP. If HP is full, CP is recovered. -->

View File

@ -1043,9 +1043,10 @@
<set name="immediate_effect" val="true" />
<set name="material" val="PAPER" />
<set name="weight" val="5" />
<set name="is_tradable" val="false" />
<set name="is_dropable" val="false" />
<set name="is_sellable" val="false" />
<set name="is_stackable" val="true" />
<set name="is_freightable" val="true" />
<set name="handler" val="NicknameColor" />
</item>
<item id="94765" name="Lv. 90 Achievement Reward Box" additionalName="Sealed" type="EtcItem">
<!-- Double-click to obtain the following. -->

View File

@ -1459,9 +1459,10 @@
<set name="immediate_effect" val="true" />
<set name="material" val="PAPER" />
<set name="weight" val="5" />
<set name="is_tradable" val="false" />
<set name="is_dropable" val="false" />
<set name="is_sellable" val="false" />
<set name="is_stackable" val="true" />
<set name="is_freightable" val="true" />
<set name="handler" val="NicknameColor" />
</item>
<item id="95893" name="Monsters Only_Sword - Not Available" additionalName="Not Available" type="Weapon">
<!-- The item is not available. Monster weapon. One-handed Sword. -->

View File

@ -734,7 +734,7 @@ public enum ExIncomingPackets implements IIncomingPackets<GameClient>
EX_DETHRONE_CHANGE_NAME(0x204, null, ConnectionState.IN_GAME),
EX_DETHRONE_CONNECT_CASTLE(0x205, null, ConnectionState.IN_GAME),
EX_DETHRONE_DISCONNECT_CASTLE(0x206, null, ConnectionState.IN_GAME),
EX_CHANGE_NICKNAME_COLOR_ICON(0x207, null, ConnectionState.IN_GAME),
EX_CHANGE_NICKNAME_COLOR_ICON(0x207, RequestChangeNicknameEmote::new, ConnectionState.IN_GAME),
EX_WORLDCASTLEWAR_MOVE_TO_HOST(0x208, null, ConnectionState.IN_GAME),
EX_WORLDCASTLEWAR_RETURN_TO_ORIGIN_PEER(0x209, null, ConnectionState.IN_GAME),
EX_WORLDCASTLEWAR_CASTLE_INFO(0x20A, null, ConnectionState.IN_GAME),

View File

@ -0,0 +1,118 @@
/*
* This file is part of the L2J Mobius 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 org.l2jmobius.gameserver.network.clientpackets;
import org.l2jmobius.commons.network.PacketReader;
import org.l2jmobius.gameserver.model.actor.Player;
import org.l2jmobius.gameserver.model.item.instance.Item;
import org.l2jmobius.gameserver.network.GameClient;
import org.l2jmobius.gameserver.network.SystemMessageId;
/**
* @author Serenitty
*/
public class RequestChangeNicknameEmote implements IClientIncomingPacket
{
private static final int ESPECIAL_COLOR_TITLE_EMOTE = 95892;
private static final int ESPECIAL_COLOR_TITLE_SEALED = 94764;
private static final int ESPECIAL_STYLISH_COLOR_TITLE = 49662;
private static final int[] COLORS =
{
0x9393FF, // Pink 1
0x7C49FC, // Rose Pink 2
0x97F8FC, // Yellow 3
0xFA9AEE, // Lilac 4
0xFF5D93, // Cobalt Violet 5
0x00FCA0, // Mint Green 6
0xA0A601, // Peacock Green 7
0x7898AF, // Ochre 8
0x486295, // Chocolate 9
0x999999, // Silver 10 ** good here
0xF3DC09, // SkyBlue 11
0x05D3F6, // Gold 12
0x3CB1F4, // Orange 13
0xF383F3, // Pink 14
0x0909F3, // Red 15
0xF3DC09, // SkyBlue 16
0x000000, // dummy
};
private int _colorNum;
private int _itemId;
private String _title;
@Override
public boolean read(GameClient client, PacketReader packet)
{
_itemId = packet.readD();
_colorNum = packet.readD();
_title = packet.readString();
return true;
}
@Override
public void run(GameClient client)
{
final Player player = client.getPlayer();
if (player == null)
{
return;
}
final Item item = player.getInventory().getItemByItemId(_itemId);
if ((item == null) || (item.getEtcItem() == null) || (item.getEtcItem().getHandlerName() == null) || !item.getEtcItem().getHandlerName().equalsIgnoreCase("NicknameColor"))
{
return;
}
if ((_colorNum < 0) || (_colorNum >= COLORS.length))
{
return;
}
if (_title.contains("{"))
{
player.sendMessage("Cannot use this type of characters {}");
return;
}
if (((_itemId == ESPECIAL_COLOR_TITLE_EMOTE) || (_itemId == ESPECIAL_COLOR_TITLE_SEALED) || (_itemId == ESPECIAL_STYLISH_COLOR_TITLE)) && player.destroyItem("Consume", item, 1, null, true))
{
player.setTitle(_title);
player.getAppearance().setTitleColor(COLORS[_colorNum - 1]);
player.broadcastUserInfo();
player.sendPacket(SystemMessageId.YOUR_TITLE_HAS_BEEN_CHANGED);
return;
}
if (player.destroyItem("Consume", item, 1, null, true))
{
int skyblue = _colorNum - 2;
if ((skyblue > 11) && (player.getLevel() >= 90))
{
skyblue = 15;
}
player.setTitle(_title);
player.sendPacket(SystemMessageId.YOUR_TITLE_HAS_BEEN_CHANGED);
player.getAppearance().setTitleColor(COLORS[skyblue]);
player.broadcastUserInfo();
}
}
}

View File

@ -0,0 +1,41 @@
/*
* This file is part of the L2J Mobius 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 org.l2jmobius.gameserver.network.serverpackets;
import org.l2jmobius.commons.network.PacketWriter;
import org.l2jmobius.gameserver.network.OutgoingPackets;
/**
* @author Serenitty
*/
public class ExChangeNicknameEmote implements IClientOutgoingPacket
{
private final int _itemId;
public ExChangeNicknameEmote(int itemId)
{
_itemId = itemId;
}
@Override
public boolean write(PacketWriter packet)
{
OutgoingPackets.EX_CHANGE_NICKNAME_COLOR_ICON.writeId(packet);
packet.writeD(_itemId);
return true;
}
}