org.bukkit.entity.Villager.Profession Java Examples
The following examples show how to use
org.bukkit.entity.Villager.Profession.
You can vote up the ones you like or vote down the ones you don't like,
and go to the original project or source file by following the links above each example. You may check out the related API usage on the sidebar.
Example #1
Source File: VillagerShop.java From Shopkeepers with GNU General Public License v3.0 | 6 votes |
@Override protected void load(ConfigurationSection config) { super.load(config); // load profession: String professionInput; if (config.isInt("prof")) { // import from pre 1.10 profession ids: int profId = config.getInt("prof"); professionInput = String.valueOf(profId); this.profession = getProfessionFromOldId(profId); } else { professionInput = config.getString("prof"); this.profession = getProfession(professionInput); } // validate: if (!isVillagerProfession(profession)) { // fallback: Log.warning("Missing or invalid villager profession '" + professionInput + "'. Using '" + Profession.FARMER + "' now."); this.profession = Profession.FARMER; } }
Example #2
Source File: VillagerShop.java From Shopkeepers with GNU General Public License v3.0 | 6 votes |
private Profession getNextVillagerProfession() { Profession[] professions = Profession.values(); int id = profession.ordinal(); while (true) { id += 1; if (id >= professions.length) { id = 0; } Profession nextProfession = professions[id]; if (isVillagerProfession(nextProfession)) { return nextProfession; } else { continue; } } }
Example #3
Source File: VillagerShop.java From Shopkeepers with GNU General Public License v3.0 | 6 votes |
private static Profession getProfessionFromOldId(int oldProfessionId) { switch (oldProfessionId) { case 0: return Profession.FARMER; case 1: return Profession.LIBRARIAN; case 2: return Profession.PRIEST; case 3: return Profession.BLACKSMITH; case 4: return Profession.BUTCHER; default: return null; } }
Example #4
Source File: VillagerData.java From Skript with GNU General Public License v3.0 | 5 votes |
@Override protected boolean deserialize(final String s) { if (s.isEmpty()) return true; try { profession = Profession.valueOf(s); return true; } catch (final IllegalArgumentException e) { return false; } }
Example #5
Source File: VillagerShop.java From Shopkeepers with GNU General Public License v3.0 | 5 votes |
private static Profession getProfession(String professionName) { if (professionName != null) { try { return Profession.valueOf(professionName); } catch (IllegalArgumentException e) { } } return null; }
Example #6
Source File: VillagerShop.java From Shopkeepers with GNU General Public License v3.0 | 5 votes |
private static boolean isVillagerProfession(Profession profession) { if (profession == null) return false; if (profession.ordinal() >= Profession.FARMER.ordinal() && profession.ordinal() <= Profession.BUTCHER.ordinal()) { return true; } // TODO: update this once we only support MC 1.11 upwards if (profession.name().equals("NITWIT")) { return true; } return false; }
Example #7
Source File: ZombieVillagerData.java From Skript with GNU General Public License v3.0 | 4 votes |
public ZombieVillagerData(Profession prof) { profession = prof; }
Example #8
Source File: VillagerPet.java From SonarPet with GNU General Public License v3.0 | 4 votes |
@Override public Profession getProfession() { return profession; }
Example #9
Source File: VillagerPet.java From SonarPet with GNU General Public License v3.0 | 4 votes |
@Override public void setProfession(Profession prof) { ((IEntityVillagerPet) getEntityPet()).setProfession(prof); this.profession = prof; }
Example #10
Source File: VillagerPet.java From EchoPet with GNU General Public License v3.0 | 4 votes |
@Override public Profession getProfession() { return profession; }
Example #11
Source File: VillagerPet.java From EchoPet with GNU General Public License v3.0 | 4 votes |
@Override public void setProfession(Profession prof) { ((IEntityVillagerPet) getEntityPet()).setProfession(prof.getId()); this.profession = prof; }