Permalink
Browse files

Add compile time warning when using an invalid Effect in make_effect()

  • Loading branch information...
PseudoKnight committed Aug 14, 2018
1 parent e450ce6 commit f8bf56c07fece8e4781045db9ae2f5a9a16ed73b
Showing with 25 additions and 1 deletion.
  1. +25 −1 src/main/java/com/laytonsmith/core/functions/Minecraft.java
@@ -391,7 +391,7 @@ public ParseTree optimizeDynamic(Target t, List<ParseTree> children, FileOptions
}
@api(environments = {CommandHelperEnvironment.class})
public static class make_effect extends AbstractFunction {
public static class make_effect extends AbstractFunction implements Optimizable {
@Override
public String getName() {
@@ -467,6 +467,30 @@ public Construct exec(Target t, Environment env, Construct... args) throws Confi
l.getWorld().playEffect(l, e, data, radius);
return CVoid.VOID;
}
@Override
public ParseTree optimizeDynamic(Target t, List<ParseTree> children, FileOptions fileOptions)
throws ConfigCompileException, ConfigRuntimeException {
if(children.size() < 2) {
return null;
}
Construct effect = children.get(1).getData();
if(effect instanceof CString) {
String effectName = effect.val().split(":")[0].toUpperCase();
try {
MCEffect.valueOf(effectName);
} catch (IllegalArgumentException ex) {
CHLog.GetLogger().w(CHLog.Tags.DEPRECATION, "The effect type " + effectName + " is not valid", t);
}
}
return null;
}
@Override
public Set<OptimizationOption> optimizationOptions() {
return EnumSet.of(OptimizationOption.OPTIMIZE_DYNAMIC);
}
}
@api(environments = {CommandHelperEnvironment.class})

0 comments on commit f8bf56c

Please sign in to comment.