Fixed DroppedItem disguise

Fixed Fireworks disguise
Fixed SplashPotion disguise
Fixed Sheep disguise colors
Fixed Wolf disguise colors
Fixed error with isGlowing in FlagWatcher
This commit is contained in:
NavidK0 2016-03-20 23:29:48 -04:00
parent 12ea8ee35e
commit ed1bcc5ad9
8 changed files with 46 additions and 30 deletions

View File

@ -24,7 +24,7 @@ public enum DisguiseType {
CREEPER, CREEPER,
DONKEY, DONKEY,
DRAGON_FIREBALL(93), DRAGON_FIREBALL(93),
DROPPED_ITEM(1, 1), DROPPED_ITEM(2, 1),
EGG(62), EGG(62),
ELDER_GUARDIAN, ELDER_GUARDIAN,
ENDER_CRYSTAL(51), ENDER_CRYSTAL(51),

View File

@ -9,6 +9,7 @@ import com.comphenix.protocol.wrappers.WrappedWatchableObject;
import me.libraryaddict.disguise.DisguiseAPI; import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.DisguiseConfig; import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.utilities.DisguiseUtilities; import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utilities.PacketsManager;
import me.libraryaddict.disguise.utilities.ReflectionManager; import me.libraryaddict.disguise.utilities.ReflectionManager;
import org.bukkit.entity.LivingEntity; import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player; import org.bukkit.entity.Player;
@ -226,11 +227,11 @@ public class FlagWatcher {
return getEntityFlag(5); return getEntityFlag(5);
} }
public boolean isFlyingWithElytra() { public boolean isGlowing() {
return getEntityFlag(6); return getEntityFlag(6);
} }
public boolean isGlowing() { public boolean isFlyingWithElytra() {
return getEntityFlag(7); return getEntityFlag(7);
} }
@ -260,10 +261,7 @@ public class FlagWatcher {
} }
Object value = entityValues.get(data); Object value = entityValues.get(data);
if (isEntityAnimationsAdded() && DisguiseConfig.isMetadataPacketsEnabled() && data == 0) { if (isEntityAnimationsAdded() && DisguiseConfig.isMetadataPacketsEnabled() && data == 0) {
if (disguise.getType() != DisguiseType.WOLF && if (!PacketsManager.isStaticMetadataDisguiseType(disguise))
disguise.getType() != DisguiseType.OCELOT &&
disguise.getType() != DisguiseType.ENDERMAN &&
disguise.getType() != DisguiseType.SHULKER)
value = addEntityAnimations((byte) value, WrappedDataWatcher.getEntityWatcher(disguise.getEntity()).getByte(0)); value = addEntityAnimations((byte) value, WrappedDataWatcher.getEntityWatcher(disguise.getEntity()).getByte(0));
} }
WrappedWatchableObject watch = new WrappedWatchableObject(ReflectionManager.createDataWatcherItem(data, value)); WrappedWatchableObject watch = new WrappedWatchableObject(ReflectionManager.createDataWatcherItem(data, value));

View File

@ -11,12 +11,11 @@ public class DroppedItemWatcher extends FlagWatcher {
} }
public ItemStack getItemStack() { public ItemStack getItemStack() {
return (ItemStack) getValue(5, new ItemStack(1)); return (ItemStack) getValue(10, new ItemStack(1));
} }
public void setItemStack(ItemStack item) { public void setItemStack(ItemStack item) {
setValue(5, item); setValue(10, item);
sendData(5); sendData(10);
} }
} }

View File

