Added new constructor for MiscDisguise, fixed potential issue in packet editing

This commit is contained in:
Andrew 2013-06-05 19:09:41 +12:00
parent d252e5f60f
commit ce9697b1ab
2 changed files with 8 additions and 1 deletions

View File

@ -18,6 +18,10 @@ public class MiscDisguise extends Disguise {
this.data = data; this.data = data;
} }
public MiscDisguise(DisguiseType disguiseType, boolean replaceSounds) {
this(disguiseType, replaceSounds, -1, -1);
}
public MiscDisguise(DisguiseType disguiseType, int id, int data) { public MiscDisguise(DisguiseType disguiseType, int id, int data) {
this(disguiseType, true, id, data); this(disguiseType, true, id, data);
} }

View File

@ -65,7 +65,10 @@ public class LibsDisguises extends JavaPlugin implements Listener {
if (DisguiseAPI.isDisguised(entity)) { if (DisguiseAPI.isDisguised(entity)) {
Disguise disguise = DisguiseAPI.getDisguise(entity); Disguise disguise = DisguiseAPI.getDisguise(entity);
if (event.getPacketID() == Packets.Server.ENTITY_METADATA) { if (event.getPacketID() == Packets.Server.ENTITY_METADATA) {
mods.write(1, disguise.getWatcher().convert((List<WatchableObject>) mods.read(1))); event.setPacket(event.getPacket().deepClone());
mods.write(1,
disguise.getWatcher()
.convert((List<WatchableObject>) event.getPacket().getModifier().read(1)));
} else if (event.getPacketID() == Packets.Server.NAMED_ENTITY_SPAWN) { } else if (event.getPacketID() == Packets.Server.NAMED_ENTITY_SPAWN) {
if (disguise.getType().isPlayer()) { if (disguise.getType().isPlayer()) {
String name = (String) mods.read(1); String name = (String) mods.read(1);