Jump to content

Recommended Posts

Posted

your making to much toughts, words in your mind, that not what acctualy need to be ! more you talk or think less time you have to acctualy make something that will give you knowledge !

 

Well it's interesting to know how people learnt Java. At least the question is legit, even if 80% of people learnt it the hard way, and maybe 5-10% are real developers IRL.

Posted

Well it's interesting to know how people learnt Java. At least the question is legit, even if 80% of people learnt it the hard way, and maybe 5-10% are real developers IRL.

i think they didnt learn it by talking on forums :D ?

 

Posted (edited)

So, tell me, what methods did you use and what would you recommend for me?

Ironically, the reason why I started with java was due to l2j. That's definitely not a good thing, since I started with 0.4.1, then C2 and up, which meant dealing with some horrible code. Eventually (around the time Wooden & KenM released the multiplexing mmocore) the code got better, design patterns were finally introduced, etc.

 

Regardless of the language, I've never found a better way to learn something than just by doing something you need for yourself. Don't get discouraged that at first your code will be bad (or at least highly influenced by other languages you already know) and thus the performance is likely to suffer. As you keep writing more code, you'll get used to the language and its specifics.

 

Try c++ if you think java is difficult.I never bothered opening a book to learn java.There are far more interesting languages than java.

As C++ is an old language, and was designed to have compilers completely compatible with C code, it has become increasingly complex, Eagle_Eye makes a correct point.

 

One of the main problems with C++ is that it's currently 2015 and you still can't avoid interfacing with C APIs at some point. Of course, the situation is much better, then, say, at 2010. You can call me a purist or whatever, but due to all the legacy compatibility "features", interfacing with C is prone to fatal errors if you forget just for a second that something that holds true in C++ world, may be interpreted differently after it crosses into C. Usually you should expect memory issues if you dared to assume something that doesn't hold true (and if you didn't take the time to learn all the features since K&R, you will, sooner or later).

 

On the other hand, if you strictly stay in the C++ world (it's not too hard now with Boost and similar libs), C++ can be as easy as Java. I think beecrypt tried to make itself an example of this.

 

Though, if performance matters to you, you will be forced to delve into the native side of things, which is the JVM for Java and all available compilers for your platform for C++.

Obviously, the JVM is much easier.

Changes in optimizing compilers (currently referred simply as 'compilers'), even when you take away security fixes & default option changes, can both boost your application speed significantly without any effort on your part, or, (e.g. with a race condition fix) effectively make your application ultra slow, even though changing a few lines or reordering a few statements will make it as fast as it used to be, etc. You'll also have to learn all about branch prediction, at the very least.

 

 

 

To sum it up, it always depends on how much you want to learn.

It doesn't take much time to learn about a language if you simply want to modify existing software. However, there is no way to skip the time you will have to learn how the software you are going to modify works.

Edited by _dev_
Posted

I made a Java project mastering pack organization with time. You just need a lot of time. I know exactly where to search if I need something and I know what methods do what.

 

And I repeat, Java is easy. Most problems can be solved Googling it (90% of time). You don't have to busy about collecting dead variables (but still if you can code it well to avoid terrible optimizations it's always better). What is hard on Java is what would be hard on any other langage : CREATE EXACTLY WHAT YOU WANT (and I would add as a personal challenge and aCis motto : USING THE LESS POSSIBLE RESSOURCES).

 

The hard part is taking time to explore, and how you handle YOURSELF your code organization. If you can't organize yourself you can't support big reworks and are limited to little edits.

 

To be a "L2J dev" you need 4 things :

  • a working brain with basic notions of logic
  • CTRL+F from Eclipse
  • Google search (mostly stackoverflow website answers and javadoc)
  • a lot of time to explore the project.

If you read aCis changesets from 0 to latest, you will figure by yourself I learnt in 4 years of coding. Even OOP stuff like inheritance I DISCOVERED IT one day. And by discovered, I really meant I was  ^-^ in front of my computer when I discovered L2PcInstance was a L2Character, which was itself a L2Object and than a method from L2Object could be used on L2PcInstance, or even overriden to handle different behavior.

 

I had logic concept as I code since my 13yo, but that was on BASIC langage which got strictly nothing similar.

 

