SPIGOT-4820: Villager Type API

Dieser Commit ist enthalten in:
md_5 2019-05-01 18:39:43 +10:00
Ursprung 3dcbf6b85b
Commit deeecc7f08

Datei anzeigen

@ -3,9 +3,9 @@ package org.bukkit.craftbukkit.entity;
import java.util.Locale;
import net.minecraft.server.EntityVillager;
import net.minecraft.server.IRegistry;
import net.minecraft.server.MinecraftKey;
import org.apache.commons.lang.Validate;
import org.bukkit.craftbukkit.CraftServer;
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
import org.bukkit.entity.EntityType;
import org.bukkit.entity.Villager;
@ -38,6 +38,17 @@ public class CraftVillager extends CraftAbstractVillager implements Villager {
@Override
public void setProfession(Profession profession) {
Validate.notNull(profession);
getHandle().setVillagerData(getHandle().getVillagerData().withProfession(IRegistry.VILLAGER_PROFESSION.get(new MinecraftKey(profession.name().toLowerCase(Locale.ROOT)))));
getHandle().setVillagerData(getHandle().getVillagerData().withProfession(IRegistry.VILLAGER_PROFESSION.get(CraftNamespacedKey.toMinecraft(profession.getKey()))));
}
@Override
public Type getVillagerType() {
return Type.valueOf(IRegistry.VILLAGER_TYPE.getKey(getHandle().getVillagerData().getType()).getKey().toUpperCase(Locale.ROOT));
}
@Override
public void setVillagerType(Type type) {
Validate.notNull(type);
getHandle().setVillagerData(getHandle().getVillagerData().withType(IRegistry.VILLAGER_TYPE.get(CraftNamespacedKey.toMinecraft(type.getKey()))));
}
}