@ -2,6 +2,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers;
import me.libraryaddict.disguise.disguisetypes.AnimalColor; import me.libraryaddict.disguise.disguisetypes.AnimalColor;
import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.Disguise;
import org.bukkit.DyeColor;
public class SheepWatcher extends AgeableWatcher { public class SheepWatcher extends AgeableWatcher {
@ -11,7 +12,7 @@ public class SheepWatcher extends AgeableWatcher {
} }
public AnimalColor getColor() { public AnimalColor getColor() {
return AnimalColor.getColor((byte) getValue(12, (byte) 0) & 15); return AnimalColor.getColor(((int) getValue(12, (byte) 0) & 15));
} }
public boolean isSheared() { public boolean isSheared() {
@ -19,8 +20,12 @@ public class SheepWatcher extends AgeableWatcher {
} }
public void setColor(AnimalColor color) { public void setColor(AnimalColor color) {
setColor(DyeColor.getByWoolData((byte) color.getId()));
}
public void setColor(DyeColor color) {
byte b0 = (byte) getValue(12, (byte) 0); byte b0 = (byte) getValue(12, (byte) 0);
setValue(12, (byte) (b0 & 240 | color.getId() & 15)); setValue(12, (byte) (b0 & 240 | color.getWoolData() & 15));
sendData(12); sendData(12);
} }

View File

@ -28,11 +28,11 @@ public class TameableWatcher extends AgeableWatcher {
} }
protected void setTameableFlag(int no, boolean flag) { protected void setTameableFlag(int no, boolean flag) {
byte b0 = (byte) getValue(12, (byte) 0); byte value = (byte) getValue(12, (byte) 0);
if (flag) { if (flag) {
setValue(12, (byte) (b0 | no)); setValue(12, (byte) (value | no));
} else { } else {
setValue(12, (byte) (b0 & -(no + 1))); setValue(12, (byte) (value & -(no + 1)));
} }
sendData(12); sendData(12);
} }

View File

@ -2,6 +2,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers;
import me.libraryaddict.disguise.disguisetypes.AnimalColor; import me.libraryaddict.disguise.disguisetypes.AnimalColor;
import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.Disguise;
import org.bukkit.DyeColor;
public class WolfWatcher extends TameableWatcher { public class WolfWatcher extends TameableWatcher {
@ -47,13 +48,17 @@ public class WolfWatcher extends TameableWatcher {
setTameableFlag(2, angry); setTameableFlag(2, angry);
} }
public void setCollarColor(AnimalColor newColor) { public void setCollarColor(AnimalColor color) {
setCollarColor(DyeColor.getByWoolData((byte) color.getId()));
}
public void setCollarColor(DyeColor newColor) {
if (!isTamed()) { if (!isTamed()) {
setTamed(true); setTamed(true);
} }
if (newColor != getCollarColor()) { if (newColor.getWoolData() != getCollarColor().getId()) {
setValue(14, (byte) newColor.getId()); setValue(16, (int) newColor.getDyeData());
sendData(14); sendData(16);
} }
} }

View File

@ -1305,10 +1305,7 @@ public class PacketsManager {
// Else if the packet is sending entity metadata // Else if the packet is sending entity metadata
else if (sentPacket.getType() == Server.ENTITY_METADATA) { else if (sentPacket.getType() == Server.ENTITY_METADATA) {
if (DisguiseConfig.isMetadataPacketsEnabled() && (disguise.getType() != DisguiseType.WOLF && if (DisguiseConfig.isMetadataPacketsEnabled() && !isStaticMetadataDisguiseType(disguise)) {
disguise.getType() != DisguiseType.OCELOT &&
disguise.getType() != DisguiseType.ENDERMAN &&
disguise.getType() != DisguiseType.SHULKER)) {
List<WrappedWatchableObject> watchableObjects = disguise.getWatcher().convert( List<WrappedWatchableObject> watchableObjects = disguise.getWatcher().convert(
packets[0].getWatchableCollectionModifier().read(0)); packets[0].getWatchableCollectionModifier().read(0));
packets[0] = new PacketContainer(sentPacket.getType()); packets[0] = new PacketContainer(sentPacket.getType());
@ -1420,10 +1417,7 @@ public class PacketsManager {
if (heldItem != null && heldItem.getType() != Material.AIR) { if (heldItem != null && heldItem.getType() != Material.AIR) {
// Convert the datawatcher // Convert the datawatcher
List<WrappedWatchableObject> list = new ArrayList<>(); List<WrappedWatchableObject> list = new ArrayList<>();
if (DisguiseConfig.isMetadataPacketsEnabled() && (disguise.getType() != DisguiseType.WOLF && if (DisguiseConfig.isMetadataPacketsEnabled() && !isStaticMetadataDisguiseType(disguise)) {
disguise.getType() != DisguiseType.OCELOT &&
disguise.getType() != DisguiseType.ENDERMAN &&
disguise.getType() != DisguiseType.SHULKER)) {
WrappedWatchableObject watch = new WrappedWatchableObject(ReflectionManager.createDataWatcherItem(0, WrappedWatchableObject watch = new WrappedWatchableObject(ReflectionManager.createDataWatcherItem(0,
WrappedDataWatcher.getEntityWatcher(entity).getByte(0))); WrappedDataWatcher.getEntityWatcher(entity).getByte(0)));
list.add(watch); list.add(watch);
@ -1498,4 +1492,19 @@ public class PacketsManager {
} }
return packets == null ? null : new PacketContainer[][]{packets, delayedPackets}; return packets == null ? null : new PacketContainer[][]{packets, delayedPackets};
} }
/**
* Returns true if this disguise type doesn't have changing metadata.
* @param disguise
* @return
*/
public static boolean isStaticMetadataDisguiseType(Disguise disguise) {
return (disguise.getType() == DisguiseType.WOLF ||
disguise.getType() == DisguiseType.OCELOT ||
disguise.getType() == DisguiseType.ENDERMAN ||
disguise.getType() == DisguiseType.SHULKER ||
disguise.getType() == DisguiseType.SPLASH_POTION ||
disguise.getType() == DisguiseType.FIREWORK ||
disguise.getType() == DisguiseType.DROPPED_ITEM);
}
} }

View File

@ -1,7 +1,7 @@
name: LibsDisguises name: LibsDisguises
main: me.libraryaddict.disguise.LibsDisguises main: me.libraryaddict.disguise.LibsDisguises
description: A disguise plugin with various disguises. description: A disguise plugin with various disguises.
version: 9.0 version: 9.0.1
author: libraryaddict author: libraryaddict
authors: [Byteflux, Navid K.] authors: [Byteflux, Navid K.]
softdepend: [ProtocolLib] softdepend: [ProtocolLib]