This is simple a boolean , a setter, and a getter (You can tell which one is which by their name) a boolean is simply a true or false statement, i've made it private so in this tutorial it will be easier to understand the methods. The isBurying() Method is your getter, this method is simply going to return the value of the boolean burying we can use this by adding something like.
Code:
if (player.isBurying()) {
player.sm("We're burying!");
} else {
return;
}
That's simply saying if the player is burying its going to send a player message saying "We're burying!" and the "else" means if the player is doing anything other then burying its simply going to return (do nothing).
Now, onto the setter, incase you havn't realised yet this is the setter:
Code:
public void setBurying(boolean burying) {
this.burying = burying;
}
This particular setter is saying whatever the value of this setter is it will set the burying boolean to value of the setter, as an example we could do something like this..
Code:
player.setBurying(true);
that will set the boolean burying true; and obviously to make it false you can do
Code:
player.setBurying(false);
Okay, thats the end of booleans for now.. We will now be learning what this piece of code does
Code:
if (player.isBurying() && Bone.forId(itemId) != null) {
return;
}
Okay, firstly the handleItemOption7 method in your InventoryOptionsHandler class is the drop method, its also used for other items but its not important.
Now i want you to remember in the above where we learned about setters, getters and booleans.. I'm sure your pretty confident about the basics of those now so here we will be demonstrating a getter along with an "&&" just means "and" or "&" also a !=null (it does what it says, if the item inst equal to null (nothing)).
So in this statement we're saying if the player is burying and the item is a Bone (If you look at Bone.forId method you will see it refers to all the types of bones in the world) and the item inst equal to null its going to return which basically means its going to do nothing you have to make sure this is put above your piece of code that adds the drop to the ground and deletes the inventory item because we want it to check our code first and if its not burying it will let it drop. Your piece of code that actually drops the item should look something like this:
Code:
player.getInventory().deleteItem(slotId, item);
player.setNextAnimation(new Animation(-1));
World.addGroundItem(item, new WorldTile(player), player, false, 180, true);
player.getPackets().sendSound(2739, 0, 1);
I'm not going to go deep into that today because that's not what we're learning about today.
Ideally your code should be placed directly above that.
Going to make this last bit short and sweet because I've already explained setters above.
I'm sure if you read all the above you will now know what this code does
Code:
player.setBurying(true);
but if your lazy like me and want a quick and easy answer its saying the player is burying a form of bone.
now we put this near or around
Code:
final ItemDefinitions itemDef = new ItemDefinitions(item.getId());
because where that line of code is thats where the player starts the burying process, and we put the
Code:
player.setBurying(false);
under
Code:
player.getTemporaryAttributtes().put("current_prayer_xp", total);
stop();
because ideally, that's exactly where the player stops the burying process, so as soon as the player stops the burying process it will tell your server that you are not burying a bone anymore, therefore are able to drop bones now.
Cool you actually made it to the end of the tutorial! Thanks for reading and if anyone needs more explanations for anything post below and ill make a thread and maybe start you tube. Any Questions ? post below ill get back to you ASAP. Thanks for reading.