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();
}
}
Social metrics matter
Visibility, trust, engagement — all of this can be enhanced systematically.
With our SMM panel you get tools that turn activity into growth: followers, reactions, reposts, and clicks — all in one place.
Active links:
SMM Panel: Go to – promotion of your social media accounts.
Promotion
Get $1 for the first trial launch of the SMM Panel: just open a ticket with the subject “Get Trial Bonus” on our website (Support).
Perfect way to experience L2 without the brutal official grind. The progression here is so much smoother and faster, you get to the fun PvP and epic raids way quicker. The custom stuff keeps it fresh too. Definitely worth diving into!
L2-Getwork server highly customized with high-stats
https://l2server.eu/
https://discord.gg/SsVhm7R
Rates:
L2 High Five fully customized Getwork Style with High Stats and Enchant
ExP/Sp: 75x (custom)
Drop/Spoil: 1x (custom)
Safe: 500
Max: 50 000
Enchant System:
Normal Scrolls: 93% - fail - decrease enchant by 20
Blessed Scrolls: 96% - fail - decrease enchant by 10
Armor
Max Enchant D-Grade: +1000
Max Enchant C-Grade: +2000
Max Enchant B-Grade: +3000
Max Enchant A-Grade: +4000
Max Enchant S-Grade: +5000
Weapons
Max Enchant D-Grade: +5000
Max Enchant C-Grade: +10000
Max Enchant B-Grade: +15000
Max Enchant A-Grade: +20000
Max Enchant S-Grade: +25000 - 50000
Fir Tree Branch (Weapon): +100 into Weapons (max 50 000)
Fir Tree Branch (Armor): +15 into Armor (max 5000)
Road to Dvc Cloak Enchant: +1 into cloak (max +1000)
Masks of Spirit/Demon Horns Enchants: +1 into Masks (max +10)
Each accessories has different max enchant and chances
Daily Missions (.missions)
Collections (ALT + B)
Gambling System(.gamble) - each pack cost different amount Gamble Points, different items
How to get gambling points? - by killing Raid Bosses/Events or Completing Daily Missions.
Clan Bonus
VIP Bonuses (maximum level 10)
Battlepass (maximum level 100) - by killing monsters
Rebirth (starting in Parnassus)
Everything in ALT+B
Master's Buffs - 100 Small Glass Box (1 buff)
Farm Zones:
Custom Farm Zones:
Ruin of Agony (Exp Zone)
Underground Coliseum (Safe Exp Zone)
DVC,Brigand,Frost are similiar farm zones with same monsters
Dvc
Brigand Stronghold
Frost Lake
Parnassus - TOP ZONE
some of our features: .gamble,collections,battlepass,talent tree, rebirth
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.
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(); } }and the bypass
Edited by disorder255 answers to this question
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now