Creating Addons

Creating an addon for Zephyrus

http://dev.bukkit.org/media/images/59/254/addon-title.png

This page is out of date. See this page for an updated tutorial.

Want to create an addon for Zephyrus? Then this tutorial is for you!

Example addon: https://github.com/minnymin3/Zephyrus/tree/Zephyrus-Addon

JavaDocs: http://minnymin3.github.io/Zephyrus/

Setting up your workspace

First off, you must know how to make a plugin. If you don't, then don't continue with this tutorial. If you do, then add Zephyrus as an external jar much the same way as you would have added Bukkit. Instead of using Bukkit's javadocs use Zephyrus' (link: http://minnymin3.github.io/Zephyrus/). Then in your plugin.yml file, put this in depend: [Zephyrus] . This makes your plugin dependant on Zephyrus so that your plugin cannot load without it. This will stop errors from spaming your consol. Another note is that your addon's version should be the same as Zephyrus' version to avoid version mess-ups (such as something changing in Zephyrus). Now you are ready to start making your custom spells!

Your first spell

The first thing you are going to want to do is extend Spell (minnymin3.zephyrus.spells.Spell) and add the unimplemented methods. When you hover over the methods you can see what each one is. Fill in each method appropriately. Remember that the mana cost is multiplied by the mana multiplier which is 5 by default! The run(Player player, String[] args) is the most important method. This is called when the spell is cast. It is the method where you would heal the player in, feed the player in, or anything else! The args is the arguments passed when someone executes the /cast [spell] command so you can have multiple arguments and make your spell act like a command! If your spell requires you to be looking at a specific block or something like that, then add public boolean canRun(Player player, String[] args) to the class. This will decide if the spell can or can't run. If you then want to add a custom message that is sent to the player when canRun returns false, add public String failMessage(). Now on to the SpellType method. This method is going to be used in the future to work with combo spells. You can set the type with SpellType.TYPE; Now you are done your first spell!

Registering your spell

Inside your main class, you will want to define Zephyrus as a variable. Add this into your onEnable: Zephyrus zephyrus = Zephyrus.getInstance();. Now you will want to tell Zephyrus that you have a new spell. To do this, lets pretend that you named your spell class TestSpell. Add new TestSpell(zephyrus); into your onEnable and that registers your spell! Now you are all done!

Worldguard

Lets say you had a spell that broke the block you were looking at. What if they were not allowed to break blocks there!? Well Zephyrus comes with a nice, easy method for detecting if a player has permission to build at a location or block. In your canRun(Player player) method, add this line of code return PluginHook.canBuild(player, block); This will return the result of canBuild witch will return true if WorldGuard is not installed, false if they cannot build, and true if they can build!

Maven

If you would like to use Maven to compile your project you may use the Zephyrus maven repository hosted by the LordsOfCode Jenkins.

<project>
  ...
  <repositories>
    <repository>
      <id>Zephyrus</id>
      <url>http://ci.lordsofcode.net/job/ZephyrusCore/lastStableBuild/maven-repository/repository/</url>
    </repository>
  </repositories>
  ...
  <dependencies>
    <dependency>
      <groupId>net.lordsofcode.zephyrus</groupId>
      <artifactId>ZephyrusCore</artifactId>
      <version>1.4.0</version>
    </dependency>
  </dependencies>
  ...
</project>

Comments

Posts Quoted:
Reply
Clear All Quotes