Hi Walter -
Thanks for your reply, but that's not my question. The location of the Bukkit API is well documented in the material you have built. I've used it quite a bit, with good results.
Please allow me to clarify my question. I'll do it with a real-world example that I am working on.
I'm writing a plugin that allows the player to cast a specific enchantment at a specific level. (I dislike the random nature of Minecraft's normal enchantment mechanic.) I'm also making it so that the player must expend reagents to cast the enchantment, and so that the player can expend blocks of redstone in place of experience levels.
I actually have all of this working quite well, but there were points where the Bukkit API docs were not entirely illuminating.
Specifically, ...
The API doc for org.bukkit.inventory.ItemStack has:
addEnchantment(Enchantment ench, int level)
So now I need to have an Enchantment object ...
The API doc for org.bukkit.enchantments.Enchantment has [1]:
getByName(String name)
So now I need to know the allowable input values for 'name'.
The question I'm asking could be phrased for this example as:
"What can I read to find out the allowable input values for org.bukkit.enchantments.Enchantment.getByName() ?"
Again, this is an example. I'm really asking the general question, "What can I read to find out the *details* for using the Bukkit API?"
I framed my initial question in terms of the code relationship because I know that -- by definition -- reading the source code will tell me authoritatively about the details beyond what is revealed by the API docs.
As it turns out, I found the answer for the valid 'name' values for org.bukkit.enchantments.Enchantment.getByName(name), but through some experimentation. After I had the answer, I used it to search 'backwards' through the Java source files that are downloaded/created during the standard Spigot installation process, but it would have been more direct to work my way forward. But for that, I would need to know the best/proper starting point. Hence, my question.
Here's a second example:
In your arrows.js plugin, you call events.projectileHit( __plugin.bukkit ? onBukkitArrowHit : onCanaryArrowHit).
Focusing on just the Bukkit part of this, this calls events.on(org.bukkit.event.entity.ProjectileHitEvent, callback, priority).
This registers onBukkitArrowHit() as a callback for ProjectileHitEvent events.
The Bukkit API docs for org.bukkit.event.entity.ProjectileHitEvent show that as a subclass of org.bukkit.event.entity.EntityEvent it has an 'entity' field, which shows how you are able to (in onBukkitArrowHit()) assign "projectile = event.entity". So far, so good.
But then you assign "shooter = projectile.shooter", and I don't see where the Bukkit API docs make it clear that this is possible. 'Entity' does not have a field 'shooter', nor does 'Arrow'.
But, I see in the Java source files in .../net/minecraft/server/EntityArrow.java that EntityArrow has a public field 'shooter'. But in the directory tree created by the standard Spigot installation, I have four EntityArrow.java files:
./CraftBukkit/src/main/java/net/minecraft/server/EntityArrow.java
./Spigot/CraftBukkit/src/main/java/net/minecraft/server/EntityArrow.java
./Spigot/Spigot-Server/src/main/java/net/minecraft/server/EntityArrow.java
./work/decompile-cf6b1333/net/minecraft/server/EntityArrow.java
Hence, again, my question about how best to read the source code in looking for details *beyond* the Bukkit API docs.
Much more succinctly, when *you* wrote the arrows.js plugin, how did *you* know that there was a 'shooter' field you could make use of?
I see that the Projectile class has a getShooter() method, so is there a relationship between getShooter() and the filed .shooter? Is there something that turns all of the Bukkit classes' getters into fields? If so, what about getters that aren't named getNNNN? (like Projectile.doesBounce()) ? And what naming convention is used? More generally : Where can I go to find out this kind of detail that bridges the Bukkit API to ScriptCraft?
I've many ideas for contributing to ScriptCraft, and some insight into this lower-level stuff would help me contribute in that way.
Thanks again for everything that ScriptCraft is, and all that you've put into it.
- Andrew
[1] org.bukkit.enchantments.Enchantment also has:
Enchantment(int id), but I need an existing Enchantment, not a new instantiation; and
getById(int id), but that's deprecated, and I'd need to know the valid values for 'id', just as with getByName()