And you won't learn project organization on any book, nor L2J javadoc which is deprecated most of the time. You have to take your balls, take time and learn by yourself.

 

Or find someone who will teach you. I, personally, took time to create tutorials, correct my helpers quests and say where it was wrong, in order they deliver better written quests (and I got less code to fix). roko91 for example mastered quests rework, he does almost 0 error both coding and quest-related and it helps me a lot :). Obviously quest system is limited to methods from quest, and my own help is limited to my pack and this section of forums for others projects.

So, let's say we have this code for Interlude Bluff. Credits to: The L2JServer Forum and ŚyśţęmƒяәдҚς

Index: /trunk/Eclipse-Game/java/net/sf/l2j/gameserver/network/serverpackets/BeginRotation.java
===================================================================
--- /trunk/Eclipse-Game/java/net/sf/l2j/gameserver/network/serverpackets/BeginRotation.java (revision 12)
+++ /trunk/Eclipse-Game/java/net/sf/l2j/gameserver/network/serverpackets/BeginRotation.java (revision 159)
@@ -19,18 +19,15 @@
 package net.sf.l2j.gameserver.network.serverpackets;
 
-import net.sf.l2j.gameserver.model.actor.instance.L2PcInstance;
-
 public class BeginRotation extends L2GameServerPacket
 {
 	private static final String _S__77_BEGINROTATION = "[S] 62 BeginRotation";
-	private int _charObjId;
-	private int _degree;
-	private int _side;
+	private int _charObjId, _degree, _side, _speed;
 
-	public BeginRotation(L2PcInstance player, int degree, int side)
+	public BeginRotation(int objectId, int degree, int side, int speed)
 	{
-		_charObjId = player.getObjectId();
+		_charObjId = objectId;
 		_degree = degree;
 		_side = side;
+		_speed = speed;
 	}
 
@@ -42,4 +39,5 @@
 		writeD(_degree);
 		writeD(_side);
+		writeD(_speed);
 	}
 
Index: /trunk/Eclipse-Game/java/net/sf/l2j/gameserver/network/serverpackets/StopRotation.java
===================================================================
--- /trunk/Eclipse-Game/java/net/sf/l2j/gameserver/network/serverpackets/StopRotation.java (revision 12)
+++ /trunk/Eclipse-Game/java/net/sf/l2j/gameserver/network/serverpackets/StopRotation.java (revision 159)
@@ -19,6 +19,4 @@
 package net.sf.l2j.gameserver.network.serverpackets;
 
