Spigotサーバーを動かしてみる

Spigotサーバーを動かしてみる

Minecraftマルチプレイをするときに、相手の環境にMODをあわせたりといろいろ面倒だとおもっていました。

Spigotpluginでは、バニラと互換性を持ちつつ(ブロックやアイテムの追加はできない)機能追加が行えるようなのでpluginを作って見ようと思い、まずは手始めにSpigotを動かしてみました。

環境

Getting Started

まずは、公式の Getting Started - Installation から始めます。

Prerequisites

Getting Startedをやる前の前準備を行います。

1. Java8インストール

1.Java 8 or above [Windows, Ubuntu, CentOS, OS X]

Java8はインストール済みなので手順をスキップします。

2. BuildToolsでSpigotのjarをビルド

記載の通り BuildTools | SpigotMC - High Performance Minecraft の手順を愚直に実施していきます。

2.The server jar compiled by following the BuildTools wiki page. (After running BuildTools you will find the Spigot/CraftBukkit server jar files in the same directory)

2.1. 前提条件の GitJava はインストール

Prerequisites(top) There are two applications necessary to use BuildTools: Git and Java.

既にインストール済みなのでスキップします。

2.2. BuildToolsダウンロード

Running BuildToolsのセクションに記載されている通り、まずは BuildToolsの最新版をダウンロードします。

以下 Macに関係ない手順はスキップします。

1.Download BuildTools.jar from https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar.

$ curl -O https://hub.spigotmc.org/jenkins/job/BuildTools/lastSuccessfulBuild/artifact/target/BuildTools.jar
  % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                 Dload  Upload   Total   Spent    Left  Speed
100 3900k  100 3900k    0     0  1902k      0  0:00:02  0:00:02 --:--:-- 1903k

$ ls
BuildTools.jar

2.3. BuildTools.jarを実行

4.Run BuildTools.jar from the terminal (Do not double-click BuildTools.jar) by doing the following:

3.On Mac run the below commands, export MAVEN_OPTS="-Xmx2G" java -Xmx2G -jar BuildTools.jar

