Skip to content

Commit

Permalink
Add #c:shields tag to default disabled items
Browse files Browse the repository at this point in the history
More compatibility with mods adding new shields (if they add shields to this tag)
  • Loading branch information
MightyKnight committed Dec 9, 2022
1 parent 38e97dd commit 5ab0568
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 4 deletions.
6 changes: 3 additions & 3 deletions build.gradle
Original file line number Diff line number Diff line change
@@ -1,15 +1,15 @@
plugins {
id 'java'
id 'fabric-loom' version '0.12-SNAPSHOT'
id 'fabric-loom' version '1.0-SNAPSHOT'
}

repositories {
maven { url "https://maven.shedaniel.me/" }
maven { url "https://maven.terraformersmc.com/releases/"}
}

sourceCompatibility = JavaVersion.VERSION_1_8
targetCompatibility = JavaVersion.VERSION_1_8
sourceCompatibility = JavaVersion.VERSION_16
targetCompatibility = JavaVersion.VERSION_16

group = project.maven_group
version = "${project.mod_version}+${project.minecraft_version}"
Expand Down
25 changes: 24 additions & 1 deletion src/main/java/net/heyzeer0/sd/configs/GeneralConfig.java
Original file line number Diff line number Diff line change
@@ -1,21 +1,27 @@
package net.heyzeer0.sd.configs;

import me.shedaniel.autoconfig.ConfigData;
import me.shedaniel.autoconfig.annotation.ConfigEntry;
import me.shedaniel.autoconfig.annotation.Config;
import net.minecraft.item.Items;
import net.minecraft.registry.Registries;

import java.util.Arrays;
import java.util.List;
import java.util.function.Predicate;

@Config(name = "shieldisruptor_general")
public class GeneralConfig implements ConfigData {

@ConfigEntry.Gui.Excluded
String modVersion = "";

public boolean isEnabled = true;

public List<String> hiddenItems = Arrays.asList(
Registries.ITEM.getId(Items.SHIELD).toString(),
Registries.ITEM.getId(Items.TOTEM_OF_UNDYING).toString());
Registries.ITEM.getId(Items.TOTEM_OF_UNDYING).toString(),
"#c:shields");

// Ignore case and leading/trailing whitespaces when checking if entry is in config
public boolean contains(String s) {
Expand All @@ -27,4 +33,21 @@ public boolean contains(String s) {
return false;
}

@Override
public void validatePostLoad() throws ValidationException {

// Upgrade from <=1.4.0, adding new tag "#c:shields"
if(modVersion == "") {
if(!hiddenItems.contains("#c:shields")) {
hiddenItems.add("#c:shields");
}
modVersion = "1.5.0";
}

// Remove empty list items and trim strings
hiddenItems.removeIf(String::isBlank);
hiddenItems.replaceAll(String::trim);

ConfigData.super.validatePostLoad();
}
}

0 comments on commit 5ab0568

Please sign in to comment.