help with some imports

Support for the latest build of L2J Server, get help here with installations, upgrades, problems.
Do not post bugs reports here, use viewforum.php?f=77 instead.
There is no support for other server builds than the official provided by l2jserver.com
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
User avatar
Crepsley
Posts: 29
Joined: Sat Feb 20, 2010 2:47 pm
Location: Romania
Contact:

help with some imports

Post by Crepsley »

import org.apache.commons.logging.Log;
import org.apache.commons.logging.LogFactory;

cant manage to find this can some on help me ?
--advertisingremoved--
User avatar
janiii
L2j Veteran
L2j Veteran
Posts: 4269
Joined: Wed May 28, 2008 3:15 pm
Location: Slovakia

Re: help with some imports

Post by janiii »

l2j doesnt use apache commons logging, l2j uses java util logging. check other l2j java classes for how logging is done in l2j.

instead of your org.apache imports use:

Code: Select all

import java.util.logging.Logger;
also instead of

Code: Select all

private static final Log _log = LogFactory.getLog(YourClassName.class.getName());
use

Code: Select all

private static final Logger _log = Logger.getLogger(YourClassName.class.getName());
where YourClassName is your class name
DO NOT EVEN TRY TO MESS WITH ME!
forum flOOder dancing dEVILoper
I don't give private support - PM will be ignored!
User avatar
Crepsley
Posts: 29
Joined: Sat Feb 20, 2010 2:47 pm
Location: Romania
Contact:

Re: help with some imports

Post by Crepsley »

Ty very much for explication now is clear to me

