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,
DONKEY,
DRAGON_FIREBALL(93),
DROPPED_ITEM(1, 1),
DROPPED_ITEM(2, 1),
EGG(62),
ELDER_GUARDIAN,
ENDER_CRYSTAL(51),

View File

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

View File

@ -11,12 +11,11 @@ public class DroppedItemWatcher extends FlagWatcher {
}
public ItemStack getItemStack() {
return (ItemStack) getValue(5, new ItemStack(1));
return (ItemStack) getValue(10, new ItemStack(1));
}
public void setItemStack(ItemStack item) {
setValue(5, item);
sendData(5);
setValue(10, item);
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.Disguise;
import org.bukkit.DyeColor;
public class SheepWatcher extends AgeableWatcher {
@ -11,7 +12,7 @@ public class SheepWatcher extends AgeableWatcher {
}
public AnimalColor getColor() {
return AnimalColor.getColor((byte) getValue(12, (byte) 0) & 15);
return AnimalColor.getColor(((int) getValue(12, (byte) 0) & 15));
}
public boolean isSheared() {
@ -19,8 +20,12 @@ public class SheepWatcher extends AgeableWatcher {
}
public void setColor(AnimalColor color) {
setColor(DyeColor.getByWoolData((byte) color.getId()));
}
public void setColor(DyeColor color) {
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);
}

View File

@ -28,11 +28,11 @@ public class TameableWatcher extends AgeableWatcher {
}
protected void setTameableFlag(int no, boolean flag) {
byte b0 = (byte) getValue(12, (byte) 0);
byte value = (byte) getValue(12, (byte) 0);
if (flag) {
setValue(12, (byte) (b0 | no));
setValue(12, (byte) (value | no));
} else {
setValue(12, (byte) (b0 & -(no + 1)));
setValue(12, (byte) (value & -(no + 1)));
}
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.Disguise;
import org.bukkit.DyeColor;
public class WolfWatcher extends TameableWatcher {
@ -47,13 +48,17 @@ public class WolfWatcher extends TameableWatcher {
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()) {
setTamed(true);
}
if (newColor != getCollarColor()) {
setValue(14, (byte) newColor.getId());
sendData(14);
if (newColor.getWoolData() != getCollarColor().getId()) {
setValue(16, (int) newColor.getDyeData());
sendData(16);
}
}

View File

@ -1305,10 +1305,7 @@ public class PacketsManager {
// Else if the packet is sending entity metadata
else if (sentPacket.getType() == Server.ENTITY_METADATA) {
if (DisguiseConfig.isMetadataPacketsEnabled() && (disguise.getType() != DisguiseType.WOLF &&
disguise.getType() != DisguiseType.OCELOT &&
disguise.getType() != DisguiseType.ENDERMAN &&
disguise.getType() != DisguiseType.SHULKER)) {
if (DisguiseConfig.isMetadataPacketsEnabled() && !isStaticMetadataDisguiseType(disguise)) {
List<WrappedWatchableObject> watchableObjects = disguise.getWatcher().convert(
packets[0].getWatchableCollectionModifier().read(0));
packets[0] = new PacketContainer(sentPacket.getType());
@ -1420,10 +1417,7 @@ public class PacketsManager {
if (heldItem != null && heldItem.getType() != Material.AIR) {
// Convert the datawatcher
List<WrappedWatchableObject> list = new ArrayList<>();
if (DisguiseConfig.isMetadataPacketsEnabled() && (disguise.getType() != DisguiseType.WOLF &&
disguise.getType() != DisguiseType.OCELOT &&
disguise.getType() != DisguiseType.ENDERMAN &&
disguise.getType() != DisguiseType.SHULKER)) {
if (DisguiseConfig.isMetadataPacketsEnabled() && !isStaticMetadataDisguiseType(disguise)) {
WrappedWatchableObject watch = new WrappedWatchableObject(ReflectionManager.createDataWatcherItem(0,
WrappedDataWatcher.getEntityWatcher(entity).getByte(0)));
list.add(watch);
@ -1498,4 +1492,19 @@ public class PacketsManager {
}
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
main: me.libraryaddict.disguise.LibsDisguises
description: A disguise plugin with various disguises.
version: 9.0
version: 9.0.1
author: libraryaddict
authors: [Byteflux, Navid K.]
softdepend: [ProtocolLib]