geforkt von Mirrors/Paper
SPIGOT-4820: Villager Type API
Dieser Commit ist enthalten in:
Ursprung
3dcbf6b85b
Commit
deeecc7f08
@ -3,9 +3,9 @@ package org.bukkit.craftbukkit.entity;
|
|||||||
import java.util.Locale;
|
import java.util.Locale;
|
||||||
import net.minecraft.server.EntityVillager;
|
import net.minecraft.server.EntityVillager;
|
||||||
import net.minecraft.server.IRegistry;
|
import net.minecraft.server.IRegistry;
|
||||||
import net.minecraft.server.MinecraftKey;
|
|
||||||
import org.apache.commons.lang.Validate;
|
import org.apache.commons.lang.Validate;
|
||||||
import org.bukkit.craftbukkit.CraftServer;
|
import org.bukkit.craftbukkit.CraftServer;
|
||||||
|
import org.bukkit.craftbukkit.util.CraftNamespacedKey;
|
||||||
import org.bukkit.entity.EntityType;
|
import org.bukkit.entity.EntityType;
|
||||||
import org.bukkit.entity.Villager;
|
import org.bukkit.entity.Villager;
|
||||||
|
|
||||||
@ -38,6 +38,17 @@ public class CraftVillager extends CraftAbstractVillager implements Villager {
|
|||||||
@Override
|
@Override
|
||||||
public void setProfession(Profession profession) {
|
public void setProfession(Profession profession) {
|
||||||
Validate.notNull(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()))));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Laden…
In neuem Issue referenzieren
Einen Benutzer sperren