Hello I have I section on my community board that have Services, like Change Gender, Pk Cleaner, Noblesse, etc. I want to add a option to change the name. I add the code but when I enter the name on the box, instead of change the name to what I enter in the box I get the bypass as my name like:
;Name;$newName
How can I fix that?
Here is my code.
package com.l2jserver.gameserver.communitybbs.Managers;
import java.sql.Connection;
import java.sql.PreparedStatement;
import java.util.StringTokenizer;
import java.util.logging.Logger;
import java.util.regex.Matcher;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import com.l2jserver.Config;
import com.l2jserver.L2DatabaseFactory;
import com.l2jserver.gameserver.cache.HtmCache;
import com.l2jserver.gameserver.communitybbs.Manager.BaseBBSManager;
import com.l2jserver.gameserver.communitybbs.Manager.RegionBBSManager;
import com.l2jserver.gameserver.datatables.CharNameTable;
import com.l2jserver.gameserver.model.L2World;
import com.l2jserver.gameserver.model.actor.instance.L2PcInstance;
import com.l2jserver.gameserver.network.SystemMessageId;
import com.l2jserver.gameserver.network.serverpackets.ExBrExtraUserInfo;
import com.l2jserver.gameserver.network.serverpackets.MagicSkillUse;
import com.l2jserver.gameserver.network.serverpackets.PartySmallWindowAll;
import com.l2jserver.gameserver.network.serverpackets.PartySmallWindowDeleteAll;
import com.l2jserver.gameserver.network.serverpackets.PledgeShowMemberListAll;
import com.l2jserver.gameserver.network.serverpackets.PledgeShowMemberListUpdate;
import com.l2jserver.gameserver.network.serverpackets.ShowBoard;
import com.l2jserver.gameserver.network.serverpackets.SystemMessage;
import com.l2jserver.gameserver.network.serverpackets.UserInfo;
import com.l2jserver.gameserver.util.Util;
public class ServiceBBSManager extends BaseBBSManager
{
public static final Logger _log = Logger.getLogger(ServiceBBSManager.class.getName());
public ServiceBBSManager()
{
}
@Override
public void parsecmd(String command, L2PcInstance activeChar)
{
if (command.equals("_bbsservice"))
{
sendHtm(activeChar, "data/html/CommunityBoard/42.htm");
}
else if (command.startsWith("_bbsservice;"))
{
StringTokenizer st = new StringTokenizer(command, ";");
st.nextToken();
String param = st.nextToken();
if (param.equalsIgnoreCase("Noobles"))
{
if (activeChar.getInventory().getItemByItemId(Config.NoblItemId) == null)
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOT_ENOUGH_ITEMS));
return;
}
if (activeChar.getInventory().getItemByItemId(Config.NoblItemId).getCount() < Config.NoblItemCount)
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOT_ENOUGH_ITEMS));
return;
}
if (activeChar.getClassId().level() < 3)
{
activeChar.sendMessage("You must have third class.");
return;
}
if (activeChar.isNoble())
{
activeChar.sendMessage("You already have nobless.");
return;
}
activeChar.destroyItemByItemId("ShopBBS", Config.NoblItemId, Config.NoblItemCount, activeChar, true);
activeChar.setNoble(true);
activeChar.setTarget(activeChar);
activeChar.broadcastPacket(new MagicSkillUse(activeChar, 5103, 1, 1000, 0));
activeChar.broadcastUserInfo();
activeChar.sendMessage("You are now a Noblesse Character.");
}
else if (param.equalsIgnoreCase("Gender"))
{
if (activeChar.getInventory().getItemByItemId(Config.GenderItemId) == null)
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOT_ENOUGH_ITEMS));
return;
}
if (activeChar.getInventory().getItemByItemId(Config.GenderItemId).getCount() < Config.GenderItemCount)
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOT_ENOUGH_ITEMS));
return;
}
activeChar.destroyItemByItemId("ShopBBS", Config.GenderItemId, Config.GenderItemCount, activeChar, true);
activeChar.getAppearance().setSex(activeChar.getAppearance().getSex() ? false : true);
activeChar.setTarget(activeChar);
activeChar.broadcastPacket(new MagicSkillUse(activeChar, 5103, 1, 1000, 0));
activeChar.broadcastUserInfo();
activeChar.sendMessage("You have change your Gender successfully.");
}
else if (param.equalsIgnoreCase("RecoveryPK"))
{
if (activeChar.getInventory().getItemByItemId(Config.RecoveryPKItemId) == null)
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOT_ENOUGH_ITEMS));
return;
}
if (activeChar.getInventory().getItemByItemId(Config.RecoveryPKItemId).getCount() < Config.RecoveryPKItemCount)
{
activeChar.sendPacket(SystemMessage.getSystemMessage(SystemMessageId.NOT_ENOUGH_ITEMS));
return;
}
activeChar.destroyItemByItemId("ShopBBS", Config.RecoveryPKItemId, Config.RecoveryPKItemCount, activeChar, true);
activeChar.setKarma(0);
activeChar.setPkKills(0);
activeChar.broadcastUserInfo();
activeChar.sendPacket(new UserInfo(activeChar));
activeChar.sendPacket(new ExBrExtraUserInfo(activeChar));
activeChar.sendMessage("You have clean your Pks.");
}
else if (command.equalsIgnoreCase("Name"))
{
try
{
String _name = command.substring(11);
String errorMsg = null;
boolean proceed = true;
if (_name.length() <= 2)
{
errorMsg = "Names have to be at least 3 characters";
activeChar.sendMessage("Names have to be at least 3 characters");
proceed = false;
}
if (_name.length() >= 17)
{
errorMsg = "Names cannot be longer than 16 characters";
activeChar.sendMessage("Names cannot be longer than 16 characters");
proceed = false;
}
if ((!Util.isAlphaNumeric(_name)) || (!isValidName(_name)))
{
errorMsg = "Invalid name";
activeChar.sendMessage("Names can Only have letters and numbers");
proceed = false;
}
if (CharNameTable.getInstance().getIdByName(_name) > 0)
{
errorMsg = "Name already exists";
activeChar.sendMessage((new StringBuilder()).append("Warning, name ").append(_name).append(" already exists.").toString());
proceed = false;
}
if (!proceed)
{
activeChar.sendMessage(errorMsg);
}
activeChar.destroyItemByItemId("ShopBBS", Config.NameItemId, Config.NameItemCount, activeChar, true);
L2World.getInstance().removeFromAllPlayers(activeChar);
activeChar.setName(_name);
activeChar.store();
L2World.getInstance().addToAllPlayers(activeChar);
activeChar.sendMessage("Your new character name is " + _name);
activeChar.broadcastUserInfo();
try (Connection con = L2DatabaseFactory.getInstance().getConnection();
PreparedStatement statement = con.prepareStatement("UPDATE characters SET char_name=? WHERE charId=?"))
{
statement.setString(1, _name);
statement.setInt(2, activeChar.getObjectId());
statement.execute();
statement.close();
}
catch (Exception e)
{
_log.info("Error updating name for player " + activeChar.getName() + ". Error: " + e);
}
if (activeChar.isInParty())
{
// Delete party window for other party members
activeChar.getParty().broadcastToPartyMembers(activeChar, new PartySmallWindowDeleteAll());
for (final L2PcInstance member : activeChar.getParty().getMembers())
{
// And re-add
if (member != activeChar)
{
member.sendPacket(new PartySmallWindowAll(activeChar, activeChar.getParty()));
}
}
}
if (activeChar.getClan() != null)
{
activeChar.getClan().updateClanMember(activeChar);
activeChar.getClan().broadcastToOnlineMembers(new PledgeShowMemberListUpdate(activeChar));
activeChar.sendPacket(new PledgeShowMemberListAll(activeChar.getClan(), activeChar));
}
RegionBBSManager.getInstance().changeCommunityBoard();
}
catch (StringIndexOutOfBoundsException e)
{ // Case of empty character name
activeChar.sendMessage("error: Something went wrong");
}
}
else
{
ShowBoard sb = new ShowBoard((new StringBuilder()).append("<html><body><br><br><center>the command: ").append(command).append(" is not implemented yet</center><br><br></body></html>").toString(), "101");
activeChar.sendPacket(sb);
activeChar.sendPacket(new ShowBoard(null, "102"));
activeChar.sendPacket(new ShowBoard(null, "103"));
}
}
}
private boolean sendHtm(L2PcInstance player, String path)
{
String oriPath = path;
if ((player.getLang() != null) && !player.getLang().equalsIgnoreCase("en") && path.contains("html/"))
{
path = path.replace("html/", (new StringBuilder()).append("html-").append(player.getLang()).append("/").toString());
}
String content = HtmCache.getInstance().getHtm(path);
if ((content == null) && !oriPath.equals(path))
{
content = HtmCache.getInstance().getHtm(oriPath);
}
if (content == null)
{
return false;
}
separateAndSend(content, player);
return true;
}
private boolean isValidName(final String text)
{
boolean result = true;
final String test = text;
Pattern pattern;
try
{
pattern = Pattern.compile(Config.CNAME_TEMPLATE);
}
catch (final PatternSyntaxException e) // case of illegal pattern
{
e.printStackTrace();
pattern = Pattern.compile(".*");
}
final Matcher regexp = pattern.matcher(test);
if (!regexp.matches())
{
result = false;
}
return result;
}
@Override
public void parsewrite(String ar1, String ar2, String ar3, String ar4, String ar5, L2PcInstance activeChar)
{
}
public static ServiceBBSManager getInstance()
{
return SingletonHolder._instance;
}
public static class SingletonHolder
{
protected static final ServiceBBSManager _instance = new ServiceBBSManager();
}
}
L2 Insignia High Five 20x
MID SERVER FOCUSED ON
OLYMPIAD | PVP | AUTOFARM
OPEN BETA TEST SERVER
3 MAY 2024
GRAND OPENING
10 MAY 2024
Rates:
📜 XP/SP 20x | Spoil 15x | Drop 10x | Adena 10x 📜
Server Features:
🔥 No Olf-T Shirt, No big over-enchant, No over-power Donate 🔥
🔥 VIP Gold Color Chat, Unique Olympiad Extra Points Engine, GvG Event 🔥
🔥 Auto-Farm, LoA and DV scheduled PvP Zone, Calendar Daily Reward 🔥
🔥 Castle Instance, Solo Instance, PvP Solo Rift, Dress me system, Adena Boxes 🔥
Website:
https://www.l2insignia.com
Discord:
https://discord.com/invite/yEgsrHn2hQ
I am selling the essence project which includes versions 388 and 439 that have been running for over 2 years or (447 as custom PVP like Pride). I have a test server for you to test them out. If you are really interested in it then contact my seller at discord: kiwi7106.
Price: 4000 Euro
P/s: This is a project that I have spent a lot of money and time developing, so if you are not interested in it, please get out of this topic, thank you.
P/s 2: If you find the price too expensive, it's best to skip this article and find another project and don't comment negatively on my topic, thank you.
Someone ask me for this, it should work on any client that has Kamael race, preview:
Installation - there are two ways to install depending on how you want to use it:
Method 1: If you want to completely replace the original, do:
Copy all lines from your armorgrp to Notepad++, press Ctrl+H, check the "match whole word" option and replace:
kamael.Mkamael_m000_w_ad00
by:
AvengersKamaelWings.Avengers_MKamael_m001_w_ad00
Then replace:
MKamael.Mkamael_m000_t00_w
by:
AvengersKamaelWings.MKamael_m001_t00_w
Now repeat the same process with the female, replace:
kamael.Fkamael_m000_w_ad00
by:
AvengersKamaelWings.Avengers_FKamael_m001_w_ad00
Then replace:
FKamael.Fkamael_m000_t00_w
by:
AvengersKamaelWings.FKamael_m001_t00_w
You're done, paste everything back into File Edit and save!
Method 2: If you only want to replace in specific sets, execute the above process only on the armorgrp of those sets.
Repack by: AvengersTeamBr
Password: LadrãoDeFrango
Question
disorder25
Hello I have I section on my community board that have Services, like Change Gender, Pk Cleaner, Noblesse, etc. I want to add a option to change the name. I add the code but when I enter the name on the box, instead of change the name to what I enter in the box I get the bypass as my name like:
How can I fix that?
Here is my code.
and the bypass
Edited by disorder25Link to comment
Share on other sites
5 answers to this question
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now