4.Options (all OS's) : The --rev option can be used to get specific 1.8/1.9 versions of CraftBukkit / Spigot See Versions below for available options

上記を加味して下記コマンドを実行

export MAVEN_OPTS="-Xmx2G"
java -Xmx2G -jar BuildTools.jar --rev 1.14.2

ビルドは5分程度かかりました。以下のようなログが出て無事終了しました。

Success! Everything compiled successfully. Copying final .jar files now.
Copying spigot-1.14.2-R0.1-SNAPSHOT.jar to /Users/username/spigot1/./spigot-1.14.2.jar
  - Saved as ./spigot-1.14.2.jar
$ ls
BuildData          Bukkit             apache-maven-3.6.0 work
BuildTools.jar     CraftBukkit        spigot-1.14.2.jar
BuildTools.log.txt Spigot

2.4. jarを作業フォルダへコピー

The Spigot/CraftBukkit server jar file copied to a new directory dedicated to your server. (Not the same folder as BuildTools is in!)

とりあえず、run-spigotというディレクトリを作り、spigot本体のjarをコピーしました。

$ mkdir run-spigot
$ cp spigot-1.14.2.jar run-spigot/
$ ls run-spigot/
spigot-1.14.2.jar
$ cd run-spigot/

Installation

1. Spigot実行

Getting Startedの手順から少し手を抜いて、下記コマンドをターミナルから直接実行

java -Xms512M -Xmx1G -XX:+UseConcMarkSweepGC -jar spigot-1.14.2.jar
$ java -Xms512M -Xmx1G -XX:+UseConcMarkSweepGC -jar spigot-1.14.2.jar
Loading libraries, please wait...
Failed to load properties from file: server.properties
Failed to load eula.txt
You need to agree to the EULA in order to run the server. Go to eula.txt for more info.
$ ls
eula.txt          logs              server.properties spigot-1.14.2.jar

2. EULAの対応

eula.txtを以下のように編集します。

$ cat eula.txt
#By changing the setting below to TRUE you are indicating your agreement to our EULA (https://account.mojang.com/documents/minecraft_eula).
#Tue Jun 04 22:51:24 JST 2019
eula=true

3. 再度実行

再度実行すると、以下のように無事起動しました。

$ java -Xms512M -Xmx1G -XX:+UseConcMarkSweepGC -jar spigot-1.14.2.jar
Loading libraries, please wait...
[22:56:27] [Server thread/INFO]: Starting minecraft server version 1.14.2
[22:56:27] [Server thread/INFO]: Loading properties
[22:56:28] [Server thread/INFO]: This server is running CraftBukkit version git-Spigot-baafee9-043d31d (MC: 1.14.2) (Implementing API version 1.14.2-R0.1-SNAPSHOT)
[22:56:28] [Server thread/INFO]: Debug logging is disabled
[22:56:28] [Server thread/INFO]: Server Ping Player Sample Count: 12
[22:56:28] [Server thread/INFO]: Using 4 threads for Netty based IO
[22:56:28] [Server thread/INFO]: Default game type: SURVIVAL
[22:56:28] [Server thread/INFO]: Generating keypair
[22:56:30] [Server thread/INFO]: Starting Minecraft server on *:25565
[22:56:30] [Server thread/INFO]: Using default channel type
[22:56:36] [Server thread/INFO]: Preparing level "world"
[22:56:36] [Server thread/INFO]: Found new data pack file/bukkit, loading it automatically
[22:56:36] [Server thread/INFO]: Found new data pack vanilla, loading it automatically
[22:56:36] [Server thread/INFO]: Reloading ResourceManager: Default, bukkit
[22:56:38] [Server thread/INFO]: Loaded 6 recipes
[22:56:42] [Server thread/INFO]: -------- World Settings For [world] --------
[22:56:42] [Server thread/INFO]: View Distance: 10
[22:56:42] [Server thread/INFO]: Nerfing mobs spawned from spawners: false
[22:56:42] [Server thread/INFO]: Allow Zombie Pigmen to spawn from portal blocks: true
[22:56:42] [Server thread/INFO]: Item Despawn Rate: 6000
[22:56:42] [Server thread/INFO]: Item Merge Radius: 2.5
[22:56:42] [Server thread/INFO]: Arrow Despawn Rate: 1200
[22:56:42] [Server thread/INFO]: Zombie Aggressive Towards Villager: true
[22:56:42] [Server thread/INFO]: Hopper Transfer: 8 Hopper Check: 1 Hopper Amount: 1
[22:56:42] [Server thread/INFO]: Experience Merge Radius: 3.0
[22:56:42] [Server thread/INFO]: Mob Spawn Range: 6
[22:56:42] [Server thread/INFO]: Cactus Growth Modifier: 100%
[22:56:42] [Server thread/INFO]: Cane Growth Modifier: 100%
[22:56:42] [Server thread/INFO]: Melon Growth Modifier: 100%
[22:56:42] [Server thread/INFO]: Mushroom Growth Modifier: 100%
[22:56:42] [Server thread/INFO]: Pumpkin Growth Modifier: 100%
[22:56:42] [Server thread/INFO]: Sapling Growth Modifier: 100%
[22:56:42] [Server thread/INFO]: Beetroot Growth Modifier: 100%
[22:56:42] [Server thread/INFO]: Carrot Growth Modifier: 100%
[22:56:42] [Server thread/INFO]: Potato Growth Modifier: 100%
[22:56:42] [Server thread/INFO]: Wheat Growth Modifier: 100%
[22:56:42] [Server thread/INFO]: NetherWart Growth Modifier: 100%
[22:56:42] [Server thread/INFO]: Vine Growth Modifier: 100%
[22:56:42] [Server thread/INFO]: Cocoa Growth Modifier: 100%
[22:56:42] [Server thread/INFO]: Entity Activation Range: An 32 / Mo 32 / Ra 48 / Mi 16 / Tiv true
[22:56:42] [Server thread/INFO]: Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64
[22:56:42] [Server thread/INFO]: Custom Map Seeds:  Village: 10387312 Desert: 14357617 Igloo: 14357618 Jungle: 14357619 Swamp: 14357620 Monument: 10387313Ocean: 14357621 Shipwreck: 165745295 Slime: 987234911
[22:56:42] [Server thread/INFO]: Max TNT Explosions: 100
[22:56:42] [Server thread/INFO]: Tile Max Tick Time: 50ms Entity max Tick Time: 50ms
[22:56:55] [Server thread/INFO]: -------- World Settings For [world_nether] --------
[22:56:55] [Server thread/INFO]: View Distance: 10
[22:56:55] [Server thread/INFO]: Nerfing mobs spawned from spawners: false
[22:56:55] [Server thread/INFO]: Allow Zombie Pigmen to spawn from portal blocks: true
[22:56:55] [Server thread/INFO]: Item Despawn Rate: 6000
[22:56:55] [Server thread/INFO]: Item Merge Radius: 2.5
[22:56:55] [Server thread/INFO]: Arrow Despawn Rate: 1200
[22:56:55] [Server thread/INFO]: Zombie Aggressive Towards Villager: true
[22:56:55] [Server thread/INFO]: Hopper Transfer: 8 Hopper Check: 1 Hopper Amount: 1
[22:56:55] [Server thread/INFO]: Experience Merge Radius: 3.0
[22:56:55] [Server thread/INFO]: Mob Spawn Range: 6
[22:56:55] [Server thread/INFO]: Cactus Growth Modifier: 100%
[22:56:55] [Server thread/INFO]: Cane Growth Modifier: 100%
[22:56:55] [Server thread/INFO]: Melon Growth Modifier: 100%
[22:56:55] [Server thread/INFO]: Mushroom Growth Modifier: 100%
[22:56:55] [Server thread/INFO]: Pumpkin Growth Modifier: 100%
[22:56:55] [Server thread/INFO]: Sapling Growth Modifier: 100%
[22:56:55] [Server thread/INFO]: Beetroot Growth Modifier: 100%
[22:56:55] [Server thread/INFO]: Carrot Growth Modifier: 100%
[22:56:55] [Server thread/INFO]: Potato Growth Modifier: 100%
[22:56:55] [Server thread/INFO]: Wheat Growth Modifier: 100%
[22:56:55] [Server thread/INFO]: NetherWart Growth Modifier: 100%
[22:56:55] [Server thread/INFO]: Vine Growth Modifier: 100%
[22:56:55] [Server thread/INFO]: Cocoa Growth Modifier: 100%
[22:56:55] [Server thread/INFO]: Entity Activation Range: An 32 / Mo 32 / Ra 48 / Mi 16 / Tiv true
[22:56:55] [Server thread/INFO]: Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64
[22:56:55] [Server thread/INFO]: Custom Map Seeds:  Village: 10387312 Desert: 14357617 Igloo: 14357618 Jungle: 14357619 Swamp: 14357620 Monument: 10387313Ocean: 14357621 Shipwreck: 165745295 Slime: 987234911
[22:56:55] [Server thread/INFO]: Max TNT Explosions: 100
[22:56:55] [Server thread/INFO]: Tile Max Tick Time: 50ms Entity max Tick Time: 50ms
[22:56:55] [Server thread/INFO]: -------- World Settings For [world_the_end] --------
[22:56:55] [Server thread/INFO]: View Distance: 10
[22:56:55] [Server thread/INFO]: Nerfing mobs spawned from spawners: false
[22:56:55] [Server thread/INFO]: Allow Zombie Pigmen to spawn from portal blocks: true
[22:56:55] [Server thread/INFO]: Item Despawn Rate: 6000
[22:56:55] [Server thread/INFO]: Item Merge Radius: 2.5
[22:56:55] [Server thread/INFO]: Arrow Despawn Rate: 1200
[22:56:55] [Server thread/INFO]: Zombie Aggressive Towards Villager: true
[22:56:55] [Server thread/INFO]: Hopper Transfer: 8 Hopper Check: 1 Hopper Amount: 1
[22:56:55] [Server thread/INFO]: Experience Merge Radius: 3.0
[22:56:55] [Server thread/INFO]: Mob Spawn Range: 6
[22:56:55] [Server thread/INFO]: Cactus Growth Modifier: 100%
[22:56:55] [Server thread/INFO]: Cane Growth Modifier: 100%
[22:56:55] [Server thread/INFO]: Melon Growth Modifier: 100%
[22:56:55] [Server thread/INFO]: Mushroom Growth Modifier: 100%
[22:56:55] [Server thread/INFO]: Pumpkin Growth Modifier: 100%
[22:56:55] [Server thread/INFO]: Sapling Growth Modifier: 100%
[22:56:55] [Server thread/INFO]: Beetroot Growth Modifier: 100%
[22:56:55] [Server thread/INFO]: Carrot Growth Modifier: 100%
[22:56:55] [Server thread/INFO]: Potato Growth Modifier: 100%
[22:56:55] [Server thread/INFO]: Wheat Growth Modifier: 100%
[22:56:55] [Server thread/INFO]: NetherWart Growth Modifier: 100%
[22:56:55] [Server thread/INFO]: Vine Growth Modifier: 100%
[22:56:55] [Server thread/INFO]: Cocoa Growth Modifier: 100%
[22:56:55] [Server thread/INFO]: Entity Activation Range: An 32 / Mo 32 / Ra 48 / Mi 16 / Tiv true
[22:56:55] [Server thread/INFO]: Entity Tracking Range: Pl 48 / An 48 / Mo 48 / Mi 32 / Other 64
[22:56:55] [Server thread/INFO]: Custom Map Seeds:  Village: 10387312 Desert: 14357617 Igloo: 14357618 Jungle: 14357619 Swamp: 14357620 Monument: 10387313Ocean: 14357621 Shipwreck: 165745295 Slime: 987234911
[22:56:55] [Server thread/INFO]: Max TNT Explosions: 100
[22:56:55] [Server thread/INFO]: Tile Max Tick Time: 50ms Entity max Tick Time: 50ms
[22:56:55] [Server thread/INFO]: Preparing start region for dimension 'world'/minecraft:overworld
[22:56:55] [Server-Worker-3/INFO]: Preparing spawn area: 0%

〜略〜

[22:57:34] [Server-Worker-3/INFO]: Preparing spawn area: 99%
[22:57:34] [Server thread/INFO]: Time elapsed: 39570 ms
[22:57:34] [Server thread/INFO]: Preparing start region for dimension 'world_nether'/minecraft:the_nether
[22:57:34] [Server-Worker-1/INFO]: Preparing spawn area: 0%

〜略〜

[22:57:51] [Server-Worker-1/INFO]: Preparing spawn area: 99%
[22:57:51] [Server thread/INFO]: Time elapsed: 16619 ms
[22:57:51] [Server thread/INFO]: Preparing start region for dimension 'world_the_end'/minecraft:the_end
[22:57:51] [Server-Worker-2/INFO]: Preparing spawn area: 0%
[22:57:51] [Server-Worker-3/INFO]: Preparing spawn area: 1%
[22:57:52] [Server-Worker-1/INFO]: Preparing spawn area: 14%
[22:57:52] [Server-Worker-2/INFO]: Preparing spawn area: 42%
[22:57:53] [Server-Worker-2/INFO]: Preparing spawn area: 72%
[22:57:53] [Server thread/INFO]: Time elapsed: 2468 ms
[22:57:53] [Server thread/INFO]: Done (77.869s)! For help, type "help"

4. 動作確認

同じ端末からMinecraftを起動し、 マルチプレイ -> ダイレクト接続 で ローカルのSpigotへ接続します。

f:id:n-noguchi:20190605004948p:plain
ダイレクト接続

ちゃんとログインできました。(うまく撮影できず、ポーズ画面)

f:id:n-noguchi:20190605005026p:plain
Spigotログイン後

ターミナルへの出力

[23:03:01] [Server thread/WARN]: Can't keep up! Is the server overloaded? Running 7754ms or 155 ticks behind
[23:03:16] [User Authenticator #1/INFO]: UUID of player user03 is e35d4001-c897-49d9-79b6-a6b4176ca25e
[23:03:18] [Server thread/INFO]: user03[/127.0.0.1:50108] logged in with entity id 331 at ([world]-179.5, 68.0, 193.5)

5. Spigotの停止

フォアグラウンドで起動しているので、Control-C もしくは、stopコマンドで停止します。

[23:12:10] [Thread-3/INFO]: Stopping server
[23:12:10] [Thread-3/INFO]: Saving players

Post-Installation

After the Spigot.jar has been run the first time, folders and config files will be created. You will need to edit these config files to have the server work properly in your environment.

For information on:
  server.properties: server.properties
  bukkit.yml: bukkit.yml
  spigot.yml: spigot.yml
  Server Icons: spigot.yml

インストール後のパラメータの調整の話しです。

いろいろいじれそうですが、今回は省略します。

サーバーを使うための設定

最後に、サーバー運営ができるようopコマンドで、自分にOP権限を付与します。

>op user03
[23:43:24] [Server thread/INFO]: Made user03 a server operator
>

これで一旦動く環境をつくれました。