Edit :( i have more errors original script

Code: Select all

/* * 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 com.l2open.gameserver.datatables; import java.sql.PreparedStatement;import java.sql.ResultSet;import java.util.Vector; import javolution.util.FastMap; import org.apache.commons.logging.Log;import org.apache.commons.logging.LogFactory; import com.l2jserver.L2DatabaseFactory;import com.l2jserver.gameserver.model.actor.instance.L2PcInstance; public class PcColorTable{	private final static Log _log = LogFactory.getLog(PcColorTable.class);	/** List of names and color values container */	private FastMap<String, PcColorContainer> _pcColors = new FastMap<String, PcColorContainer>(); 	PcColorTable()	{		java.sql.Connection con = null;		try		{			Vector<String> deleteNames = new Vector<String>();			con = L2DatabaseFactory.getInstance().getConnection();			PreparedStatement ps = con.prepareStatement("SELECT * FROM `character_colors`");			ResultSet rs = ps.executeQuery();			while (rs.next())			{				long regTime = rs.getLong("reg_time"), time = rs.getLong("time");				String charName = rs.getString("char_name");				int color = rs.getInt("color");				if ((time == 0) || (regTime + time > System.currentTimeMillis()))					_pcColors.put(charName, new PcColorContainer(color, regTime, time));				else					deleteNames.add(charName);			}			ps.close();			rs.close();			for (String deleteName : deleteNames)			{				PreparedStatement psDel = con.prepareStatement("DELETE FROM `character_colors` WHERE `char_name`=?");				psDel.setString(1, deleteName);				psDel.executeUpdate();				psDel.close();			}			_log.info("PcColorTable: Loaded: " + _pcColors.size() + " Expired/Deleted: " + deleteNames.size());			deleteNames.clear();		}		catch (Exception e)		{			_log.error("Error while loading data from DB!");		}		finally		{			L2DatabaseFactory.close(con);		}	} 	/**	 * Returns the instance of this class, assign a new object to _instance if it's null	 * 	 * @return PcColorTable	 */	public static PcColorTable getInstance()	{		return SingletonHolder._instance;	} 	/**	 * Sets the name color of the L2PcInstance if it name is on the list	 * 	 * @param activeChar	 */	public synchronized void process(L2PcInstance activeChar)	{		PcColorContainer colorContainer = _pcColors.get(activeChar.getName());		if (colorContainer == null)			return;		long time = colorContainer.getTime();		if ((time == 0) || (colorContainer.getRegTime() + time > System.currentTimeMillis()))		{			activeChar.getAppearance().setNameColor(colorContainer.getColor());			activeChar.broadcastUserInfo();		}		else			delete(activeChar.getName());	} 	/**	 * Adds the name of the L2PcInstance to the list with the color values	 * 	 * @param activeChar	 * @param color	 * @param regTime	 * @param time	 */	public synchronized void add(L2PcInstance activeChar, int color, long regTime, long time)	{		String charName = activeChar.getName();		PcColorContainer colorContainer = _pcColors.get(charName);		if (colorContainer != null)		{			if (!delete(charName))				return;		}		java.sql.Connection con = null;		try		{			con = L2DatabaseFactory.getInstance().getConnection();			PreparedStatement psIns = con.prepareStatement("INSERT INTO `character_colors` VALUES (?,?,?,?)");			psIns.setString(1, charName);			psIns.setInt(2, color);			psIns.setLong(3, regTime);			psIns.setLong(4, time);			psIns.executeUpdate();			psIns.close();			_pcColors.put(activeChar.getName(), new PcColorContainer(color, regTime, time));			activeChar.getAppearance().setNameColor(color);			activeChar.broadcastUserInfo();			activeChar.sendMessage("Your name color has been changed!");		}		catch (Exception e)		{			_log.error("Pc Color Table: Error while add " + charName + "'s color to DB!");		}		finally		{			L2DatabaseFactory.close(con);		}	} 	/**	 * Returns true if the name is deleted successfully from list, otherwise false Deletes the name from the list	 * 	 * @param charName	 * @return boolean	 */	public synchronized boolean delete(String charName)	{		PcColorContainer colorContainer = _pcColors.get(charName);		if (colorContainer == null)			return false;		colorContainer = null;		java.sql.Connection con = null;		try		{			con = L2DatabaseFactory.getInstance().getConnection();			PreparedStatement psDel = con.prepareStatement("DELETE FROM `character_colors` WHERE `char_name`=?");			psDel.setString(1, charName);			psDel.executeUpdate();			psDel.close();			_pcColors.remove(charName);		}		catch (Exception e)		{			_log.error("Pc Color Table: Error while delete " + charName + "'s color from DB!");			return false;		}		finally		{			L2DatabaseFactory.close(con);		}		return true;	} 	@SuppressWarnings("synthetic-access")	private static class SingletonHolder	{		protected static final PcColorTable _instance = new PcColorTable();	}} 
--advertisingremoved--
User avatar
JIV
L2j Veteran
L2j Veteran
Posts: 1882
Joined: Sun Jan 06, 2008 8:17 pm
Location: Slovakia
Contact:

Re: help with some imports

Post by JIV »

You cant just take script from other l2j forks and hope it will work. To fix it you should have at least basic java knowledge and instead of posting questions you could spent this time with learning and trying to make it right.
User avatar
janiii
L2j Veteran
L2j Veteran
Posts: 4269
Joined: Wed May 28, 2008 3:15 pm
Location: Slovakia

Re: help with some imports

Post by janiii »

JIV is true. modding l2j server is not just adding some stuff, you have to know at least something about java programming and java code.

- your package declaration is wrong, imo should be

Code: Select all

package com.l2jserver.gameserver.datatables;
- java util logging doesnt have error method, use warning method instead

Code: Select all

_log.warning("Error while loading data from DB!");
- l2j doesnt have close method in L2DatabaseFactory, use this instead:

Code: Select all

try{	con.close();}catch (Exception e){}
DO NOT EVEN TRY TO MESS WITH ME!
forum flOOder dancing dEVILoper
I don't give private support - PM will be ignored!
User avatar
ThePhoenixBird
L2j Inner Circle
L2j Inner Circle
Posts: 1857
Joined: Fri May 27, 2005 5:11 pm

Re: help with some imports

Post by ThePhoenixBird »

USE SUPPORT FORUMS

DO NOT POST HELP REQUESTS IN OFF-TOPIC!!! :x
Post Reply