Add compatibility to flagwatcher for the new watchers
This commit is contained in:
parent
a19b3a7833
commit
fddbabf931
@ -49,6 +49,11 @@ public class FlagWatcher {
|
|||||||
this.disguise = disguise;
|
this.disguise = disguise;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected Object clone() {
|
||||||
|
throw new RuntimeException("Please use clone(disguise) instead of clone()");
|
||||||
|
}
|
||||||
|
|
||||||
public FlagWatcher clone(Disguise disguise) {
|
public FlagWatcher clone(Disguise disguise) {
|
||||||
FlagWatcher cloned = null;
|
FlagWatcher cloned = null;
|
||||||
try {
|
try {
|
||||||
@ -110,7 +115,7 @@ public class FlagWatcher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
// Here we check for if there is a health packet that says they died.
|
// Here we check for if there is a health packet that says they died.
|
||||||
if (disguise.isSelfDisguiseVisible() && disguise.getEntity() != null && disguise.getEntity() instanceof Player) {
|
if (disguise.isSelfDisguiseVisible() && getDisguise().getEntity() != null && getDisguise().getEntity() instanceof Player) {
|
||||||
for (WrappedWatchableObject watch : newList) {
|
for (WrappedWatchableObject watch : newList) {
|
||||||
// Its a health packet
|
// Its a health packet
|
||||||
if (watch.getIndex() == 6) {
|
if (watch.getIndex() == 6) {
|
||||||
@ -119,7 +124,7 @@ public class FlagWatcher {
|
|||||||
float newHealth = (Float) value;
|
float newHealth = (Float) value;
|
||||||
if (newHealth > 0 && hasDied) {
|
if (newHealth > 0 && hasDied) {
|
||||||
hasDied = false;
|
hasDied = false;
|
||||||
DisguiseUtilities.sendSelfDisguise((Player) disguise.getEntity());
|
DisguiseUtilities.sendSelfDisguise((Player) getDisguise().getEntity());
|
||||||
} else if (newHealth <= 0 && !hasDied) {
|
} else if (newHealth <= 0 && !hasDied) {
|
||||||
hasDied = true;
|
hasDied = true;
|
||||||
}
|
}
|
||||||
@ -194,7 +199,7 @@ public class FlagWatcher {
|
|||||||
return;
|
return;
|
||||||
if (!entityValues.containsKey(data) || entityValues.get(data) == null)
|
if (!entityValues.containsKey(data) || entityValues.get(data) == null)
|
||||||
return;
|
return;
|
||||||
Entity entity = disguise.getEntity();
|
Entity entity = getDisguise().getEntity();
|
||||||
Object value = entityValues.get(data);
|
Object value = entityValues.get(data);
|
||||||
List<WrappedWatchableObject> list = new ArrayList<WrappedWatchableObject>();
|
List<WrappedWatchableObject> list = new ArrayList<WrappedWatchableObject>();
|
||||||
list.add(new WrappedWatchableObject(data, value));
|
list.add(new WrappedWatchableObject(data, value));
|
||||||
@ -202,7 +207,7 @@ public class FlagWatcher {
|
|||||||
StructureModifier<Object> mods = packet.getModifier();
|
StructureModifier<Object> mods = packet.getModifier();
|
||||||
mods.write(0, entity.getEntityId());
|
mods.write(0, entity.getEntityId());
|
||||||
packet.getWatchableCollectionModifier().write(0, list);
|
packet.getWatchableCollectionModifier().write(0, list);
|
||||||
for (Player player : disguise.getPerverts()) {
|
for (Player player : getDisguise().getPerverts()) {
|
||||||
if (DisguiseAPI.isViewDisguises() || player != entity) {
|
if (DisguiseAPI.isViewDisguises() || player != entity) {
|
||||||
try {
|
try {
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
|
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
|
||||||
@ -251,7 +256,7 @@ public class FlagWatcher {
|
|||||||
if (itemStack == null) {
|
if (itemStack == null) {
|
||||||
// Find the item to replace it with
|
// Find the item to replace it with
|
||||||
if (disguise.getEntity() instanceof LivingEntity) {
|
if (disguise.getEntity() instanceof LivingEntity) {
|
||||||
EntityEquipment enquipment = ((LivingEntity) disguise.getEntity()).getEquipment();
|
EntityEquipment enquipment = ((LivingEntity) getDisguise().getEntity()).getEquipment();
|
||||||
if (slot == 0) {
|
if (slot == 0) {
|
||||||
itemStack = enquipment.getItemInHand();
|
itemStack = enquipment.getItemInHand();
|
||||||
} else {
|
} else {
|
||||||
@ -273,11 +278,11 @@ public class FlagWatcher {
|
|||||||
slot = 0;
|
slot = 0;
|
||||||
PacketContainer packet = new PacketContainer(Packets.Server.ENTITY_EQUIPMENT);
|
PacketContainer packet = new PacketContainer(Packets.Server.ENTITY_EQUIPMENT);
|
||||||
StructureModifier<Object> mods = packet.getModifier();
|
StructureModifier<Object> mods = packet.getModifier();
|
||||||
mods.write(0, disguise.getEntity().getEntityId());
|
mods.write(0, getDisguise().getEntity().getEntityId());
|
||||||
mods.write(1, slot);
|
mods.write(1, slot);
|
||||||
mods.write(2, itemToSend);
|
mods.write(2, itemToSend);
|
||||||
for (Player player : disguise.getPerverts()) {
|
for (Player player : getDisguise().getPerverts()) {
|
||||||
if (player != disguise.getEntity()) {
|
if (player != getDisguise().getEntity()) {
|
||||||
try {
|
try {
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
|
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
|
||||||
} catch (InvocationTargetException e) {
|
} catch (InvocationTargetException e) {
|
||||||
@ -312,6 +317,10 @@ public class FlagWatcher {
|
|||||||
sendData(0);
|
sendData(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected Disguise getDisguise() {
|
||||||
|
return disguise;
|
||||||
|
}
|
||||||
|
|
||||||
protected void setValue(int no, Object value) {
|
protected void setValue(int no, Object value) {
|
||||||
entityValues.put(no, value);
|
entityValues.put(no, value);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user