Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
4555051
commit 7a88706
Showing
2 changed files
with
40 additions
and
4 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
36 changes: 36 additions & 0 deletions
36
src/main/java/org/auioc/mcmod/arnicalib/utils/game/ConfigUtils.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
package org.auioc.mcmod.arnicalib.utils.game; | ||
|
||
import java.util.List; | ||
import java.util.function.Consumer; | ||
import net.minecraftforge.common.ForgeConfigSpec.Builder; | ||
|
||
public interface ConfigUtils { | ||
|
||
static void pushWithoutPop(Builder specBuilder, String path, Consumer<Builder> subBuilder) { | ||
specBuilder.push(path); | ||
subBuilder.accept(specBuilder); | ||
} | ||
|
||
static void push(Builder specBuilder, String path, Consumer<Builder> subBuilder) { | ||
specBuilder.push(path); | ||
subBuilder.accept(specBuilder); | ||
specBuilder.pop(); | ||
} | ||
|
||
|
||
static boolean validateListSize(Object obj, int size) { | ||
if (!(obj instanceof List)) return false; | ||
return (((List<?>) obj).size() == size) ? true : false; | ||
} | ||
|
||
static boolean validateListElements(Object obj, Class<?> clazz) { | ||
if (!(obj instanceof List)) return false; | ||
|
||
for (Object e : (List<?>) obj) { | ||
if (e.getClass() != clazz) return false; | ||
} | ||
|
||
return true; | ||
} | ||
|
||
} |