[QUESTION] I want to learn :)

This is not a Support area! Discuss about the Server here. Non-Server related discussion goes in Off-Topic Discussion.
Forum rules
READ NOW: L2j Forums Rules of Conduct
Post Reply
User avatar
Minutis
Posts: 56
Joined: Thu Feb 22, 2007 2:01 pm

[QUESTION] I want to learn :)

Post by Minutis »

Hi, I'm very intrested in JAVA developing, I still lack of knowledge, so I'm here to learn. I was studying c6 libraries (maybe this is wrong forum, but I think this one fits best for my idea). So far, I figured out that bsf.jar was used to connect java with python (to be more specific jython). But after Kamael CT1 initial import bsf.jar was gone and instead IF I'M CORRECT you used jython-engine.jar + your own L2ScriptEngineManager. Am I right? If not, please explain how you connect jython with java.

How to know, how to use libary (i know how to set references and use methods in source, but I'm talking about how to know if this library will give anything better) , for example, where you look, for new libaries, that can fasten servers performance, or just increase stability? Is it just like - you know what you need, and you look for it (exmpl: we need to connect jython with java so we look for appropriate libraries?) or there any sites, where you can cehck what new libraries was released and etc :) I still don't understand, you use some libs of your own and some you take from other GPL projects (i mean these libraries are build under GPL).

And last thing, if I want to turn all Quests from python to Java, in witch direction should I go? I know that then you would need to build new QuestManager from scratch. How to start working on things like this, any tips? Any suggested sites? I know JAVA about 5/10 and I'm stuck i learned everything from others work and all, but now i'm stuck, i can't do anything to progress, so i think this should be my next step.

Please when you have time, answer me as clearly and informative as you can :) This could be a step for other members too :)

My english is ok, but sorry for mistakes :)
Probe
Posts: 915
Joined: Thu Sep 03, 2009 6:36 pm
Location: Israel
Contact:

Re: [QUESTION] I want to learn :)

Post by Probe »

I can answer about the writing the quest from python to java part -
you don't need any new questengine, the Quest class is written in java, and is extended by a class called JQuest which is what jython uses.
to make a quest in java all you have to do is write

Code: Select all

 import com.l2jserver.gameserver.model.quest.Quest; public class YourQuestName extends Quest{}
and overwrite the necessary methods.
For an example you can look at the Saga Quests, which are all written in java:
http://www.l2jdp.com/svn/trunk/datapack ... Class.java
User avatar
Minutis
Posts: 56
Joined: Thu Feb 22, 2007 2:01 pm

Re: [QUESTION] I want to learn :)

Post by Minutis »

So if I understood corectly, QuestJython class is only used as a link between python and java? And all methods are called from model.quest package? Could you explain a little bit this class (this is older rev QuestJython.java).

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 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.quest.jython; import net.sf.l2j.Config;import net.sf.l2j.gameserver.model.quest.Quest; import org.apache.bsf.BSFException;import org.apache.bsf.BSFManager; public abstract class QuestJython extends Quest{	private static BSFManager _bsf; 	/**	 * Initialize the engine for scripts of quests, luxury shops and blacksmith	 */	public static void init()	{		try		{			// Initialize the engine for loading Jython scripts			_bsf = new BSFManager();			// Execution of all the scripts placed in data/jscript			// inside the DataPack directory 			String dataPackDirForwardSlashes = Config.DATAPACK_ROOT.getPath().replaceAll("\\\\","/");			String loadingScript =			    "import sys;"			  + "sys.path.insert(0,'" + dataPackDirForwardSlashes + "');"			  + "import data"; 			_bsf.exec("jython", "quest", 0, 0, loadingScript);		}		catch (BSFException e)		{			e.printStackTrace();		}	} 	public static boolean reloadQuest(String questFolder)	{		try		{			_bsf.exec("jython", "quest", 0, 0, "reload(data.jscript."+questFolder+");");			return true;		}		catch (Exception e)		{			//System.out.println("Reload Failed");			//e.printStackTrace();		}		return false;	} 	/**	 * Constructor used in jython files.	 * @param questId : int designating the ID of the quest	 * @param name : String designating the name of the quest	 * @param descr : String designating the description of the quest	 */	public QuestJython(int questId, String name, String descr)	{		super(questId, name, descr);	}} 
Why is BSF manager used? In GE source i see completely different class only with constructor and no BSF manager usage?

And why SagaSuperclass class written in JAVA still extends QuestJython and not only Quest.
User avatar
JIV
L2j Veteran
L2j Veteran
Posts: 1882
Joined: Sun Jan 06, 2008 8:17 pm
Location: Slovakia
Contact:

Re: [QUESTION] I want to learn :)

Post by JIV »

bsh-engine.jar - faenor engine
jython-engine.jar - jython quests
java-engine.jar - java scripts
User avatar
Minutis
Posts: 56
Joined: Thu Feb 22, 2007 2:01 pm

Re: [QUESTION] I want to learn :)

Post by Minutis »

If it is possible maybe you could give me more detailed information, about witch libs are developed by l2jserver team and wich are just seperate projects? And a little more detailed description of each.
Last edited by Minutis on Wed Jan 13, 2010 2:55 pm, edited 2 times in total.
Post Reply