Skip to content

Commit

Permalink
fix villager changes profession determine
Browse files Browse the repository at this point in the history
  • Loading branch information
mcmonkey4eva committed Jan 11, 2021
1 parent 3c1d221 commit a556822
Showing 1 changed file with 7 additions and 9 deletions.
Expand Up @@ -2,7 +2,6 @@

import com.denizenscript.denizen.events.BukkitScriptEvent;
import com.denizenscript.denizen.objects.EntityTag;
import com.denizenscript.denizen.utilities.debugging.Debug;
import com.denizenscript.denizencore.objects.ObjectTag;
import com.denizenscript.denizencore.objects.core.ElementTag;
import org.bukkit.entity.Villager;
Expand Down Expand Up @@ -64,14 +63,13 @@ public String getName() {

@Override
public boolean applyDetermination(ScriptPath path, ObjectTag determinationObj) {
String determination = determinationObj.toString();
try {
Villager.Profession newProfession = Villager.Profession.valueOf(determination.toUpperCase());
event.setProfession(newProfession);
return true;
}
catch (IllegalArgumentException e) {
Debug.echoError("Invalid profession specified: " + determination);
if (!isDefaultDetermination(determinationObj)) {
String determination = determinationObj.toString();
if (exactMatchesEnum(determination, Villager.Profession.values())) {
Villager.Profession newProfession = Villager.Profession.valueOf(determination.toUpperCase());
event.setProfession(newProfession);
return true;
}
}
return super.applyDetermination(path, determinationObj);
}
Expand Down

0 comments on commit a556822

Please sign in to comment.