mirror of
https://github.com/libraryaddict/LibsDisguises.git
synced 2024-09-11 01:38:07 +02:00
Fix villager professions once and for all
This commit is contained in:
parent
3f27bcf999
commit
5b86025fa0
@ -1,13 +0,0 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by libraryaddict on 23/12/2017.
|
|
||||||
*/
|
|
||||||
public enum VillagerProfession {
|
|
||||||
FARMER,
|
|
||||||
LIBRARIAN,
|
|
||||||
PRIEST,
|
|
||||||
BLACKSMITH,
|
|
||||||
BUTCHER,
|
|
||||||
NITWIT;
|
|
||||||
}
|
|
@ -1,9 +0,0 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes;
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Created by libraryaddict on 23/12/2017.
|
|
||||||
*/
|
|
||||||
public enum ZombieProfession {
|
|
||||||
NORMAL,
|
|
||||||
HUSK;
|
|
||||||
}
|
|
@ -2,7 +2,6 @@ package me.libraryaddict.disguise.disguisetypes.watchers;
|
|||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||||
import me.libraryaddict.disguise.disguisetypes.VillagerProfession;
|
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import org.bukkit.entity.Villager.Profession;
|
import org.bukkit.entity.Villager.Profession;
|
||||||
|
|
||||||
@ -13,27 +12,17 @@ public class VillagerWatcher extends AgeableWatcher {
|
|||||||
setProfession(Profession.values()[DisguiseUtilities.random.nextInt(Profession.values().length)]);
|
setProfession(Profession.values()[DisguiseUtilities.random.nextInt(Profession.values().length)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public Profession getProfession() {
|
public Profession getProfession() {
|
||||||
return Profession.values()[getData(MetaIndex.VILLAGER_PROFESSION) + 1];
|
return Profession.values()[getData(MetaIndex.VILLAGER_PROFESSION) + 1];
|
||||||
}
|
}
|
||||||
|
|
||||||
public VillagerProfession getVillagerProfession() {
|
|
||||||
return VillagerProfession.values()[getData(MetaIndex.VILLAGER_PROFESSION)];
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setProfession(int professionId) {
|
public void setProfession(int professionId) {
|
||||||
setData(MetaIndex.VILLAGER_PROFESSION, professionId);
|
setData(MetaIndex.VILLAGER_PROFESSION, professionId);
|
||||||
sendData(MetaIndex.VILLAGER_PROFESSION);
|
sendData(MetaIndex.VILLAGER_PROFESSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProfession(VillagerProfession profession) {
|
|
||||||
setProfession(Math.max(1, Math.min(profession.ordinal(), Profession.BUTCHER.ordinal()) - 1));
|
|
||||||
}
|
|
||||||
|
|
||||||
@Deprecated
|
|
||||||
public void setProfession(Profession newProfession) {
|
public void setProfession(Profession newProfession) {
|
||||||
setProfession(newProfession.ordinal());
|
setProfession(newProfession.ordinal() - 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package me.libraryaddict.disguise.disguisetypes.watchers;
|
|||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
|
||||||
import me.libraryaddict.disguise.disguisetypes.ZombieProfession;
|
|
||||||
import org.bukkit.entity.Villager.Profession;
|
import org.bukkit.entity.Villager.Profession;
|
||||||
|
|
||||||
public class ZombieVillagerWatcher extends ZombieWatcher {
|
public class ZombieVillagerWatcher extends ZombieWatcher {
|
||||||
@ -35,16 +34,7 @@ public class ZombieVillagerWatcher extends ZombieWatcher {
|
|||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Profession getProfession() {
|
public Profession getProfession() {
|
||||||
int ord = getData(MetaIndex.ZOMBIE_VILLAGER_PROFESSION);
|
return Profession.values()[getData(MetaIndex.ZOMBIE_VILLAGER_PROFESSION) + 1];
|
||||||
|
|
||||||
if (ord == 1)
|
|
||||||
return Profession.HUSK;
|
|
||||||
|
|
||||||
return Profession.NORMAL;
|
|
||||||
}
|
|
||||||
|
|
||||||
public ZombieProfession getZombieProfession() {
|
|
||||||
return ZombieProfession.values()[getData(MetaIndex.ZOMBIE_VILLAGER_PROFESSION)];
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -54,7 +44,7 @@ public class ZombieVillagerWatcher extends ZombieWatcher {
|
|||||||
*/
|
*/
|
||||||
@Deprecated
|
@Deprecated
|
||||||
public void setProfession(int id) {
|
public void setProfession(int id) {
|
||||||
setData(MetaIndex.ZOMBIE_VILLAGER_PROFESSION, id % 2);
|
setData(MetaIndex.ZOMBIE_VILLAGER_PROFESSION, id);
|
||||||
sendData(MetaIndex.ZOMBIE_VILLAGER_PROFESSION);
|
sendData(MetaIndex.ZOMBIE_VILLAGER_PROFESSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -63,12 +53,7 @@ public class ZombieVillagerWatcher extends ZombieWatcher {
|
|||||||
*
|
*
|
||||||
* @param profession
|
* @param profession
|
||||||
*/
|
*/
|
||||||
@Deprecated
|
|
||||||
public void setProfession(Profession profession) {
|
public void setProfession(Profession profession) {
|
||||||
setProfession(profession.ordinal());
|
setProfession(profession.ordinal() - 1);
|
||||||
}
|
|
||||||
|
|
||||||
public void setProfession(ZombieProfession profession) {
|
|
||||||
setProfession(profession.ordinal());
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -759,16 +759,9 @@ public class DisguiseParser {
|
|||||||
// Parse to string
|
// Parse to string
|
||||||
value = ChatColor.translateAlternateColorCodes('&', valueString);
|
value = ChatColor.translateAlternateColorCodes('&', valueString);
|
||||||
}
|
}
|
||||||
} else if (param == ZombieProfession.class) {
|
} else if (param == Villager.Profession.class) {
|
||||||
try {
|
try {
|
||||||
value = ZombieProfession.valueOf(valueString.toUpperCase());
|
value = Villager.Profession.valueOf(valueString.toUpperCase());
|
||||||
}
|
|
||||||
catch (Exception ex) {
|
|
||||||
throw parseToException(param, valueString, methodName);
|
|
||||||
}
|
|
||||||
} else if (param == VillagerProfession.class) {
|
|
||||||
try {
|
|
||||||
value = VillagerProfession.valueOf(valueString.toUpperCase());
|
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
throw parseToException(param, valueString, methodName);
|
throw parseToException(param, valueString, methodName);
|
||||||
|
@ -153,10 +153,8 @@ public class ReflectionFlagWatchers {
|
|||||||
new ParamInfo(Horse.Color.class, "Horse Color", "View all the colors you can use for a horses color");
|
new ParamInfo(Horse.Color.class, "Horse Color", "View all the colors you can use for a horses color");
|
||||||
|
|
||||||
new ParamInfo(Ocelot.Type.class, "Ocelot Type", "View all the ocelot types you can use for ocelots");
|
new ParamInfo(Ocelot.Type.class, "Ocelot Type", "View all the ocelot types you can use for ocelots");
|
||||||
new ParamInfo(VillagerProfession.class, "Villager Profession",
|
new ParamInfo(Villager.Profession.class, "Villager Profession",
|
||||||
"View all the professions you can set on a villager");
|
"View all the professions you can set on a Zombie and Normal Villager");
|
||||||
new ParamInfo(ZombieProfession.class, "Zombie Profession",
|
|
||||||
"View all the professions you can set on a zombie villager");
|
|
||||||
new ParamInfo(BlockFace.class, Arrays.copyOf(BlockFace.values(), 6),
|
new ParamInfo(BlockFace.class, Arrays.copyOf(BlockFace.values(), 6),
|
||||||
"Direction (North, East, South, West, " + "Up, Down)",
|
"Direction (North, East, South, West, " + "Up, Down)",
|
||||||
"View the directions usable on player setSleeping and shulker direction");
|
"View the directions usable on player setSleeping and shulker direction");
|
||||||
|
Loading…
Reference in New Issue
Block a user