Fix up stuff a little for latest ProtocolLib, more disguise params

This commit is contained in:
libraryaddict 2016-07-08 17:59:30 +12:00
parent 37395a1a6d
commit e6627c1fea
8 changed files with 75 additions and 34 deletions

View File

@ -37,7 +37,7 @@
<dependency>
<groupId>com.comphenix.protocol</groupId>
<artifactId>ProtocolLib</artifactId>
<version>4.0.0-SNAPSHOT</version>
<version>4.1.0-SNAPSHOT</version>
</dependency>
<dependency>
<groupId>org.spigotmc</groupId>

View File

@ -23,6 +23,7 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.permissions.PermissionAttachmentInfo;
import org.bukkit.potion.PotionEffectType;
import com.comphenix.protocol.wrappers.BlockPosition;
import com.comphenix.protocol.wrappers.WrappedGameProfile;
import com.comphenix.protocol.wrappers.WrappedSignedProperty;
import com.google.gson.Gson;
@ -952,7 +953,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor
{
BlockFace face = BlockFace.valueOf(valueString.toUpperCase());
if (face.ordinal() > 4)
if (face.ordinal() > 5)
{
throw new DisguiseParseException();
}
@ -961,7 +962,8 @@ public abstract class BaseDisguiseCommand implements CommandExecutor
}
catch (Exception ex)
{
throw parseToException("a direction (north, east, south, west, up)", valueString, methodName);
throw parseToException("a direction (north, east, south, west, up, down)", valueString,
methodName);
}
}
else if (param == RabbitType.class)
@ -988,6 +990,23 @@ public abstract class BaseDisguiseCommand implements CommandExecutor
throw parseToException("rabbit type (white, brown, patches...)", valueString, methodName);
}
}
else if (param == BlockPosition.class)
{
try
{
String[] split = valueString.split(",");
assert split.length == 3;
value = new BlockPosition(Integer.parseInt(split[0]), Integer.parseInt(split[1]),
Integer.parseInt(split[2]));
}
catch (Exception ex)
{
throw parseToException("three numbers Number,Number,Number", valueString,
methodName);
}
}
}
if (value == null && boolean.class == param)

View File

@ -14,6 +14,9 @@ import org.bukkit.command.CommandSender;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffectType;
import com.comphenix.protocol.wrappers.BlockPosition;
import com.comphenix.protocol.wrappers.WrappedGameProfile;
import me.libraryaddict.disguise.disguisetypes.AnimalColor;
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
@ -316,6 +319,15 @@ public class HelpDisguiseCommand extends BaseDisguiseCommand
{
valueType = "rabbit type";
}
else if (c == BlockPosition.class)
{
valueType = "three numbers";
}
else if (c == WrappedGameProfile.class)
{
valueType = "gameprofile";
}
if (valueType != null)
{
ChatColor methodColor = ChatColor.YELLOW;

View File

@ -8,11 +8,10 @@ import java.util.UUID;
import org.bukkit.Color;
import org.bukkit.Material;
import org.bukkit.block.BlockFace;
import org.bukkit.inventory.ItemStack;
import org.bukkit.util.EulerAngle;
import com.comphenix.protocol.wrappers.BlockPosition;
import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
import com.comphenix.protocol.wrappers.Vector3F;
import com.comphenix.protocol.wrappers.WrappedBlockData;
import com.google.common.base.Optional;
@ -79,23 +78,23 @@ public class FlagType<Y>
public static FlagType<Float> AREA_EFFECT_RADIUS = new FlagType<Float>(AreaEffectCloudWatcher.class, 0, 0F);
public static FlagType<EulerAngle> ARMORSTAND_BODY = new FlagType<EulerAngle>(ArmorStandWatcher.class, 2,
new EulerAngle(0, 0, 0));
public static FlagType<Vector3F> ARMORSTAND_BODY = new FlagType<Vector3F>(ArmorStandWatcher.class, 2,
new Vector3F(0, 0, 0));
public static FlagType<EulerAngle> ARMORSTAND_HEAD = new FlagType<EulerAngle>(ArmorStandWatcher.class, 1,
new EulerAngle(0, 0, 0));
public static FlagType<Vector3F> ARMORSTAND_HEAD = new FlagType<Vector3F>(ArmorStandWatcher.class, 1,
new Vector3F(0, 0, 0));
public static FlagType<EulerAngle> ARMORSTAND_LEFT_ARM = new FlagType<EulerAngle>(ArmorStandWatcher.class, 3,
new EulerAngle(0, 0, 0));
public static FlagType<Vector3F> ARMORSTAND_LEFT_ARM = new FlagType<Vector3F>(ArmorStandWatcher.class, 3,
new Vector3F(0, 0, 0));
public static FlagType<EulerAngle> ARMORSTAND_LEFT_LEG = new FlagType<EulerAngle>(ArmorStandWatcher.class, 5,
new EulerAngle(0, 0, 0));
public static FlagType<Vector3F> ARMORSTAND_LEFT_LEG = new FlagType<Vector3F>(ArmorStandWatcher.class, 5,
new Vector3F(0, 0, 0));
public static FlagType<Byte> ARMORSTAND_META = new FlagType<Byte>(ArmorStandWatcher.class, 0, (byte) 0);
public static FlagType<EulerAngle> ARMORSTAND_RIGHT_ARM = new FlagType<EulerAngle>(ArmorStandWatcher.class, 4, new EulerAngle(0,0,0));
public static FlagType<Vector3F> ARMORSTAND_RIGHT_ARM = new FlagType<Vector3F>(ArmorStandWatcher.class, 4, new Vector3F(0,0,0));
public static FlagType<EulerAngle> ARMORSTAND_RIGHT_LEG = new FlagType<EulerAngle>(ArmorStandWatcher.class, 6, new EulerAngle(0,0,0));
public static FlagType<Vector3F> ARMORSTAND_RIGHT_LEG = new FlagType<Vector3F>(ArmorStandWatcher.class, 6, new Vector3F(0,0,0));
public static FlagType<Byte> ARROW_CRITICAL = new FlagType<Byte>(ArrowWatcher.class, 0, (byte) 0);
@ -225,7 +224,7 @@ public class FlagType<Y>
public static FlagType<Optional<BlockPosition>> SHULKER_ATTACHED = new FlagType<Optional<BlockPosition>>(ShulkerWatcher.class,
1, Optional.<BlockPosition> absent());
public static FlagType<BlockFace> SHULKER_FACING = new FlagType<BlockFace>(ShulkerWatcher.class, 0, BlockFace.DOWN);
public static FlagType<Direction> SHULKER_FACING = new FlagType<Direction>(ShulkerWatcher.class, 0, Direction.DOWN);
public static FlagType<Byte> SHULKER_PEEKING = new FlagType<Byte>(ShulkerWatcher.class, 2, (byte) 0);

View File

@ -1,6 +1,9 @@
package me.libraryaddict.disguise.disguisetypes.watchers;
import org.bukkit.util.EulerAngle;
import com.comphenix.protocol.wrappers.Vector3F;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.FlagType;
@ -36,12 +39,14 @@ public class ArmorStandWatcher extends LivingWatcher
return getPose(FlagType.ARMORSTAND_LEFT_LEG);
}
private EulerAngle getPose(FlagType<EulerAngle> type)
private EulerAngle getPose(FlagType<Vector3F> type)
{
if (!hasValue(type))
setValue(type, new EulerAngle(0, 0, 0));
return new EulerAngle(0, 0, 0);
return getValue(type);
Vector3F vec = getValue(type);
return new EulerAngle(vec.getX(), vec.getY(), vec.getZ());
}
public EulerAngle getRightArm()
@ -134,9 +139,9 @@ public class ArmorStandWatcher extends LivingWatcher
sendData(FlagType.ARMORSTAND_META);
}
private void setPose(FlagType type, EulerAngle vector)
private void setPose(FlagType<Vector3F> type, EulerAngle vector)
{
setValue(type, vector);
setValue(type, new Vector3F((float) vector.getX(), (float) vector.getY(), (float) vector.getZ()));
sendData(type);
}

