10-29-2011, 03:15 PM
Вот код Charmaganer не хочет компилиться пишет ошибку
Buildfile: E:\gm\server\serverfrozeh\Core\Core\build.xml
prepare-local:
prepare-final:
init:
version:
[echo] L2jFrozen Gameserver Revision: exported
compile:
[javac] Compiling 662 source files to E:\gm\server\serverfrozeh\Core\Core\build\classes
[javac] E:\gm\server\serverfrozeh\Core\Core\head-src\com\l2jfrozen\gameserver\model\actor\L2CharManagerInstance.java:1(и так с 1 по 29 строчку): unmappable character for encoding utf-8 : illegal character: \0
[javac] ?? :
[javac] 100 errors
Кодировку меняю и тоже самое помогите решить ошибку вот собственно код чар менеджера
Buildfile: E:\gm\server\serverfrozeh\Core\Core\build.xml
prepare-local:
prepare-final:
init:
version:
[echo] L2jFrozen Gameserver Revision: exported
compile:
[javac] Compiling 662 source files to E:\gm\server\serverfrozeh\Core\Core\build\classes
[javac] E:\gm\server\serverfrozeh\Core\Core\head-src\com\l2jfrozen\gameserver\model\actor\L2CharManagerInstance.java:1(и так с 1 по 29 строчку): unmappable character for encoding utf-8 : illegal character: \0
[javac] ?? :
[javac] 100 errors
Кодировку меняю и тоже самое помогите решить ошибку вот собственно код чар менеджера
1
package com.l2jfrozen.gameserver.model.actor.instance;
import java.util.StringTokenizer;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import java.util.regex.Matcher;
import javolution.text.TextBuilder;
import com.l2jfrozen.gameserver.network.serverpackets.ActionFailed;
import com.l2jfrozen.gameserver.network.serverpackets.MagicSkillUser;
import com.l2jfrozen.gameserver.network.serverpackets.MyTargetSelected;
import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jfrozen.gameserver.network.serverpackets.UserInfo;
import com.l2jfrozen.gameserver.network.serverpackets.ValidateLocation;
import com.l2jfrozen.gameserver.templates.L2NpcTemplate;
import com.l2jfrozen.gameserver.util.Util;
public class L2CharManagerInstance extends L2FolkInstance {
/**
* @author SeDneY
*/
private final String NPC_MENU = "<html><title>L2j Char Manager</title><body>" +
"<a action=\"bypass -h npc_%objectId%_showwindow 1\">>Change my name</a><br>" +
"<a action=\"bypass -h npc_%objectId%_showwindow 2\">Change my name color</a><br>" +
"<a action=\"bypass -h npc_%objectId%_showwindow 3\">Change my title color</a><br>" +
"<a action=\"bypass -h npc_%objectId%_showwindow 4\">Set me as Noble</a><br>" +
"<a action=\"bypass -h npc_%objectId%_showwindow 5\">Set me as Hero</a><br>" +
"<a action=\"bypass -h npc_%objectId%_showwindow 6\">Change my sex</a><br>" +
"<a action=\"bypass -h npc_%objectId%_showwindow 7\">Put down my PKs</a><br>" +
"</body></html>";
private final int NickNameChangeItem = 4037;
private final int NickNameChangeItemCount = 200;
private final String NickNameChangeItemName = "Coin of Luck";
private final String NickNamePattern = ".*"; //
private final int ChangeTitleColorItem = 4037; //
private final int ChangeTitleColorItemCount = 20; //
private final String ChangeTitleColorItemName = "Coin of Luck";
private final int ChangeNickColorItem = 4037;
private final int ChangeNickColorItemCount = 30;
private final String ChangeNickColorItemName = "Coin of Luck";
private final int SetNobleItem = 4037; //
private final int SetNobleItemCount = 100; //
private final String SetNobleItemName = "Coin of Luck";
private final int SetHeroItem = 4037; //
private final int SetHeroItemCount = 300; //
private final String SetHeroItemName = "Coin of Luck"; //
private final int SetSexItem = 4037; //
private final int SetSexItemCount = 10; //
private final String SetSexItemName = "Coin of Luck"; //
private final int ChangePkKillsItem = 57; //
private final int ChangePkKillsItemCount = 1; //
private final String ChangePkKillsItemName = "Coin of Luck"; //
public L2CharManagerInstance(int objectId, L2NpcTemplate template) {
super(objectId, template);
}
@Override
public void onBypassFeedback(L2PcInstance player, String command)
{
StringTokenizer st = new StringTokenizer(command, " ");
String curCommand = st.nextToken();
if(curCommand.startsWith("showwindow"))
{
showWindow(player, Integer.parseInt(st.nextToken()));
}
else if(curCommand.startsWith("change_nickname"))
{
String name = st.nextToken();
playerSetNickName(player, name);
}
else if(curCommand.startsWith("change_nickcolor"))
{
playerSetColor(player, st.nextToken(), 1);
}
else if(curCommand.startsWith("change_titlecolor"))
{
playerSetColor(player, st.nextToken(), 2);
}
else if(curCommand.startsWith("change_pkcount"))
{
changePkCount(player, Integer.parseInt(st.nextToken()));
}
else if(curCommand.startsWith("setstatus"))
{
setStatus(player, Integer.parseInt(st.nextToken()));
}
}
@Override
public void onAction(L2PcInstance player)
{
player.setLastFolkNPC(this);
if(!canTarget(player))
return;
if(this != player.getTarget())
{
player.setTarget(this);
MyTargetSelected my = new MyTargetSelected(getObjectId(), 0);
player.sendPacket(my);
player.sendPacket(new ValidateLocation(this));
}
else
{
if(!canInteract(player))
{
}
else
{
NpcHtmlMessage html = new NpcHtmlMessage(1);
html.setHtml(NPC_MENU);
sendHtmlMessage(player, html);
}
}
player.sendPacket(ActionFailed.STATIC_PACKET);
}
private void sendHtmlMessage(L2PcInstance player, NpcHtmlMessage html)
{
html.replace("%objectId%", String.valueOf(getObjectId()));
html.replace("%npcId%", String.valueOf(getNpcId()));
player.sendPacket(html);
}
private void playerSetColor(L2PcInstance player, String color, int type)
{
int colorh = -1;
if(color.equalsIgnoreCase("Green"))
{
colorh = Integer.decode("0x00FF00");
}
else if(color.equalsIgnoreCase("Yellow"))
{
colorh = Integer.decode("0x00FFFF");
}
else if(color.equalsIgnoreCase("Orange"))
{
colorh = Integer.decode("0x0099FF");
}
else if(color.equalsIgnoreCase("Blue"))
{
colorh = Integer.decode("0xFF0000");
}
else if(color.equalsIgnoreCase("Black"))
{
colorh = Integer.decode("0x000000");
}
else if(color.equalsIgnoreCase("White"))
{
colorh = Integer.decode("0xFFFFFF");
}
if(type == 1)
{
if(player.getInventory().getItemByItemId(ChangeNickColorItem) != null && player.getInventory().getItemByItemId(ChangeNickColorItem).getCount() >= ChangeNickColorItemCount && colorh != -1)
{
player.destroyItemByItemId("Consume", ChangeNickColorItem, ChangeNickColorItemCount, player, false);
player.getAppearance().setNameColor(colorh);
player.broadcastUserInfo();
player.sendMessage(" " + color);
}
else
{
player.sendMessage("");
}
}
else if(type == 2)
{
if(player.getInventory().getItemByItemId(ChangeTitleColorItem) != null && player.getInventory().getItemByItemId(ChangeTitleColorItem).getCount() >= ChangeTitleColorItemCount)
{
player.destroyItemByItemId("Consume", ChangeTitleColorItem, ChangeTitleColorItemCount, player, false);
player.getAppearance().setTitleColor(colorh);
player.broadcastUserInfo();
player.sendMessage(" " + color);
}
else
{
player.sendMessage("");
}
}
}
private void playerSetNickName(L2PcInstance player, String name)
{
if (name.length() < 3 || name.length() > 16 || !Util.isAlphaNumeric(name) || !isValidName(name))
{
player.sendMessage("");
}
else
{
if(player.getInventory().getItemByItemId(NickNameChangeItem) != null && player.getInventory().getItemByItemId(NickNameChangeItem).getCount() >= NickNameChangeItemCount)
{
player.setName(name);
player.destroyItemByItemId("Consume", NickNameChangeItem, NickNameChangeItemCount, player, false);
player.broadcastUserInfo();
player.sendMessage("");
player.store();
}
else
{
player.sendMessage("");
}
}
}
private void setStatus(L2PcInstance player, int type)
{
if(type == 1)
{
if(player.isNoble())
{
player.sendMessage("");
return;
}
else if(player.getInventory().getItemByItemId(SetNobleItem) == null || player.getInventory().getItemByItemId(SetNobleItem).getCount() < SetNobleItemCount)
{
player.sendMessage("");
return;
}
player.destroyItemByItemId("Consume", SetNobleItem, SetNobleItemCount, player, false);
MagicSkillUser MSU = new MagicSkillUser(player, player, 2023, 1, 1, 0);
player.sendPacket(MSU);
player.broadcastPacket(MSU);
player.setNoble(true);
player.sendMessage("");
player.broadcastUserInfo();
player.getInventory().addItem("Noblesse Tiara",7694, 1, player, player.getTarget());
}
else if(type == 2)
{
if(player.isHero())
{
player.sendMessage("");
return;
}
else if(player.getInventory().getItemByItemId(SetHeroItem) == null || player.getInventory().getItemByItemId(SetHeroItem).getCount() < SetHeroItemCount)
{
player.sendMessage("");
return;
}
player.destroyItemByItemId("Consume", SetHeroItem, SetHeroItemCount, player, false);
player.setHero(true);
player.broadcastUserInfo();
}
else if(type == 3)
{
if(player.getInventory().getItemByItemId(SetSexItem) == null || player.getInventory().getItemByItemId(SetSexItem).getCount() < SetSexItemCount)
{
player.sendMessage("Not enough item");
return;
}
player.destroyItemByItemId("Consume", SetSexItem, SetSexItemCount, player, false);
player.getAppearance().setSex(player.getAppearance().getSex() ? false : true);
player.broadcastUserInfo();
player.decayMe();
player.spawnMe(player.getX(), player.getY(), player.getZ());
player.sendMessage("You have successfully changed their sex.");
}
}
private void showWindow(L2PcInstance player, int window)
{
TextBuilder tb;
NpcHtmlMessage html;
if(window == 0)
{
html = new NpcHtmlMessage(1);
html.setHtml(NPC_MENU);
sendHtmlMessage(player, html);
}
else if(window == 1)
{
tb = new TextBuilder();
tb.append("<html><title></title>");
tb.append("<body><center>");
tb.append("<br> <edit var=\"name\" width=120 height=15><br>");
tb.append("<a action=\"bypass -h npc_%objectId%_change_nickname $name\"></a><br>");
tb.append(" " + NickNameChangeItemCount + " <font color=\"LEVEL\">" + NickNameChangeItemName + "</font><br>");
tb.append("<a action=\"bypass -h npc_%objectId%_showwindow 0\"></a><br>");
tb.append("</center></body></html>");
html = new NpcHtmlMessage(1);
html.setHtml(tb.toString());
sendHtmlMessage(player, html);
}
else if(window == 2)
{
tb = new TextBuilder();
tb.append("<html><title></title><body><center>");
tb.append("<br>");
tb.append("<br> <combobox var=\"scolor\" width=\"100\" List=\"White;Green;Yellow;Orange;Blue;Black\"><br>");
tb.append("<a action=\"bypass -h npc_%objectId%_change_nickcolor $scolor\"></a>");
tb.append("" + ChangeNickColorItemCount + " <font color=\"LEVEL\">" + ChangeNickColorItemName + "</font><br>");
tb.append("<a action=\"bypass -h npc_%objectId%_showwindow 0\"></a><br>");
tb.append("</center></body></html>");
html = new NpcHtmlMessage(1);
html.setHtml(tb.toString());
sendHtmlMessage(player, html);
}
else if(window == 3)
{
tb = new TextBuilder();
tb.append("<html><title></title><body><center>");
tb.append("<br>");
tb.append("<br> <combobox var=\"scolor\" width=\"100\" List=\"White;Green;Yellow;Orange;Blue;Black\"><br>");
tb.append("<a action=\"bypass -h npc_%objectId%_change_titlecolor $scolor\"></a><br>");
tb.append(" " + ChangeTitleColorItemCount + " <font color=\"LEVEL\">" + ChangeTitleColorItemName + "</font><br>");
tb.append("<a action=\"bypass -h npc_%objectId%_showwindow 0\"></a><br>");
tb.append("</center></body></html>");
html = new NpcHtmlMessage(1);
html.setHtml(tb.toString());
sendHtmlMessage(player, html);
}
else if(window == 4)
{
tb = new TextBuilder();
tb.append("<html><title></title><body><center>");
tb.append("<br>");
tb.append("<a action=\"bypass -h npc_%objectId%_setstatus 1\"></a>");
tb.append(" " + SetNobleItemCount + " <font color=\"LEVEL\">" + SetNobleItemName + "</font><br>");
tb.append("<a action=\"bypass -h npc_%objectId%_showwindow 0\"></a><br>");
tb.append("</center></body></html>");
html = new NpcHtmlMessage(1);
html.setHtml(tb.toString());
sendHtmlMessage(player, html);
}
else if(window == 5)
{
tb = new TextBuilder();
tb.append("<html><title></title><body><center>");
tb.append("<br>");
tb.append("<a action=\"bypass -h npc_%objectId%_setstatus 2\"></a><br>");
tb.append(" " + SetHeroItemCount + " <font color=\"LEVEL\">" + SetHeroItemName + "</font><br>");
tb.append("<a action=\"bypass -h npc_%objectId%_showwindow 0\"></a><br>");
tb.append("</center></body></html>");
html = new NpcHtmlMessage(1);
html.setHtml(tb.toString());
sendHtmlMessage(player, html);
}
else if(window == 6)
{
tb = new TextBuilder();
tb.append("<html><title>sex change</title><body><center>");
tb.append("Here you can change the gender of your character.<br>");
tb.append("<a action=\"bypass -h npc_%objectId%_setstatus 3\">Back to the floor</a><br>");
tb.append("Price: " + SetSexItemCount + " <font color=\"LEVEL\">" + SetSexItemName + "</font><br>");
tb.append("<a action=\"bypass -h npc_%objectId%_showwindow 0\">back</a><br>");
tb.append("</center></body></html>");
html = new NpcHtmlMessage(1);
html.setHtml(tb.toString());
sendHtmlMessage(player, html);
}
else if(window == 7)
{
tb = new TextBuilder();
tb.append("<html><title>Wash counter pc</title>");
tb.append("<body><center>");
tb.append("<br> Enter a quantitative pc that will be deleted:<br> <edit var=\"pkcount\" width=120 height=15><br>");
tb.append("<a action=\"bypass -h npc_%objectId%_change_pkcount $pkcount\">Change</a><br>");
tb.append("1 PC = " + ChangePkKillsItemCount + " <font color=\"LEVEL\">" + ChangePkKillsItemName + "</font>");
tb.append("<a action=\"bypass -h npc_%objectId%_showwindow 0\">back</a><br>");
tb.append("</center></body></html>");
html = new NpcHtmlMessage(1);
html.setHtml(tb.toString());
sendHtmlMessage(player, html);
}
}
private void changePkCount(L2PcInstance player, int count)
{
if(player.getInventory().getItemByItemId(ChangePkKillsItem) != null && player.getInventory().getItemByItemId(ChangePkKillsItem).getCount() >= ChangePkKillsItemCount * count)
{
int inipkKills = player.getPkKills();
if(inipkKills == 0) {
player.sendMessage("You have 0 PC");
return;
}
else if(inipkKills < count)
{
player.sendMessage("Not the correct number of PCs");
return;
}
player.destroyItemByItemId("Consume", ChangePkKillsItem, count * ChangePkKillsItemCount, player, false);
player.setPkKills(inipkKills - count);
player.sendPacket(new UserInfo(player));
player.sendMessage("You have removed " + count + " PK");
}
else
{
player.sendMessage("Not enough item");
}
}
private boolean isValidName(String text) { Pattern pattern;
boolean result = true;
String test = text;
try
{
pattern = Pattern.compile(Config.NICK_CHANGE_TEMPLATE);
}
catch (PatternSyntaxException e)
{
_log.warning("ERROR : Character name pattern of config is wrong!");
pattern = Pattern.compile(".*");
}
Matcher regexp = pattern.matcher(test);
if (!(regexp.matches()))
{
result = false;
if (Config.SYMBOL_MIX_PROTECTION)
{
try
{
pattern = Pattern.compile("[0-9А-Яа-я]{1,16}");
}
catch (PatternSyntaxException e)
{
_log.warning("ERROR : RU char name pattern is wrong!");
}
regexp = pattern.matcher(test);
if (regexp.matches())
{
result = true;
}
}
}
return result;
}
}
import java.util.StringTokenizer;
import java.util.regex.Pattern;
import java.util.regex.PatternSyntaxException;
import java.util.regex.Matcher;
import javolution.text.TextBuilder;
import com.l2jfrozen.gameserver.network.serverpackets.ActionFailed;
import com.l2jfrozen.gameserver.network.serverpackets.MagicSkillUser;
import com.l2jfrozen.gameserver.network.serverpackets.MyTargetSelected;
import com.l2jfrozen.gameserver.network.serverpackets.NpcHtmlMessage;
import com.l2jfrozen.gameserver.network.serverpackets.UserInfo;
import com.l2jfrozen.gameserver.network.serverpackets.ValidateLocation;
import com.l2jfrozen.gameserver.templates.L2NpcTemplate;
import com.l2jfrozen.gameserver.util.Util;
public class L2CharManagerInstance extends L2FolkInstance {
/**
* @author SeDneY
*/
private final String NPC_MENU = "<html><title>L2j Char Manager</title><body>" +
"<a action=\"bypass -h npc_%objectId%_showwindow 1\">>Change my name</a><br>" +
"<a action=\"bypass -h npc_%objectId%_showwindow 2\">Change my name color</a><br>" +
"<a action=\"bypass -h npc_%objectId%_showwindow 3\">Change my title color</a><br>" +
"<a action=\"bypass -h npc_%objectId%_showwindow 4\">Set me as Noble</a><br>" +
"<a action=\"bypass -h npc_%objectId%_showwindow 5\">Set me as Hero</a><br>" +
"<a action=\"bypass -h npc_%objectId%_showwindow 6\">Change my sex</a><br>" +
"<a action=\"bypass -h npc_%objectId%_showwindow 7\">Put down my PKs</a><br>" +
"</body></html>";
private final int NickNameChangeItem = 4037;
private final int NickNameChangeItemCount = 200;
private final String NickNameChangeItemName = "Coin of Luck";
private final String NickNamePattern = ".*"; //
private final int ChangeTitleColorItem = 4037; //
private final int ChangeTitleColorItemCount = 20; //
private final String ChangeTitleColorItemName = "Coin of Luck";
private final int ChangeNickColorItem = 4037;
private final int ChangeNickColorItemCount = 30;
private final String ChangeNickColorItemName = "Coin of Luck";
private final int SetNobleItem = 4037; //
private final int SetNobleItemCount = 100; //
private final String SetNobleItemName = "Coin of Luck";
private final int SetHeroItem = 4037; //
private final int SetHeroItemCount = 300; //
private final String SetHeroItemName = "Coin of Luck"; //
private final int SetSexItem = 4037; //
private final int SetSexItemCount = 10; //
private final String SetSexItemName = "Coin of Luck"; //
private final int ChangePkKillsItem = 57; //
private final int ChangePkKillsItemCount = 1; //
private final String ChangePkKillsItemName = "Coin of Luck"; //
public L2CharManagerInstance(int objectId, L2NpcTemplate template) {
super(objectId, template);
}
@Override
public void onBypassFeedback(L2PcInstance player, String command)
{
StringTokenizer st = new StringTokenizer(command, " ");
String curCommand = st.nextToken();
if(curCommand.startsWith("showwindow"))
{
showWindow(player, Integer.parseInt(st.nextToken()));
}
else if(curCommand.startsWith("change_nickname"))
{
String name = st.nextToken();
playerSetNickName(player, name);
}
else if(curCommand.startsWith("change_nickcolor"))
{
playerSetColor(player, st.nextToken(), 1);
}
else if(curCommand.startsWith("change_titlecolor"))
{
playerSetColor(player, st.nextToken(), 2);
}
else if(curCommand.startsWith("change_pkcount"))
{
changePkCount(player, Integer.parseInt(st.nextToken()));
}
else if(curCommand.startsWith("setstatus"))
{
setStatus(player, Integer.parseInt(st.nextToken()));
}
}
@Override
public void onAction(L2PcInstance player)
{
player.setLastFolkNPC(this);
if(!canTarget(player))
return;
if(this != player.getTarget())
{
player.setTarget(this);
MyTargetSelected my = new MyTargetSelected(getObjectId(), 0);
player.sendPacket(my);
player.sendPacket(new ValidateLocation(this));
}
else
{
if(!canInteract(player))
{
}
else
{
NpcHtmlMessage html = new NpcHtmlMessage(1);
html.setHtml(NPC_MENU);
sendHtmlMessage(player, html);
}
}
player.sendPacket(ActionFailed.STATIC_PACKET);
}
private void sendHtmlMessage(L2PcInstance player, NpcHtmlMessage html)
{
html.replace("%objectId%", String.valueOf(getObjectId()));
html.replace("%npcId%", String.valueOf(getNpcId()));
player.sendPacket(html);
}
private void playerSetColor(L2PcInstance player, String color, int type)
{
int colorh = -1;
if(color.equalsIgnoreCase("Green"))
{
colorh = Integer.decode("0x00FF00");
}
else if(color.equalsIgnoreCase("Yellow"))
{
colorh = Integer.decode("0x00FFFF");
}
else if(color.equalsIgnoreCase("Orange"))
{
colorh = Integer.decode("0x0099FF");
}
else if(color.equalsIgnoreCase("Blue"))
{
colorh = Integer.decode("0xFF0000");
}
else if(color.equalsIgnoreCase("Black"))
{
colorh = Integer.decode("0x000000");
}
else if(color.equalsIgnoreCase("White"))
{
colorh = Integer.decode("0xFFFFFF");
}
if(type == 1)
{
if(player.getInventory().getItemByItemId(ChangeNickColorItem) != null && player.getInventory().getItemByItemId(ChangeNickColorItem).getCount() >= ChangeNickColorItemCount && colorh != -1)
{
player.destroyItemByItemId("Consume", ChangeNickColorItem, ChangeNickColorItemCount, player, false);
player.getAppearance().setNameColor(colorh);
player.broadcastUserInfo();
player.sendMessage(" " + color);
}
else
{
player.sendMessage("");
}
}
else if(type == 2)
{
if(player.getInventory().getItemByItemId(ChangeTitleColorItem) != null && player.getInventory().getItemByItemId(ChangeTitleColorItem).getCount() >= ChangeTitleColorItemCount)
{
player.destroyItemByItemId("Consume", ChangeTitleColorItem, ChangeTitleColorItemCount, player, false);
player.getAppearance().setTitleColor(colorh);
player.broadcastUserInfo();
player.sendMessage(" " + color);
}
else
{
player.sendMessage("");
}
}
}
private void playerSetNickName(L2PcInstance player, String name)
{
if (name.length() < 3 || name.length() > 16 || !Util.isAlphaNumeric(name) || !isValidName(name))
{
player.sendMessage("");
}
else
{
if(player.getInventory().getItemByItemId(NickNameChangeItem) != null && player.getInventory().getItemByItemId(NickNameChangeItem).getCount() >= NickNameChangeItemCount)
{
player.setName(name);
player.destroyItemByItemId("Consume", NickNameChangeItem, NickNameChangeItemCount, player, false);
player.broadcastUserInfo();
player.sendMessage("");
player.store();
}
else
{
player.sendMessage("");
}
}
}
private void setStatus(L2PcInstance player, int type)
{
if(type == 1)
{
if(player.isNoble())
{
player.sendMessage("");
return;
}
else if(player.getInventory().getItemByItemId(SetNobleItem) == null || player.getInventory().getItemByItemId(SetNobleItem).getCount() < SetNobleItemCount)
{
player.sendMessage("");
return;
}
player.destroyItemByItemId("Consume", SetNobleItem, SetNobleItemCount, player, false);
MagicSkillUser MSU = new MagicSkillUser(player, player, 2023, 1, 1, 0);
player.sendPacket(MSU);
player.broadcastPacket(MSU);
player.setNoble(true);
player.sendMessage("");
player.broadcastUserInfo();
player.getInventory().addItem("Noblesse Tiara",7694, 1, player, player.getTarget());
}
else if(type == 2)
{
if(player.isHero())
{
player.sendMessage("");
return;
}
else if(player.getInventory().getItemByItemId(SetHeroItem) == null || player.getInventory().getItemByItemId(SetHeroItem).getCount() < SetHeroItemCount)
{
player.sendMessage("");
return;
}
player.destroyItemByItemId("Consume", SetHeroItem, SetHeroItemCount, player, false);
player.setHero(true);
player.broadcastUserInfo();
}
else if(type == 3)
{
if(player.getInventory().getItemByItemId(SetSexItem) == null || player.getInventory().getItemByItemId(SetSexItem).getCount() < SetSexItemCount)
{
player.sendMessage("Not enough item");
return;
}
player.destroyItemByItemId("Consume", SetSexItem, SetSexItemCount, player, false);
player.getAppearance().setSex(player.getAppearance().getSex() ? false : true);
player.broadcastUserInfo();
player.decayMe();
player.spawnMe(player.getX(), player.getY(), player.getZ());
player.sendMessage("You have successfully changed their sex.");
}
}
private void showWindow(L2PcInstance player, int window)
{
TextBuilder tb;
NpcHtmlMessage html;
if(window == 0)
{
html = new NpcHtmlMessage(1);
html.setHtml(NPC_MENU);
sendHtmlMessage(player, html);
}
else if(window == 1)
{
tb = new TextBuilder();
tb.append("<html><title></title>");
tb.append("<body><center>");
tb.append("<br> <edit var=\"name\" width=120 height=15><br>");
tb.append("<a action=\"bypass -h npc_%objectId%_change_nickname $name\"></a><br>");
tb.append(" " + NickNameChangeItemCount + " <font color=\"LEVEL\">" + NickNameChangeItemName + "</font><br>");
tb.append("<a action=\"bypass -h npc_%objectId%_showwindow 0\"></a><br>");
tb.append("</center></body></html>");
html = new NpcHtmlMessage(1);
html.setHtml(tb.toString());
sendHtmlMessage(player, html);
}
else if(window == 2)
{
tb = new TextBuilder();
tb.append("<html><title></title><body><center>");
tb.append("<br>");
tb.append("<br> <combobox var=\"scolor\" width=\"100\" List=\"White;Green;Yellow;Orange;Blue;Black\"><br>");
tb.append("<a action=\"bypass -h npc_%objectId%_change_nickcolor $scolor\"></a>");
tb.append("" + ChangeNickColorItemCount + " <font color=\"LEVEL\">" + ChangeNickColorItemName + "</font><br>");
tb.append("<a action=\"bypass -h npc_%objectId%_showwindow 0\"></a><br>");
tb.append("</center></body></html>");
html = new NpcHtmlMessage(1);
html.setHtml(tb.toString());
sendHtmlMessage(player, html);
}
else if(window == 3)
{
tb = new TextBuilder();
tb.append("<html><title></title><body><center>");
tb.append("<br>");
tb.append("<br> <combobox var=\"scolor\" width=\"100\" List=\"White;Green;Yellow;Orange;Blue;Black\"><br>");
tb.append("<a action=\"bypass -h npc_%objectId%_change_titlecolor $scolor\"></a><br>");
tb.append(" " + ChangeTitleColorItemCount + " <font color=\"LEVEL\">" + ChangeTitleColorItemName + "</font><br>");
tb.append("<a action=\"bypass -h npc_%objectId%_showwindow 0\"></a><br>");
tb.append("</center></body></html>");
html = new NpcHtmlMessage(1);
html.setHtml(tb.toString());
sendHtmlMessage(player, html);
}
else if(window == 4)
{
tb = new TextBuilder();
tb.append("<html><title></title><body><center>");
tb.append("<br>");
tb.append("<a action=\"bypass -h npc_%objectId%_setstatus 1\"></a>");
tb.append(" " + SetNobleItemCount + " <font color=\"LEVEL\">" + SetNobleItemName + "</font><br>");
tb.append("<a action=\"bypass -h npc_%objectId%_showwindow 0\"></a><br>");
tb.append("</center></body></html>");
html = new NpcHtmlMessage(1);
html.setHtml(tb.toString());
sendHtmlMessage(player, html);
}
else if(window == 5)
{
tb = new TextBuilder();
tb.append("<html><title></title><body><center>");
tb.append("<br>");
tb.append("<a action=\"bypass -h npc_%objectId%_setstatus 2\"></a><br>");
tb.append(" " + SetHeroItemCount + " <font color=\"LEVEL\">" + SetHeroItemName + "</font><br>");
tb.append("<a action=\"bypass -h npc_%objectId%_showwindow 0\"></a><br>");
tb.append("</center></body></html>");
html = new NpcHtmlMessage(1);
html.setHtml(tb.toString());
sendHtmlMessage(player, html);
}
else if(window == 6)
{
tb = new TextBuilder();
tb.append("<html><title>sex change</title><body><center>");
tb.append("Here you can change the gender of your character.<br>");
tb.append("<a action=\"bypass -h npc_%objectId%_setstatus 3\">Back to the floor</a><br>");
tb.append("Price: " + SetSexItemCount + " <font color=\"LEVEL\">" + SetSexItemName + "</font><br>");
tb.append("<a action=\"bypass -h npc_%objectId%_showwindow 0\">back</a><br>");
tb.append("</center></body></html>");
html = new NpcHtmlMessage(1);
html.setHtml(tb.toString());
sendHtmlMessage(player, html);
}
else if(window == 7)
{
tb = new TextBuilder();
tb.append("<html><title>Wash counter pc</title>");
tb.append("<body><center>");
tb.append("<br> Enter a quantitative pc that will be deleted:<br> <edit var=\"pkcount\" width=120 height=15><br>");
tb.append("<a action=\"bypass -h npc_%objectId%_change_pkcount $pkcount\">Change</a><br>");
tb.append("1 PC = " + ChangePkKillsItemCount + " <font color=\"LEVEL\">" + ChangePkKillsItemName + "</font>");
tb.append("<a action=\"bypass -h npc_%objectId%_showwindow 0\">back</a><br>");
tb.append("</center></body></html>");
html = new NpcHtmlMessage(1);
html.setHtml(tb.toString());
sendHtmlMessage(player, html);
}
}
private void changePkCount(L2PcInstance player, int count)
{
if(player.getInventory().getItemByItemId(ChangePkKillsItem) != null && player.getInventory().getItemByItemId(ChangePkKillsItem).getCount() >= ChangePkKillsItemCount * count)
{
int inipkKills = player.getPkKills();
if(inipkKills == 0) {
player.sendMessage("You have 0 PC");
return;
}
else if(inipkKills < count)
{
player.sendMessage("Not the correct number of PCs");
return;
}
player.destroyItemByItemId("Consume", ChangePkKillsItem, count * ChangePkKillsItemCount, player, false);
player.setPkKills(inipkKills - count);
player.sendPacket(new UserInfo(player));
player.sendMessage("You have removed " + count + " PK");
}
else
{
player.sendMessage("Not enough item");
}
}
private boolean isValidName(String text) { Pattern pattern;
boolean result = true;
String test = text;
try
{
pattern = Pattern.compile(Config.NICK_CHANGE_TEMPLATE);
}
catch (PatternSyntaxException e)
{
_log.warning("ERROR : Character name pattern of config is wrong!");
pattern = Pattern.compile(".*");
}
Matcher regexp = pattern.matcher(test);
if (!(regexp.matches()))
{
result = false;
if (Config.SYMBOL_MIX_PROTECTION)
{
try
{
pattern = Pattern.compile("[0-9А-Яа-я]{1,16}");
}
catch (PatternSyntaxException e)
{
_log.warning("ERROR : RU char name pattern is wrong!");
}
regexp = pattern.matcher(test);
if (regexp.matches())
{
result = true;
}
}
}
return result;
}
}