Thursday, May 12, 2011

Purugin

Announcing Purugin (プルギン)!
http://www.github.com/enebo/Purugin

Purugin is a Ruby-based plugin framework for Minecraft which is written on top of Bukkit.

Motivation

Minecraft is a fun game by itself. If it stayed the way it is today, then people would continue enjoying Minecraft for a long time to come. However, all players are critics and all players love the ability to change things in a game here and there. Since Minecraft is written in Java, many plugin initiatives have sprung up to allow just that. The sheer number of mods available for the game is staggering. In looking at the source of several of these mods one thing which struck me was....Damn! I would rather write these things in Ruby. Fortunately, JRuby exists...

Purugin is written using JRuby and it layers on top of Bukkit. Bukkit is an API which maps to the obfuscated Minecraft APIs and it also provides many conveniences for writing server-side plugins. The Bukkit API by itself is not particularly tough to use, but because it is Java and because it cannot make use of blocks/closures it ends up having more syntax/ceremony than what you can do in a Ruby syntax. Purugin is a Bukkit plugin which allows you to register plugins written in Ruby. Yay....

Getting Started

(Note: This assumes you have purchased and installed Minecraft already...kind of tough to mod a game you don’t actually have ;) )

In order to install Purugin you must first get CraftBukkit. CraftBukkit is a companion piece to the Bukkit library which manages Minecraft servers. Install CraftBukkit (instructions) and then get a copy of Purugin.jar and place it in your CraftBukkit plugins directory. Now also put in an example Purugin plugin player_joined.rb into the plugins directory as well. Finally, you need a copy of jruby-complete.jar (http://www.jruby.org/download) at the root of your CraftBukkit directory. Once you have did all this your CraftBukkit dir should now have these things added to it:


CraftBukkit/plugins/Purugin.jar
/player_joined.rb
/jruby-complete-1.6.1.jar


Now startup CraftBukkit:

java  -Xms1024M -Xmx1024M -cp jruby-complete-1.6.1.jar:craftbukkit-0.0.1-SNAPSHOT.jar org.bukkit.craftbukkit.Main


When it starts you should see the console come up and you will see a couple of noteworthy lines:


17:38:36 [INFO] [PuruginPlugin] version 0.1 ENABLED
17:38:36 [INFO] [PlayerJoined] version 0.1 ENABLED


So, at this point if you run Minecraft and enter the Multiplayer game at localhost (or whatever host you are running your server), you should see the message: Player {your_name} has joined.

player_joined-2011-05-12-08-42.jpg

Let’s look at the source for the player_joined.rb plugin:


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


Just scanning down this source I think it is fairly obvious how your were sent the Player joined message. Let’s example a few other aspects of writing any plugin. For starters there is a purugin method. This method contains the name of the plugin and the version along with a block which is the logic for the plugin. Using a block-based method for this stuff is sometimes inadequate since block scoping is a little more limiting than defining a class. For a more traditional definition using a class look at https://github.com/enebo/Purugin/blob/master/examples/player_joined_full_class.rb. I prefer using the short method-based definition up until the point it becomes a pain. For short plugins like this the method-based definition makes the plugin that much more concise. To each their own...

The next interesting bit is the lifecycle method on_enable. There are three lifecycle methods you will be concerned with: on_load, on_enable, and on_disable. You can refer to Bukkit documentation for the exact definition, but I think they are fairly intuitive. For most people you probably will only use on_enable. on_load will sometimes be used if you want something loaded before any plugin in the system has been enabled.

Inside of on_enable you will typically register events. In this case, we register listeners for :player_joined and :player_quit, but there are many many many events that you can register. You can monitor virtually anything. See the examples directory in Purugin’s source for more. [Note: :player_joined or any event name is not actually a symbol in Bukkit. This is Purugin trying to make the API look a little cleaner. At this point the documentation for Purugin is lacking, but the source is fairly small and tables for events or block types will not take long to find. Please consider helping me document things via rdoc patches of documentation on the wiki associated with this project].

Early Days

At this point, I have made a small collection of examples that are included with the source. I recommend looking at these as a way to get started. commands.rb is a plugin for registering commands. locs_plus.rb is a plugin which uses commands.rb for registering it’s own commands. ports.rb is a simple teleporter plugin (out of specially marked signs) which shows how to look at blocks.

Over time, I (someone) will make some more guides and help flush out the API better. This is a very humble start with an API I knew very little about. Expect change and perhaps help facilitate that change via Github issues and pull requests (or editing the wiki).

37 comments:

  1. This. Is. So. Awesome.

    I had wished for quite a while that there was a ruby API to build minecraft plugins.

    This is spectacular, and I'm so glad you've done the work to make it possible.

    Thank you so much for this :D

    ReplyDelete
  2. Any recommendations for hosting companies? I'd rather not run the whole thing myself as I already have a full time job...

    ReplyDelete
  3. Awesome dispatch! I am indeed getting apt to over this info, is truly neighborly my buddy. Likewise fantastic blog here among many of the costly info you acquire. Reserve up the beneficial process you are doing here. 한국야동

    Also feel free to visit may web page 야한동영상

    ReplyDelete
  4. I am really happy to say it’s an interesting post to read. I learn new information from your article , you are doing a great job. Keep it up 야설

    Also feel free to visit may web page 한국야동

    ReplyDelete
  5. Wonderful web site. Plenty of helpful information here. I am sending it to a few pals and additionally sharing in delicious. And obviously, thank you to your sweat! 야동

    Also feel free to visit may web page 일본야동

    ReplyDelete
  6. Good way of explaining, and pleasant post to obtain information about my presentation focus, which i am going to present in college 한국야동

    Also feel free to visit may web page 야설

    ReplyDelete
  7. Stay up the good work! You know, many people are looking round for this info, you could aid them greatly.
    토토
    온라인경마
    경마사이트

    ReplyDelete
  8. There is definately a great deal too find out about this topic.

    I love all of the points you have made.
    카지노사이트
    토토사이트

    ReplyDelete
  9. Awesome dispatch! I am indeed getting apt to over this info,Reserve up the beneficial process you are doing here.Dissertation Help Uk

    ReplyDelete
  10. If Minecraft were to remain the same, it would be a great game in itself. But I don't know if it's luck or not, but Minecraft is not what it used to be, and it's not easy for people to learn to use. Coursework Writing Services

    ReplyDelete
  11. Minecraft is perhaps one of the best nonviolent, educational games available. It may teach children the principles of programming, teamwork, problem-solving, and project management, as well as providing a wonderful setting in which to promote creativity and "out of the box" thinking.
    Source: Digital Marketing Services in Australia

    ReplyDelete

  12. Thanks for sharing.I found a lot of interesting information here. A really good post, very thankful and hopeful that you will write many more posts like this one.Source: Web Design Bolt

    ReplyDelete
  13. Hello there and thank you for your information – I've definitely picked up anything new from right here. I did however expertise a few technical points using this website, since I experienced to reload the site a lot of times previous to I could get it to load properly. I had been wondering if your web host is OK?

    야한소설
    대딸방
    마사지
    건전마사지
    바카라사이트

    ReplyDelete
  14. Mine craft is one my most favorite game and i really enjoy it.
    professional copywriting services

    ReplyDelete
  15. A Recruitment Management System (RMS) is a set of tools designed to automate and manage your organization's recruiting and staffing operations. From posting your jobs to keeping applicants connected and engaged throughout, Zoho Recruit's RMS lets you manage your entire recruiting process. I am using cordis.us services they offered large variety of business management services in affordable rates,deals in real estate softwares for large companies they have different packages for small medium and large corporate sectors for more information visit websites recruitment management software

    ReplyDelete
  16. Your post is so amazing i read this post it's very helpful for us. roseland furniture discount code We also provide a washing machine repair services.

    ReplyDelete

  17. The global smart waste management market size was valued at $1,684.1 million in 2019, and is expected to reach $4,103.7 million by 2027, registering a CAGR of 15.3% from 2020 to 2027. Smart waste management is the concept that uses sensors in waste to track live status of city waste collection services when bins are ready to be emptied, or filled. It also monitors historical data collected by sensors and databases, which can be used to identify and optimize driver routes, fill patterns, reduce operational costs, and schedules. Remote monitoring, and IoT based waste bins are more feasible to collect waste effectively. It also reduces routing and fuel prices. The Smart Waste Management Market covers the trends that are promoting the growth of technologies, such as sensors, RFID, GPS, cloud-based software solutions for effectively managing the waste (from collection to disposal) generated across the residential and commercial sectors. The commercial sector includes waste generated from the food and beverages industry electronics manufacturers, pharmaceutical industries, paper industries, healthcare industries, among others.








    Here if you like to see more of reports : Asia Pacific Vaccine Market, Micro Inverter Market, Albumin Market, Middle East and Africa Cybersecurity Market,Digital Blood Pressure Monitor Market, Vegetable Concentrates Market, Learning Management System Market, States Flooring Market, Sports and Energy Drinks Market, Brazil Healthcare, Sterilisation Services Market, Media Monitoring Tools Market

    ReplyDelete
  18. We will be perceived as the confided in discussion tax check car, for examination and answers lastly deals.

    ReplyDelete
  19. The market for business jets has seen substantial growth due to factors such as the increasing number of staff and the introduction of fresh aircraft programs. Also, increased knowledge across different segments offers an enormous market opportunity for key players in the business jets market. The light aircraft segment is expected to grow at the fastest rate during the forecast period.

    Also Read: europe covid-19 diagnostics market, middle east and africa covid-19 diagnostics market

    ReplyDelete
  20. Marriage is a fantastic Thing to happen, we are happy you both have been working out your components well
    dua islamic anniversary wishes for husband

    ReplyDelete
  21. Stark tutor provides online physics tution for our students and in our online course library, which contains more than 350 questions covered.

    ReplyDelete
  22. I'm delighted to notice some excellent articles on your website. I sincerely appreciate it; thank you for sharing.
    New Jersey uncontested divorce lawyer

    ReplyDelete
  23. Students can expect timely delivery of their assignments from myassignmenthelp.sg . The team works efficiently to ensure that every assignment help Singapore is completed within the given deadline, allowing students to submit their work on time and without stress.

    ReplyDelete
  24. Minecraft the name is enough for me to read this blog post. Initially I thought that this post will show some mods or tricks in the game. After reading entire post, so much of information are working by the developers. This is amazing. Game developers has to be more knowledgeable. Really good. I like the way you explained about technical things in Minecraft. Thanks for sharing this beautiful post. Keep sharing more technical as well as game related post. DUI Lawyer Henrico VA

    ReplyDelete
  25. I found the discussion on code comments to be thought-provoking. While comments can be helpful in explaining complex logic or providing context, I agree with the author that self-explanatory code is ideal. Cheap Dissertation Writing Services UK

    ReplyDelete
  26. This article is an absolute gem! 🌟 The insights shared here are truly eye-opening and inspiring. ¿Qué Rápidamente Puede Obtener una Divorciar en Nueva York? I'm grateful for the valuable information and fresh perspectives. Kudos to the author for delivering such uplifting content! Can't wait to see more posts like this. 💯

    ReplyDelete
  27. I learned something new from your essay; keep up the good work.




    TEAS Test Online

    ReplyDelete
  28. "purugin" in their training data up to September 2021. They suggest that "purugin" may be a term or product that emerged after their last knowledge update. They are willing to provide more details or context about the term to provide relevant information or review comments. They are also willing to generate more lines of text on various topics and ask for a topic or question to generate relevant content. They are sorry for any confusion and hope to assist further.baltimore truck accident lawyer

    ReplyDelete
  29. Thank you for sharing this wonderful, informative blog!
    It was really a great post. Hope to read many such posts!
    Cost of Invisalign

    ReplyDelete
  30. The announcement of "Purugin" is intriguing and evokes curiosity among readers. However, it lacks specific details about its nature or features, leaving them wanting more information. To better understand the announcement, a brief description or key features could be provided. Overall, the announcement is engaging but could benefit from additional information to satisfy readers' curiosity.New York Marriage Laws Divorce

    ReplyDelete
  31. The use of JRuby to extend Minecraft with Purugin is a fascinating idea. This blog provides a clear and concise guide for getting started, making it accessible to those interested in enhancing their Minecraft experience with Ruby. The provided examples and explanations are quite helpful for budding plugin developers. Well done! Contested Divorce New York State

    ReplyDelete
  32. Trusted DUI lawyer in Dinwiddie, VA,   dui lawyer dinwiddie va offering expert defense against drunk driving charges. Committed to securing the best possible outcome for your case.   dui lawyer dinwiddie va
    Call for a consultation and advocacy."

    ReplyDelete
  33. The review highlights the excitement of the gaming community with the announcement of Purugin, a game that combines innovation and nostalgia. It highlights its unique features and captivating gameplay, generating anticipation among players. The review effectively conveys the positive impact Purugin is expected to have, making it a must-try for enthusiasts. Overall, it's a compelling and informative review. New York No-Fault State Divorce

    ReplyDelete

  34. It seems like you want to announce the use of Purugin in just 4 lines. Purugin is a library that allows you to write Bukkit plugins using the Ruby programming language.
    personal injury attorney virginia

    ReplyDelete
  35. As of my last knowledge update in January 2022, I don't have specific information on Yahoo's remote work observations. Please check the latest sources or news for the most recent updates on Yahoo's remote work policies and observations.
    estate tax lawyer attorney corporate

    ReplyDelete
  36. Thank you for creating this wonderful blog. It's genuinely worth reading and immensely valuable. www.concreteoakville.com

    ReplyDelete
  37. Reckless Driving Attorney In New Jersey A reckless driving attorney in New Jersey provides legal representation and guidance for individuals facing charges related to reckless driving offenses, aiming to minimize penalties and protect their rights.

    ReplyDelete