Skip to content

Commit

Permalink
Add warning for deprecated tame_mob()
Browse files Browse the repository at this point in the history
  • Loading branch information
PseudoKnight committed Aug 5, 2018
1 parent ff30bd0 commit 6c566d7
Showing 1 changed file with 20 additions and 1 deletion.
21 changes: 20 additions & 1 deletion src/main/java/com/laytonsmith/core/functions/MobManagement.java
Original file line number Diff line number Diff line change
Expand Up @@ -26,9 +26,13 @@
import com.laytonsmith.abstraction.enums.MCZombieType;
import com.laytonsmith.annotations.api;
import com.laytonsmith.annotations.hide;
import com.laytonsmith.core.CHLog;
import com.laytonsmith.core.CHVersion;
import com.laytonsmith.core.ObjectGenerator;
import com.laytonsmith.core.Optimizable;
import com.laytonsmith.core.ParseTree;
import com.laytonsmith.core.Static;
import com.laytonsmith.core.compiler.FileOptions;
import com.laytonsmith.core.constructs.CArray;
import com.laytonsmith.core.constructs.CBoolean;
import com.laytonsmith.core.constructs.CDouble;
Expand Down Expand Up @@ -57,8 +61,11 @@
import com.laytonsmith.core.exceptions.ConfigCompileException;
import com.laytonsmith.core.exceptions.ConfigRuntimeException;

import java.util.EnumSet;
import java.util.HashSet;
import java.util.List;
import java.util.Map;
import java.util.Set;

public class MobManagement {

Expand Down Expand Up @@ -172,7 +179,7 @@ public Construct exec(Target t, Environment env, Construct... args) throws Cance

@api(environments = {CommandHelperEnvironment.class})
@hide("Deprecated")
public static class tame_mob extends AbstractFunction {
public static class tame_mob extends AbstractFunction implements Optimizable {

@Override
public String getName() {
Expand Down Expand Up @@ -246,6 +253,18 @@ public Construct exec(Target t, Environment environment, Construct... args) thro
throw new CREUntameableMobException("The specified entity is not tameable", t);
}
}

@Override
public ParseTree optimizeDynamic(Target t, List<ParseTree> children, FileOptions fileOptions)
throws ConfigCompileException, ConfigRuntimeException {
CHLog.GetLogger().w(CHLog.Tags.DEPRECATION, "The function tame_mob() is deprecated for set_mob_owner().", t);
return null;
}

@Override
public Set<OptimizationOption> optimizationOptions() {
return EnumSet.of(OptimizationOption.OPTIMIZE_DYNAMIC);
}
}

@api
Expand Down

0 comments on commit 6c566d7

Please sign in to comment.