24 lines
844 B
Perl
24 lines
844 B
Perl
package POE::Component::BukkitRestart;
|
|
|
|
use strict;
|
|
use warnings;
|
|
|
|
sub spawn {
|
|
POE::Session->new(
|
|
inline_states => {
|
|
_start => sub {
|
|
$_[HEAP]->{todo} = [ qw( step1 step2 step2a ) ],
|
|
$_[KERNEL]->delay( restartwarning => 45*60 );
|
|
},
|
|
restartwarning => sub {
|
|
my @messages = ("Incoming game prepare for ReBoot!", "What's this bright light aimed at us? It's a ReBoot!", "I'll get you next ReBoot, Gadget! Next TIME!");
|
|
$_[KERNEL]->post( 'bukkitdtach', 'queue_command', 'say '.$messages[rand(0+@messages)] );
|
|
$_[KERNEL]->delay( restart => 30 );
|
|
}
|
|
restart => sub {
|
|
$_[KERNEL]->post( 'bukkitdtach', 'queue_command', 'save-all' );
|
|
$_[KERNEL]->post( 'bukkitdtach', 'queue_command', 'stop' );
|
|
$_[KERNEL]->delay( restartwarning => 45*60 );
|
|
}
|
|
);
|
|
}
|