summaryrefslogtreecommitdiffstats
path: root/src/main/java/org/bukkit/entity/Villager.java
blob: 1120330bc2a62572083773f1d1a33ed50479e343 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
package org.bukkit.entity;

import java.util.List;
import org.bukkit.inventory.Inventory;
import org.bukkit.inventory.InventoryHolder;
import org.bukkit.inventory.MerchantRecipe;

/**
 * Represents a villager NPC
 */
public interface Villager extends Ageable, NPC, InventoryHolder {

    /**
     * Gets the current profession of this villager.
     *
     * @return Current profession.
     */
    public Profession getProfession();

    /**
     * Sets the new profession of this villager.
     *
     * @param profession New profession.
     */
    public void setProfession(Profession profession);

    /**
     * Get a list of trades currently available from this villager.
     *
     * @return an immutable list of trades
     */
    List<MerchantRecipe> getRecipes();

    /**
     * Set the list of trades currently available from this villager.
     * <br>
     * This will not change the selected trades of players currently trading
     * with this villager.
     *
     * @param recipes a list of recipes
     */
    void setRecipes(List<MerchantRecipe> recipes);

    /**
     * Get the recipe at a certain index of this villager's trade list.
     *
     * @param i the index
     * @return the recipe
     * @throws IndexOutOfBoundsException
     */
    MerchantRecipe getRecipe(int i) throws IndexOutOfBoundsException;

    /**
     * Set the recipe at a certain index of this villager's trade list.
     *
     * @param i the index
     * @param recipe the recipe
     * @throws IndexOutOfBoundsException
     */
    void setRecipe(int i, MerchantRecipe recipe) throws IndexOutOfBoundsException;

    /**
     * Get the number of trades this villager currently has available.
     *
     * @return the recipe count
     */
    int getRecipeCount();

    /**
     * Gets this villager's inventory.
     * <br>
     * Note that this inventory is not the Merchant inventory, rather, it is the
     * items that a villager might have collected (from harvesting crops, etc.)
     *
     * {@inheritDoc}
     */
    @Override
    Inventory getInventory();

    /**
     * Gets whether this villager is currently trading.
     *
     * @return whether the villager is trading
     */
    boolean isTrading();

    /**
     * Gets the player this villager is trading with, or null if it is not
     * currently trading.
     *
     * @return the trader, or null
     */
    HumanEntity getTrader();

    /**
     * Gets this villager's riches, the number of emeralds this villager has
     * been given.
     *
     * @return the villager's riches
     */
    int getRiches();

    /**
     * Sets this villager's riches.
     *
     * @see Villager#getRiches()
     *
     * @param riches the new riches
     */
    void setRiches(int riches);

    /**
     * Represents the various different Villager professions there may be.
     * Villagers have different trading options depending on their profession,
     */
    public enum Profession {
        /**
         * Normal. <b>Reserved for Zombies.</b>
         */
        NORMAL(true),
        /**
         * Farmer profession. Wears a brown robe.
         */
        FARMER(false),
        /**
         * Librarian profession. Wears a white robe.
         */
        LIBRARIAN(false),
        /**
         * Priest profession. Wears a purple robe.
         */
        PRIEST(false),
        /**
         * Blacksmith profession. Wears a black apron.
         */
        BLACKSMITH(false),
        /**
         * Butcher profession. Wears a white apron.
         */
        BUTCHER(false),
        /**
         * Husk. <b>Reserved for Zombies</b>
         */
        HUSK(true);
        private final boolean zombie;

        private Profession(boolean zombie) {
            this.zombie = zombie;
        }

        /**
         * Returns if this profession can only be used by zombies.
         *
         * @return zombie profession status
         */
        public boolean isZombie() {
            return zombie;
        }
    }
}