Current work
This commit is contained in:
parent
8e255c5ccf
commit
e751cf4582
4
pom.xml
4
pom.xml
@ -42,12 +42,12 @@
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.9.4-R0.1-SNAPSHOT</version>
|
||||
<version>1.10-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.9.4-R0.1-SNAPSHOT</version>
|
||||
<version>1.10-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
@ -30,6 +30,7 @@ import me.libraryaddict.disguise.commands.UndisguiseEntityCommand;
|
||||
import me.libraryaddict.disguise.commands.UndisguisePlayerCommand;
|
||||
import me.libraryaddict.disguise.commands.UndisguiseRadiusCommand;
|
||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.GuardianWatcher;
|
||||
@ -299,7 +300,18 @@ public class LibsDisguises extends JavaPlugin
|
||||
|
||||
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..
|
||||
// int id = watch.getIndex();
|
||||
// Object val = watch.getValue();
|
||||
|
@ -6,6 +6,7 @@ import java.util.HashMap;
|
||||
import java.util.HashSet;
|
||||
import java.util.Iterator;
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
@ -782,134 +783,15 @@ public abstract class Disguise
|
||||
*/
|
||||
private void setupWatcher()
|
||||
{
|
||||
HashMap<Integer, Object> disguiseValues = DisguiseValues.getMetaValues(getType());
|
||||
HashMap<Integer, Object> entityValues = DisguiseValues.getMetaValues(DisguiseType.getType(getEntity().getType()));
|
||||
HashMap<FlagType, Object> disguiseValues = DisguiseValues.getMetaValues(getType());
|
||||
HashMap<FlagType, Object> entityValues = DisguiseValues.getMetaValues(DisguiseType.getType(getEntity().getType()));
|
||||
|
||||
// Start from 2 as they ALL share 0 and 1
|
||||
for (int dataNo = 0; dataNo <= 31; dataNo++)
|
||||
for (Entry<FlagType, Object> entry : entityValues.entrySet())
|
||||
{
|
||||
// STEP 1. Find out if the watcher has set data on it.
|
||||
// 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.
|
||||
if (disguiseValues.containsKey(entry.getKey()))
|
||||
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.
|
||||
// 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));
|
||||
getWatcher().setBackupValue(entry.getKey(), entry.getValue());
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -337,7 +337,7 @@ public enum DisguiseType
|
||||
return objectId;
|
||||
}
|
||||
|
||||
public Class getWatcherClass()
|
||||
public Class<? extends FlagWatcher> getWatcherClass()
|
||||
{
|
||||
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
|
||||
{
|
||||
|
||||
private boolean addEntityAnimations = DisguiseConfig.isEntityAnimationsAdded();
|
||||
/**
|
||||
* 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 HashMap<Integer, Object> entityValues = new HashMap<>();
|
||||
private boolean hasDied;
|
||||
private HashMap<FlagType, Object> entityValues = new HashMap<>();
|
||||
private EntityEquipment equipment;
|
||||
private boolean hasDied;
|
||||
private HashSet<Integer> modifiedEntityAnimations = new HashSet<>();
|
||||
private List<WrappedWatchableObject> watchableObjects;
|
||||
|
||||
@ -78,7 +77,7 @@ public class FlagWatcher
|
||||
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.modifiedEntityAnimations = (HashSet<Integer>) modifiedEntityAnimations.clone();
|
||||
cloned.addEntityAnimations = addEntityAnimations;
|
||||
@ -159,7 +158,7 @@ public class FlagWatcher
|
||||
if (sendAllCustom)
|
||||
{
|
||||
// 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))
|
||||
{
|
||||
@ -173,7 +172,8 @@ public class FlagWatcher
|
||||
continue;
|
||||
}
|
||||
|
||||
WrappedWatchableObject watch = new WrappedWatchableObject(ReflectionManager.createDataWatcherItem(id, value));
|
||||
WrappedWatchableObject watch = new WrappedWatchableObject(
|
||||
ReflectionManager.createDataWatcherItem(id.getIndex(), value));
|
||||
|
||||
newList.add(watch);
|
||||
}
|
||||
@ -235,7 +235,7 @@ public class FlagWatcher
|
||||
|
||||
public String getCustomName()
|
||||
{
|
||||
return (String) getValue(2, null);
|
||||
return (String) getValue(FlagType.ENTITY_CUSTOM_NAME);
|
||||
}
|
||||
|
||||
protected TargetedDisguise getDisguise()
|
||||
@ -245,7 +245,12 @@ public class FlagWatcher
|
||||
|
||||
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()
|
||||
@ -264,19 +269,38 @@ public class FlagWatcher
|
||||
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))
|
||||
{
|
||||
return (Y) entityValues.get(no);
|
||||
}
|
||||
|
||||
return backup;
|
||||
return no.getDefault();
|
||||
}
|
||||
|
||||
public List<WrappedWatchableObject> getWatchableObjects()
|
||||
@ -299,9 +323,14 @@ public class FlagWatcher
|
||||
return entityValues.containsKey(no);
|
||||
}
|
||||
|
||||
public boolean isBurning()
|
||||
{
|
||||
return getEntityFlag(0);
|
||||
}
|
||||
|
||||
public boolean isCustomNameVisible()
|
||||
{
|
||||
return (boolean) getValue(3, false);
|
||||
return getValue(FlagType.ENTITY_CUSTOM_NAME_VISIBLE);
|
||||
}
|
||||
|
||||
public boolean isEntityAnimationsAdded()
|
||||
@ -309,9 +338,29 @@ public class FlagWatcher
|
||||
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()
|
||||
@ -324,26 +373,6 @@ public class FlagWatcher
|
||||
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()
|
||||
{
|
||||
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)
|
||||
{
|
||||
@ -377,7 +406,7 @@ public class FlagWatcher
|
||||
|
||||
List<WrappedWatchableObject> list = new ArrayList<>();
|
||||
|
||||
for (int data : dataValues)
|
||||
for (FlagType data : dataValues)
|
||||
{
|
||||
if (!entityValues.containsKey(data) || entityValues.get(data) == null)
|
||||
{
|
||||
@ -386,7 +415,7 @@ public class FlagWatcher
|
||||
|
||||
Object value = entityValues.get(data);
|
||||
|
||||
if (isEntityAnimationsAdded() && DisguiseConfig.isMetadataPacketsEnabled() && data == 0)
|
||||
if (isEntityAnimationsAdded() && DisguiseConfig.isMetadataPacketsEnabled() && data == FlagType.ENTITY_META)
|
||||
{
|
||||
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);
|
||||
}
|
||||
@ -436,7 +466,7 @@ public class FlagWatcher
|
||||
setItemStack(EquipmentSlot.FEET, itemstack[3]);
|
||||
}
|
||||
|
||||
protected void setBackupValue(int no, Object value)
|
||||
protected void setBackupValue(FlagType no, Object value)
|
||||
{
|
||||
backupEntityValues.put(no, value);
|
||||
}
|
||||
@ -445,7 +475,7 @@ public class FlagWatcher
|
||||
{
|
||||
setEntityFlag(0, setBurning);
|
||||
|
||||
sendData(0);
|
||||
sendData(FlagType.ENTITY_META);
|
||||
}
|
||||
|
||||
public void setCustomName(String name)
|
||||
@ -455,48 +485,48 @@ public class FlagWatcher
|
||||
name = name.substring(0, 64);
|
||||
}
|
||||
|
||||
setValue(2, name);
|
||||
sendData(2);
|
||||
setValue(FlagType.ENTITY_CUSTOM_NAME, name);
|
||||
sendData(FlagType.ENTITY_CUSTOM_NAME);
|
||||
}
|
||||
|
||||
public void setCustomNameVisible(boolean display)
|
||||
{
|
||||
setValue(3, display);
|
||||
sendData(3);
|
||||
setValue(FlagType.ENTITY_CUSTOM_NAME_VISIBLE, display);
|
||||
sendData(FlagType.ENTITY_CUSTOM_NAME_VISIBLE);
|
||||
}
|
||||
|
||||
private void setEntityFlag(int byteValue, boolean flag)
|
||||
{
|
||||
modifiedEntityAnimations.add(byteValue);
|
||||
|
||||
byte b0 = (byte) getValue(0, (byte) 0);
|
||||
byte b0 = (byte) getValue(FlagType.ENTITY_META);
|
||||
|
||||
if (flag)
|
||||
{
|
||||
setValue(0, (byte) (b0 | 1 << byteValue));
|
||||
setValue(FlagType.ENTITY_META, (byte) (b0 | 1 << byteValue));
|
||||
}
|
||||
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)
|
||||
{
|
||||
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);
|
||||
}
|
||||
|
||||
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)
|
||||
{
|
||||
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)
|
||||
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 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;
|
||||
setValue(FlagType.ENTITY_NO_GRAVITY, noGravity);
|
||||
sendData(FlagType.ENTITY_NO_GRAVITY);
|
||||
}
|
||||
|
||||
public void setRightClicking(boolean setRightClicking)
|
||||
{
|
||||
setEntityFlag(4, setRightClicking);
|
||||
sendData(0);
|
||||
sendData(FlagType.ENTITY_META);
|
||||
}
|
||||
|
||||
public void setSneaking(boolean setSneaking)
|
||||
{
|
||||
setEntityFlag(1, setSneaking);
|
||||
sendData(0);
|
||||
sendData(FlagType.ENTITY_META);
|
||||
}
|
||||
|
||||
public void setSprinting(boolean 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);
|
||||
|
||||
|
@ -2,7 +2,6 @@ package me.libraryaddict.disguise.disguisetypes;
|
||||
|
||||
public enum RabbitType
|
||||
{
|
||||
|
||||
BLACK(2), BROWN(0), GOLD(4), KILLER_BUNNY(99), PATCHES(3), PEPPER(5), WHITE(1);
|
||||
|
||||
public static RabbitType getType(int id)
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||
|
||||
public class AgeableWatcher extends LivingWatcher
|
||||
{
|
||||
@ -17,7 +18,7 @@ public class AgeableWatcher extends LivingWatcher
|
||||
|
||||
public boolean isBaby()
|
||||
{
|
||||
return (boolean) getValue(11, false);
|
||||
return getValue(FlagType.AGEABLE_BABY);
|
||||
}
|
||||
|
||||
public void setAdult()
|
||||
@ -32,8 +33,8 @@ public class AgeableWatcher extends LivingWatcher
|
||||
|
||||
public void setBaby(boolean isBaby)
|
||||
{
|
||||
setValue(11, isBaby);
|
||||
sendData(11);
|
||||
setValue(FlagType.AGEABLE_BABY, isBaby);
|
||||
sendData(FlagType.AGEABLE_BABY);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -3,48 +3,58 @@ package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
import java.awt.Color;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||
|
||||
/**
|
||||
* @author Navid
|
||||
*/
|
||||
public class AreaEffectCloudWatcher extends FlagWatcher {
|
||||
public class AreaEffectCloudWatcher extends FlagWatcher
|
||||
{
|
||||
|
||||
public AreaEffectCloudWatcher(Disguise disguise) {
|
||||
public AreaEffectCloudWatcher(Disguise disguise)
|
||||
{
|
||||
super(disguise);
|
||||
}
|
||||
|
||||
public float getRadius() {
|
||||
return (float) getValue(5, 0f);
|
||||
public float getRadius()
|
||||
{
|
||||
return getValue(FlagType.AREA_EFFECT_RADIUS);
|
||||
}
|
||||
|
||||
public int getColor() {
|
||||
return (int) getValue(6, Color.BLACK.getRGB());
|
||||
public int getColor()
|
||||
{
|
||||
return getValue(FlagType.AREA_EFFECT_COLOR);
|
||||
}
|
||||
|
||||
public boolean isIgnoreRadius() {
|
||||
return (boolean) getValue(7, false);
|
||||
public boolean isIgnoreRadius()
|
||||
{
|
||||
return getValue(FlagType.AREA_EFFECT_IGNORE_RADIUS);
|
||||
}
|
||||
|
||||
public int getParticleId() {
|
||||
return (int) getValue(8, 0);
|
||||
public int getParticleId()
|
||||
{
|
||||
return getValue(FlagType.AREA_EFFECT_PARTICLE);
|
||||
}
|
||||
|
||||
public void setRadius(float radius) {
|
||||
setValue(5, radius);
|
||||
public void setRadius(float radius)
|
||||
{
|
||||
setValue(FlagType.AREA_EFFECT_RADIUS, radius);
|
||||
}
|
||||
|
||||
public void setColor(int color) {
|
||||
setValue(6, color);
|
||||
public void setColor(int color)
|
||||
{
|
||||
setValue(FlagType.AREA_EFFECT_COLOR, color);
|
||||
}
|
||||
|
||||
public void setIgnoreRadius(boolean ignore) {
|
||||
setValue(7, ignore);
|
||||
public void setIgnoreRadius(boolean ignore)
|
||||
{
|
||||
setValue(FlagType.AREA_EFFECT_IGNORE_RADIUS, ignore);
|
||||
}
|
||||
|
||||
public void setParticleId(int particleId) {
|
||||
setValue(8, particleId);
|
||||
public void setParticleId(int particleId)
|
||||
{
|
||||
setValue(FlagType.AREA_EFFECT_PARTICLE, particleId);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||
|
||||
public class ArmorStandWatcher extends LivingWatcher
|
||||
{
|
||||
@ -12,7 +13,7 @@ public class ArmorStandWatcher extends LivingWatcher
|
||||
|
||||
private boolean getArmorStandFlag(int value)
|
||||
{
|
||||
return (getValue(10, 0) & value) != 0;
|
||||
return (getValue(FlagType.ARMORSTAND_META) & value) != 0;
|
||||
}
|
||||
|
||||
public boolean isNoBasePlate()
|
||||
@ -42,7 +43,8 @@ public class ArmorStandWatcher extends LivingWatcher
|
||||
|
||||
private void setArmorStandFlag(int value, boolean isTrue)
|
||||
{
|
||||
byte b1 = (byte) getValue(10, (byte) 0);
|
||||
byte b1 = (byte) getValue(FlagType.ARMORSTAND_META);
|
||||
|
||||
if (isTrue)
|
||||
{
|
||||
b1 = (byte) (b1 | value);
|
||||
@ -51,38 +53,39 @@ public class ArmorStandWatcher extends LivingWatcher
|
||||
{
|
||||
b1 = (byte) (b1 & value);
|
||||
}
|
||||
setValue(10, b1);
|
||||
sendData(10);
|
||||
|
||||
setValue(FlagType.ARMORSTAND_META, b1);
|
||||
sendData(FlagType.ARMORSTAND_META);
|
||||
}
|
||||
|
||||
public void setNoBasePlate(boolean noBasePlate)
|
||||
{
|
||||
setArmorStandFlag(8, noBasePlate);
|
||||
sendData(10);
|
||||
sendData(FlagType.ARMORSTAND_META);
|
||||
}
|
||||
|
||||
public void setNoGravity(boolean noGravity)
|
||||
{
|
||||
setArmorStandFlag(2, noGravity);
|
||||
sendData(10);
|
||||
sendData(FlagType.ARMORSTAND_META);
|
||||
}
|
||||
|
||||
public void setShowArms(boolean showArms)
|
||||
{
|
||||
setArmorStandFlag(4, showArms);
|
||||
sendData(10);
|
||||
sendData(FlagType.ARMORSTAND_META);
|
||||
}
|
||||
|
||||
public void setSmall(boolean isSmall)
|
||||
{
|
||||
setArmorStandFlag(1, isSmall);
|
||||
sendData(10);
|
||||
sendData(FlagType.ARMORSTAND_META);
|
||||
}
|
||||
|
||||
public void setMarker(boolean isMarker)
|
||||
{
|
||||
setArmorStandFlag(10, isMarker);
|
||||
sendData(10);
|
||||
sendData(FlagType.ARMORSTAND_META);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,21 +1,26 @@
|
||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||
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);
|
||||
}
|
||||
|
||||
public boolean isCritical() {
|
||||
return (byte) getValue(5, (byte) 0) == 1;
|
||||
public boolean isCritical()
|
||||
{
|
||||
return (byte) getValue(FlagType.ARROW_CRITICAL) == 1;
|
||||
}
|
||||
|
||||
public void setCritical(boolean critical) {
|
||||
setValue(5, (byte) (critical ? 1 : 0));
|
||||
sendData(5);
|
||||
public void setCritical(boolean critical)
|
||||
{
|
||||
setValue(FlagType.ARROW_CRITICAL, (byte) (critical ? 1 : 0));
|
||||
sendData(FlagType.ARROW_CRITICAL);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,20 +1,26 @@
|
||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
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);
|
||||
|
||||
setHanging(false);
|
||||
}
|
||||
|
||||
public boolean isHanging() {
|
||||
return ((byte)getValue(11, (byte) 1)) == 1;
|
||||
public boolean isHanging()
|
||||
{
|
||||
return ((byte) getValue(FlagType.BAT_HANGING)) == 1;
|
||||
}
|
||||
|
||||
public void setHanging(boolean hanging) {
|
||||
setValue(11, hanging ? (byte) 1 : (byte) 0);
|
||||
sendData(11);
|
||||
public void setHanging(boolean hanging)
|
||||
{
|
||||
setValue(FlagType.BAT_HANGING, hanging ? (byte) 1 : (byte) 0);
|
||||
sendData(FlagType.BAT_HANGING);
|
||||
}
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||
|
||||
public class BlazeWatcher extends LivingWatcher
|
||||
{
|
||||
@ -11,13 +12,13 @@ public class BlazeWatcher extends LivingWatcher
|
||||
|
||||
public boolean isBlazing()
|
||||
{
|
||||
return (boolean) getValue(11, false);
|
||||
return getValue(FlagType.BLAZE_BLAZING);
|
||||
}
|
||||
|
||||
public void setBlazing(boolean isBlazing)
|
||||
{
|
||||
setValue(11, isBlazing);
|
||||
sendData(11);
|
||||
setValue(FlagType.BLAZE_BLAZING, isBlazing);
|
||||
sendData(FlagType.BLAZE_BLAZING);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,6 +1,7 @@
|
||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||
|
||||
public class BoatWatcher extends FlagWatcher
|
||||
@ -15,13 +16,13 @@ public class BoatWatcher extends FlagWatcher
|
||||
|
||||
public float getDamage()
|
||||
{
|
||||
return getValue(7, 40F);
|
||||
return getValue(FlagType.BOAT_DAMAGE);
|
||||
}
|
||||
|
||||
public void setDamage(float dmg)
|
||||
{
|
||||
setValue(7, dmg);
|
||||
sendData(7);
|
||||
setValue(FlagType.BOAT_DAMAGE, dmg);
|
||||
sendData(FlagType.BOAT_DAMAGE);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,29 +1,36 @@
|
||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public boolean isIgnited() {
|
||||
return (boolean) getValue(13, false);
|
||||
public boolean isIgnited()
|
||||
{
|
||||
return (boolean) getValue(FlagType.CREEPER_IGNITED);
|
||||
}
|
||||
|
||||
public boolean isPowered() {
|
||||
return (boolean) getValue(12, false);
|
||||
public boolean isPowered()
|
||||
{
|
||||
return (boolean) getValue(FlagType.CREEPER_POWERED);
|
||||
}
|
||||
|
||||
public void setIgnited(boolean ignited) {
|
||||
setValue(13, ignited);
|
||||
sendData(13);
|
||||
public void setIgnited(boolean ignited)
|
||||
{
|
||||
setValue(FlagType.CREEPER_IGNITED, ignited);
|
||||
sendData(FlagType.CREEPER_IGNITED);
|
||||
}
|
||||
|
||||
public void setPowered(boolean powered) {
|
||||
setValue(12, powered);
|
||||
sendData(12);
|
||||
public void setPowered(boolean powered)
|
||||
{
|
||||
setValue(FlagType.CREEPER_POWERED, powered);
|
||||
sendData(FlagType.CREEPER_POWERED);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,23 +1,29 @@
|
||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||
|
||||
//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);
|
||||
}
|
||||
|
||||
public ItemStack getItemStack() {
|
||||
return (ItemStack) getValue(5, new ItemStack(1));
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
return getValue(FlagType.DROPPED_ITEM);
|
||||
}
|
||||
|
||||
public void setItemStack(ItemStack item) {
|
||||
setValue(5, item);
|
||||
sendData(5);
|
||||
public void setItemStack(ItemStack item)
|
||||
{
|
||||
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 me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||
|
||||
/**
|
||||
@ -18,24 +19,24 @@ public class EnderCrystalWatcher extends FlagWatcher
|
||||
|
||||
public void setBeamTarget(BlockPosition position)
|
||||
{
|
||||
setValue(5, Optional.of(position));
|
||||
sendData(5);
|
||||
setValue(FlagType.ENDER_CRYSTAL_BEAM, Optional.of(position));
|
||||
sendData(FlagType.ENDER_CRYSTAL_BEAM);
|
||||
}
|
||||
|
||||
public Optional<BlockPosition> getBeamTarget()
|
||||
{
|
||||
return (Optional) getValue(5, Optional.absent());
|
||||
return getValue(FlagType.ENDER_CRYSTAL_BEAM);
|
||||
}
|
||||
|
||||
public void setShowBottom(boolean bool)
|
||||
{
|
||||
setValue(6, bool);
|
||||
sendData(6);
|
||||
setValue(FlagType.ENDER_CRYSTAL_PLATE, bool);
|
||||
sendData(FlagType.ENDER_CRYSTAL_PLATE);
|
||||
}
|
||||
|
||||
public boolean isShowBottom()
|
||||
{
|
||||
return (boolean) getValue(6, false);
|
||||
return getValue(FlagType.ENDER_CRYSTAL_PLATE);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,22 +1,27 @@
|
||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||
|
||||
/**
|
||||
* @author Navid
|
||||
*/
|
||||
public class EnderDragonWatcher extends LivingWatcher {
|
||||
public class EnderDragonWatcher extends LivingWatcher
|
||||
{
|
||||
|
||||
public EnderDragonWatcher(Disguise disguise) {
|
||||
public EnderDragonWatcher(Disguise disguise)
|
||||
{
|
||||
super(disguise);
|
||||
}
|
||||
|
||||
public int getPhase() {
|
||||
return (int) getValue(11, 0);
|
||||
public int getPhase()
|
||||
{
|
||||
return getValue(FlagType.ENDERDRAGON_PHASE);
|
||||
}
|
||||
|
||||
public void setPhase(int phase) {
|
||||
setValue(11, phase);
|
||||
sendData(11);
|
||||
public void setPhase(int phase)
|
||||
{
|
||||
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 me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||
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);
|
||||
}
|
||||
|
||||
@Override
|
||||
public ItemStack getItemInMainHand() {
|
||||
Optional<Integer> value = (Optional<Integer>) getValue(11, Optional.of(1));
|
||||
if (value.isPresent()) {
|
||||
public ItemStack getItemInMainHand()
|
||||
{
|
||||
Optional<Integer> value = getValue(FlagType.ENDERMAN_ITEM);
|
||||
|
||||
if (value.isPresent())
|
||||
{
|
||||
Pair<Integer, Integer> pair = ReflectionManager.getFromCombinedId(value.get());
|
||||
int id = pair.getLeft();
|
||||
int data = pair.getRight();
|
||||
|
||||
return new ItemStack(id, 1, (short) data);
|
||||
} else {
|
||||
}
|
||||
else
|
||||
{
|
||||
return null;
|
||||
}
|
||||
}
|
||||
|
||||
@Override
|
||||
public void setItemInMainHand(ItemStack itemstack) {
|
||||
public void setItemInMainHand(ItemStack itemstack)
|
||||
{
|
||||
setItemInMainHand(itemstack.getTypeId(), itemstack.getDurability());
|
||||
}
|
||||
|
||||
public void setItemInMainHand(int typeId) {
|
||||
public void setItemInMainHand(int typeId)
|
||||
{
|
||||
setItemInMainHand(typeId, 0);
|
||||
}
|
||||
|
||||
public void setItemInMainHand(int typeId, int data) {
|
||||
public void setItemInMainHand(int typeId, int data)
|
||||
{
|
||||
int combined = ReflectionManager.getCombinedId(typeId, data);
|
||||
setValue(11, Optional.of(combined));
|
||||
|
||||
setValue(FlagType.ENDERMAN_ITEM, Optional.of(combined));
|
||||
}
|
||||
|
||||
public boolean isAggressive() {
|
||||
return (boolean) getValue(12, false);
|
||||
public boolean isAggressive()
|
||||
{
|
||||
return getValue(FlagType.ENDERMAN_AGRESSIVE);
|
||||
}
|
||||
|
||||
public void setAggressive(boolean isAggressive) {
|
||||
setValue(12, isAggressive);
|
||||
sendData(12);
|
||||
public void setAggressive(boolean isAggressive)
|
||||
{
|
||||
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.utilities.DisguiseUtilities;
|
||||
|
||||
public class FallingBlockWatcher extends FlagWatcher {
|
||||
|
||||
public class FallingBlockWatcher extends FlagWatcher
|
||||
{
|
||||
private ItemStack block;
|
||||
|
||||
public FallingBlockWatcher(Disguise disguise) {
|
||||
public FallingBlockWatcher(Disguise disguise)
|
||||
{
|
||||
super(disguise);
|
||||
}
|
||||
|
||||
@Override
|
||||
public FallingBlockWatcher clone(Disguise disguise) {
|
||||
public FallingBlockWatcher clone(Disguise disguise)
|
||||
{
|
||||
FallingBlockWatcher watcher = (FallingBlockWatcher) super.clone(disguise);
|
||||
watcher.setBlock(getBlock());
|
||||
|
||||
return watcher;
|
||||
}
|
||||
|
||||
public ItemStack getBlock() {
|
||||
public ItemStack getBlock()
|
||||
{
|
||||
return block;
|
||||
}
|
||||
|
||||
public void setBlock(ItemStack block) {
|
||||
public void setBlock(ItemStack block)
|
||||
{
|
||||
this.block = block;
|
||||
if (block.getType() == null || block.getType() == Material.AIR) {
|
||||
|
||||
if (block.getType() == null || block.getType() == Material.AIR)
|
||||
{
|
||||
block.setType(Material.STONE);
|
||||
}
|
||||
if (DisguiseAPI.isDisguiseInUse(getDisguise()) && getDisguise().getWatcher() == this) {
|
||||
|
||||
if (DisguiseAPI.isDisguiseInUse(getDisguise()) && getDisguise().getWatcher() == this)
|
||||
{
|
||||
DisguiseUtilities.refreshTrackers(getDisguise());
|
||||
}
|
||||
}
|
||||
|
@ -1,20 +1,25 @@
|
||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public boolean isAggressive() {
|
||||
return (boolean) getValue(11, false);
|
||||
public boolean isAggressive()
|
||||
{
|
||||
return getValue(FlagType.GHAST_AGRESSIVE);
|
||||
}
|
||||
|
||||
public void setAggressive(boolean isAggressive) {
|
||||
setValue(11, isAggressive);
|
||||
sendData(11);
|
||||
public void setAggressive(boolean isAggressive)
|
||||
{
|
||||
setValue(FlagType.GHAST_AGRESSIVE, isAggressive);
|
||||
sendData(FlagType.GHAST_AGRESSIVE);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,72 +1,101 @@
|
||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this guardian targetting someone?
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isTarget() {
|
||||
return ((int)getValue(12, 0)) != 0;
|
||||
public boolean isTarget()
|
||||
{
|
||||
return ((int) getValue(FlagType.GUARDIAN_TARGET)) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
* Shoot a beam at the given entityId.
|
||||
*
|
||||
* @param entityId
|
||||
*/
|
||||
public void setTarget(int entityId) {
|
||||
setValue(12, entityId);
|
||||
sendData(12);
|
||||
public void setTarget(int entityId)
|
||||
{
|
||||
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.
|
||||
*
|
||||
* @param playername
|
||||
*/
|
||||
public void setTarget(String playername) {
|
||||
public void setTarget(String playername)
|
||||
{
|
||||
Player player = Bukkit.getPlayer(playername);
|
||||
if (player == null) return;
|
||||
setValue(12, player.getEntityId());
|
||||
sendData(12);
|
||||
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
setValue(FlagType.GUARDIAN_TARGET, player.getEntityId());
|
||||
sendData(FlagType.GUARDIAN_TARGET);
|
||||
}
|
||||
|
||||
public boolean isRetractingSpikes() {
|
||||
public boolean isRetractingSpikes()
|
||||
{
|
||||
return isGuardianFlag(2);
|
||||
}
|
||||
|
||||
public void setRetractingSpikes(boolean isRetracting) {
|
||||
public void setRetractingSpikes(boolean isRetracting)
|
||||
{
|
||||
setGuardianFlag(2, isRetracting);
|
||||
}
|
||||
|
||||
public boolean isElder() {
|
||||
public boolean isElder()
|
||||
{
|
||||
return isGuardianFlag(4);
|
||||
}
|
||||
|
||||
public void setElder(boolean isGuardian) {
|
||||
public void setElder(boolean isGuardian)
|
||||
{
|
||||
setGuardianFlag(4, isGuardian);
|
||||
}
|
||||
|
||||
protected boolean isGuardianFlag(int no) {
|
||||
return ((byte) getValue(11, (byte) 0) & no) != 0;
|
||||
protected boolean isGuardianFlag(int no)
|
||||
{
|
||||
return (getValue(FlagType.GUARDIAN_FLAG) & no) != 0;
|
||||
}
|
||||
|
||||
protected void setGuardianFlag(int no, boolean flag) {
|
||||
byte b0 = (byte) getValue(11, (byte) 0);
|
||||
if (flag) {
|
||||
setValue(11, (byte) (b0 | no));
|
||||
} else {
|
||||
setValue(11, (byte) (b0 & -(no + 1)));
|
||||
protected void setGuardianFlag(int no, boolean flag)
|
||||
{
|
||||
byte b0 = getValue(FlagType.GUARDIAN_FLAG);
|
||||
|
||||
if (flag)
|
||||
{
|
||||
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 me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
|
||||
public class HorseWatcher extends AgeableWatcher
|
||||
@ -19,13 +20,14 @@ public class HorseWatcher extends AgeableWatcher
|
||||
public HorseWatcher(Disguise disguise)
|
||||
{
|
||||
super(disguise);
|
||||
|
||||
setStyle(Style.values()[DisguiseUtilities.random.nextInt(Style.values().length)]);
|
||||
setColor(Color.values()[DisguiseUtilities.random.nextInt(Color.values().length)]);
|
||||
}
|
||||
|
||||
public Variant getVariant()
|
||||
{
|
||||
return Variant.values()[(int) getValue(13, 0)];
|
||||
return Variant.values()[getValue(FlagType.HORSE_VARIANT)];
|
||||
}
|
||||
|
||||
public void setVariant(Variant variant)
|
||||
@ -39,45 +41,48 @@ public class HorseWatcher extends AgeableWatcher
|
||||
{
|
||||
variant = 0; // Crashing people is mean
|
||||
}
|
||||
setValue(13, variant);
|
||||
sendData(13);
|
||||
|
||||
setValue(FlagType.HORSE_VARIANT, variant);
|
||||
sendData(FlagType.HORSE_VARIANT);
|
||||
}
|
||||
|
||||
public Color getColor()
|
||||
{
|
||||
return Color.values()[((Integer) getValue(14, 0) & 0xFF)];
|
||||
return Color.values()[((Integer) getValue(FlagType.HORSE_COLOR) & 0xFF)];
|
||||
}
|
||||
|
||||
public ItemStack getHorseArmor()
|
||||
{
|
||||
int horseValue = getHorseArmorAsInt();
|
||||
|
||||
switch (horseValue)
|
||||
{
|
||||
case 1:
|
||||
return new ItemStack(Material.getMaterial("IRON_BARDING"));
|
||||
return new ItemStack(Material.IRON_BARDING);
|
||||
case 2:
|
||||
return new ItemStack(Material.getMaterial("GOLD_BARDING"));
|
||||
return new ItemStack(Material.GOLD_BARDING);
|
||||
case 3:
|
||||
return new ItemStack(Material.getMaterial("DIAMOND_BARDING"));
|
||||
return new ItemStack(Material.DIAMOND_BARDING);
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
protected int getHorseArmorAsInt()
|
||||
{
|
||||
return (int) getValue(16, 0);
|
||||
return getValue(FlagType.HORSE_ARMOR);
|
||||
}
|
||||
|
||||
public Optional<UUID> getOwner()
|
||||
{
|
||||
return getValue(15, Optional.<UUID> absent());
|
||||
return getValue(FlagType.HORSE_OWNER);
|
||||
}
|
||||
|
||||
public Style getStyle()
|
||||
{
|
||||
return Style.values()[((int) getValue(14, 0) >>> 8)];
|
||||
return Style.values()[(getValue(FlagType.HORSE_STYLE) >>> 8)];
|
||||
}
|
||||
|
||||
public boolean hasChest()
|
||||
@ -122,7 +127,7 @@ public class HorseWatcher extends AgeableWatcher
|
||||
|
||||
private byte getHorseFlag()
|
||||
{
|
||||
return (byte) getValue(12, (byte) 0);
|
||||
return getValue(FlagType.HORSE_META);
|
||||
}
|
||||
|
||||
public void setCanBreed(boolean breed)
|
||||
@ -137,22 +142,24 @@ public class HorseWatcher extends AgeableWatcher
|
||||
|
||||
public void setColor(Color color)
|
||||
{
|
||||
setValue(14, color.ordinal() & 0xFF | getStyle().ordinal() << 8);
|
||||
sendData(14);
|
||||
setValue(FlagType.HORSE_COLOR, color.ordinal() & 0xFF | getStyle().ordinal() << 8);
|
||||
sendData(FlagType.HORSE_COLOR);
|
||||
}
|
||||
|
||||
private void setHorseFlag(int i, boolean flag)
|
||||
{
|
||||
byte j = (byte) getValue(12, (byte) 0);
|
||||
byte j = getValue(FlagType.HORSE_META);
|
||||
|
||||
if (flag)
|
||||
{
|
||||
setValue(12, (byte) (j | i));
|
||||
setValue(FlagType.HORSE_META, (byte) (j | i));
|
||||
}
|
||||
else
|
||||
{
|
||||
setValue(12, (byte) (j & ~i));
|
||||
setValue(FlagType.HORSE_META, (byte) (j & ~i));
|
||||
}
|
||||
sendData(12);
|
||||
|
||||
sendData(FlagType.HORSE_META);
|
||||
}
|
||||
|
||||
public void setGrazing(boolean grazing)
|
||||
@ -162,16 +169,18 @@ public class HorseWatcher extends AgeableWatcher
|
||||
|
||||
protected void setHorseArmor(int armor)
|
||||
{
|
||||
setValue(16, armor);
|
||||
sendData(16);
|
||||
setValue(FlagType.HORSE_ARMOR, armor);
|
||||
sendData(FlagType.HORSE_ARMOR);
|
||||
}
|
||||
|
||||
public void setHorseArmor(ItemStack item)
|
||||
{
|
||||
int value = 0;
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
Material mat = item.getType();
|
||||
|
||||
if (mat == Material.IRON_BARDING)
|
||||
{
|
||||
value = 1;
|
||||
@ -185,6 +194,7 @@ public class HorseWatcher extends AgeableWatcher
|
||||
value = 3;
|
||||
}
|
||||
}
|
||||
|
||||
setHorseArmor(value);
|
||||
}
|
||||
|
||||
@ -195,8 +205,8 @@ public class HorseWatcher extends AgeableWatcher
|
||||
|
||||
public void setOwner(UUID uuid)
|
||||
{
|
||||
setValue(15, Optional.of(uuid));
|
||||
sendData(15);
|
||||
setValue(FlagType.HORSE_OWNER, Optional.of(uuid));
|
||||
sendData(FlagType.HORSE_OWNER);
|
||||
}
|
||||
|
||||
public void setRearing(boolean rear)
|
||||
@ -211,8 +221,8 @@ public class HorseWatcher extends AgeableWatcher
|
||||
|
||||
public void setStyle(Style style)
|
||||
{
|
||||
setValue(14, getColor().ordinal() & 0xFF | style.ordinal() << 8);
|
||||
sendData(14);
|
||||
setValue(FlagType.HORSE_STYLE, getColor().ordinal() & 0xFF | style.ordinal() << 8);
|
||||
sendData(FlagType.HORSE_STYLE);
|
||||
}
|
||||
|
||||
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;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||
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);
|
||||
}
|
||||
|
||||
public ItemStack getItem() {
|
||||
if (getValue(5, null) == null) {
|
||||
return new ItemStack(0);
|
||||
}
|
||||
return (ItemStack) getValue(5, null);
|
||||
public ItemStack getItem()
|
||||
{
|
||||
if (getValue(FlagType.ITEMFRAME_ITEM) == null)
|
||||
{
|
||||
return new ItemStack(Material.AIR);
|
||||
}
|
||||
|
||||
public int getRotation() {
|
||||
return (int) getValue(6, 0);
|
||||
return (ItemStack) getValue(FlagType.ITEMFRAME_ITEM);
|
||||
}
|
||||
|
||||
public void setItem(ItemStack newItem) {
|
||||
if (newItem == null) {
|
||||
newItem = new ItemStack(0);
|
||||
public int getRotation()
|
||||
{
|
||||
return getValue(FlagType.ITEMFRAME_ROTATION);
|
||||
}
|
||||
|
||||
public void setItem(ItemStack newItem)
|
||||
{
|
||||
if (newItem == null)
|
||||
{
|
||||
newItem = new ItemStack(Material.AIR);
|
||||
}
|
||||
|
||||
newItem = newItem.clone();
|
||||
newItem.setAmount(1);
|
||||
setValue(5, newItem);
|
||||
sendData(5);
|
||||
|
||||
setValue(FlagType.ITEMFRAME_ITEM, newItem);
|
||||
sendData(FlagType.ITEMFRAME_ITEM);
|
||||
}
|
||||
|
||||
public void setRotation(int rotation) {
|
||||
setValue(6, (byte) (rotation % 4));
|
||||
sendData(6);
|
||||
public void setRotation(int rotation)
|
||||
{
|
||||
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.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
||||
|
||||
public class LivingWatcher extends FlagWatcher
|
||||
{
|
||||
|
||||
static Map<Integer, Object> list = new HashMap<>();
|
||||
static Method getId;
|
||||
|
||||
@ -36,6 +36,7 @@ public class LivingWatcher extends FlagWatcher
|
||||
{
|
||||
getId = ReflectionManager.getNmsMethod("MobEffectList", "getId", ReflectionManager.getNmsClass("MobEffectList"));
|
||||
Object REGISTRY = ReflectionManager.getNmsField("MobEffectList", "REGISTRY").get(null);
|
||||
|
||||
for (Object next : ((Iterable) REGISTRY))
|
||||
{
|
||||
int id = (int) getId.invoke(null, next);
|
||||
@ -81,7 +82,7 @@ public class LivingWatcher extends FlagWatcher
|
||||
|
||||
public float getHealth()
|
||||
{
|
||||
return (float) getValue(6, 0F);
|
||||
return (float) getValue(FlagType.LIVING_HEALTH);
|
||||
}
|
||||
|
||||
public double getMaxHealth()
|
||||
@ -91,7 +92,7 @@ public class LivingWatcher extends FlagWatcher
|
||||
|
||||
public boolean isPotionParticlesAmbient()
|
||||
{
|
||||
return (boolean) getValue(8, false);
|
||||
return (boolean) getValue(FlagType.LIVING_POTION_AMBIENT);
|
||||
}
|
||||
|
||||
private int getPotions()
|
||||
@ -151,31 +152,31 @@ public class LivingWatcher extends FlagWatcher
|
||||
|
||||
public void setPotionParticlesAmbient(boolean particles)
|
||||
{
|
||||
setValue(8, particles);
|
||||
sendData(8);
|
||||
setValue(FlagType.LIVING_POTION_AMBIENT, particles);
|
||||
sendData(FlagType.LIVING_POTION_AMBIENT);
|
||||
}
|
||||
|
||||
private void sendPotionEffects()
|
||||
{
|
||||
setValue(7, getPotions());
|
||||
sendData(7);
|
||||
setValue(FlagType.LIVING_POTIONS, getPotions());
|
||||
sendData(FlagType.LIVING_POTIONS);
|
||||
}
|
||||
|
||||
public void setHealth(float health)
|
||||
{
|
||||
setValue(6, health);
|
||||
sendData(6);
|
||||
setValue(FlagType.LIVING_HEALTH, health);
|
||||
sendData(FlagType.LIVING_HEALTH);
|
||||
}
|
||||
|
||||
public int getArrowsSticking()
|
||||
{
|
||||
return (int) getValue(9, 0);
|
||||
return (int) getValue(FlagType.LIVING_ARROWS);
|
||||
}
|
||||
|
||||
public void setArrowsSticking(int arrowsNo)
|
||||
{
|
||||
setValue(9, arrowsNo);
|
||||
sendData(9);
|
||||
setValue(FlagType.LIVING_ARROWS, arrowsNo);
|
||||
sendData(FlagType.LIVING_ARROWS);
|
||||
}
|
||||
|
||||
public void setMaxHealth(double newHealth)
|
||||
|
@ -3,6 +3,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||
|
||||
public class MinecartWatcher extends FlagWatcher
|
||||
@ -15,39 +16,42 @@ public class MinecartWatcher extends FlagWatcher
|
||||
|
||||
public ItemStack getBlockInCart()
|
||||
{
|
||||
int id = (int) getValue(8, 0) & 0xffff;
|
||||
int data = (int) getValue(8, 0) >> 16;
|
||||
int id = (int) getValue(FlagType.MINECART_BLOCK) & 0xffff;
|
||||
int data = (int) getValue(FlagType.MINECART_BLOCK) >> 16;
|
||||
|
||||
return new ItemStack(id, 1, (short) data);
|
||||
}
|
||||
|
||||
public int getBlockYOffset()
|
||||
{
|
||||
return (int) getValue(9, 0);
|
||||
return (int) getValue(FlagType.MINECART_BLOCK_Y);
|
||||
}
|
||||
|
||||
public boolean isViewBlockInCart()
|
||||
{
|
||||
return (boolean) getValue(10, false);
|
||||
return (boolean) getValue(FlagType.MINECART_BLOCK_VISIBLE);
|
||||
}
|
||||
|
||||
public void setBlockInCart(ItemStack item)
|
||||
{
|
||||
int id = item.getTypeId();
|
||||
int data = item.getDurability();
|
||||
setValue(8, id & 0xffff | data << 16);
|
||||
setValue(10, true); // Show block
|
||||
sendData(8, 10);
|
||||
|
||||
setValue(FlagType.MINECART_BLOCK, id & 0xffff | data << 16);
|
||||
setValue(FlagType.MINECART_BLOCK_VISIBLE, true); // Show block
|
||||
|
||||
sendData(FlagType.MINECART_BLOCK);
|
||||
}
|
||||
|
||||
public void setBlockOffset(int i)
|
||||
{
|
||||
setValue(9, i);
|
||||
sendData(9);
|
||||
setValue(FlagType.MINECART_BLOCK_Y, i);
|
||||
sendData(FlagType.MINECART_BLOCK_Y);
|
||||
}
|
||||
|
||||
public void setViewBlockInCart(boolean viewBlock)
|
||||
{
|
||||
setValue(10, viewBlock);
|
||||
sendData(10);
|
||||
setValue(FlagType.MINECART_BLOCK_VISIBLE, viewBlock);
|
||||
sendData(FlagType.MINECART_BLOCK_VISIBLE);
|
||||
}
|
||||
}
|
||||
|
@ -4,19 +4,24 @@ import org.bukkit.entity.Ocelot;
|
||||
import org.bukkit.entity.Ocelot.Type;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public Type getType() {
|
||||
return Ocelot.Type.getType((int) getValue(14, 0));
|
||||
public Type getType()
|
||||
{
|
||||
return Ocelot.Type.getType(getValue(FlagType.OCELOT_TYPE));
|
||||
}
|
||||
|
||||
public void setType(Type newType) {
|
||||
setValue(14, newType.getId());
|
||||
sendData(14);
|
||||
public void setType(Type newType)
|
||||
{
|
||||
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.utilities.DisguiseUtilities;
|
||||
|
||||
public class PaintingWatcher extends FlagWatcher {
|
||||
public class PaintingWatcher extends FlagWatcher
|
||||
{
|
||||
|
||||
private Art painting;
|
||||
|
||||
public PaintingWatcher(Disguise disguise) {
|
||||
public PaintingWatcher(Disguise disguise)
|
||||
{
|
||||
super(disguise);
|
||||
}
|
||||
|
||||
@Override
|
||||
public PaintingWatcher clone(Disguise disguise) {
|
||||
public PaintingWatcher clone(Disguise disguise)
|
||||
{
|
||||
PaintingWatcher watcher = (PaintingWatcher) super.clone(disguise);
|
||||
watcher.setArt(getArt());
|
||||
|
||||
return watcher;
|
||||
}
|
||||
|
||||
public Art getArt() {
|
||||
public Art getArt()
|
||||
{
|
||||
return painting;
|
||||
}
|
||||
|
||||
public void setArt(Art newPainting) {
|
||||
public void setArt(Art newPainting)
|
||||
{
|
||||
this.painting = newPainting;
|
||||
if (getDisguise().getEntity() != null && getDisguise().getWatcher() == this) {
|
||||
|
||||
if (getDisguise().getEntity() != null && getDisguise().getWatcher() == this)
|
||||
{
|
||||
DisguiseUtilities.refreshTrackers(getDisguise());
|
||||
}
|
||||
}
|
||||
|
@ -1,19 +1,24 @@
|
||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public boolean isSaddled() {
|
||||
return (boolean) getValue(12, false);
|
||||
public boolean isSaddled()
|
||||
{
|
||||
return (boolean) getValue(FlagType.PIG_SADDLED);
|
||||
}
|
||||
|
||||
public void setSaddled(boolean isSaddled) {
|
||||
setValue(12, isSaddled);
|
||||
sendData(12);
|
||||
public void setSaddled(boolean isSaddled)
|
||||
{
|
||||
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.DisguiseConfig;
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||
import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
|
||||
@ -60,7 +61,7 @@ public class PlayerWatcher extends LivingWatcher
|
||||
|
||||
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()
|
||||
@ -101,43 +102,50 @@ public class PlayerWatcher extends LivingWatcher
|
||||
public void setCapeEnabled(boolean enabled)
|
||||
{
|
||||
setSkinFlags(1, enabled);
|
||||
sendData(12);
|
||||
|
||||
sendData(FlagType.PLAYER_SKIN);
|
||||
}
|
||||
|
||||
public void setJackedEnabled(boolean enabled)
|
||||
{
|
||||
setSkinFlags(2, enabled);
|
||||
sendData(12);
|
||||
|
||||
sendData(FlagType.PLAYER_SKIN);
|
||||
}
|
||||
|
||||
public void setLeftSleeveEnabled(boolean enabled)
|
||||
{
|
||||
setSkinFlags(3, enabled);
|
||||
sendData(12);
|
||||
|
||||
sendData(FlagType.PLAYER_SKIN);
|
||||
}
|
||||
|
||||
public void setRightSleeveEnabled(boolean enabled)
|
||||
{
|
||||
setSkinFlags(4, enabled);
|
||||
sendData(12);
|
||||
|
||||
sendData(FlagType.PLAYER_SKIN);
|
||||
}
|
||||
|
||||
public void setLeftPantsEnabled(boolean enabled)
|
||||
{
|
||||
setSkinFlags(5, enabled);
|
||||
sendData(12);
|
||||
|
||||
sendData(FlagType.PLAYER_SKIN);
|
||||
}
|
||||
|
||||
public void setRightPantsEnabled(boolean enabled)
|
||||
{
|
||||
setSkinFlags(6, enabled);
|
||||
sendData(12);
|
||||
|
||||
sendData(FlagType.PLAYER_SKIN);
|
||||
}
|
||||
|
||||
public void setHatEnabled(boolean enabled)
|
||||
{
|
||||
setSkinFlags(7, enabled);
|
||||
sendData(12);
|
||||
|
||||
sendData(FlagType.PLAYER_SKIN);
|
||||
}
|
||||
|
||||
public boolean isSleeping()
|
||||
@ -232,14 +240,15 @@ public class PlayerWatcher extends LivingWatcher
|
||||
|
||||
private void setSkinFlags(int i, boolean flag)
|
||||
{
|
||||
byte b0 = (byte) getValue(12, (byte) 0);
|
||||
byte b0 = (byte) getValue(FlagType.PLAYER_SKIN);
|
||||
|
||||
if (flag)
|
||||
{
|
||||
setValue(12, (byte) (b0 | 1 << i));
|
||||
setValue(FlagType.PLAYER_SKIN, (byte) (b0 | 1 << i));
|
||||
}
|
||||
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;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||
import me.libraryaddict.disguise.disguisetypes.RabbitType;
|
||||
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);
|
||||
setType(RabbitType.values()[DisguiseUtilities.random.nextInt(RabbitType.values().length)]);
|
||||
}
|
||||
|
||||
public RabbitType getType() {
|
||||
return RabbitType.getType((int) getValue(18, 0));
|
||||
public RabbitType getType()
|
||||
{
|
||||
return RabbitType.getType((int) getValue(FlagType.RABBIT_TYPE));
|
||||
}
|
||||
|
||||
public void setType(RabbitType type) {
|
||||
setValue(12, type.getTypeId());
|
||||
sendData(12);
|
||||
public void setType(RabbitType type)
|
||||
{
|
||||
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.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);
|
||||
setValue(12, (byte) 0);
|
||||
|
||||
setValue(FlagType.SHEEP_WOOL, (byte) 0);
|
||||
}
|
||||
|
||||
public AnimalColor getColor() {
|
||||
return AnimalColor.getColor(((int) getValue(12, (byte) 0) & 15));
|
||||
public AnimalColor getColor()
|
||||
{
|
||||
return AnimalColor.getColor(((int) getValue(FlagType.SHEEP_WOOL) & 15));
|
||||
}
|
||||
|
||||
public boolean isSheared() {
|
||||
return ((byte) getValue(12, (byte) 0) & 16) != 0;
|
||||
public boolean isSheared()
|
||||
{
|
||||
return ((byte) getValue(FlagType.SHEEP_WOOL) & 16) != 0;
|
||||
}
|
||||
|
||||
public void setColor(AnimalColor color) {
|
||||
public void setColor(AnimalColor color)
|
||||
{
|
||||
setColor(DyeColor.getByWoolData((byte) color.getId()));
|
||||
}
|
||||
|
||||
public void setColor(DyeColor color) {
|
||||
byte b0 = (byte) getValue(12, (byte) 0);
|
||||
setValue(12, (byte) (b0 & 240 | color.getWoolData() & 15));
|
||||
sendData(12);
|
||||
public void setColor(DyeColor color)
|
||||
{
|
||||
byte b0 = (byte) getValue(FlagType.SHEEP_WOOL);
|
||||
|
||||
setValue(FlagType.SHEEP_WOOL, (byte) (b0 & 240 | color.getWoolData() & 15));
|
||||
sendData(FlagType.SHEEP_WOOL);
|
||||
}
|
||||
|
||||
public void setSheared(boolean flag) {
|
||||
byte b0 = (byte) getValue(12, (byte) 0);
|
||||
if (flag) {
|
||||
setValue(12, (byte) (b0 | 16));
|
||||
} else {
|
||||
setValue(12, (byte) (b0 & -17));
|
||||
public void setSheared(boolean flag)
|
||||
{
|
||||
byte b0 = (byte) getValue(FlagType.SHEEP_WOOL);
|
||||
|
||||
if (flag)
|
||||
{
|
||||
setValue(FlagType.SHEEP_WOOL, (byte) (b0 | 16));
|
||||
}
|
||||
sendData(12);
|
||||
else
|
||||
{
|
||||
setValue(FlagType.SHEEP_WOOL, (byte) (b0 & -17));
|
||||
}
|
||||
|
||||
sendData(FlagType.SHEEP_WOOL);
|
||||
}
|
||||
}
|
||||
|
@ -11,33 +11,41 @@ import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
* @author Navid
|
||||
*/
|
||||
// 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);
|
||||
}
|
||||
|
||||
public BlockFace getFacingDirection() {
|
||||
public BlockFace getFacingDirection()
|
||||
{
|
||||
return BlockFace.UP;
|
||||
}
|
||||
|
||||
public void setFacingDirection() {
|
||||
public void setFacingDirection()
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public Optional<BlockPosition> getAttachmentPosition() {
|
||||
public Optional<BlockPosition> getAttachmentPosition()
|
||||
{
|
||||
return Optional.absent();
|
||||
}
|
||||
|
||||
public void setAttachmentPosition(BlockPosition pos) {
|
||||
public void setAttachmentPosition(BlockPosition pos)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
public byte getShieldHeight() {
|
||||
public byte getShieldHeight()
|
||||
{
|
||||
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 me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||
|
||||
/**
|
||||
* @author Navid
|
||||
*/
|
||||
public class SkeletonWatcher extends LivingWatcher {
|
||||
|
||||
public SkeletonWatcher(Disguise disguise) {
|
||||
public class SkeletonWatcher extends LivingWatcher
|
||||
{
|
||||
public SkeletonWatcher(Disguise disguise)
|
||||
{
|
||||
super(disguise);
|
||||
}
|
||||
|
||||
public void setType(SkeletonType type) {
|
||||
setValue(11, type.getId());
|
||||
sendData(11);
|
||||
public void setType(SkeletonType type)
|
||||
{
|
||||
setValue(FlagType.SKELETON_TYPE, type.ordinal());
|
||||
sendData(FlagType.SKELETON_TYPE);
|
||||
}
|
||||
|
||||
public SkeletonType getType() {
|
||||
return SkeletonType.getType((int) getValue(11, SkeletonType.NORMAL.getId()));
|
||||
public SkeletonType getType()
|
||||
{
|
||||
return SkeletonType.values()[getValue(FlagType.SKELETON_TYPE)];
|
||||
}
|
||||
}
|
||||
|
@ -1,25 +1,32 @@
|
||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||
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);
|
||||
setSize(DisguiseUtilities.random.nextInt(4) + 1);
|
||||
}
|
||||
|
||||
public int getSize() {
|
||||
return (int) getValue(11, 1);
|
||||
public int getSize()
|
||||
{
|
||||
return (int) getValue(FlagType.SLIME_SIZE);
|
||||
}
|
||||
|
||||
public void setSize(int size) {
|
||||
if (size <= 0 || size >= 128) {
|
||||
public void setSize(int size)
|
||||
{
|
||||
if (size <= 0 || size >= 128)
|
||||
{
|
||||
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.utilities.DisguiseUtilities;
|
||||
|
||||
public class SplashPotionWatcher extends FlagWatcher {
|
||||
|
||||
public class SplashPotionWatcher extends FlagWatcher
|
||||
{
|
||||
private int potionId;
|
||||
|
||||
public SplashPotionWatcher(Disguise disguise) {
|
||||
public SplashPotionWatcher(Disguise disguise)
|
||||
{
|
||||
super(disguise);
|
||||
}
|
||||
|
||||
@Override
|
||||
public SplashPotionWatcher clone(Disguise disguise) {
|
||||
public SplashPotionWatcher clone(Disguise disguise)
|
||||
{
|
||||
SplashPotionWatcher watcher = (SplashPotionWatcher) super.clone(disguise);
|
||||
watcher.setPotionId(getPotionId());
|
||||
|
||||
return watcher;
|
||||
}
|
||||
|
||||
public int getPotionId() {
|
||||
public int getPotionId()
|
||||
{
|
||||
return potionId;
|
||||
}
|
||||
|
||||
public void setPotionId(int newPotionId) {
|
||||
public void setPotionId(int newPotionId)
|
||||
{
|
||||
this.potionId = newPotionId;
|
||||
if (getDisguise().getEntity() != null && getDisguise().getWatcher() == this) {
|
||||
|
||||
if (getDisguise().getEntity() != null && getDisguise().getWatcher() == this)
|
||||
{
|
||||
DisguiseUtilities.refreshTrackers(getDisguise());
|
||||
}
|
||||
}
|
||||
|
@ -5,10 +5,10 @@ import java.util.UUID;
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||
|
||||
public class TameableWatcher extends AgeableWatcher
|
||||
{
|
||||
|
||||
public TameableWatcher(Disguise disguise)
|
||||
{
|
||||
super(disguise);
|
||||
@ -16,7 +16,7 @@ public class TameableWatcher extends AgeableWatcher
|
||||
|
||||
public Optional<UUID> getOwner()
|
||||
{
|
||||
return getValue(13, Optional.<UUID> absent());
|
||||
return getValue(FlagType.TAMEABLE_OWNER);
|
||||
}
|
||||
|
||||
public boolean isSitting()
|
||||
@ -31,27 +31,29 @@ public class TameableWatcher extends AgeableWatcher
|
||||
|
||||
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)
|
||||
{
|
||||
byte value = (byte) getValue(12, (byte) 0);
|
||||
byte value = (byte) getValue(FlagType.TAMEABLE_META);
|
||||
|
||||
if (flag)
|
||||
{
|
||||
setValue(12, (byte) (value | no));
|
||||
setValue(FlagType.TAMEABLE_META, (byte) (value | no));
|
||||
}
|
||||
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)
|
||||
{
|
||||
setValue(13, Optional.of(owner));
|
||||
sendData(13);
|
||||
setValue(FlagType.TAMEABLE_OWNER, Optional.of(owner));
|
||||
sendData(FlagType.TAMEABLE_OWNER);
|
||||
}
|
||||
|
||||
public void setSitting(boolean sitting)
|
||||
|
@ -3,28 +3,35 @@ package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
import org.bukkit.Color;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
|
||||
/**
|
||||
* @author Navid
|
||||
*/
|
||||
public class TippedArrowWatcher extends ArrowWatcher {
|
||||
public class TippedArrowWatcher extends ArrowWatcher
|
||||
{
|
||||
|
||||
public TippedArrowWatcher(Disguise disguise) {
|
||||
public TippedArrowWatcher(Disguise disguise)
|
||||
{
|
||||
super(disguise);
|
||||
|
||||
int r = DisguiseUtilities.random.nextInt(256);
|
||||
int g = DisguiseUtilities.random.nextInt(256);
|
||||
int b = DisguiseUtilities.random.nextInt(256);
|
||||
|
||||
setColor(Color.fromRGB(r, g, b));
|
||||
}
|
||||
|
||||
public Color getColor() {
|
||||
int color = (int) getValue(5, Color.WHITE.asRGB());
|
||||
public Color getColor()
|
||||
{
|
||||
int color = (int) getValue(FlagType.TIPPED_ARROW_COLOR);
|
||||
return Color.fromRGB(color);
|
||||
}
|
||||
|
||||
public void setColor(Color color) {
|
||||
setValue(5, color.asRGB());
|
||||
sendData(5);
|
||||
public void setColor(Color color)
|
||||
{
|
||||
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 me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||
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);
|
||||
setProfession(Profession.values()[DisguiseUtilities.random.nextInt(Profession.values().length)]);
|
||||
}
|
||||
|
||||
public Profession getProfession() {
|
||||
return Profession.getProfession((int) getValue(16, 0));
|
||||
public Profession getProfession()
|
||||
{
|
||||
return Profession.values()[getValue(FlagType.VILLAGER_PROFESSION)];
|
||||
}
|
||||
|
||||
public void setProfession(int professionId) {
|
||||
setValue(12, professionId);
|
||||
sendData(12);
|
||||
public void setProfession(int professionId)
|
||||
{
|
||||
setValue(FlagType.VILLAGER_PROFESSION, professionId);
|
||||
sendData(FlagType.VILLAGER_PROFESSION);
|
||||
}
|
||||
|
||||
public void setProfession(Profession newProfession) {
|
||||
setProfession(newProfession.getId());
|
||||
public void setProfession(Profession newProfession)
|
||||
{
|
||||
setProfession(newProfession.ordinal());
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +1,28 @@
|
||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||
|
||||
/**
|
||||
* @author Navid
|
||||
*/
|
||||
public class WitchWatcher extends LivingWatcher {
|
||||
public class WitchWatcher extends LivingWatcher
|
||||
{
|
||||
|
||||
public WitchWatcher(Disguise disguise) {
|
||||
public WitchWatcher(Disguise disguise)
|
||||
{
|
||||
super(disguise);
|
||||
}
|
||||
|
||||
|
||||
public boolean isAggressive() {
|
||||
return (boolean) getValue(11, false);
|
||||
public boolean isAggressive()
|
||||
{
|
||||
return (boolean) getValue(FlagType.WITCH_AGGRESSIVE);
|
||||
}
|
||||
|
||||
public void setAggressive(boolean aggressive) {
|
||||
setValue(11, aggressive);
|
||||
sendData(11);
|
||||
public void setAggressive(boolean aggressive)
|
||||
{
|
||||
setValue(FlagType.WITCH_AGGRESSIVE, aggressive);
|
||||
sendData(FlagType.WITCH_AGGRESSIVE);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,21 +1,26 @@
|
||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||
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);
|
||||
}
|
||||
|
||||
public boolean isBlue() {
|
||||
return (boolean) getValue(5, false);
|
||||
public boolean isBlue()
|
||||
{
|
||||
return (boolean) getValue(FlagType.WITHERSKULL_BLUE);
|
||||
}
|
||||
|
||||
public void setBlue(boolean blue) {
|
||||
setValue(5, blue);
|
||||
sendData(5);
|
||||
public void setBlue(boolean blue)
|
||||
{
|
||||
setValue(FlagType.WITHERSKULL_BLUE, blue);
|
||||
sendData(FlagType.WITHERSKULL_BLUE);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -5,42 +5,54 @@ import java.security.InvalidParameterException;
|
||||
import org.bukkit.ChatColor;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
/**
|
||||
* Returns the amount of time this Wither is invulnerable for
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getInvulnerability() {
|
||||
return (int) getValue(14, 0);
|
||||
public int getInvulnerability()
|
||||
{
|
||||
return (int) getValue(FlagType.WITHER_INVUL);
|
||||
}
|
||||
|
||||
public int[] getTargets() {
|
||||
return new int[]{(Integer) getValue(11, 0), (Integer) getValue(12, 0), (Integer) getValue(13, 0)};
|
||||
public int[] getTargets()
|
||||
{
|
||||
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
|
||||
*/
|
||||
public void setInvulnerability(int invulnerability) {
|
||||
setValue(14, invulnerability);
|
||||
sendData(14);
|
||||
public void setInvulnerability(int invulnerability)
|
||||
{
|
||||
setValue(FlagType.WITHER_INVUL, invulnerability);
|
||||
sendData(FlagType.WITHER_INVUL);
|
||||
}
|
||||
|
||||
public void setTargets(int... targets) {
|
||||
if (targets.length != 3) {
|
||||
throw new InvalidParameterException(ChatColor.RED + "Expected 3 numbers for wither setTargets. Received "
|
||||
+ targets.length);
|
||||
public void setTargets(int... targets)
|
||||
{
|
||||
if (targets.length != 3)
|
||||
{
|
||||
throw new InvalidParameterException(
|
||||
ChatColor.RED + "Expected 3 numbers for wither setTargets. Received " + targets.length);
|
||||
}
|
||||
setValue(11, targets[0]);
|
||||
setValue(12, targets[1]);
|
||||
setValue(13, targets[2]);
|
||||
sendData(11, 12, 13);
|
||||
setValue(FlagType.WITHER_TARGET_1, targets[0]);
|
||||
setValue(FlagType.WITHER_TARGET_2, targets[1]);
|
||||
setValue(FlagType.WITHER_TARGET_3, targets[2]);
|
||||
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.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);
|
||||
}
|
||||
|
||||
public AnimalColor getCollarColor() {
|
||||
return AnimalColor.getColor((int) getValue(16, 14));
|
||||
public AnimalColor getCollarColor()
|
||||
{
|
||||
return AnimalColor.getColor(getValue(FlagType.WOLF_COLLAR));
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for tail rotation.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public float getDamageTaken() {
|
||||
return (float) getValue(14, 0);
|
||||
public float getDamageTaken()
|
||||
{
|
||||
return (float) getValue(FlagType.WOLF_DAMAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for tail rotation.
|
||||
*
|
||||
* @param damage
|
||||
*/
|
||||
public void setDamageTaken(float damage) {
|
||||
setValue(14, damage);
|
||||
sendData(14);
|
||||
public void setDamageTaken(float damage)
|
||||
{
|
||||
setValue(FlagType.WOLF_DAMAGE, damage);
|
||||
sendData(FlagType.WOLF_DAMAGE);
|
||||
}
|
||||
|
||||
public boolean isBegging() {
|
||||
return (boolean) getValue(15, false);
|
||||
public boolean isBegging()
|
||||
{
|
||||
return (boolean) getValue(FlagType.WOLF_BEGGING);
|
||||
}
|
||||
|
||||
public void setBegging(boolean begging) {
|
||||
setValue(15, begging);
|
||||
sendData(15);
|
||||
public void setBegging(boolean begging)
|
||||
{
|
||||
setValue(FlagType.WOLF_BEGGING, begging);
|
||||
sendData(FlagType.WOLF_BEGGING);
|
||||
}
|
||||
|
||||
public boolean isAngry() {
|
||||
public boolean isAngry()
|
||||
{
|
||||
return isTameableFlag(2);
|
||||
}
|
||||
|
||||
public void setAngry(boolean angry) {
|
||||
public void setAngry(boolean angry)
|
||||
{
|
||||
setTameableFlag(2, angry);
|
||||
}
|
||||
|
||||
public void setCollarColor(AnimalColor color) {
|
||||
public void setCollarColor(AnimalColor color)
|
||||
{
|
||||
setCollarColor(DyeColor.getByWoolData((byte) color.getId()));
|
||||
}
|
||||
|
||||
public void setCollarColor(DyeColor newColor) {
|
||||
if (!isTamed()) {
|
||||
public void setCollarColor(DyeColor newColor)
|
||||
{
|
||||
if (!isTamed())
|
||||
{
|
||||
setTamed(true);
|
||||
}
|
||||
if (newColor.getWoolData() != getCollarColor().getId()) {
|
||||
setValue(16, (int) newColor.getDyeData());
|
||||
sendData(16);
|
||||
|
||||
if (newColor.getWoolData() == getCollarColor().getId())
|
||||
{
|
||||
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 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);
|
||||
}
|
||||
|
||||
public boolean isAdult() {
|
||||
public boolean isAdult()
|
||||
{
|
||||
return !isBaby();
|
||||
}
|
||||
|
||||
public boolean isBaby() {
|
||||
return (boolean) getValue(11, false);
|
||||
public boolean isBaby()
|
||||
{
|
||||
return getValue(FlagType.ZOMBIE_BABY);
|
||||
}
|
||||
|
||||
public boolean isShaking() {
|
||||
return (boolean) getValue(14, false);
|
||||
public boolean isShaking()
|
||||
{
|
||||
return getValue(FlagType.ZOMBIE_SHAKING);
|
||||
}
|
||||
|
||||
/**
|
||||
* Is this zombie a villager?
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isVillager() {
|
||||
return ((int)getValue(12, 0)) != 0;
|
||||
public boolean isVillager()
|
||||
{
|
||||
return ((int) getValue(FlagType.ZOMBIE_PROFESSION)) != 0;
|
||||
}
|
||||
|
||||
public boolean isAggressive() {
|
||||
return (boolean) getValue(14, false);
|
||||
public boolean isAggressive()
|
||||
{
|
||||
return (boolean) getValue(FlagType.ZOMBIE_AGGRESSIVE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Only returns a valid value if this zombie
|
||||
* is a villager.
|
||||
* Only returns a valid value if this zombie is a villager.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public Profession getProfession() {
|
||||
return Profession.getProfession((int) getValue(12, 0));
|
||||
public Profession getProfession()
|
||||
{
|
||||
return Profession.values()[getValue(FlagType.ZOMBIE_PROFESSION)];
|
||||
}
|
||||
|
||||
public void setAdult() {
|
||||
public void setAdult()
|
||||
{
|
||||
setBaby(false);
|
||||
}
|
||||
|
||||
public void setBaby() {
|
||||
public void setBaby()
|
||||
{
|
||||
setBaby(true);
|
||||
}
|
||||
|
||||
public void setBaby(boolean baby) {
|
||||
setValue(11, baby);
|
||||
sendData(11);
|
||||
public void setBaby(boolean baby)
|
||||
{
|
||||
setValue(FlagType.ZOMBIE_BABY, baby);
|
||||
sendData(FlagType.ZOMBIE_BABY);
|
||||
}
|
||||
|
||||
public void setShaking(boolean shaking) {
|
||||
setValue(13, (byte) (shaking ? 1 : 0));
|
||||
sendData(13);
|
||||
public void setShaking(boolean shaking)
|
||||
{
|
||||
setValue(FlagType.ZOMBIE_SHAKING, shaking);
|
||||
sendData(FlagType.ZOMBIE_SHAKING);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the profession of this zombie, in turn
|
||||
* turning it into a Zombie Villager
|
||||
* Sets the profession of this zombie, in turn turning it into a Zombie Villager
|
||||
*
|
||||
* @param id
|
||||
*/
|
||||
public void setProfession(int id) {
|
||||
setValue(12, id);
|
||||
sendData(12);
|
||||
public void setProfession(int id)
|
||||
{
|
||||
setValue(FlagType.ZOMBIE_PROFESSION, id);
|
||||
sendData(FlagType.ZOMBIE_PROFESSION);
|
||||
}
|
||||
|
||||
/**
|
||||
* Sets the profession of this zombie, in turn
|
||||
* turning it into a Zombie Villager
|
||||
* Sets the profession of this zombie, in turn turning it into a Zombie Villager
|
||||
*
|
||||
* @param profession
|
||||
*/
|
||||
public void setProfession(Profession profession) {
|
||||
setValue(12, profession.getId());
|
||||
sendData(12);
|
||||
public void setProfession(Profession profession)
|
||||
{
|
||||
setValue(FlagType.ZOMBIE_PROFESSION, profession.ordinal());
|
||||
sendData(FlagType.ZOMBIE_PROFESSION);
|
||||
}
|
||||
|
||||
public void setAggressive(boolean handsup) {
|
||||
setValue(14, handsup);
|
||||
sendData(14);
|
||||
public void setAggressive(boolean handsup)
|
||||
{
|
||||
setValue(FlagType.ZOMBIE_AGGRESSIVE, handsup);
|
||||
sendData(FlagType.ZOMBIE_AGGRESSIVE);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -57,7 +57,6 @@ import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher;
|
||||
|
||||
public class DisguiseUtilities
|
||||
{
|
||||
|
||||
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
|
||||
@ -359,8 +358,9 @@ public class DisguiseUtilities
|
||||
{
|
||||
Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity());
|
||||
|
||||
if (entityTrackerEntry != null)
|
||||
{
|
||||
if (entityTrackerEntry == null)
|
||||
return;
|
||||
|
||||
Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers")
|
||||
.get(entityTrackerEntry);
|
||||
|
||||
@ -385,7 +385,6 @@ public class DisguiseUtilities
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
ex.printStackTrace(System.out);
|
||||
@ -664,6 +663,7 @@ public class DisguiseUtilities
|
||||
for (Object p : trackedPlayers)
|
||||
{
|
||||
Player player = (Player) ReflectionManager.getBukkitEntity(p);
|
||||
|
||||
if (((TargetedDisguise) disguise).canSee(player))
|
||||
{
|
||||
players.add(player);
|
||||
@ -919,8 +919,9 @@ public class DisguiseUtilities
|
||||
{
|
||||
final Object entityTrackerEntry = ReflectionManager.getEntityTrackerEntry(disguise.getEntity());
|
||||
|
||||
if (entityTrackerEntry != null)
|
||||
{
|
||||
if (entityTrackerEntry == null)
|
||||
return;
|
||||
|
||||
Set trackedPlayers = (Set) ReflectionManager.getNmsField("EntityTrackerEntry", "trackedPlayers")
|
||||
.get(entityTrackerEntry);
|
||||
|
||||
@ -936,8 +937,9 @@ public class DisguiseUtilities
|
||||
{
|
||||
Player pl = (Player) ReflectionManager.getBukkitEntity(p);
|
||||
|
||||
if (player.equalsIgnoreCase((pl).getName()))
|
||||
{
|
||||
if (!player.equalsIgnoreCase((pl).getName()))
|
||||
continue;
|
||||
|
||||
clear.invoke(entityTrackerEntry, p);
|
||||
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(pl, destroyPacket);
|
||||
@ -962,8 +964,6 @@ public class DisguiseUtilities
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (
|
||||
|
||||
Exception ex)
|
||||
|
@ -3,6 +3,7 @@ package me.libraryaddict.disguise.utilities;
|
||||
import java.util.HashMap;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||
|
||||
public class DisguiseValues
|
||||
{
|
||||
@ -39,7 +40,7 @@ public class DisguiseValues
|
||||
return values.get(type);
|
||||
}
|
||||
|
||||
public static HashMap<Integer, Object> getMetaValues(DisguiseType type)
|
||||
public static HashMap<FlagType, Object> getMetaValues(DisguiseType type)
|
||||
{
|
||||
return getDisguiseValues(type).getMetaValues();
|
||||
}
|
||||
@ -53,7 +54,7 @@ public class DisguiseValues
|
||||
private FakeBoundingBox babyBox;
|
||||
private float[] entitySize;
|
||||
private double maxHealth;
|
||||
private HashMap<Integer, Object> metaValues = new HashMap<>();
|
||||
private HashMap<FlagType, Object> metaValues = new HashMap<>();
|
||||
private Class nmsEntityClass;
|
||||
|
||||
public DisguiseValues(DisguiseType type, Class classType, int entitySize, double maxHealth)
|
||||
@ -83,7 +84,7 @@ public class DisguiseValues
|
||||
return maxHealth;
|
||||
}
|
||||
|
||||
public HashMap<Integer, Object> getMetaValues()
|
||||
public HashMap<FlagType, Object> getMetaValues()
|
||||
{
|
||||
return metaValues;
|
||||
}
|
||||
@ -108,7 +109,7 @@ public class DisguiseValues
|
||||
this.entitySize = size;
|
||||
}
|
||||
|
||||
public void setMetaValue(int id, Object value)
|
||||
public void setMetaValue(FlagType id, Object value)
|
||||
{
|
||||
metaValues.put(id, value);
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user