use of org.bukkit.entity.Villager.Profession in project Citizens2 by CitizensDev.
the class NPCCommands method profession.
@Command(aliases = { "npc" }, usage = "profession|prof [profession]", desc = "Set a NPC's profession", modifiers = { "profession", "prof" }, min = 2, max = 2, permission = "citizens.npc.profession")
@Requirements(selected = true, ownership = true, types = { EntityType.VILLAGER })
public void profession(CommandContext args, CommandSender sender, NPC npc) throws CommandException {
String profession = args.getString(1);
Profession parsed = Util.matchEnum(Profession.values(), profession.toUpperCase());
if (parsed == null) {
throw new CommandException(Messages.INVALID_PROFESSION, args.getString(1), StringUtils.join(Profession.values(), ","));
}
npc.getTrait(VillagerProfession.class).setProfession(parsed);
Messaging.sendTr(sender, Messages.PROFESSION_SET, npc.getName(), profession);
}
use of org.bukkit.entity.Villager.Profession in project MagicPlugin by elBukkit.
the class AlterSpell method alterEntity.
protected SpellResult alterEntity(Entity entity) {
EntityType entityType = entity.getType();
switch(entityType) {
case PAINTING:
registerModified(entity);
Painting painting = (Painting) entity;
Art[] artValues = Art.values();
Art oldArt = painting.getArt();
Art newArt = oldArt;
int ordinal = (oldArt.ordinal() + 1);
for (int i = 0; i < artValues.length; i++) {
newArt = artValues[ordinal++ % artValues.length];
painting.setArt(newArt);
newArt = painting.getArt();
if (oldArt != newArt) {
break;
}
}
if (oldArt == newArt) {
return SpellResult.FAIL;
}
mage.sendDebugMessage("Altering art from " + oldArt + " to " + newArt);
break;
case ITEM_FRAME:
ItemFrame itemFrame = (ItemFrame) entity;
ItemStack frameItem = itemFrame.getItem();
if (frameItem == null || frameItem.getType() != Material.MAP) {
return SpellResult.NO_TARGET;
}
short data = frameItem.getDurability();
data++;
MapView mapView = DeprecatedUtils.getMap(data);
if (mapView == null) {
data = 0;
mapView = DeprecatedUtils.getMap(data);
if (mapView == null) {
return SpellResult.NO_TARGET;
}
}
registerModified(entity);
frameItem.setDurability(data);
itemFrame.setItem(frameItem);
break;
case HORSE:
registerModified(entity);
Horse horse = (Horse) entity;
Color color = horse.getColor();
Color[] colorValues = Color.values();
color = colorValues[(color.ordinal() + 1) % colorValues.length];
Style horseStyle = horse.getStyle();
Style[] styleValues = Style.values();
horseStyle = styleValues[(horseStyle.ordinal() + 1) % styleValues.length];
horse.setStyle(horseStyle);
horse.setColor(color);
break;
case OCELOT:
registerModified(entity);
Ocelot ocelot = (Ocelot) entity;
Type catType = ocelot.getCatType();
Type[] typeValues = Type.values();
catType = typeValues[(catType.ordinal() + 1) % typeValues.length];
ocelot.setCatType(catType);
break;
case VILLAGER:
registerModified(entity);
Villager villager = (Villager) entity;
Profession profession = villager.getProfession();
Profession[] professionValues = Profession.values();
profession = professionValues[(profession.ordinal() + 1) % professionValues.length];
villager.setProfession(profession);
break;
case WOLF:
registerModified(entity);
Wolf wolf = (Wolf) entity;
DyeColor wolfColor = wolf.getCollarColor();
DyeColor[] wolfColorValues = DyeColor.values();
wolfColor = wolfColorValues[(wolfColor.ordinal() + 1) % wolfColorValues.length];
wolf.setCollarColor(wolfColor);
break;
case SHEEP:
registerModified(entity);
Sheep sheep = (Sheep) entity;
DyeColor dyeColor = sheep.getColor();
DyeColor[] dyeColorValues = DyeColor.values();
dyeColor = dyeColorValues[(dyeColor.ordinal() + 1) % dyeColorValues.length];
sheep.setColor(dyeColor);
break;
case SKELETON:
registerModified(entity);
Skeleton skeleton = (Skeleton) entity;
SkeletonType skeletonType = skeleton.getSkeletonType();
SkeletonType[] skeletonTypeValues = SkeletonType.values();
skeletonType = skeletonTypeValues[(skeletonType.ordinal() + 1) % skeletonTypeValues.length];
skeleton.setSkeletonType(skeletonType);
break;
default:
return SpellResult.NO_TARGET;
}
;
registerForUndo();
return SpellResult.CAST;
}
Aggregations