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

tag: 1.8.1.3

Fetching latest commit…

Cannot retrieve the latest commit at this time

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_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

Plugin Dependencies

Plugins can depend on other plugins. There are multiple ways of accessing dependent plugins. The first is to declare your plugin dependencies at the top of your Purugin:


class AdminPlugin
  include Purugin::Plugin
  description 'Admin', 0.2
  required :Commands, :include => :Command
  
  def on_enable
    command('/who', 'display all users') do |e, *args|
      me = e.player
      me.world.players.each do |player|
        me.send_message "#{player.display_name} (#{player.name})"
      end
    end
  end
end

This example shows that the 'Admin' plugin requires (via 'required' method) the 'Commands' plugin and that it should include the 'Command' module from the 'Commands' plugin.

You can specify optional dependencies via the optional declaration:


optional :Permissions

As a side-effect both required and optional will define a method by the same name as plugin being referenced (Note: This may change since plugin names may not conform to sane Ruby-naming and some people don't like methods like 'Permissions()').

A second way to get a live reference to a plugin is to ask the plugin manager:


plugin_manager['Permissions']

This has the advantage that a plugin can be named anything and you will still be able to reference it.

Running

If you used the install script (requires a Ruby interpreter >1.9.1), then all you need to do is execute the run.sh or run.bat script which gets put into your minecraft directory.

If you want to do this manually, then you will need to: 1. Have jruby-complete.jar from www.jruby.org/downloads in your Minecraft directory. 2. java -Xms1024M -Xmx1024M -cp jruby-complete.jar:craftbukkit-0.0.1-SNAPSHOT.jar org.bukkit.craftbukkit.Main

Something went wrong with that request. Please try again.