Skip to content

Commit

Permalink
Further fix versioning
Browse files Browse the repository at this point in the history
Previously, the tags class was not using the correct version formatting which went unnoticed before and likely is why the update checker broke.
  • Loading branch information
Roadhog360 committed Nov 4, 2024
1 parent 687b12e commit 747a932
Show file tree
Hide file tree
Showing 4 changed files with 37 additions and 8 deletions.
16 changes: 12 additions & 4 deletions build.gradle
Original file line number Diff line number Diff line change
Expand Up @@ -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.
Expand All @@ -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)
}
5 changes: 5 additions & 0 deletions gradle.properties
Original file line number Diff line number Diff line change
@@ -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
Expand Down
8 changes: 5 additions & 3 deletions src/main/java/ganymedes01/etfuturum/EtFuturum.java
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand Down Expand Up @@ -141,7 +142,7 @@ public void displayAllReleventItems(List<ItemStack> 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<ItemStack>) list) {
for (ItemStack stack : list) {
if (Item.getIdFromItem(stack.getItem()) > Block.getIdFromBlock(((ItemWoodSign) sign.get()).getSignBlock())) {
list.add(list.indexOf(stack), sign.newItemStack());
break;
Expand All @@ -153,6 +154,8 @@ public void displayAllReleventItems(List<ItemStack> 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();
Expand Down Expand Up @@ -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();
Expand Down
16 changes: 15 additions & 1 deletion src/main/java/ganymedes01/etfuturum/lib/Reference.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,6 @@
package ganymedes01.etfuturum.lib;

import ganymedes01.etfuturum.EtFuturum;
import ganymedes01.etfuturum.Tags;
import net.minecraft.launchwrapper.Launch;

Expand All @@ -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"));
}
}

0 comments on commit 747a932

Please sign in to comment.