Skip to content

Commit a64f05d

Browse files
committed
Jar signing
1 parent 75ad130 commit a64f05d

File tree

2 files changed

+29
-2
lines changed

2 files changed

+29
-2
lines changed

build.gradle

Lines changed: 22 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,8 @@ minecraft {
7474
mappings = "snapshot_20170925"
7575
// coreMod = ""
7676
makeObfSourceJar = false
77+
78+
replace '@FINGERPRINT@', project.findProperty('signSHA1')
7779
}
7880

7981
repositories {
@@ -179,6 +181,26 @@ task deobfJar(type: Jar) {
179181
from sourceSets.main.output
180182
}
181183

184+
task signJar(type: SignJar, dependsOn: reobfJar) {
185+
186+
// Skips if the keyStore property is missing.
187+
onlyIf {
188+
project.hasProperty('keyStore')
189+
}
190+
191+
// findProperty allows us to reference the property without it existing.
192+
// Using project.propName would cause the script to fail validation if
193+
// the property did not exist.
194+
keyStore = project.findProperty('keyStore')
195+
alias = project.findProperty('keyStoreAlias')
196+
storePass = project.findProperty('keyStorePass')
197+
keyPass = project.findProperty('keyStoreKeyPass')
198+
inputFile = jar.archivePath
199+
outputFile = jar.archivePath
200+
}
201+
202+
build.dependsOn signJar
203+
182204
task javadocJar(type: Jar, dependsOn: javadoc) {
183205
classifier = 'javadoc'
184206
from javadoc.getDestinationDir()

src/main/java/com/mcmoddev/orespawn/OreSpawn.java

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,6 @@
2222
import org.apache.logging.log4j.LogManager;
2323
import org.apache.logging.log4j.Logger;
2424

25-
2625
import net.minecraftforge.common.MinecraftForge;
2726
import net.minecraftforge.fml.common.Mod;
2827
import net.minecraftforge.fml.common.Mod.EventHandler;
@@ -42,7 +41,8 @@
4241
@Mod(modid = Constants.MODID,
4342
name = Constants.NAME,
4443
version = Constants.VERSION,
45-
acceptedMinecraftVersions = "[1.12,)")
44+
acceptedMinecraftVersions = "[1.12,)",
45+
certificateFingerprint = "@FINGERPRINT@")
4646

4747
public class OreSpawn {
4848
@Instance
@@ -61,6 +61,11 @@ public static Map<Integer, List<SpawnBuilder>> getSpawns() {
6161
return spawns;
6262
}
6363

64+
@EventHandler
65+
public void onFingerprintViolation(FMLFingerprintViolationEvent event) {
66+
logger.warn("Invalid fingerprint detected!");
67+
}
68+
6469
@EventHandler
6570
public void preInit(FMLPreInitializationEvent ev) {
6671
Config.loadConfig();

0 commit comments

Comments
 (0)