module JohnDoe # Allows the handler to be reloaded without a restart of MCL (and therefore the minecraft server). # It must define the name of the handler class which needs to be a direct descendant of parent. # The handler class MUST be passed as symbol, the parent MUST be a constant (class/module). Mcl.reloadable(:MyHandler, parent = JohnDoe) ## MyHandler (it does things!) # You may describe your handler here or list the available commands. class MyHandler < Handler # This method is being called by MCL (see Callbacks). def setup # It's a good habit to have a method for each command (unless they're oneliner) which accepts # it's ACL level as argument. This way it's more easy to see and modify the permissions. register_gamemode_commands register_some_command :admin end def register_gamemode_commands register_command(:s, :survival, desc: "be mortal and die!", acl: :guest) {|player, args| gm(0, args.first || player) } register_command(:c, :creative, desc: "be creative" , acl: :builder) {|player, args| gm(1, args.first || player) } register_command(:adventure, desc: "be creative" , acl: :builder) {|player, args| gm(2, args.first || player) } register_command(:spec, :spectator, desc: "become spectator" , acl: :builder) {|player, args| gm(3, args.first || player) } end def register_some_command acl_level register_command :some_command, desc: "does something", acl: acl_level do |player, args, handler, option_parser| # ... end end # Organize stuff with modules if you don't want to use multiple files. module Helper def gm mode, target $mcl.server.invoke "/gamemode #{mode} #{target}" end end include Helper end end