From 42bb298f05c88a03458ae6b733d0f5b290605dc7 Mon Sep 17 00:00:00 2001 From: Sander Date: Wed, 12 Mar 2025 23:59:54 +0100 Subject: [PATCH 1/9] Create CraftyController.php --- CraftyController/CraftyController.php | 84 +++++++++++++++++++++++++++ 1 file changed, 84 insertions(+) create mode 100644 CraftyController/CraftyController.php diff --git a/CraftyController/CraftyController.php b/CraftyController/CraftyController.php new file mode 100644 index 0000000000..d699c03636 --- /dev/null +++ b/CraftyController/CraftyController.php @@ -0,0 +1,84 @@ +jar = new \GuzzleHttp\Cookie\CookieJar; // Uncomment if cookies need to be set + } + + public function test() + { + $test = parent::appTest($this->url('api/v2/auth/login'), $this->auth_attrs()); + echo $test->status; + } + + public function livestats() + { + $status = "inactive"; + $res = parent::execute($this->url('api/v2/auth/login'), $this->auth_attrs()); + $data = json_decode($res->getBody()); + + if ($data->status == 'ok') { + $this->token = $data->data->token; + } + + $res = parent::execute($this->url('api/v2/servers'), attrs: $this->attrs(), overridemethod: 'GET'); + $details = json_decode($res->getBody()); + + $vars['servers_total'] = count($details->data); + + $online = 0; + + foreach ($details->data as $server) { + $server_res = parent::execute($this->url('api/v2/servers/' . $server->server_id . '/stats'), attrs: $this->attrs(), overridemethod: 'GET'); + $server_details = json_decode($server_res->getBody()); + if ($server_details->data->running == True) + $online++; + } + + $vars['servers_online'] = $online; + + return parent::getLiveStats($status, $vars); + + } + + private function auth_attrs() + { + return [ + "body" => json_encode([ + "username" => $this->config->username, + "password" => $this->config->password + ]), + "verify" => false + ]; + } + + + public function attrs() + { + $attrs["headers"] = [ + "content-type" => "application/json", + "Authorization" => "Bearer " . $this->token, + ]; + $attrs["verify"] = false; + + return $attrs; + } + + public function url($endpoint) + { + $api_url = parent::normaliseurl($this->config->url).$endpoint; + return $api_url; + } +} From 335ee90a3f6edbaa449cf48c68b8201c30f1f8f6 Mon Sep 17 00:00:00 2001 From: Sander Date: Thu, 13 Mar 2025 00:01:56 +0100 Subject: [PATCH 2/9] Add files via upload --- CraftyController/app.json | 10 ++++++++++ CraftyController/config.blade.php | 19 +++++++++++++++++++ CraftyController/craftycontroller.png | Bin 0 -> 6426 bytes CraftyController/livestats.blade.php | 10 ++++++++++ 4 files changed, 39 insertions(+) create mode 100644 CraftyController/app.json create mode 100644 CraftyController/config.blade.php create mode 100644 CraftyController/craftycontroller.png create mode 100644 CraftyController/livestats.blade.php diff --git a/CraftyController/app.json b/CraftyController/app.json new file mode 100644 index 0000000000..23e3109826 --- /dev/null +++ b/CraftyController/app.json @@ -0,0 +1,10 @@ +{ + "appid": "200fe80f6b54e75f36a0ae671663f47b417de384", + "name": "Crafty Controller", + "website": "https://craftycontrol.com", + "license": "GNU General Public License v3.0 or later", + "description": "Crafty Controller is a free and open-source Minecraft launcher and manager that allows users to start and administer Minecraft servers from a user-friendly interface. The interface is run as a self-hosted web server that is accessible to devices on the local network by default and can be port forwarded to provide external access outside of your local network. Crafty is designed to be easy to install and use, requiring only a bit of technical knowledge and a desire to learn to get started. Crafty Controller is still actively being developed by Arcadia Technology and we are continually making major improvements to the software.\r\n\r\nCrafty Controller is a feature rich panel that allows you to create and run servers, manage players, run commands, change server settings, view and edit server files, and make backups. With the help of Crafty Controller managing a large number of Minecraft servers on separate versions is easy and intuitive to do.", + "enhanced": true, + "tile_background": "dark", + "icon": "craftycontroller.png" +} \ No newline at end of file diff --git a/CraftyController/config.blade.php b/CraftyController/config.blade.php new file mode 100644 index 0000000000..e892e6c0d9 --- /dev/null +++ b/CraftyController/config.blade.php @@ -0,0 +1,19 @@ +

