cuberite / Essentials

Plugin for Cuberite that implements useful additional features, such as homes and warps

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Info.lua

NiLSPACE opened this issue · comments

Since it's easier to read it might be smart to change to the Info.lua way of registering commands. I created a parser that generated this for me:

-- Info.lua

-- Implements the g_PluginInfo standard plugin description




g_PluginInfo =
{
    Name = "Essentials",
    Date = "<Date>",
    Description = "",

    Commands =
    {
        ["/more"] =
        {
            Permission =  "es.more",
            HelpString =  " Changes the held stack to have 64 items.",
            Handler =  HandleMoreCommand,
        },

        ["/spawnmob"] =
        {
            Permission =  "es.spawnmob",
            HelpString =  " Spawn a mob.",
            Handler =  HandleSpawnMobCommand,
        },

        ["/biome"] =
        {
            Permission =  "es.biome",
            HelpString =  " Tells you the biome in wich you are.",
            Handler =  HandleBiomeCommand,
        },

        ["/repair"] =
        {
            Permission =  "es.repair",
            HelpString =  " Repairs the item you are holding.",
            Handler =  HandleRepairCommand,
        },

        ["/feed"] =
        {
            Permission =  "es.feed",
            HelpString =  " Satisfy the hunger.",
            Handler =  HandleFeedCommand,
        },

        ["/heal"] =
        {
            Permission =  "es.heal",
            HelpString =  " Heals a player.",
            Handler =  HandleHealCommand,
        },

        ["/enchant"] =
        {
            Permission =  "es.enchant",
            HelpString =  " Enchants the item you are holding.",
            Handler =  HandleEnchantCommand,
        },

        ["/burn"] =
        {
            Permission =  "es.burn",
            HelpString =  " Set a player on fire.",
            Handler =  HandleBurnCommand,
        },

        ["/ping"] =
        {
            Permission =  "es.ping",
            HelpString =  " Check if the server is alive.",
            Handler =  HandlePingCommand,
        },

        ["/vanish"] =
        {
            Permission =  "es.vanish",
            HelpString =  " Be invisible!.",
            Handler =  HandleVanishCommand,
        },

        ["/hat"] =
        {
            Permission =  "es.hat",
            HelpString =  " Use your equipped item as helmet.",
            Handler =  HandleHatCommand,
        },

        ["/fly"] =
        {
            Permission =  "es.fly",
            HelpString =  " Enable or disable flying.",
            Handler =  HandleFlyCommand,
        },

        ["/warp"] =
        {
            Permission =  "warp.warp",
            HelpString =  " - Moves player to location of warp [Tag].",
            Handler =  HandleWarpCommand,
        },

        ["/setwarp"] =
        {
            Permission =  "warp.setwarp",
            HelpString =  " - Creates a warp at players location.",
            Handler =  HandleSetWarpCommand,
        },

        ["/delwarp"] =
        {
            Permission =  "warp.dropwarp",
            HelpString =  " - Deletes a warp.",
            Handler =  HandleDelWarpCommand,
        },

        ["/warps"] =
        {
            Permission =  "warp.listwarp",
            HelpString =  " - Lists all warps.",
            Handler =  HandleListWarpCommand,
        },

        ["/jail"] =
        {
            Permission =  "jail.jail",
            HelpString =  " - Jails a player.",
            Handler =  HandleJailCommand,
        },

        ["/unjail"] =
        {
            Permission =  "jail.unjail",
            HelpString =  " - unjails a player.",
            Handler =  HandleUnJailCommand,
        },

        ["/setjail"] =
        {
            Permission =  "jail.setjail",
            HelpString =  " - Creates a jail at players location.",
            Handler =  HandleSetJailCommand,
        },

        ["/deljail"] =
        {
            Permission =  "jail.deljail",
            HelpString =  " - Deletes a jail.",
            Handler =  HandleDelJailCommand,
        },

        ["/jails"] =
        {
            Permission =  "jail.listjail",
            HelpString =  " - Lists all jails.",
            Handler =  HandleListJailCommand,
        },

        ["/home"] =
        {
            Permission =  "es.home",
            HelpString =  " - Go Home",
            Handler =  HandleHomeCommand,
        },

        ["/sethome"] =
        {
            Permission =  "es.sethome",
            HelpString =  " - Set your home!",
            Handler =  HandleSetHomeCommand,
        },

        ["/delhome"] =
        {
            Permission =  "es.delhome",
            HelpString =  " - Delete a home!",
            Handler =  HandleDelHomeCommand,
        },

        ["/lightning"] =
        {
            Permission =  "es.lightning",
            HelpString =  " - Get a lightning damage the specified player",
            Handler =  HandleLightningCommand,
        },

        ["/shock"] =
        {
            Permission =  "es.lightning",
            HelpString =  " - Get a lightning damage the specified player",
            Handler =  HandleLightningCommand,
        },

        ["/bring"] =
        {
            Permission =  "es.tphere",
            HelpString =  " - Get a lightning damage the specified player",
            Handler =  HandleTPHereCommand,
        },

        ["/tphere"] =
        {
            Permission =  "es.tphere",
            HelpString =  " - Teleports a player to you",
            Handler =  HandleTPHereCommand,
        },

        ["/place"] =
        {
            Permission =  "es.place",
            HelpString =  " - Teleports a player where you are looking",
            Handler =  HandlePlaceCommand,
        },

        ["/getpos"] =
        {
            Permission =  "es.getpos",
            HelpString =  " - Get your current location in the world",
            Handler =  HandleGetPosCommand,
        },

        ["/whereami"] =
        {
            Permission =  "es.getpos",
            HelpString =  " - Get your current location in the world",
            Handler =  HandleGetPosCommand,
        },

        ["/whois"] =
        {
            Permission =  "es.whois",
            HelpString =  " - Get information about the specified player",
            Handler =  HandleWhoisCommand,
        },
    },
}

It doesn't contain /xp though because the help string contains commas and my parser didn't like that ;)

Sorry but I didn't used this way of registering commands. If I use this way, I won't need to bind commands in main.lua anymore?

If you would use this method you would put

dofile(cPluginManager:GetPluginsPath() .. "/InfoReg.lua");

-- Initialize in-game commands:
RegisterPluginInfoCommands();

in the main.lua and you're done.

The main advantages are that it's easier to read for a developer and you can generate README files/forum posts with it

Done, hopefully all is well.