Removed Deprecated methods and added a few isAdult codes to zombie and ageable watchers

This commit is contained in:
libraryaddict 2014-04-03 02:49:33 +13:00
parent 8c20f0c3b6
commit 8f63a6eaa0
16 changed files with 21 additions and 202 deletions

View File

@ -19,11 +19,6 @@ public class DisguiseConfig {
private static boolean showNameAboveHeadAlwaysVisible;
private static boolean targetDisguises;
@Deprecated
public static boolean canHearSelfDisguise() {
return hearSelfDisguise;
}
public static String getDisguiseBlownMessage() {
return disguiseBlownMessage;
}

View File

@ -48,11 +48,6 @@ public abstract class Disguise {
private boolean viewSelfDisguise = DisguiseConfig.isViewDisguises();
private FlagWatcher watcher;
@Deprecated
public boolean canHearSelfDisguise() {
return hearSelfDisguise;
}
@Override
public abstract Disguise clone();
@ -86,9 +81,9 @@ public abstract class Disguise {
// Set the disguise if its a baby or not
if (!isAdult) {
if (getWatcher() instanceof AgeableWatcher) {
((AgeableWatcher) getWatcher()).setAdult(false);
((AgeableWatcher) getWatcher()).setBaby(true);
} else if (getWatcher() instanceof ZombieWatcher) {
((ZombieWatcher) getWatcher()).setAdult(false);
((ZombieWatcher) getWatcher()).setBaby(true);
}
}
// If the disguise type is a wither, set the flagwatcher value for the skeleton to a wither skeleton
@ -422,11 +417,6 @@ public abstract class Disguise {
}
}
@Deprecated
public boolean replaceSounds() {
return replaceSounds;
}
/**
* Set the entity of the disguise. Only used for internal things.
*/
@ -614,9 +604,4 @@ public abstract class Disguise {
public void setWatcher(FlagWatcher newWatcher) {
watcher = newWatcher;
}
@Deprecated
public boolean viewSelfDisguise() {
return viewSelfDisguise;
}
}

View File

@ -161,11 +161,6 @@ public class FlagWatcher {
return ((Byte) getValue(0, (byte) 0) & 1 << byteValue) != 0;
}
@Deprecated
public ItemStack getHeldItem() {
return getItemInHand();
}
public ItemStack getItemInHand() {
return getItemStack(SlotType.HELD_ITEM);
}
@ -200,11 +195,6 @@ public class FlagWatcher {
return getFlag(5);
}
@Deprecated
public boolean isRiding() {
return getFlag(2);
}
public boolean isRightClicking() {
return getFlag(4);
}
@ -269,11 +259,6 @@ public class FlagWatcher {
}
}
@Deprecated
public void setHeldItem(ItemStack itemstack) {
setItemInHand(itemstack);
}
public void setInvisible(boolean setInvis) {
setFlag(5, setInvis);
sendData(0);
@ -328,12 +313,6 @@ public class FlagWatcher {
setItemStack(slot.getSlot(), itemStack);
}
@Deprecated
public void setRiding(boolean setRiding) {
setFlag(2, setRiding);
sendData(0);
}
public void setRightClicking(boolean setRightClicking) {
setFlag(4, setRightClicking);
sendData(0);

View File

@ -69,7 +69,7 @@ public class MiscDisguise extends TargetedDisguise {
((FallingBlockWatcher) getWatcher()).setBlock(new ItemStack(this.id, 1, (short) this.data));
break;
case PAINTING:
((PaintingWatcher) getWatcher()).setArtId(this.data);
((PaintingWatcher) getWatcher()).setArt(Art.values()[this.data % Art.values().length]);
break;
case SPLASH_POTION:
((SplashPotionWatcher) getWatcher()).setPotionId(this.data);

View File

@ -62,9 +62,9 @@ public class MobDisguise extends TargetedDisguise {
public boolean isAdult() {
if (getWatcher() != null) {
if (getWatcher() instanceof AgeableWatcher)
return ((AgeableWatcher) getWatcher()).isAdult();
return ((AgeableWatcher) getWatcher()).isBaby();
else if (getWatcher() instanceof ZombieWatcher)
return ((ZombieWatcher) getWatcher()).isAdult();
return ((ZombieWatcher) getWatcher()).isBaby();
return false;
}
return isAdult;

View File

@ -12,7 +12,6 @@ public class AgeableWatcher extends LivingWatcher {
return (Integer) getValue(12, 0);
}
@Deprecated
public boolean isAdult() {
return !isBaby();
}
@ -21,9 +20,8 @@ public class AgeableWatcher extends LivingWatcher {
return (Integer) getValue(12, 0) < 0;
}
@Deprecated
public void setAdult(boolean isAdult) {
setBaby(!isAdult);
public void setAdult() {
setBaby(false);
}
public void setAge(int newAge) {
@ -31,6 +29,10 @@ public class AgeableWatcher extends LivingWatcher {
sendData(12);
}
public void setBaby() {
setBaby(true);
}
public void setBaby(boolean isBaby) {
setValue(12, isBaby ? -24000 : 0);
sendData(12);

View File

@ -8,11 +8,6 @@ public class CreeperWatcher extends LivingWatcher {
super(disguise);
}
@Deprecated
public boolean isFused() {
return (Byte) getValue(16, (byte) 0) == 1;
}
public boolean isIgnited() {
return (Byte) getValue(18, (byte) 0) == 1;
}
@ -21,18 +16,6 @@ public class CreeperWatcher extends LivingWatcher {
return (Byte) getValue(17, (byte) 0) == 1;
}
@Deprecated
public void setFuse(boolean isFused) {
setValue(16, (byte) (isFused ? 1 : -1));
sendData(16);
}
@Deprecated
public void setFused(boolean isFused) {
setValue(16, (byte) (isFused ? 1 : -1));
sendData(16);
}
public void setIgnited(boolean ignited) {
setValue(18, (byte) (ignited ? 1 : 0));
sendData(18);

View File

@ -10,22 +10,6 @@ public class EndermanWatcher extends LivingWatcher {
super(disguise);
}
@Deprecated
public int getCarriedData() {
return ((Byte) getValue(17, (byte) 0));
}
@Deprecated
public int getCarriedId() {
return ((Byte) getValue(16, (byte) 0));
}
@Override
@Deprecated
public ItemStack getHeldItem() {
return getItemInHand();
}
@Override
public ItemStack getItemInHand() {
return new ItemStack((Byte) getValue(16, (byte) 0), 1, ((Byte) getValue(17, (byte) 0)));
@ -40,26 +24,6 @@ public class EndermanWatcher extends LivingWatcher {
sendData(18);
}
@Deprecated
public void setCarriedItem(int id, int dataValue) {
setValue(16, (byte) (id & 255));
setValue(17, (byte) (dataValue & 255));
sendData(16);
sendData(17);
}
@Deprecated
public void setCarriedItem(ItemStack itemstack) {
setValue(16, (byte) (itemstack.getTypeId() & 255));
setValue(17, (byte) (itemstack.getDurability() & 255));
}
@Override
@Deprecated
public void setHeldItem(ItemStack itemstack) {
setItemInHand(itemstack);
}
@Override
public void setItemInHand(ItemStack itemstack) {
setValue(16, (byte) (itemstack.getTypeId() & 255));

View File

@ -12,20 +12,9 @@ public class GhastWatcher extends LivingWatcher {
return (Byte) getValue(16, (byte) 0) == 1;
}
@Deprecated
public boolean isAgressive() {
return (Byte) getValue(16, (byte) 0) == 1;
}
public void setAggressive(boolean isAgressive) {
setValue(16, (byte) (isAgressive ? 1 : 0));
sendData(16);
}
@Deprecated
public void setAgressive(boolean isAgressive) {
setValue(16, (byte) (isAgressive ? 1 : 0));
sendData(16);
}
}

View File

@ -11,7 +11,7 @@ public class HorseWatcher extends AgeableWatcher {
public HorseWatcher(Disguise disguise) {
super(disguise);
setColorId(new Random().nextInt(Color.values().length));
setColor(Color.values()[new Random().nextInt(Color.values().length)]);
}
public Color getColor() {
@ -34,11 +34,6 @@ public class HorseWatcher extends AgeableWatcher {
return isTrue(8);
}
@Deprecated
public boolean isBredable() {
return isTrue(16);
}
public boolean isBreedable() {
return isTrue(16);
}
@ -67,11 +62,6 @@ public class HorseWatcher extends AgeableWatcher {
return ((Integer) getValue(16, (byte) 0) & i) != 0;
}
@Deprecated
public void setCanBred(boolean breed) {
setFlag(16, breed);
}
public void setCanBreed(boolean breed) {
setFlag(16, breed);
}
@ -85,12 +75,6 @@ public class HorseWatcher extends AgeableWatcher {
sendData(20);
}
@Deprecated
public void setColorId(int color) {
setValue(20, (color % Color.values().length) & 0xFF | getStyle().ordinal() << 8);
sendData(20);
}
private void setFlag(int i, boolean flag) {
int j = (Byte) getValue(16, (byte) 0);
if (flag) {
@ -132,12 +116,6 @@ public class HorseWatcher extends AgeableWatcher {
sendData(20);
}
@Deprecated
public void setStyleId(int style) {
setValue(20, getColor().ordinal() & 0xFF | (style % Style.values().length) << 8);
sendData(20);
}
public void setTamed(boolean tamed) {
setFlag(2, tamed);
}

View File

@ -6,7 +6,6 @@ import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
import me.libraryaddict.disguise.utilities.ReflectionManager;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class LivingWatcher extends FlagWatcher {
@ -38,14 +37,6 @@ public class LivingWatcher extends FlagWatcher {
super(disguise);
}
@Deprecated
public void addPotionEffect(PotionEffect potionEffect) {
if (hasPotionEffect(potionEffect.getType()))
removePotionEffect(potionEffect.getType());
potionEffects.add(potionEffect.getType().getId());
sendPotionEffects();
}
public void addPotionEffect(PotionEffectType potionEffect) {
if (hasPotionEffect(potionEffect))
removePotionEffect(potionEffect);

View File

@ -58,10 +58,4 @@ public class OcelotWatcher extends AgeableWatcher {
setValue(18, (byte) newType.getId());
sendData(18);
}
@Deprecated
public void setTypeId(int type) {
setValue(18, (byte) (type % Type.values().length));
sendData(18);
}
}

View File

@ -30,9 +30,4 @@ public class PaintingWatcher extends FlagWatcher {
}
}
@Deprecated
public void setArtId(int paintingNo) {
painting = Art.values()[paintingNo % Art.values().length];
}
}

View File

@ -10,25 +10,15 @@ public class VillagerWatcher extends AgeableWatcher {
public VillagerWatcher(Disguise disguise) {
super(disguise);
setProfessionId(new Random().nextInt(Profession.values().length));
setProfession(Profession.values()[new Random().nextInt(Profession.values().length)]);
}
public Profession getProfession() {
return Profession.values()[(Integer) getValue(16, 0)];
}
@Deprecated
public int getProfessionId() {
return (Integer) getValue(16, 0);
}
public void setProfession(Profession newProfession) {
setProfessionId(newProfession.getId());
}
@Deprecated
public void setProfessionId(int profession) {
setValue(16, profession % 6);
setValue(16, newProfession.getId() % 6);
sendData(16);
}

View File

@ -8,9 +8,8 @@ public class ZombieWatcher extends LivingWatcher {
super(disguise);
}
@Deprecated
public boolean isAdult() {
return (Byte) getValue(12, (byte) 0) == 0;
return !isBaby();
}
public boolean isBaby() {
@ -21,9 +20,12 @@ public class ZombieWatcher extends LivingWatcher {
return (Byte) getValue(13, (byte) 0) == 1;
}
@Deprecated
public void setAdult(boolean adult) {
setBaby(!adult);
public void setAdult() {
setBaby(false);
}
public void setBaby() {
setBaby(true);
}
public void setBaby(boolean baby) {

View File

@ -372,34 +372,6 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
return disguise;
}
/* private ArrayList<Method> getUsableMethods(DisguiseType disguiseType, CommandSender commandSender) {
ArrayList<Method> methods = getSettableMethods(disguiseType);
ArrayList<String> allowedDisguises = this.getAllowedDisguises(commandSender);
}
private ArrayList<Method> getSettableMethods(DisguiseType disguiseType) {
ArrayList<Method> methods = new ArrayList<Method>();
String[] acceptableParams = new String[] { "String", "boolean", "int", "float", "double", "AnimalColor", "ItemStack",
"ItemStack[]", "Style", "Color", "Type", "Profession", "PotionEffectType" };
try {
for (Method method : disguiseType.getWatcherClass().getMethods()) {
if (!method.getName().startsWith("get") && method.getParameterTypes().length == 1
&& method.getAnnotation(Deprecated.class) == null) {
Class c = method.getParameterTypes()[0];
for (String acceptable : acceptableParams) {
if (c.getSimpleName().equals(acceptable)) {
methods.add(method);
break;
}
}
}
}
} catch (Exception ex) {
ex.printStackTrace();
}
return methods;
}*/// //
private void doCheck(HashSet<HashSet<String>> optionPermissions, HashSet<String> usedOptions) throws Exception {
if (!optionPermissions.isEmpty()) {
for (HashSet<String> perms : optionPermissions) {