Spigot编译流程

相关文档

使用说明

使用gitbash打开当前目录,输入java -jar BuildTools.jar --rev 1.8,这里的1.8可以替换成其它版本,如1.10,1.10.2等。

流程一,下载代码

  • 克隆git代码bukkitbukkit 目录
  • 克隆git代码craftbukkitcraftbukkit 目录
  • 克隆git代码spigotSpigot 目录
  • 克隆git代码buildataBuildData 目录
  • 下载maven工具
  • 从服务器上查询命令行中指定的rev对应的各代码库的分支,如
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Attempting to build version: '1.8' use --rev <version> to override
Found version
{
"name": "1.8",
"description": "Backport of fixes from 1.8.3",
"information": "Last build of Spigot 1.8.0. To update please see http://www.spigotmc.org/",
"warning": "***** Please ensure your BuildTools is at least #35 *****",
"refs": {
"BuildData": "0630ea462a82fdbd93018de7d5ec5e9d3b3c732b",
"Bukkit": "1d2509b99fb10b3bd6f597e63805f85b49d5a055",
"CraftBukkit": "7019900e276b7c9f6e940debf8529094c7f4da0c",
"Spigot": "550ebace4b43adc73854d7d5976e1343eba6fb98"
}
}
  • 将4个文件夹中的代码更新到指定标签

目录说明

BuildData

反编译工具及反编译minecraft使用的代码映射。

CraftBukkit

对minecraft server的魔改,改善性能,并支持插件等。

Bukkit

Bukkit是服务器插件编程接口,封装不同版本minecraft server的细节,统一接口,便于开发插件。

Spigot目录

spigot服务器是一个改良服务器,在文件夹里是两个补丁目录,CraftBukkit-Patches存放对craftBukkit代码的补丁,Bukkit-Patches存放对Bukkit代码的补丁。

流程二,下载minecraft server并反编译

  • 下载纯净版本minecraft服务器jar包(此处应有梯子)。
1
2
3
4
5
6
Attempting to build Minecraft with details: VersionInfo(minecraftVersion=1.8, accessTransforms=bukkit-1.8.at, classMappings=bukkit-1.8-cl.csrg, memberMappings=bukkit-1.8-members.csrg, packageMappings=package.srg, minecraftHash=null, decompileCommand=null, serverUrl=null)
Starting download of https://s3.amazonaws.com/Minecraft.Download/versions/1.8/minecraft_server.1.8.jar

如果下载不下来,也可以迅雷下载后直接放在work目录中,如果已经存在,则会提示:
Found good Minecraft hash (5b19d1a562a8a7c5f9a787ad96c8148b)
Found good Minecraft hash (5b19d1a562a8a7c5f9a787ad96c8148b)
  • 反编译代码
1
2
3
4
5
6
7
8
9
10
Final mapped jar: work\mapped.8eb82bde.jar does not exist, creating!
Loading mappings
Loading mappings
1 packages, 0 classes, 0 fields, 0 methods
INFO: merging AccessMap net/minecraft/server/CraftingManager/recipes from AccessChange(clear=16, set=0, vis=1) with AccessChange(clear=0, set=0, vis=1)
INFO: merging AccessMap net/minecraft/server/PropertyManager/properties from AccessChange(clear=0, set=0, vis=1) with AccessChange(clear=0, set=0, vis=1)
INFO: merging AccessMap net/minecraft/server/TileEntityBrewingStand/items from AccessChange(clear=0, set=0, vis=1) with AccessChange(clear=0, set=0, vis=1)
INFO: merging AccessMap net/minecraft/server/WorldServer/tracker from AccessChange(clear=16, set=0, vis=1) with AccessChange(clear=0, set=0, vis=1)
INFO: merging AccessMap net/minecraft/server/WorldManager/world from AccessChange(clear=0, set=0, vis=1) with AccessChange(clear=0, set=0, vis=1)
Remapping final jar
  • 将minecraft-server的class文件释放到work目录下的decompile-xxxxxxxx目录的classes子目录。
  • 根据map文件,将释放的class文件,反编译到work目录下的decompile-xxxxxxxx中。
  • 将生成的java文件,编译并生成minecraft-server-1.8-SNAPSHOT.jar到mvn的代码仓库目录
1
2
3
4
5
6
7
8
9
10
11
12
13
14
[INFO] Scanning for projects...
[INFO]
[INFO] ------------------------------------------------------------------------
[INFO] Building Maven Stub Project (No POM) 1
[INFO] ------------------------------------------------------------------------
[INFO]
[INFO] --- maven-install-plugin:2.4:install-file (default-cli) @ standalone-pom ---
[INFO] Installing D:\mc\spigotmc_build\work\mapped.8eb82bde.jar to D:\repo\repository\org\spigotmc\minecraft-server\1.8-SNAPSHOT\minecraft-server-1.8-SNAPSHOT.jar
[INFO] Installing C:\Users\terry\AppData\Local\Temp\mvninstall1056450265315348368.pom to D:\repo\repository\org\spigotmc\minecraft-server\1.8-SNAPSHOT\minecraft-server-1.8-SNAPSHOT.pom
[INFO] ------------------------------------------------------------------------
[INFO] BUILD SUCCESS
extract ....*.class
Decomiling ***.java
Applying CraftBukkit Patches
  • 应用代码补丁
1
2
3
Applying CraftBukkit Patches
Patching with BiomeDecorator.patch
Patching with BiomeTheEndDecorator.patch
  • 并各种文件夹合并,将Bukkit和CraftBukkit的代码都checkout一份到Spigot目录。

流程三,编译代码

  • 编译Bukkit和CraftBukkit,并且都输出到Maven本地仓库。
  • 将Bukkit和CraftBukkit的代码check out到Spigot中的Spigot-API和Spigot-Server,然后分别打上补丁(Bukkit-Patches和CraftBukkit-Patches)。
1
2
3
4
5
6
7
8
9
10
11
12
13
14
Rebuilding Forked projects.... 
From file:///D:\mc\spigotmc_build\Bukkit
* [new branch] spigot -> origin/spigot
HEAD is now at 1d2509b Revert finite checks in locations. Fixes SPIGOT-628 and others
Cloning into 'Spigot-API'...
done.
Resetting Spigot-API to Bukkit...

...

HEAD is now at 36052f0 CraftBukkit $ Fri Aug 04 14:37:11 CST 2017
Cloning into 'Spigot-Server'...
done.
Resetting Spigot-Server to CraftBukkit...
  • 编译输出 craftbukkit-1.8.jar 和 spigot-1.8.jar 等
1
2
3
4
5
6
7
8
9
Success! Everything compiled successfully. Copying final .jar files now.
Copying craftbukkit-1.8-R0.1-SNAPSHOT-remapped.jar to D:\mc\spigotmc_build\.
- Saved as craftbukkit-1.8.jar
Copying craftbukkit-1.8-R0.1-SNAPSHOT.jar to D:\mc\spigotmc_build\.
- Saved as craftbukkit-1.8.jar
Copying spigot-1.8-R0.1-SNAPSHOT-remapped.jar to D:\mc\spigotmc_build\.
- Saved as spigot-1.8.jar
Copying spigot-1.8-R0.1-SNAPSHOT.jar to D:\mc\spigotmc_build\.
- Saved as spigot-1.8.jar