How to create new Crafts, etc...

How to create new Crafts and different Event to make this plugin:

#The beginning

  • First of all, you have to create your "basic" plugin: import craftbukkit/spigot, create the file "pluin.yml" and "config.yml", package (me: plugin.craft.plus) and inside the package, a Class (me: MainRecipe)).

Plugin

  • Now, go to the Class. extends JavaPlugin, implements Listener(For Events) and CommandExecutor(For Commands) and create voids OnEnable and OnDisable.

Plugin

  • In the plugin.yml, you have to write: main: (=Destination of the Class), name: (The name of the plugin), Optional version: (The version of the plugin) and author: (The author's name).

Plugin

  • And this is my config.yml:

Plugin

#Create a new Craft

  • For example, we'll create a block of grasslike that:

Plugin

  • The code is:

Plugin

  • The first string equals to the first line in the crafting table, the twice to te twice line etc... and we say that "G" for example is vines and H, the dirt, this isn't hard. But we have to add another line of code to say, -I add this craft-:

Plugin

  • all the code above must be placed in: OnEnabled!
  • Now you can try and the new craft you have created works! But if you want to place the blocs differently, ther is another code. For example, if you want to create a coal ore:

Plugin Plugin

  • You can see the craft works with all the different postitions of the items
  • And the code is (always in OnEnable):

Plugin Plugin

#Events

  • With the events, we will check if we can craft the item (check true/false in config.yml). The Event is "CraftItemEvent" and this is the code:

Plugin

  • If you don't understand:
  • m is the material you want to craft and b is the metadata for example: 98:1 is the mossy stone brick.
  • At once, we check if the block we will to craft is the grass.
  • After that: if The string is false (in config.yml) the grass disapeared and the crafting table close, we hear a sound and a message appared.
  • but if the string is true, we can craft the item (return; : stop the event)

Sorry for the mistakes, I don't speak english very well but I hope you'll understand! ;)//

Thank You! - MrfroziX134


Comments

Posts Quoted:
Reply
Clear All Quotes