Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Ruby Minecraft Plugin support on top of bukkit

tree: 3edc52df52

Fetching latest commit…

Octocat-spinner-32-eaf2f5

Cannot retrieve the latest commit at this time

Octocat-spinner-32 examples
Octocat-spinner-32 lib
Octocat-spinner-32 nbproject
Octocat-spinner-32 src
Octocat-spinner-32 .gitignore
Octocat-spinner-32 Purugin.jar
Octocat-spinner-32 README.md
Octocat-spinner-32 build.xml
README.md

Purugin - Ruby Plugins for Minecraft + Bukkit

Purugin is a plugin framework which sites on top of Bukkit that allows you to write plugins in a Ruby syntax.

Once you copy Purugin.jar into your plugins directory you only need to drop .rb files into your plugins directory. If they contain code which includes Purugin::Plugin, then they will load and get registered as Bukkit plugins.

When I started this plugin I thought it would be fairly straight-forward. In respect to basic methods like onEnable it has been. Overall, it has been a huge voyage of discovery. I did not know Bukkit at all when I started (and I really just started) and limitations combined with lessons learned makes me think the API will be changing over time. So write plugins but be forewarned, they may change here and there....

Example

Here is a plugin which gets registered as a plugin in Bukkit which tells every use in the players world when a player joins or quits the world:


--------- examples/player_joined.rb -----
purugin('PlayerJoined', 0.1) do
  def on_enable
    # Tell everyone in players world that they have joined
    event(:player_join) do |e|
      e.player.world.players.each do |p| 
        p.send_message "Player #{e.player.name} has joined"
      end
    end

    # Tell everyone in players world that they have quit
    event(:player_quit) do |e|
      e.player.world.players.each do |p| 
        p.send_message "Player #{e.player.name} has quit"
      end
    end
  end
end

The purugin method allows you to specify the name and version of your plugin along with a block which represents the methods that this plugin should contain. To some this is a bit more magic than they want. If you prefer a more traditional way of creating plugins you can:


--------- examples/player_joined_full_class.rb ----------
class PlayerJoinedPlugin
  include Purugin::Plugin
  description 'PlayerJoined', 0.1
  
  def on_enable
    # Tell everyone in players world that they have joined
    event(:player_join) do |e|
      e.player.world.players.each do |p| 
        p.send_message "Player #{e.player.name} has joined"
      end
    end

    # Tell everyone in players world that they have quit
    event(:player_quit) do |e|
      e.player.world.players.each do |p| 
        p.send_message "Player #{e.player.name} has quit"
      end
    end
  end
end

Load plugins

If you want to include an module into your plugin you can add a line in on_enable like:


def on_enable
  include_plugin_module 'Commands', 'Command'
  # .... use methods from Command module now
end

This example shows this method include the Command module defined in the Commands plugin into it.

Running

Unfortunately, there is some weird Java Classloader interaction between JRuby and CraftBukkit. To start up Craftbukkit with Purugin, you need to do a couple of extra things:

  1. Have jruby-complete.jar from www.jruby.org/downloads in your Craftbukkit directory.
  2. java -Xms1024M -Xmx1024M -cp jruby-complete-0.6.1.jar:craftbukkit-0.0.1-SNAPSHOT.jar org.bukkit.craftbukkit.Main

Not ideal, but not particularly difficult either...

Something went wrong with that request. Please try again.