Added new entities to DisguiseType
Changed entity Ids to reflect new entity Ids in Spigot 1.9 Cleaned up code
This commit is contained in:
parent
9847ff035a
commit
50623a9be2
@ -9,7 +9,7 @@ println 'Compiling LibsDisguises via Gradle ver. ' + gradle.gradleVersion
|
|||||||
sourceCompatibility = '1.7'
|
sourceCompatibility = '1.7'
|
||||||
ext.spigotVersion = '1.8.8-R0.1-SNAPSHOT'
|
ext.spigotVersion = '1.8.8-R0.1-SNAPSHOT'
|
||||||
|
|
||||||
ext.disguisesVersion = '8.6.8'
|
ext.disguisesVersion = '9.0.0'
|
||||||
|
|
||||||
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
|
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'
|
||||||
|
|
||||||
|
@ -63,7 +63,7 @@ public abstract class Disguise {
|
|||||||
/**
|
/**
|
||||||
* Seems I do this method so I can make cleaner constructors on disguises..
|
* Seems I do this method so I can make cleaner constructors on disguises..
|
||||||
*
|
*
|
||||||
* @param newType
|
* @param newType The disguise
|
||||||
*/
|
*/
|
||||||
protected void createDisguise(DisguiseType newType) {
|
protected void createDisguise(DisguiseType newType) {
|
||||||
if (getWatcher() != null) {
|
if (getWatcher() != null) {
|
||||||
@ -73,7 +73,7 @@ public abstract class Disguise {
|
|||||||
throw new RuntimeException(
|
throw new RuntimeException(
|
||||||
"DisguiseType "
|
"DisguiseType "
|
||||||
+ newType
|
+ newType
|
||||||
+ " was used in a futile attempt to construct a disguise, but this version of craftbukkit does not have that entity");
|
+ " was used in a futile attempt to construct a disguise, but this version of Spigot does not have that entity");
|
||||||
}
|
}
|
||||||
// Set the disguise type
|
// Set the disguise type
|
||||||
disguiseType = newType;
|
disguiseType = newType;
|
||||||
@ -103,7 +103,7 @@ public abstract class Disguise {
|
|||||||
else if (getType() == DisguiseType.ZOMBIE_VILLAGER) {
|
else if (getType() == DisguiseType.ZOMBIE_VILLAGER) {
|
||||||
getWatcher().setValue(13, (byte) 1);
|
getWatcher().setValue(13, (byte) 1);
|
||||||
} else if (getType() == DisguiseType.ELDER_GUARDIAN) {
|
} else if (getType() == DisguiseType.ELDER_GUARDIAN) {
|
||||||
getWatcher().setValue(16, 0 | 4);
|
getWatcher().setValue(16, 4);
|
||||||
} // Else if its a horse. Set the horse watcher type
|
} // Else if its a horse. Set the horse watcher type
|
||||||
else if (getWatcher() instanceof HorseWatcher) {
|
else if (getWatcher() instanceof HorseWatcher) {
|
||||||
try {
|
try {
|
||||||
@ -325,7 +325,7 @@ public abstract class Disguise {
|
|||||||
/**
|
/**
|
||||||
* Get the disguised entity
|
* Get the disguised entity
|
||||||
*
|
*
|
||||||
* @return
|
* @return entity
|
||||||
*/
|
*/
|
||||||
public Entity getEntity() {
|
public Entity getEntity() {
|
||||||
return entity;
|
return entity;
|
||||||
@ -334,7 +334,7 @@ public abstract class Disguise {
|
|||||||
/**
|
/**
|
||||||
* Get the disguise type
|
* Get the disguise type
|
||||||
*
|
*
|
||||||
* @return
|
* @return disguiseType
|
||||||
*/
|
*/
|
||||||
public DisguiseType getType() {
|
public DisguiseType getType() {
|
||||||
return disguiseType;
|
return disguiseType;
|
||||||
@ -343,7 +343,7 @@ public abstract class Disguise {
|
|||||||
/**
|
/**
|
||||||
* Get the flag watcher
|
* Get the flag watcher
|
||||||
*
|
*
|
||||||
* @return
|
* @return flagWatcher
|
||||||
*/
|
*/
|
||||||
public FlagWatcher getWatcher() {
|
public FlagWatcher getWatcher() {
|
||||||
return watcher;
|
return watcher;
|
||||||
@ -352,7 +352,7 @@ public abstract class Disguise {
|
|||||||
/**
|
/**
|
||||||
* In use doesn't mean that this disguise is active. It means that Lib's Disguises still stores a reference to the disguise. getEntity() can still return null if this disguise is active after despawn, logout, etc.
|
* In use doesn't mean that this disguise is active. It means that Lib's Disguises still stores a reference to the disguise. getEntity() can still return null if this disguise is active after despawn, logout, etc.
|
||||||
*
|
*
|
||||||
* @return
|
* @return isDisguiseInUse
|
||||||
*/
|
*/
|
||||||
public boolean isDisguiseInUse() {
|
public boolean isDisguiseInUse() {
|
||||||
return disguiseInUse;
|
return disguiseInUse;
|
||||||
@ -396,16 +396,9 @@ public abstract class Disguise {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* Internal use
|
* Internal use
|
||||||
*
|
|
||||||
* @return
|
|
||||||
*/
|
*/
|
||||||
public boolean isRemoveDisguiseOnDeath() {
|
public boolean isRemoveDisguiseOnDeath() {
|
||||||
if (getEntity() == null) {
|
return getEntity() == null || (getEntity() instanceof Player ? (!((Player) getEntity()).isOnline() ? !isKeepDisguiseOnPlayerLogout() : !isKeepDisguiseOnPlayerDeath()) : (!isKeepDisguiseOnEntityDespawn() || getEntity().isDead()));
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return getEntity() instanceof Player
|
|
||||||
? (!((Player) getEntity()).isOnline() ? !isKeepDisguiseOnPlayerLogout() : !isKeepDisguiseOnPlayerDeath())
|
|
||||||
: (!isKeepDisguiseOnEntityDespawn() || getEntity().isDead());
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSelfDisguiseSoundsReplaced() {
|
public boolean isSelfDisguiseSoundsReplaced() {
|
||||||
@ -415,7 +408,7 @@ public abstract class Disguise {
|
|||||||
/**
|
/**
|
||||||
* Can the disguised view himself as the disguise
|
* Can the disguised view himself as the disguise
|
||||||
*
|
*
|
||||||
* @return
|
* @return viewSelfDisguise
|
||||||
*/
|
*/
|
||||||
public boolean isSelfDisguiseVisible() {
|
public boolean isSelfDisguiseVisible() {
|
||||||
return viewSelfDisguise;
|
return viewSelfDisguise;
|
||||||
@ -441,7 +434,7 @@ public abstract class Disguise {
|
|||||||
/**
|
/**
|
||||||
* Removes the disguise and undisguises the entity if its using this disguise.
|
* Removes the disguise and undisguises the entity if its using this disguise.
|
||||||
*
|
*
|
||||||
* @return
|
* @return removeDiguise
|
||||||
*/
|
*/
|
||||||
public boolean removeDisguise() {
|
public boolean removeDisguise() {
|
||||||
if (disguiseInUse) {
|
if (disguiseInUse) {
|
||||||
@ -505,7 +498,7 @@ public abstract class Disguise {
|
|||||||
* Set the entity of the disguise. Only used for internal things.
|
* Set the entity of the disguise. Only used for internal things.
|
||||||
*
|
*
|
||||||
* @param entity
|
* @param entity
|
||||||
* @return
|
* @return disguise
|
||||||
*/
|
*/
|
||||||
public Disguise setEntity(Entity entity) {
|
public Disguise setEntity(Entity entity) {
|
||||||
if (this.getEntity() != null) {
|
if (this.getEntity() != null) {
|
||||||
|
@ -12,6 +12,7 @@ import java.lang.reflect.Method;
|
|||||||
|
|
||||||
public enum DisguiseType {
|
public enum DisguiseType {
|
||||||
|
|
||||||
|
AREA_EFFECT_CLOUD, //Disguising as this would be something else.
|
||||||
ARMOR_STAND(78),
|
ARMOR_STAND(78),
|
||||||
ARROW(60),
|
ARROW(60),
|
||||||
BAT,
|
BAT,
|
||||||
@ -22,8 +23,9 @@ public enum DisguiseType {
|
|||||||
COW,
|
COW,
|
||||||
CREEPER,
|
CREEPER,
|
||||||
DONKEY,
|
DONKEY,
|
||||||
DROPPED_ITEM(2, 1),
|
DRAGON_FIREBALL(26),
|
||||||
EGG(62),
|
DROPPED_ITEM(-1, 1),
|
||||||
|
EGG,
|
||||||
ELDER_GUARDIAN,
|
ELDER_GUARDIAN,
|
||||||
ENDER_CRYSTAL(51),
|
ENDER_CRYSTAL(51),
|
||||||
ENDER_DRAGON,
|
ENDER_DRAGON,
|
||||||
@ -35,7 +37,7 @@ public enum DisguiseType {
|
|||||||
FALLING_BLOCK(70, 1),
|
FALLING_BLOCK(70, 1),
|
||||||
FIREBALL(63, 0),
|
FIREBALL(63, 0),
|
||||||
FIREWORK(76),
|
FIREWORK(76),
|
||||||
FISHING_HOOK(90),
|
FISHING_HOOK,
|
||||||
GHAST,
|
GHAST,
|
||||||
GIANT,
|
GIANT,
|
||||||
GUARDIAN,
|
GUARDIAN,
|
||||||
@ -43,6 +45,7 @@ public enum DisguiseType {
|
|||||||
IRON_GOLEM,
|
IRON_GOLEM,
|
||||||
ITEM_FRAME(71),
|
ITEM_FRAME(71),
|
||||||
LEASH_HITCH(77),
|
LEASH_HITCH(77),
|
||||||
|
LIGHTING,
|
||||||
MAGMA_CUBE,
|
MAGMA_CUBE,
|
||||||
MINECART(10, 0),
|
MINECART(10, 0),
|
||||||
MINECART_CHEST(10, 1),
|
MINECART_CHEST(10, 1),
|
||||||
@ -61,6 +64,8 @@ public enum DisguiseType {
|
|||||||
PRIMED_TNT(50),
|
PRIMED_TNT(50),
|
||||||
RABBIT,
|
RABBIT,
|
||||||
SHEEP,
|
SHEEP,
|
||||||
|
SHULKER,
|
||||||
|
SHULKER_BULLET(25),
|
||||||
SILVERFISH,
|
SILVERFISH,
|
||||||
SKELETON,
|
SKELETON,
|
||||||
SKELETON_HORSE,
|
SKELETON_HORSE,
|
||||||
@ -68,12 +73,15 @@ public enum DisguiseType {
|
|||||||
SMALL_FIREBALL(64, 0),
|
SMALL_FIREBALL(64, 0),
|
||||||
SNOWBALL(61),
|
SNOWBALL(61),
|
||||||
SNOWMAN,
|
SNOWMAN,
|
||||||
|
SPECTRAL_ARROW(24),
|
||||||
SPIDER,
|
SPIDER,
|
||||||
SPLASH_POTION(73),
|
SPLASH_POTION(-1),
|
||||||
SQUID,
|
SQUID,
|
||||||
|
TIPPED_ARROW(23),
|
||||||
THROWN_EXP_BOTTLE(75),
|
THROWN_EXP_BOTTLE(75),
|
||||||
UNDEAD_HORSE,
|
UNDEAD_HORSE,
|
||||||
VILLAGER,
|
VILLAGER,
|
||||||
|
WEATHER,
|
||||||
WITCH,
|
WITCH,
|
||||||
WITHER,
|
WITHER,
|
||||||
WITHER_SKELETON,
|
WITHER_SKELETON,
|
||||||
@ -116,7 +124,7 @@ public enum DisguiseType {
|
|||||||
}
|
}
|
||||||
type.setEntityType(EntityType.valueOf(toUse.name()));
|
type.setEntityType(EntityType.valueOf(toUse.name()));
|
||||||
} catch (Throwable ex) {
|
} catch (Throwable ex) {
|
||||||
// This version of craftbukkit doesn't have the disguise.
|
// This version of Spigot doesn't have the disguise.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
|
@ -75,7 +75,7 @@ public class FlagWatcher {
|
|||||||
}
|
}
|
||||||
cloned.entityValues = (HashMap<Integer, Object>) entityValues.clone();
|
cloned.entityValues = (HashMap<Integer, Object>) entityValues.clone();
|
||||||
cloned.items = items.clone();
|
cloned.items = items.clone();
|
||||||
cloned.modifiedEntityAnimations = (HashSet) modifiedEntityAnimations.clone();
|
cloned.modifiedEntityAnimations = (HashSet<Integer>) modifiedEntityAnimations.clone();
|
||||||
cloned.addEntityAnimations = addEntityAnimations;
|
cloned.addEntityAnimations = addEntityAnimations;
|
||||||
return cloned;
|
return cloned;
|
||||||
}
|
}
|
||||||
@ -106,7 +106,7 @@ public class FlagWatcher {
|
|||||||
}
|
}
|
||||||
if (value != null) {
|
if (value != null) {
|
||||||
if (isEntityAnimationsAdded() && dataType == 0) {
|
if (isEntityAnimationsAdded() && dataType == 0) {
|
||||||
value = this.addEntityAnimations((Byte) value, (Byte) watch.getValue());
|
value = this.addEntityAnimations((byte) value, (byte) watch.getValue());
|
||||||
}
|
}
|
||||||
boolean isDirty = watch.getDirtyState();
|
boolean isDirty = watch.getDirtyState();
|
||||||
watch = new WrappedWatchableObject(dataType, value);
|
watch = new WrappedWatchableObject(dataType, value);
|
||||||
@ -173,7 +173,7 @@ public class FlagWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean getFlag(int byteValue) {
|
private boolean getFlag(int byteValue) {
|
||||||
return ((Byte) getValue(0, (byte) 0) & 1 << byteValue) != 0;
|
return ((byte) getValue(0, (byte) 0) & 1 << byteValue) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getItemInHand() {
|
public ItemStack getItemInHand() {
|
||||||
@ -264,7 +264,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) {
|
||||||
value = addEntityAnimations((Byte) value, WrappedDataWatcher.getEntityWatcher(disguise.getEntity()).getByte(0));
|
value = addEntityAnimations((byte) value, WrappedDataWatcher.getEntityWatcher(disguise.getEntity()).getByte(0));
|
||||||
}
|
}
|
||||||
list.add(new WrappedWatchableObject(data, value));
|
list.add(new WrappedWatchableObject(data, value));
|
||||||
}
|
}
|
||||||
@ -317,7 +317,7 @@ public class FlagWatcher {
|
|||||||
|
|
||||||
private void setFlag(int byteValue, boolean flag) {
|
private void setFlag(int byteValue, boolean flag) {
|
||||||
modifiedEntityAnimations.add(byteValue);
|
modifiedEntityAnimations.add(byteValue);
|
||||||
byte b0 = (Byte) getValue(0, (byte) 0);
|
byte b0 = (byte) getValue(0, (byte) 0);
|
||||||
if (flag) {
|
if (flag) {
|
||||||
setValue(0, (byte) (b0 | 1 << byteValue));
|
setValue(0, (byte) (b0 | 1 << byteValue));
|
||||||
} else {
|
} else {
|
||||||
|
@ -17,7 +17,7 @@ public class AgeableWatcher extends LivingWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBaby() {
|
public boolean isBaby() {
|
||||||
return ((Byte) getValue(12, (byte) 0)).intValue() < 0;
|
return ((byte) getValue(12, (byte) 0)) < 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAdult() {
|
public void setAdult() {
|
||||||
|
@ -9,7 +9,7 @@ public class ArmorStandWatcher extends LivingWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean get10(int value) {
|
private boolean get10(int value) {
|
||||||
return ((Byte) getValue(10, 0) & value) != 0;
|
return ((byte) getValue(10, 0) & value) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNoBasePlate() {
|
public boolean isNoBasePlate() {
|
||||||
@ -29,7 +29,7 @@ public class ArmorStandWatcher extends LivingWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void set10(int value, boolean isTrue) {
|
private void set10(int value, boolean isTrue) {
|
||||||
byte b1 = (Byte) getValue(10, (byte) 0);
|
byte b1 = (byte) getValue(10, (byte) 0);
|
||||||
if (isTrue) {
|
if (isTrue) {
|
||||||
b1 = (byte) (b1 | value);
|
b1 = (byte) (b1 | value);
|
||||||
} else {
|
} else {
|
||||||
|
@ -10,7 +10,7 @@ public class ArrowWatcher extends FlagWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCritical() {
|
public boolean isCritical() {
|
||||||
return (Byte) getValue(16, (byte) 0) == 1;
|
return (byte) getValue(16, (byte) 0) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCritical(boolean critical) {
|
public void setCritical(boolean critical) {
|
||||||
|
@ -10,7 +10,7 @@ public class BatWatcher extends LivingWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFlying() {
|
public boolean isFlying() {
|
||||||
return (Byte) getValue(16, (byte) 1) == 0;
|
return (byte) getValue(16, (byte) 1) == 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFlying(boolean flying) {
|
public void setFlying(boolean flying) {
|
||||||
|
@ -9,7 +9,7 @@ public class BlazeWatcher extends LivingWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBlazing() {
|
public boolean isBlazing() {
|
||||||
return (Byte) getValue(16, (byte) 0) == 1;
|
return (byte) getValue(16, (byte) 0) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBlazing(boolean isBlazing) {
|
public void setBlazing(boolean isBlazing) {
|
||||||
|
@ -9,11 +9,11 @@ public class CreeperWatcher extends LivingWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIgnited() {
|
public boolean isIgnited() {
|
||||||
return (Byte) getValue(18, (byte) 0) == 1;
|
return (byte) getValue(18, (byte) 0) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPowered() {
|
public boolean isPowered() {
|
||||||
return (Byte) getValue(17, (byte) 0) == 1;
|
return (byte) getValue(17, (byte) 0) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIgnited(boolean ignited) {
|
public void setIgnited(boolean ignited) {
|
||||||
|
@ -1,8 +1,7 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class EndermanWatcher extends LivingWatcher {
|
public class EndermanWatcher extends LivingWatcher {
|
||||||
|
|
||||||
@ -12,11 +11,11 @@ public class EndermanWatcher extends LivingWatcher {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItemInHand() {
|
public ItemStack getItemInHand() {
|
||||||
return new ItemStack((Byte) getValue(16, (byte) 0), 1, ((Byte) getValue(17, (byte) 0)));
|
return new ItemStack((byte) getValue(16, (byte) 0), 1, ((byte) getValue(17, (byte) 0)));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAggressive() {
|
public boolean isAggressive() {
|
||||||
return (Byte) getValue(18, (byte) 0) == 1;
|
return (byte) getValue(18, (byte) 0) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
|
@ -9,7 +9,7 @@ public class GhastWatcher extends LivingWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAggressive() {
|
public boolean isAggressive() {
|
||||||
return (Byte) getValue(16, (byte) 0) == 1;
|
return (byte) getValue(16, (byte) 0) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAggressive(boolean isAggressive) {
|
public void setAggressive(boolean isAggressive) {
|
||||||
|
@ -1,26 +1,24 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
import java.lang.reflect.InvocationTargetException;
|
|
||||||
import java.lang.reflect.Method;
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashSet;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
|
||||||
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
|
||||||
|
|
||||||
import org.bukkit.entity.Entity;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
import org.bukkit.potion.PotionEffectType;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.wrappers.WrappedAttribute;
|
import com.comphenix.protocol.wrappers.WrappedAttribute;
|
||||||
import com.comphenix.protocol.wrappers.WrappedAttribute.Builder;
|
import com.comphenix.protocol.wrappers.WrappedAttribute.Builder;
|
||||||
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||||
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
|
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.potion.PotionEffectType;
|
||||||
|
|
||||||
|
import java.lang.reflect.InvocationTargetException;
|
||||||
|
import java.lang.reflect.Method;
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashSet;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
public class LivingWatcher extends FlagWatcher {
|
public class LivingWatcher extends FlagWatcher {
|
||||||
|
|
||||||
@ -80,7 +78,7 @@ public class LivingWatcher extends FlagWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean getPotionParticlesRemoved() {
|
public boolean getPotionParticlesRemoved() {
|
||||||
return (Byte) getValue(8, (byte) 0) == 1;
|
return (byte) getValue(8, (byte) 0) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getPotions() {
|
private int getPotions() {
|
||||||
@ -99,7 +97,7 @@ public class LivingWatcher extends FlagWatcher {
|
|||||||
int n = (Integer) potionNo.invoke(list[localMobEffect]);
|
int n = (Integer) potionNo.invoke(list[localMobEffect]);
|
||||||
f1 += (n >> 16 & 0xFF) / 255.0F;
|
f1 += (n >> 16 & 0xFF) / 255.0F;
|
||||||
f2 += (n >> 8 & 0xFF) / 255.0F;
|
f2 += (n >> 8 & 0xFF) / 255.0F;
|
||||||
f3 += (n >> 0 & 0xFF) / 255.0F;
|
f3 += (n & 0xFF) / 255.0F;
|
||||||
f4 += 1.0F;
|
f4 += 1.0F;
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
@ -30,7 +30,7 @@ public class MinecartWatcher extends FlagWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean getViewBlockInCart() {
|
public boolean getViewBlockInCart() {
|
||||||
return ((Byte) getValue(22, (byte) 0)) == (byte) 1;
|
return ((byte) getValue(22, (byte) 0)) == (byte) 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBlockInCart(ItemStack item) {
|
public void setBlockInCart(ItemStack item) {
|
||||||
|
@ -1,7 +1,6 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
|
||||||
import org.bukkit.entity.Ocelot;
|
import org.bukkit.entity.Ocelot;
|
||||||
import org.bukkit.entity.Ocelot.Type;
|
import org.bukkit.entity.Ocelot.Type;
|
||||||
|
|
||||||
@ -12,7 +11,7 @@ public class OcelotWatcher extends TameableWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Type getType() {
|
public Type getType() {
|
||||||
return Ocelot.Type.getType((Byte) getValue(18, (byte) 0));
|
return Ocelot.Type.getType((byte) getValue(18, (byte) 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(Type newType) {
|
public void setType(Type newType) {
|
||||||
|
@ -9,7 +9,7 @@ public class PigWatcher extends AgeableWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSaddled() {
|
public boolean isSaddled() {
|
||||||
return (Byte) getValue(16, (byte) 0) == 1;
|
return (byte) getValue(16, (byte) 0) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSaddled(boolean isSaddled) {
|
public void setSaddled(boolean isSaddled) {
|
||||||
|
@ -1,19 +1,16 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
import org.bukkit.block.BlockFace;
|
|
||||||
import org.bukkit.entity.Player;
|
|
||||||
|
|
||||||
import com.comphenix.protocol.PacketType;
|
import com.comphenix.protocol.PacketType;
|
||||||
import com.comphenix.protocol.ProtocolLibrary;
|
import com.comphenix.protocol.ProtocolLibrary;
|
||||||
import com.comphenix.protocol.events.PacketContainer;
|
import com.comphenix.protocol.events.PacketContainer;
|
||||||
import com.comphenix.protocol.reflect.StructureModifier;
|
import com.comphenix.protocol.reflect.StructureModifier;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.DisguiseConfig;
|
import me.libraryaddict.disguise.DisguiseConfig;
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
|
import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
import me.libraryaddict.disguise.utilities.ReflectionManager.LibVersion;
|
import org.bukkit.block.BlockFace;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class PlayerWatcher extends LivingWatcher {
|
public class PlayerWatcher extends LivingWatcher {
|
||||||
|
|
||||||
@ -32,7 +29,7 @@ public class PlayerWatcher extends LivingWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getArrowsSticking() {
|
public int getArrowsSticking() {
|
||||||
return (Byte) getValue(9, (byte) 0);
|
return (byte) getValue(9, (byte) 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockFace getSleepingDirection() {
|
public BlockFace getSleepingDirection() {
|
||||||
@ -48,7 +45,7 @@ public class PlayerWatcher extends LivingWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private boolean getValue16(int i) {
|
private boolean getValue16(int i) {
|
||||||
return ((Byte) getValue(16, (byte) 0) & 1 << i) != 0;
|
return ((byte) getValue(16, (byte) 0) & 1 << i) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isHideCape() {
|
public boolean isHideCape() {
|
||||||
@ -129,11 +126,11 @@ public class PlayerWatcher extends LivingWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private void setValue16(int i, boolean flag) {
|
private void setValue16(int i, boolean flag) {
|
||||||
byte b0 = (Byte) getValue(16, (byte) 0);
|
byte b0 = (byte) getValue(16, (byte) 0);
|
||||||
if (flag) {
|
if (flag) {
|
||||||
setValue(16, (byte) (b0 | 1 << i));
|
setValue(16, (byte) (b0 | 1 << i));
|
||||||
} else {
|
} else {
|
||||||
setValue(16, (byte) (b0 & (1 << i ^ 0xFFFFFFFF)));
|
setValue(16, (byte) (b0 & (~1 << i)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -11,21 +11,21 @@ public class SheepWatcher extends AgeableWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public AnimalColor getColor() {
|
public AnimalColor getColor() {
|
||||||
return AnimalColor.getColor((Byte) getValue(16, (byte) 0) & 15);
|
return AnimalColor.getColor((byte) getValue(16, (byte) 0) & 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSheared() {
|
public boolean isSheared() {
|
||||||
return ((Byte) getValue(16, (byte) 0) & 16) != 0;
|
return ((byte) getValue(16, (byte) 0) & 16) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setColor(AnimalColor color) {
|
public void setColor(AnimalColor color) {
|
||||||
byte b0 = (Byte) getValue(16, (byte) 0);
|
byte b0 = (byte) getValue(16, (byte) 0);
|
||||||
setValue(16, (byte) (b0 & 240 | color.getId() & 15));
|
setValue(16, (byte) (b0 & 240 | color.getId() & 15));
|
||||||
sendData(16);
|
sendData(16);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSheared(boolean flag) {
|
public void setSheared(boolean flag) {
|
||||||
byte b0 = (Byte) getValue(16, (byte) 0);
|
byte b0 = (byte) getValue(16, (byte) 0);
|
||||||
if (flag) {
|
if (flag) {
|
||||||
setValue(16, (byte) (b0 | 16));
|
setValue(16, (byte) (b0 | 16));
|
||||||
} else {
|
} else {
|
||||||
|
@ -1,9 +1,9 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
import java.util.Random;
|
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
public class SlimeWatcher extends LivingWatcher {
|
public class SlimeWatcher extends LivingWatcher {
|
||||||
|
|
||||||
public SlimeWatcher(Disguise disguise) {
|
public SlimeWatcher(Disguise disguise) {
|
||||||
@ -12,7 +12,7 @@ public class SlimeWatcher extends LivingWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getSize() {
|
public int getSize() {
|
||||||
return (Byte) getValue(16, (byte) 1);
|
return (byte) getValue(16, (byte) 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSize(int size) {
|
public void setSize(int size) {
|
||||||
|
@ -26,11 +26,11 @@ public class TameableWatcher extends AgeableWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isTrue(int no) {
|
protected boolean isTrue(int no) {
|
||||||
return ((Byte) getValue(16, (byte) 0) & no) != 0;
|
return ((byte) getValue(16, (byte) 0) & no) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setFlag(int no, boolean flag) {
|
protected void setFlag(int no, boolean flag) {
|
||||||
byte b0 = (Byte) getValue(16, (byte) 0);
|
byte b0 = (byte) getValue(16, (byte) 0);
|
||||||
if (flag) {
|
if (flag) {
|
||||||
setValue(16, (byte) (b0 | no));
|
setValue(16, (byte) (b0 | no));
|
||||||
} else {
|
} else {
|
||||||
|
@ -10,7 +10,7 @@ public class WitherSkullWatcher extends FlagWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBlue() {
|
public boolean isBlue() {
|
||||||
return (Byte) getValue(10, (byte) 0) == 1;
|
return (byte) getValue(10, (byte) 0) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBlue(boolean blue) {
|
public void setBlue(boolean blue) {
|
||||||
|
@ -10,7 +10,7 @@ public class WolfWatcher extends TameableWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public AnimalColor getCollarColor() {
|
public AnimalColor getCollarColor() {
|
||||||
return AnimalColor.getColor((Byte) getValue(20, (byte) 14));
|
return AnimalColor.getColor((byte) getValue(20, (byte) 14));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAngry() {
|
public boolean isAngry() {
|
||||||
|
@ -13,15 +13,15 @@ public class ZombieWatcher extends LivingWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBaby() {
|
public boolean isBaby() {
|
||||||
return (Byte) getValue(12, (byte) 0) == 1;
|
return (byte) getValue(12, (byte) 0) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isShaking() {
|
public boolean isShaking() {
|
||||||
return (Byte) getValue(14, (byte) 0) == 1;
|
return (byte) getValue(14, (byte) 0) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isVillager() {
|
public boolean isVillager() {
|
||||||
return (Byte) getValue(13, (byte) 0) == 1;
|
return (byte) getValue(13, (byte) 0) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAdult() {
|
public void setAdult() {
|
||||||
|
@ -33,6 +33,7 @@ import org.bukkit.configuration.file.YamlConfiguration;
|
|||||||
import org.bukkit.plugin.Plugin;
|
import org.bukkit.plugin.Plugin;
|
||||||
import org.bukkit.plugin.PluginDescriptionFile;
|
import org.bukkit.plugin.PluginDescriptionFile;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
|
|
||||||
import java.io.BufferedReader;
|
import java.io.BufferedReader;
|
||||||
import java.io.ByteArrayOutputStream;
|
import java.io.ByteArrayOutputStream;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
@ -46,7 +47,6 @@ import java.net.URLConnection;
|
|||||||
import java.net.URLEncoder;
|
import java.net.URLEncoder;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
|
||||||
import java.util.LinkedHashSet;
|
import java.util.LinkedHashSet;
|
||||||
import java.util.Set;
|
import java.util.Set;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
@ -275,7 +275,7 @@ public class Metrics {
|
|||||||
* @return the File object for the config file
|
* @return the File object for the config file
|
||||||
*/
|
*/
|
||||||
public File getConfigFile() {
|
public File getConfigFile() {
|
||||||
// I believe the easiest way to get the base folder (e.g craftbukkit set via -P) for plugins to use
|
// I believe the easiest way to get the base folder (e.g Spigot set via -P) for plugins to use
|
||||||
// is to abuse the plugin object we already have
|
// is to abuse the plugin object we already have
|
||||||
// plugin.getDataFolder() => base/plugins/PluginA/
|
// plugin.getDataFolder() => base/plugins/PluginA/
|
||||||
// pluginsFolder => base/plugins/
|
// pluginsFolder => base/plugins/
|
||||||
@ -334,9 +334,7 @@ public class Metrics {
|
|||||||
json.append(':');
|
json.append(':');
|
||||||
json.append('{');
|
json.append('{');
|
||||||
boolean firstGraph = true;
|
boolean firstGraph = true;
|
||||||
final Iterator<Graph> iter = graphs.iterator();
|
for (Graph graph : graphs) {
|
||||||
while (iter.hasNext()) {
|
|
||||||
Graph graph = iter.next();
|
|
||||||
StringBuilder graphJson = new StringBuilder();
|
StringBuilder graphJson = new StringBuilder();
|
||||||
graphJson.append('{');
|
graphJson.append('{');
|
||||||
for (Plotter plotter : graph.getPlotters()) {
|
for (Plotter plotter : graph.getPlotters()) {
|
||||||
@ -402,9 +400,7 @@ public class Metrics {
|
|||||||
// Is this the first update this hour?
|
// Is this the first update this hour?
|
||||||
if (response.equals("1") || response.contains("This is your first update this hour")) {
|
if (response.equals("1") || response.contains("This is your first update this hour")) {
|
||||||
synchronized (graphs) {
|
synchronized (graphs) {
|
||||||
final Iterator<Graph> iter = graphs.iterator();
|
for (Graph graph : graphs) {
|
||||||
while (iter.hasNext()) {
|
|
||||||
final Graph graph = iter.next();
|
|
||||||
for (Plotter plotter : graph.getPlotters()) {
|
for (Plotter plotter : graph.getPlotters()) {
|
||||||
plotter.reset();
|
plotter.reset();
|
||||||
}
|
}
|
||||||
@ -418,7 +414,7 @@ public class Metrics {
|
|||||||
* GZip compress a string of bytes
|
* GZip compress a string of bytes
|
||||||
*
|
*
|
||||||
* @param input
|
* @param input
|
||||||
* @return
|
* @return byte[]
|
||||||
*/
|
*/
|
||||||
public static byte[] gzip(String input) {
|
public static byte[] gzip(String input) {
|
||||||
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
ByteArrayOutputStream baos = new ByteArrayOutputStream();
|
||||||
@ -487,7 +483,7 @@ public class Metrics {
|
|||||||
* Escape a string to create a valid JSON string
|
* Escape a string to create a valid JSON string
|
||||||
*
|
*
|
||||||
* @param text
|
* @param text
|
||||||
* @return
|
* @return String
|
||||||
*/
|
*/
|
||||||
private static String escapeJSON(String text) {
|
private static String escapeJSON(String text) {
|
||||||
StringBuilder builder = new StringBuilder();
|
StringBuilder builder = new StringBuilder();
|
||||||
@ -515,7 +511,7 @@ public class Metrics {
|
|||||||
default:
|
default:
|
||||||
if (chr < ' ') {
|
if (chr < ' ') {
|
||||||
String t = "000" + Integer.toHexString(chr);
|
String t = "000" + Integer.toHexString(chr);
|
||||||
builder.append("\\u" + t.substring(t.length() - 4));
|
builder.append("\\u").append(t.substring(t.length() - 4));
|
||||||
} else {
|
} else {
|
||||||
builder.append(chr);
|
builder.append(chr);
|
||||||
}
|
}
|
||||||
|
@ -119,7 +119,7 @@ public class PacketsManager {
|
|||||||
if (disguise.getEntity() == null)
|
if (disguise.getEntity() == null)
|
||||||
disguise.setEntity(disguisedEntity);
|
disguise.setEntity(disguisedEntity);
|
||||||
Object nmsEntity = ReflectionManager.getNmsEntity(disguisedEntity);
|
Object nmsEntity = ReflectionManager.getNmsEntity(disguisedEntity);
|
||||||
ArrayList<PacketContainer> packets = new ArrayList<PacketContainer>();
|
ArrayList<PacketContainer> packets = new ArrayList<>();
|
||||||
// This sends the armor packets so that the player isn't naked.
|
// This sends the armor packets so that the player isn't naked.
|
||||||
// Please note it only sends the packets that wouldn't be sent normally
|
// Please note it only sends the packets that wouldn't be sent normally
|
||||||
if (DisguiseConfig.isEquipmentPacketsEnabled()) {
|
if (DisguiseConfig.isEquipmentPacketsEnabled()) {
|
||||||
@ -151,7 +151,7 @@ public class PacketsManager {
|
|||||||
if (DisguiseConfig.isMiscDisguisesForLivingEnabled()) {
|
if (DisguiseConfig.isMiscDisguisesForLivingEnabled()) {
|
||||||
if (disguise.getWatcher() instanceof LivingWatcher) {
|
if (disguise.getWatcher() instanceof LivingWatcher) {
|
||||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.UPDATE_ATTRIBUTES);
|
PacketContainer packet = new PacketContainer(PacketType.Play.Server.UPDATE_ATTRIBUTES);
|
||||||
List<WrappedAttribute> attributes = new ArrayList<WrappedAttribute>();
|
List<WrappedAttribute> attributes = new ArrayList<>();
|
||||||
Builder builder = WrappedAttribute.newBuilder().attributeKey("generic.maxHealth");
|
Builder builder = WrappedAttribute.newBuilder().attributeKey("generic.maxHealth");
|
||||||
if (((LivingWatcher) disguise.getWatcher()).isMaxHealthSet()) {
|
if (((LivingWatcher) disguise.getWatcher()).isMaxHealthSet()) {
|
||||||
builder.baseValue(((LivingWatcher) disguise.getWatcher()).getMaxHealth());
|
builder.baseValue(((LivingWatcher) disguise.getWatcher()).getMaxHealth());
|
||||||
@ -257,16 +257,14 @@ public class PacketsManager {
|
|||||||
PacketContainer[] bedPackets = DisguiseUtilities.getBedPackets(player,
|
PacketContainer[] bedPackets = DisguiseUtilities.getBedPackets(player,
|
||||||
loc.clone().subtract(0, PacketsManager.getYModifier(disguisedEntity, disguise), 0), player.getLocation(),
|
loc.clone().subtract(0, PacketsManager.getYModifier(disguisedEntity, disguise), 0), player.getLocation(),
|
||||||
((PlayerDisguise) disguise));
|
((PlayerDisguise) disguise));
|
||||||
for (int i = 0; i < 2; i++) {
|
System.arraycopy(bedPackets, 0, spawnPackets, 1, 2);
|
||||||
spawnPackets[i + 1] = bedPackets[i];
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
ArrayList<PacketContainer> newPackets = new ArrayList<PacketContainer>();
|
ArrayList<PacketContainer> newPackets = new ArrayList<>();
|
||||||
newPackets.add(null);
|
newPackets.add(null);
|
||||||
for (int i = 0; i < spawnPackets.length; i++) {
|
for (PacketContainer spawnPacket : spawnPackets) {
|
||||||
if (spawnPackets[i] != null) { // Get rid of empty packet '1' if it exists.
|
if (spawnPacket != null) { // Get rid of empty packet '1' if it exists.
|
||||||
newPackets.add(spawnPackets[i]);
|
newPackets.add(spawnPacket);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
spawnPackets = newPackets.toArray(new PacketContainer[newPackets.size()]);
|
spawnPackets = newPackets.toArray(new PacketContainer[newPackets.size()]);
|
||||||
@ -547,8 +545,7 @@ public class PacketsManager {
|
|||||||
DisguiseSound entitySound = null;
|
DisguiseSound entitySound = null;
|
||||||
Disguise disguise = null;
|
Disguise disguise = null;
|
||||||
Entity[] entities = soundLoc.getChunk().getEntities();
|
Entity[] entities = soundLoc.getChunk().getEntities();
|
||||||
for (int i = 0; i < entities.length; i++) {
|
for (Entity entity : entities) {
|
||||||
Entity entity = entities[i];
|
|
||||||
Disguise entityDisguise = DisguiseAPI.getDisguise(observer, entity);
|
Disguise entityDisguise = DisguiseAPI.getDisguise(observer, entity);
|
||||||
if (entityDisguise != null) {
|
if (entityDisguise != null) {
|
||||||
Location loc = entity.getLocation();
|
Location loc = entity.getLocation();
|
||||||
@ -618,8 +615,7 @@ public class PacketsManager {
|
|||||||
typeId);
|
typeId);
|
||||||
if (block != null) {
|
if (block != null) {
|
||||||
Object step = ReflectionManager.getNmsField("Block", "stepSound").get(block);
|
Object step = ReflectionManager.getNmsField("Block", "stepSound").get(block);
|
||||||
mods.write(0, ReflectionManager.getNmsMethod(step.getClass(), "getStepSound")
|
mods.write(0, ReflectionManager.getNmsMethod(step.getClass(), "getStepSound").invoke(step));
|
||||||
.invoke(step));
|
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
@ -682,7 +678,7 @@ public class PacketsManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (event.getPacketType() == PacketType.Play.Server.ENTITY_STATUS) {
|
} else if (event.getPacketType() == PacketType.Play.Server.ENTITY_STATUS) {
|
||||||
if ((Byte) mods.read(1) == 2) {
|
if ((byte) mods.read(1) == 2) {
|
||||||
// It made a damage animation
|
// It made a damage animation
|
||||||
Entity entity = event.getPacket().getEntityModifier(observer.getWorld()).read(0);
|
Entity entity = event.getPacket().getEntityModifier(observer.getWorld()).read(0);
|
||||||
Disguise disguise = DisguiseAPI.getDisguise(observer, entity);
|
Disguise disguise = DisguiseAPI.getDisguise(observer, entity);
|
||||||
@ -805,7 +801,7 @@ public class PacketsManager {
|
|||||||
event.setPacket(event.getPacket().deepClone());
|
event.setPacket(event.getPacket().deepClone());
|
||||||
for (WrappedWatchableObject watch : event.getPacket().getWatchableCollectionModifier().read(0)) {
|
for (WrappedWatchableObject watch : event.getPacket().getWatchableCollectionModifier().read(0)) {
|
||||||
if (watch.getIndex() == 0) {
|
if (watch.getIndex() == 0) {
|
||||||
byte b = (Byte) watch.getValue();
|
byte b = (byte) watch.getValue();
|
||||||
byte a = (byte) (b | 1 << 5);
|
byte a = (byte) (b | 1 << 5);
|
||||||
if ((b & 1 << 3) != 0)
|
if ((b & 1 << 3) != 0)
|
||||||
a = (byte) (a | 1 << 3);
|
a = (byte) (a | 1 << 3);
|
||||||
@ -817,7 +813,7 @@ public class PacketsManager {
|
|||||||
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
|
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
|
||||||
StructureModifier<Object> mods = packet.getModifier();
|
StructureModifier<Object> mods = packet.getModifier();
|
||||||
mods.write(0, observer.getEntityId());
|
mods.write(0, observer.getEntityId());
|
||||||
List<WrappedWatchableObject> watchableList = new ArrayList<WrappedWatchableObject>();
|
List<WrappedWatchableObject> watchableList = new ArrayList<>();
|
||||||
byte b = (byte) 1 << 5;
|
byte b = (byte) 1 << 5;
|
||||||
if (observer.isSprinting())
|
if (observer.isSprinting())
|
||||||
b = (byte) (b | 1 << 3);
|
b = (byte) (b | 1 << 3);
|
||||||
@ -1144,7 +1140,7 @@ public class PacketsManager {
|
|||||||
if (mainListener != null) {
|
if (mainListener != null) {
|
||||||
ProtocolLibrary.getProtocolManager().removePacketListener(mainListener);
|
ProtocolLibrary.getProtocolManager().removePacketListener(mainListener);
|
||||||
}
|
}
|
||||||
List<PacketType> packetsToListen = new ArrayList<PacketType>();
|
List<PacketType> packetsToListen = new ArrayList<>();
|
||||||
// Add spawn packets
|
// Add spawn packets
|
||||||
{
|
{
|
||||||
packetsToListen.add(PacketType.Play.Server.NAMED_ENTITY_SPAWN);
|
packetsToListen.add(PacketType.Play.Server.NAMED_ENTITY_SPAWN);
|
||||||
@ -1276,7 +1272,7 @@ public class PacketsManager {
|
|||||||
if (disguise.isMiscDisguise()) {
|
if (disguise.isMiscDisguise()) {
|
||||||
packets = new PacketContainer[0];
|
packets = new PacketContainer[0];
|
||||||
} else {
|
} else {
|
||||||
List<WrappedAttribute> attributes = new ArrayList<WrappedAttribute>();
|
List<WrappedAttribute> attributes = new ArrayList<>();
|
||||||
for (WrappedAttribute attribute : sentPacket.getAttributeCollectionModifier().read(0)) {
|
for (WrappedAttribute attribute : sentPacket.getAttributeCollectionModifier().read(0)) {
|
||||||
if (attribute.getAttributeKey().equals("generic.maxHealth")) {
|
if (attribute.getAttributeKey().equals("generic.maxHealth")) {
|
||||||
packets[0] = new PacketContainer(PacketType.Play.Server.UPDATE_ATTRIBUTES);
|
packets[0] = new PacketContainer(PacketType.Play.Server.UPDATE_ATTRIBUTES);
|
||||||
@ -1340,9 +1336,7 @@ public class PacketsManager {
|
|||||||
.getWatcher()).isSleeping())))) {
|
.getWatcher()).isSleeping())))) {
|
||||||
packets = new PacketContainer[0];
|
packets = new PacketContainer[0];
|
||||||
}
|
}
|
||||||
}
|
} else if (sentPacket.getType() == PacketType.Play.Server.COLLECT) {
|
||||||
|
|
||||||
else if (sentPacket.getType() == PacketType.Play.Server.COLLECT) {
|
|
||||||
if (disguise.getType().isMisc()) {
|
if (disguise.getType().isMisc()) {
|
||||||
packets = new PacketContainer[0];
|
packets = new PacketContainer[0];
|
||||||
} else if (DisguiseConfig.isBedPacketsEnabled() && disguise.getType().isPlayer()
|
} else if (DisguiseConfig.isBedPacketsEnabled() && disguise.getType().isPlayer()
|
||||||
@ -1408,9 +1402,7 @@ public class PacketsManager {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (sentPacket.getType() == PacketType.Play.Server.ENTITY_EQUIPMENT) {
|
||||||
|
|
||||||
else if (sentPacket.getType() == PacketType.Play.Server.ENTITY_EQUIPMENT) {
|
|
||||||
int slot = (Integer) packets[0].getModifier().read(1) - 1;
|
int slot = (Integer) packets[0].getModifier().read(1) - 1;
|
||||||
if (slot < 0)
|
if (slot < 0)
|
||||||
slot = 4;
|
slot = 4;
|
||||||
@ -1424,7 +1416,7 @@ public class PacketsManager {
|
|||||||
ItemStack heldItem = packets[0].getItemModifier().read(0);
|
ItemStack heldItem = packets[0].getItemModifier().read(0);
|
||||||
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<WrappedWatchableObject>();
|
List<WrappedWatchableObject> list = new ArrayList<>();
|
||||||
if (DisguiseConfig.isMetadataPacketsEnabled()) {
|
if (DisguiseConfig.isMetadataPacketsEnabled()) {
|
||||||
list.add(new WrappedWatchableObject(0, WrappedDataWatcher.getEntityWatcher(entity).getByte(0)));
|
list.add(new WrappedWatchableObject(0, WrappedDataWatcher.getEntityWatcher(entity).getByte(0)));
|
||||||
list = disguise.getWatcher().convert(list);
|
list = disguise.getWatcher().convert(list);
|
||||||
@ -1444,7 +1436,7 @@ public class PacketsManager {
|
|||||||
PacketContainer packetUnblock = packetBlock.deepClone();
|
PacketContainer packetUnblock = packetBlock.deepClone();
|
||||||
// Make a packet to send the 'unblock'
|
// Make a packet to send the 'unblock'
|
||||||
for (WrappedWatchableObject watcher : packetUnblock.getWatchableCollectionModifier().read(0)) {
|
for (WrappedWatchableObject watcher : packetUnblock.getWatchableCollectionModifier().read(0)) {
|
||||||
watcher.setValue((byte) ((Byte) watcher.getValue() & ~(1 << 4)));
|
watcher.setValue((byte) ((byte) watcher.getValue() & ~(1 << 4)));
|
||||||
}
|
}
|
||||||
// Send the unblock before the itemstack change so that the 2nd metadata packet works. Why? Scheduler
|
// Send the unblock before the itemstack change so that the 2nd metadata packet works. Why? Scheduler
|
||||||
// delay.
|
// delay.
|
||||||
@ -1453,21 +1445,15 @@ public class PacketsManager {
|
|||||||
// it.
|
// it.
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
} else if (sentPacket.getType() == PacketType.Play.Server.BED) {
|
||||||
|
|
||||||
else if (sentPacket.getType() == PacketType.Play.Server.BED) {
|
|
||||||
if (!disguise.getType().isPlayer()) {
|
if (!disguise.getType().isPlayer()) {
|
||||||
packets = new PacketContainer[0];
|
packets = new PacketContainer[0];
|
||||||
}
|
}
|
||||||
}
|
} else if (sentPacket.getType() == PacketType.Play.Server.ENTITY_STATUS) {
|
||||||
|
|
||||||
else if (sentPacket.getType() == PacketType.Play.Server.ENTITY_STATUS) {
|
|
||||||
if (packets[0].getBytes().read(0) == (byte) 3) {
|
if (packets[0].getBytes().read(0) == (byte) 3) {
|
||||||
packets = new PacketContainer[0];
|
packets = new PacketContainer[0];
|
||||||
}
|
}
|
||||||
}
|
} else if (sentPacket.getType() == PacketType.Play.Server.ENTITY_HEAD_ROTATION) {
|
||||||
|
|
||||||
else if (sentPacket.getType() == PacketType.Play.Server.ENTITY_HEAD_ROTATION) {
|
|
||||||
if (disguise.getType().isPlayer() && entity.getType() != EntityType.PLAYER) {
|
if (disguise.getType().isPlayer() && entity.getType() != EntityType.PLAYER) {
|
||||||
Location loc = entity.getLocation();
|
Location loc = entity.getLocation();
|
||||||
byte pitch = getPitch(disguise.getType(), DisguiseType.getType(entity.getType()),
|
byte pitch = getPitch(disguise.getType(), DisguiseType.getType(entity.getType()),
|
||||||
@ -1483,9 +1469,7 @@ public class PacketsManager {
|
|||||||
look.getBytes().write(4, pitch);
|
look.getBytes().write(4, pitch);
|
||||||
packets = new PacketContainer[]{look, rotation};
|
packets = new PacketContainer[]{look, rotation};
|
||||||
}
|
}
|
||||||
}
|
} else {
|
||||||
|
|
||||||
else {
|
|
||||||
packets = null;
|
packets = null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -28,21 +28,6 @@ import java.util.regex.Pattern;
|
|||||||
|
|
||||||
public class ReflectionManager {
|
public class ReflectionManager {
|
||||||
|
|
||||||
public enum LibVersion {
|
|
||||||
|
|
||||||
V1_8;
|
|
||||||
private static LibVersion currentVersion;
|
|
||||||
|
|
||||||
static {
|
|
||||||
//String mcVersion = Bukkit.getVersion().split("MC: ")[1].replace(")", "");
|
|
||||||
currentVersion = V1_8;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static LibVersion getGameVersion() {
|
|
||||||
return currentVersion;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static final String bukkitVersion = Bukkit.getServer().getClass().getName().split("\\.")[3];
|
private static final String bukkitVersion = Bukkit.getServer().getClass().getName().split("\\.")[3];
|
||||||
private static final Class<?> craftItemClass;
|
private static final Class<?> craftItemClass;
|
||||||
private static Method damageAndIdleSoundMethod;
|
private static Method damageAndIdleSoundMethod;
|
||||||
@ -551,7 +536,7 @@ public class ReflectionManager {
|
|||||||
try {
|
try {
|
||||||
damageAndIdleSoundMethod.setAccessible(true);
|
damageAndIdleSoundMethod.setAccessible(true);
|
||||||
return (Float) damageAndIdleSoundMethod.invoke(entity);
|
return (Float) damageAndIdleSoundMethod.invoke(entity);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ignored) {
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
@ -610,6 +595,7 @@ public class ReflectionManager {
|
|||||||
|
|
||||||
public static void setAllowSleep(Player player) {
|
public static void setAllowSleep(Player player) {
|
||||||
try {
|
try {
|
||||||
|
//TODO: Fix this!
|
||||||
/**
|
/**
|
||||||
* Object nmsEntity = getNmsEntity(player); Object connection = getNmsField(nmsEntity.getClass(), "playerConnection").get(nmsEntity); Field check = getNmsField(connection.getClass(), "checkMovement"); check.setBoolean(connection, true); *
|
* Object nmsEntity = getNmsEntity(player); Object connection = getNmsField(nmsEntity.getClass(), "playerConnection").get(nmsEntity); Field check = getNmsField(connection.getClass(), "checkMovement"); check.setBoolean(connection, true); *
|
||||||
*/
|
*/
|
||||||
|
@ -1,6 +1,6 @@
|
|||||||
name: LibsDisguises
|
name: LibsDisguises
|
||||||
main: me.libraryaddict.disguise.LibsDisguises
|
main: me.libraryaddict.disguise.LibsDisguises
|
||||||
version: 8.6.8
|
version: 9.0.0
|
||||||
author: libraryaddict
|
author: libraryaddict
|
||||||
authors: [Byteflux, Navid K.]
|
authors: [Byteflux, Navid K.]
|
||||||
softdepend: [ProtocolLib]
|
softdepend: [ProtocolLib]
|
||||||
|
Loading…
Reference in New Issue
Block a user