{{ __('app.apps.config') }} ({{ __('app.optional') }}) @include('items.enable')

+
+
+ + {!! Form::text('config[override_url]', null, array('placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control')) !!} +
+
+ + {!! Form::text('config[username]', null, array('placeholder' => __('app.apps.username'), 'data-config' => 'username', 'class' => 'form-control config-item')) !!} +
+
+ + {!! Form::input('password', 'config[password]', '', ['placeholder' => __('app.apps.password'), 'data-config' => 'password', 'class' => 'form-control config-item']) !!} +
+
+ +
+
+ diff --git a/CraftyController/craftycontroller.png b/CraftyController/craftycontroller.png new file mode 100644 index 0000000000000000000000000000000000000000..ec39e3fd2903b4852a4f6d3cf579be487e61e342 GIT binary patch literal 6426 zcmbt(XEghY$pW=14JNR&5%6cU~2J?aRFBzlV$ zW`Yo9%;t6MF_PrC$O>Z*La?=6;z+hykZwUYpFbe@_ zsKCVGQHdv*PmtHu@N-cC4l6P9TZC&~VKuFQp>#N#5s~Wg zRU?bG#HF?Cy|o@c79|565A)LGj26GYQ1HIG7d#rO;alwM$vPA~y4CZa1y65{h*Mcf znb@>-bedRSnQ??rTAtypagPRe9cTf-Y~$*`@=H7P@0EJ#w5hr&igzmt-6PJFo3hw2 z>C#fK)jC92{);1= zHl_4Pn9kB<8FXwfK$S_uMnI((9fUc&uH_}y1CX==T90hpO`l`vFfKSR3=`eq@1^Us z=(`yw!m%bIp6K3K0>li6dm24R7X*;jRMLu!FW#d-(nj;BGWN4?U(?y)0g5-qp4?=k5^E68dh+ptb`s?bmeGvUcE1N6W2LPIH>V4IuxzM^w@ z9h4-6lZ!mA?Nfp=CyGCtIf3QEOsTJlnZpEGk@7fY+&$;kA`rOCk2{_3*g%><^z(jD z(_$Pke+>MUtYLz+)m#`)oD|0N+~N%<;z3jcEs%D9hL&vN?-ZI3)e(I&7E6JFM;+JB zog0o+i7V|f(@)L~85jvP7LV_<0}cOHfm8OWPXKdb5eFs{M6aJS4CW(Bfaoj`9qEc8 zShj}gKm=KJ@t9n2j8W_$qMnTu7xsqs5}?m1K|#vIAYo`j#R{s9;n~a=QhVY%X~= zS8GK(>>iPii5HFy?An9lwI`aS6U2yaf#h&rtOGgbAxW#5G2ZQLn<)q01ti?%@|911 z@-*AXt)kDl692{F^*6(BLVhQYa6GRsSnJcW4RwcU2CV5iw~{<~P-V&L8c)>&_z7fb zD>f0<5Vo@2Udb!SLD_20AJ@+T&wP;w7W7OuNJ;+ z-C*38_bN`zRo9zcuS!*WEfORB%tCg+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.php b/CraftyController/livestats.blade.php new file mode 100644 index 0000000000..73a7470ee4 --- /dev/null +++ b/CraftyController/livestats.blade.php @@ -0,0 +1,10 @@ +
    +
  • + servers + {!! $servers_total !!} +
  • +
  • + online + {!! $servers_online !!} +
  • +
\ No newline at end of file From 6db4e6c164c4c5c76ad87cc0d6f5ba6952581789 Mon Sep 17 00:00:00 2001 From: Sander Date: Thu, 13 Mar 2025 09:23:59 +0100 Subject: [PATCH 3/9] Update CraftyController.php --- CraftyController/CraftyController.php | 22 +++++++++++----------- 1 file changed, 11 insertions(+), 11 deletions(-) diff --git a/CraftyController/CraftyController.php b/CraftyController/CraftyController.php index d699c03636..9da10ce624 100644 --- a/CraftyController/CraftyController.php +++ b/CraftyController/CraftyController.php @@ -4,7 +4,6 @@ class CraftyController extends \App\SupportedApps implements \App\EnhancedApps { - public $config; private $token = null; @@ -18,17 +17,16 @@ public function __construct() } public function test() - { - $test = parent::appTest($this->url('api/v2/auth/login'), $this->auth_attrs()); + { + $test = parent::appTest($this->url('api/v2/auth/login'), $this->authAttrs()); echo $test->status; } public function livestats() { $status = "inactive"; - $res = parent::execute($this->url('api/v2/auth/login'), $this->auth_attrs()); + $res = parent::execute($this->url('api/v2/auth/login'), $this->authAttrs()); $data = json_decode($res->getBody()); - if ($data->status == 'ok') { $this->token = $data->data->token; } @@ -41,19 +39,21 @@ public function livestats() $online = 0; foreach ($details->data as $server) { - $server_res = parent::execute($this->url('api/v2/servers/' . $server->server_id . '/stats'), attrs: $this->attrs(), overridemethod: 'GET'); + $server_res = parent::execute($this->url('api/v2/servers/' . $server->server_id . '/stats'), + attrs: $this->attrs(), + overridemethod: 'GET'); $server_details = json_decode($server_res->getBody()); - if ($server_details->data->running == True) + if ($server_details->data->running == true) { $online++; + } } $vars['servers_online'] = $online; return parent::getLiveStats($status, $vars); - } - private function auth_attrs() + private function authAttrs() { return [ "body" => json_encode([ @@ -64,7 +64,7 @@ private function auth_attrs() ]; } - + public function attrs() { $attrs["headers"] = [ @@ -78,7 +78,7 @@ public function attrs() public function url($endpoint) { - $api_url = parent::normaliseurl($this->config->url).$endpoint; + $api_url = parent::normaliseurl($this->config->url) . $endpoint; return $api_url; } } From e434790eee8c1c9b4c69f5a8f91e554c2d918aa6 Mon Sep 17 00:00:00 2001 From: Sander Date: Thu, 13 Mar 2025 09:25:58 +0100 Subject: [PATCH 4/9] Update CraftyController.php --- CraftyController/CraftyController.php | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/CraftyController/CraftyController.php b/CraftyController/CraftyController.php index 9da10ce624..463543f32f 100644 --- a/CraftyController/CraftyController.php +++ b/CraftyController/CraftyController.php @@ -39,9 +39,11 @@ public function livestats() $online = 0; foreach ($details->data as $server) { - $server_res = parent::execute($this->url('api/v2/servers/' . $server->server_id . '/stats'), - attrs: $this->attrs(), - overridemethod: 'GET'); + $server_res = parent::execute( + $this->url('api/v2/servers/' . $server->server_id . '/stats'), + attrs: $this->attrs(), + overridemethod: 'GET' + ); $server_details = json_decode($server_res->getBody()); if ($server_details->data->running == true) { $online++; From be6b4316a71395c0ebad27ac7ef5aca10773638e Mon Sep 17 00:00:00 2001 From: root Date: Thu, 13 Mar 2025 11:16:44 +0100 Subject: [PATCH 5/9] Added some features --- CraftyController/CraftyController.php | 89 +++++++++++++++++++++------ CraftyController/config.blade.php | 17 +++++ CraftyController/livestats.blade.php | 8 +-- 3 files changed, 90 insertions(+), 24 deletions(-) diff --git a/CraftyController/CraftyController.php b/CraftyController/CraftyController.php index 463543f32f..9a45427b4e 100644 --- a/CraftyController/CraftyController.php +++ b/CraftyController/CraftyController.php @@ -16,27 +16,42 @@ public function __construct() //$this->jar = new \GuzzleHttp\Cookie\CookieJar; // Uncomment if cookies need to be set } + private function getToken() + { + $res = parent::execute($this->url('api/v2/auth/login'), $this->authAttrs()); + $data = json_decode($res->getBody()); + if ($data->status == 'ok') { + $this->token = $data->data->token; + } + } + public function test() { - $test = parent::appTest($this->url('api/v2/auth/login'), $this->authAttrs()); - echo $test->status; + try { + $this->getToken(); + echo "Successfully communicated with the API"; + } catch (Exception $err) { + echo $err->getMessage(); + } } public function livestats() { $status = "inactive"; - $res = parent::execute($this->url('api/v2/auth/login'), $this->authAttrs()); - $data = json_decode($res->getBody()); - if ($data->status == 'ok') { - $this->token = $data->data->token; - } + $this->getToken(); - $res = parent::execute($this->url('api/v2/servers'), attrs: $this->attrs(), overridemethod: 'GET'); + $res = parent::execute( + $this->url('api/v2/servers'), + attrs: $this->attrs(), + overridemethod: 'GET' + ); $details = json_decode($res->getBody()); $vars['servers_total'] = count($details->data); - $online = 0; + $servers_online = 0; + $players_online = 0; + $mem = 0; foreach ($details->data as $server) { $server_res = parent::execute( @@ -45,37 +60,43 @@ public function livestats() overridemethod: 'GET' ); $server_details = json_decode($server_res->getBody()); + $players_online += $server_details->data->online; + $mem += $this->decodeSizeToGB($server_details->data->mem); if ($server_details->data->running == true) { - $online++; + $servers_online++; } } - $vars['servers_online'] = $online; + $vars['servers_online'] = $servers_online; + $vars['players_online'] = $players_online; + $vars['mem'] = $mem; return parent::getLiveStats($status, $vars); } private function authAttrs() { + $ignoreTls = $this->getConfigValue("ignore_tls", false); return [ "body" => json_encode([ - "username" => $this->config->username, - "password" => $this->config->password + "username" => $this->getConfigValue("username", null), + "password" => $this->getConfigValue("password", null) ]), - "verify" => false + "verify" => ($ignoreTls ? false : true) ]; } public function attrs() { - $attrs["headers"] = [ - "content-type" => "application/json", - "Authorization" => "Bearer " . $this->token, + $ignoreTls = $this->getConfigValue("ignore_tls", false); + return [ + "headers" => [ + "content-type" => "application/json", + "Authorization" => "Bearer " . $this->token, + ], + "verify" => ($ignoreTls ? false : true) ]; - $attrs["verify"] = false; - - return $attrs; } public function url($endpoint) @@ -83,4 +104,32 @@ public function url($endpoint) $api_url = parent::normaliseurl($this->config->url) . $endpoint; return $api_url; } + + private function getConfigValue($key, $default = null) + { + return isset($this->config) && isset($this->config->$key) + ? $this->config->$key + : $default; + } + + private function decodeSizeToGB($size) + { + $units = [ + 'B' => 1 / (1024 * 1024 * 1024), // Convert bytes to GB + 'KB' => 1 / (1024 * 1024), // Convert KB to GB + 'MB' => 1 / 1024, // Convert MB to GB + 'GB' => 1, // GB is the base unit + 'TB' => 1024, // Convert TB to GB + 'PB' => 1024 * 1024, // Convert PB to GB + ]; + + if (preg_match('/^([\d\.]+)\s*([KMGTP]?B)$/i', strtoupper($size), $matches)) { + $value = (float)$matches[1]; + $unit = $matches[2]; + + return $value * ($units[$unit] ?? 1); + } + + return false; // Invalid format + } } diff --git a/CraftyController/config.blade.php b/CraftyController/config.blade.php index e892e6c0d9..e4030b30f4 100644 --- a/CraftyController/config.blade.php +++ b/CraftyController/config.blade.php @@ -12,6 +12,23 @@ {!! Form::input('password', 'config[password]', '', ['placeholder' => __('app.apps.password'), 'data-config' => 'password', 'class' => 'form-control config-item']) !!} +
+ +
+ {!! Form::hidden('config[ignore_tls]', 0, ['class' => 'config-item', 'data-config' => 'ignore_tls']) !!} + +
+
diff --git a/CraftyController/livestats.blade.php b/CraftyController/livestats.blade.php index 73a7470ee4..af51228714 100644 --- a/CraftyController/livestats.blade.php +++ b/CraftyController/livestats.blade.php @@ -1,10 +1,10 @@
  • - servers - {!! $servers_total !!} + servers: {!! $servers_total !!} + players: {!! $players_online !!}
  • - online - {!! $servers_online !!} + online: {!! $servers_online !!} + {!! $mem !!} GB
\ No newline at end of file From 2953ebe4f5b645e1928dd02ccf4e2cc8e10b810d Mon Sep 17 00:00:00 2001 From: root Date: Thu, 13 Mar 2025 11:24:12 +0100 Subject: [PATCH 6/9] Improve linting --- CraftyController/CraftyController.php | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/CraftyController/CraftyController.php b/CraftyController/CraftyController.php index 9a45427b4e..5cf82e4ce0 100644 --- a/CraftyController/CraftyController.php +++ b/CraftyController/CraftyController.php @@ -122,14 +122,14 @@ private function decodeSizeToGB($size) 'TB' => 1024, // Convert TB to GB 'PB' => 1024 * 1024, // Convert PB to GB ]; - + if (preg_match('/^([\d\.]+)\s*([KMGTP]?B)$/i', strtoupper($size), $matches)) { $value = (float)$matches[1]; $unit = $matches[2]; - + return $value * ($units[$unit] ?? 1); } - + return false; // Invalid format } } From 05a351c3a972f4265bc5cb9c3a145525af0a1627 Mon Sep 17 00:00:00 2001 From: root Date: Thu, 13 Mar 2025 11:36:06 +0100 Subject: [PATCH 7/9] Memory value rounding --- CraftyController/CraftyController.php | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/CraftyController/CraftyController.php b/CraftyController/CraftyController.php index 5cf82e4ce0..b44a6fd0fd 100644 --- a/CraftyController/CraftyController.php +++ b/CraftyController/CraftyController.php @@ -127,7 +127,7 @@ private function decodeSizeToGB($size) $value = (float)$matches[1]; $unit = $matches[2]; - return $value * ($units[$unit] ?? 1); + return round($value * ($units[$unit] ?? 1), 1); } return false; // Invalid format From c827d3688a6059818d3b91e2b248f763c49b59af Mon Sep 17 00:00:00 2001 From: root Date: Fri, 14 Mar 2025 11:35:38 +0100 Subject: [PATCH 8/9] Updated config and livestats --- CraftyController/config.blade.php | 4 ++-- CraftyController/livestats.blade.php | 8 ++++---- 2 files changed, 6 insertions(+), 6 deletions(-) diff --git a/CraftyController/config.blade.php b/CraftyController/config.blade.php index e4030b30f4..93635e82e0 100644 --- a/CraftyController/config.blade.php +++ b/CraftyController/config.blade.php @@ -2,11 +2,11 @@
- {!! Form::text('config[override_url]', null, array('placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control')) !!} + {!! Form::text('config[override_url]', isset($item) ? $item->getconfig()->override_url : null, array('placeholder' => __('app.apps.override'), 'id' => 'override_url', 'class' => 'form-control')) !!}
- {!! Form::text('config[username]', null, array('placeholder' => __('app.apps.username'), 'data-config' => 'username', 'class' => 'form-control config-item')) !!} + {!! Form::text('config[username]', isset($item) ? $item->getconfig()->username : null, array('placeholder' => __('app.apps.username'), 'data-config' => 'username', 'class' => 'form-control config-item')) !!}
diff --git a/CraftyController/livestats.blade.php b/CraftyController/livestats.blade.php index af51228714..a369ff6643 100644 --- a/CraftyController/livestats.blade.php +++ b/CraftyController/livestats.blade.php @@ -1,10 +1,10 @@
  • - servers: {!! $servers_total !!} - players: {!! $players_online !!} + servers:{!! $servers_total !!} + players:{!! $players_online !!}
  • - online: {!! $servers_online !!} - {!! $mem !!} GB + online:{!! $servers_online !!} + memory:{!! $mem !!} GB
\ No newline at end of file From 6e916628b21ccf97c2e5fa284903dd15b7a5939b Mon Sep 17 00:00:00 2001 From: Sander Date: Mon, 24 Mar 2025 07:09:34 +0100 Subject: [PATCH 9/9] Update app.json --- CraftyController/app.json | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/CraftyController/app.json b/CraftyController/app.json index 23e3109826..edd052843e 100644 --- a/CraftyController/app.json +++ b/CraftyController/app.json @@ -3,8 +3,8 @@ "name": "Crafty Controller", "website": "https://craftycontrol.com", "license": "GNU General Public License v3.0 or later", - "description": "Crafty Controller is a free and open-source Minecraft launcher and manager that allows users to start and administer Minecraft servers from a user-friendly interface. The interface is run as a self-hosted web server that is accessible to devices on the local network by default and can be port forwarded to provide external access outside of your local network. Crafty is designed to be easy to install and use, requiring only a bit of technical knowledge and a desire to learn to get started. Crafty Controller is still actively being developed by Arcadia Technology and we are continually making major improvements to the software.\r\n\r\nCrafty Controller is a feature rich panel that allows you to create and run servers, manage players, run commands, change server settings, view and edit server files, and make backups. With the help of Crafty Controller managing a large number of Minecraft servers on separate versions is easy and intuitive to do.", + "description": "Crafty Controller is a free and open-source Minecraft launcher and manager that allows users to start and administer Minecraft servers from a user-friendly interface.", "enhanced": true, "tile_background": "dark", "icon": "craftycontroller.png" -} \ No newline at end of file +}