Minecraft Blogs / Tutorial

Bukkit Plugin Tutorial 5: Let's disable those recepis.

  • 1,886 views, 1 today
  • 4
  • 2
  • 4
evilguy4000's Avatar evilguy4000
Level 33 : Artisan Modder
33
Welcome here dear PMC'ers,

Today I'm going to learn you how you can disable the recipes you want. This can come in very handy if you are making your own role-play servers or some of that kind. These can be used to stop people from crafting specified things. I hope you learn something from this tutorial and please check out my website below aswel as the Bukkit docs and the medieval-craft website.


Medieval-Craft

My Website

Bukkit Docs

Things you will need this lesson :


1) The project of last lesson or a new one.
2) A bunch of papers if you want to take some notes.
3) A big portion of patience

Getting Started


Click to reveal
sPujkjpng

Now we are going to start with the Iterator, an Iterator can be compared with ArrrayLists and that kind of stuff. But Iterators are way more easy to use with Recipes. So we start off with Iterator <---- this declares what will be in the Iterator. Then we give it the name in this case recipes. Then it's followed by = and then Bukkit.getServer().recipeIterator(); This gets all the Recipes of the server.
rDhsckpng


Click to reveal

ItvgPApng

Now we are going to start with a while, that's just like an if statement. so while(recipes.hasNext()){ } There we are going to put the code for executing the removing of the recipe.
ozaytevpng

Now we are going to make it so the plugin keeps scrolling through all the recipes until it has found the right one. You do that with recipe = recipes.next(); You really can't forget this part.
mdkxqOApng

Now we are going to add an if statement that blocks out the not wanted recipes. This involves a lot of code. We are first going to check if the recipe isn't null and if the result of the recipe is wood. and only if the result has a durability of one, then the recipe will be disabled. You can find the code in the picture down here.

aisBCNNpng


And now once again you have finished your plugin. With this you can disabled every recipe you want. Make sure to check out the links at the top of this page and I hope to see you all soon again.

peace out!
Tags

1 Update Logs

Update #1 : by evilguy4000 11/14/2013 4:33:03 pmNov 14th, 2013

Awesome Tutorial :o

Create an account or sign in to comment.

1
12/22/2013 12:05 pm
Level 1 : New Explorer
brw
brw's Avatar
This is what I need! This must have more views! :D
1
10/28/2013 3:53 pm
Level 39 : Artisan Network
caiden2000
caiden2000's Avatar
This deserves more views :(
1
10/28/2013 4:21 pm
Level 33 : Artisan Modder
evilguy4000
evilguy4000's Avatar
Thank you that really means much to me :3
1
10/28/2013 6:04 pm
Level 39 : Artisan Network
caiden2000
caiden2000's Avatar
I'm not on this level yet, but I subbed t you for when I am :)
Planet Minecraft

Website

© 2010 - 2024
www.planetminecraft.com

Welcome