diff --git a/minecraft/edit_cmds.cgi b/minecraft/edit_cmds.cgi index 4d59522cb..49d0f4e5a 100755 --- a/minecraft/edit_cmds.cgi +++ b/minecraft/edit_cmds.cgi @@ -27,7 +27,7 @@ print &ui_table_row($text{'cmds_gamemode'}, # Change difficulty level print &ui_table_row($text{'cmds_difficulty'}, - &ui_select("defmode", 2, + &ui_select("diff", 2, [ [ 0, $text{'cmds_peaceful'} ], [ 1, $text{'cmds_easy'} ], [ 2, $text{'cmds_normal'} ], diff --git a/minecraft/images/cmds.gif b/minecraft/images/cmds.gif new file mode 100755 index 000000000..e06e422e9 Binary files /dev/null and b/minecraft/images/cmds.gif differ diff --git a/minecraft/lang/en b/minecraft/lang/en index a9e7de2e2..59e62a139 100644 --- a/minecraft/lang/en +++ b/minecraft/lang/en @@ -174,5 +174,12 @@ cmds_for=for time cmds_weatherb=Change cmds_err=World command failed cmds_downfalldone=Started rain or snow +cmds_esecs=Time to change weather for must be a positive number of seconds +cmds_weatherdone=Changed weather to $1 for $2 seconds +cmds_etimeset=Time to set must be a number between 0 and 24000 +cmds_etimeadd=Time to add must be a number between 0 and 24000 +cmds_timedone=Changed game time +cmds_gamemodedone=Changed default game mode to $1 +cmds_difficultydone=Changed game difficulty manual_title=Edit Configuration File diff --git a/minecraft/list_worlds.cgi b/minecraft/list_worlds.cgi index 60ab7356d..ecf2d6c32 100644 --- a/minecraft/list_worlds.cgi +++ b/minecraft/list_worlds.cgi @@ -39,7 +39,8 @@ if (@worlds) { } print &ui_columns_end(); print &ui_links_row(\@links); - print &ui_form_end([ [ undef, $text{'worlds_change'} ] ]); + print &ui_form_end([ [ undef, $text{'worlds_change'} ], + [ 'apply', $text{'worlds_change2'} ] ]); } else { print "$text{'worlds_none'}
\n"; diff --git a/minecraft/minecraft-lib.pl b/minecraft/minecraft-lib.pl index b9bae4092..cfc57af2c 100644 --- a/minecraft/minecraft-lib.pl +++ b/minecraft/minecraft-lib.pl @@ -2,8 +2,7 @@ # # XXX java param options # XXX plugins? -# XXX world reset -# XXX world create / clone +# XXX configuration page, with seed field BEGIN { push(@INC, ".."); }; use strict; @@ -266,8 +265,8 @@ sub list_connected_players my @out = &execute_minecraft_command("/list"); my @rv; foreach my $l (@out) { - if ($l =~ /\[INFO\]\s+(\S+)$/) { - push(@rv, $1); + if ($l !~ /players\s+online:/ && $l =~ /\[INFO\]\s+(\S.*)$/) { + push(@rv, split(/,\s+/, $1)); } } return @rv; @@ -340,8 +339,8 @@ sub list_banned_players my @out = &execute_minecraft_command("/banlist"); my @rv; foreach my $l (@out) { - if ($l =~ /\[INFO\]\s+(\S+)$/) { - push(@rv, $1); + if ($l !~ /banned\s+players:/ && $l =~ /\[INFO\]\s+(\S.*)$/) { + push(@rv, split(/,\s+/, $1)); } } return @rv; @@ -351,11 +350,11 @@ return @rv; # Returns a list of players who are whitelisted sub list_whitelisted_players { -my @out = &execute_minecraft_command("/whitelist"); +my @out = &execute_minecraft_command("/whitelist list"); my @rv; foreach my $l (@out) { - if ($l =~ /\[INFO\]\s+(\S+)$/) { - push(@rv, $1); + if ($l !~ /whitelisted\s+players:/ && $l =~ /\[INFO\]\s+(\S.*)$/) { + push(@rv, split(/,\s+/, $1)); } } return @rv; diff --git a/minecraft/save_cmds.cgi b/minecraft/save_cmds.cgi index 9bafc1aad..14ab2d944 100644 --- a/minecraft/save_cmds.cgi +++ b/minecraft/save_cmds.cgi @@ -11,9 +11,43 @@ our (%in, %text); my $msg; if ($in{'gamemode'}) { # Change game mode + my $out = &execute_minecraft_command( + "/defaultgamemode $in{'defmode'}"); + $out =~ /The\s+world's\s+default\s+game\s+mode/ || + &error(&html_escape($out)); + $msg = &text('cmds_gamemodedone', $in{'defmode'}); } elsif ($in{'difficulty'}) { # Change game mode + &send_server_command("/difficulty $in{'diff'}"); + $msg = $text{'cmds_difficultydone'}; + } +elsif ($in{'time'}) { + # Change game time + my $mode; + if ($in{'time_mode'} == 0) { + $mode = 'set day'; + } + elsif ($in{'time_mode'} == 1) { + $mode = 'set night'; + } + elsif ($in{'time_mode'} == 2) { + $in{'timeset'} =~ /^\d+$/ && + $in{'timeset'} >= 0 && $in{'timeset'} <= 24000 || + &error($text{'cmds_etimeset'}); + $mode = 'set '.$in{'timeset'}; + } + elsif ($in{'time_mode'} == 3) { + $in{'timeadd'} =~ /^\d+$/ && + $in{'timeadd'} >= 0 && $in{'timeadd'} <= 24000 || + &error($text{'cmds_etimeadd'}); + $mode = 'add '.$in{'timeadd'}; + } + my $out = &execute_minecraft_command( + "/time $mode"); + $out =~ /Set\s+the\s+time/ || $out =~ /Added.*to\s+the\s+time/ || + &error(&html_escape($out)); + $msg = &text('cmds_timedone'); } elsif ($in{'downfall'}) { # Start rain @@ -23,6 +57,16 @@ elsif ($in{'downfall'}) { &error(&html_escape($out)); $msg = &text('cmds_downfalldone'); } +elsif ($in{'weather'}) { + # Change weather + $in{'secs'} =~ /^[1-9][0-9]*$/ || + &error($text{'cmds_esecs'}); + my $out = &execute_minecraft_command( + "/weather $in{'wtype'} $in{'secs'}"); + $out =~ /Changing\s+to/ || + &error(&html_escape($out)); + $msg = &text('cmds_weatherdone', $in{'wtype'}, $in{'secs'}); + } else { &error($text{'conn_ebutton'}); } diff --git a/minecraft/save_users.cgi b/minecraft/save_users.cgi index 8a01567ff..941da36c4 100644 --- a/minecraft/save_users.cgi +++ b/minecraft/save_users.cgi @@ -16,7 +16,7 @@ if ($in{'mode'} eq 'white') { my @users = split(/\r?\n/, $in{'white'}); &save_whitelist_users(\@users); &save_directive("white-list", $in{'enabled'} ? 'true' : 'false', $conf); - &flush_file_lines(); + &flush_file_lines(&get_minecraft_config_file()); &unlock_file(&get_whitelist_file()); &unlock_file(&get_minecraft_config_file()); diff --git a/minecraft/save_world.cgi b/minecraft/save_world.cgi index 824bb5069..c575057e0 100644 --- a/minecraft/save_world.cgi +++ b/minecraft/save_world.cgi @@ -27,8 +27,10 @@ if ($in{'new'}) { # Create world directory if ($in{'src'} == 0) { # Empty world - # XXX .dat file? - &make_dir_logged($dir, 0755); + &make_dir($dir, 0755); + my $fh = "EMPTY"; + &open_tempfile($fh, ">$dir/level.dat", 0, 1); + &close_tempfile($fh); } elsif ($in{'src'} == 1) { # Clone existing world @@ -67,7 +69,6 @@ if ($in{'new'}) { -r $dat && $dat =~ /^(.*)\/level.dat$/ || &error($text{'world_edat'}); my $copysrc = $1; - print STDERR "dat=$dat copysrc=$copysrc\n"; ©_source_dest($copysrc, $dir); } &redirect("list_worlds.cgi"); diff --git a/minecraft/view_conn.cgi b/minecraft/view_conn.cgi index 97ea93cbc..fb93e9450 100644 --- a/minecraft/view_conn.cgi +++ b/minecraft/view_conn.cgi @@ -53,9 +53,9 @@ if ($c || 1) { &ui_textbox("text", undef, 40)." ". &ui_submit($text{'conn_msgb'}, 'msg')); - # Kill player - print &ui_table_row($text{'conn_kill'}, - &ui_submit($text{'conn_killb'}, 'kill')); + # Kill player (not possible?) + #print &ui_table_row($text{'conn_kill'}, + # &ui_submit($text{'conn_killb'}, 'kill')); # Disconnect player print &ui_table_row($text{'conn_kick'},