From eb4eb2fdad25d609895e0e40ead922feb8a66eb2 Mon Sep 17 00:00:00 2001 From: TechLord22 <37029404+TechLord22@users.noreply.github.com> Date: Thu, 16 Sep 2021 18:43:17 -0400 Subject: [PATCH] Allow CT to add flags to existing materials (#150) --- .../api/unification/material/Material.java | 16 ++++++++++------ 1 file changed, 10 insertions(+), 6 deletions(-) diff --git a/src/main/java/gregtech/api/unification/material/Material.java b/src/main/java/gregtech/api/unification/material/Material.java index cb8948a4c1d..7945a6bdad5 100644 --- a/src/main/java/gregtech/api/unification/material/Material.java +++ b/src/main/java/gregtech/api/unification/material/Material.java @@ -19,10 +19,7 @@ import stanhebben.zenscript.annotations.*; import javax.annotation.Nonnull; -import java.util.ArrayList; -import java.util.Arrays; -import java.util.Collection; -import java.util.List; +import java.util.*; @ZenClass("mods.gregtech.material.Material") @ZenRegister @@ -111,13 +108,20 @@ protected void registerMaterial(Material material) { MaterialRegistry.register(this); } - @ZenMethod - public void addFlag(MaterialFlag... flags) { + public void addFlags(MaterialFlag... flags) { if (MaterialRegistry.isFrozen()) throw new IllegalStateException("Cannot add flag to material when registry is frozen!"); this.flags.addFlags(flags).verify(this); } + @ZenMethod + public void addFlags(String... names) { + addFlags(Arrays.stream(names) + .map(MaterialFlag::getByName) + .filter(Objects::nonNull) + .toArray(MaterialFlag[]::new)); + } + public boolean hasFlag(MaterialFlag flag) { return flags.hasFlag(flag); }