From 318ee560765e7ee5f4c269b80465baeba602f58f Mon Sep 17 00:00:00 2001 From: Jamie Cameron Date: Wed, 26 Dec 2012 00:00:23 -0800 Subject: [PATCH] Completed server configuration page --- minecraft/edit_conf.cgi | 115 +++++++++++++++++++++++++++++++++++-- minecraft/edit_world.cgi | 8 +++ minecraft/lang/en | 42 ++++++++++++++ minecraft/minecraft-lib.pl | 1 + minecraft/save_conf.cgi | 92 +++++++++++++++++++++++++++++ minecraft/view_conn.cgi | 12 ++-- 6 files changed, 260 insertions(+), 10 deletions(-) create mode 100644 minecraft/save_conf.cgi diff --git a/minecraft/edit_conf.cgi b/minecraft/edit_conf.cgi index dcff292cf..95527e628 100644 --- a/minecraft/edit_conf.cgi +++ b/minecraft/edit_conf.cgi @@ -9,15 +9,17 @@ my $conf = &get_minecraft_config(); &ui_print_header(undef, $text{'conf_title'}, ""); +print $text{'conf_desc'},"

\n"; + print &ui_form_start("save_conf.cgi", "post"); -print &ui_table_start($text{'conf_header'}, undef, 2); +print &ui_table_start($text{'conf_header'}, undef, 4); #### World-related options # Seed for new worlds my $seed = &find_value("level-seed", $conf); print &ui_table_row($text{'conf_seed'}, - &ui_opt_textbox("seed", $seed, 20, $text{'conf_random'})); + &ui_opt_textbox("seed", $seed, 20, $text{'conf_random'}), 3); # Type for new worlds my $type = &find_value("level-type", $conf) || "DEFAULT"; @@ -30,17 +32,122 @@ print &ui_table_row($text{'conf_type'}, # Generate structures in new worlds my $structs = &find_value("generate-structures", $conf) || "true"; print &ui_table_row($text{'conf_structs'}, - &ui_yesno_radio("structs", lc($structs) eq "true"); + &ui_yesno_radio("structs", lc($structs) eq "true")); # Allow nether my $nether = &find_value("allow-nether", $conf) || "true"; print &ui_table_row($text{'conf_nether'}, - &ui_yesno_radio("nether", lc($nether) eq "true"); + &ui_yesno_radio("nether", lc($nether) eq "true")); + +# Allow command block +my $command = &find_value("enable-command-block", $conf) || "false"; +print &ui_table_row($text{'conf_command'}, + &ui_yesno_radio("command", lc($command) eq "true")); print &ui_table_hr(); #### Game-related options +# Startup difficulty +my $diff = &find_value("difficulty", $conf); +$diff = 1 if (!defined($diff)); +print &ui_table_row($text{'conf_difficulty'}, + &ui_select("diff", $diff, + [ [ 0, $text{'cmds_peaceful'} ], + [ 1, $text{'cmds_easy'} ], + [ 2, $text{'cmds_normal'} ], + [ 3, $text{'cmds_hard'} ] ])); + +# Default game mode +my $gamemode = &find_value("gamemode", $conf); +$gamemode = 0 if (!defined($gamemode)); +print &ui_table_row($text{'conf_gamemode'}, + &ui_select("gamemode", $gamemode, + [ [ 0, $text{'cmds_survival'} ], + [ 1, $text{'cmds_creative'} ], + [ 2, $text{'cmds_adventure'} ] ])); + +# Allow flight +my $flight = &find_value("allow-flight", $conf) || "false"; +print &ui_table_row($text{'conf_flight'}, + &ui_yesno_radio("flight", lc($flight) eq "true")); + +# Hardcore mode +my $hardcore = &find_value("hardcore", $conf) || "false"; +print &ui_table_row($text{'conf_hardcore'}, + &ui_yesno_radio("hardcore", lc($hardcore) eq "true")); + +# Online mode +my $online = &find_value("online-mode", $conf) || "true"; +print &ui_table_row($text{'conf_online'}, + &ui_yesno_radio("online", lc($online) eq "true")); + +# Allow player vs player +my $pvp = &find_value("pvp", $conf) || "true"; +print &ui_table_row($text{'conf_pvp'}, + &ui_yesno_radio("pvp", lc($pvp) eq "true")); + +print &ui_table_hr(); + +#### Server options + +# Max players +my $players = &find_value("max-players", $conf) || 20; +print &ui_table_row($text{'conf_players'}, + &ui_textbox("players", $players, 5)); + +# Message of the day +my $motd = &find_value("motd", $conf); +print &ui_table_row($text{'conf_motd'}, + &ui_opt_textbox("motd", $motd, 60, + $text{'default'}." (A Minecraft Server)
", + $text{'conf_motdmsg'}), 3); + +# Max build height +my $build = &find_value("max-build-height", $conf) || 256; +print &ui_table_row($text{'conf_build'}, + &ui_textbox("build", $build, 5)); + +print &ui_table_hr(); + +#### Spawn options + +# Spawn various creatures +foreach my $s ("animals", "monsters", "npcs") { + my $spawn = &find_value("spawn-$s", $conf) || "true"; + print &ui_table_row($text{'conf_'.$s}, + &ui_yesno_radio($s, lc($spawn) eq "true")); + } + +# Spawn protection range +my $protect = &find_value("spawn-protection", $conf) || 16; +print &ui_table_row($text{'conf_protect'}, + &ui_textbox("protect", $protect, 5)); + +print &ui_table_hr(); + +#### Network options + +# Listen on IP +my $ip = &find_value("server-ip", $conf); +print &ui_table_row($text{'conf_ip'}, + &ui_opt_textbox("ip", $ip, 15, $text{'conf_allip'})); + +# Listen on port +my $port = &find_value("server-port", $conf); +print &ui_table_row($text{'conf_port'}, + &ui_opt_textbox("port", $port, 5, $text{'default'}." (25565)")); + +# Allow query port +my $query = &find_value("enable-query", $conf) || "false"; +print &ui_table_row($text{'conf_query'}, + &ui_yesno_radio("query", lc($query) eq "true")); + +# Allow remote console port +my $rcon = &find_value("enable-rcon", $conf) || "false"; +print &ui_table_row($text{'conf_rcon'}, + &ui_yesno_radio("rcon", lc($rcon) eq "true")); + print &ui_table_end(); print &ui_form_end([ [ undef, $text{'save'} ] ]); diff --git a/minecraft/edit_world.cgi b/minecraft/edit_world.cgi index 3ccbebf41..9a9fcf274 100644 --- a/minecraft/edit_world.cgi +++ b/minecraft/edit_world.cgi @@ -61,6 +61,14 @@ else { print &ui_table_row($text{'worlds_size'}, &nice_size($world->{'size'})); + # Seed, if active + if (&is_minecraft_server_running() && $def eq $world->{'name'}) { + my $out = &execute_minecraft_command("/seed"); + if ($out =~ /Seed:\s+(\S+)/) { + print &ui_table_row($text{'worlds_seed'}, $1); + } + } + # All players if (@{$world->{'players'}}) { my @grid = map { "