Fix null, fixed FlagWatchers, fixed typo on EquipmentSlot

This commit is contained in:
libraryaddict 2016-07-05 17:01:51 +12:00
parent dedc043558
commit d98333f0f1
6 changed files with 35 additions and 26 deletions

View File

@ -152,6 +152,9 @@ public class DisguiseListener implements Listener
{ {
for (TargetedDisguise disguise : list) for (TargetedDisguise disguise : list)
{ {
if (disguise.getEntity() == null)
continue;
if (!disguise.isPlayerDisguise()) if (!disguise.isPlayerDisguise())
continue; continue;

View File

@ -53,7 +53,7 @@ public abstract class Disguise
private boolean keepDisguisePlayerLogout = DisguiseConfig.isKeepDisguiseOnPlayerLogout(); private boolean keepDisguisePlayerLogout = DisguiseConfig.isKeepDisguiseOnPlayerLogout();
private boolean modifyBoundingBox = DisguiseConfig.isModifyBoundingBox(); private boolean modifyBoundingBox = DisguiseConfig.isModifyBoundingBox();
private boolean replaceSounds = DisguiseConfig.isSoundEnabled(); private boolean replaceSounds = DisguiseConfig.isSoundEnabled();
private BukkitTask task = null; private BukkitTask task;
private Runnable velocityRunnable; private Runnable velocityRunnable;
private boolean velocitySent = DisguiseConfig.isVelocitySent(); private boolean velocitySent = DisguiseConfig.isVelocitySent();
private boolean viewSelfDisguise = DisguiseConfig.isViewDisguises(); private boolean viewSelfDisguise = DisguiseConfig.isViewDisguises();

View File

@ -10,7 +10,7 @@ import org.bukkit.Color;
import org.bukkit.Material; import org.bukkit.Material;
import org.bukkit.block.BlockFace; import org.bukkit.block.BlockFace;
import org.bukkit.inventory.ItemStack; import org.bukkit.inventory.ItemStack;
import org.bukkit.util.Vector; import org.bukkit.util.EulerAngle;
import com.comphenix.protocol.wrappers.BlockPosition; import com.comphenix.protocol.wrappers.BlockPosition;
import com.comphenix.protocol.wrappers.WrappedBlockData; import com.comphenix.protocol.wrappers.WrappedBlockData;
@ -79,19 +79,23 @@ public class FlagType<Y>
public static FlagType<Float> AREA_EFFECT_RADIUS = new FlagType<Float>(AreaEffectCloudWatcher.class, 0, 0F); public static FlagType<Float> AREA_EFFECT_RADIUS = new FlagType<Float>(AreaEffectCloudWatcher.class, 0, 0F);
public static FlagType<Vector> ARMORSTAND_BODY = new FlagType<Vector>(ArmorStandWatcher.class, 2, new Vector()); public static FlagType<EulerAngle> ARMORSTAND_BODY = new FlagType<EulerAngle>(ArmorStandWatcher.class, 2,
new EulerAngle(0, 0, 0));
public static FlagType<Vector> ARMORSTAND_HEAD = new FlagType<Vector>(ArmorStandWatcher.class, 1, new Vector()); public static FlagType<EulerAngle> ARMORSTAND_HEAD = new FlagType<EulerAngle>(ArmorStandWatcher.class, 1,
new EulerAngle(0, 0, 0));
public static FlagType<Vector> ARMORSTAND_LEFT_ARM = new FlagType<Vector>(ArmorStandWatcher.class, 3, new Vector()); public static FlagType<EulerAngle> ARMORSTAND_LEFT_ARM = new FlagType<EulerAngle>(ArmorStandWatcher.class, 3,
new EulerAngle(0, 0, 0));
public static FlagType<Vector> ARMORSTAND_LEFT_LEG = new FlagType<Vector>(ArmorStandWatcher.class, 5, new Vector()); public static FlagType<EulerAngle> ARMORSTAND_LEFT_LEG = new FlagType<EulerAngle>(ArmorStandWatcher.class, 5,
new EulerAngle(0, 0, 0));
public static FlagType<Byte> ARMORSTAND_META = new FlagType<Byte>(ArmorStandWatcher.class, 0, (byte) 0); public static FlagType<Byte> ARMORSTAND_META = new FlagType<Byte>(ArmorStandWatcher.class, 0, (byte) 0);
public static FlagType<Vector> ARMORSTAND_RIGHT_ARM = new FlagType<Vector>(ArmorStandWatcher.class, 4, new Vector()); public static FlagType<EulerAngle> ARMORSTAND_RIGHT_ARM = new FlagType<EulerAngle>(ArmorStandWatcher.class, 4, new EulerAngle(0,0,0));
public static FlagType<Vector> ARMORSTAND_RIGHT_LEG = new FlagType<Vector>(ArmorStandWatcher.class, 6, new Vector()); public static FlagType<EulerAngle> ARMORSTAND_RIGHT_LEG = new FlagType<EulerAngle>(ArmorStandWatcher.class, 6, new EulerAngle(0,0,0));
public static FlagType<Byte> ARROW_CRITICAL = new FlagType<Byte>(ArrowWatcher.class, 0, (byte) 0); public static FlagType<Byte> ARROW_CRITICAL = new FlagType<Byte>(ArrowWatcher.class, 0, (byte) 0);

View File

@ -1,7 +1,6 @@
package me.libraryaddict.disguise.disguisetypes.watchers; package me.libraryaddict.disguise.disguisetypes.watchers;
import org.bukkit.util.Vector; import org.bukkit.util.EulerAngle;
import me.libraryaddict.disguise.disguisetypes.Disguise; import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.FlagType; import me.libraryaddict.disguise.disguisetypes.FlagType;
@ -17,40 +16,40 @@ public class ArmorStandWatcher extends LivingWatcher
return (getValue(FlagType.ARMORSTAND_META) & value) != 0; return (getValue(FlagType.ARMORSTAND_META) & value) != 0;
} }
public Vector getBody() public EulerAngle getBody()
{ {
return getPose(FlagType.ARMORSTAND_BODY); return getPose(FlagType.ARMORSTAND_BODY);
} }
public Vector getHead() public EulerAngle getHead()
{ {
return getPose(FlagType.ARMORSTAND_HEAD); return getPose(FlagType.ARMORSTAND_HEAD);
} }
public Vector getLeftArm() public EulerAngle getLeftArm()
{ {
return getPose(FlagType.ARMORSTAND_LEFT_ARM); return getPose(FlagType.ARMORSTAND_LEFT_ARM);
} }
public Vector getLeftLeg() public EulerAngle getLeftLeg()
{ {
return getPose(FlagType.ARMORSTAND_LEFT_LEG); return getPose(FlagType.ARMORSTAND_LEFT_LEG);
} }
private Vector getPose(FlagType<Vector> type) private EulerAngle getPose(FlagType<EulerAngle> type)
{ {
if (!hasValue(type)) if (!hasValue(type))
setValue(type, new Vector()); setValue(type, new EulerAngle(0, 0, 0));
return getValue(type); return getValue(type);
} }
public Vector getRightArm() public EulerAngle getRightArm()
{ {
return getPose(FlagType.ARMORSTAND_RIGHT_ARM); return getPose(FlagType.ARMORSTAND_RIGHT_ARM);
} }
public Vector getRightLeg() public EulerAngle getRightLeg()
{ {
return getPose(FlagType.ARMORSTAND_RIGHT_LEG); return getPose(FlagType.ARMORSTAND_RIGHT_LEG);
} }
@ -97,22 +96,22 @@ public class ArmorStandWatcher extends LivingWatcher
sendData(FlagType.ARMORSTAND_META); sendData(FlagType.ARMORSTAND_META);
} }
public void setBody(Vector vector) public void setBody(EulerAngle vector)
{ {
setPose(FlagType.ARMORSTAND_BODY, vector); setPose(FlagType.ARMORSTAND_BODY, vector);
} }
public void setHead(Vector vector) public void setHead(EulerAngle vector)
{ {
setPose(FlagType.ARMORSTAND_HEAD, vector); setPose(FlagType.ARMORSTAND_HEAD, vector);
} }
public void setLeftArm(Vector vector) public void setLeftArm(EulerAngle vector)
{ {
setPose(FlagType.ARMORSTAND_LEFT_ARM, vector); setPose(FlagType.ARMORSTAND_LEFT_ARM, vector);
} }
public void setLeftLeg(Vector vector) public void setLeftLeg(EulerAngle vector)
{ {
setPose(FlagType.ARMORSTAND_LEFT_LEG, vector); setPose(FlagType.ARMORSTAND_LEFT_LEG, vector);
} }
@ -135,18 +134,18 @@ public class ArmorStandWatcher extends LivingWatcher
sendData(FlagType.ARMORSTAND_META); sendData(FlagType.ARMORSTAND_META);
} }
private void setPose(FlagType type, Vector vector) private void setPose(FlagType type, EulerAngle vector)
{ {
setValue(type, vector); setValue(type, vector);
sendData(type); sendData(type);
} }
public void setRightArm(Vector vector) public void setRightArm(EulerAngle vector)
{ {
setPose(FlagType.ARMORSTAND_RIGHT_ARM, vector); setPose(FlagType.ARMORSTAND_RIGHT_ARM, vector);
} }
public void setRightLeg(Vector vector) public void setRightLeg(EulerAngle vector)
{ {
setPose(FlagType.ARMORSTAND_RIGHT_LEG, vector); setPose(FlagType.ARMORSTAND_RIGHT_LEG, vector);
} }

View File

@ -606,6 +606,9 @@ public class DisguiseUtilities
if (mainThread != Thread.currentThread()) if (mainThread != Thread.currentThread())
throw new IllegalStateException("Cannot modify disguises on an async thread"); throw new IllegalStateException("Cannot modify disguises on an async thread");
if (disguise.getEntity() == null)
throw new IllegalStateException("The entity for the disguisetype " + disguise.getType().name() + " is null!");
List<Player> players = new ArrayList<>(); List<Player> players = new ArrayList<>();
try try

View File

@ -831,7 +831,7 @@ public class ReflectionManager
case "CHEST": case "CHEST":
return EquipmentSlot.CHEST; return EquipmentSlot.CHEST;
case "HEAD": case "HEAD":
return EquipmentSlot.HAND; return EquipmentSlot.HEAD;
} }
} }
catch (Exception e) catch (Exception e)