-import net.sf.l2j.gameserver.model.L2Character;
-
 /**
  * This class ...
@@ -29,11 +27,11 @@
 {
 	private static final String _S__78_STOPROTATION = "[S] 63 StopRotation";
-	private int _charObjId;
-	private int _degree;
+	private int _charObjId, _degree, _speed;
 
-	public StopRotation(L2Character player, int degree)
+	public StopRotation(int objectId, int degree, int speed)
 	{
-		_charObjId = player.getObjectId();
+		_charObjId = objectId;
 		_degree = degree;
+		_speed = speed;
 	}
 
@@ -44,4 +42,6 @@
 		writeD(_charObjId);
 		writeD(_degree);
+		writeD(_speed);
+		writeC(0); // ?
 	}
 
Index: /trunk/Eclipse-Game/java/net/sf/l2j/gameserver/network/clientpackets/FinishRotating.java
===================================================================
--- /trunk/Eclipse-Game/java/net/sf/l2j/gameserver/network/clientpackets/FinishRotating.java (revision 12)
+++ /trunk/Eclipse-Game/java/net/sf/l2j/gameserver/network/clientpackets/FinishRotating.java (revision 159)
@@ -46,5 +46,5 @@
 		if (getClient().getActiveChar() == null)
 		    return;
-		StopRotation sr = new StopRotation(getClient().getActiveChar(), _degree);
+		StopRotation sr = new StopRotation(getClient().getActiveChar().getObjectId(), _degree, 0);
 		getClient().getActiveChar().broadcastPacket(sr);
 	}
Index: /trunk/Eclipse-Game/java/net/sf/l2j/gameserver/network/clientpackets/StartRotating.java
===================================================================
--- /trunk/Eclipse-Game/java/net/sf/l2j/gameserver/network/clientpackets/StartRotating.java (revision 12)
+++ /trunk/Eclipse-Game/java/net/sf/l2j/gameserver/network/clientpackets/StartRotating.java (revision 159)
@@ -46,5 +46,5 @@
 		if (getClient().getActiveChar() == null)
 		    return;
-		BeginRotation br = new BeginRotation(getClient().getActiveChar(), _degree, _side);
+		BeginRotation br = new BeginRotation(getClient().getActiveChar().getObjectId(), _degree, _side, 0);
 		getClient().getActiveChar().broadcastPacket(br);
 	}
Index: /trunk/Eclipse-Game/java/net/sf/l2j/gameserver/skills/effects/EffectBluff.java
===================================================================
--- /trunk/Eclipse-Game/java/net/sf/l2j/gameserver/skills/effects/EffectBluff.java (revision 12)
+++ /trunk/Eclipse-Game/java/net/sf/l2j/gameserver/skills/effects/EffectBluff.java (revision 159)
@@ -19,10 +19,10 @@
 package net.sf.l2j.gameserver.skills.effects;
 
-import net.sf.l2j.gameserver.ai.CtrlIntention;
-import net.sf.l2j.gameserver.model.L2CharPosition;
 import net.sf.l2j.gameserver.model.L2Effect;
 import net.sf.l2j.gameserver.model.actor.instance.L2FolkInstance;
 import net.sf.l2j.gameserver.model.actor.instance.L2NpcInstance;
 import net.sf.l2j.gameserver.model.actor.instance.L2SiegeSummonInstance;
+import net.sf.l2j.gameserver.network.serverpackets.BeginRotation;
+import net.sf.l2j.gameserver.network.serverpackets.StopRotation;
 import net.sf.l2j.gameserver.network.serverpackets.SystemMessage;
 import net.sf.l2j.gameserver.skills.Env;
@@ -33,5 +33,6 @@
  * Implementation of the Bluff Effect
  */
