Skip to content

Commit 6215fe2

Browse files
committed
Jar signing
1 parent 7472bf1 commit 6215fe2

File tree

2 files changed

+30
-1
lines changed

2 files changed

+30
-1
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 = 'stable_32'
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: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,6 +27,7 @@
2727
import net.minecraftforge.fml.common.Mod;
2828
import net.minecraftforge.fml.common.Mod.EventHandler;
2929
import net.minecraftforge.fml.common.Mod.Instance;
30+
import net.minecraftforge.fml.common.event.FMLFingerprintViolationEvent;
3031
import net.minecraftforge.fml.common.event.FMLInitializationEvent;
3132
import net.minecraftforge.fml.common.event.FMLPostInitializationEvent;
3233
import net.minecraftforge.fml.common.event.FMLPreInitializationEvent;
@@ -42,7 +43,8 @@
4243
@Mod(modid = Constants.MODID,
4344
name = Constants.NAME,
4445
version = Constants.VERSION,
45-
acceptedMinecraftVersions = "[1.11.2,)")
46+
acceptedMinecraftVersions = "[1.11.2,)",
47+
certificateFingerprint = "@FINGERPRINT@")
4648

4749
public class OreSpawn {
4850
@Instance
@@ -61,6 +63,11 @@ public static Map<Integer, List<SpawnBuilder>> getSpawns() {
6163
return spawns;
6264
}
6365

66+
@EventHandler
67+
public void onFingerprintViolation(FMLFingerprintViolationEvent event) {
68+
logger.warn("Invalid fingerprint detected!");
69+
}
70+
6471
@EventHandler
6572
public void preInit(FMLPreInitializationEvent ev) {
6673
Config.loadConfig();

0 commit comments

Comments
 (0)