NAME
Net::RCON::Minecraft::Response - Minecraft RCON command response
VERSION
Version 0.04
SYNOPSIS
use Net::RCON::Minecraft;
my $response = eval { $rcon->command($command) };
if ($response) {
print "Response: " . $response->ansi . "\n";
logger "Response: " . $response->plain;
logger "Response: " . $response; # Stringifies to $response->plain;
}
DESCRIPTION
This module encapsulates a command response from a Minecraft server. You would not normally create one of these objects yourself; they are generated from Net::RCON::Minecraft's command()
method.
Minecraft servers return commands in a format that may include Minecraft color codes, so this module provides methods to strip or convert those codes as needed. At the time of release, vanilla Minecraft servers do not ever transmit color codes to RCON results, but modded servers such as Bukkit do.
STRINGIFICATION
If all you need is the plaintext response with color codes stripped, in most cases you can just use $response
as a string. The object is overloaded to return $response->plain
in such cases.
CONSTRUCTOR
new( raw => $raw, id => $id )
This is called automatically by command()
in Net::RCON::Minecraft
.
Creates a new RCON command response with the given raw command response text, and request ID.
METHODS
raw
Returns the unaltered raw command response.
$raw = $response->raw;
plain
Returns the command response with all color codes removed.
$plain = $response->plain;
ansi
Returns the command response with color codes converted to ANSI escape sequences, suitable for displaying in a terminal.
$ansi = $response->ansi;
id
Returns the numerical request ID that this response was for. These IDs are generated automatically by Net::RCON::Minecraft
, and there is normally no need to know them, but this may be useful for debugging.
SEE ALSO
AUTHOR
Ryan Thompson <rjt@cpan.org>
COPYRIGHT AND LICENSE
Copyright 2019 Ryan Thompson
This program is free software; you can redistribute it and/or modify it under the same terms as Perl itself.