-final class EffectBluff extends L2Effect {
+final class EffectBluff extends L2Effect
+{
 
     public EffectBluff(Env env, EffectTemplate template)
@@ -50,6 +51,5 @@
 	public void onStart()
     {
-        getEffected().startFear();
-    	if(getEffected() instanceof L2FolkInstance) return;
+        if(getEffected() instanceof L2FolkInstance) return;
     	// if(getEffected() instanceof L2SiegeGuardInstance) return;
     	// Cannot be used on Headquarters Flag.
@@ -58,33 +58,12 @@
 
     	if(getEffected() instanceof L2SiegeSummonInstance)
-    	{
     		return;
-    	}
-        int posX = getEffected().getX();
-        int posY = getEffected().getY();
-        int posZ = getEffected().getZ();
-        int signx=-1;
-        int signy=-1;
-        if (getEffected().getX()>getEffector().getX())
-            signx=1;
-        if (getEffected().getY()>getEffector().getY())
-            signy=1;
-
-        //posX += signx*40; //distance less than melee attacks (40)
-        //posY += signy*40;
-
-        getEffected().setRunning();
-        getEffected().getAI().setIntention(CtrlIntention.AI_INTENTION_MOVE_TO,
-                              new L2CharPosition(posX +(signx*40),posY + (signy*40),posZ,0));
-        getEffected().sendPacket(SystemMessage.sendString("You can feel Bluff's effect"));
-        getEffected().setTarget(null);
+    	
+    	getEffected().broadcastPacket(new BeginRotation(getEffected().getObjectId(), getEffected().getHeading(), 1, 65535));
+    	getEffected().broadcastPacket(new StopRotation(getEffected().getObjectId(), getEffector().getHeading(), 65535));
+    	getEffected().setHeading(getEffector().getHeading());
         onActionTime();
     }
-    @Override
-	public void onExit()
-    {
-        getEffected().stopFear(this);
-
-    }
+    
     @Override
 	public boolean onActionTime()
Index: /trunk/Eclipse-Game/java/net/sf/l2j/gameserver/skills/effects/EffectRemoveTarget.java
===================================================================
--- /trunk/Eclipse-Game/java/net/sf/l2j/gameserver/skills/effects/EffectRemoveTarget.java (revision 12)
+++ /trunk/Eclipse-Game/java/net/sf/l2j/gameserver/skills/effects/EffectRemoveTarget.java (revision 159)
@@ -18,4 +18,5 @@
 package net.sf.l2j.gameserver.skills.effects;
 
+import net.sf.l2j.gameserver.ai.CtrlIntention;
 import net.sf.l2j.gameserver.model.L2Effect;
 import net.sf.l2j.gameserver.skills.Env;
@@ -44,4 +45,5 @@
         getEffected().abortAttack();
         getEffected().abortCast();
+        getEffected().getAI().setIntention(CtrlIntention.AI_INTENTION_IDLE, getEffector());
     }
 
Index: /trunk/Eclipse-Game/java/net/sf/l2j/gameserver/ai/AbstractAI.java
===================================================================
--- /trunk/Eclipse-Game/java/net/sf/l2j/gameserver/ai/AbstractAI.java (revision 12)
+++ /trunk/Eclipse-Game/java/net/sf/l2j/gameserver/ai/AbstractAI.java (revision 159)
@@ -624,5 +624,5 @@
             {
                 // Send a Server->Client packet StopRotation to the actor and all L2PcInstance in its _knownPlayers
-                StopRotation sr = new StopRotation(_actor, pos.heading);
+            	StopRotation sr = new StopRotation(_actor.getObjectId(), pos.heading, 0);
                 _actor.sendPacket(sr);
                 _actor.broadcastPacket(sr);

What do you search in order to make bluff last for 1 second and have 50% chance?

 

(That was just an easy example, I don't need such a code).

 

I suppose what you mean is one has to apply patches for years so that one day he'll know how to edit already existing parts, mostly by searching and write a small code.

 

 

when I discovered L2PcInstance was a L2Character, which was itself a L2Object and than a method from L2Object could be used on L2PcInstance, or even overriden to handle different behavior.

Can you explain that with more details?

 

A tutorial explaining and analyzing some already existing codes of L2PCInstance.java would probably be the most useful share on MaxCheaters.

Posted (edited)

What do you search in order to make bluff last for 1 second and have 50% chance?

Such 'static' info is stored under xml.

Edited by SweeTs
Posted (edited)

Java is considered a Hard language to learn worldwide, 2 cases you found it easy

  • You write static non-reusable code (you are shitcoding)
  • You are a genius

 

c++ hard? c++ is hard as far as you play on hardware level, its far more easy to code OOP in c++ because the language is big and you can do anything you want with macros and overloading

Edited by xxdem
Posted

c++ hard? c++ is hard as far as you play on hardware level

And pretty much all widespread OSes (embedded included) have a native C API. Of course, the driver model can allow C++ code, but interface points will always be C (you can forget about dealing in classes at the hardware level, although you can use them for internal state management inside the driver).

 

its far more easy to code OOP in c++ because the language is big

C++ also has real generics (though that has its side effects on the compilers), which are easier because you can declare any reasonable type limits, unlike in Java where you can't do this and that and also that other thing because in runtime there's no generics at all and thus nothing of this can be enforced.

 

and you can do anything you want with macros and overloading

Two most dreaded features a language can have. An unlimited complexity preprocessing stage and the ability to make operators do things that only make sense to a single person.

Of course, Java has those annotations and technically they can be used to induce an unlimited complexity preprocessing stage. But this is somewhat less popular in Java, because it is not used by default (at least not for code generation), while a preprocessing stage always exists in C/C++, just teasing to use more than imports or constant declarations.

Posted (edited)

C++ also has real generics (though that has its side effects on the compilers), which are easier because you can declare any reasonable type limits, unlike in Java where you can't do this and that and also that other thing because in runtime there's no generics at all and thus nothing of this can be enforced.

 

Fake generics is what I hate in java, you can make a pretty generic code that under the hood will have a shitload of casting from Object to the target class on runtime (idk if the JIT optimises it, I guess not)

 

Thats what makes java difficult, its hard to make good code with it

 

Java has these drawback intended, they can't make cross-platform generic code

 

 

To call a programming language easy means that you have mastered its libraries (its default libs at least)

 

Two most dreaded features a language can have. An unlimited complexity preprocessing stage and the ability to make operators do things that only make sense to a single person.

Of course, Java has those annotations and technically they can be used to induce an unlimited complexity preprocessing stage. But this is somewhat less popular in Java, because it is not used by default (at least not for code generation), while a preprocessing stage always exists in C/C++, just teasing to use more than imports or constant declarations.

 

I agree that the code can get out of control, but these are two great tools for the c++ developer, but if you work in a group where everyone is doing his own c++ style you're screwed

Edited by xxdem
Posted (edited)

Fake generics is what I hate in java, you can make a pretty generic code that under the hood will have a shitload of casting from Object to the target class on runtime (idk if the JIT optimises it, I guess not)

JIT cannot optimize based on something that isn't there :D

And since generics only exist at compile time in Java, JIT will keep the CHECKCAST instruction equivalent in the compiled code, even though it may be obvious from actual code logic that the object cannot be of any different type at that point.

 

So two possible approaches to this performance issue (since there is definitely more than one branch involved in CHECKCASTing): a configurable compiled bytecode postprocessor (preferably) or a configurable agent that would remove unnecessary CHECKCAST instructions from bytecode. After all, refs on the stack are untyped.

 

Of course, if unrelated CHECKCASTs are removed, you wont be getting Exceptions at the time of invocation, but (unchecked) Errors instead. Hence it must be configurable to only process parts of the code.

Edited by _dev_
Posted (edited)

 

What do you search in order to make bluff last for 1 second and have 50% chance?

 

(That was just an easy example, I don't need such a code).

 

I suppose what you mean is one has to apply patches for years so that one day he'll know how to edit already existing parts, mostly by searching and write a small code.

 

Can you explain that with more details?

 

A tutorial explaining and analyzing some already existing codes of L2PCInstance.java would probably be the most useful share on MaxCheaters.

 

Your exemple question refers to a mis-knowledge of the project. Skills data is handled by... L2Skill model, which is generated from XML files loading. When I say you have to check the project, I also speak about the datapack. The core processes the datapack, and without datapack you haven't gameserver.

 

You should check what loads when you launch a gameserver, then see the data itself. From the data, you ctrl+f any XML tag inside core and bingo, you will find where's the XML is processed. That's the sort of basic logic you have to figure by yourself (I don't even speak about developement logic).

 

L2PcInstance got nothing specific to explain, it's just a mess concerning players stuff, but the hierarchy between classes is vital to understand. Imagine a tree, where L2Object is the root and L2PcInstance is one of the highest branch. You only have to draw it to understand a lot of things by yourself.

 

I invite you to download Class Visualizer  compile L2J project and load l2jserver into it.

 

For example, you see L2Object is a regular Object, and is the mother class of ItemInstance, L2Character and L2StaticObjectInstance. L2Character is itself the mother classes of... which are mother classes of... All methods and variables from mother class can be used on children classes. But a method from children can't be used on mother, only on objects sharing the same model type.

 

A L2Character object can't use ItemInstance variables, but as they are both L2Object, they can use common shared primitive methods.

 

Do you see the Darwin species evolution tree ? It's similar. A horse doesn't share all properties of a dolphin, but they are both mammal type.

 

9rtajc.png

Edited by Tryskell
Posted

Your exemple question refers to a mis-knowledge of the project. Skills data is handled by... L2Skill model, which is generated from XML files loading. When I say you have to check the project, I also speak about the datapack. The core processes the datapack, and without datapack you haven't gameserver.

 

You should check what loads when you launch a gameserver, then see the data itself. From the data, you ctrl+f any XML tag inside core and bingo, you will find where's the XML is processed. That's the sort of basic logic you have to figure by yourself (I don't even speak about developement logic).

 

L2PcInstance got nothing specific to explain, it's just a mess concerning players stuff, but the hierarchy between classes is vital to understand. Imagine a tree, where L2Object is the root and L2PcInstance is one of the highest branch. You only have to draw it to understand a lot of things by yourself.

 

I invite you to download Class Visualizer  compile L2J project and load l2jserver into it.

 

For example, you see L2Object is a regular Object, and is the mother class of ItemInstance, L2Character and L2StaticObjectInstance. L2Character is itself the mother classes of... which are mother classes of... All methods and variables from mother class can be used on children classes. But a method from children can't be used on mother, only on objects sharing the same model type.

 

A L2Character object can't use ItemInstance variables, but as they are both L2Object, they can use common shared primitive methods.

 

Do you see the Darwin species evolution tree ? It's similar. A horse doesn't share all properties of a dolphin, but they are both mammal type.

 

9rtajc.png

A most interresting post once again Tryskell.

 

When the GameServer launches it doesn't give specific xml names. It reads, for instance, "loaded 3k skills". Could you explain that a little more? I mean using the GameServer.bat to find the appropriate core file or method to edit.

 

A guide about java methods and commands would be nice. Or a code analyzer, explaining in detail each line of a java code. That would be really helpful.

Posted (edited)

There is nothing like a "explained code analyzer", for the simple reason a method is crafted for particular uses. At best you will have documented javadoc for that method, at worst the content itself will be so messed you will have hard time to figure what it does. Fortunately on L2J, there isn't such stuff (and if you want to see how a messed code is, read L2J russian forks with broken english, such as "reflection" = "instance"). You can refer to method content and read variables or called methods, it's your only documentation. On Eclipse you can ctrl+left click on any method to "teleport" to that method and read content.

 

Edit the .bat you are refering with notepad (I take aCis one but L2J is similar)

REM Default parameters for a basic server.
java -Xmx512m -cp ./libs/*; net.sf.l2j.gameserver.GameServer

As you can see the .bat launches the class net.sf.l2j.gameserver.GameServer. This class handles server startup, you will find all stuff related to data loading here.

Edited by Tryskell
  • 1 month later...
Posted

As someone asked me "where to begin" by PM, I linked to that topic and also added :

 

 

About L2J project, really, there is nothing to "learn"... It's all about exploring what class does what. You will learn which class does what after a while. You can't know L2PcInstance is the player class before figuring it out yourself, or until someone wants to explain what does each of the 1200+ classes of L2J.

 

About Java, I suggest you to learn basics if you haven't :

- All "commands" : break, return, if/else if, for, do/while,...

- Logic operators ( || / |, && / &)

- OOP properties (notably inheritance, polymorphism, object/class/method/variable)

- The variables types (String, int, float, double,...)

 

You have to know than Java got a documentation named Javadoc, which references all possibles methods handled by Java. L2J got its own Javadoc, but you have to know it's incomplete for 75% of code.

 

About Java use, if you got a specific question you can Google and search stackoverflow website links, many questions are already answered. I often use it. Type any question on google, and if it's correctly formulated you should find a stackoverflow link.

 

About breaking files, that's the reason SVN exists  :). Create your own SVN on Assembla, download any pack (mine or another) and put it on Assembla (there are topics about it, search for subclipse plugin tutorial on those forums). A SVN is a place where your code is safe, you can break it as you want and revert to previous version if you break too much (which avoid you to begin from zero each time).

 

I gave you a lot of informations, I suggest you to first setup eclipse and the project you will use, then try to subclipse it asap (you have to create your own space on Assembla), and finally you can begin to mess it. I invite you to apply customs diff patches by yourself and try to guess what you are doing reading the content you apply.

Posted

You can learn the programming basics at first, and then dive into Java. It's much easier to browse the API, when you know what you need and where should you looking for it!

Posted

You can learn the programming basics at first, and then dive into Java. It's much easier to browse the API, when you know what you need and where should you looking for it!

 

Yes , learn basics than try to understand what is what and why is why.

I used some nabsters websites for starting , but havnt finished all the course.

Too bad i dont have time for learning java programing, but i guess this one could help you if you have totaly 0 understanding.

https://www.codecademy.com/

There`s a lot of internet "schools" of programing.

It gives you theory and then it ask you program something with that theory  - in my opinion you couldn find better.

After you know basics  you can start working with l2j and discover things - it will be easier to understand.

 

 

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.
Note: Your post will require moderator approval before it will be visible.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...