Current work
This commit is contained in:
parent
8e255c5ccf
commit
e751cf4582
4
pom.xml
4
pom.xml
@ -42,12 +42,12 @@
|
|||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot-api</artifactId>
|
<artifactId>spigot-api</artifactId>
|
||||||
<version>1.9.4-R0.1-SNAPSHOT</version>
|
<version>1.10-R0.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
<dependency>
|
<dependency>
|
||||||
<groupId>org.spigotmc</groupId>
|
<groupId>org.spigotmc</groupId>
|
||||||
<artifactId>spigot</artifactId>
|
<artifactId>spigot</artifactId>
|
||||||
<version>1.9.4-R0.1-SNAPSHOT</version>
|
<version>1.10-R0.1-SNAPSHOT</version>
|
||||||
</dependency>
|
</dependency>
|
||||||
</dependencies>
|
</dependencies>
|
||||||
|
|
||||||
|
@ -30,6 +30,7 @@ import me.libraryaddict.disguise.commands.UndisguiseEntityCommand;
|
|||||||
import me.libraryaddict.disguise.commands.UndisguisePlayerCommand;
|
import me.libraryaddict.disguise.commands.UndisguisePlayerCommand;
|
||||||
import me.libraryaddict.disguise.commands.UndisguiseRadiusCommand;
|
import me.libraryaddict.disguise.commands.UndisguiseRadiusCommand;
|
||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher;
|
||||||
import me.libraryaddict.disguise.disguisetypes.watchers.GuardianWatcher;
|
import me.libraryaddict.disguise.disguisetypes.watchers.GuardianWatcher;
|
||||||
@ -299,7 +300,18 @@ public class LibsDisguises extends JavaPlugin
|
|||||||
|
|
||||||
for (WrappedWatchableObject watch : watcher.getWatchableObjects())
|
for (WrappedWatchableObject watch : watcher.getWatchableObjects())
|
||||||
{
|
{
|
||||||
disguiseValues.setMetaValue(watch.getIndex(), watch.getValue());
|
FlagType flagType = FlagType.getFlag(watcherClass, watch.getIndex());
|
||||||
|
|
||||||
|
if (flagType == null)
|
||||||
|
{
|
||||||
|
System.err.println("Error finding the FlagType for " + disguiseType.name() + "! " + watch.getIndex()
|
||||||
|
+ " cannot be found!");
|
||||||
|
System.err.println("Lib's Disguises will continue to load, but this will not work properly!");
|
||||||
|
continue;
|
||||||
|
}
|
||||||
|
|
||||||
|
disguiseValues.setMetaValue(flagType, watch.getValue());
|
||||||
|
|
||||||
// Uncomment when I need to find the new datawatcher values for a class..
|
// Uncomment when I need to find the new datawatcher values for a class..
|
||||||
// int id = watch.getIndex();
|
// int id = watch.getIndex();
|
||||||
// Object val = watch.getValue();
|
// Object val = watch.getValue();
|
||||||
|
@ -6,6 +6,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.Map.Entry;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
@ -782,134 +783,15 @@ public abstract class Disguise
|
|||||||
*/
|
*/
|
||||||
private void setupWatcher()
|
private void setupWatcher()
|
||||||
{
|
{
|
||||||
HashMap<Integer, Object> disguiseValues = DisguiseValues.getMetaValues(getType());
|
HashMap<FlagType, Object> disguiseValues = DisguiseValues.getMetaValues(getType());
|
||||||
HashMap<Integer, Object> entityValues = DisguiseValues.getMetaValues(DisguiseType.getType(getEntity().getType()));
|
HashMap<FlagType, Object> entityValues = DisguiseValues.getMetaValues(DisguiseType.getType(getEntity().getType()));
|
||||||
|
|
||||||
// Start from 2 as they ALL share 0 and 1
|
for (Entry<FlagType, Object> entry : entityValues.entrySet())
|
||||||
for (int dataNo = 0; dataNo <= 31; dataNo++)
|
|
||||||
{
|
{
|
||||||
// STEP 1. Find out if the watcher has set data on it.
|
if (disguiseValues.containsKey(entry.getKey()))
|
||||||
// If the watcher already set a metadata on this
|
|
||||||
if (getWatcher().hasValue(dataNo))
|
|
||||||
{
|
|
||||||
// Better check that the value is stable.
|
|
||||||
// To check this, I'm going to check if there exists a default value
|
|
||||||
// Then I'm going to check if the watcher value is the same as the default value.
|
|
||||||
if (disguiseValues.containsKey(dataNo))
|
|
||||||
{
|
|
||||||
// Now check if they are the same class, or both null.
|
|
||||||
if (disguiseValues.get(dataNo) == null || getWatcher().getValue(dataNo, null) == null)
|
|
||||||
{
|
|
||||||
if (disguiseValues.get(dataNo) == null && getWatcher().getValue(dataNo, null) == null)
|
|
||||||
{
|
|
||||||
// They are both null. Idk what this means really.
|
|
||||||
continue;
|
continue;
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (getWatcher().getValue(dataNo, null).getClass() == disguiseValues.get(dataNo).getClass())
|
|
||||||
{
|
|
||||||
// The classes are the same. The client "shouldn't" crash.
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// STEP 2. As the watcher has not set data on it, check if I need to set the default data.
|
getWatcher().setBackupValue(entry.getKey(), entry.getValue());
|
||||||
// If neither of them touch it
|
|
||||||
if (!entityValues.containsKey(dataNo) && !disguiseValues.containsKey(dataNo))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// If the disguise has this, but not the entity. Then better set it!
|
|
||||||
if (!entityValues.containsKey(dataNo) && disguiseValues.containsKey(dataNo))
|
|
||||||
{
|
|
||||||
getWatcher().setBackupValue(dataNo, disguiseValues.get(dataNo));
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Else if the disguise doesn't have it. But the entity does. Better remove it!
|
|
||||||
if (entityValues.containsKey(dataNo) && !disguiseValues.containsKey(dataNo))
|
|
||||||
{
|
|
||||||
getWatcher().setBackupValue(dataNo, null);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
Object eObj = entityValues.get(dataNo);
|
|
||||||
Object dObj = disguiseValues.get(dataNo);
|
|
||||||
|
|
||||||
if (eObj == null || dObj == null)
|
|
||||||
{
|
|
||||||
if (eObj == null && dObj == null)
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
getWatcher().setBackupValue(dataNo, dObj);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
if (eObj.getClass() != dObj.getClass())
|
|
||||||
{
|
|
||||||
getWatcher().setBackupValue(dataNo, dObj);
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Since they both share it. With the same classes. Time to check if its from something they extend.
|
|
||||||
// Better make this clear before I compare the values because some default values are different!
|
|
||||||
// Entity is 0 & 1 - But we aint gonna be checking that
|
|
||||||
// EntityAgeable is 11
|
|
||||||
// EntityInsentient is 10
|
|
||||||
// EntityLiving is 5 & 6 & 7 & 8 & 9
|
|
||||||
// Lets use switch
|
|
||||||
Class baseClass = null;
|
|
||||||
|
|
||||||
switch (dataNo)
|
|
||||||
{
|
|
||||||
case 5:
|
|
||||||
case 6:
|
|
||||||
case 7:
|
|
||||||
case 8:
|
|
||||||
case 9:
|
|
||||||
baseClass = ReflectionManager.getNmsClass("EntityLiving");
|
|
||||||
break;
|
|
||||||
case 10:
|
|
||||||
baseClass = ReflectionManager.getNmsClass("EntityInsentient");
|
|
||||||
break;
|
|
||||||
case 11:
|
|
||||||
baseClass = ReflectionManager.getNmsClass("EntityAgeable");
|
|
||||||
break;
|
|
||||||
default:
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
Class nmsEntityClass = ReflectionManager.getNmsEntity(getEntity()).getClass();
|
|
||||||
Class nmsDisguiseClass = DisguiseValues.getNmsEntityClass(getType());
|
|
||||||
|
|
||||||
if (nmsDisguiseClass != null)
|
|
||||||
{
|
|
||||||
// If they both extend the same base class. They OBVIOUSLY share the same datavalue. Right..?
|
|
||||||
if (baseClass != null && baseClass.isAssignableFrom(nmsDisguiseClass)
|
|
||||||
&& baseClass.isAssignableFrom(nmsEntityClass))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
// So they don't extend a basic class.
|
|
||||||
// Maybe if I check that they extend each other..
|
|
||||||
// Seeing as I only store the finished forms of entitys. This should raise no problems and allow for more shared
|
|
||||||
// datawatchers.
|
|
||||||
if (nmsEntityClass.isAssignableFrom(nmsDisguiseClass) || nmsDisguiseClass.isAssignableFrom(nmsEntityClass))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Well I can't find a reason I should leave it alone. They will probably conflict.
|
|
||||||
// Time to set the value to the disguises value so no conflicts!
|
|
||||||
getWatcher().setBackupValue(dataNo, disguiseValues.get(dataNo));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -337,7 +337,7 @@ public enum DisguiseType
|
|||||||
return objectId;
|
return objectId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Class getWatcherClass()
|
public Class<? extends FlagWatcher> getWatcherClass()
|
||||||
{
|
{
|
||||||
return watcherClass;
|
return watcherClass;
|
||||||
}
|
}
|
||||||
|
260
src/me/libraryaddict/disguise/disguisetypes/FlagType.java
Normal file
260
src/me/libraryaddict/disguise/disguisetypes/FlagType.java
Normal file
@ -0,0 +1,260 @@
|
|||||||
|
package me.libraryaddict.disguise.disguisetypes;
|
||||||
|
|
||||||
|
import java.util.Arrays;
|
||||||
|
import java.util.HashMap;
|
||||||
|
import java.util.UUID;
|
||||||
|
import java.util.Map.Entry;
|
||||||
|
|
||||||
|
import org.bukkit.Color;
|
||||||
|
import org.bukkit.Material;
|
||||||
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
|
import com.google.common.base.Optional;
|
||||||
|
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.watchers.*;
|
||||||
|
|
||||||
|
public class FlagType<Y>
|
||||||
|
{
|
||||||
|
private static FlagType[] _values = new FlagType[0];
|
||||||
|
|
||||||
|
public static FlagType<Boolean> AGEABLE_BABY = new FlagType<Boolean>(AgeableWatcher.class, 11, false);
|
||||||
|
|
||||||
|
public static FlagType<Integer> AREA_EFFECT_COLOR = new FlagType<Integer>(AreaEffectCloudWatcher.class, 6,
|
||||||
|
Color.BLACK.asRGB());
|
||||||
|
|
||||||
|
public static FlagType<Boolean> AREA_EFFECT_IGNORE_RADIUS = new FlagType<Boolean>(AreaEffectCloudWatcher.class, 7, false);
|
||||||
|
|
||||||
|
public static FlagType<Integer> AREA_EFFECT_PARTICLE = new FlagType<Integer>(AreaEffectCloudWatcher.class, 8, 0);
|
||||||
|
|
||||||
|
public static FlagType<Float> AREA_EFFECT_RADIUS = new FlagType<Float>(AreaEffectCloudWatcher.class, 6, 0F);
|
||||||
|
|
||||||
|
public static FlagType<Byte> ARMORSTAND_META = new FlagType<Byte>(ArmorStandWatcher.class, 10, (byte) 0);
|
||||||
|
|
||||||
|
public static FlagType<Byte> ARROW_CRITICAL = new FlagType<Byte>(ArrowWatcher.class, 6, (byte) 0);
|
||||||
|
|
||||||
|
public static FlagType<Byte> BAT_HANGING = new FlagType<Byte>(BatWatcher.class, 11, (byte) 1);
|
||||||
|
|
||||||
|
public static FlagType<Boolean> BLAZE_BLAZING = new FlagType<Boolean>(BlazeWatcher.class, 11, false);
|
||||||
|
|
||||||
|
public static FlagType<Float> BOAT_DAMAGE = new FlagType<Float>(BoatWatcher.class, 7, 40F);
|
||||||
|
|
||||||
|
public static FlagType<Boolean> CREEPER_IGNITED = new FlagType<Boolean>(CreeperWatcher.class, 13, false);
|
||||||
|
|
||||||
|
public static FlagType<Boolean> CREEPER_POWERED = new FlagType<Boolean>(CreeperWatcher.class, 12, false);
|
||||||
|
|
||||||
|
public static FlagType<ItemStack> DROPPED_ITEM = new FlagType<ItemStack>(DroppedItemWatcher.class, 6,
|
||||||
|
new ItemStack(Material.AIR));
|
||||||
|
|
||||||
|
public static FlagType<Optional> ENDER_CRYSTAL_BEAM = new FlagType<Optional>(EnderCrystalWatcher.class, 6, Optional.absent());
|
||||||
|
|
||||||
|
public static FlagType<Boolean> ENDER_CRYSTAL_PLATE = new FlagType<Boolean>(EnderCrystalWatcher.class, 6, false);
|
||||||
|
|
||||||
|
public static FlagType<Integer> ENDERDRAGON_PHASE = new FlagType<Integer>(EnderDragonWatcher.class, 6, 0);
|
||||||
|
|
||||||
|
public static FlagType<Boolean> ENDERMAN_AGRESSIVE = new FlagType<Boolean>(EndermanWatcher.class, 12, false);
|
||||||
|
|
||||||
|
public static FlagType<Optional<Integer>> ENDERMAN_ITEM = new FlagType<Optional<Integer>>(EndermanWatcher.class, 11,
|
||||||
|
Optional.of(1));
|
||||||
|
|
||||||
|
public static FlagType<Integer> ENTITY_AIR_TICKS = new FlagType<Integer>(FlagWatcher.class, 1, 0);
|
||||||
|
|
||||||
|
public static FlagType<String> ENTITY_CUSTOM_NAME = new FlagType<String>(FlagWatcher.class, 2, null);
|
||||||
|
|
||||||
|
public static FlagType<Boolean> ENTITY_CUSTOM_NAME_VISIBLE = new FlagType<Boolean>(FlagWatcher.class, 3, false);
|
||||||
|
|
||||||
|
public static FlagType<Byte> ENTITY_META = new FlagType<Byte>(FlagWatcher.class, 0, (byte) 0);
|
||||||
|
|
||||||
|
public static FlagType<Boolean> ENTITY_NO_GRAVITY = new FlagType<Boolean>(FlagWatcher.class, 5, false);
|
||||||
|
|
||||||
|
public static FlagType<Integer> ENTITY_SILENT = new FlagType<Integer>(FlagWatcher.class, 4, 0);
|
||||||
|
|
||||||
|
public static FlagType<Boolean> GHAST_AGRESSIVE = new FlagType<Boolean>(GhastWatcher.class, 11, false);
|
||||||
|
|
||||||
|
public static FlagType<Byte> GUARDIAN_FLAG = new FlagType<Byte>(GuardianWatcher.class, 11, (byte) 0);
|
||||||
|
|
||||||
|
public static FlagType<Integer> GUARDIAN_TARGET = new FlagType<Integer>(GuardianWatcher.class, 12, 0);
|
||||||
|
|
||||||
|
public static FlagType<Integer> HORSE_ARMOR = new FlagType<Integer>(HorseWatcher.class, 16, 0);
|
||||||
|
|
||||||
|
public static FlagType<Integer> HORSE_COLOR = new FlagType<Integer>(HorseWatcher.class, 14, 0);
|
||||||
|
|
||||||
|
public static FlagType<Byte> HORSE_META = new FlagType<Byte>(HorseWatcher.class, 12, (byte) 0);
|
||||||
|
|
||||||
|
public static FlagType<Optional<UUID>> HORSE_OWNER = new FlagType<Optional<UUID>>(HorseWatcher.class, 15,
|
||||||
|
Optional.<UUID> absent());
|
||||||
|
|
||||||
|
public static FlagType<Integer> HORSE_STYLE = new FlagType<Integer>(HorseWatcher.class, 14, 0);
|
||||||
|
|
||||||
|
public static FlagType<Integer> HORSE_VARIANT = new FlagType<Integer>(HorseWatcher.class, 13, 0);
|
||||||
|
|
||||||
|
public static FlagType<Byte> INSENTIENT_META = new FlagType<Byte>(LivingWatcher.class, 10, (byte) 0);
|
||||||
|
|
||||||
|
public static FlagType<ItemStack> ITEMFRAME_ITEM = new FlagType<ItemStack>(ItemFrameWatcher.class, 6, null);
|
||||||
|
|
||||||
|
public static FlagType<Byte> ITEMFRAME_ROTATION = new FlagType<Byte>(ItemFrameWatcher.class, 6, (byte) 0);
|
||||||
|
|
||||||
|
public static FlagType<Integer> LIVING_ARROWS = new FlagType<Integer>(LivingWatcher.class, 9, 0);
|
||||||
|
|
||||||
|
public static FlagType<Float> LIVING_HEALTH = new FlagType<Float>(LivingWatcher.class, 6, 0F);
|
||||||
|
|
||||||
|
public static FlagType<Boolean> LIVING_POTION_AMBIENT = new FlagType<Boolean>(LivingWatcher.class, 8, false);
|
||||||
|
|
||||||
|
public static FlagType<Integer> LIVING_POTIONS = new FlagType<Integer>(LivingWatcher.class, 7, 0);
|
||||||
|
|
||||||
|
public static FlagType<Integer> MINECART_BLOCK = new FlagType<Integer>(MinecartWatcher.class, 8, 0);
|
||||||
|
|
||||||
|
public static FlagType<Boolean> MINECART_BLOCK_VISIBLE = new FlagType<Boolean>(MinecartWatcher.class, 10, false);
|
||||||
|
|
||||||
|
public static FlagType<Integer> MINECART_BLOCK_Y = new FlagType<Integer>(MinecartWatcher.class, 9, 0);
|
||||||
|
|
||||||
|
public static FlagType<Integer> OCELOT_TYPE = new FlagType<Integer>(OcelotWatcher.class, 14, 0);
|
||||||
|
|
||||||
|
public static FlagType<Boolean> PIG_SADDLED = new FlagType<Boolean>(PigWatcher.class, 12, false);
|
||||||
|
|
||||||
|
public static FlagType<Byte> PLAYER_SKIN = new FlagType<Byte>(PlayerWatcher.class, 12, (byte) 0);
|
||||||
|
|
||||||
|
public static FlagType<Integer> RABBIT_TYPE = new FlagType<Integer>(RabbitWatcher.class, 12, 0);
|
||||||
|
|
||||||
|
public static FlagType<Byte> SHEEP_WOOL = new FlagType<Byte>(SheepWatcher.class, 12, (byte) 0);
|
||||||
|
|
||||||
|
public static FlagType<Integer> SKELETON_TYPE = new FlagType<Integer>(SkeletonWatcher.class, 11, 0);
|
||||||
|
|
||||||
|
public static FlagType<Integer> SLIME_SIZE = new FlagType<Integer>(SlimeWatcher.class, 11, 0);
|
||||||
|
|
||||||
|
public static FlagType<Byte> TAMEABLE_META = new FlagType<Byte>(TameableWatcher.class, 12, (byte) 0);
|
||||||
|
|
||||||
|
public static FlagType<Optional<UUID>> TAMEABLE_OWNER = new FlagType<Optional<UUID>>(TameableWatcher.class, 13,
|
||||||
|
Optional.<UUID> absent());
|
||||||
|
|
||||||
|
public static FlagType<Integer> TIPPED_ARROW_COLOR = new FlagType<Integer>(TippedArrowWatcher.class, 6, Color.WHITE.asRGB());
|
||||||
|
|
||||||
|
public static FlagType<Integer> VILLAGER_PROFESSION = new FlagType<Integer>(VillagerWatcher.class, 12, 0);
|
||||||
|
|
||||||
|
public static FlagType<Boolean> WITCH_AGGRESSIVE = new FlagType<Boolean>(WitchWatcher.class, 11, false);
|
||||||
|
|
||||||
|
public static FlagType<Integer> WITHER_INVUL = new FlagType<Integer>(WitchWatcher.class, 14, 0);
|
||||||
|
|
||||||
|
public static FlagType<Integer> WITHER_TARGET_1 = new FlagType<Integer>(WitherWatcher.class, 11, 0);
|
||||||
|
|
||||||
|
public static FlagType<Integer> WITHER_TARGET_2 = new FlagType<Integer>(WitherWatcher.class, 12, 0);
|
||||||
|
|
||||||
|
public static FlagType<Integer> WITHER_TARGET_3 = new FlagType<Integer>(WitherWatcher.class, 13, 0);
|
||||||
|
|
||||||
|
public static FlagType<Boolean> WITHERSKULL_BLUE = new FlagType<Boolean>(WitherSkullWatcher.class, 6, false);
|
||||||
|
|
||||||
|
public static FlagType<Boolean> WOLF_BEGGING = new FlagType<Boolean>(WolfWatcher.class, 15, false);
|
||||||
|
|
||||||
|
public static FlagType<Integer> WOLF_COLLAR = new FlagType<Integer>(WolfWatcher.class, 16, 14);
|
||||||
|
|
||||||
|
public static FlagType<Float> WOLF_DAMAGE = new FlagType<Float>(WolfWatcher.class, 14, 0F);
|
||||||
|
|
||||||
|
public static FlagType<Boolean> ZOMBIE_AGGRESSIVE = new FlagType<Boolean>(ZombieWatcher.class, 14, false);
|
||||||
|
|
||||||
|
public static FlagType<Boolean> ZOMBIE_BABY = new FlagType<Boolean>(ZombieWatcher.class, 11, false);
|
||||||
|
|
||||||
|
public static FlagType<Integer> ZOMBIE_PROFESSION = new FlagType<Integer>(ZombieWatcher.class, 12, 0);
|
||||||
|
|
||||||
|
public static FlagType<Boolean> ZOMBIE_SHAKING = new FlagType<Boolean>(ZombieWatcher.class, 13, false);
|
||||||
|
|
||||||
|
static
|
||||||
|
{
|
||||||
|
// Simple verification for the dev that he's setting up the FlagType's properly.
|
||||||
|
// All flag types should be from 0 to <Max Number> with no empty numbers.
|
||||||
|
// All flag types should never occur twice.
|
||||||
|
|
||||||
|
HashMap<Class, Integer> maxValues = new HashMap<Class, Integer>();
|
||||||
|
|
||||||
|
for (FlagType type : values())
|
||||||
|
{
|
||||||
|
if (maxValues.containsKey(type.getFlagWatcher()) && maxValues.get(type.getFlagWatcher()) > type.getIndex())
|
||||||
|
continue;
|
||||||
|
|
||||||
|
maxValues.put(type.getFlagWatcher(), type.getIndex());
|
||||||
|
}
|
||||||
|
|
||||||
|
for (Entry<Class, Integer> entry : maxValues.entrySet())
|
||||||
|
{
|
||||||
|
loop:
|
||||||
|
|
||||||
|
for (int i = 0; i < entry.getValue(); i++)
|
||||||
|
{
|
||||||
|
FlagType found = null;
|
||||||
|
|
||||||
|
for (FlagType type : values())
|
||||||
|
{
|
||||||
|
if (type.getIndex() != i)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!type.getFlagWatcher().isAssignableFrom(entry.getKey()))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (found != null)
|
||||||
|
{
|
||||||
|
System.err.println(entry.getKey().getSimpleName() + " has multiple FlagType's registered for the index "
|
||||||
|
+ i + " (" + type.getFlagWatcher().getSimpleName() + ", " + found.getFlagWatcher().getSimpleName()
|
||||||
|
+ ")");
|
||||||
|
continue loop;
|
||||||
|
}
|
||||||
|
|
||||||
|
found = type;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (found != null)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
System.err.println(entry.getKey().getSimpleName() + " has no FlagType registered for the index " + i);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FlagType getFlag(Class<? extends FlagWatcher> watcherClass, int flagNo)
|
||||||
|
{
|
||||||
|
for (FlagType type : values())
|
||||||
|
{
|
||||||
|
if (type.getIndex() != flagNo)
|
||||||
|
continue;
|
||||||
|
|
||||||
|
if (!type.getFlagWatcher().isAssignableFrom(watcherClass))
|
||||||
|
continue;
|
||||||
|
|
||||||
|
return type;
|
||||||
|
}
|
||||||
|
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
public static FlagType[] values()
|
||||||
|
{
|
||||||
|
return _values;
|
||||||
|
}
|
||||||
|
|
||||||
|
private Y _defaultValue;
|
||||||
|
|
||||||
|
private int _index;
|
||||||
|
|
||||||
|
private Class<? extends FlagWatcher> _watcher;
|
||||||
|
|
||||||
|
private FlagType(Class<? extends FlagWatcher> watcher, int index, Y defaultValue)
|
||||||
|
{
|
||||||
|
_index = index;
|
||||||
|
_watcher = watcher;
|
||||||
|
|
||||||
|
_values = Arrays.copyOf(_values, _values.length + 1);
|
||||||
|
_values[_values.length - 1] = this;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Y getDefault()
|
||||||
|
{
|
||||||
|
return _defaultValue;
|
||||||
|
}
|
||||||
|
|
||||||
|
public Class<? extends FlagWatcher> getFlagWatcher()
|
||||||
|
{
|
||||||
|
return _watcher;
|
||||||
|
}
|
||||||
|
|
||||||
|
public int getIndex()
|
||||||
|
{
|
||||||
|
return _index;
|
||||||
|
}
|
||||||
|
}
|
@ -28,16 +28,15 @@ import me.libraryaddict.disguise.utilities.ReflectionManager;
|
|||||||
|
|
||||||
public class FlagWatcher
|
public class FlagWatcher
|
||||||
{
|
{
|
||||||
|
|
||||||
private boolean addEntityAnimations = DisguiseConfig.isEntityAnimationsAdded();
|
private boolean addEntityAnimations = DisguiseConfig.isEntityAnimationsAdded();
|
||||||
/**
|
/**
|
||||||
* These are the entity values I need to add else it could crash them..
|
* These are the entity values I need to add else it could crash them..
|
||||||
*/
|
*/
|
||||||
private HashMap<Integer, Object> backupEntityValues = new HashMap<>();
|
private HashMap<FlagType, Object> backupEntityValues = new HashMap<>();
|
||||||
private TargetedDisguise disguise;
|
private TargetedDisguise disguise;
|
||||||
private HashMap<Integer, Object> entityValues = new HashMap<>();
|
private HashMap<FlagType, Object> entityValues = new HashMap<>();
|
||||||
private boolean hasDied;
|
|
||||||
private EntityEquipment equipment;
|
private EntityEquipment equipment;
|
||||||
|
private boolean hasDied;
|
||||||
private HashSet<Integer> modifiedEntityAnimations = new HashSet<>();
|
private HashSet<Integer> modifiedEntityAnimations = new HashSet<>();
|
||||||
private List<WrappedWatchableObject> watchableObjects;
|
private List<WrappedWatchableObject> watchableObjects;
|
||||||
|
|
||||||
@ -78,7 +77,7 @@ public class FlagWatcher
|
|||||||
cloned = new FlagWatcher(getDisguise());
|
cloned = new FlagWatcher(getDisguise());
|
||||||
}
|
}
|
||||||
|
|
||||||
cloned.entityValues = (HashMap<Integer, Object>) entityValues.clone();
|
cloned.entityValues = (HashMap<FlagType, Object>) entityValues.clone();
|
||||||
cloned.equipment = ReflectionManager.createEntityEquipment(cloned.getDisguise().getEntity());
|
cloned.equipment = ReflectionManager.createEntityEquipment(cloned.getDisguise().getEntity());
|
||||||
cloned.modifiedEntityAnimations = (HashSet<Integer>) modifiedEntityAnimations.clone();
|
cloned.modifiedEntityAnimations = (HashSet<Integer>) modifiedEntityAnimations.clone();
|
||||||
cloned.addEntityAnimations = addEntityAnimations;
|
cloned.addEntityAnimations = addEntityAnimations;
|
||||||
@ -159,7 +158,7 @@ public class FlagWatcher
|
|||||||
if (sendAllCustom)
|
if (sendAllCustom)
|
||||||
{
|
{
|
||||||
// Its sending the entire meta data. Better add the custom meta
|
// Its sending the entire meta data. Better add the custom meta
|
||||||
for (int id : entityValues.keySet())
|
for (FlagType id : entityValues.keySet())
|
||||||
{
|
{
|
||||||
if (sentValues.contains(id))
|
if (sentValues.contains(id))
|
||||||
{
|
{
|
||||||
@ -173,7 +172,8 @@ public class FlagWatcher
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
WrappedWatchableObject watch = new WrappedWatchableObject(ReflectionManager.createDataWatcherItem(id, value));
|
WrappedWatchableObject watch = new WrappedWatchableObject(
|
||||||
|
ReflectionManager.createDataWatcherItem(id.getIndex(), value));
|
||||||
|
|
||||||
newList.add(watch);
|
newList.add(watch);
|
||||||
}
|
}
|
||||||
@ -235,7 +235,7 @@ public class FlagWatcher
|
|||||||
|
|
||||||
public String getCustomName()
|
public String getCustomName()
|
||||||
{
|
{
|
||||||
return (String) getValue(2, null);
|
return (String) getValue(FlagType.ENTITY_CUSTOM_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected TargetedDisguise getDisguise()
|
protected TargetedDisguise getDisguise()
|
||||||
@ -245,7 +245,12 @@ public class FlagWatcher
|
|||||||
|
|
||||||
private boolean getEntityFlag(int byteValue)
|
private boolean getEntityFlag(int byteValue)
|
||||||
{
|
{
|
||||||
return ((byte) getValue(0, (byte) 0) & 1 << byteValue) != 0;
|
return ((byte) getValue(FlagType.ENTITY_META) & 1 << byteValue) != 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
public EntityEquipment getEquipment()
|
||||||
|
{
|
||||||
|
return equipment;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getItemInMainHand()
|
public ItemStack getItemInMainHand()
|
||||||
@ -264,19 +269,38 @@ public class FlagWatcher
|
|||||||
return equipment.getItemInOffHand();
|
return equipment.getItemInOffHand();
|
||||||
}
|
}
|
||||||
|
|
||||||
public EntityEquipment getEquipment()
|
public ItemStack getItemStack(EquipmentSlot slot)
|
||||||
{
|
{
|
||||||
return equipment;
|
if (equipment == null)
|
||||||
|
return null;
|
||||||
|
|
||||||
|
switch (slot)
|
||||||
|
{
|
||||||
|
case CHEST:
|
||||||
|
return equipment.getChestplate();
|
||||||
|
case FEET:
|
||||||
|
return equipment.getBoots();
|
||||||
|
case HAND:
|
||||||
|
return equipment.getItemInMainHand();
|
||||||
|
case HEAD:
|
||||||
|
return equipment.getHelmet();
|
||||||
|
case LEGS:
|
||||||
|
return equipment.getLeggings();
|
||||||
|
case OFF_HAND:
|
||||||
|
return equipment.getItemInOffHand();
|
||||||
}
|
}
|
||||||
|
|
||||||
protected <Y> Y getValue(int no, Y backup)
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
|
protected <Y> Y getValue(FlagType<Y> no)
|
||||||
{
|
{
|
||||||
if (entityValues.containsKey(no))
|
if (entityValues.containsKey(no))
|
||||||
{
|
{
|
||||||
return (Y) entityValues.get(no);
|
return (Y) entityValues.get(no);
|
||||||
}
|
}
|
||||||
|
|
||||||
return backup;
|
return no.getDefault();
|
||||||
}
|
}
|
||||||
|
|
||||||
public List<WrappedWatchableObject> getWatchableObjects()
|
public List<WrappedWatchableObject> getWatchableObjects()
|
||||||
@ -299,9 +323,14 @@ public class FlagWatcher
|
|||||||
return entityValues.containsKey(no);
|
return entityValues.containsKey(no);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isBurning()
|
||||||
|
{
|
||||||
|
return getEntityFlag(0);
|
||||||
|
}
|
||||||
|
|
||||||
public boolean isCustomNameVisible()
|
public boolean isCustomNameVisible()
|
||||||
{
|
{
|
||||||
return (boolean) getValue(3, false);
|
return getValue(FlagType.ENTITY_CUSTOM_NAME_VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isEntityAnimationsAdded()
|
public boolean isEntityAnimationsAdded()
|
||||||
@ -309,9 +338,29 @@ public class FlagWatcher
|
|||||||
return addEntityAnimations;
|
return addEntityAnimations;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBurning()
|
public boolean isFlyingWithElytra()
|
||||||
{
|
{
|
||||||
return getEntityFlag(0);
|
return getEntityFlag(7);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isGlowing()
|
||||||
|
{
|
||||||
|
return getEntityFlag(6);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isInvisible()
|
||||||
|
{
|
||||||
|
return getEntityFlag(5);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isNoGravity()
|
||||||
|
{
|
||||||
|
return getValue(FlagType.ENTITY_NO_GRAVITY);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRightClicking()
|
||||||
|
{
|
||||||
|
return getEntityFlag(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSneaking()
|
public boolean isSneaking()
|
||||||
@ -324,26 +373,6 @@ public class FlagWatcher
|
|||||||
return getEntityFlag(3);
|
return getEntityFlag(3);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRightClicking()
|
|
||||||
{
|
|
||||||
return getEntityFlag(4);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isInvisible()
|
|
||||||
{
|
|
||||||
return getEntityFlag(5);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isGlowing()
|
|
||||||
{
|
|
||||||
return getEntityFlag(6);
|
|
||||||
}
|
|
||||||
|
|
||||||
public boolean isFlyingWithElytra()
|
|
||||||
{
|
|
||||||
return getEntityFlag(7);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void rebuildWatchableObjects()
|
public void rebuildWatchableObjects()
|
||||||
{
|
{
|
||||||
watchableObjects = new ArrayList<>();
|
watchableObjects = new ArrayList<>();
|
||||||
@ -368,7 +397,7 @@ public class FlagWatcher
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void sendData(int... dataValues)
|
protected void sendData(FlagType... dataValues)
|
||||||
{
|
{
|
||||||
if (!DisguiseAPI.isDisguiseInUse(getDisguise()) || getDisguise().getWatcher() != this)
|
if (!DisguiseAPI.isDisguiseInUse(getDisguise()) || getDisguise().getWatcher() != this)
|
||||||
{
|
{
|
||||||
@ -377,7 +406,7 @@ public class FlagWatcher
|
|||||||
|
|
||||||
List<WrappedWatchableObject> list = new ArrayList<>();
|
List<WrappedWatchableObject> list = new ArrayList<>();
|
||||||
|
|
||||||
for (int data : dataValues)
|
for (FlagType data : dataValues)
|
||||||
{
|
{
|
||||||
if (!entityValues.containsKey(data) || entityValues.get(data) == null)
|
if (!entityValues.containsKey(data) || entityValues.get(data) == null)
|
||||||
{
|
{
|
||||||
@ -386,7 +415,7 @@ public class FlagWatcher
|
|||||||
|
|
||||||
Object value = entityValues.get(data);
|
Object value = entityValues.get(data);
|
||||||
|
|
||||||
if (isEntityAnimationsAdded() && DisguiseConfig.isMetadataPacketsEnabled() && data == 0)
|
if (isEntityAnimationsAdded() && DisguiseConfig.isMetadataPacketsEnabled() && data == FlagType.ENTITY_META)
|
||||||
{
|
{
|
||||||
if (!PacketsManager.isStaticMetadataDisguiseType(disguise))
|
if (!PacketsManager.isStaticMetadataDisguiseType(disguise))
|
||||||
{
|
{
|
||||||
@ -395,7 +424,8 @@ public class FlagWatcher
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
WrappedWatchableObject watch = new WrappedWatchableObject(ReflectionManager.createDataWatcherItem(data, value));
|
WrappedWatchableObject watch = new WrappedWatchableObject(
|
||||||
|
ReflectionManager.createDataWatcherItem(data.getIndex(), value));
|
||||||
|
|
||||||
list.add(watch);
|
list.add(watch);
|
||||||
}
|
}
|
||||||
@ -436,7 +466,7 @@ public class FlagWatcher
|
|||||||
setItemStack(EquipmentSlot.FEET, itemstack[3]);
|
setItemStack(EquipmentSlot.FEET, itemstack[3]);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setBackupValue(int no, Object value)
|
protected void setBackupValue(FlagType no, Object value)
|
||||||
{
|
{
|
||||||
backupEntityValues.put(no, value);
|
backupEntityValues.put(no, value);
|
||||||
}
|
}
|
||||||
@ -445,7 +475,7 @@ public class FlagWatcher
|
|||||||
{
|
{
|
||||||
setEntityFlag(0, setBurning);
|
setEntityFlag(0, setBurning);
|
||||||
|
|
||||||
sendData(0);
|
sendData(FlagType.ENTITY_META);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCustomName(String name)
|
public void setCustomName(String name)
|
||||||
@ -455,48 +485,48 @@ public class FlagWatcher
|
|||||||
name = name.substring(0, 64);
|
name = name.substring(0, 64);
|
||||||
}
|
}
|
||||||
|
|
||||||
setValue(2, name);
|
setValue(FlagType.ENTITY_CUSTOM_NAME, name);
|
||||||
sendData(2);
|
sendData(FlagType.ENTITY_CUSTOM_NAME);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCustomNameVisible(boolean display)
|
public void setCustomNameVisible(boolean display)
|
||||||
{
|
{
|
||||||
setValue(3, display);
|
setValue(FlagType.ENTITY_CUSTOM_NAME_VISIBLE, display);
|
||||||
sendData(3);
|
sendData(FlagType.ENTITY_CUSTOM_NAME_VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setEntityFlag(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(FlagType.ENTITY_META);
|
||||||
|
|
||||||
if (flag)
|
if (flag)
|
||||||
{
|
{
|
||||||
setValue(0, (byte) (b0 | 1 << byteValue));
|
setValue(FlagType.ENTITY_META, (byte) (b0 | 1 << byteValue));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setValue(0, (byte) (b0 & ~(1 << byteValue)));
|
setValue(FlagType.ENTITY_META, (byte) (b0 & ~(1 << byteValue)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setInvisible(boolean setInvis)
|
|
||||||
{
|
|
||||||
setEntityFlag(5, setInvis);
|
|
||||||
sendData(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setGlowing(boolean glowing)
|
|
||||||
{
|
|
||||||
setEntityFlag(6, glowing);
|
|
||||||
sendData(0);
|
|
||||||
}
|
|
||||||
|
|
||||||
public void setFlyingWithElytra(boolean flying)
|
public void setFlyingWithElytra(boolean flying)
|
||||||
{
|
{
|
||||||
setEntityFlag(7, flying);
|
setEntityFlag(7, flying);
|
||||||
sendData(0);
|
sendData(FlagType.ENTITY_META);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setGlowing(boolean glowing)
|
||||||
|
{
|
||||||
|
setEntityFlag(6, glowing);
|
||||||
|
sendData(FlagType.ENTITY_META);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setInvisible(boolean setInvis)
|
||||||
|
{
|
||||||
|
setEntityFlag(5, setInvis);
|
||||||
|
sendData(FlagType.ENTITY_META);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -520,6 +550,34 @@ public class FlagWatcher
|
|||||||
setItemStack(EquipmentSlot.OFF_HAND, itemstack);
|
setItemStack(EquipmentSlot.OFF_HAND, itemstack);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private void setItemStack(EntityEquipment equipment, EquipmentSlot slot, ItemStack itemStack)
|
||||||
|
{
|
||||||
|
if (equipment == null)
|
||||||
|
return;
|
||||||
|
|
||||||
|
switch (slot)
|
||||||
|
{
|
||||||
|
case CHEST:
|
||||||
|
equipment.setChestplate(itemStack);
|
||||||
|
break;
|
||||||
|
case FEET:
|
||||||
|
equipment.setBoots(itemStack);
|
||||||
|
break;
|
||||||
|
case HAND:
|
||||||
|
equipment.setItemInMainHand(itemStack);
|
||||||
|
break;
|
||||||
|
case HEAD:
|
||||||
|
equipment.setHelmet(itemStack);
|
||||||
|
break;
|
||||||
|
case LEGS:
|
||||||
|
equipment.setLeggings(itemStack);
|
||||||
|
break;
|
||||||
|
case OFF_HAND:
|
||||||
|
equipment.setItemInOffHand(itemStack);
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
public void setItemStack(EquipmentSlot slot, ItemStack itemStack)
|
public void setItemStack(EquipmentSlot slot, ItemStack itemStack)
|
||||||
{
|
{
|
||||||
if (equipment == null)
|
if (equipment == null)
|
||||||
@ -569,77 +627,31 @@ public class FlagWatcher
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setItemStack(EntityEquipment equipment, EquipmentSlot slot, ItemStack itemStack)
|
public void setNoGravity(boolean noGravity)
|
||||||
{
|
{
|
||||||
if (equipment == null)
|
setValue(FlagType.ENTITY_NO_GRAVITY, noGravity);
|
||||||
return;
|
sendData(FlagType.ENTITY_NO_GRAVITY);
|
||||||
|
|
||||||
switch (slot)
|
|
||||||
{
|
|
||||||
case CHEST:
|
|
||||||
equipment.setChestplate(itemStack);
|
|
||||||
break;
|
|
||||||
case FEET:
|
|
||||||
equipment.setBoots(itemStack);
|
|
||||||
break;
|
|
||||||
case HAND:
|
|
||||||
equipment.setItemInMainHand(itemStack);
|
|
||||||
break;
|
|
||||||
case HEAD:
|
|
||||||
equipment.setHelmet(itemStack);
|
|
||||||
break;
|
|
||||||
case LEGS:
|
|
||||||
equipment.setLeggings(itemStack);
|
|
||||||
break;
|
|
||||||
case OFF_HAND:
|
|
||||||
equipment.setItemInOffHand(itemStack);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public ItemStack getItemStack(EquipmentSlot slot)
|
|
||||||
{
|
|
||||||
if (equipment == null)
|
|
||||||
return null;
|
|
||||||
|
|
||||||
switch (slot)
|
|
||||||
{
|
|
||||||
case CHEST:
|
|
||||||
return equipment.getChestplate();
|
|
||||||
case FEET:
|
|
||||||
return equipment.getBoots();
|
|
||||||
case HAND:
|
|
||||||
return equipment.getItemInMainHand();
|
|
||||||
case HEAD:
|
|
||||||
return equipment.getHelmet();
|
|
||||||
case LEGS:
|
|
||||||
return equipment.getLeggings();
|
|
||||||
case OFF_HAND:
|
|
||||||
return equipment.getItemInOffHand();
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRightClicking(boolean setRightClicking)
|
public void setRightClicking(boolean setRightClicking)
|
||||||
{
|
{
|
||||||
setEntityFlag(4, setRightClicking);
|
setEntityFlag(4, setRightClicking);
|
||||||
sendData(0);
|
sendData(FlagType.ENTITY_META);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSneaking(boolean setSneaking)
|
public void setSneaking(boolean setSneaking)
|
||||||
{
|
{
|
||||||
setEntityFlag(1, setSneaking);
|
setEntityFlag(1, setSneaking);
|
||||||
sendData(0);
|
sendData(FlagType.ENTITY_META);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSprinting(boolean setSprinting)
|
public void setSprinting(boolean setSprinting)
|
||||||
{
|
{
|
||||||
setEntityFlag(3, setSprinting);
|
setEntityFlag(3, setSprinting);
|
||||||
sendData(0);
|
sendData(FlagType.ENTITY_META);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setValue(int id, Object value)
|
protected <Y> void setValue(FlagType<Y> id, Y value)
|
||||||
{
|
{
|
||||||
entityValues.put(id, value);
|
entityValues.put(id, value);
|
||||||
|
|
||||||
|
@ -2,7 +2,6 @@ package me.libraryaddict.disguise.disguisetypes;
|
|||||||
|
|
||||||
public enum RabbitType
|
public enum RabbitType
|
||||||
{
|
{
|
||||||
|
|
||||||
BLACK(2), BROWN(0), GOLD(4), KILLER_BUNNY(99), PATCHES(3), PEPPER(5), WHITE(1);
|
BLACK(2), BROWN(0), GOLD(4), KILLER_BUNNY(99), PATCHES(3), PEPPER(5), WHITE(1);
|
||||||
|
|
||||||
public static RabbitType getType(int id)
|
public static RabbitType getType(int id)
|
||||||
|
@ -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 me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||||
|
|
||||||
public class AgeableWatcher extends LivingWatcher
|
public class AgeableWatcher extends LivingWatcher
|
||||||
{
|
{
|
||||||
@ -17,7 +18,7 @@ public class AgeableWatcher extends LivingWatcher
|
|||||||
|
|
||||||
public boolean isBaby()
|
public boolean isBaby()
|
||||||
{
|
{
|
||||||
return (boolean) getValue(11, false);
|
return getValue(FlagType.AGEABLE_BABY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAdult()
|
public void setAdult()
|
||||||
@ -32,8 +33,8 @@ public class AgeableWatcher extends LivingWatcher
|
|||||||
|
|
||||||
public void setBaby(boolean isBaby)
|
public void setBaby(boolean isBaby)
|
||||||
{
|
{
|
||||||
setValue(11, isBaby);
|
setValue(FlagType.AGEABLE_BABY, isBaby);
|
||||||
sendData(11);
|
sendData(FlagType.AGEABLE_BABY);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,48 +3,58 @@ package me.libraryaddict.disguise.disguisetypes.watchers;
|
|||||||
import java.awt.Color;
|
import java.awt.Color;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Navid
|
* @author Navid
|
||||||
*/
|
*/
|
||||||
public class AreaEffectCloudWatcher extends FlagWatcher {
|
public class AreaEffectCloudWatcher extends FlagWatcher
|
||||||
|
{
|
||||||
|
|
||||||
public AreaEffectCloudWatcher(Disguise disguise) {
|
public AreaEffectCloudWatcher(Disguise disguise)
|
||||||
|
{
|
||||||
super(disguise);
|
super(disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
public float getRadius() {
|
public float getRadius()
|
||||||
return (float) getValue(5, 0f);
|
{
|
||||||
|
return getValue(FlagType.AREA_EFFECT_RADIUS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getColor() {
|
public int getColor()
|
||||||
return (int) getValue(6, Color.BLACK.getRGB());
|
{
|
||||||
|
return getValue(FlagType.AREA_EFFECT_COLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIgnoreRadius() {
|
public boolean isIgnoreRadius()
|
||||||
return (boolean) getValue(7, false);
|
{
|
||||||
|
return getValue(FlagType.AREA_EFFECT_IGNORE_RADIUS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getParticleId() {
|
public int getParticleId()
|
||||||
return (int) getValue(8, 0);
|
{
|
||||||
|
return getValue(FlagType.AREA_EFFECT_PARTICLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRadius(float radius) {
|
public void setRadius(float radius)
|
||||||
setValue(5, radius);
|
{
|
||||||
|
setValue(FlagType.AREA_EFFECT_RADIUS, radius);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setColor(int color) {
|
public void setColor(int color)
|
||||||
setValue(6, color);
|
{
|
||||||
|
setValue(FlagType.AREA_EFFECT_COLOR, color);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIgnoreRadius(boolean ignore) {
|
public void setIgnoreRadius(boolean ignore)
|
||||||
setValue(7, ignore);
|
{
|
||||||
|
setValue(FlagType.AREA_EFFECT_IGNORE_RADIUS, ignore);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setParticleId(int particleId) {
|
public void setParticleId(int particleId)
|
||||||
setValue(8, particleId);
|
{
|
||||||
|
setValue(FlagType.AREA_EFFECT_PARTICLE, particleId);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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 me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||||
|
|
||||||
public class ArmorStandWatcher extends LivingWatcher
|
public class ArmorStandWatcher extends LivingWatcher
|
||||||
{
|
{
|
||||||
@ -12,7 +13,7 @@ public class ArmorStandWatcher extends LivingWatcher
|
|||||||
|
|
||||||
private boolean getArmorStandFlag(int value)
|
private boolean getArmorStandFlag(int value)
|
||||||
{
|
{
|
||||||
return (getValue(10, 0) & value) != 0;
|
return (getValue(FlagType.ARMORSTAND_META) & value) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isNoBasePlate()
|
public boolean isNoBasePlate()
|
||||||
@ -42,7 +43,8 @@ public class ArmorStandWatcher extends LivingWatcher
|
|||||||
|
|
||||||
private void setArmorStandFlag(int value, boolean isTrue)
|
private void setArmorStandFlag(int value, boolean isTrue)
|
||||||
{
|
{
|
||||||
byte b1 = (byte) getValue(10, (byte) 0);
|
byte b1 = (byte) getValue(FlagType.ARMORSTAND_META);
|
||||||
|
|
||||||
if (isTrue)
|
if (isTrue)
|
||||||
{
|
{
|
||||||
b1 = (byte) (b1 | value);
|
b1 = (byte) (b1 | value);
|
||||||
@ -51,38 +53,39 @@ public class ArmorStandWatcher extends LivingWatcher
|
|||||||
{
|
{
|
||||||
b1 = (byte) (b1 & value);
|
b1 = (byte) (b1 & value);
|
||||||
}
|
}
|
||||||
setValue(10, b1);
|
|
||||||
sendData(10);
|
setValue(FlagType.ARMORSTAND_META, b1);
|
||||||
|
sendData(FlagType.ARMORSTAND_META);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNoBasePlate(boolean noBasePlate)
|
public void setNoBasePlate(boolean noBasePlate)
|
||||||
{
|
{
|
||||||
setArmorStandFlag(8, noBasePlate);
|
setArmorStandFlag(8, noBasePlate);
|
||||||
sendData(10);
|
sendData(FlagType.ARMORSTAND_META);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setNoGravity(boolean noGravity)
|
public void setNoGravity(boolean noGravity)
|
||||||
{
|
{
|
||||||
setArmorStandFlag(2, noGravity);
|
setArmorStandFlag(2, noGravity);
|
||||||
sendData(10);
|
sendData(FlagType.ARMORSTAND_META);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setShowArms(boolean showArms)
|
public void setShowArms(boolean showArms)
|
||||||
{
|
{
|
||||||
setArmorStandFlag(4, showArms);
|
setArmorStandFlag(4, showArms);
|
||||||
sendData(10);
|
sendData(FlagType.ARMORSTAND_META);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSmall(boolean isSmall)
|
public void setSmall(boolean isSmall)
|
||||||
{
|
{
|
||||||
setArmorStandFlag(1, isSmall);
|
setArmorStandFlag(1, isSmall);
|
||||||
sendData(10);
|
sendData(FlagType.ARMORSTAND_META);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMarker(boolean isMarker)
|
public void setMarker(boolean isMarker)
|
||||||
{
|
{
|
||||||
setArmorStandFlag(10, isMarker);
|
setArmorStandFlag(10, isMarker);
|
||||||
sendData(10);
|
sendData(FlagType.ARMORSTAND_META);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,26 @@
|
|||||||
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 me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||||
|
|
||||||
public class ArrowWatcher extends FlagWatcher {
|
public class ArrowWatcher extends FlagWatcher
|
||||||
|
{
|
||||||
|
|
||||||
public ArrowWatcher(Disguise disguise) {
|
public ArrowWatcher(Disguise disguise)
|
||||||
|
{
|
||||||
super(disguise);
|
super(disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCritical() {
|
public boolean isCritical()
|
||||||
return (byte) getValue(5, (byte) 0) == 1;
|
{
|
||||||
|
return (byte) getValue(FlagType.ARROW_CRITICAL) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCritical(boolean critical) {
|
public void setCritical(boolean critical)
|
||||||
setValue(5, (byte) (critical ? 1 : 0));
|
{
|
||||||
sendData(5);
|
setValue(FlagType.ARROW_CRITICAL, (byte) (critical ? 1 : 0));
|
||||||
|
sendData(FlagType.ARROW_CRITICAL);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,26 @@
|
|||||||
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 me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||||
|
|
||||||
public class BatWatcher extends LivingWatcher {
|
public class BatWatcher extends LivingWatcher
|
||||||
|
{
|
||||||
|
|
||||||
public BatWatcher(Disguise disguise) {
|
public BatWatcher(Disguise disguise)
|
||||||
|
{
|
||||||
super(disguise);
|
super(disguise);
|
||||||
|
|
||||||
setHanging(false);
|
setHanging(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isHanging() {
|
public boolean isHanging()
|
||||||
return ((byte)getValue(11, (byte) 1)) == 1;
|
{
|
||||||
|
return ((byte) getValue(FlagType.BAT_HANGING)) == 1;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHanging(boolean hanging) {
|
public void setHanging(boolean hanging)
|
||||||
setValue(11, hanging ? (byte) 1 : (byte) 0);
|
{
|
||||||
sendData(11);
|
setValue(FlagType.BAT_HANGING, hanging ? (byte) 1 : (byte) 0);
|
||||||
|
sendData(FlagType.BAT_HANGING);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -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 me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||||
|
|
||||||
public class BlazeWatcher extends LivingWatcher
|
public class BlazeWatcher extends LivingWatcher
|
||||||
{
|
{
|
||||||
@ -11,13 +12,13 @@ public class BlazeWatcher extends LivingWatcher
|
|||||||
|
|
||||||
public boolean isBlazing()
|
public boolean isBlazing()
|
||||||
{
|
{
|
||||||
return (boolean) getValue(11, false);
|
return getValue(FlagType.BLAZE_BLAZING);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBlazing(boolean isBlazing)
|
public void setBlazing(boolean isBlazing)
|
||||||
{
|
{
|
||||||
setValue(11, isBlazing);
|
setValue(FlagType.BLAZE_BLAZING, isBlazing);
|
||||||
sendData(11);
|
sendData(FlagType.BLAZE_BLAZING);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -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 me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||||
|
|
||||||
public class BoatWatcher extends FlagWatcher
|
public class BoatWatcher extends FlagWatcher
|
||||||
@ -15,13 +16,13 @@ public class BoatWatcher extends FlagWatcher
|
|||||||
|
|
||||||
public float getDamage()
|
public float getDamage()
|
||||||
{
|
{
|
||||||
return getValue(7, 40F);
|
return getValue(FlagType.BOAT_DAMAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setDamage(float dmg)
|
public void setDamage(float dmg)
|
||||||
{
|
{
|
||||||
setValue(7, dmg);
|
setValue(FlagType.BOAT_DAMAGE, dmg);
|
||||||
sendData(7);
|
sendData(FlagType.BOAT_DAMAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,29 +1,36 @@
|
|||||||
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 me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||||
|
|
||||||
public class CreeperWatcher extends LivingWatcher {
|
public class CreeperWatcher extends LivingWatcher
|
||||||
|
{
|
||||||
|
|
||||||
public CreeperWatcher(Disguise disguise) {
|
public CreeperWatcher(Disguise disguise)
|
||||||
|
{
|
||||||
super(disguise);
|
super(disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isIgnited() {
|
public boolean isIgnited()
|
||||||
return (boolean) getValue(13, false);
|
{
|
||||||
|
return (boolean) getValue(FlagType.CREEPER_IGNITED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isPowered() {
|
public boolean isPowered()
|
||||||
return (boolean) getValue(12, false);
|
{
|
||||||
|
return (boolean) getValue(FlagType.CREEPER_POWERED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setIgnited(boolean ignited) {
|
public void setIgnited(boolean ignited)
|
||||||
setValue(13, ignited);
|
{
|
||||||
sendData(13);
|
setValue(FlagType.CREEPER_IGNITED, ignited);
|
||||||
|
sendData(FlagType.CREEPER_IGNITED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPowered(boolean powered) {
|
public void setPowered(boolean powered)
|
||||||
setValue(12, powered);
|
{
|
||||||
sendData(12);
|
setValue(FlagType.CREEPER_POWERED, powered);
|
||||||
|
sendData(FlagType.CREEPER_POWERED);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,23 +1,29 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||||
|
|
||||||
//TODO: Add support for custom items instead of just stone
|
//TODO: Add support for custom items instead of just stone
|
||||||
public class DroppedItemWatcher extends FlagWatcher {
|
public class DroppedItemWatcher extends FlagWatcher
|
||||||
|
{
|
||||||
|
|
||||||
public DroppedItemWatcher(Disguise disguise) {
|
public DroppedItemWatcher(Disguise disguise)
|
||||||
|
{
|
||||||
super(disguise);
|
super(disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getItemStack() {
|
public ItemStack getItemStack()
|
||||||
return (ItemStack) getValue(5, new ItemStack(1));
|
{
|
||||||
|
return getValue(FlagType.DROPPED_ITEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setItemStack(ItemStack item) {
|
public void setItemStack(ItemStack item)
|
||||||
setValue(5, item);
|
{
|
||||||
sendData(5);
|
setValue(FlagType.DROPPED_ITEM, item);
|
||||||
|
sendData(FlagType.DROPPED_ITEM);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,6 +4,7 @@ import com.comphenix.protocol.wrappers.BlockPosition;
|
|||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@ -18,24 +19,24 @@ public class EnderCrystalWatcher extends FlagWatcher
|
|||||||
|
|
||||||
public void setBeamTarget(BlockPosition position)
|
public void setBeamTarget(BlockPosition position)
|
||||||
{
|
{
|
||||||
setValue(5, Optional.of(position));
|
setValue(FlagType.ENDER_CRYSTAL_BEAM, Optional.of(position));
|
||||||
sendData(5);
|
sendData(FlagType.ENDER_CRYSTAL_BEAM);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<BlockPosition> getBeamTarget()
|
public Optional<BlockPosition> getBeamTarget()
|
||||||
{
|
{
|
||||||
return (Optional) getValue(5, Optional.absent());
|
return getValue(FlagType.ENDER_CRYSTAL_BEAM);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setShowBottom(boolean bool)
|
public void setShowBottom(boolean bool)
|
||||||
{
|
{
|
||||||
setValue(6, bool);
|
setValue(FlagType.ENDER_CRYSTAL_PLATE, bool);
|
||||||
sendData(6);
|
sendData(FlagType.ENDER_CRYSTAL_PLATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isShowBottom()
|
public boolean isShowBottom()
|
||||||
{
|
{
|
||||||
return (boolean) getValue(6, false);
|
return getValue(FlagType.ENDER_CRYSTAL_PLATE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,22 +1,27 @@
|
|||||||
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 me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Navid
|
* @author Navid
|
||||||
*/
|
*/
|
||||||
public class EnderDragonWatcher extends LivingWatcher {
|
public class EnderDragonWatcher extends LivingWatcher
|
||||||
|
{
|
||||||
|
|
||||||
public EnderDragonWatcher(Disguise disguise) {
|
public EnderDragonWatcher(Disguise disguise)
|
||||||
|
{
|
||||||
super(disguise);
|
super(disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPhase() {
|
public int getPhase()
|
||||||
return (int) getValue(11, 0);
|
{
|
||||||
|
return getValue(FlagType.ENDERDRAGON_PHASE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPhase(int phase) {
|
public void setPhase(int phase)
|
||||||
setValue(11, phase);
|
{
|
||||||
sendData(11);
|
setValue(FlagType.ENDERDRAGON_PHASE, phase);
|
||||||
|
sendData(FlagType.ENDERDRAGON_PHASE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,48 +6,63 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||||
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
||||||
|
|
||||||
public class EndermanWatcher extends LivingWatcher {
|
public class EndermanWatcher extends LivingWatcher
|
||||||
|
{
|
||||||
|
|
||||||
public EndermanWatcher(Disguise disguise) {
|
public EndermanWatcher(Disguise disguise)
|
||||||
|
{
|
||||||
super(disguise);
|
super(disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public ItemStack getItemInMainHand() {
|
public ItemStack getItemInMainHand()
|
||||||
Optional<Integer> value = (Optional<Integer>) getValue(11, Optional.of(1));
|
{
|
||||||
if (value.isPresent()) {
|
Optional<Integer> value = getValue(FlagType.ENDERMAN_ITEM);
|
||||||
|
|
||||||
|
if (value.isPresent())
|
||||||
|
{
|
||||||
Pair<Integer, Integer> pair = ReflectionManager.getFromCombinedId(value.get());
|
Pair<Integer, Integer> pair = ReflectionManager.getFromCombinedId(value.get());
|
||||||
int id = pair.getLeft();
|
int id = pair.getLeft();
|
||||||
int data = pair.getRight();
|
int data = pair.getRight();
|
||||||
|
|
||||||
return new ItemStack(id, 1, (short) data);
|
return new ItemStack(id, 1, (short) data);
|
||||||
} else {
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setItemInMainHand(ItemStack itemstack) {
|
public void setItemInMainHand(ItemStack itemstack)
|
||||||
|
{
|
||||||
setItemInMainHand(itemstack.getTypeId(), itemstack.getDurability());
|
setItemInMainHand(itemstack.getTypeId(), itemstack.getDurability());
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setItemInMainHand(int typeId) {
|
public void setItemInMainHand(int typeId)
|
||||||
|
{
|
||||||
setItemInMainHand(typeId, 0);
|
setItemInMainHand(typeId, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setItemInMainHand(int typeId, int data) {
|
public void setItemInMainHand(int typeId, int data)
|
||||||
|
{
|
||||||
int combined = ReflectionManager.getCombinedId(typeId, data);
|
int combined = ReflectionManager.getCombinedId(typeId, data);
|
||||||
setValue(11, Optional.of(combined));
|
|
||||||
|
setValue(FlagType.ENDERMAN_ITEM, Optional.of(combined));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAggressive() {
|
public boolean isAggressive()
|
||||||
return (boolean) getValue(12, false);
|
{
|
||||||
|
return getValue(FlagType.ENDERMAN_AGRESSIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAggressive(boolean isAggressive) {
|
public void setAggressive(boolean isAggressive)
|
||||||
setValue(12, isAggressive);
|
{
|
||||||
sendData(12);
|
setValue(FlagType.ENDERMAN_AGRESSIVE, isAggressive);
|
||||||
|
sendData(FlagType.ENDERMAN_AGRESSIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -8,31 +8,40 @@ 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;
|
||||||
|
|
||||||
public class FallingBlockWatcher extends FlagWatcher {
|
public class FallingBlockWatcher extends FlagWatcher
|
||||||
|
{
|
||||||
private ItemStack block;
|
private ItemStack block;
|
||||||
|
|
||||||
public FallingBlockWatcher(Disguise disguise) {
|
public FallingBlockWatcher(Disguise disguise)
|
||||||
|
{
|
||||||
super(disguise);
|
super(disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public FallingBlockWatcher clone(Disguise disguise) {
|
public FallingBlockWatcher clone(Disguise disguise)
|
||||||
|
{
|
||||||
FallingBlockWatcher watcher = (FallingBlockWatcher) super.clone(disguise);
|
FallingBlockWatcher watcher = (FallingBlockWatcher) super.clone(disguise);
|
||||||
watcher.setBlock(getBlock());
|
watcher.setBlock(getBlock());
|
||||||
|
|
||||||
return watcher;
|
return watcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getBlock() {
|
public ItemStack getBlock()
|
||||||
|
{
|
||||||
return block;
|
return block;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBlock(ItemStack block) {
|
public void setBlock(ItemStack block)
|
||||||
|
{
|
||||||
this.block = block;
|
this.block = block;
|
||||||
if (block.getType() == null || block.getType() == Material.AIR) {
|
|
||||||
|
if (block.getType() == null || block.getType() == Material.AIR)
|
||||||
|
{
|
||||||
block.setType(Material.STONE);
|
block.setType(Material.STONE);
|
||||||
}
|
}
|
||||||
if (DisguiseAPI.isDisguiseInUse(getDisguise()) && getDisguise().getWatcher() == this) {
|
|
||||||
|
if (DisguiseAPI.isDisguiseInUse(getDisguise()) && getDisguise().getWatcher() == this)
|
||||||
|
{
|
||||||
DisguiseUtilities.refreshTrackers(getDisguise());
|
DisguiseUtilities.refreshTrackers(getDisguise());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,20 +1,25 @@
|
|||||||
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 me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||||
|
|
||||||
public class GhastWatcher extends LivingWatcher {
|
public class GhastWatcher extends LivingWatcher
|
||||||
|
{
|
||||||
|
|
||||||
public GhastWatcher(Disguise disguise) {
|
public GhastWatcher(Disguise disguise)
|
||||||
|
{
|
||||||
super(disguise);
|
super(disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAggressive() {
|
public boolean isAggressive()
|
||||||
return (boolean) getValue(11, false);
|
{
|
||||||
|
return getValue(FlagType.GHAST_AGRESSIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAggressive(boolean isAggressive) {
|
public void setAggressive(boolean isAggressive)
|
||||||
setValue(11, isAggressive);
|
{
|
||||||
sendData(11);
|
setValue(FlagType.GHAST_AGRESSIVE, isAggressive);
|
||||||
|
sendData(FlagType.GHAST_AGRESSIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,72 +1,101 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||||
|
|
||||||
public class GuardianWatcher extends LivingWatcher {
|
public class GuardianWatcher extends LivingWatcher
|
||||||
|
{
|
||||||
|
|
||||||
public GuardianWatcher(Disguise disguise) {
|
public GuardianWatcher(Disguise disguise)
|
||||||
|
{
|
||||||
super(disguise);
|
super(disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is this guardian targetting someone?
|
* Is this guardian targetting someone?
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean isTarget() {
|
public boolean isTarget()
|
||||||
return ((int)getValue(12, 0)) != 0;
|
{
|
||||||
|
return ((int) getValue(FlagType.GUARDIAN_TARGET)) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shoot a beam at the given entityId.
|
* Shoot a beam at the given entityId.
|
||||||
|
*
|
||||||
* @param entityId
|
* @param entityId
|
||||||
*/
|
*/
|
||||||
public void setTarget(int entityId) {
|
public void setTarget(int entityId)
|
||||||
setValue(12, entityId);
|
{
|
||||||
sendData(12);
|
setValue(FlagType.GUARDIAN_TARGET, entityId);
|
||||||
|
sendData(FlagType.GUARDIAN_TARGET);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setTarget(Entity entity)
|
||||||
|
{
|
||||||
|
setTarget(entity == null ? 0 : entity.getEntityId());
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Shoot a beam at the given player name.
|
* Shoot a beam at the given player name.
|
||||||
|
*
|
||||||
* @param playername
|
* @param playername
|
||||||
*/
|
*/
|
||||||
public void setTarget(String playername) {
|
public void setTarget(String playername)
|
||||||
|
{
|
||||||
Player player = Bukkit.getPlayer(playername);
|
Player player = Bukkit.getPlayer(playername);
|
||||||
if (player == null) return;
|
|
||||||
setValue(12, player.getEntityId());
|
if (player == null)
|
||||||
sendData(12);
|
return;
|
||||||
|
|
||||||
|
setValue(FlagType.GUARDIAN_TARGET, player.getEntityId());
|
||||||
|
sendData(FlagType.GUARDIAN_TARGET);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isRetractingSpikes() {
|
public boolean isRetractingSpikes()
|
||||||
|
{
|
||||||
return isGuardianFlag(2);
|
return isGuardianFlag(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRetractingSpikes(boolean isRetracting) {
|
public void setRetractingSpikes(boolean isRetracting)
|
||||||
|
{
|
||||||
setGuardianFlag(2, isRetracting);
|
setGuardianFlag(2, isRetracting);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isElder() {
|
public boolean isElder()
|
||||||
|
{
|
||||||
return isGuardianFlag(4);
|
return isGuardianFlag(4);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setElder(boolean isGuardian) {
|
public void setElder(boolean isGuardian)
|
||||||
|
{
|
||||||
setGuardianFlag(4, isGuardian);
|
setGuardianFlag(4, isGuardian);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected boolean isGuardianFlag(int no) {
|
protected boolean isGuardianFlag(int no)
|
||||||
return ((byte) getValue(11, (byte) 0) & no) != 0;
|
{
|
||||||
|
return (getValue(FlagType.GUARDIAN_FLAG) & no) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setGuardianFlag(int no, boolean flag) {
|
protected void setGuardianFlag(int no, boolean flag)
|
||||||
byte b0 = (byte) getValue(11, (byte) 0);
|
{
|
||||||
if (flag) {
|
byte b0 = getValue(FlagType.GUARDIAN_FLAG);
|
||||||
setValue(11, (byte) (b0 | no));
|
|
||||||
} else {
|
if (flag)
|
||||||
setValue(11, (byte) (b0 & -(no + 1)));
|
{
|
||||||
|
setValue(FlagType.GUARDIAN_FLAG, (byte) (b0 | no));
|
||||||
}
|
}
|
||||||
sendData(11);
|
else
|
||||||
|
{
|
||||||
|
setValue(FlagType.GUARDIAN_FLAG, (byte) (b0 & -(no + 1)));
|
||||||
|
}
|
||||||
|
|
||||||
|
sendData(FlagType.GUARDIAN_FLAG);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -11,6 +11,7 @@ import org.bukkit.inventory.ItemStack;
|
|||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
|
|
||||||
public class HorseWatcher extends AgeableWatcher
|
public class HorseWatcher extends AgeableWatcher
|
||||||
@ -19,13 +20,14 @@ public class HorseWatcher extends AgeableWatcher
|
|||||||
public HorseWatcher(Disguise disguise)
|
public HorseWatcher(Disguise disguise)
|
||||||
{
|
{
|
||||||
super(disguise);
|
super(disguise);
|
||||||
|
|
||||||
setStyle(Style.values()[DisguiseUtilities.random.nextInt(Style.values().length)]);
|
setStyle(Style.values()[DisguiseUtilities.random.nextInt(Style.values().length)]);
|
||||||
setColor(Color.values()[DisguiseUtilities.random.nextInt(Color.values().length)]);
|
setColor(Color.values()[DisguiseUtilities.random.nextInt(Color.values().length)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Variant getVariant()
|
public Variant getVariant()
|
||||||
{
|
{
|
||||||
return Variant.values()[(int) getValue(13, 0)];
|
return Variant.values()[getValue(FlagType.HORSE_VARIANT)];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setVariant(Variant variant)
|
public void setVariant(Variant variant)
|
||||||
@ -39,45 +41,48 @@ public class HorseWatcher extends AgeableWatcher
|
|||||||
{
|
{
|
||||||
variant = 0; // Crashing people is mean
|
variant = 0; // Crashing people is mean
|
||||||
}
|
}
|
||||||
setValue(13, variant);
|
|
||||||
sendData(13);
|
setValue(FlagType.HORSE_VARIANT, variant);
|
||||||
|
sendData(FlagType.HORSE_VARIANT);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color getColor()
|
public Color getColor()
|
||||||
{
|
{
|
||||||
return Color.values()[((Integer) getValue(14, 0) & 0xFF)];
|
return Color.values()[((Integer) getValue(FlagType.HORSE_COLOR) & 0xFF)];
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getHorseArmor()
|
public ItemStack getHorseArmor()
|
||||||
{
|
{
|
||||||
int horseValue = getHorseArmorAsInt();
|
int horseValue = getHorseArmorAsInt();
|
||||||
|
|
||||||
switch (horseValue)
|
switch (horseValue)
|
||||||
{
|
{
|
||||||
case 1:
|
case 1:
|
||||||
return new ItemStack(Material.getMaterial("IRON_BARDING"));
|
return new ItemStack(Material.IRON_BARDING);
|
||||||
case 2:
|
case 2:
|
||||||
return new ItemStack(Material.getMaterial("GOLD_BARDING"));
|
return new ItemStack(Material.GOLD_BARDING);
|
||||||
case 3:
|
case 3:
|
||||||
return new ItemStack(Material.getMaterial("DIAMOND_BARDING"));
|
return new ItemStack(Material.DIAMOND_BARDING);
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected int getHorseArmorAsInt()
|
protected int getHorseArmorAsInt()
|
||||||
{
|
{
|
||||||
return (int) getValue(16, 0);
|
return getValue(FlagType.HORSE_ARMOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<UUID> getOwner()
|
public Optional<UUID> getOwner()
|
||||||
{
|
{
|
||||||
return getValue(15, Optional.<UUID> absent());
|
return getValue(FlagType.HORSE_OWNER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Style getStyle()
|
public Style getStyle()
|
||||||
{
|
{
|
||||||
return Style.values()[((int) getValue(14, 0) >>> 8)];
|
return Style.values()[(getValue(FlagType.HORSE_STYLE) >>> 8)];
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean hasChest()
|
public boolean hasChest()
|
||||||
@ -122,7 +127,7 @@ public class HorseWatcher extends AgeableWatcher
|
|||||||
|
|
||||||
private byte getHorseFlag()
|
private byte getHorseFlag()
|
||||||
{
|
{
|
||||||
return (byte) getValue(12, (byte) 0);
|
return getValue(FlagType.HORSE_META);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCanBreed(boolean breed)
|
public void setCanBreed(boolean breed)
|
||||||
@ -137,22 +142,24 @@ public class HorseWatcher extends AgeableWatcher
|
|||||||
|
|
||||||
public void setColor(Color color)
|
public void setColor(Color color)
|
||||||
{
|
{
|
||||||
setValue(14, color.ordinal() & 0xFF | getStyle().ordinal() << 8);
|
setValue(FlagType.HORSE_COLOR, color.ordinal() & 0xFF | getStyle().ordinal() << 8);
|
||||||
sendData(14);
|
sendData(FlagType.HORSE_COLOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void setHorseFlag(int i, boolean flag)
|
private void setHorseFlag(int i, boolean flag)
|
||||||
{
|
{
|
||||||
byte j = (byte) getValue(12, (byte) 0);
|
byte j = getValue(FlagType.HORSE_META);
|
||||||
|
|
||||||
if (flag)
|
if (flag)
|
||||||
{
|
{
|
||||||
setValue(12, (byte) (j | i));
|
setValue(FlagType.HORSE_META, (byte) (j | i));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setValue(12, (byte) (j & ~i));
|
setValue(FlagType.HORSE_META, (byte) (j & ~i));
|
||||||
}
|
}
|
||||||
sendData(12);
|
|
||||||
|
sendData(FlagType.HORSE_META);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setGrazing(boolean grazing)
|
public void setGrazing(boolean grazing)
|
||||||
@ -162,16 +169,18 @@ public class HorseWatcher extends AgeableWatcher
|
|||||||
|
|
||||||
protected void setHorseArmor(int armor)
|
protected void setHorseArmor(int armor)
|
||||||
{
|
{
|
||||||
setValue(16, armor);
|
setValue(FlagType.HORSE_ARMOR, armor);
|
||||||
sendData(16);
|
sendData(FlagType.HORSE_ARMOR);
|
||||||
}
|
}
|
||||||
|
|
||||||
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 == Material.IRON_BARDING)
|
if (mat == Material.IRON_BARDING)
|
||||||
{
|
{
|
||||||
value = 1;
|
value = 1;
|
||||||
@ -185,6 +194,7 @@ public class HorseWatcher extends AgeableWatcher
|
|||||||
value = 3;
|
value = 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
setHorseArmor(value);
|
setHorseArmor(value);
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -195,8 +205,8 @@ public class HorseWatcher extends AgeableWatcher
|
|||||||
|
|
||||||
public void setOwner(UUID uuid)
|
public void setOwner(UUID uuid)
|
||||||
{
|
{
|
||||||
setValue(15, Optional.of(uuid));
|
setValue(FlagType.HORSE_OWNER, Optional.of(uuid));
|
||||||
sendData(15);
|
sendData(FlagType.HORSE_OWNER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRearing(boolean rear)
|
public void setRearing(boolean rear)
|
||||||
@ -211,8 +221,8 @@ public class HorseWatcher extends AgeableWatcher
|
|||||||
|
|
||||||
public void setStyle(Style style)
|
public void setStyle(Style style)
|
||||||
{
|
{
|
||||||
setValue(14, getColor().ordinal() & 0xFF | style.ordinal() << 8);
|
setValue(FlagType.HORSE_STYLE, getColor().ordinal() & 0xFF | style.ordinal() << 8);
|
||||||
sendData(14);
|
sendData(FlagType.HORSE_STYLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTamed(boolean tamed)
|
public void setTamed(boolean tamed)
|
||||||
|
@ -0,0 +1,63 @@
|
|||||||
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||||
|
|
||||||
|
public class InsentientWatcher extends LivingWatcher
|
||||||
|
{
|
||||||
|
public InsentientWatcher(Disguise disguise)
|
||||||
|
{
|
||||||
|
super(disguise);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setLeftHanded(boolean leftHanded)
|
||||||
|
{
|
||||||
|
setRightHanded(!leftHanded);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setRightHanded(boolean rightHanded)
|
||||||
|
{
|
||||||
|
setInsentientFlag(2, rightHanded);
|
||||||
|
sendData(FlagType.INSENTIENT_META);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isRightHanded()
|
||||||
|
{
|
||||||
|
return getInsentientFlag(2);
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isLeftHanded()
|
||||||
|
{
|
||||||
|
return !isRightHanded();
|
||||||
|
}
|
||||||
|
|
||||||
|
public boolean isAI()
|
||||||
|
{
|
||||||
|
return getInsentientFlag(1);
|
||||||
|
}
|
||||||
|
|
||||||
|
public void setAI(boolean ai)
|
||||||
|
{
|
||||||
|
setInsentientFlag(1, ai);
|
||||||
|
sendData(FlagType.INSENTIENT_META);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void setInsentientFlag(int i, boolean flag)
|
||||||
|
{
|
||||||
|
byte b0 = (byte) getValue(FlagType.INSENTIENT_META);
|
||||||
|
|
||||||
|
if (flag)
|
||||||
|
{
|
||||||
|
setValue(FlagType.INSENTIENT_META, (byte) (b0 | 1 << i));
|
||||||
|
}
|
||||||
|
else
|
||||||
|
{
|
||||||
|
setValue(FlagType.INSENTIENT_META, (byte) (b0 & (~1 << i)));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
private boolean getInsentientFlag(int i)
|
||||||
|
{
|
||||||
|
return ((byte) getValue(FlagType.PLAYER_SKIN) & 1 << i) != 0;
|
||||||
|
}
|
||||||
|
}
|
@ -1,40 +1,53 @@
|
|||||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||||
|
|
||||||
|
import org.bukkit.Material;
|
||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||||
|
|
||||||
public class ItemFrameWatcher extends FlagWatcher {
|
public class ItemFrameWatcher extends FlagWatcher
|
||||||
|
{
|
||||||
|
|
||||||
public ItemFrameWatcher(Disguise disguise) {
|
public ItemFrameWatcher(Disguise disguise)
|
||||||
|
{
|
||||||
super(disguise);
|
super(disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
public ItemStack getItem() {
|
public ItemStack getItem()
|
||||||
if (getValue(5, null) == null) {
|
{
|
||||||
return new ItemStack(0);
|
if (getValue(FlagType.ITEMFRAME_ITEM) == null)
|
||||||
}
|
{
|
||||||
return (ItemStack) getValue(5, null);
|
return new ItemStack(Material.AIR);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getRotation() {
|
return (ItemStack) getValue(FlagType.ITEMFRAME_ITEM);
|
||||||
return (int) getValue(6, 0);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setItem(ItemStack newItem) {
|
public int getRotation()
|
||||||
if (newItem == null) {
|
{
|
||||||
newItem = new ItemStack(0);
|
return getValue(FlagType.ITEMFRAME_ROTATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public void setItem(ItemStack newItem)
|
||||||
|
{
|
||||||
|
if (newItem == null)
|
||||||
|
{
|
||||||
|
newItem = new ItemStack(Material.AIR);
|
||||||
|
}
|
||||||
|
|
||||||
newItem = newItem.clone();
|
newItem = newItem.clone();
|
||||||
newItem.setAmount(1);
|
newItem.setAmount(1);
|
||||||
setValue(5, newItem);
|
|
||||||
sendData(5);
|
setValue(FlagType.ITEMFRAME_ITEM, newItem);
|
||||||
|
sendData(FlagType.ITEMFRAME_ITEM);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRotation(int rotation) {
|
public void setRotation(int rotation)
|
||||||
setValue(6, (byte) (rotation % 4));
|
{
|
||||||
sendData(6);
|
setValue(FlagType.ITEMFRAME_ROTATION, (byte) (rotation % 4));
|
||||||
|
sendData(FlagType.ITEMFRAME_ROTATION);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -20,13 +20,13 @@ import com.comphenix.protocol.wrappers.WrappedAttribute.Builder;
|
|||||||
|
|
||||||
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.FlagType;
|
||||||
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 me.libraryaddict.disguise.utilities.ReflectionManager;
|
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
||||||
|
|
||||||
public class LivingWatcher extends FlagWatcher
|
public class LivingWatcher extends FlagWatcher
|
||||||
{
|
{
|
||||||
|
|
||||||
static Map<Integer, Object> list = new HashMap<>();
|
static Map<Integer, Object> list = new HashMap<>();
|
||||||
static Method getId;
|
static Method getId;
|
||||||
|
|
||||||
@ -36,6 +36,7 @@ public class LivingWatcher extends FlagWatcher
|
|||||||
{
|
{
|
||||||
getId = ReflectionManager.getNmsMethod("MobEffectList", "getId", ReflectionManager.getNmsClass("MobEffectList"));
|
getId = ReflectionManager.getNmsMethod("MobEffectList", "getId", ReflectionManager.getNmsClass("MobEffectList"));
|
||||||
Object REGISTRY = ReflectionManager.getNmsField("MobEffectList", "REGISTRY").get(null);
|
Object REGISTRY = ReflectionManager.getNmsField("MobEffectList", "REGISTRY").get(null);
|
||||||
|
|
||||||
for (Object next : ((Iterable) REGISTRY))
|
for (Object next : ((Iterable) REGISTRY))
|
||||||
{
|
{
|
||||||
int id = (int) getId.invoke(null, next);
|
int id = (int) getId.invoke(null, next);
|
||||||
@ -81,7 +82,7 @@ public class LivingWatcher extends FlagWatcher
|
|||||||
|
|
||||||
public float getHealth()
|
public float getHealth()
|
||||||
{
|
{
|
||||||
return (float) getValue(6, 0F);
|
return (float) getValue(FlagType.LIVING_HEALTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
public double getMaxHealth()
|
public double getMaxHealth()
|
||||||
@ -91,7 +92,7 @@ public class LivingWatcher extends FlagWatcher
|
|||||||
|
|
||||||
public boolean isPotionParticlesAmbient()
|
public boolean isPotionParticlesAmbient()
|
||||||
{
|
{
|
||||||
return (boolean) getValue(8, false);
|
return (boolean) getValue(FlagType.LIVING_POTION_AMBIENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private int getPotions()
|
private int getPotions()
|
||||||
@ -151,31 +152,31 @@ public class LivingWatcher extends FlagWatcher
|
|||||||
|
|
||||||
public void setPotionParticlesAmbient(boolean particles)
|
public void setPotionParticlesAmbient(boolean particles)
|
||||||
{
|
{
|
||||||
setValue(8, particles);
|
setValue(FlagType.LIVING_POTION_AMBIENT, particles);
|
||||||
sendData(8);
|
sendData(FlagType.LIVING_POTION_AMBIENT);
|
||||||
}
|
}
|
||||||
|
|
||||||
private void sendPotionEffects()
|
private void sendPotionEffects()
|
||||||
{
|
{
|
||||||
setValue(7, getPotions());
|
setValue(FlagType.LIVING_POTIONS, getPotions());
|
||||||
sendData(7);
|
sendData(FlagType.LIVING_POTIONS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHealth(float health)
|
public void setHealth(float health)
|
||||||
{
|
{
|
||||||
setValue(6, health);
|
setValue(FlagType.LIVING_HEALTH, health);
|
||||||
sendData(6);
|
sendData(FlagType.LIVING_HEALTH);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getArrowsSticking()
|
public int getArrowsSticking()
|
||||||
{
|
{
|
||||||
return (int) getValue(9, 0);
|
return (int) getValue(FlagType.LIVING_ARROWS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setArrowsSticking(int arrowsNo)
|
public void setArrowsSticking(int arrowsNo)
|
||||||
{
|
{
|
||||||
setValue(9, arrowsNo);
|
setValue(FlagType.LIVING_ARROWS, arrowsNo);
|
||||||
sendData(9);
|
sendData(FlagType.LIVING_ARROWS);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMaxHealth(double newHealth)
|
public void setMaxHealth(double newHealth)
|
||||||
|
@ -3,6 +3,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers;
|
|||||||
import org.bukkit.inventory.ItemStack;
|
import org.bukkit.inventory.ItemStack;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||||
|
|
||||||
public class MinecartWatcher extends FlagWatcher
|
public class MinecartWatcher extends FlagWatcher
|
||||||
@ -15,39 +16,42 @@ public class MinecartWatcher extends FlagWatcher
|
|||||||
|
|
||||||
public ItemStack getBlockInCart()
|
public ItemStack getBlockInCart()
|
||||||
{
|
{
|
||||||
int id = (int) getValue(8, 0) & 0xffff;
|
int id = (int) getValue(FlagType.MINECART_BLOCK) & 0xffff;
|
||||||
int data = (int) getValue(8, 0) >> 16;
|
int data = (int) getValue(FlagType.MINECART_BLOCK) >> 16;
|
||||||
|
|
||||||
return new ItemStack(id, 1, (short) data);
|
return new ItemStack(id, 1, (short) data);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getBlockYOffset()
|
public int getBlockYOffset()
|
||||||
{
|
{
|
||||||
return (int) getValue(9, 0);
|
return (int) getValue(FlagType.MINECART_BLOCK_Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isViewBlockInCart()
|
public boolean isViewBlockInCart()
|
||||||
{
|
{
|
||||||
return (boolean) getValue(10, false);
|
return (boolean) getValue(FlagType.MINECART_BLOCK_VISIBLE);
|
||||||
}
|
}
|
||||||
|
|
||||||
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(8, id & 0xffff | data << 16);
|
|
||||||
setValue(10, true); // Show block
|
setValue(FlagType.MINECART_BLOCK, id & 0xffff | data << 16);
|
||||||
sendData(8, 10);
|
setValue(FlagType.MINECART_BLOCK_VISIBLE, true); // Show block
|
||||||
|
|
||||||
|
sendData(FlagType.MINECART_BLOCK);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBlockOffset(int i)
|
public void setBlockOffset(int i)
|
||||||
{
|
{
|
||||||
setValue(9, i);
|
setValue(FlagType.MINECART_BLOCK_Y, i);
|
||||||
sendData(9);
|
sendData(FlagType.MINECART_BLOCK_Y);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setViewBlockInCart(boolean viewBlock)
|
public void setViewBlockInCart(boolean viewBlock)
|
||||||
{
|
{
|
||||||
setValue(10, viewBlock);
|
setValue(FlagType.MINECART_BLOCK_VISIBLE, viewBlock);
|
||||||
sendData(10);
|
sendData(FlagType.MINECART_BLOCK_VISIBLE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -4,19 +4,24 @@ import org.bukkit.entity.Ocelot;
|
|||||||
import org.bukkit.entity.Ocelot.Type;
|
import org.bukkit.entity.Ocelot.Type;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||||
|
|
||||||
public class OcelotWatcher extends TameableWatcher {
|
public class OcelotWatcher extends TameableWatcher
|
||||||
|
{
|
||||||
|
|
||||||
public OcelotWatcher(Disguise disguise) {
|
public OcelotWatcher(Disguise disguise)
|
||||||
|
{
|
||||||
super(disguise);
|
super(disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Type getType() {
|
public Type getType()
|
||||||
return Ocelot.Type.getType((int) getValue(14, 0));
|
{
|
||||||
|
return Ocelot.Type.getType(getValue(FlagType.OCELOT_TYPE));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(Type newType) {
|
public void setType(Type newType)
|
||||||
setValue(14, newType.getId());
|
{
|
||||||
sendData(14);
|
setValue(FlagType.OCELOT_TYPE, newType.getId());
|
||||||
|
sendData(FlagType.OCELOT_TYPE);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -6,28 +6,36 @@ 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;
|
||||||
|
|
||||||
public class PaintingWatcher extends FlagWatcher {
|
public class PaintingWatcher extends FlagWatcher
|
||||||
|
{
|
||||||
|
|
||||||
private Art painting;
|
private Art painting;
|
||||||
|
|
||||||
public PaintingWatcher(Disguise disguise) {
|
public PaintingWatcher(Disguise disguise)
|
||||||
|
{
|
||||||
super(disguise);
|
super(disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public PaintingWatcher clone(Disguise disguise) {
|
public PaintingWatcher clone(Disguise disguise)
|
||||||
|
{
|
||||||
PaintingWatcher watcher = (PaintingWatcher) super.clone(disguise);
|
PaintingWatcher watcher = (PaintingWatcher) super.clone(disguise);
|
||||||
watcher.setArt(getArt());
|
watcher.setArt(getArt());
|
||||||
|
|
||||||
return watcher;
|
return watcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
public Art getArt() {
|
public Art getArt()
|
||||||
|
{
|
||||||
return painting;
|
return painting;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setArt(Art newPainting) {
|
public void setArt(Art newPainting)
|
||||||
|
{
|
||||||
this.painting = newPainting;
|
this.painting = newPainting;
|
||||||
if (getDisguise().getEntity() != null && getDisguise().getWatcher() == this) {
|
|
||||||
|
if (getDisguise().getEntity() != null && getDisguise().getWatcher() == this)
|
||||||
|
{
|
||||||
DisguiseUtilities.refreshTrackers(getDisguise());
|
DisguiseUtilities.refreshTrackers(getDisguise());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,19 +1,24 @@
|
|||||||
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 me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||||
|
|
||||||
public class PigWatcher extends AgeableWatcher {
|
public class PigWatcher extends AgeableWatcher
|
||||||
|
{
|
||||||
|
|
||||||
public PigWatcher(Disguise disguise) {
|
public PigWatcher(Disguise disguise)
|
||||||
|
{
|
||||||
super(disguise);
|
super(disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSaddled() {
|
public boolean isSaddled()
|
||||||
return (boolean) getValue(12, false);
|
{
|
||||||
|
return (boolean) getValue(FlagType.PIG_SADDLED);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSaddled(boolean isSaddled) {
|
public void setSaddled(boolean isSaddled)
|
||||||
setValue(12, isSaddled);
|
{
|
||||||
sendData(12);
|
setValue(FlagType.PIG_SADDLED, isSaddled);
|
||||||
|
sendData(FlagType.PIG_SADDLED);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -12,6 +12,7 @@ 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;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||||
import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
|
import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
|
|
||||||
@ -60,7 +61,7 @@ public class PlayerWatcher extends LivingWatcher
|
|||||||
|
|
||||||
private boolean isSkinFlag(int i)
|
private boolean isSkinFlag(int i)
|
||||||
{
|
{
|
||||||
return ((byte) getValue(12, (byte) 0) & 1 << i) != 0;
|
return ((byte) getValue(FlagType.PLAYER_SKIN) & 1 << i) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isCapeEnabled()
|
public boolean isCapeEnabled()
|
||||||
@ -101,43 +102,50 @@ public class PlayerWatcher extends LivingWatcher
|
|||||||
public void setCapeEnabled(boolean enabled)
|
public void setCapeEnabled(boolean enabled)
|
||||||
{
|
{
|
||||||
setSkinFlags(1, enabled);
|
setSkinFlags(1, enabled);
|
||||||
sendData(12);
|
|
||||||
|
sendData(FlagType.PLAYER_SKIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setJackedEnabled(boolean enabled)
|
public void setJackedEnabled(boolean enabled)
|
||||||
{
|
{
|
||||||
setSkinFlags(2, enabled);
|
setSkinFlags(2, enabled);
|
||||||
sendData(12);
|
|
||||||
|
sendData(FlagType.PLAYER_SKIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLeftSleeveEnabled(boolean enabled)
|
public void setLeftSleeveEnabled(boolean enabled)
|
||||||
{
|
{
|
||||||
setSkinFlags(3, enabled);
|
setSkinFlags(3, enabled);
|
||||||
sendData(12);
|
|
||||||
|
sendData(FlagType.PLAYER_SKIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRightSleeveEnabled(boolean enabled)
|
public void setRightSleeveEnabled(boolean enabled)
|
||||||
{
|
{
|
||||||
setSkinFlags(4, enabled);
|
setSkinFlags(4, enabled);
|
||||||
sendData(12);
|
|
||||||
|
sendData(FlagType.PLAYER_SKIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setLeftPantsEnabled(boolean enabled)
|
public void setLeftPantsEnabled(boolean enabled)
|
||||||
{
|
{
|
||||||
setSkinFlags(5, enabled);
|
setSkinFlags(5, enabled);
|
||||||
sendData(12);
|
|
||||||
|
sendData(FlagType.PLAYER_SKIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setRightPantsEnabled(boolean enabled)
|
public void setRightPantsEnabled(boolean enabled)
|
||||||
{
|
{
|
||||||
setSkinFlags(6, enabled);
|
setSkinFlags(6, enabled);
|
||||||
sendData(12);
|
|
||||||
|
sendData(FlagType.PLAYER_SKIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setHatEnabled(boolean enabled)
|
public void setHatEnabled(boolean enabled)
|
||||||
{
|
{
|
||||||
setSkinFlags(7, enabled);
|
setSkinFlags(7, enabled);
|
||||||
sendData(12);
|
|
||||||
|
sendData(FlagType.PLAYER_SKIN);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSleeping()
|
public boolean isSleeping()
|
||||||
@ -232,14 +240,15 @@ public class PlayerWatcher extends LivingWatcher
|
|||||||
|
|
||||||
private void setSkinFlags(int i, boolean flag)
|
private void setSkinFlags(int i, boolean flag)
|
||||||
{
|
{
|
||||||
byte b0 = (byte) getValue(12, (byte) 0);
|
byte b0 = (byte) getValue(FlagType.PLAYER_SKIN);
|
||||||
|
|
||||||
if (flag)
|
if (flag)
|
||||||
{
|
{
|
||||||
setValue(12, (byte) (b0 | 1 << i));
|
setValue(FlagType.PLAYER_SKIN, (byte) (b0 | 1 << i));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setValue(12, (byte) (b0 & (~1 << i)));
|
setValue(FlagType.PLAYER_SKIN, (byte) (b0 & (~1 << i)));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1,23 +1,28 @@
|
|||||||
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 me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||||
import me.libraryaddict.disguise.disguisetypes.RabbitType;
|
import me.libraryaddict.disguise.disguisetypes.RabbitType;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
|
|
||||||
public class RabbitWatcher extends AgeableWatcher {
|
public class RabbitWatcher extends AgeableWatcher
|
||||||
|
{
|
||||||
|
|
||||||
public RabbitWatcher(Disguise disguise) {
|
public RabbitWatcher(Disguise disguise)
|
||||||
|
{
|
||||||
super(disguise);
|
super(disguise);
|
||||||
setType(RabbitType.values()[DisguiseUtilities.random.nextInt(RabbitType.values().length)]);
|
setType(RabbitType.values()[DisguiseUtilities.random.nextInt(RabbitType.values().length)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public RabbitType getType() {
|
public RabbitType getType()
|
||||||
return RabbitType.getType((int) getValue(18, 0));
|
{
|
||||||
|
return RabbitType.getType((int) getValue(FlagType.RABBIT_TYPE));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(RabbitType type) {
|
public void setType(RabbitType type)
|
||||||
setValue(12, type.getTypeId());
|
{
|
||||||
sendData(12);
|
setValue(FlagType.RABBIT_TYPE, type.getTypeId());
|
||||||
|
sendData(FlagType.RABBIT_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,39 +4,54 @@ import org.bukkit.DyeColor;
|
|||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.AnimalColor;
|
import me.libraryaddict.disguise.disguisetypes.AnimalColor;
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||||
|
|
||||||
public class SheepWatcher extends AgeableWatcher {
|
public class SheepWatcher extends AgeableWatcher
|
||||||
|
{
|
||||||
|
|
||||||
public SheepWatcher(Disguise disguise) {
|
public SheepWatcher(Disguise disguise)
|
||||||
|
{
|
||||||
super(disguise);
|
super(disguise);
|
||||||
setValue(12, (byte) 0);
|
|
||||||
|
setValue(FlagType.SHEEP_WOOL, (byte) 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AnimalColor getColor() {
|
public AnimalColor getColor()
|
||||||
return AnimalColor.getColor(((int) getValue(12, (byte) 0) & 15));
|
{
|
||||||
|
return AnimalColor.getColor(((int) getValue(FlagType.SHEEP_WOOL) & 15));
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSheared() {
|
public boolean isSheared()
|
||||||
return ((byte) getValue(12, (byte) 0) & 16) != 0;
|
{
|
||||||
|
return ((byte) getValue(FlagType.SHEEP_WOOL) & 16) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setColor(AnimalColor color) {
|
public void setColor(AnimalColor color)
|
||||||
|
{
|
||||||
setColor(DyeColor.getByWoolData((byte) color.getId()));
|
setColor(DyeColor.getByWoolData((byte) color.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setColor(DyeColor color) {
|
public void setColor(DyeColor color)
|
||||||
byte b0 = (byte) getValue(12, (byte) 0);
|
{
|
||||||
setValue(12, (byte) (b0 & 240 | color.getWoolData() & 15));
|
byte b0 = (byte) getValue(FlagType.SHEEP_WOOL);
|
||||||
sendData(12);
|
|
||||||
|
setValue(FlagType.SHEEP_WOOL, (byte) (b0 & 240 | color.getWoolData() & 15));
|
||||||
|
sendData(FlagType.SHEEP_WOOL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSheared(boolean flag) {
|
public void setSheared(boolean flag)
|
||||||
byte b0 = (byte) getValue(12, (byte) 0);
|
{
|
||||||
if (flag) {
|
byte b0 = (byte) getValue(FlagType.SHEEP_WOOL);
|
||||||
setValue(12, (byte) (b0 | 16));
|
|
||||||
} else {
|
if (flag)
|
||||||
setValue(12, (byte) (b0 & -17));
|
{
|
||||||
|
setValue(FlagType.SHEEP_WOOL, (byte) (b0 | 16));
|
||||||
}
|
}
|
||||||
sendData(12);
|
else
|
||||||
|
{
|
||||||
|
setValue(FlagType.SHEEP_WOOL, (byte) (b0 & -17));
|
||||||
|
}
|
||||||
|
|
||||||
|
sendData(FlagType.SHEEP_WOOL);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -10,34 +10,42 @@ import me.libraryaddict.disguise.disguisetypes.Disguise;
|
|||||||
/**
|
/**
|
||||||
* @author Navid
|
* @author Navid
|
||||||
*/
|
*/
|
||||||
//TODO: Add the appropriate data values to this class
|
// TODO: Add the appropriate data values to this class
|
||||||
public class ShulkerWatcher extends LivingWatcher {
|
public class ShulkerWatcher extends LivingWatcher
|
||||||
|
{
|
||||||
|
|
||||||
public ShulkerWatcher(Disguise disguise) {
|
public ShulkerWatcher(Disguise disguise)
|
||||||
|
{
|
||||||
super(disguise);
|
super(disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
public BlockFace getFacingDirection() {
|
public BlockFace getFacingDirection()
|
||||||
|
{
|
||||||
return BlockFace.UP;
|
return BlockFace.UP;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setFacingDirection() {
|
public void setFacingDirection()
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public Optional<BlockPosition> getAttachmentPosition() {
|
public Optional<BlockPosition> getAttachmentPosition()
|
||||||
|
{
|
||||||
return Optional.absent();
|
return Optional.absent();
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAttachmentPosition(BlockPosition pos) {
|
public void setAttachmentPosition(BlockPosition pos)
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public byte getShieldHeight() {
|
public byte getShieldHeight()
|
||||||
|
{
|
||||||
return 0x00;
|
return 0x00;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setShieldHeight() {
|
public void setShieldHeight()
|
||||||
|
{
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3,22 +3,26 @@ package me.libraryaddict.disguise.disguisetypes.watchers;
|
|||||||
import org.bukkit.entity.Skeleton.SkeletonType;
|
import org.bukkit.entity.Skeleton.SkeletonType;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Navid
|
* @author Navid
|
||||||
*/
|
*/
|
||||||
public class SkeletonWatcher extends LivingWatcher {
|
public class SkeletonWatcher extends LivingWatcher
|
||||||
|
{
|
||||||
public SkeletonWatcher(Disguise disguise) {
|
public SkeletonWatcher(Disguise disguise)
|
||||||
|
{
|
||||||
super(disguise);
|
super(disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setType(SkeletonType type) {
|
public void setType(SkeletonType type)
|
||||||
setValue(11, type.getId());
|
{
|
||||||
sendData(11);
|
setValue(FlagType.SKELETON_TYPE, type.ordinal());
|
||||||
|
sendData(FlagType.SKELETON_TYPE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public SkeletonType getType() {
|
public SkeletonType getType()
|
||||||
return SkeletonType.getType((int) getValue(11, SkeletonType.NORMAL.getId()));
|
{
|
||||||
|
return SkeletonType.values()[getValue(FlagType.SKELETON_TYPE)];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,25 +1,32 @@
|
|||||||
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 me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
|
|
||||||
public class SlimeWatcher extends LivingWatcher {
|
public class SlimeWatcher extends LivingWatcher
|
||||||
|
{
|
||||||
|
|
||||||
public SlimeWatcher(Disguise disguise) {
|
public SlimeWatcher(Disguise disguise)
|
||||||
|
{
|
||||||
super(disguise);
|
super(disguise);
|
||||||
setSize(DisguiseUtilities.random.nextInt(4) + 1);
|
setSize(DisguiseUtilities.random.nextInt(4) + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getSize() {
|
public int getSize()
|
||||||
return (int) getValue(11, 1);
|
{
|
||||||
|
return (int) getValue(FlagType.SLIME_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
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(11, size);
|
|
||||||
sendData(11);
|
setValue(FlagType.SLIME_SIZE, size);
|
||||||
|
sendData(FlagType.SLIME_SIZE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,28 +4,35 @@ 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;
|
||||||
|
|
||||||
public class SplashPotionWatcher extends FlagWatcher {
|
public class SplashPotionWatcher extends FlagWatcher
|
||||||
|
{
|
||||||
private int potionId;
|
private int potionId;
|
||||||
|
|
||||||
public SplashPotionWatcher(Disguise disguise) {
|
public SplashPotionWatcher(Disguise disguise)
|
||||||
|
{
|
||||||
super(disguise);
|
super(disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public SplashPotionWatcher clone(Disguise disguise) {
|
public SplashPotionWatcher clone(Disguise disguise)
|
||||||
|
{
|
||||||
SplashPotionWatcher watcher = (SplashPotionWatcher) super.clone(disguise);
|
SplashPotionWatcher watcher = (SplashPotionWatcher) super.clone(disguise);
|
||||||
watcher.setPotionId(getPotionId());
|
watcher.setPotionId(getPotionId());
|
||||||
|
|
||||||
return watcher;
|
return watcher;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getPotionId() {
|
public int getPotionId()
|
||||||
|
{
|
||||||
return potionId;
|
return potionId;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setPotionId(int newPotionId) {
|
public void setPotionId(int newPotionId)
|
||||||
|
{
|
||||||
this.potionId = newPotionId;
|
this.potionId = newPotionId;
|
||||||
if (getDisguise().getEntity() != null && getDisguise().getWatcher() == this) {
|
|
||||||
|
if (getDisguise().getEntity() != null && getDisguise().getWatcher() == this)
|
||||||
|
{
|
||||||
DisguiseUtilities.refreshTrackers(getDisguise());
|
DisguiseUtilities.refreshTrackers(getDisguise());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -5,10 +5,10 @@ import java.util.UUID;
|
|||||||
import com.google.common.base.Optional;
|
import com.google.common.base.Optional;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||||
|
|
||||||
public class TameableWatcher extends AgeableWatcher
|
public class TameableWatcher extends AgeableWatcher
|
||||||
{
|
{
|
||||||
|
|
||||||
public TameableWatcher(Disguise disguise)
|
public TameableWatcher(Disguise disguise)
|
||||||
{
|
{
|
||||||
super(disguise);
|
super(disguise);
|
||||||
@ -16,7 +16,7 @@ public class TameableWatcher extends AgeableWatcher
|
|||||||
|
|
||||||
public Optional<UUID> getOwner()
|
public Optional<UUID> getOwner()
|
||||||
{
|
{
|
||||||
return getValue(13, Optional.<UUID> absent());
|
return getValue(FlagType.TAMEABLE_OWNER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isSitting()
|
public boolean isSitting()
|
||||||
@ -31,27 +31,29 @@ public class TameableWatcher extends AgeableWatcher
|
|||||||
|
|
||||||
protected boolean isTameableFlag(int no)
|
protected boolean isTameableFlag(int no)
|
||||||
{
|
{
|
||||||
return ((byte) getValue(12, (byte) 0) & no) != 0;
|
return ((byte) getValue(FlagType.TAMEABLE_META) & no) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
protected void setTameableFlag(int no, boolean flag)
|
protected void setTameableFlag(int no, boolean flag)
|
||||||
{
|
{
|
||||||
byte value = (byte) getValue(12, (byte) 0);
|
byte value = (byte) getValue(FlagType.TAMEABLE_META);
|
||||||
|
|
||||||
if (flag)
|
if (flag)
|
||||||
{
|
{
|
||||||
setValue(12, (byte) (value | no));
|
setValue(FlagType.TAMEABLE_META, (byte) (value | no));
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
setValue(12, (byte) (value & -(no + 1)));
|
setValue(FlagType.TAMEABLE_META, (byte) (value & -(no + 1)));
|
||||||
}
|
}
|
||||||
sendData(12);
|
|
||||||
|
sendData(FlagType.TAMEABLE_META);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setOwner(UUID owner)
|
public void setOwner(UUID owner)
|
||||||
{
|
{
|
||||||
setValue(13, Optional.of(owner));
|
setValue(FlagType.TAMEABLE_OWNER, Optional.of(owner));
|
||||||
sendData(13);
|
sendData(FlagType.TAMEABLE_OWNER);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setSitting(boolean sitting)
|
public void setSitting(boolean sitting)
|
||||||
|
@ -3,28 +3,35 @@ package me.libraryaddict.disguise.disguisetypes.watchers;
|
|||||||
import org.bukkit.Color;
|
import org.bukkit.Color;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Navid
|
* @author Navid
|
||||||
*/
|
*/
|
||||||
public class TippedArrowWatcher extends ArrowWatcher {
|
public class TippedArrowWatcher extends ArrowWatcher
|
||||||
|
{
|
||||||
|
|
||||||
public TippedArrowWatcher(Disguise disguise) {
|
public TippedArrowWatcher(Disguise disguise)
|
||||||
|
{
|
||||||
super(disguise);
|
super(disguise);
|
||||||
|
|
||||||
int r = DisguiseUtilities.random.nextInt(256);
|
int r = DisguiseUtilities.random.nextInt(256);
|
||||||
int g = DisguiseUtilities.random.nextInt(256);
|
int g = DisguiseUtilities.random.nextInt(256);
|
||||||
int b = DisguiseUtilities.random.nextInt(256);
|
int b = DisguiseUtilities.random.nextInt(256);
|
||||||
|
|
||||||
setColor(Color.fromRGB(r, g, b));
|
setColor(Color.fromRGB(r, g, b));
|
||||||
}
|
}
|
||||||
|
|
||||||
public Color getColor() {
|
public Color getColor()
|
||||||
int color = (int) getValue(5, Color.WHITE.asRGB());
|
{
|
||||||
|
int color = (int) getValue(FlagType.TIPPED_ARROW_COLOR);
|
||||||
return Color.fromRGB(color);
|
return Color.fromRGB(color);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setColor(Color color) {
|
public void setColor(Color color)
|
||||||
setValue(5, color.asRGB());
|
{
|
||||||
sendData(5);
|
setValue(FlagType.TIPPED_ARROW_COLOR, color.asRGB());
|
||||||
|
sendData(FlagType.TIPPED_ARROW_COLOR);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -3,25 +3,31 @@ package me.libraryaddict.disguise.disguisetypes.watchers;
|
|||||||
import org.bukkit.entity.Villager.Profession;
|
import org.bukkit.entity.Villager.Profession;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||||
|
|
||||||
public class VillagerWatcher extends AgeableWatcher {
|
public class VillagerWatcher extends AgeableWatcher
|
||||||
|
{
|
||||||
|
|
||||||
public VillagerWatcher(Disguise disguise) {
|
public VillagerWatcher(Disguise disguise)
|
||||||
|
{
|
||||||
super(disguise);
|
super(disguise);
|
||||||
setProfession(Profession.values()[DisguiseUtilities.random.nextInt(Profession.values().length)]);
|
setProfession(Profession.values()[DisguiseUtilities.random.nextInt(Profession.values().length)]);
|
||||||
}
|
}
|
||||||
|
|
||||||
public Profession getProfession() {
|
public Profession getProfession()
|
||||||
return Profession.getProfession((int) getValue(16, 0));
|
{
|
||||||
|
return Profession.values()[getValue(FlagType.VILLAGER_PROFESSION)];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProfession(int professionId) {
|
public void setProfession(int professionId)
|
||||||
setValue(12, professionId);
|
{
|
||||||
sendData(12);
|
setValue(FlagType.VILLAGER_PROFESSION, professionId);
|
||||||
|
sendData(FlagType.VILLAGER_PROFESSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setProfession(Profession newProfession) {
|
public void setProfession(Profession newProfession)
|
||||||
setProfession(newProfession.getId());
|
{
|
||||||
|
setProfession(newProfession.ordinal());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -1,24 +1,28 @@
|
|||||||
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 me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @author Navid
|
* @author Navid
|
||||||
*/
|
*/
|
||||||
public class WitchWatcher extends LivingWatcher {
|
public class WitchWatcher extends LivingWatcher
|
||||||
|
{
|
||||||
|
|
||||||
public WitchWatcher(Disguise disguise) {
|
public WitchWatcher(Disguise disguise)
|
||||||
|
{
|
||||||
super(disguise);
|
super(disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public boolean isAggressive()
|
||||||
public boolean isAggressive() {
|
{
|
||||||
return (boolean) getValue(11, false);
|
return (boolean) getValue(FlagType.WITCH_AGGRESSIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAggressive(boolean aggressive) {
|
public void setAggressive(boolean aggressive)
|
||||||
setValue(11, aggressive);
|
{
|
||||||
sendData(11);
|
setValue(FlagType.WITCH_AGGRESSIVE, aggressive);
|
||||||
|
sendData(FlagType.WITCH_AGGRESSIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -1,21 +1,26 @@
|
|||||||
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 me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||||
|
|
||||||
public class WitherSkullWatcher extends FlagWatcher {
|
public class WitherSkullWatcher extends FlagWatcher
|
||||||
|
{
|
||||||
|
|
||||||
public WitherSkullWatcher(Disguise disguise) {
|
public WitherSkullWatcher(Disguise disguise)
|
||||||
|
{
|
||||||
super(disguise);
|
super(disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBlue() {
|
public boolean isBlue()
|
||||||
return (boolean) getValue(5, false);
|
{
|
||||||
|
return (boolean) getValue(FlagType.WITHERSKULL_BLUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBlue(boolean blue) {
|
public void setBlue(boolean blue)
|
||||||
setValue(5, blue);
|
{
|
||||||
sendData(5);
|
setValue(FlagType.WITHERSKULL_BLUE, blue);
|
||||||
|
sendData(FlagType.WITHERSKULL_BLUE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -5,42 +5,54 @@ import java.security.InvalidParameterException;
|
|||||||
import org.bukkit.ChatColor;
|
import org.bukkit.ChatColor;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||||
|
|
||||||
public class WitherWatcher extends LivingWatcher {
|
public class WitherWatcher extends LivingWatcher
|
||||||
|
{
|
||||||
|
|
||||||
public WitherWatcher(Disguise disguise) {
|
public WitherWatcher(Disguise disguise)
|
||||||
|
{
|
||||||
super(disguise);
|
super(disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns the amount of time this Wither is invulnerable for
|
* Returns the amount of time this Wither is invulnerable for
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public int getInvulnerability() {
|
public int getInvulnerability()
|
||||||
return (int) getValue(14, 0);
|
{
|
||||||
|
return (int) getValue(FlagType.WITHER_INVUL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public int[] getTargets() {
|
public int[] getTargets()
|
||||||
return new int[]{(Integer) getValue(11, 0), (Integer) getValue(12, 0), (Integer) getValue(13, 0)};
|
{
|
||||||
|
return new int[]
|
||||||
|
{
|
||||||
|
getValue(FlagType.WITHER_TARGET_1), getValue(FlagType.WITHER_TARGET_2), getValue(FlagType.WITHER_TARGET_3)
|
||||||
|
};
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the amount of time this Wither is invulnerable for
|
* Sets the amount of time this Wither is invulnerable for
|
||||||
*/
|
*/
|
||||||
public void setInvulnerability(int invulnerability) {
|
public void setInvulnerability(int invulnerability)
|
||||||
setValue(14, invulnerability);
|
{
|
||||||
sendData(14);
|
setValue(FlagType.WITHER_INVUL, invulnerability);
|
||||||
|
sendData(FlagType.WITHER_INVUL);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setTargets(int... targets) {
|
public void setTargets(int... targets)
|
||||||
if (targets.length != 3) {
|
{
|
||||||
throw new InvalidParameterException(ChatColor.RED + "Expected 3 numbers for wither setTargets. Received "
|
if (targets.length != 3)
|
||||||
+ targets.length);
|
{
|
||||||
|
throw new InvalidParameterException(
|
||||||
|
ChatColor.RED + "Expected 3 numbers for wither setTargets. Received " + targets.length);
|
||||||
}
|
}
|
||||||
setValue(11, targets[0]);
|
setValue(FlagType.WITHER_TARGET_1, targets[0]);
|
||||||
setValue(12, targets[1]);
|
setValue(FlagType.WITHER_TARGET_2, targets[1]);
|
||||||
setValue(13, targets[2]);
|
setValue(FlagType.WITHER_TARGET_3, targets[2]);
|
||||||
sendData(11, 12, 13);
|
sendData(FlagType.WITHER_TARGET_1, FlagType.WITHER_TARGET_2, FlagType.WITHER_TARGET_3);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -4,63 +4,82 @@ import org.bukkit.DyeColor;
|
|||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.AnimalColor;
|
import me.libraryaddict.disguise.disguisetypes.AnimalColor;
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||||
|
|
||||||
public class WolfWatcher extends TameableWatcher {
|
public class WolfWatcher extends TameableWatcher
|
||||||
|
{
|
||||||
|
|
||||||
public WolfWatcher(Disguise disguise) {
|
public WolfWatcher(Disguise disguise)
|
||||||
|
{
|
||||||
super(disguise);
|
super(disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
public AnimalColor getCollarColor() {
|
public AnimalColor getCollarColor()
|
||||||
return AnimalColor.getColor((int) getValue(16, 14));
|
{
|
||||||
|
return AnimalColor.getColor(getValue(FlagType.WOLF_COLLAR));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used for tail rotation.
|
* Used for tail rotation.
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public float getDamageTaken() {
|
public float getDamageTaken()
|
||||||
return (float) getValue(14, 0);
|
{
|
||||||
|
return (float) getValue(FlagType.WOLF_DAMAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Used for tail rotation.
|
* Used for tail rotation.
|
||||||
|
*
|
||||||
* @param damage
|
* @param damage
|
||||||
*/
|
*/
|
||||||
public void setDamageTaken(float damage) {
|
public void setDamageTaken(float damage)
|
||||||
setValue(14, damage);
|
{
|
||||||
sendData(14);
|
setValue(FlagType.WOLF_DAMAGE, damage);
|
||||||
|
sendData(FlagType.WOLF_DAMAGE);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBegging() {
|
public boolean isBegging()
|
||||||
return (boolean) getValue(15, false);
|
{
|
||||||
|
return (boolean) getValue(FlagType.WOLF_BEGGING);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBegging(boolean begging) {
|
public void setBegging(boolean begging)
|
||||||
setValue(15, begging);
|
{
|
||||||
sendData(15);
|
setValue(FlagType.WOLF_BEGGING, begging);
|
||||||
|
sendData(FlagType.WOLF_BEGGING);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAngry() {
|
public boolean isAngry()
|
||||||
|
{
|
||||||
return isTameableFlag(2);
|
return isTameableFlag(2);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAngry(boolean angry) {
|
public void setAngry(boolean angry)
|
||||||
|
{
|
||||||
setTameableFlag(2, angry);
|
setTameableFlag(2, angry);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCollarColor(AnimalColor color) {
|
public void setCollarColor(AnimalColor color)
|
||||||
|
{
|
||||||
setCollarColor(DyeColor.getByWoolData((byte) color.getId()));
|
setCollarColor(DyeColor.getByWoolData((byte) color.getId()));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCollarColor(DyeColor newColor) {
|
public void setCollarColor(DyeColor newColor)
|
||||||
if (!isTamed()) {
|
{
|
||||||
|
if (!isTamed())
|
||||||
|
{
|
||||||
setTamed(true);
|
setTamed(true);
|
||||||
}
|
}
|
||||||
if (newColor.getWoolData() != getCollarColor().getId()) {
|
|
||||||
setValue(16, (int) newColor.getDyeData());
|
if (newColor.getWoolData() == getCollarColor().getId())
|
||||||
sendData(16);
|
{
|
||||||
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
setValue(FlagType.WOLF_COLLAR, (int) newColor.getDyeData());
|
||||||
|
sendData(FlagType.WOLF_COLLAR);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -3,87 +3,104 @@ package me.libraryaddict.disguise.disguisetypes.watchers;
|
|||||||
import org.bukkit.entity.Villager.Profession;
|
import org.bukkit.entity.Villager.Profession;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||||
|
|
||||||
public class ZombieWatcher extends LivingWatcher {
|
public class ZombieWatcher extends LivingWatcher
|
||||||
|
{
|
||||||
|
|
||||||
public ZombieWatcher(Disguise disguise) {
|
public ZombieWatcher(Disguise disguise)
|
||||||
|
{
|
||||||
super(disguise);
|
super(disguise);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAdult() {
|
public boolean isAdult()
|
||||||
|
{
|
||||||
return !isBaby();
|
return !isBaby();
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isBaby() {
|
public boolean isBaby()
|
||||||
return (boolean) getValue(11, false);
|
{
|
||||||
|
return getValue(FlagType.ZOMBIE_BABY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isShaking() {
|
public boolean isShaking()
|
||||||
return (boolean) getValue(14, false);
|
{
|
||||||
|
return getValue(FlagType.ZOMBIE_SHAKING);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Is this zombie a villager?
|
* Is this zombie a villager?
|
||||||
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public boolean isVillager() {
|
public boolean isVillager()
|
||||||
return ((int)getValue(12, 0)) != 0;
|
{
|
||||||
|
return ((int) getValue(FlagType.ZOMBIE_PROFESSION)) != 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
public boolean isAggressive() {
|
public boolean isAggressive()
|
||||||
return (boolean) getValue(14, false);
|
{
|
||||||
|
return (boolean) getValue(FlagType.ZOMBIE_AGGRESSIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Only returns a valid value if this zombie
|
* Only returns a valid value if this zombie is a villager.
|
||||||
* is a villager.
|
*
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
public Profession getProfession() {
|
public Profession getProfession()
|
||||||
return Profession.getProfession((int) getValue(12, 0));
|
{
|
||||||
|
return Profession.values()[getValue(FlagType.ZOMBIE_PROFESSION)];
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAdult() {
|
public void setAdult()
|
||||||
|
{
|
||||||
setBaby(false);
|
setBaby(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBaby() {
|
public void setBaby()
|
||||||
|
{
|
||||||
setBaby(true);
|
setBaby(true);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setBaby(boolean baby) {
|
public void setBaby(boolean baby)
|
||||||
setValue(11, baby);
|
{
|
||||||
sendData(11);
|
setValue(FlagType.ZOMBIE_BABY, baby);
|
||||||
|
sendData(FlagType.ZOMBIE_BABY);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setShaking(boolean shaking) {
|
public void setShaking(boolean shaking)
|
||||||
setValue(13, (byte) (shaking ? 1 : 0));
|
{
|
||||||
sendData(13);
|
setValue(FlagType.ZOMBIE_SHAKING, shaking);
|
||||||
|
sendData(FlagType.ZOMBIE_SHAKING);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the profession of this zombie, in turn
|
* Sets the profession of this zombie, in turn turning it into a Zombie Villager
|
||||||
* turning it into a Zombie Villager
|
*
|
||||||
* @param id
|
* @param id
|
||||||
*/
|
*/
|
||||||
public void setProfession(int id) {
|
public void setProfession(int id)
|
||||||
setValue(12, id);
|
{
|
||||||
sendData(12);
|
setValue(FlagType.ZOMBIE_PROFESSION, id);
|
||||||
|
sendData(FlagType.ZOMBIE_PROFESSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Sets the profession of this zombie, in turn
|
* Sets the profession of this zombie, in turn turning it into a Zombie Villager
|
||||||
* turning it into a Zombie Villager
|
*
|
||||||
* @param profession
|
* @param profession
|
||||||
*/
|
*/
|
||||||
public void setProfession(Profession profession) {
|
public void setProfession(Profession profession)
|
||||||
setValue(12, profession.getId());
|
{
|
||||||
sendData(12);
|
setValue(FlagType.ZOMBIE_PROFESSION, profession.ordinal());
|
||||||
|
sendData(FlagType.ZOMBIE_PROFESSION);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setAggressive(boolean handsup) {
|
public void setAggressive(boolean handsup)
|
||||||
setValue(14, handsup);
|
{
|
||||||
sendData(14);
|
setValue(FlagType.ZOMBIE_AGGRESSIVE, handsup);
|
||||||
|
sendData(FlagType.ZOMBIE_AGGRESSIVE);
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
@ -57,7 +57,6 @@ import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher;
|
|||||||
|
|
||||||
public class DisguiseUtilities
|
public class DisguiseUtilities
|
||||||
{
|
{
|
||||||
|
|
||||||
public static final Random random = new Random();
|
public static final Random random = new Random();
|
||||||
/**
|
/**
|
||||||
* This is a list of names which was called by other plugins. As such, don't remove from the gameProfiles as its the duty of
|
* This is a list of names which was called by other plugins. As such, don't remove from the gameProfiles as its the duty of
|
||||||
@ -359,8 +358,9 @@ public class DisguiseUtilities
|
|||||||
{
|
{
|
||||||
Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity());
|
Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity());
|
||||||
|
|
||||||
if (entityTrackerEntry != null)
|
if (entityTrackerEntry == null)
|
||||||
{
|
return;
|
||||||
|
|
||||||
Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers")
|
Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers")
|
||||||
.get(entityTrackerEntry);
|
.get(entityTrackerEntry);
|
||||||
|
|
||||||
@ -385,7 +385,6 @@ public class DisguiseUtilities
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
ex.printStackTrace(System.out);
|
ex.printStackTrace(System.out);
|
||||||
@ -664,6 +663,7 @@ public class DisguiseUtilities
|
|||||||
for (Object p : trackedPlayers)
|
for (Object p : trackedPlayers)
|
||||||
{
|
{
|
||||||
Player player = (Player) ReflectionManager.getBukkitEntity(p);
|
Player player = (Player) ReflectionManager.getBukkitEntity(p);
|
||||||
|
|
||||||
if (((TargetedDisguise) disguise).canSee(player))
|
if (((TargetedDisguise) disguise).canSee(player))
|
||||||
{
|
{
|
||||||
players.add(player);
|
players.add(player);
|
||||||
@ -919,8 +919,9 @@ public class DisguiseUtilities
|
|||||||
{
|
{
|
||||||
final Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity());
|
final Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity());
|
||||||
|
|
||||||
if (entityTrackerEntry != null)
|
if (entityTrackerEntry == null)
|
||||||
{
|
return;
|
||||||
|
|
||||||
Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers")
|
Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers")
|
||||||
.get(entityTrackerEntry);
|
.get(entityTrackerEntry);
|
||||||
|
|
||||||
@ -936,8 +937,9 @@ public class DisguiseUtilities
|
|||||||
{
|
{
|
||||||
Player pl = (Player) ReflectionManager.getBukkitEntity(p);
|
Player pl = (Player) ReflectionManager.getBukkitEntity(p);
|
||||||
|
|
||||||
if (player.equalsIgnoreCase((pl).getName()))
|
if (!player.equalsIgnoreCase((pl).getName()))
|
||||||
{
|
continue;
|
||||||
|
|
||||||
clear.invoke(entityTrackerEntry, p);
|
clear.invoke(entityTrackerEntry, p);
|
||||||
|
|
||||||
ProtocolLibrary.getProtocolManager().sendServerPacket(pl, destroyPacket);
|
ProtocolLibrary.getProtocolManager().sendServerPacket(pl, destroyPacket);
|
||||||
@ -962,8 +964,6 @@ public class DisguiseUtilities
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
|
||||||
catch (
|
catch (
|
||||||
|
|
||||||
Exception ex)
|
Exception ex)
|
||||||
|
@ -3,6 +3,7 @@ package me.libraryaddict.disguise.utilities;
|
|||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
|
|
||||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||||
|
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||||
|
|
||||||
public class DisguiseValues
|
public class DisguiseValues
|
||||||
{
|
{
|
||||||
@ -39,7 +40,7 @@ public class DisguiseValues
|
|||||||
return values.get(type);
|
return values.get(type);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static HashMap<Integer, Object> getMetaValues(DisguiseType type)
|
public static HashMap<FlagType, Object> getMetaValues(DisguiseType type)
|
||||||
{
|
{
|
||||||
return getDisguiseValues(type).getMetaValues();
|
return getDisguiseValues(type).getMetaValues();
|
||||||
}
|
}
|
||||||
@ -53,7 +54,7 @@ public class DisguiseValues
|
|||||||
private FakeBoundingBox babyBox;
|
private FakeBoundingBox babyBox;
|
||||||
private float[] entitySize;
|
private float[] entitySize;
|
||||||
private double maxHealth;
|
private double maxHealth;
|
||||||
private HashMap<Integer, Object> metaValues = new HashMap<>();
|
private HashMap<FlagType, Object> metaValues = new HashMap<>();
|
||||||
private Class nmsEntityClass;
|
private Class nmsEntityClass;
|
||||||
|
|
||||||
public DisguiseValues(DisguiseType type, Class classType, int entitySize, double maxHealth)
|
public DisguiseValues(DisguiseType type, Class classType, int entitySize, double maxHealth)
|
||||||
@ -83,7 +84,7 @@ public class DisguiseValues
|
|||||||
return maxHealth;
|
return maxHealth;
|
||||||
}
|
}
|
||||||
|
|
||||||
public HashMap<Integer, Object> getMetaValues()
|
public HashMap<FlagType, Object> getMetaValues()
|
||||||
{
|
{
|
||||||
return metaValues;
|
return metaValues;
|
||||||
}
|
}
|
||||||
@ -108,7 +109,7 @@ public class DisguiseValues
|
|||||||
this.entitySize = size;
|
this.entitySize = size;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setMetaValue(int id, Object value)
|
public void setMetaValue(FlagType id, Object value)
|
||||||
{
|
{
|
||||||
metaValues.put(id, value);
|
metaValues.put(id, value);
|
||||||
}
|
}
|
||||||
|
Loading…
Reference in New Issue
Block a user