-
Notifications
You must be signed in to change notification settings - Fork 2
/
server.php
50 lines (50 loc) · 1.27 KB
/
server.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
<?php
echo "Phpcraft PHP Minecraft Server\n\n";
if(empty($argv))
{
die("This is for PHP-CLI. Connect to your server via SSH and use `php server.php`.\n");
}
require __DIR__."/vendor/autoload.php";
use Asyncore\Asyncore;
use Phpcraft\
{ChatComponent, Command\Command, Event\ServerConsoleEvent, IntegratedServer, PluginManager};
$server = IntegratedServer::cliStart("Phpcraft Server", [
"groups" => [
"default" => [
"allow" => [
"use /me",
"use /gamemode",
"use /noclipcreative",
"use /metadata",
"change the world"
]
],
"user" => [
"inherit" => "default",
"allow" => [
"use /abilities",
"use chromium"
]
],
"admin" => [
"allow" => "everything"
]
]
]);
echo "Loading plugins...\n";
PluginManager::loadPlugins();
echo "Loaded ".count(PluginManager::$loaded_plugins)." plugin(s).\n";
$server->ui->render();
Asyncore::on("stdin_line", function(string $msg) use (&$server)
{
if($msg && !Command::handleMessage($server, $msg) && !PluginManager::fire(new ServerConsoleEvent($server, $msg)))
{
$server->broadcast(ChatComponent::translate("chat.type.announcement", [
"Server",
$msg
]));
}
});
Asyncore::loop();
$server->ui->add("Server is not listening on any ports and has no clients, so it's shutting down.");
$server->ui->render();