Fix Bukkit's mistake with villager professions

This commit is contained in:
libraryaddict 2017-12-04 02:24:19 +13:00
parent bdad4c3f1d
commit 7e18b96186

View File

@ -1,10 +1,9 @@
package me.libraryaddict.disguise.disguisetypes.watchers; package me.libraryaddict.disguise.disguisetypes.watchers;
import org.bukkit.entity.Villager.Profession;
import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.MetaIndex; import me.libraryaddict.disguise.disguisetypes.MetaIndex;
import me.libraryaddict.disguise.utilities.DisguiseUtilities; import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import org.bukkit.entity.Villager.Profession;
public class VillagerWatcher extends AgeableWatcher { public class VillagerWatcher extends AgeableWatcher {
@ -19,7 +18,7 @@ public class VillagerWatcher extends AgeableWatcher {
@Deprecated @Deprecated
public void setProfession(int professionId) { public void setProfession(int professionId) {
setData(MetaIndex.VILLAGER_PROFESSION, professionId); setData(MetaIndex.VILLAGER_PROFESSION, Math.max(1, Math.min(professionId, Profession.BUTCHER.ordinal()) - 1));
sendData(MetaIndex.VILLAGER_PROFESSION); sendData(MetaIndex.VILLAGER_PROFESSION);
} }