Updated all the flag watchers to 1.9 values
Added some new flag watchers Added some new API methods to flag watchers Fixed some more disguises Added new options to some disguises Certain packets have been fixed Still not ready for use, but most mob disguises work WARNING, the plugin is still heavily in ALPHA - Currently not working: Player disguises Misc. disguises Joining a server while someone is disguised Sounds Names above heads Other packet related things
This commit is contained in:
parent
d498613f15
commit
51483e0572
@ -22,6 +22,7 @@ import me.libraryaddict.disguise.disguisetypes.watchers.GuardianWatcher;
|
|||||||
import me.libraryaddict.disguise.disguisetypes.watchers.HorseWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.HorseWatcher;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.MinecartWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.MinecartWatcher;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.watchers.SkeletonWatcher;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.SlimeWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.SlimeWatcher;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.TameableWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.TameableWatcher;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher;
|
||||||
@ -130,6 +131,9 @@ public class LibsDisguises extends JavaPlugin {
|
|||||||
case ENDERMITE:
|
case ENDERMITE:
|
||||||
watcherClass = LivingWatcher.class;
|
watcherClass = LivingWatcher.class;
|
||||||
break;
|
break;
|
||||||
|
case WITHER_SKELETON:
|
||||||
|
watcherClass = SkeletonWatcher.class;
|
||||||
|
break;
|
||||||
default:
|
default:
|
||||||
watcherClass = Class.forName("me.libraryaddict.disguise.disguisetypes.watchers."
|
watcherClass = Class.forName("me.libraryaddict.disguise.disguisetypes.watchers."
|
||||||
+ toReadable(disguiseType.name()) + "Watcher");
|
+ toReadable(disguiseType.name()) + "Watcher");
|
||||||
|
@ -10,7 +10,9 @@ import me.libraryaddict.disguise.LibsDisguises;
|
|||||||
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise.TargetType;
|
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise.TargetType;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.BatWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.BatWatcher;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.watchers.GuardianWatcher;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.HorseWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.HorseWatcher;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.watchers.SkeletonWatcher;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher;
|
||||||
import me.libraryaddict.disguise.events.DisguiseEvent;
|
import me.libraryaddict.disguise.events.DisguiseEvent;
|
||||||
import me.libraryaddict.disguise.events.UndisguiseEvent;
|
import me.libraryaddict.disguise.events.UndisguiseEvent;
|
||||||
@ -24,6 +26,8 @@ import org.bukkit.entity.Entity;
|
|||||||
import org.bukkit.entity.Horse.Variant;
|
import org.bukkit.entity.Horse.Variant;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.Skeleton.SkeletonType;
|
||||||
|
import org.bukkit.entity.Villager.Profession;
|
||||||
import org.bukkit.scheduler.BukkitTask;
|
import org.bukkit.scheduler.BukkitTask;
|
||||||
import org.bukkit.util.Vector;
|
import org.bukkit.util.Vector;
|
||||||
|
|
||||||
@ -33,6 +37,7 @@ import java.util.HashMap;
|
|||||||
import java.util.HashSet;
|
import java.util.HashSet;
|
||||||
import java.util.Iterator;
|
import java.util.Iterator;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
import java.util.Random;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
public abstract class Disguise {
|
public abstract class Disguise {
|
||||||
@ -98,19 +103,17 @@ public abstract class Disguise {
|
|||||||
}
|
}
|
||||||
// If the disguise type is a wither, set the flagwatcher value for the skeleton to a wither skeleton
|
// If the disguise type is a wither, set the flagwatcher value for the skeleton to a wither skeleton
|
||||||
if (getType() == DisguiseType.WITHER_SKELETON) {
|
if (getType() == DisguiseType.WITHER_SKELETON) {
|
||||||
getWatcher().setValue(13, (byte) 1);
|
((SkeletonWatcher)getWatcher()).setType(SkeletonType.WITHER);
|
||||||
} // Else if its a zombie, but the disguise type is a zombie villager. Set the value.
|
} // Else if its a zombie, but the disguise type is a zombie villager. Set the value.
|
||||||
else if (getType() == DisguiseType.ZOMBIE_VILLAGER) {
|
else if (getType() == DisguiseType.ZOMBIE_VILLAGER) {
|
||||||
getWatcher().setValue(13, (byte) 1);
|
((ZombieWatcher)getWatcher()).setProfession(Profession.values()[new Random().nextInt(Profession.values().length)]);
|
||||||
} else if (getType() == DisguiseType.ELDER_GUARDIAN) {
|
} else if (getType() == DisguiseType.ELDER_GUARDIAN) {
|
||||||
getWatcher().setValue(16, 4);
|
((GuardianWatcher)getWatcher()).setElder(true);
|
||||||
} // 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 {
|
||||||
// Don't mess with this because Varient is something like ZombieHorse and so on.
|
|
||||||
// Not something that a watcher needs to access.
|
|
||||||
Variant horseType = Variant.valueOf(getType().name());
|
Variant horseType = Variant.valueOf(getType().name());
|
||||||
getWatcher().setValue(19, (byte) horseType.ordinal());
|
((HorseWatcher)getWatcher()).setVariant(horseType);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
// Ok.. So it aint a horse
|
// Ok.. So it aint a horse
|
||||||
}
|
}
|
||||||
|
@ -159,7 +159,7 @@ public class FlagWatcher {
|
|||||||
return disguise;
|
return disguise;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean getFlag(int byteValue) {
|
private boolean getEntityFlag(int byteValue) {
|
||||||
return ((byte) getValue(0, (byte) 0) & 1 << byteValue) != 0;
|
return ((byte) getValue(0, (byte) 0) & 1 << byteValue) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -199,10 +199,6 @@ public class FlagWatcher {
|
|||||||
return entityValues.containsKey(no);
|
return entityValues.containsKey(no);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBurning() {
|
|
||||||
return getFlag(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isCustomNameVisible() {
|
public boolean isCustomNameVisible() {
|
||||||
return (byte) getValue(3, (byte) 0) == 1;
|
return (byte) getValue(3, (byte) 0) == 1;
|
||||||
}
|
}
|
||||||
@ -211,20 +207,32 @@ public class FlagWatcher {
|
|||||||
return addEntityAnimations;
|
return addEntityAnimations;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isInvisible() {
|
public boolean isBurning() {
|
||||||
return getFlag(5);
|
return getEntityFlag(0);
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isRightClicking() {
|
|
||||||
return getFlag(4);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSneaking() {
|
public boolean isSneaking() {
|
||||||
return getFlag(1);
|
return getEntityFlag(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSprinting() {
|
public boolean isSprinting() {
|
||||||
return getFlag(3);
|
return getEntityFlag(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRightClicking() {
|
||||||
|
return getEntityFlag(4);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isInvisible() {
|
||||||
|
return getEntityFlag(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isFlyingWithElytra() {
|
||||||
|
return getEntityFlag(6);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isGlowing() {
|
||||||
|
return getEntityFlag(7);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void rebuildWatchableObjects() {
|
public void rebuildWatchableObjects() {
|
||||||
@ -289,7 +297,7 @@ public class FlagWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setBurning(boolean setBurning) {
|
public void setBurning(boolean setBurning) {
|
||||||
setFlag(0, setBurning);
|
setEntityFlag(0, setBurning);
|
||||||
sendData(0);
|
sendData(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -306,7 +314,7 @@ public class FlagWatcher {
|
|||||||
sendData(3);
|
sendData(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setFlag(int byteValue, boolean flag) {
|
private void setEntityFlag(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) {
|
||||||
@ -317,7 +325,17 @@ public class FlagWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setInvisible(boolean setInvis) {
|
public void setInvisible(boolean setInvis) {
|
||||||
setFlag(5, setInvis);
|
setEntityFlag(5, setInvis);
|
||||||
|
sendData(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGlowing(boolean glowing) {
|
||||||
|
setEntityFlag(6, glowing);
|
||||||
|
sendData(0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFlyingWithElytra(boolean flying) {
|
||||||
|
setEntityFlag(7, flying);
|
||||||
sendData(0);
|
sendData(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -413,17 +431,17 @@ public class FlagWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setRightClicking(boolean setRightClicking) {
|
public void setRightClicking(boolean setRightClicking) {
|
||||||
setFlag(4, setRightClicking);
|
setEntityFlag(4, setRightClicking);
|
||||||
sendData(0);
|
sendData(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSneaking(boolean setSneaking) {
|
public void setSneaking(boolean setSneaking) {
|
||||||
setFlag(1, setSneaking);
|
setEntityFlag(1, setSneaking);
|
||||||
sendData(0);
|
sendData(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSprinting(boolean setSprinting) {
|
public void setSprinting(boolean setSprinting) {
|
||||||
setFlag(3, setSprinting);
|
setEntityFlag(3, setSprinting);
|
||||||
sendData(0);
|
sendData(0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,15 +1,14 @@
|
|||||||
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.Entity;
|
||||||
|
|
||||||
public class AgeableWatcher extends LivingWatcher {
|
public class AgeableWatcher extends LivingWatcher {
|
||||||
|
|
||||||
public AgeableWatcher(Disguise disguise) {
|
public AgeableWatcher(Disguise disguise) {
|
||||||
super(disguise);
|
super(disguise);
|
||||||
}
|
Entity e;
|
||||||
|
|
||||||
public int getAge() {
|
|
||||||
return (Integer) getValue(12, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAdult() {
|
public boolean isAdult() {
|
||||||
@ -17,25 +16,20 @@ public class AgeableWatcher extends LivingWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBaby() {
|
public boolean isBaby() {
|
||||||
return ((byte) getValue(12, (byte) 0)) < 0;
|
return (boolean) getValue(11, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAdult() {
|
public void setAdult() {
|
||||||
setBaby(false);
|
setBaby(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAge(int newAge) {
|
|
||||||
setValue(12, (byte) newAge);
|
|
||||||
sendData(12);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setBaby() {
|
public void setBaby() {
|
||||||
setBaby(true);
|
setBaby(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBaby(boolean isBaby) {
|
public void setBaby(boolean isBaby) {
|
||||||
setValue(12, (byte) (isBaby ? -1 : 0));
|
setValue(11, isBaby);
|
||||||
sendData(12);
|
sendData(11);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,27 +8,31 @@ public class ArmorStandWatcher extends LivingWatcher {
|
|||||||
super(disguise);
|
super(disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean get10(int value) {
|
private boolean getArmorStandFlag(int value) {
|
||||||
return ((byte) getValue(10, 0) & value) != 0;
|
return ((byte) getValue(10, 0) & value) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNoBasePlate() {
|
public boolean isNoBasePlate() {
|
||||||
return get10(8);
|
return getArmorStandFlag(8);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNoGravity() {
|
public boolean isNoGravity() {
|
||||||
return get10(2);
|
return getArmorStandFlag(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isShowArms() {
|
public boolean isShowArms() {
|
||||||
return get10(4);
|
return getArmorStandFlag(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSmall() {
|
public boolean isSmall() {
|
||||||
return get10(1);
|
return getArmorStandFlag(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void set10(int value, boolean isTrue) {
|
public boolean isMarker() {
|
||||||
|
return getArmorStandFlag(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setArmorStandFlag(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);
|
||||||
@ -40,22 +44,27 @@ public class ArmorStandWatcher extends LivingWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setNoBasePlate(boolean noBasePlate) {
|
public void setNoBasePlate(boolean noBasePlate) {
|
||||||
set10(8, noBasePlate);
|
setArmorStandFlag(8, noBasePlate);
|
||||||
sendData(10);
|
sendData(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNoGravity(boolean noGravity) {
|
public void setNoGravity(boolean noGravity) {
|
||||||
set10(2, noGravity);
|
setArmorStandFlag(2, noGravity);
|
||||||
sendData(10);
|
sendData(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setShowArms(boolean showArms) {
|
public void setShowArms(boolean showArms) {
|
||||||
set10(4, showArms);
|
setArmorStandFlag(4, showArms);
|
||||||
sendData(10);
|
sendData(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSmall(boolean isSmall) {
|
public void setSmall(boolean isSmall) {
|
||||||
set10(1, isSmall);
|
setArmorStandFlag(1, isSmall);
|
||||||
|
sendData(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setMarker(boolean isMarker) {
|
||||||
|
setArmorStandFlag(10, isMarker);
|
||||||
sendData(10);
|
sendData(10);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -10,12 +10,12 @@ public class ArrowWatcher extends FlagWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCritical() {
|
public boolean isCritical() {
|
||||||
return (byte) getValue(16, (byte) 0) == 1;
|
return (byte) getValue(5, (byte) 0) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCritical(boolean critical) {
|
public void setCritical(boolean critical) {
|
||||||
setValue(16, (byte) (critical ? 1 : 0));
|
setValue(5, (byte) (critical ? 1 : 0));
|
||||||
sendData(16);
|
sendData(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,11 +10,11 @@ public class BatWatcher extends LivingWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isFlying() {
|
public boolean isFlying() {
|
||||||
return (byte) getValue(16, (byte) 1) == 0;
|
return (boolean) getValue(11, true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFlying(boolean flying) {
|
public void setFlying(boolean flying) {
|
||||||
setValue(16, (byte) (flying ? 0 : 1));
|
setValue(11, flying);
|
||||||
sendData(16);
|
sendData(11);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -9,12 +9,12 @@ public class BlazeWatcher extends LivingWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBlazing() {
|
public boolean isBlazing() {
|
||||||
return (byte) getValue(16, (byte) 0) == 1;
|
return (boolean) getValue(11, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBlazing(boolean isBlazing) {
|
public void setBlazing(boolean isBlazing) {
|
||||||
setValue(16, (byte) (isBlazing ? 1 : 0));
|
setValue(11, isBlazing);
|
||||||
sendData(16);
|
sendData(11);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,26 +5,20 @@ import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
|||||||
|
|
||||||
public class BoatWatcher extends FlagWatcher {
|
public class BoatWatcher extends FlagWatcher {
|
||||||
|
|
||||||
|
//TODO: Add stuff for new boat values
|
||||||
|
|
||||||
public BoatWatcher(Disguise disguise) {
|
public BoatWatcher(Disguise disguise) {
|
||||||
super(disguise);
|
super(disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getDamage() {
|
public int getDamage() {
|
||||||
return (Integer) getValue(19, 40F);
|
return (int) getValue(7, 40F);
|
||||||
}
|
|
||||||
|
|
||||||
public int getHealth() {
|
|
||||||
return (Integer) getValue(17, 10);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDamage(float dmg) {
|
public void setDamage(float dmg) {
|
||||||
setValue(19, dmg);
|
setValue(7, dmg);
|
||||||
sendData(19);
|
sendData(7);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHealth(int health) {
|
|
||||||
setValue(17, health);
|
|
||||||
sendData(17);
|
|
||||||
}
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -9,21 +9,21 @@ public class CreeperWatcher extends LivingWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIgnited() {
|
public boolean isIgnited() {
|
||||||
return (byte) getValue(18, (byte) 0) == 1;
|
return (boolean) getValue(13, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPowered() {
|
public boolean isPowered() {
|
||||||
return (byte) getValue(17, (byte) 0) == 1;
|
return (boolean) getValue(12, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIgnited(boolean ignited) {
|
public void setIgnited(boolean ignited) {
|
||||||
setValue(18, (byte) (ignited ? 1 : 0));
|
setValue(13, ignited);
|
||||||
sendData(18);
|
sendData(13);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPowered(boolean powered) {
|
public void setPowered(boolean powered) {
|
||||||
setValue(17, (byte) (powered ? 1 : 0));
|
setValue(12, powered);
|
||||||
sendData(17);
|
sendData(12);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -2,7 +2,6 @@ package me.libraryaddict.disguise.disguisetypes.watchers;
|
|||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||||
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class DroppedItemWatcher extends FlagWatcher {
|
public class DroppedItemWatcher extends FlagWatcher {
|
||||||
@ -12,12 +11,12 @@ public class DroppedItemWatcher extends FlagWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getItemStack() {
|
public ItemStack getItemStack() {
|
||||||
return (ItemStack) getValue(10, new ItemStack(1));
|
return (ItemStack) getValue(5, new ItemStack(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setItemStack(ItemStack item) {
|
public void setItemStack(ItemStack item) {
|
||||||
setValue(10, item);
|
setValue(5, item);
|
||||||
sendData(10);
|
sendData(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,22 @@
|
|||||||
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Navid
|
||||||
|
*/
|
||||||
|
public class EnderDragonWatcher extends LivingWatcher {
|
||||||
|
|
||||||
|
public EnderDragonWatcher(Disguise disguise) {
|
||||||
|
super(disguise);
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getPhase() {
|
||||||
|
return (int) getValue(11, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setPhase(int phase) {
|
||||||
|
setValue(11, phase);
|
||||||
|
sendData(11);
|
||||||
|
}
|
||||||
|
}
|
@ -11,22 +11,21 @@ public class EndermanWatcher extends LivingWatcher {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItemInMainHand() {
|
public ItemStack getItemInMainHand() {
|
||||||
return new ItemStack((byte) getValue(16, (byte) 0), 1, ((byte) getValue(17, (byte) 0)));
|
return new ItemStack((int) getValue(11, 1), 1, (short) 0);
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isAggressive() {
|
|
||||||
return (byte) getValue(18, (byte) 0) == 1;
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setAggressive(boolean isAggressive) {
|
|
||||||
setValue(18, (byte) (isAggressive ? 1 : 0));
|
|
||||||
sendData(18);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setItemInMainHand(ItemStack itemstack) {
|
public void setItemInMainHand(ItemStack itemstack) {
|
||||||
setValue(16, (short) (itemstack.getTypeId() & 255));
|
setValue(11, itemstack.getTypeId());
|
||||||
setValue(17, (byte) (itemstack.getDurability() & 255));
|
}
|
||||||
|
|
||||||
|
public boolean isAggressive() {
|
||||||
|
return (boolean) getValue(12, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAggressive(boolean isAggressive) {
|
||||||
|
setValue(12, isAggressive);
|
||||||
|
sendData(12);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,17 +1,17 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
|
||||||
import org.bukkit.inventory.ItemStack;
|
|
||||||
|
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
public class FallingBlockWatcher extends FlagWatcher {
|
public class FallingBlockWatcher extends FlagWatcher {
|
||||||
|
|
||||||
private ItemStack block;
|
private ItemStack block;
|
||||||
|
|
||||||
|
//TODO: Check this watcher and make sure it works
|
||||||
public FallingBlockWatcher(Disguise disguise) {
|
public FallingBlockWatcher(Disguise disguise) {
|
||||||
super(disguise);
|
super(disguise);
|
||||||
}
|
}
|
||||||
|
@ -9,12 +9,12 @@ public class GhastWatcher extends LivingWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAggressive() {
|
public boolean isAggressive() {
|
||||||
return (byte) getValue(16, (byte) 0) == 1;
|
return (boolean) getValue(11, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAggressive(boolean isAggressive) {
|
public void setAggressive(boolean isAggressive) {
|
||||||
setValue(16, (byte) (isAggressive ? 1 : 0));
|
setValue(11, isAggressive);
|
||||||
sendData(16);
|
sendData(11);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
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.Bukkit;
|
||||||
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
public class GuardianWatcher extends LivingWatcher {
|
public class GuardianWatcher extends LivingWatcher {
|
||||||
|
|
||||||
@ -8,13 +10,62 @@ public class GuardianWatcher extends LivingWatcher {
|
|||||||
super(disguise);
|
super(disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBeam() {
|
/**
|
||||||
return (Integer) getValue(17, 0) == 1;
|
* Is this guardian targetting someone?
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean isTarget() {
|
||||||
|
return ((int)getValue(12, 0)) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBeam(boolean isBeaming) {
|
/**
|
||||||
setValue(17, isBeaming ? 1 : 0);
|
* Shoot a beam at the given entityId.
|
||||||
sendData(17);
|
* @param entityId
|
||||||
|
*/
|
||||||
|
public void setTarget(int entityId) {
|
||||||
|
setValue(12, entityId);
|
||||||
|
sendData(12);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Shoot a beam at the given player name.
|
||||||
|
* @param playername
|
||||||
|
*/
|
||||||
|
public void setTarget(String playername) {
|
||||||
|
Player player = Bukkit.getPlayer(playername);
|
||||||
|
if (player == null) return;
|
||||||
|
setValue(12, player.getEntityId());
|
||||||
|
sendData(12);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRetractingSpikes() {
|
||||||
|
return isGuardianFlag(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRetractingSpikes(boolean isRetracting) {
|
||||||
|
setGuardianFlag(2, isRetracting);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isElder() {
|
||||||
|
return isGuardianFlag(4);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setElder(boolean isGuardian) {
|
||||||
|
setGuardianFlag(4, isGuardian);
|
||||||
|
}
|
||||||
|
|
||||||
|
protected boolean isGuardianFlag(int no) {
|
||||||
|
return ((byte) getValue(11, (byte) 0) & no) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected void setGuardianFlag(int no, boolean flag) {
|
||||||
|
byte b0 = (byte) getValue(11, (byte) 0);
|
||||||
|
if (flag) {
|
||||||
|
setValue(11, (byte) (b0 | no));
|
||||||
|
} else {
|
||||||
|
setValue(11, (byte) (b0 & -(no + 1)));
|
||||||
|
}
|
||||||
|
sendData(11);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,16 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
import java.util.Random;
|
import com.google.common.base.Optional;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
|
||||||
import org.bukkit.Material;
|
import org.bukkit.Material;
|
||||||
import org.bukkit.entity.Horse.Color;
|
import org.bukkit.entity.Horse.Color;
|
||||||
import org.bukkit.entity.Horse.Style;
|
import org.bukkit.entity.Horse.Style;
|
||||||
|
import org.bukkit.entity.Horse.Variant;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class HorseWatcher extends AgeableWatcher {
|
public class HorseWatcher extends AgeableWatcher {
|
||||||
|
|
||||||
public HorseWatcher(Disguise disguise) {
|
public HorseWatcher(Disguise disguise) {
|
||||||
@ -16,8 +18,18 @@ public class HorseWatcher extends AgeableWatcher {
|
|||||||
setColor(Color.values()[new Random().nextInt(Color.values().length)]);
|
setColor(Color.values()[new Random().nextInt(Color.values().length)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//TODO: Check and make sure Variants work
|
||||||
|
public Variant getVariant() {
|
||||||
|
return Variant.values()[(int) getValue(14, 0)];
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setVariant(Variant variant) {
|
||||||
|
setValue(14, variant.ordinal());
|
||||||
|
sendData(14);
|
||||||
|
}
|
||||||
|
|
||||||
public Color getColor() {
|
public Color getColor() {
|
||||||
return Color.values()[((Integer) getValue(20, 0) & 0xFF)];
|
return Color.values()[((Integer) getValue(13, 0) & 0xFF)];
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getHorseArmor() {
|
public ItemStack getHorseArmor() {
|
||||||
@ -35,93 +47,91 @@ public class HorseWatcher extends AgeableWatcher {
|
|||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
protected int getHorseArmorAsInt() {
|
||||||
public int getHorseArmorAsInt() {
|
return (int) getValue(16, 0);
|
||||||
return (Integer) getValue(22, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public String getOwnerName() {
|
public Optional<UUID> getOwner() {
|
||||||
return (String) getValue(21, null);
|
return (Optional<UUID>) getValue(15, Optional.absent());
|
||||||
}
|
}
|
||||||
|
|
||||||
public Style getStyle() {
|
public Style getStyle() {
|
||||||
return Style.values()[((Integer) getValue(20, 0) >>> 8)];
|
return Style.values()[((int) getValue(13, 0) >>> 8)];
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasChest() {
|
public boolean hasChest() {
|
||||||
return isTrue(8);
|
return isHorseFlag(8);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBreedable() {
|
public boolean isBreedable() {
|
||||||
return isTrue(16);
|
return isHorseFlag(16);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isGrazing() {
|
public boolean isGrazing() {
|
||||||
return isTrue(32);
|
return isHorseFlag(32);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isMouthOpen() {
|
public boolean isMouthOpen() {
|
||||||
return isTrue(128);
|
return isHorseFlag(128);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRearing() {
|
public boolean isRearing() {
|
||||||
return isTrue(64);
|
return isHorseFlag(64);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSaddled() {
|
public boolean isSaddled() {
|
||||||
return isTrue(4);
|
return isHorseFlag(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isTamed() {
|
public boolean isTamed() {
|
||||||
return isTrue(2);
|
return isHorseFlag(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean isTrue(int i) {
|
private boolean isHorseFlag(int i) {
|
||||||
return ((Integer) getValue(16, (byte) 0) & i) != 0;
|
return ((Integer) getValue(12, (byte) 0) & i) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCanBreed(boolean breed) {
|
public void setCanBreed(boolean breed) {
|
||||||
setFlag(16, breed);
|
setHorseFlag(16, breed);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCarryingChest(boolean chest) {
|
public void setCarryingChest(boolean chest) {
|
||||||
setFlag(8, chest);
|
setHorseFlag(8, chest);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setColor(Color color) {
|
public void setColor(Color color) {
|
||||||
setValue(20, color.ordinal() & 0xFF | getStyle().ordinal() << 8);
|
setValue(13, color.ordinal() & 0xFF | getStyle().ordinal() << 8);
|
||||||
sendData(20);
|
sendData(13);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setFlag(int i, boolean flag) {
|
private void setHorseFlag(int i, boolean flag) {
|
||||||
int j = (Integer) getValue(16, 0);
|
int j = (int) getValue(12, 0);
|
||||||
if (flag) {
|
if (flag) {
|
||||||
setValue(16, j | i);
|
setValue(12, j | i);
|
||||||
} else {
|
} else {
|
||||||
setValue(16, j & ~i);
|
setValue(12, j & ~i);
|
||||||
}
|
}
|
||||||
sendData(16);
|
sendData(12);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGrazing(boolean grazing) {
|
public void setGrazing(boolean grazing) {
|
||||||
setFlag(32, grazing);
|
setHorseFlag(32, grazing);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
protected void setHorseArmor(int armor) {
|
||||||
public void setHorseArmor(int armor) {
|
setValue(16, armor);
|
||||||
setValue(22, armor % 4);
|
sendData(16);
|
||||||
sendData(22);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHorseArmor(ItemStack item) {
|
public void setHorseArmor(ItemStack item) {
|
||||||
int value = 0;
|
int value = 0;
|
||||||
if (item != null) {
|
if (item != null) {
|
||||||
Material mat = item.getType();
|
Material mat = item.getType();
|
||||||
if (mat.name().equals("IRON_BARDING")) {
|
if (mat == Material.IRON_BARDING) {
|
||||||
value = 1;
|
value = 1;
|
||||||
} else if (mat.name().equals("GOLD_BARDING")) {
|
} else if (mat == Material.GOLD_BARDING) {
|
||||||
value = 2;
|
value = 2;
|
||||||
} else if (mat.name().equals("DIAMOND_BARDING")) {
|
} else if (mat == Material.DIAMOND_BARDING) {
|
||||||
value = 3;
|
value = 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -129,29 +139,29 @@ public class HorseWatcher extends AgeableWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setMouthOpen(boolean mouthOpen) {
|
public void setMouthOpen(boolean mouthOpen) {
|
||||||
setFlag(128, mouthOpen);
|
setHorseFlag(128, mouthOpen);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOwnerName(String name) {
|
public void setOwner(Optional<UUID> uuid) {
|
||||||
setValue(21, name);
|
setValue(15, uuid);
|
||||||
sendData(21);
|
sendData(15);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRearing(boolean rear) {
|
public void setRearing(boolean rear) {
|
||||||
setFlag(64, rear);
|
setHorseFlag(64, rear);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSaddled(boolean saddled) {
|
public void setSaddled(boolean saddled) {
|
||||||
setFlag(4, saddled);
|
setHorseFlag(4, saddled);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setStyle(Style style) {
|
public void setStyle(Style style) {
|
||||||
setValue(20, getColor().ordinal() & 0xFF | style.ordinal() << 8);
|
setValue(13, getColor().ordinal() & 0xFF | style.ordinal() << 8);
|
||||||
sendData(20);
|
sendData(13);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTamed(boolean tamed) {
|
public void setTamed(boolean tamed) {
|
||||||
setFlag(2, tamed);
|
setHorseFlag(2, tamed);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,14 +11,14 @@ public class ItemFrameWatcher extends FlagWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getItem() {
|
public ItemStack getItem() {
|
||||||
if (getValue(2, null) == null) {
|
if (getValue(5, null) == null) {
|
||||||
return new ItemStack(0);
|
return new ItemStack(0);
|
||||||
}
|
}
|
||||||
return (ItemStack) getValue(8, null);
|
return (ItemStack) getValue(5, null);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRotation() {
|
public int getRotation() {
|
||||||
return (Integer) getValue(9, 0);
|
return (int) getValue(6, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setItem(ItemStack newItem) {
|
public void setItem(ItemStack newItem) {
|
||||||
@ -27,13 +27,13 @@ public class ItemFrameWatcher extends FlagWatcher {
|
|||||||
}
|
}
|
||||||
newItem = newItem.clone();
|
newItem = newItem.clone();
|
||||||
newItem.setAmount(1);
|
newItem.setAmount(1);
|
||||||
setValue(8, newItem);
|
setValue(5, newItem);
|
||||||
sendData(8);
|
sendData(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRotation(int rotation) {
|
public void setRotation(int rotation) {
|
||||||
setValue(9, (byte) (rotation % 4));
|
setValue(6, (byte) (rotation % 4));
|
||||||
sendData(9);
|
sendData(6);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -65,15 +65,15 @@ public class LivingWatcher extends FlagWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public float getHealth() {
|
public float getHealth() {
|
||||||
return (Float) getValue(6, 0F);
|
return (float) getValue(6, 0F);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getMaxHealth() {
|
public double getMaxHealth() {
|
||||||
return maxHealth;
|
return maxHealth;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean getPotionParticlesRemoved() {
|
public boolean isPotionParticlesAmbient() {
|
||||||
return (byte) getValue(8, (byte) 0) == 1;
|
return (boolean) getValue(8, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getPotions() {
|
private int getPotions() {
|
||||||
@ -121,8 +121,8 @@ public class LivingWatcher extends FlagWatcher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void removePotionParticles(boolean particles) {
|
public void setPotionParticlesAmbient(boolean particles) {
|
||||||
setValue(8, (byte) (particles ? 1 : 0));
|
setValue(8, particles);
|
||||||
sendData(8);
|
sendData(8);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -136,6 +136,15 @@ public class LivingWatcher extends FlagWatcher {
|
|||||||
sendData(6);
|
sendData(6);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public int getArrowsSticking() {
|
||||||
|
return (int) getValue(9, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setArrowsSticking(int arrowsNo) {
|
||||||
|
setValue(9, arrowsNo);
|
||||||
|
sendData(9);
|
||||||
|
}
|
||||||
|
|
||||||
public void setMaxHealth(double newHealth) {
|
public void setMaxHealth(double newHealth) {
|
||||||
this.maxHealth = newHealth;
|
this.maxHealth = newHealth;
|
||||||
this.maxHealthSet = true;
|
this.maxHealthSet = true;
|
||||||
|
@ -11,39 +11,30 @@ public class MinecartWatcher extends FlagWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getBlockInCart() {
|
public ItemStack getBlockInCart() {
|
||||||
int id = (Integer) getValue(20, 0) & 0xffff;
|
int id = (int) getValue(8, 0) & 0xffff;
|
||||||
int data = (Integer) getValue(20, 0) >> 16;
|
int data = (int) getValue(8, 0) >> 16;
|
||||||
return new ItemStack(id, 1, (short) data);
|
return new ItemStack(id, 1, (short) data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getBlockOffset() {
|
public int getBlockYOffset() {
|
||||||
return (Integer) getValue(21, 0);
|
return (int) getValue(9, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
public boolean isViewBlockInCart() {
|
||||||
public int getBlockOffSet() {
|
return (boolean) getValue(10, false);
|
||||||
return getBlockOffset();
|
|
||||||
}
|
|
||||||
|
|
||||||
public float getDamage() {
|
|
||||||
return (Float) getValue(19, 0F);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean getViewBlockInCart() {
|
|
||||||
return ((byte) getValue(22, (byte) 0)) == (byte) 1;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBlockInCart(ItemStack item) {
|
public void setBlockInCart(ItemStack item) {
|
||||||
int id = item.getTypeId();
|
int id = item.getTypeId();
|
||||||
int data = item.getDurability();
|
int data = item.getDurability();
|
||||||
setValue(20, id & 0xffff | data << 16);
|
setValue(8, id & 0xffff | data << 16);
|
||||||
setValue(22, (byte) 1);
|
setValue(10, true); //Show block
|
||||||
sendData(20, 22);
|
sendData(8, 10);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBlockOffset(int i) {
|
public void setBlockOffset(int i) {
|
||||||
setValue(21, i);
|
setValue(9, i);
|
||||||
sendData(21);
|
sendData(9);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Deprecated
|
@Deprecated
|
||||||
@ -51,13 +42,8 @@ public class MinecartWatcher extends FlagWatcher {
|
|||||||
setBlockOffset(i);
|
setBlockOffset(i);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDamage(float damage) {
|
|
||||||
setValue(19, damage);
|
|
||||||
sendData(19);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setViewBlockInCart(boolean viewBlock) {
|
public void setViewBlockInCart(boolean viewBlock) {
|
||||||
setValue(22, (byte) (viewBlock ? 1 : 0));
|
setValue(10, viewBlock);
|
||||||
sendData(22);
|
sendData(10);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -11,11 +11,11 @@ public class OcelotWatcher extends TameableWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Type getType() {
|
public Type getType() {
|
||||||
return Ocelot.Type.getType((byte) getValue(18, (byte) 0));
|
return Ocelot.Type.getType((int) getValue(14, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(Type newType) {
|
public void setType(Type newType) {
|
||||||
setValue(18, (byte) newType.getId());
|
setValue(14, newType.getId());
|
||||||
sendData(18);
|
sendData(14);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,14 +1,15 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
import org.bukkit.Art;
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
|
import org.bukkit.Art;
|
||||||
|
|
||||||
public class PaintingWatcher extends FlagWatcher {
|
public class PaintingWatcher extends FlagWatcher {
|
||||||
|
|
||||||
private Art painting;
|
private Art painting;
|
||||||
|
|
||||||
|
//TODO: Check this
|
||||||
public PaintingWatcher(Disguise disguise) {
|
public PaintingWatcher(Disguise disguise) {
|
||||||
super(disguise);
|
super(disguise);
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import com.comphenix.protocol.PacketType.Play.Server;
|
|||||||
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 com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||||
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;
|
||||||
@ -28,10 +29,6 @@ public class PlayerWatcher extends LivingWatcher {
|
|||||||
return watcher;
|
return watcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getArrowsSticking() {
|
|
||||||
return (byte) getValue(9, (byte) 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public BlockFace getSleepingDirection() {
|
public BlockFace getSleepingDirection() {
|
||||||
if (sleepingDirection == null) {
|
if (sleepingDirection == null) {
|
||||||
if (this.getDisguise().getEntity() != null && isSleeping()) {
|
if (this.getDisguise().getEntity() != null && isSleeping()) {
|
||||||
@ -44,32 +41,95 @@ public class PlayerWatcher extends LivingWatcher {
|
|||||||
return sleepingDirection;
|
return sleepingDirection;
|
||||||
}
|
}
|
||||||
|
|
||||||
private boolean getValue16(int i) {
|
|
||||||
return ((byte) getValue(16, (byte) 0) & 1 << i) != 0;
|
// Bit 0 (0x01): Cape enabled
|
||||||
|
// Bit 1 (0x02): Jacket enabled
|
||||||
|
// Bit 2 (0x04): Left Sleeve enabled
|
||||||
|
// Bit 3 (0x08): Right Sleeve enabled
|
||||||
|
// Bit 4 (0x10): Left Pants Leg enabled
|
||||||
|
// Bit 5 (0x20): Right Pants Leg enabled
|
||||||
|
// Bit 6 (0x40): Hat enabled
|
||||||
|
|
||||||
|
private boolean isSkinFlag(int i) {
|
||||||
|
return ((byte) getValue(12, (byte) 0) & 1 << i) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isHideCape() {
|
public boolean isCapeEnabled() {
|
||||||
return getValue16(1);
|
return isSkinFlag(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isJackedEnabled() {
|
||||||
|
return isSkinFlag(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLeftSleeveEnabled() {
|
||||||
|
return isSkinFlag(3);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRightSleeveEnabled() {
|
||||||
|
return isSkinFlag(4);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLeftPantsEnabled() {
|
||||||
|
return isSkinFlag(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRightPantsEnabled() {
|
||||||
|
return isSkinFlag(6);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isHatEnabled() {
|
||||||
|
return isSkinFlag(7);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setCapeEnabled(boolean enabled) {
|
||||||
|
setSkinFlags(1, enabled);
|
||||||
|
sendData(12);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setJackedEnabled(boolean enabled) {
|
||||||
|
setSkinFlags(2, enabled);
|
||||||
|
sendData(12);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLeftSleeveEnabled(boolean enabled) {
|
||||||
|
setSkinFlags(3, enabled);
|
||||||
|
sendData(12);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRightSleeveEnabled(boolean enabled) {
|
||||||
|
setSkinFlags(4, enabled);
|
||||||
|
sendData(12);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLeftPantsEnabled(boolean enabled) {
|
||||||
|
setSkinFlags(5, enabled);
|
||||||
|
sendData(12);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRightPantsEnabled(boolean enabled) {
|
||||||
|
setSkinFlags(6, enabled);
|
||||||
|
sendData(12);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setHatEnabled(boolean enabled) {
|
||||||
|
setSkinFlags(7, enabled);
|
||||||
|
sendData(12);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
public boolean isSleeping() {
|
public boolean isSleeping() {
|
||||||
return isInBed;
|
return isInBed;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setArrowsSticking(int arrowsNo) {
|
|
||||||
setValue(9, (byte) arrowsNo);
|
|
||||||
sendData(9);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setHideCape(boolean hideCape) {
|
|
||||||
setValue16(1, hideCape);
|
|
||||||
sendData(16);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setSkin(String playerName) {
|
public void setSkin(String playerName) {
|
||||||
((PlayerDisguise) getDisguise()).setSkin(playerName);
|
((PlayerDisguise) getDisguise()).setSkin(playerName);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setSkin(WrappedGameProfile profile) {
|
||||||
|
((PlayerDisguise) getDisguise()).setSkin(profile);
|
||||||
|
}
|
||||||
|
|
||||||
public void setSleeping(BlockFace sleepingDirection) {
|
public void setSleeping(BlockFace sleepingDirection) {
|
||||||
setSleeping(true, sleepingDirection);
|
setSleeping(true, sleepingDirection);
|
||||||
}
|
}
|
||||||
@ -125,12 +185,12 @@ public class PlayerWatcher extends LivingWatcher {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setValue16(int i, boolean flag) {
|
private void setSkinFlags(int i, boolean flag) {
|
||||||
byte b0 = (byte) getValue(16, (byte) 0);
|
byte b0 = (byte) getValue(12, (byte) 0);
|
||||||
if (flag) {
|
if (flag) {
|
||||||
setValue(16, (byte) (b0 | 1 << i));
|
setValue(12, (byte) (b0 | 1 << i));
|
||||||
} else {
|
} else {
|
||||||
setValue(16, (byte) (b0 & (~1 << i)));
|
setValue(12, (byte) (b0 & (~1 << i)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -13,12 +13,12 @@ public class RabbitWatcher extends AgeableWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public RabbitType getType() {
|
public RabbitType getType() {
|
||||||
return RabbitType.getType((Integer) getValue(18, 0));
|
return RabbitType.getType((int) getValue(18, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(RabbitType type) {
|
public void setType(RabbitType type) {
|
||||||
setValue(18, (byte) type.getTypeId());
|
setValue(12, type.getTypeId());
|
||||||
sendData(18);
|
sendData(12);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -7,30 +7,30 @@ public class SheepWatcher extends AgeableWatcher {
|
|||||||
|
|
||||||
public SheepWatcher(Disguise disguise) {
|
public SheepWatcher(Disguise disguise) {
|
||||||
super(disguise);
|
super(disguise);
|
||||||
setValue(16, (byte) 0);
|
setValue(12, (byte) 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AnimalColor getColor() {
|
public AnimalColor getColor() {
|
||||||
return AnimalColor.getColor((byte) getValue(16, (byte) 0) & 15);
|
return AnimalColor.getColor((byte) getValue(12, (byte) 0) & 15);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSheared() {
|
public boolean isSheared() {
|
||||||
return ((byte) getValue(16, (byte) 0) & 16) != 0;
|
return ((byte) getValue(12, (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(12, (byte) 0);
|
||||||
setValue(16, (byte) (b0 & 240 | color.getId() & 15));
|
setValue(12, (byte) (b0 & 240 | color.getId() & 15));
|
||||||
sendData(16);
|
sendData(12);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSheared(boolean flag) {
|
public void setSheared(boolean flag) {
|
||||||
byte b0 = (byte) getValue(16, (byte) 0);
|
byte b0 = (byte) getValue(12, (byte) 0);
|
||||||
if (flag) {
|
if (flag) {
|
||||||
setValue(16, (byte) (b0 | 16));
|
setValue(12, (byte) (b0 | 16));
|
||||||
} else {
|
} else {
|
||||||
setValue(16, (byte) (b0 & -17));
|
setValue(12, (byte) (b0 & -17));
|
||||||
}
|
}
|
||||||
sendData(16);
|
sendData(12);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,43 @@
|
|||||||
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
|
import com.comphenix.protocol.wrappers.BlockPosition;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import org.bukkit.block.BlockFace;
|
||||||
|
|
||||||
|
import java.util.Optional;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Navid
|
||||||
|
*/
|
||||||
|
//TODO: Add the appropriate data values to this class
|
||||||
|
public class ShulkerWatcher extends LivingWatcher {
|
||||||
|
|
||||||
|
public ShulkerWatcher(Disguise disguise) {
|
||||||
|
super(disguise);
|
||||||
|
}
|
||||||
|
|
||||||
|
public BlockFace getFacingDirection() {
|
||||||
|
return BlockFace.UP;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setFacingDirection() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public Optional<BlockPosition> getAttachmentPosition() {
|
||||||
|
return Optional.empty();
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAttachmentPosition(BlockPosition pos) {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
public byte getShieldHeight() {
|
||||||
|
return 0x00;
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setShieldHeight() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -0,0 +1,23 @@
|
|||||||
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import org.bukkit.entity.Skeleton.SkeletonType;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Navid
|
||||||
|
*/
|
||||||
|
public class SkeletonWatcher extends LivingWatcher {
|
||||||
|
|
||||||
|
public SkeletonWatcher(Disguise disguise) {
|
||||||
|
super(disguise);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setType(SkeletonType type) {
|
||||||
|
setValue(11, type.getId());
|
||||||
|
sendData(11);
|
||||||
|
}
|
||||||
|
|
||||||
|
public SkeletonType getType() {
|
||||||
|
return SkeletonType.getType((int) getValue(11, SkeletonType.NORMAL.getId()));
|
||||||
|
}
|
||||||
|
}
|
@ -12,15 +12,15 @@ public class SlimeWatcher extends LivingWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public int getSize() {
|
public int getSize() {
|
||||||
return (byte) getValue(16, (byte) 1);
|
return (int) getValue(11, 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSize(int size) {
|
public void setSize(int size) {
|
||||||
if (size <= 0 || size >= 128) {
|
if (size <= 0 || size >= 128) {
|
||||||
size = 1;
|
size = 1;
|
||||||
}
|
}
|
||||||
setValue(16, (byte) size);
|
setValue(11, size);
|
||||||
sendData(16);
|
sendData(11);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,62 +1,53 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
|
import com.google.common.base.Optional;
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
|
||||||
|
import java.util.UUID;
|
||||||
|
|
||||||
public class TameableWatcher extends AgeableWatcher {
|
public class TameableWatcher extends AgeableWatcher {
|
||||||
|
|
||||||
public TameableWatcher(Disguise disguise) {
|
public TameableWatcher(Disguise disguise) {
|
||||||
super(disguise);
|
super(disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public Optional<UUID> getOwner() {
|
||||||
public float getHealth() {
|
return (Optional<UUID>) getValue(13, Optional.absent());
|
||||||
return (Float) getValue(18, 8F);
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getOwner() {
|
|
||||||
return (String) getValue(17, null);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSitting() {
|
public boolean isSitting() {
|
||||||
return isTrue(1);
|
return isTameableFlag(1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isTamed() {
|
public boolean isTamed() {
|
||||||
return isTrue(4);
|
return isTameableFlag(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isTrue(int no) {
|
protected boolean isTameableFlag(int no) {
|
||||||
return ((byte) getValue(16, (byte) 0) & no) != 0;
|
return ((byte) getValue(12, (byte) 0) & no) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setFlag(int no, boolean flag) {
|
protected void setTameableFlag(int no, boolean flag) {
|
||||||
byte b0 = (byte) getValue(16, (byte) 0);
|
byte b0 = (byte) getValue(12, (byte) 0);
|
||||||
if (flag) {
|
if (flag) {
|
||||||
setValue(16, (byte) (b0 | no));
|
setValue(12, (byte) (b0 | no));
|
||||||
} else {
|
} else {
|
||||||
setValue(16, (byte) (b0 & -(no + 1)));
|
setValue(12, (byte) (b0 & -(no + 1)));
|
||||||
}
|
}
|
||||||
sendData(16);
|
sendData(12);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
public void setOwner(Optional<UUID> owner) {
|
||||||
public void setHealth(float newHealth) {
|
setValue(13, owner);
|
||||||
setValue(18, newHealth);
|
sendData(13);
|
||||||
setValue(6, newHealth);
|
|
||||||
sendData(6, 18);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setOwner(String owner) {
|
|
||||||
setValue(17, owner);
|
|
||||||
sendData(17);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSitting(boolean sitting) {
|
public void setSitting(boolean sitting) {
|
||||||
setFlag(1, sitting);
|
setTameableFlag(1, sitting);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTamed(boolean tamed) {
|
public void setTamed(boolean tamed) {
|
||||||
setFlag(4, tamed);
|
setTameableFlag(4, tamed);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import org.bukkit.Color;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Navid
|
||||||
|
*/
|
||||||
|
public class TippedArrowWatcher extends ArrowWatcher {
|
||||||
|
|
||||||
|
public TippedArrowWatcher(Disguise disguise) {
|
||||||
|
super(disguise);
|
||||||
|
}
|
||||||
|
|
||||||
|
public Color getColor() {
|
||||||
|
int color = (int) getValue(5, Color.WHITE.asRGB());
|
||||||
|
return Color.fromRGB(color);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setColor(Color color) {
|
||||||
|
setValue(5, color.asRGB());
|
||||||
|
sendData(5);
|
||||||
|
}
|
||||||
|
}
|
@ -1,11 +1,10 @@
|
|||||||
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 org.bukkit.entity.Villager.Profession;
|
import org.bukkit.entity.Villager.Profession;
|
||||||
|
|
||||||
|
import java.util.Random;
|
||||||
|
|
||||||
public class VillagerWatcher extends AgeableWatcher {
|
public class VillagerWatcher extends AgeableWatcher {
|
||||||
|
|
||||||
public VillagerWatcher(Disguise disguise) {
|
public VillagerWatcher(Disguise disguise) {
|
||||||
@ -14,12 +13,12 @@ public class VillagerWatcher extends AgeableWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public Profession getProfession() {
|
public Profession getProfession() {
|
||||||
return Profession.values()[(Integer) getValue(16, 0)];
|
return Profession.getProfession((int) getValue(16, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProfession(int professionId) {
|
public void setProfession(int professionId) {
|
||||||
setValue(16, professionId % 6);
|
setValue(12, professionId);
|
||||||
sendData(16);
|
sendData(12);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProfession(Profession newProfession) {
|
public void setProfession(Profession newProfession) {
|
||||||
|
@ -0,0 +1,24 @@
|
|||||||
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @author Navid
|
||||||
|
*/
|
||||||
|
public class WitchWatcher extends LivingWatcher {
|
||||||
|
|
||||||
|
public WitchWatcher(Disguise disguise) {
|
||||||
|
super(disguise);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
public boolean isAggressive() {
|
||||||
|
return (boolean) getValue(11, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAggressive(boolean aggressive) {
|
||||||
|
setValue(11, aggressive);
|
||||||
|
sendData(11);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
@ -10,12 +10,12 @@ public class WitherSkullWatcher extends FlagWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBlue() {
|
public boolean isBlue() {
|
||||||
return (byte) getValue(10, (byte) 0) == 1;
|
return (boolean) getValue(5, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBlue(boolean blue) {
|
public void setBlue(boolean blue) {
|
||||||
setValue(10, (byte) (blue ? 1 : 0));
|
setValue(5, blue);
|
||||||
sendData(10);
|
sendData(5);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,10 +1,9 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
import java.security.InvalidParameterException;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
|
||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import java.security.InvalidParameterException;
|
||||||
|
|
||||||
public class WitherWatcher extends LivingWatcher {
|
public class WitherWatcher extends LivingWatcher {
|
||||||
|
|
||||||
@ -12,25 +11,24 @@ public class WitherWatcher extends LivingWatcher {
|
|||||||
super(disguise);
|
super(disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getInvul() {
|
/**
|
||||||
return getInvulnerability();
|
* Returns the amount of time this Wither is invulnerable for
|
||||||
}
|
* @return
|
||||||
|
*/
|
||||||
public int getInvulnerability() {
|
public int getInvulnerability() {
|
||||||
return (Integer) getValue(20, 0);
|
return (int) getValue(14, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int[] getTargets() {
|
public int[] getTargets() {
|
||||||
return new int[]{(Integer) getValue(17, 0), (Integer) getValue(18, 0), (Integer) getValue(19, 0)};
|
return new int[]{(Integer) getValue(11, 0), (Integer) getValue(12, 0), (Integer) getValue(13, 0)};
|
||||||
}
|
|
||||||
|
|
||||||
public void setInvul(int invulnerability) {
|
|
||||||
setInvulnerability(invulnerability);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the amount of time this Wither is invulnerable for
|
||||||
|
*/
|
||||||
public void setInvulnerability(int invulnerability) {
|
public void setInvulnerability(int invulnerability) {
|
||||||
setValue(20, invulnerability);
|
setValue(14, invulnerability);
|
||||||
sendData(20);
|
sendData(14);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTargets(int... targets) {
|
public void setTargets(int... targets) {
|
||||||
@ -38,10 +36,10 @@ public class WitherWatcher extends LivingWatcher {
|
|||||||
throw new InvalidParameterException(ChatColor.RED + "Expected 3 numbers for wither setTargets. Received "
|
throw new InvalidParameterException(ChatColor.RED + "Expected 3 numbers for wither setTargets. Received "
|
||||||
+ targets.length);
|
+ targets.length);
|
||||||
}
|
}
|
||||||
setValue(17, targets[0]);
|
setValue(11, targets[0]);
|
||||||
setValue(18, targets[1]);
|
setValue(12, targets[1]);
|
||||||
setValue(19, targets[2]);
|
setValue(13, targets[2]);
|
||||||
sendData(17, 18, 19);
|
sendData(11, 12, 13);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -10,15 +10,41 @@ public class WolfWatcher extends TameableWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public AnimalColor getCollarColor() {
|
public AnimalColor getCollarColor() {
|
||||||
return AnimalColor.getColor((byte) getValue(20, (byte) 14));
|
return AnimalColor.getColor((int) getValue(16, 14));
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used for tail rotation.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public float getDamageTaken() {
|
||||||
|
return (float) getValue(14, 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Used for tail rotation.
|
||||||
|
* @param damage
|
||||||
|
*/
|
||||||
|
public void setDamageTaken(float damage) {
|
||||||
|
setValue(14, damage);
|
||||||
|
sendData(14);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isBegging() {
|
||||||
|
return (boolean) getValue(15, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setBegging(boolean begging) {
|
||||||
|
setValue(15, begging);
|
||||||
|
sendData(15);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAngry() {
|
public boolean isAngry() {
|
||||||
return isTrue(2);
|
return isTameableFlag(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAngry(boolean angry) {
|
public void setAngry(boolean angry) {
|
||||||
setFlag(2, angry);
|
setTameableFlag(2, angry);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCollarColor(AnimalColor newColor) {
|
public void setCollarColor(AnimalColor newColor) {
|
||||||
@ -26,8 +52,8 @@ public class WolfWatcher extends TameableWatcher {
|
|||||||
setTamed(true);
|
setTamed(true);
|
||||||
}
|
}
|
||||||
if (newColor != getCollarColor()) {
|
if (newColor != getCollarColor()) {
|
||||||
setValue(20, (byte) newColor.getId());
|
setValue(14, (byte) newColor.getId());
|
||||||
sendData(20);
|
sendData(14);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
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.Villager.Profession;
|
||||||
|
|
||||||
public class ZombieWatcher extends LivingWatcher {
|
public class ZombieWatcher extends LivingWatcher {
|
||||||
|
|
||||||
@ -13,15 +14,32 @@ public class ZombieWatcher extends LivingWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBaby() {
|
public boolean isBaby() {
|
||||||
return (byte) getValue(12, (byte) 0) == 1;
|
return (boolean) getValue(11, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isShaking() {
|
public boolean isShaking() {
|
||||||
return (byte) getValue(14, (byte) 0) == 1;
|
return (boolean) getValue(14, false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Is this zombie a villager?
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
public boolean isVillager() {
|
public boolean isVillager() {
|
||||||
return (byte) getValue(13, (byte) 0) == 1;
|
return ((int)getValue(12, 0)) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAggressive() {
|
||||||
|
return (boolean) getValue(14, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Only returns a valid value if this zombie
|
||||||
|
* is a villager.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public Profession getProfession() {
|
||||||
|
return Profession.getProfession((int) getValue(12, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAdult() {
|
public void setAdult() {
|
||||||
@ -33,18 +51,38 @@ public class ZombieWatcher extends LivingWatcher {
|
|||||||
}
|
}
|
||||||
|
|
||||||
public void setBaby(boolean baby) {
|
public void setBaby(boolean baby) {
|
||||||
setValue(12, (byte) (baby ? 1 : 0));
|
setValue(11, baby);
|
||||||
sendData(12);
|
sendData(11);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setShaking(boolean shaking) {
|
public void setShaking(boolean shaking) {
|
||||||
setValue(14, (byte) (shaking ? 1 : 0));
|
setValue(13, (byte) (shaking ? 1 : 0));
|
||||||
sendData(14);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setVillager(boolean villager) {
|
|
||||||
setValue(13, (byte) (villager ? 1 : 0));
|
|
||||||
sendData(13);
|
sendData(13);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the profession of this zombie, in turn
|
||||||
|
* turning it into a Zombie Villager
|
||||||
|
* @param id
|
||||||
|
*/
|
||||||
|
public void setProfession(int id) {
|
||||||
|
setValue(12, id);
|
||||||
|
sendData(12);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the profession of this zombie, in turn
|
||||||
|
* turning it into a Zombie Villager
|
||||||
|
* @param profession
|
||||||
|
*/
|
||||||
|
public void setProfession(Profession profession) {
|
||||||
|
setValue(12, profession.getId());
|
||||||
|
sendData(12);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAggressive(boolean handsup) {
|
||||||
|
setValue(14, handsup);
|
||||||
|
sendData(14);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -699,6 +699,7 @@ public class DisguiseUtilities {
|
|||||||
/**
|
/**
|
||||||
* Resends the entity to all the watching players, which is where the magic begins
|
* Resends the entity to all the watching players, which is where the magic begins
|
||||||
*/
|
*/
|
||||||
|
//TODO: Check this method, something's not right here
|
||||||
public static void refreshTrackers(final TargetedDisguise disguise) {
|
public static void refreshTrackers(final TargetedDisguise disguise) {
|
||||||
if (disguise.getEntity().isValid()) {
|
if (disguise.getEntity().isValid()) {
|
||||||
PacketContainer destroyPacket = getDestroyPacket(disguise.getEntity().getEntityId());
|
PacketContainer destroyPacket = getDestroyPacket(disguise.getEntity().getEntityId());
|
||||||
|
@ -12,6 +12,8 @@ import com.comphenix.protocol.reflect.StructureModifier;
|
|||||||
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 com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
import com.comphenix.protocol.wrappers.WrappedDataWatcher;
|
||||||
|
import com.comphenix.protocol.wrappers.WrappedDataWatcher.Registry;
|
||||||
|
import com.comphenix.protocol.wrappers.WrappedDataWatcher.WrappedDataWatcherObject;
|
||||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
import com.comphenix.protocol.wrappers.WrappedGameProfile;
|
||||||
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
|
||||||
import me.libraryaddict.disguise.DisguiseAPI;
|
import me.libraryaddict.disguise.DisguiseAPI;
|
||||||
@ -26,6 +28,7 @@ import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
|
|||||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.PlayerWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.PlayerWatcher;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.SheepWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.SheepWatcher;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.watchers.SlimeWatcher;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.WolfWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.WolfWatcher;
|
||||||
import org.bukkit.Art;
|
import org.bukkit.Art;
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -39,6 +42,7 @@ import org.bukkit.entity.ExperienceOrb;
|
|||||||
import org.bukkit.entity.Item;
|
import org.bukkit.entity.Item;
|
||||||
import org.bukkit.entity.LivingEntity;
|
import org.bukkit.entity.LivingEntity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
import org.bukkit.entity.Slime;
|
||||||
import org.bukkit.inventory.EquipmentSlot;
|
import org.bukkit.inventory.EquipmentSlot;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
import org.bukkit.metadata.FixedMetadataValue;
|
import org.bukkit.metadata.FixedMetadataValue;
|
||||||
@ -114,7 +118,6 @@ public class PacketsManager {
|
|||||||
public static PacketContainer[][] constructSpawnPackets(final Player player, Disguise disguise, Entity disguisedEntity) {
|
public static PacketContainer[][] constructSpawnPackets(final Player player, Disguise disguise, Entity disguisedEntity) {
|
||||||
if (disguise.getEntity() == null)
|
if (disguise.getEntity() == null)
|
||||||
disguise.setEntity(disguisedEntity);
|
disguise.setEntity(disguisedEntity);
|
||||||
Object nmsEntity = ReflectionManager.getNmsEntity(disguisedEntity);
|
|
||||||
ArrayList<PacketContainer> packets = new ArrayList<>();
|
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
|
||||||
@ -170,6 +173,7 @@ public class PacketsManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
if (disguise.getType() == DisguiseType.EXPERIENCE_ORB) {
|
if (disguise.getType() == DisguiseType.EXPERIENCE_ORB) {
|
||||||
|
//TODO: Fix experience orb
|
||||||
spawnPackets[0] = new PacketContainer(Server.SPAWN_ENTITY_EXPERIENCE_ORB);
|
spawnPackets[0] = new PacketContainer(Server.SPAWN_ENTITY_EXPERIENCE_ORB);
|
||||||
StructureModifier<Object> mods = spawnPackets[0].getModifier();
|
StructureModifier<Object> mods = spawnPackets[0].getModifier();
|
||||||
mods.write(0, disguisedEntity.getEntityId());
|
mods.write(0, disguisedEntity.getEntityId());
|
||||||
@ -178,13 +182,15 @@ public class PacketsManager {
|
|||||||
mods.write(3, Math.floor(loc.getZ() * 32));
|
mods.write(3, Math.floor(loc.getZ() * 32));
|
||||||
mods.write(4, 1);
|
mods.write(4, 1);
|
||||||
} else if (disguise.getType() == DisguiseType.PAINTING) {
|
} else if (disguise.getType() == DisguiseType.PAINTING) {
|
||||||
|
//TODO: Fix painting
|
||||||
spawnPackets[0] = new PacketContainer(Server.SPAWN_ENTITY_PAINTING);
|
spawnPackets[0] = new PacketContainer(Server.SPAWN_ENTITY_PAINTING);
|
||||||
StructureModifier<Object> mods = spawnPackets[0].getModifier();
|
StructureModifier<Object> mods = spawnPackets[0].getModifier();
|
||||||
mods.write(0, disguisedEntity.getEntityId());
|
mods.write(0, disguisedEntity.getEntityId());
|
||||||
mods.write(1, ReflectionManager.getBlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
mods.write(1, disguisedEntity.getUniqueId());
|
||||||
mods.write(2, ReflectionManager.getEnumDirection(((int) loc.getYaw()) % 4));
|
mods.write(2, ReflectionManager.getBlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ()));
|
||||||
|
mods.write(3, ReflectionManager.getEnumDirection(((int) loc.getYaw()) % 4));
|
||||||
int id = ((MiscDisguise) disguise).getData();
|
int id = ((MiscDisguise) disguise).getData();
|
||||||
mods.write(3, ReflectionManager.getEnumArt(Art.values()[id]));
|
mods.write(4, ReflectionManager.getEnumArt(Art.values()[id]));
|
||||||
|
|
||||||
// Make the teleport packet to make it visible..
|
// Make the teleport packet to make it visible..
|
||||||
spawnPackets[1] = new PacketContainer(Server.ENTITY_TELEPORT);
|
spawnPackets[1] = new PacketContainer(Server.ENTITY_TELEPORT);
|
||||||
@ -265,19 +271,26 @@ public class PacketsManager {
|
|||||||
|
|
||||||
} else if (disguise.getType().isMob() || disguise.getType() == DisguiseType.ARMOR_STAND) {
|
} else if (disguise.getType().isMob() || disguise.getType() == DisguiseType.ARMOR_STAND) {
|
||||||
Class<? extends Entity> entityClass = disguise.getType().getEntityClass();
|
Class<? extends Entity> entityClass = disguise.getType().getEntityClass();
|
||||||
|
int entityId = disguise.getType().getEntityId();
|
||||||
Entity entity = Bukkit.getWorlds().get(0).spawn(disguise.getEntity().getLocation(), entityClass);
|
Entity entity = Bukkit.getWorlds().get(0).spawn(disguise.getEntity().getLocation(), entityClass);
|
||||||
entity.setVelocity(disguisedEntity.getVelocity());
|
entity.setVelocity(disguisedEntity.getVelocity());
|
||||||
|
if (disguise.getType() == DisguiseType.SLIME || disguise.getType() == DisguiseType.MAGMA_CUBE) {
|
||||||
|
((Slime)entity).setSize(((SlimeWatcher)disguise.getWatcher()).getSize());
|
||||||
|
}
|
||||||
Object nms = ReflectionManager.getNmsEntity(entity);
|
Object nms = ReflectionManager.getNmsEntity(entity);
|
||||||
PacketContainer packet = ProtocolLibrary.getProtocolManager().createPacketConstructor(Server.SPAWN_ENTITY_LIVING, nms)
|
PacketContainer packet = ProtocolLibrary.getProtocolManager().createPacketConstructor(Server.SPAWN_ENTITY_LIVING, nms).createPacket(nms);
|
||||||
.createPacket(nms);
|
|
||||||
spawnPackets[0] = packet;
|
spawnPackets[0] = packet;
|
||||||
spawnPackets[0].getDataWatcherModifier().write(0,
|
spawnPackets[0].getIntegers().write(0, entityId);
|
||||||
createDataWatcher(WrappedDataWatcher.getEntityWatcher(disguisedEntity), disguise.getWatcher()));
|
spawnPackets[0].getDataWatcherModifier().write(0, createDataWatcher(WrappedDataWatcher.getEntityWatcher(disguisedEntity), disguise.getWatcher()));
|
||||||
entity.remove();
|
entity.remove();
|
||||||
//You know, as cheap as this may seem, this is pretty damn effective
|
//You know, as cheap as this may seem, this is pretty damn effective
|
||||||
} else if (disguise.getType().isMisc()) {
|
} else if (disguise.getType().isMisc()) {
|
||||||
//TODO: Fix miscs
|
//TODO: Fix miscs
|
||||||
int id = disguise.getType().getEntityId();
|
Class<? extends Entity> entityClass = disguise.getType().getEntityClass();
|
||||||
|
Entity entity = Bukkit.getWorlds().get(0).spawn(disguise.getEntity().getLocation().add(0, 0.5, 0), entityClass);
|
||||||
|
entity.setVelocity(disguisedEntity.getVelocity());
|
||||||
|
int entityId = disguise.getType().getEntityId();
|
||||||
|
int typeId = disguise.getType().getTypeId();
|
||||||
int data = ((MiscDisguise) disguise).getData();
|
int data = ((MiscDisguise) disguise).getData();
|
||||||
if (disguise.getType() == DisguiseType.FALLING_BLOCK) {
|
if (disguise.getType() == DisguiseType.FALLING_BLOCK) {
|
||||||
data = (((MiscDisguise) disguise).getId() | data << 16);
|
data = (((MiscDisguise) disguise).getId() | data << 16);
|
||||||
@ -287,12 +300,10 @@ public class PacketsManager {
|
|||||||
} else if (disguise.getType() == DisguiseType.ITEM_FRAME) {
|
} else if (disguise.getType() == DisguiseType.ITEM_FRAME) {
|
||||||
data = ((((int) loc.getYaw() % 360) + 720 + 45) / 90) % 4;
|
data = ((((int) loc.getYaw() % 360) + 720 + 45) / 90) % 4;
|
||||||
}
|
}
|
||||||
spawnPackets[0] = ProtocolLibrary.getProtocolManager()
|
Object nms = ReflectionManager.getNmsEntity(entity);
|
||||||
.createPacketConstructor(Server.SPAWN_ENTITY, nmsEntity, id, data)
|
spawnPackets[0] = ProtocolLibrary.getProtocolManager().createPacketConstructor(Server.SPAWN_ENTITY, nms, typeId, data)
|
||||||
.createPacket(nmsEntity, id, data);
|
.createPacket(nms, typeId, data);
|
||||||
spawnPackets[0].getModifier().write(2, (int) Math.floor(loc.getY() * 32D));
|
spawnPackets[0].getIntegers().write(0, entityId);
|
||||||
spawnPackets[0].getModifier().write(7, pitch);
|
|
||||||
spawnPackets[0].getModifier().write(8, yaw);
|
|
||||||
if (disguise.getType() == DisguiseType.ITEM_FRAME) {
|
if (disguise.getType() == DisguiseType.ITEM_FRAME) {
|
||||||
if (data % 2 == 0) {
|
if (data % 2 == 0) {
|
||||||
spawnPackets[0].getModifier().write(3, (int) Math.floor((loc.getZ() + (data == 0 ? -1 : 1)) * 32D));
|
spawnPackets[0].getModifier().write(3, (int) Math.floor((loc.getZ() + (data == 0 ? -1 : 1)) * 32D));
|
||||||
@ -300,6 +311,7 @@ public class PacketsManager {
|
|||||||
spawnPackets[0].getModifier().write(1, (int) Math.floor((loc.getX() + (data == 3 ? -1 : 1)) * 32D));
|
spawnPackets[0].getModifier().write(1, (int) Math.floor((loc.getX() + (data == 3 ? -1 : 1)) * 32D));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
entity.remove();
|
||||||
}
|
}
|
||||||
if (spawnPackets[1] == null || disguise.isPlayerDisguise()) {
|
if (spawnPackets[1] == null || disguise.isPlayerDisguise()) {
|
||||||
int entry = spawnPackets[1] == null ? 1 : 0;
|
int entry = spawnPackets[1] == null ? 1 : 0;
|
||||||
@ -320,13 +332,15 @@ public class PacketsManager {
|
|||||||
* Create a new datawatcher but with the 'correct' values
|
* Create a new datawatcher but with the 'correct' values
|
||||||
*/
|
*/
|
||||||
private static WrappedDataWatcher createDataWatcher(WrappedDataWatcher watcher, FlagWatcher flagWatcher) {
|
private static WrappedDataWatcher createDataWatcher(WrappedDataWatcher watcher, FlagWatcher flagWatcher) {
|
||||||
//TODO: Specify a serializer...
|
|
||||||
WrappedDataWatcher newWatcher = new WrappedDataWatcher();
|
WrappedDataWatcher newWatcher = new WrappedDataWatcher();
|
||||||
try {
|
try {
|
||||||
List<WrappedWatchableObject> list = DisguiseConfig.isMetadataPacketsEnabled() ?
|
List<WrappedWatchableObject> list = DisguiseConfig.isMetadataPacketsEnabled() ?
|
||||||
flagWatcher.convert(watcher.getWatchableObjects()) : flagWatcher.getWatchableObjects();
|
flagWatcher.convert(watcher.getWatchableObjects()) : flagWatcher.getWatchableObjects();
|
||||||
for (WrappedWatchableObject watchableObject : list) {
|
for (WrappedWatchableObject watchableObject : list) {
|
||||||
newWatcher.setObject(watchableObject.getWatcherObject(), watchableObject.getValue());
|
if (watchableObject.getValue() == null) continue;
|
||||||
|
if (Registry.get(watchableObject.getValue().getClass()) == null) continue;
|
||||||
|
WrappedDataWatcherObject obj = new WrappedDataWatcherObject(watchableObject.getIndex(), Registry.get(watchableObject.getValue().getClass()));
|
||||||
|
newWatcher.setObject(obj, watchableObject.getValue());
|
||||||
}
|
}
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
ex.printStackTrace();
|
ex.printStackTrace();
|
||||||
@ -912,7 +926,7 @@ public class PacketsManager {
|
|||||||
} else if (event.getPacketType() == PacketType.Play.Client.WINDOW_CLICK) {
|
} else if (event.getPacketType() == PacketType.Play.Client.WINDOW_CLICK) {
|
||||||
int slot = event.getPacket().getIntegers().read(1);
|
int slot = event.getPacket().getIntegers().read(1);
|
||||||
org.bukkit.inventory.ItemStack clickedItem;
|
org.bukkit.inventory.ItemStack clickedItem;
|
||||||
if (event.getPacket().getIntegers().read(3) == 1) {
|
if (event.getPacket().getShorts().read(3) == 1) {
|
||||||
// Its a shift click
|
// Its a shift click
|
||||||
clickedItem = event.getPacket().getItemModifier().read(0);
|
clickedItem = event.getPacket().getItemModifier().read(0);
|
||||||
if (clickedItem != null && clickedItem.getType() != Material.AIR) {
|
if (clickedItem != null && clickedItem.getType() != Material.AIR) {
|
||||||
|
Loading…
Reference in New Issue
Block a user