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 showNameAboveHeadAlwaysVisible;
private static boolean targetDisguises; private static boolean targetDisguises;
@Deprecated
public static boolean canHearSelfDisguise() {
return hearSelfDisguise;
}
public static String getDisguiseBlownMessage() { public static String getDisguiseBlownMessage() {
return disguiseBlownMessage; return disguiseBlownMessage;
} }

View File

@ -48,11 +48,6 @@ public abstract class Disguise {
private boolean viewSelfDisguise = DisguiseConfig.isViewDisguises(); private boolean viewSelfDisguise = DisguiseConfig.isViewDisguises();
private FlagWatcher watcher; private FlagWatcher watcher;
@Deprecated
public boolean canHearSelfDisguise() {
return hearSelfDisguise;
}
@Override @Override
public abstract Disguise clone(); public abstract Disguise clone();
@ -86,9 +81,9 @@ public abstract class Disguise {
// Set the disguise if its a baby or not // Set the disguise if its a baby or not
if (!isAdult) { if (!isAdult) {
if (getWatcher() instanceof AgeableWatcher) { if (getWatcher() instanceof AgeableWatcher) {
((AgeableWatcher) getWatcher()).setAdult(false); ((AgeableWatcher) getWatcher()).setBaby(true);
} else if (getWatcher() instanceof ZombieWatcher) { } 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 // 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. * Set the entity of the disguise. Only used for internal things.
*/ */
@ -614,9 +604,4 @@ public abstract class Disguise {
public void setWatcher(FlagWatcher newWatcher) { public void setWatcher(FlagWatcher newWatcher) {
watcher = 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; return ((Byte) getValue(0, (byte) 0) & 1 << byteValue) != 0;
} }
@Deprecated
public ItemStack getHeldItem() {
return getItemInHand();
}
public ItemStack getItemInHand() { public ItemStack getItemInHand() {
return getItemStack(SlotType.HELD_ITEM); return getItemStack(SlotType.HELD_ITEM);
} }
@ -200,11 +195,6 @@ public class FlagWatcher {
return getFlag(5); return getFlag(5);
} }
@Deprecated
public boolean isRiding() {
return getFlag(2);
}
public boolean isRightClicking() { public boolean isRightClicking() {
return getFlag(4); return getFlag(4);
} }
@ -269,11 +259,6 @@ public class FlagWatcher {
} }
} }
@Deprecated
public void setHeldItem(ItemStack itemstack) {
setItemInHand(itemstack);
}
public void setInvisible(boolean setInvis) { public void setInvisible(boolean setInvis) {
setFlag(5, setInvis); setFlag(5, setInvis);
sendData(0); sendData(0);
@ -328,12 +313,6 @@ public class FlagWatcher {
setItemStack(slot.getSlot(), itemStack); setItemStack(slot.getSlot(), itemStack);
} }
@Deprecated
public void setRiding(boolean setRiding) {
setFlag(2, setRiding);
sendData(0);
}
public void setRightClicking(boolean setRightClicking) { public void setRightClicking(boolean setRightClicking) {
setFlag(4, setRightClicking); setFlag(4, setRightClicking);
sendData(0); sendData(0);

View File

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

View File

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

View File

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

View File

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

View File

@ -10,22 +10,6 @@ public class EndermanWatcher extends LivingWatcher {
super(disguise); 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 @Override
public ItemStack getItemInHand() { public ItemStack getItemInHand() {
return new ItemStack((Byte) getValue(16, (byte) 0), 1, ((Byte) getValue(17, (byte) 0))); 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); 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 @Override
public void setItemInHand(ItemStack itemstack) { public void setItemInHand(ItemStack itemstack) {
setValue(16, (byte) (itemstack.getTypeId() & 255)); setValue(16, (byte) (itemstack.getTypeId() & 255));

View File

@ -12,20 +12,9 @@ public class GhastWatcher extends LivingWatcher {
return (Byte) getValue(16, (byte) 0) == 1; return (Byte) getValue(16, (byte) 0) == 1;
} }
@Deprecated
public boolean isAgressive() {
return (Byte) getValue(16, (byte) 0) == 1;
}
public void setAggressive(boolean isAgressive) { public void setAggressive(boolean isAgressive) {
setValue(16, (byte) (isAgressive ? 1 : 0)); setValue(16, (byte) (isAgressive ? 1 : 0));
sendData(16); 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) { public HorseWatcher(Disguise disguise) {
super(disguise); super(disguise);
setColorId(new Random().nextInt(Color.values().length)); setColor(Color.values()[new Random().nextInt(Color.values().length)]);
} }
public Color getColor() { public Color getColor() {
@ -34,11 +34,6 @@ public class HorseWatcher extends AgeableWatcher {
return isTrue(8); return isTrue(8);
} }
@Deprecated
public boolean isBredable() {
return isTrue(16);
}
public boolean isBreedable() { public boolean isBreedable() {
return isTrue(16); return isTrue(16);
} }
@ -67,11 +62,6 @@ public class HorseWatcher extends AgeableWatcher {
return ((Integer) getValue(16, (byte) 0) & i) != 0; return ((Integer) getValue(16, (byte) 0) & i) != 0;
} }
@Deprecated
public void setCanBred(boolean breed) {
setFlag(16, breed);
}
public void setCanBreed(boolean breed) { public void setCanBreed(boolean breed) {
setFlag(16, breed); setFlag(16, breed);
} }
@ -85,12 +75,6 @@ public class HorseWatcher extends AgeableWatcher {
sendData(20); 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) { private void setFlag(int i, boolean flag) {
int j = (Byte) getValue(16, (byte) 0); int j = (Byte) getValue(16, (byte) 0);
if (flag) { if (flag) {
@ -132,12 +116,6 @@ public class HorseWatcher extends AgeableWatcher {
sendData(20); 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) { public void setTamed(boolean tamed) {
setFlag(2, 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.disguisetypes.FlagWatcher;
import me.libraryaddict.disguise.utilities.ReflectionManager; import me.libraryaddict.disguise.utilities.ReflectionManager;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType; import org.bukkit.potion.PotionEffectType;
public class LivingWatcher extends FlagWatcher { public class LivingWatcher extends FlagWatcher {
@ -38,14 +37,6 @@ public class LivingWatcher extends FlagWatcher {
super(disguise); 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) { public void addPotionEffect(PotionEffectType potionEffect) {
if (hasPotionEffect(potionEffect)) if (hasPotionEffect(potionEffect))
removePotionEffect(potionEffect); removePotionEffect(potionEffect);

View File

@ -58,10 +58,4 @@ public class OcelotWatcher extends AgeableWatcher {
setValue(18, (byte) newType.getId()); setValue(18, (byte) newType.getId());
sendData(18); 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) { public VillagerWatcher(Disguise disguise) {
super(disguise); super(disguise);
setProfessionId(new Random().nextInt(Profession.values().length)); setProfession(Profession.values()[new Random().nextInt(Profession.values().length)]);
} }
public Profession getProfession() { public Profession getProfession() {
return Profession.values()[(Integer) getValue(16, 0)]; return Profession.values()[(Integer) getValue(16, 0)];
} }
@Deprecated
public int getProfessionId() {
return (Integer) getValue(16, 0);
}
public void setProfession(Profession newProfession) { public void setProfession(Profession newProfession) {
setProfessionId(newProfession.getId()); setValue(16, newProfession.getId() % 6);
}
@Deprecated
public void setProfessionId(int profession) {
setValue(16, profession % 6);
sendData(16); sendData(16);
} }

View File

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

View File

@ -372,34 +372,6 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
return disguise; 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 { private void doCheck(HashSet<HashSet<String>> optionPermissions, HashSet<String> usedOptions) throws Exception {
if (!optionPermissions.isEmpty()) { if (!optionPermissions.isEmpty()) {
for (HashSet<String> perms : optionPermissions) { for (HashSet<String> perms : optionPermissions) {