Вот код подскажите как сделать чтобы он брал итем за смену ника не адену, а коин оф лак
}
if (ChangeType == 1 && player.getInventory().[color=#ff0000]getAdena[/color]() < _priceForName ||
ChangeType == 2 && player.getInventory().[color=#ff0000]getAdena[/color]() < _priceForTitle)
{
player.sendMessage("Incorrect Adena in you inventory. You do not have required Adena.");
return false;
}
Я так понял тут, а что поставить чтобы Coin of Luck забирал?
/*
* 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 2, 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, write to the Free Software
* Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA
* 02111-1307, USA.
*
* http://www.gnu.org/copyleft/gpl.html
*/
package net.sf.l2j.gameserver.model.actor.instance;
import javolution.text.TextBuilder;
import net.sf.l2j.Config;
import net.sf.l2j.gameserver.templates.L2NpcTemplate;
import net.sf.l2j.gameserver.serverpackets.NpcHtmlMessage;
import net.sf.l2j.gameserver.services.HtmlPathService;
import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;
import java.util.StringTokenizer;
/**
* @author: Aquanox
* @description: Class for name and title color change
* @version: 0.7.2
*/
public class L2CustomColorManagerInstance extends L2NpcInstance
{
private static final Log _log = LogFactory.getLog(L2CustomColorManagerInstance.class);
/** Get info from CONFIG */
private final static boolean _isColorManagerEnabled = Config.CM_ALLOW_COLOR_MANAGER;
private final static boolean _allowTitleChange = Config.CM_ALLOW_TITLE_COLOR_CHANGE;
private final static boolean _allowNameChange = Config.CM_ALLOW_NAME_COLOR_CHANGE;
private final static int _priceForName = Config.CM_CHANGE_NAME_COLOR_PRICE;
private final static int _priceForTitle = Config.CM_CHANGE_TITLE_COLOR_PRICE;
private final static int _minLevel = Config.CM_PLAYER_MIN_LEVEL;
/**
* @description Main colors datatable
*/
protected final static int[][] COLORS_DATA = new int[][]
{
{0,0,0},{0,0,51},{0,0,102},{0,0,153},{0,0,204},{0,0,255},{0,51,0},{0,51,51},
{0,51,102},{0,51,153},{0,51,204},{0,51,255},{0,102,0},{0,102,51},{0,102,102},{0,102,153},
{0,102,204},{0,102,255},{0,153,0},{0,153,51},{0,153,102},{0,153,153},{0,153,204},{0,153,255},
{0,204,0},{0,204,51},{0,204,102},{0,204,153},{0,204,204},{0,204,255},{0,255,0},{0,255,51},
{0,255,102},{0,255,153},{0,255,204},{0,255,255},{51,0,0},{51,0,51},{51,0,102},
{51,0,153},{51,0,204},{51,0,255},{51,51,0},{51,51,51},{51,51,102},{51,51,153},{51,51,204},{51,51,255},
{51,102,0},{51,102,51},{51,102,102},{51,102,153},{51,102,204},{51,102,255},
{51,153,0},{51,153,51},{51,153,102},{51,153,153},{51,153,204},{51,153,255},
{51,204,0},{51,204,51},{51,204,102},{51,204,153},{51,204,204},{51,204,255},
{51,255,0},{51,255,51},{51,255,102},{51,255,153},{51,255,204},{51,255,255},
{102,0,0},{102,0,51},{102,0,102},{102,0,153},{102,0,204},{102,0,255},
{102,51,0},{102,51,51},{102,51,102},{102,51,153},{102,51,204},{102,51,255},
{102,102,0},{102,102,51},{102,102,102},{102,102,153},{102,102,204},{102,102,255},
{102,153,0},{102,153,51},{102,153,102},{102,153,153},{102,153,204},{102,153,255},
{102,204,0},{102,204,51},{102,204,102},{102,204,153},{102,204,204},{102,204,255},
{102,255,0},{102,255,51},{102,255,102},{102,255,153},{102,255,204},{102,255,255},
{153,0,0},{153,0,51},{153,0,102},{153,0,153},{153,0,204},{153,0,255},
{153,51,0},{153,51,51},{153,51,102},{153,51,153},{153,51,204},{153,51,255},
{153,102,0},{153,102,51},{153,102,102},{153,102,153},{153,102,204},{153,102,255},
{153,153,0},{153,153,51},{153,153,102},{153,153,153},{153,153,204},{153,153,255},
{153,204,0},{153,204,51},{153,204,102},{153,204,153},{153,204,204},{153,204,255},
{153,255,0},{153,255,51},{153,255,102},{153,255,153},{153,255,204},{153,255,255},
{204,0,0},{204,0,51},{204,0,102},{204,0,153},{204,0,204},{204,0,255},
{204,51,0},{204,51,51},{204,51,102},{204,51,153},{204,51,204},{204,51,255},
{204,102,0},{204,102,51},{204,102,102},{204,102,153},{204,102,204},{204,102,255},
{204,153,0},{204,153,51},{204,153,102},{204,153,153},{204,153,204},{204,153,255},
{204,204,0},{204,204,51},{204,204,102},{204,204,153},{204,204,204},{204,204,255},
{204,255,0},{204,255,51},{204,255,102},{204,255,153},{204,255,204},{204,255,255},
{255,0,0},{255,0,51},{255,0,102},{255,0,153},{255,0,204},{255,0,255},
{255,51,0},{255,51,51},{255,51,102},{255,51,153},{255,51,204},{255,51,255},
{255,102,0},{255,102,51},{255,102,102},{255,102,153},{255,102,204},{255,102,255},
{255,153,0},{255,153,51},{255,153,102},{255,153,153},{255,153,204},{255,153,255},
{255,204,0},{255,204,51},{255,204,102},{255,204,153},{255,204,204},{255,204,255},
{255,255,0},{255,255,51},{255,255,102},{255,255,153},{255,255,204},{255,255,255}
};
private final static int _colorsPerPage = 18;
private final static int _maxPages = (COLORS_DATA.length/_colorsPerPage);
/**
* @param objectId - ObjectId
* @param template - Template
*/
public L2CustomColorManagerInstance(int objectId, L2NpcTemplate template)
{
super(objectId, template);
}
/**
* @param npcId NpcId
* @param val ChatId
* @return String path to html-file
*/
@Override
public String getHtmlPath(int npcId, int val)
{
return HtmlPathService.getPath(HtmlPathService.ADDONS_CLR_MANAGER_PATH,npcId,val);
}
/**
* @param red Red Color
* @param green Green Color
* @param blue Blue color
* @return HEX Color
*/
protected String getHexColor(int red,int green,int blue)
{
String _red = Integer.toHexString(red);
if (_red.length() == 1)
_red = "0"+_red;
String _green = Integer.toHexString(green);
if (_green.length() == 1)
_green = "0"+_green;
String _blue = Integer.toHexString(blue);
if (_blue.length() == 1)
_blue = "0"+_blue;
return (_red + _green + _blue);
}
/**
*
* @param player L2PcInstance
* @param type int
* @param val int
*/
protected void showColorsListPage(L2PcInstance player,int type ,int val)
{
NpcHtmlMessage html = new NpcHtmlMessage(getObjectId());
TextBuilder sb = new TextBuilder();
if (val <= 0 || val > _maxPages)
return;
String Command;
String bypass;
String Header;
if (type == 1)
{
Command = "SetNameColor";
bypass = "NColorsList";
Header = "Name Color Change";
}
else
{
Command = "SetTitleColor";
bypass = "TColorsList";
Header = "Title Color Change";
}
sb.append("<html><body>" + getName() + " - " + Header + "<br1>");
sb.append("<table>\n");
int _start = _colorsPerPage*(val-1);
int _end = _colorsPerPage*val-1;
int objId = getObjectId();
for (int i=_start;i <= _end;i++)
{
int[] ColorData = COLORS_DATA[i];
String HexColor = getHexColor(ColorData[0],ColorData[1],ColorData[2]);
sb.append("<tr><td><a action=\"bypass -h npc_" + objId + "_" + Command + " " + i + "\"><font color=\"" + HexColor + "\" >### COLOR ###</font></a></td></tr>\n");
}
sb.append("</table>\n");
if (val == 1)
{
sb.append("<center><button value=\"NEXT >>\" action=\"bypass -h npc_" + objId + "_" + bypass + " " + (val+1) + "\" width=75 height=21 back=\"L2UI_ch3.Btn1_normal\" fore=\"L2UI_ch3.Btn1_normal\"></center>");
}
else if (val == _maxPages)
{
sb.append("<center><button value=\"<< BACK\" action=\"bypass -h npc_" + objId + "_" + bypass + " " + (val-1) + "\" width=75 height=21 back=\"L2UI_ch3.Btn1_normal\" fore=\"L2UI_ch3.Btn1_normal\"></center>");
}
else if ((val > 1) && (val < _maxPages))
{
sb.append("<table><tr><td><button value=\"<< BACK\" action=\"bypass -h npc_" + objId + "_" + bypass + " " + (val-1) + "\" width=75 height=21 back=\"L2UI_ch3.Btn1_normal\" fore=\"L2UI_ch3.Btn1_normal\"></td><td><button value=\"NEXT >>\" action=\"bypass -h npc_"+objId+"_"+bypass+" "+ (val+1) +"\" width=75 height=21 back=\"L2UI_ch3.Btn1_normal\" fore=\"L2UI_ch3.Btn1_normal\"></td></tr></table>");
}
sb.append("</body></html>");
html.setHtml(sb.toString());
player.sendPacket(html);
}
/**
* @param player L2PcInstance
* @param ColorId int
* @param ChangeType int
* @return boolean
*/
protected static boolean ChangeCharColor(L2PcInstance player, int ColorId, int ChangeType)
{
if (!_isColorManagerEnabled)
{
player.sendMessage("Not allowed by the server cofiguration");
return false;
}
int pLevel = player.getLevel();
if (pLevel < _minLevel)
{
player.sendMessage("Yor level is too low. Min level is " + _minLevel);
return false;
}
if (ColorId < 0 || ColorId > COLORS_DATA.length)
{
player.sendMessage("Incorrect action.");
return false;
}
if (ChangeType == 1 && player.getInventory().getAdena() < _priceForName ||
ChangeType == 2 && player.getInventory().getAdena() < _priceForTitle)
{
player.sendMessage("Incorrect Adena in you inventory. You do not have required Adena.");
return false;
}
try
{
if (ChangeType == 1)
{
// Name color change
if (!_allowNameChange)
{
player.sendMessage("Name color change is disabled.");
return true;
}
player.getAppearance().setNameColor(COLORS_DATA[ColorId][0] , COLORS_DATA[ColorId][1], COLORS_DATA[ColorId][2]);
player.reduceAdena("BuyNameColorChange", _priceForName, player.getLastFolkNPC(), true);
player.broadcastUserInfo();
player.store();
}
else if (ChangeType == 2)
{
// Title color change
if (!_allowTitleChange)
{
player.sendMessage("Title color change is disabled.");
return true;
}
player.getAppearance().setTitleColor(COLORS_DATA[ColorId][0] , COLORS_DATA[ColorId][1], COLORS_DATA[ColorId][2]);
player.reduceAdena("BuyTitleColorChange", _priceForTitle, player.getLastFolkNPC(), true);
player.broadcastUserInfo();
player.store();
}
player.sendMessage("Enjoy your new color!");
return true;
}
catch (Exception e)
{
_log.warn("An exception from L2CustomColorManager",e);
player.sendMessage("Incorrect action.");
return false;
}
}
/**
*
* @param player L2PcInstance
* @param command String
*/
@Override
public void onBypassFeedback(L2PcInstance player, String command)
{
StringTokenizer st = new StringTokenizer(command, " ");
String actualCommand = st.nextToken();
if (actualCommand.equalsIgnoreCase("SetNameColor"))
{
if (st.countTokens() < 1) return;
int ColorId = Integer.parseInt(st.nextToken());
ChangeCharColor(player,ColorId,1);
}
else if (actualCommand.equalsIgnoreCase("SetTitleColor"))
{
if (st.countTokens() < 1) return;
int ColorId = Integer.parseInt(st.nextToken());
ChangeCharColor(player,ColorId,2);
}
else if (actualCommand.equalsIgnoreCase("NColorsList"))
{
if (st.countTokens() < 1) return;
int val = Integer.parseInt(st.nextToken());
showColorsListPage(player,1,val);
}
else if (actualCommand.equalsIgnoreCase("TColorsList"))
{
if (st.countTokens() < 1) return;
int val = Integer.parseInt(st.nextToken());
showColorsListPage(player,2,val);
}
}
}