Fredrik Vold > Minecraft-RCON-v0.1.3 > Minecraft::RCON

Download:
Minecraft-RCON-v0.1.3.tar.gz

Dependencies

Annotate this POD

CPAN RT

Open  0
View/Report Bugs
Module Version: v0.1.3   Source   Latest Release: Minecraft-RCON-v0.1.4

NAME ^

Minecraft::RCON - Handles talking to the Minecraft remote console

SYNOPSIS ^

    use Minecraft::RCON;

    my $rcon = Minecraft::RCON->new( { password => 'f4ble' } );
    if ($rcon->connect){
        print $rcon->command('help');
    }
    else {
        print "Oh dang, connection failed!\n";
        # Error capturing and fetching is in the works...
    }
    $rcon->disconnect;

DESCRIPTION ^

Minecraft::RCON provides a nice object interface for talking to Mojang AB's game Minecraft. Intended for use with their multiplayer servers, specifically your multiplayer server, as you will need the correct rcon.password, and rcon must be enabled on said server.

CONSTRUCTOR ^

new ( [HASHREF] )

A hashref containing all used keys with their default value:

    my $rcon = Minecraft::RCON->new({
        address         => '127.0.0.1',
        port            => 25575,
        password        => ''
        strip_color     => 1,
        convert_color   => 1,
    });
address and port should explain themselves. Defaults to localhost and the default Minecraft RCON port.
password defaults to blank, which is never valid.
strip_color makes the response to ->command have its Minecraft color codes stripped out.
convert_color tries to convert the Minecraft colors to terminal colors using Term::ANSIColor.

Note that no conversion attempt is made while stripping is enabled. In addition to the constructor, the different options can be set or changed using the methods below.

METHODS ^

These are the public methods. There are others, but any method not listed here is subject to change without any kind of notice.

address([STRING])

The string is the new setting, and can be omitted if you don't want to change it. Returns the address used to connect.

Note that changing this during an ongoing connection does nothing until you ->disconnect and ->connect again.

port([INTEGER])

The integer is the new setting, and can be omitted if you don't want to change it. Returns the port used to connect.

Note that changing this during an ongoing connection does nothing until you ->disconnect and ->connect again.

password([STRING])

The string is the new setting, and can be omitted if you don't want to change it. Returns the password used to connect.

Note that changing this during an ongoing connection does nothing until you disconnect and connect again.

If the password is wrong, it will be carped about when you attempt to connect.

connect

Attempt to connect to the configured address and port, and issue the configured password for authentication. Returns 1 on success, 0 otherwise.

If the password is wrong, it will also carp that fact.

command([STRING])

Issues the string as a command to the Minecraft server.

Returns the server's response, with the color codes optionally stripped or converted.

disconnect

Disconnects from the server by closing the socket.

convert_color([BOOLEAN])

The boolean is the new setting, and can be omitted if you don't want to change it. Returns the current color conversion setting.

As per usual in perl, blank strings, 0 and undef are considered FALSE, while pretty much anything else is TRUE.

This takes effect immediately, and does not require a reconnect.

Color conversion does not happen unless stripping is disabled. I mean... what colors would it convert? Turn both off if you want to do the conversion yourself, or have other uses for the data.

strip_color([BOOLEAN])

The boolean is the new setting, and can be omitted if you don't want to change it. Returns the current color stripping setting.

As per usual in perl, blank strings, 0 and undef are considered FALSE, while pretty much anything else is TRUE.

This takes effect immediately, and does not require a reconnect.

Note that unless you've turned on color conversions this might cause command returns to contain color codes, which is pretty much just junk data unless you intend to do the conversion yourself.

SEE ALSO ^

Terminal::ANSIColor, IO::Socket::INET, Carp

AFFILIATION WITH MOJANG ^

I am in no way affiliated with Mojang or the development of Minecraft. I'm simply a fan of their work, and a server admin myself. I needed some RCON magic for my servers website, and there was no perl module.

It is important that everyone using this module understands that if Mojang changes the way RCON works, I won't be notified any sooner than anyone else, and I have no special avenue of connection with them.

AUTHOR ^

Fredrik Vold <fredrik@webkonsept.com>

THANKS ^

Thanks to Mojang for such a great game.

Thanks to #perl on Freenode for being great and assisting me in so many ways.

Of course, thanks to Larry for Perl!

COPYRIGHT ^

Minecraft is a trademark of Mojang AB. Name used in accordance with my interpretation of http://www.minecraft.net/terms, but someone correct me if I'm wrong. I have no affiliation with Mojang (other than being a customer and fan).

No copyright claimed, no rights reserved.

You are absolutely free to do as you wish with this code, but mentioning me in your comments or whatever would be nice.

syntax highlighting: