001    package org.bukkit.entity;
002    
003    /**
004     * Represents a villager NPC
005     */
006    public interface Villager extends Ageable, NPC {
007    
008        /**
009         * Gets the current profession of this villager.
010         *
011         * @return Current profession.
012         */
013        public Profession getProfession();
014    
015        /**
016         * Sets the new profession of this villager.
017         *
018         * @param profession New profession.
019         */
020        public void setProfession(Profession profession);
021    
022    
023        /**
024         * Represents the various different Villager professions there may be.
025         */
026        public enum Profession {
027            FARMER(0),
028            LIBRARIAN(1),
029            PRIEST(2),
030            BLACKSMITH(3),
031            BUTCHER(4);
032    
033            private static final Profession[] professions = new Profession[Profession.values().length];
034            private final int id;
035    
036            static {
037                for (Profession type : values()) {
038                    professions[type.getId()] = type;
039                }
040            }
041    
042            private Profession(int id) {
043                this.id = id;
044            }
045    
046            /**
047             * Gets the ID of this profession.
048             *
049             * @return Profession ID.
050             * @deprecated Magic value
051             */
052            @Deprecated
053            public int getId() {
054                return id;
055            }
056    
057            /**
058             * Gets a profession by its ID.
059             *
060             * @param id ID of the profession to get.
061             * @return Resulting profession, or null if not found.
062             * @deprecated Magic value
063             */
064            @Deprecated
065            public static Profession getProfession(int id) {
066                return (id >= professions.length) ? null : professions[id];
067            }
068        }
069    }