View File

@ -3,6 +3,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers;
import org.bukkit.block.BlockFace;
import com.comphenix.protocol.wrappers.BlockPosition;
import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
import com.google.common.base.Optional;
import me.libraryaddict.disguise.disguisetypes.Disguise;
@ -21,12 +22,12 @@ public class ShulkerWatcher extends InsentientWatcher
public BlockFace getFacingDirection()
{
return getValue(FlagType.SHULKER_FACING);
return BlockFace.valueOf(getValue(FlagType.SHULKER_FACING).name());
}
public void setFacingDirection(BlockFace face)
{
setValue(FlagType.SHULKER_FACING, face);
setValue(FlagType.SHULKER_FACING, Direction.valueOf(face.name()));
sendData(FlagType.SHULKER_FACING);
}

View File

@ -738,7 +738,6 @@ public class PacketsManager
{
packetsToListen.add(Server.ENTITY_LOOK);
packetsToListen.add(Server.REL_ENTITY_MOVE_LOOK);
packetsToListen.add(Server.REL_ENTITY_MOVE_LOOK);
packetsToListen.add(Server.ENTITY_HEAD_ROTATION);
packetsToListen.add(Server.ENTITY_TELEPORT);
packetsToListen.add(Server.REL_ENTITY_MOVE);

View File

@ -15,7 +15,6 @@ import org.bukkit.Location;
import org.bukkit.Material;
import org.bukkit.Sound;
import org.bukkit.World;
import org.bukkit.block.BlockFace;
import org.bukkit.entity.Ambient;
import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
@ -25,10 +24,10 @@ import org.bukkit.inventory.EntityEquipment;
import org.bukkit.inventory.EquipmentSlot;
import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffect;
import org.bukkit.util.EulerAngle;
import com.comphenix.protocol.wrappers.BlockPosition;
import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
import com.comphenix.protocol.wrappers.MinecraftKey;
import com.comphenix.protocol.wrappers.Vector3F;
import com.comphenix.protocol.wrappers.WrappedDataWatcher.Registry;
import com.comphenix.protocol.wrappers.WrappedDataWatcher.Serializer;
import com.comphenix.protocol.wrappers.WrappedDataWatcher.WrappedDataWatcherObject;
@ -941,23 +940,30 @@ public class ReflectionManager
}
}
}
else if (value instanceof EulerAngle)
else if (value instanceof Vector3F)
{
EulerAngle angle = (EulerAngle) value;
Vector3F angle = (Vector3F) value;
try
{
return getNmsConstructor("Vector3f", float.class, float.class, float.class).newInstance((float) angle.getX(),
(float) angle.getY(), (float) angle.getZ());
return getNmsConstructor("Vector3f", float.class, float.class, float.class).newInstance(angle.getX(),
angle.getY(), angle.getZ());
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
else if (value instanceof BlockFace)
else if (value instanceof Direction)
{
return getEnumDirection(((BlockFace) value).ordinal());
try
{
return (Enum) getNmsMethod("EnumDirection", "fromType1", int.class).invoke(null, ((Direction) value).ordinal());
}
catch (Exception ex)
{
ex.printStackTrace();
}
}
return value;