Added new config option AddEntityAnimations
This commit is contained in:
parent
4e72ad359c
commit
0e0418b7be
@ -23,4 +23,8 @@ SendVelocity: true
|
||||
# However! This doesn't actually remove the armor!
|
||||
# It just makes the client think the armor was removed so that it doesn't render it!
|
||||
RemoveArmor: true
|
||||
RemoveHeldItem: true
|
||||
RemoveHeldItem: true
|
||||
# If you set a disguise to burning, it will no longer be able to be shown as sneaking or invisible.
|
||||
# Set this to true if you want the disguise to get the animations of the disguised entity. Such as invisible, on fire, sprinting, sneaking, blocking
|
||||
# This is only valid if you set a animation on the disguise itself. Because the entitys animations are applied otherwise.
|
||||
AddEntityAnimations: false
|
@ -13,11 +13,11 @@ import org.bukkit.entity.Entity;
|
||||
|
||||
public class DisguiseAPI {
|
||||
private static boolean hearSelfDisguise;
|
||||
|
||||
private static boolean hidingArmor;
|
||||
private static boolean hidingHeldItem;
|
||||
private static boolean isEntityAnimationsAdded;
|
||||
private static boolean sendVelocity;
|
||||
|
||||
|
||||
@Deprecated
|
||||
public static boolean canHearSelfDisguise() {
|
||||
return hearSelfDisguise;
|
||||
@ -107,6 +107,10 @@ public class DisguiseAPI {
|
||||
return getDisguise(disguised) != null;
|
||||
}
|
||||
|
||||
public static boolean isEntityAnimationsAdded() {
|
||||
return isEntityAnimationsAdded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Is the plugin modifying the inventory packets so that players when self disguised, do not see their armor floating around
|
||||
*/
|
||||
@ -150,6 +154,10 @@ public class DisguiseAPI {
|
||||
return PacketsManager.isViewDisguisesListenerEnabled();
|
||||
}
|
||||
|
||||
public static void setAddEntityAnimations(boolean isEntityAnimationsAdded) {
|
||||
DisguiseAPI.isEntityAnimationsAdded = isEntityAnimationsAdded;
|
||||
}
|
||||
|
||||
/**
|
||||
* Can players hear their own disguises
|
||||
*/
|
||||
|
@ -63,6 +63,7 @@ public class LibsDisguises extends JavaPlugin {
|
||||
DisguiseAPI.setHearSelfDisguise(getConfig().getBoolean("HearSelfDisguise"));
|
||||
DisguiseAPI.setHideArmorFromSelf(getConfig().getBoolean("RemoveArmor"));
|
||||
DisguiseAPI.setHideHeldItemFromSelf(getConfig().getBoolean("RemoveHeldItem"));
|
||||
DisguiseAPI.setAddEntityAnimations(getConfig().getBoolean("AddEntityAnimations"));
|
||||
if (DisguiseAPI.isHidingArmorFromSelf() || DisguiseAPI.isHidingHeldItemFromSelf()) {
|
||||
DisguiseAPI.setInventoryListenerEnabled(true);
|
||||
}
|
||||
|
@ -36,6 +36,7 @@ public class FlagWatcher {
|
||||
}
|
||||
}
|
||||
|
||||
private boolean addEntityAnimations = DisguiseAPI.isEntityAnimationsAdded();
|
||||
/**
|
||||
* This is the entity values I need to add else it could crash them..
|
||||
*/
|
||||
@ -44,6 +45,7 @@ public class FlagWatcher {
|
||||
private HashMap<Integer, Object> entityValues = new HashMap<Integer, Object>();
|
||||
private boolean hasDied;
|
||||
private org.bukkit.inventory.ItemStack[] items = new org.bukkit.inventory.ItemStack[5];
|
||||
private HashSet<Integer> modifiedEntityAnimations = new HashSet<Integer>();
|
||||
|
||||
public FlagWatcher(Disguise disguise) {
|
||||
this.disguise = disguise;
|
||||
@ -63,6 +65,7 @@ public class FlagWatcher {
|
||||
}
|
||||
cloned.entityValues = (HashMap<Integer, Object>) entityValues.clone();
|
||||
cloned.items = items.clone();
|
||||
cloned.modifiedEntityAnimations = (HashSet) modifiedEntityAnimations.clone();
|
||||
return cloned;
|
||||
}
|
||||
|
||||
@ -90,6 +93,16 @@ public class FlagWatcher {
|
||||
value = backupEntityValues.get(dataType);
|
||||
}
|
||||
if (value != null) {
|
||||
if (addEntityAnimations && dataType == 0) {
|
||||
byte watcher = (Byte) watch.getValue();
|
||||
byte valueByte = (Byte) value;
|
||||
for (int i = 0; i < 6; i++) {
|
||||
if ((watcher & 1 << i) != 0 && !modifiedEntityAnimations.contains(i)) {
|
||||
valueByte = (byte) (valueByte | 1 << i);
|
||||
}
|
||||
}
|
||||
value = valueByte;
|
||||
}
|
||||
boolean doD = watch.getDirtyState();
|
||||
watch = new WrappedWatchableObject(dataType, value);
|
||||
if (!doD)
|
||||
@ -177,6 +190,10 @@ public class FlagWatcher {
|
||||
return getFlag(0);
|
||||
}
|
||||
|
||||
public boolean isEntityAnimationsAdded() {
|
||||
return addEntityAnimations;
|
||||
}
|
||||
|
||||
public boolean isInvisible() {
|
||||
return getFlag(5);
|
||||
}
|
||||
@ -222,6 +239,10 @@ public class FlagWatcher {
|
||||
}
|
||||
}
|
||||
|
||||
public void setAddEntityAnimations(boolean isEntityAnimationsAdded) {
|
||||
this.addEntityAnimations = isEntityAnimationsAdded;
|
||||
}
|
||||
|
||||
public void setArmor(org.bukkit.inventory.ItemStack[] itemstack) {
|
||||
for (int i = 0; i < itemstack.length; i++)
|
||||
setItemStack(i, itemstack[i]);
|
||||
@ -237,8 +258,10 @@ public class FlagWatcher {
|
||||
}
|
||||
|
||||
protected void setFlag(int no, int i, boolean flag) {
|
||||
if (no == 0) {
|
||||
modifiedEntityAnimations.add(i);
|
||||
}
|
||||
byte b0 = (Byte) getValue(no, (byte) 0);
|
||||
|
||||
if (flag) {
|
||||
setValue(no, (byte) (b0 | 1 << i));
|
||||
} else {
|
||||
|
@ -8,18 +8,12 @@ public class GhastWatcher extends LivingWatcher {
|
||||
super(disguise);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public boolean isAgressive() {
|
||||
public boolean isAggressive() {
|
||||
return (Byte) getValue(16, (byte) 0) == 1;
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setAgressive(boolean isAgressive) {
|
||||
setValue(16, (byte) (isAgressive ? 1 : 0));
|
||||
sendData(16);
|
||||
}
|
||||
|
||||
public boolean isAggressive() {
|
||||
public boolean isAgressive() {
|
||||
return (Byte) getValue(16, (byte) 0) == 1;
|
||||
}
|
||||
|
||||
@ -28,4 +22,10 @@ public class GhastWatcher extends LivingWatcher {
|
||||
sendData(16);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public void setAgressive(boolean isAgressive) {
|
||||
setValue(16, (byte) (isAgressive ? 1 : 0));
|
||||
sendData(16);
|
||||
}
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user