Fixed up the flagwatchers .clone and fixed playerdisguise not .clone working

This commit is contained in:
Andrew 2013-11-06 05:37:10 +13:00
parent fb38bcd99f
commit d84121c4eb
5 changed files with 22 additions and 8 deletions

View File

@ -62,8 +62,14 @@ public class FlagWatcher {
this.disguise = disguise;
}
public FlagWatcher clone() {
FlagWatcher cloned = new FlagWatcher(disguise);
public FlagWatcher clone(Disguise disguise) {
FlagWatcher cloned = null;
try {
cloned = getClass().getConstructor(Disguise.class).newInstance(disguise);
} catch (Exception e) {
// TODO Auto-generated catch block
e.printStackTrace();
}
cloned.entityValues = (HashMap<Integer, Object>) entityValues.clone();
cloned.items = items.clone();
return cloned;

View File

@ -54,6 +54,7 @@ public class MiscDisguise extends Disguise {
this(disguiseType, true, id, data);
}
@Override
public MiscDisguise clone() {
MiscDisguise disguise = new MiscDisguise(getType(), replaceSounds(), getId(), getData());
disguise.setViewSelfDisguise(viewSelfDisguise());
@ -61,7 +62,7 @@ public class MiscDisguise extends Disguise {
disguise.setHideArmorFromSelf(isHidingArmorFromSelf());
disguise.setHideHeldItemFromSelf(isHidingHeldItemFromSelf());
disguise.setVelocitySent(isVelocitySent());
disguise.setWatcher(getWatcher().clone());
disguise.setWatcher(getWatcher().clone(disguise));
return disguise;
}

View File

@ -38,6 +38,7 @@ public class MobDisguise extends Disguise {
createDisguise(DisguiseType.getType(entityType), replaceSounds);
}
@Override
public MobDisguise clone() {
MobDisguise disguise = new MobDisguise(getType(), isAdult(), replaceSounds());
disguise.setViewSelfDisguise(viewSelfDisguise());
@ -45,7 +46,7 @@ public class MobDisguise extends Disguise {
disguise.setHideArmorFromSelf(isHidingArmorFromSelf());
disguise.setHideHeldItemFromSelf(isHidingHeldItemFromSelf());
disguise.setVelocitySent(isVelocitySent());
disguise.setWatcher(getWatcher().clone());
disguise.setWatcher(getWatcher().clone(disguise));
return disguise;
}

View File

@ -14,8 +14,15 @@ public class PlayerDisguise extends Disguise {
createDisguise(DisguiseType.PLAYER, replaceSounds);
}
@Override
public PlayerDisguise clone() {
PlayerDisguise disguise = new PlayerDisguise(getName(), replaceSounds());
disguise.setViewSelfDisguise(viewSelfDisguise());
disguise.setHearSelfDisguise(canHearSelfDisguise());
disguise.setHideArmorFromSelf(isHidingArmorFromSelf());
disguise.setHideHeldItemFromSelf(isHidingHeldItemFromSelf());
disguise.setVelocitySent(isVelocitySent());
disguise.setWatcher(getWatcher().clone(disguise));
return disguise;
}

View File

@ -11,8 +11,6 @@ import net.minecraft.server.v1_6_R3.PotionBrewer;
import org.bukkit.potion.PotionEffect;
import org.bukkit.potion.PotionEffectType;
public class LivingWatcher extends FlagWatcher {
private HashSet<MobEffect> potionEffects = new HashSet<MobEffect>();
@ -27,8 +25,9 @@ public class LivingWatcher extends FlagWatcher {
sendPotionEffects();
}
public LivingWatcher clone() {
LivingWatcher clone = (LivingWatcher) super.clone();
@Override
public LivingWatcher clone(Disguise disguise) {
LivingWatcher clone = (LivingWatcher) super.clone(disguise);
clone.potionEffects = (HashSet<MobEffect>) potionEffects.clone();
return clone;
}