diff --git a/build.gradle b/build.gradle index 42e67fb1..b6313d13 100644 --- a/build.gradle +++ b/build.gradle @@ -2,11 +2,11 @@ plugins { id 'com.gtnewhorizons.gtnhconvention' + id 'com.palantir.git-version' } // The planned name of the next release -def NEXT_VERSION = "2.6.2" -version = NEXT_VERSION +def NEXT_VERSION = ext.modVersion // Append to the version as needed. If the variables look a bit strange, that's because they are - // git-version doesn't expose a ton of useful functions, we need to extract them indirectly. @@ -17,11 +17,19 @@ def details = versionDetails() def isPlainTag = details.getCommitDistance() == 0 def noCommitHash = providers.gradleProperty("noCommitHash").isPresent() if (!isPlainTag && !noCommitHash) { - version += "-nightly-" + details.gitHash + NEXT_VERSION += "-nightly-" + details.gitHash } // If we have uncommitted changes, say so. def isDirty = gitVersion().endsWith(".dirty") if (isDirty && !noCommitHash) { - version += "-dirty" + NEXT_VERSION += "-dirty" +} + +//Set the mod and jar version to the info we just collected. +version = NEXT_VERSION + +minecraft { + //Creates a tag in Tags with the above generated mod version, instead of the "clean" one + injectedTags.put("RAW_VERSION", NEXT_VERSION) } diff --git a/gradle.properties b/gradle.properties index bdae28e6..0779a06d 100644 --- a/gradle.properties +++ b/gradle.properties @@ -1,3 +1,8 @@ +#We don't (entirely) use git versioning so we override it here to make some tweaks to the way version numbers are defined. +gtnh.modules.gitVersion = false +#Planned name for next release +modVersion = 2.6.2 + # ExampleMod tag to use as Blowdryer (Spotless, etc.) settings version, leave empty to disable. # LOCAL to test local config updates. gtnh.settings.blowdryerTag = 0.2.2 diff --git a/src/main/java/ganymedes01/etfuturum/EtFuturum.java b/src/main/java/ganymedes01/etfuturum/EtFuturum.java index 4969bdf1..11c81d33 100644 --- a/src/main/java/ganymedes01/etfuturum/EtFuturum.java +++ b/src/main/java/ganymedes01/etfuturum/EtFuturum.java @@ -28,6 +28,7 @@ import ganymedes01.etfuturum.core.handlers.WorldEventHandler; import ganymedes01.etfuturum.core.proxy.CommonProxy; import ganymedes01.etfuturum.core.utils.IInitAction; +import ganymedes01.etfuturum.core.utils.Logger; import ganymedes01.etfuturum.entities.ModEntityList; import ganymedes01.etfuturum.items.ItemWoodSign; import ganymedes01.etfuturum.lib.Reference; @@ -141,7 +142,7 @@ public void displayAllReleventItems(List list) { //Add the sign items back but in a way so they are sorted by their block ID instead of their item ID. //This allows them to be in the correct place instead of always at the bottom of the block ID list, since item IDs are always above block IDs for (ModItems sign : ModItems.OLD_SIGN_ITEMS) { - for (ItemStack stack : (List) list) { + for (ItemStack stack : list) { if (Item.getIdFromItem(stack.getItem()) > Block.getIdFromBlock(((ItemWoodSign) sign.get()).getSignBlock())) { list.add(list.indexOf(stack), sign.newItemStack()); break; @@ -153,6 +154,8 @@ public void displayAllReleventItems(List list) { @EventHandler public void onConstruction(FMLConstructionEvent event) { + Logger.info(Reference.MOD_ID + " is in snapshot mode. Disabling update checker... Other features may also be different."); + MCLib.init(); ADConfig config = new ADConfig(); @@ -228,9 +231,8 @@ public void preInit(FMLPreInitializationEvent event) { networkWrapper.registerMessage(StartElytraFlyingHandler.class, StartElytraFlyingMessage.class, 6, Side.SERVER); networkWrapper.registerMessage(AttackYawHandler.class, AttackYawMessage.class, 7, Side.CLIENT); - String buildVer = event.getModMetadata().version; if (!Reference.SNAPSHOT_BUILD && !Reference.DEV_ENVIRONMENT) { - MCLibModules.updateCheckAPI.submitModTask(Reference.MOD_ID, Reference.VERSION_URL); + MCLibModules.updateCheckAPI.submitModTask(Reference.MOD_ID, Reference.VERSION_NUMBER, Reference.VERSION_URL); } CompatMisc.runModHooksPreInit(); diff --git a/src/main/java/ganymedes01/etfuturum/lib/Reference.java b/src/main/java/ganymedes01/etfuturum/lib/Reference.java index 5c1a15e7..df2c1653 100644 --- a/src/main/java/ganymedes01/etfuturum/lib/Reference.java +++ b/src/main/java/ganymedes01/etfuturum/lib/Reference.java @@ -1,5 +1,6 @@ package ganymedes01.etfuturum.lib; +import ganymedes01.etfuturum.EtFuturum; import ganymedes01.etfuturum.Tags; import net.minecraft.launchwrapper.Launch; @@ -23,5 +24,18 @@ public class Reference { public static final String ENTITY_TEXTURE_PATH = ITEM_BLOCK_TEXTURE_PATH + "textures/entities/"; public static boolean launchConfigWarning; - public static boolean SNAPSHOT_BUILD = Tags.VERSION.toLowerCase().contains("snapshot") || Tags.VERSION.toLowerCase().contains("nightly") || Tags.VERSION.toLowerCase().contains("alpha") || Tags.VERSION.toLowerCase().contains("beta") || Tags.VERSION.toLowerCase().contains("rc"); + public static final boolean SNAPSHOT_BUILD = isSnapshotBuild(Tags.RAW_VERSION); + + /** + * TODO move to HogUtils once that exists + */ + private static boolean isSnapshotBuild(String version) { + version = version.toLowerCase(); + return version.contains("snapshot") + || version.contains("nightly") + || version.contains("alpha") + || version.contains("beta") + || version.contains("rc") + || (version.contains("release") && version.contains("candidate")); + } }