You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: CONTRIBUTING.md
+8-1Lines changed: 8 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -15,7 +15,14 @@ Pull requests are the best way to propose changes to the codebase (we use [Githu
15
15
16
16
1. Fork the repo and create your branch from `master`. You don't need to run BuildTools or any other setup, everything is setup using Gradle tasks.
17
17
2. Make your changes.
18
-
3. Make sure to build and test the plugin extensively. You can run the `runServer` Gradle Task, which builds the plugin and starts a local test server for you.
18
+
3. Make sure to build and test the plugin extensively. You can run the `runServer` Gradle Task, which builds the plugin and starts a local test server for you. Be sure to use the local resource pack hosting server. See [below](#how-we-handle-the-custom-resource-pack) for more information
19
19
4. We use [ktlint](https://github.com/pinterest/ktlint) to enforce the kotlin code styleguides. Please run the `ktlintFormat` Gradle task to check your code.
20
20
5. Please use [Conventional Commit Messages](https://www.conventionalcommits.org/en/v1.0.0/) for your Commits.
21
21
6. Issue your pull request!
22
+
23
+
## How we handle the custom Resource Pack
24
+
MPP uses a custom Resource Pack that needed for the custom blocks and items. You can generate this pack by running the `buildResourcePack` Gradle Task.
25
+
26
+
The plugin first checks for a Resource Pack with the correct version locally and then on Github Releases. If no pack is found an error is logged. The plugin version is calculated from the commit amount on the current branch.
27
+
28
+
If you are in a development or testing environment you should run the local Resource Pack hosting server with the `runResourcePackServer` Gradle Task. This is to make sure that the plugin always finds and uses the matching Resource Pack.
val localPackExists = doesPackExist(URL(localPackLink))
53
+
val githubPackExists = doesPackExist(URL(githubPackLink))
54
+
55
+
resourcePackLink =when {
56
+
localPackExists -> {
57
+
logInfo("Using local hosted mpp resource pack.")
58
+
localPackLink
59
+
}
60
+
61
+
githubPackExists -> {
62
+
logInfo("Using remote hosted mpp resource pack.")
63
+
githubPackLink
64
+
}
37
65
38
-
packEnabled = doesPackExist(URL(githubPackLink))
39
-
if (!packEnabled) {
40
-
logError("The MPP Resource Pack was not found on Github! Please make sure to download the latest official Release from https://github.com/dm432/MPP/releases")
66
+
else-> {
67
+
logError(
68
+
"No mpp resource pack found! Make sure that you are using the latest plugin version. "+
69
+
"If you're running the plugin in a development environment make sure that the local "+
70
+
"ResourcePackHostingServer is running."
71
+
)
72
+
null
73
+
}
41
74
}
75
+
76
+
// Download pack
77
+
val request =Request.Builder()
78
+
.url(resourcePackLink ?:"")
79
+
.build()
80
+
81
+
val packFile =File(inst().dataFolder, "$pluginVersion.zip")
82
+
try {
83
+
val response = httpClient.newCall(request).execute()
84
+
if (response.isSuccessful && response.body !=null) {
85
+
response.body!!.byteStream().use { input ->
86
+
packFile.outputStream().use { output ->
87
+
input.copyTo(output)
88
+
}
89
+
}
90
+
} else {
91
+
logError("Error while downloading mpp resource pack to calculate the hash! Please restart the server to try again.")
92
+
}
93
+
} catch (e:Exception) {
94
+
logError("Error while downloading mpp resource pack to calculate the hash! Please restart the server to try again.")
95
+
}
96
+
97
+
packHash = calculateSHA1Hash(packFile)
98
+
if (packHash !=null) {
99
+
logInfo("Resource pack hash is $packHash")
100
+
}
101
+
102
+
packFile.delete()
42
103
}
43
104
44
-
// Checks if the resource pack exits at the given link
105
+
// Checks if the resource pack exists at the given link
45
106
privatefundoesPackExist(url:URL): Boolean {
46
-
val connection = url.openConnection() asHttpURLConnection
0 commit comments