介绍c++
Cuberite是什么?git
Cuberite是一个可扩展的开源Minecraft服务器实现,使用c++编写。它有一个易于使用的插件系统,容许用户用Lua编写自定义插件,最初是用MCServer的名字建立的。github
支持平台:vim
Cuberite是多平台的,能够用于大多数Linux操做系统和Windows。本教程将只介绍在CentOS 6或7安装上安装服务器软件的状况。和大多数Minecraft服务器同样,插件和其余因素将致使更大的内存占用。首先,建议您至少有:服务器
1 g的内存编辑器
一个CPU核心工具
安装fetch
先决条件ui
在开始以前,咱们必须确保系统是最新的,而且有一个适当的文本编辑器。这对于配置服务器是必要的。咱们还须要适当的工具来构建和编译软件。this
在咱们安装任何东西以前,执行如下命令更新您的系统:
yum update -y
如今,咱们将安装nano (您可使用vim或任何其余编辑器):
yum install nano -y
完成后,运行如下命令安装cmake(编译器):
yum install cmake -y
如今,安装screen (容许应用程序在后台运行):
yum install screen -y
在screen安装以后,您能够继续进入下一个部分
运行安装脚本
如今咱们已经完成了安装所需的全部依赖项,咱们必须检索脚本。下面的命令将在/root或~中建立一个新目录。
cd ~ && mkdir server
cd server
wget -O install.sh https://www.yunjinquan.com/quan/
如今,您能够运行安装脚本:
sh install.sh
您将在终端上看到如下信息:
[root@demo server]# sh install sh
Hello, this script will download and compile Cuberite.
On subsequent runs, it will update Cuberite.
The compilation and download will occur in the current directory.
If you're updating, you should run: <Path to Cuberite>/compile.sh
Compiling from srouce takes time, but it usually generates faster
executables. If you prefer ready-to-use binaries or if you want
more info, please visit: https://cuberite.org
Choose compile mode:
* (R)Release: Compiles normally.
Generates the fastest build.
* (D)Debug: Compiles in debug mode.
Makes your console and crashes more verbose.
A bit slower than Release mode. If you plan to help
development by reporting bugs, this is preferred.
Choose compile mode: (r/d) (Default: "Release"):
当你看到上面的内容时,只需按下键盘上的回车键。
如今您将看到如下内容:
Choose the number of compilation threads.
You have 2 CPU threads.
If you have enough RAM, it is wise to choose your CPU's thread count.
Otherwise choose lower. Old Raspberry Pis should choose 1. If in doubt, choose 1
.
Please enter the number of compilation threads to use (Default: 1):
您能够选择为编译使用更多的线程(取决于您拥有的实例)。除此以外,你要作的就是按回车键。
一旦你这样作了,你将被提示以下信息:
#### Settings Summary ####
Build Type: Release
Branch: master (Currently the only choice)
Compilation threads: 1
CPU Threads: 2
Previous Compilation: Not detected. We are assuming this is the first compile.sh run.
Upstream Link: https://github.com/cuberite/cuberite.git
Upstream Repo: origin
After pressing ENTER, the script will connect to http://52kuaiyun.com/codes/
to check for updates and/or fetch code. It will then compile your program.
If you compiled before, make sure you're in the proper directory and that "Previous
compilation" is detected.
Press ENTER to continue...
这是编译开始前的最后一步。您将被告知按回车键开始编译。根据您的系统,大约须要15分钟。
注意:若是你看到一堆文本在你的终端上滚动,不要惊慌。系统将软件彻底编译成可执行包须要一些时间。
一旦完成,你会收到如下信息:
-----------------
Compilation done!
Cuberite awaits you at:
/root/server/cuberite/Server/Cuberite
You can always update Cuberite by executing:
/root/server/cuberite/compile.sh
Enjoy :)
这标志着安装的结束。您能够进入下一节了解服务器的配置。
配置
为了配置您的服务器,咱们必须首先从咱们的临时目录中找到并复制已编译的服务器:
cd cuberite
cp -r Server ~/server/cuberiteServer
cd ./cuberiteServer
您的服务器目录将位于/root/server/cuberiteServer
,配置文件将位于/root/server/cuberiteServer/settings.ini
.
咱们如今可使用任何文本编辑器编辑配置:
nano settings.ini
您将看到以下内容:
[Server]
Description=Cuberite - in C++!
ShutdownMessage=Server shutdown
MaxPlayers=100
HardcoreEnabled=0
AllowMultiLogin=0
Ports=25565
为了编辑在任何给定时间能够在线的最大玩家数量,只需将MaxPlayers=100行修改成任何您想要的数字。
例如,若是您想要最多25个玩家,您所要作的就是将行改成MaxPlayers=25。
你也能够改变这个端口,可是不建议这样作,由于用户链接到你的服务器的难度增长了(Minecraft服务器的默认端口是25565)。
若是你使用的是nano,你能够退出并经过CTRL + X保存,而后回车。
启动、中止并链接到新服务器
启动服务器
要启动服务器,只需转到服务器目录(/root/server/cuberiteServer)并启动一个屏幕:
cd ~/server/cuberiteServer
screen -S MinecraftServer && screen -r MinecraftServer
您能够在任什么时候候使用screen -r 命令从新链接到屏幕。咱们将屏幕命名为MinecraftServer,所以从新链接能够经过执行screen -r MinecraftServer来完成。
如今,执行服务器二进制文件:
./Cuberite
在使用服务器以前,地形可能须要几秒钟才能生成。一样,使用如下组合退出屏幕:CTRL + A + D。
中止服务器
为了执行硬关机,你只须要使用CTRL + c来执行一个优雅的关机,在控制台输入如下命令:
stop
链接到您的服务器
假设您已经配置了防火墙,那么您能够在Minecraft客户机中输入服务器地址。
您的地址应该以下所示:192.0.2.5:25565(192.0.2.5是实际的服务器地址)。
最后的评论
此时,您能够将服务器地址和一些朋友一块儿传递,而后开始构建。
卸载Cuberite
删除软件很简单。您所要作的就是确保服务器离线并运行rm -rf ~/server。