Deprecate the replaceSounds and add new constructors for miscDisguise

This commit is contained in:
libraryaddict 2014-05-14 10:34:41 +12:00
parent b7dfb2c66b
commit 8db338f533
5 changed files with 44 additions and 24 deletions

View File

@ -54,7 +54,7 @@ public abstract class Disguise {
/** /**
* Seems I do this method so I can make cleaner constructors on disguises.. * Seems I do this method so I can make cleaner constructors on disguises..
*/ */
protected void createDisguise(DisguiseType newType, boolean doSounds) { protected void createDisguise(DisguiseType newType) {
if (getWatcher() != null) if (getWatcher() != null)
return; return;
if (newType.getEntityType() == null) { if (newType.getEntityType() == null) {
@ -65,8 +65,6 @@ public abstract class Disguise {
} }
// Set the disguise type // Set the disguise type
disguiseType = newType; disguiseType = newType;
// Set the option to replace the sounds
setReplaceSounds(doSounds);
// Get if they are a adult now.. // Get if they are a adult now..
boolean isAdult = true; boolean isAdult = true;
if (isMobDisguise()) { if (isMobDisguise()) {

View File

@ -16,21 +16,33 @@ public class MiscDisguise extends TargetedDisguise {
private int id = -1; private int id = -1;
public MiscDisguise(DisguiseType disguiseType) { public MiscDisguise(DisguiseType disguiseType) {
this(disguiseType, true, -1, -1); this(disguiseType, -1, -1);
} }
@Deprecated
public MiscDisguise(DisguiseType disguiseType, boolean replaceSounds) { public MiscDisguise(DisguiseType disguiseType, boolean replaceSounds) {
this(disguiseType, replaceSounds, -1, -1); this(disguiseType, replaceSounds, -1, -1);
} }
@Deprecated
public MiscDisguise(DisguiseType disguiseType, boolean replaceSounds, int addictionalData) { public MiscDisguise(DisguiseType disguiseType, boolean replaceSounds, int addictionalData) {
this(disguiseType, replaceSounds, (disguiseType == DisguiseType.FALLING_BLOCK this(disguiseType, replaceSounds, (disguiseType == DisguiseType.FALLING_BLOCK
|| disguiseType == DisguiseType.DROPPED_ITEM ? addictionalData : -1), (disguiseType == DisguiseType.FALLING_BLOCK || disguiseType == DisguiseType.DROPPED_ITEM ? addictionalData : -1), (disguiseType == DisguiseType.FALLING_BLOCK
|| disguiseType == DisguiseType.DROPPED_ITEM ? -1 : addictionalData)); || disguiseType == DisguiseType.DROPPED_ITEM ? -1 : addictionalData));
} }
@Deprecated
public MiscDisguise(DisguiseType disguiseType, boolean replaceSounds, int id, int data) { public MiscDisguise(DisguiseType disguiseType, boolean replaceSounds, int id, int data) {
createDisguise(disguiseType, replaceSounds); this(disguiseType, id, data);
this.setReplaceSounds(replaceSounds);
}
public MiscDisguise(DisguiseType disguiseType, int id) {
this(disguiseType, id, -1);
}
public MiscDisguise(DisguiseType disguiseType, int id, int data) {
createDisguise(disguiseType);
switch (disguiseType) { switch (disguiseType) {
// The only disguises which should use a custom data. // The only disguises which should use a custom data.
case FISHING_HOOK: case FISHING_HOOK:
@ -46,6 +58,7 @@ public class MiscDisguise extends TargetedDisguise {
data = -1; data = -1;
break; break;
} }
// Only falling block should set the id
if (getType() == DisguiseType.FALLING_BLOCK && id != -1) { if (getType() == DisguiseType.FALLING_BLOCK && id != -1) {
this.id = id; this.id = id;
} else { } else {
@ -79,13 +92,14 @@ public class MiscDisguise extends TargetedDisguise {
} }
} }
public MiscDisguise(DisguiseType disguiseType, int id, int data) { @Deprecated
this(disguiseType, true, id, data); public MiscDisguise(EntityType entityType) {
this(entityType, -1, -1);
} }
@Deprecated @Deprecated
public MiscDisguise(EntityType entityType) { public MiscDisguise(EntityType entityType, int id) {
this(entityType, true, -1, -1); this(entityType, id, -1);
} }
@Deprecated @Deprecated
@ -100,12 +114,13 @@ public class MiscDisguise extends TargetedDisguise {
@Deprecated @Deprecated
public MiscDisguise(EntityType disguiseType, int id, int data) { public MiscDisguise(EntityType disguiseType, int id, int data) {
this(disguiseType, true, id, data); this(DisguiseType.getType(disguiseType), id, data);
} }
@Override @Override
public MiscDisguise clone() { public MiscDisguise clone() {
MiscDisguise disguise = new MiscDisguise(getType(), isSoundsReplaced(), getData()); MiscDisguise disguise = new MiscDisguise(getType(), getData());
disguise.setReplaceSounds(isSoundsReplaced());
disguise.setViewSelfDisguise(isSelfDisguiseVisible()); disguise.setViewSelfDisguise(isSelfDisguiseVisible());
disguise.setHearSelfDisguise(isSelfDisguiseSoundsReplaced()); disguise.setHearSelfDisguise(isSelfDisguiseSoundsReplaced());
disguise.setHideArmorFromSelf(isHidingArmorFromSelf()); disguise.setHideArmorFromSelf(isHidingArmorFromSelf());

View File

@ -14,12 +14,14 @@ public class MobDisguise extends TargetedDisguise {
} }
public MobDisguise(DisguiseType disguiseType, boolean isAdult) { public MobDisguise(DisguiseType disguiseType, boolean isAdult) {
this(disguiseType, isAdult, true); this.isAdult = isAdult;
createDisguise(disguiseType);
} }
@Deprecated
public MobDisguise(DisguiseType disguiseType, boolean isAdult, boolean replaceSounds) { public MobDisguise(DisguiseType disguiseType, boolean isAdult, boolean replaceSounds) {
this.isAdult = isAdult; this(disguiseType, isAdult);
createDisguise(disguiseType, replaceSounds); this.setReplaceSounds(replaceSounds);
} }
@Deprecated @Deprecated
@ -29,18 +31,19 @@ public class MobDisguise extends TargetedDisguise {
@Deprecated @Deprecated
public MobDisguise(EntityType entityType, boolean isAdult) { public MobDisguise(EntityType entityType, boolean isAdult) {
this(entityType, isAdult, true); this(DisguiseType.getType(entityType), isAdult);
} }
@Deprecated @Deprecated
public MobDisguise(EntityType entityType, boolean isAdult, boolean replaceSounds) { public MobDisguise(EntityType entityType, boolean isAdult, boolean replaceSounds) {
this.isAdult = isAdult; this(entityType, isAdult);
createDisguise(DisguiseType.getType(entityType), replaceSounds); this.setReplaceSounds(replaceSounds);
} }
@Override @Override
public MobDisguise clone() { public MobDisguise clone() {
MobDisguise disguise = new MobDisguise(getType(), isAdult(), isSoundsReplaced()); MobDisguise disguise = new MobDisguise(getType(), isAdult());
disguise.setReplaceSounds(isSoundsReplaced());
disguise.setViewSelfDisguise(isSelfDisguiseVisible()); disguise.setViewSelfDisguise(isSelfDisguiseVisible());
disguise.setHearSelfDisguise(isSelfDisguiseSoundsReplaced()); disguise.setHearSelfDisguise(isSelfDisguiseSoundsReplaced());
disguise.setHideArmorFromSelf(isHidingArmorFromSelf()); disguise.setHideArmorFromSelf(isHidingArmorFromSelf());

View File

@ -4,19 +4,22 @@ public class PlayerDisguise extends TargetedDisguise {
private String playerName; private String playerName;
public PlayerDisguise(String name) { public PlayerDisguise(String name) {
this(name, true);
}
public PlayerDisguise(String name, boolean replaceSounds) {
if (name.length() > 16) if (name.length() > 16)
name = name.substring(0, 16); name = name.substring(0, 16);
playerName = name; playerName = name;
createDisguise(DisguiseType.PLAYER, replaceSounds); createDisguise(DisguiseType.PLAYER);
}
@Deprecated
public PlayerDisguise(String name, boolean replaceSounds) {
this(name);
this.setReplaceSounds(replaceSounds);
} }
@Override @Override
public PlayerDisguise clone() { public PlayerDisguise clone() {
PlayerDisguise disguise = new PlayerDisguise(getName(), isSoundsReplaced()); PlayerDisguise disguise = new PlayerDisguise(getName());
disguise.setReplaceSounds(isSoundsReplaced());
disguise.setViewSelfDisguise(isSelfDisguiseVisible()); disguise.setViewSelfDisguise(isSelfDisguiseVisible());
disguise.setHearSelfDisguise(isSelfDisguiseSoundsReplaced()); disguise.setHearSelfDisguise(isSelfDisguiseSoundsReplaced());
disguise.setHideArmorFromSelf(isHidingArmorFromSelf()); disguise.setHideArmorFromSelf(isHidingArmorFromSelf());

View File

@ -2,6 +2,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers;
import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.FlagWatcher; import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
public class DroppedItemWatcher extends FlagWatcher { public class DroppedItemWatcher extends FlagWatcher {