Added new disguises, added new disguisetypes, fixed the
horse/lama/whatever changes, fixed a boat 'facing' bug, renamed a few internal methods, still dont know why some disguises are invisible.
This commit is contained in:
parent
58b7086cd2
commit
bb303ac96b
6
pom.xml
6
pom.xml
@ -37,17 +37,17 @@
|
||||
<dependency>
|
||||
<groupId>com.comphenix.protocol</groupId>
|
||||
<artifactId>ProtocolLib</artifactId>
|
||||
<version>4.1.0-SNAPSHOT</version>
|
||||
<version>4.2.0-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot-api</artifactId>
|
||||
<version>1.10-R0.1-SNAPSHOT</version>
|
||||
<version>1.11-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
<dependency>
|
||||
<groupId>org.spigotmc</groupId>
|
||||
<artifactId>spigot</artifactId>
|
||||
<version>1.10-R0.1-SNAPSHOT</version>
|
||||
<version>1.11-R0.1-SNAPSHOT</version>
|
||||
</dependency>
|
||||
</dependencies>
|
||||
|
||||
|
@ -27,158 +27,126 @@ import me.libraryaddict.disguise.disguisetypes.MobDisguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.TargetedDisguise.TargetType;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.HorseAbstractWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.HorseWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
||||
|
||||
public class DisguiseAPI
|
||||
{
|
||||
public static Disguise constructDisguise(Entity entity)
|
||||
{
|
||||
public class DisguiseAPI {
|
||||
public static Disguise constructDisguise(Entity entity) {
|
||||
return constructDisguise(entity, true, true, true);
|
||||
}
|
||||
|
||||
public static Disguise constructDisguise(Entity entity, boolean doEquipment, boolean doSneak, boolean doSprint)
|
||||
{
|
||||
public static Disguise constructDisguise(Entity entity, boolean doEquipment, boolean doSneak, boolean doSprint) {
|
||||
DisguiseType disguiseType = DisguiseType.getType(entity);
|
||||
Disguise disguise;
|
||||
|
||||
if (disguiseType.isMisc())
|
||||
{
|
||||
if (disguiseType.isMisc()) {
|
||||
disguise = new MiscDisguise(disguiseType);
|
||||
}
|
||||
else if (disguiseType.isMob())
|
||||
{
|
||||
else if (disguiseType.isMob()) {
|
||||
disguise = new MobDisguise(disguiseType);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
disguise = new PlayerDisguise(entity.getName());
|
||||
}
|
||||
|
||||
FlagWatcher watcher = disguise.getWatcher();
|
||||
|
||||
if (entity instanceof LivingEntity)
|
||||
{
|
||||
for (PotionEffect effect : ((LivingEntity) entity).getActivePotionEffects())
|
||||
{
|
||||
if (entity instanceof LivingEntity) {
|
||||
for (PotionEffect effect : ((LivingEntity) entity).getActivePotionEffects()) {
|
||||
((LivingWatcher) watcher).addPotionEffect(effect.getType());
|
||||
|
||||
if (effect.getType() == PotionEffectType.INVISIBILITY)
|
||||
{
|
||||
if (effect.getType() == PotionEffectType.INVISIBILITY) {
|
||||
watcher.setInvisible(true);
|
||||
}
|
||||
else if (effect.getType() == PotionEffectType.GLOWING)
|
||||
{
|
||||
else if (effect.getType() == PotionEffectType.GLOWING) {
|
||||
watcher.setGlowing(true);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (entity.getFireTicks() > 0)
|
||||
{
|
||||
if (entity.getFireTicks() > 0) {
|
||||
watcher.setBurning(true);
|
||||
}
|
||||
|
||||
if (doEquipment && entity instanceof LivingEntity)
|
||||
{
|
||||
if (doEquipment && entity instanceof LivingEntity) {
|
||||
EntityEquipment equip = ((LivingEntity) entity).getEquipment();
|
||||
|
||||
watcher.setArmor(equip.getArmorContents());
|
||||
watcher.setItemInMainHand(equip.getItemInMainHand());
|
||||
|
||||
if (disguiseType.getEntityType() == EntityType.HORSE)
|
||||
{
|
||||
if (disguiseType.getEntityType() == EntityType.HORSE) {
|
||||
Horse horse = (Horse) entity;
|
||||
HorseInventory horseInventory = horse.getInventory();
|
||||
ItemStack saddle = horseInventory.getSaddle();
|
||||
|
||||
if (saddle != null && saddle.getType() == Material.SADDLE)
|
||||
{
|
||||
((HorseWatcher) watcher).setSaddled(true);
|
||||
if (saddle != null && saddle.getType() == Material.SADDLE) {
|
||||
((HorseAbstractWatcher) watcher).setSaddled(true);
|
||||
}
|
||||
|
||||
((HorseWatcher) watcher).setHorseArmor(horseInventory.getArmor());
|
||||
if (watcher instanceof HorseWatcher)
|
||||
((HorseWatcher) watcher).setHorseArmor(horseInventory.getArmor());
|
||||
}
|
||||
}
|
||||
for (Method method : entity.getClass().getMethods())
|
||||
{
|
||||
for (Method method : entity.getClass().getMethods()) {
|
||||
if ((doSneak || !method.getName().equals("setSneaking")) && (doSprint || !method.getName().equals("setSprinting"))
|
||||
&& method.getParameterTypes().length == 0 && method.getReturnType() != void.class)
|
||||
{
|
||||
&& method.getParameterTypes().length == 0 && method.getReturnType() != void.class) {
|
||||
Class methodReturn = method.getReturnType();
|
||||
|
||||
if (methodReturn == float.class || methodReturn == Float.class || methodReturn == Double.class)
|
||||
{
|
||||
if (methodReturn == float.class || methodReturn == Float.class || methodReturn == Double.class) {
|
||||
methodReturn = double.class;
|
||||
}
|
||||
|
||||
int firstCapitalMethod = firstCapital(method.getName());
|
||||
|
||||
if (firstCapitalMethod > 0)
|
||||
{
|
||||
for (Method watcherMethod : watcher.getClass().getMethods())
|
||||
{
|
||||
if (firstCapitalMethod > 0) {
|
||||
for (Method watcherMethod : watcher.getClass().getMethods()) {
|
||||
if (!watcherMethod.getName().startsWith("get") && watcherMethod.getReturnType() == void.class
|
||||
&& watcherMethod.getParameterTypes().length == 1)
|
||||
{
|
||||
&& watcherMethod.getParameterTypes().length == 1) {
|
||||
int firstCapitalWatcher = firstCapital(watcherMethod.getName());
|
||||
|
||||
if (firstCapitalWatcher > 0 && method.getName().substring(firstCapitalMethod)
|
||||
.equalsIgnoreCase(watcherMethod.getName().substring(firstCapitalWatcher)))
|
||||
{
|
||||
.equalsIgnoreCase(watcherMethod.getName().substring(firstCapitalWatcher))) {
|
||||
Class methodParam = watcherMethod.getParameterTypes()[0];
|
||||
|
||||
if (methodParam == float.class || methodParam == Float.class || methodParam == Double.class)
|
||||
{
|
||||
if (methodParam == float.class || methodParam == Float.class || methodParam == Double.class) {
|
||||
methodParam = double.class;
|
||||
}
|
||||
else if (methodParam == AnimalColor.class)
|
||||
{
|
||||
else if (methodParam == AnimalColor.class) {
|
||||
methodParam = DyeColor.class;
|
||||
}
|
||||
if (methodReturn == methodParam)
|
||||
{
|
||||
try
|
||||
{
|
||||
if (methodReturn == methodParam) {
|
||||
try {
|
||||
Object value = method.invoke(entity);
|
||||
if (value != null)
|
||||
{
|
||||
if (value != null) {
|
||||
Class toCast = watcherMethod.getParameterTypes()[0];
|
||||
if (!(toCast.isInstance(value)))
|
||||
{
|
||||
if (toCast == float.class)
|
||||
{
|
||||
if (!(value instanceof Float))
|
||||
{
|
||||
if (!(toCast.isInstance(value))) {
|
||||
if (toCast == float.class) {
|
||||
if (!(value instanceof Float)) {
|
||||
double d = (Double) value;
|
||||
value = (float) d;
|
||||
}
|
||||
}
|
||||
else if (toCast == double.class)
|
||||
{
|
||||
if (!(value instanceof Double))
|
||||
{
|
||||
else if (toCast == double.class) {
|
||||
if (!(value instanceof Double)) {
|
||||
float d = (Float) value;
|
||||
value = (double) d;
|
||||
}
|
||||
}
|
||||
else if (toCast == AnimalColor.class)
|
||||
{
|
||||
else if (toCast == AnimalColor.class) {
|
||||
value = AnimalColor.valueOf(((DyeColor) value).name());
|
||||
}
|
||||
}
|
||||
if (value instanceof Boolean && !(Boolean) value
|
||||
&& watcherMethod.getDeclaringClass() == FlagWatcher.class)
|
||||
{
|
||||
&& watcherMethod.getDeclaringClass() == FlagWatcher.class) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
watcherMethod.invoke(watcher, value);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -191,21 +159,17 @@ public class DisguiseAPI
|
||||
return disguise;
|
||||
}
|
||||
|
||||
public static void disguiseEntity(Entity entity, Disguise disguise)
|
||||
{
|
||||
public static void disguiseEntity(Entity entity, Disguise disguise) {
|
||||
// If they are trying to disguise a null entity or use a null disguise
|
||||
// Just return.
|
||||
if (entity == null || disguise == null)
|
||||
{
|
||||
if (entity == null || disguise == null) {
|
||||
return;
|
||||
}
|
||||
// The event wasn't cancelled.
|
||||
// If the disguise entity isn't the same as the one we are disguising
|
||||
if (disguise.getEntity() != entity)
|
||||
{
|
||||
if (disguise.getEntity() != entity) {
|
||||
// If the disguise entity actually exists
|
||||
if (disguise.getEntity() != null)
|
||||
{
|
||||
if (disguise.getEntity() != null) {
|
||||
// Clone the disguise
|
||||
disguise = disguise.clone();
|
||||
}
|
||||
@ -213,31 +177,25 @@ public class DisguiseAPI
|
||||
disguise.setEntity(entity);
|
||||
}
|
||||
|
||||
if (Disguise.getViewSelf().contains(disguise.getEntity().getUniqueId()))
|
||||
{
|
||||
if (Disguise.getViewSelf().contains(disguise.getEntity().getUniqueId())) {
|
||||
disguise.setViewSelfDisguise(true);
|
||||
}
|
||||
|
||||
disguise.startDisguise();
|
||||
}
|
||||
|
||||
public static void disguiseIgnorePlayers(Entity entity, Disguise disguise, Collection playersToNotSeeDisguise)
|
||||
{
|
||||
if (disguise.getEntity() != null)
|
||||
{
|
||||
public static void disguiseIgnorePlayers(Entity entity, Disguise disguise, Collection playersToNotSeeDisguise) {
|
||||
if (disguise.getEntity() != null) {
|
||||
disguise = disguise.clone();
|
||||
}
|
||||
|
||||
((TargetedDisguise) disguise).setDisguiseTarget(TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS);
|
||||
|
||||
for (Object obj : playersToNotSeeDisguise)
|
||||
{
|
||||
if (obj instanceof String)
|
||||
{
|
||||
for (Object obj : playersToNotSeeDisguise) {
|
||||
if (obj instanceof String) {
|
||||
((TargetedDisguise) disguise).addPlayer((String) obj);
|
||||
}
|
||||
else if (obj instanceof Player)
|
||||
{
|
||||
else if (obj instanceof Player) {
|
||||
((TargetedDisguise) disguise).addPlayer(((Player) obj).getName());
|
||||
}
|
||||
}
|
||||
@ -246,18 +204,15 @@ public class DisguiseAPI
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void disguiseIgnorePlayers(Entity entity, Disguise disguise, List<String> playersToNotSeeDisguise)
|
||||
{
|
||||
public static void disguiseIgnorePlayers(Entity entity, Disguise disguise, List<String> playersToNotSeeDisguise) {
|
||||
disguiseIgnorePlayers(entity, disguise, (Collection) playersToNotSeeDisguise);
|
||||
}
|
||||
|
||||
public static void disguiseIgnorePlayers(Entity entity, Disguise disguise, Player... playersToNotSeeDisguise)
|
||||
{
|
||||
public static void disguiseIgnorePlayers(Entity entity, Disguise disguise, Player... playersToNotSeeDisguise) {
|
||||
disguiseIgnorePlayers(entity, disguise, (Collection) Arrays.asList(playersToNotSeeDisguise));
|
||||
}
|
||||
|
||||
public static void disguiseIgnorePlayers(Entity entity, Disguise disguise, String... playersToNotSeeDisguise)
|
||||
{
|
||||
public static void disguiseIgnorePlayers(Entity entity, Disguise disguise, String... playersToNotSeeDisguise) {
|
||||
disguiseIgnorePlayers(entity, disguise, (Collection) Arrays.asList(playersToNotSeeDisguise));
|
||||
}
|
||||
|
||||
@ -267,27 +222,22 @@ public class DisguiseAPI
|
||||
* @param disguise
|
||||
* @return
|
||||
*/
|
||||
public static int disguiseNextEntity(Disguise disguise)
|
||||
{
|
||||
if (disguise == null)
|
||||
{
|
||||
public static int disguiseNextEntity(Disguise disguise) {
|
||||
if (disguise == null) {
|
||||
return -1;
|
||||
}
|
||||
|
||||
if (disguise.getEntity() != null || DisguiseUtilities.getDisguises().containsValue(disguise))
|
||||
{
|
||||
if (disguise.getEntity() != null || DisguiseUtilities.getDisguises().containsValue(disguise)) {
|
||||
disguise = disguise.clone();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
int id = ReflectionManager.getNmsField("Entity", "entityCount").getInt(null);
|
||||
DisguiseUtilities.addFutureDisguise(id, (TargetedDisguise) disguise);
|
||||
|
||||
return id;
|
||||
}
|
||||
catch (IllegalAccessException e)
|
||||
{
|
||||
catch (IllegalAccessException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
@ -300,40 +250,32 @@ public class DisguiseAPI
|
||||
* @param entity
|
||||
* @param disguise
|
||||
*/
|
||||
public static void disguiseToAll(Entity entity, Disguise disguise)
|
||||
{
|
||||
if (disguise.getEntity() != null)
|
||||
{
|
||||
public static void disguiseToAll(Entity entity, Disguise disguise) {
|
||||
if (disguise.getEntity() != null) {
|
||||
disguise = disguise.clone();
|
||||
}
|
||||
|
||||
// You called the disguiseToAll method foolish mortal! Prepare to have your custom settings wiped!!!
|
||||
((TargetedDisguise) disguise).setDisguiseTarget(TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS);
|
||||
|
||||
for (String observer : ((TargetedDisguise) disguise).getObservers())
|
||||
{
|
||||
for (String observer : ((TargetedDisguise) disguise).getObservers()) {
|
||||
((TargetedDisguise) disguise).removePlayer(observer);
|
||||
}
|
||||
disguiseEntity(entity, disguise);
|
||||
}
|
||||
|
||||
public static void disguiseToPlayers(Entity entity, Disguise disguise, Collection playersToViewDisguise)
|
||||
{
|
||||
if (disguise.getEntity() != null)
|
||||
{
|
||||
public static void disguiseToPlayers(Entity entity, Disguise disguise, Collection playersToViewDisguise) {
|
||||
if (disguise.getEntity() != null) {
|
||||
disguise = disguise.clone();
|
||||
}
|
||||
|
||||
((TargetedDisguise) disguise).setDisguiseTarget(TargetType.HIDE_DISGUISE_TO_EVERYONE_BUT_THESE_PLAYERS);
|
||||
|
||||
for (Object obj : playersToViewDisguise)
|
||||
{
|
||||
if (obj instanceof String)
|
||||
{
|
||||
for (Object obj : playersToViewDisguise) {
|
||||
if (obj instanceof String) {
|
||||
((TargetedDisguise) disguise).addPlayer((String) obj);
|
||||
}
|
||||
else if (obj instanceof Player)
|
||||
{
|
||||
else if (obj instanceof Player) {
|
||||
((TargetedDisguise) disguise).addPlayer(((Player) obj).getName());
|
||||
}
|
||||
}
|
||||
@ -342,27 +284,21 @@ public class DisguiseAPI
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
public static void disguiseToPlayers(Entity entity, Disguise disguise, List<String> playersToViewDisguise)
|
||||
{
|
||||
public static void disguiseToPlayers(Entity entity, Disguise disguise, List<String> playersToViewDisguise) {
|
||||
disguiseToPlayers(entity, disguise, (Collection) playersToViewDisguise);
|
||||
}
|
||||
|
||||
public static void disguiseToPlayers(Entity entity, Disguise disguise, Player... playersToViewDisguise)
|
||||
{
|
||||
public static void disguiseToPlayers(Entity entity, Disguise disguise, Player... playersToViewDisguise) {
|
||||
disguiseToPlayers(entity, disguise, (Collection) Arrays.asList(playersToViewDisguise));
|
||||
}
|
||||
|
||||
public static void disguiseToPlayers(Entity entity, Disguise disguise, String... playersToViewDisguise)
|
||||
{
|
||||
public static void disguiseToPlayers(Entity entity, Disguise disguise, String... playersToViewDisguise) {
|
||||
disguiseToPlayers(entity, disguise, (Collection) Arrays.asList(playersToViewDisguise));
|
||||
}
|
||||
|
||||
private static int firstCapital(String str)
|
||||
{
|
||||
for (int i = 0; i < str.length(); i++)
|
||||
{
|
||||
if (Character.isUpperCase(str.charAt(i)))
|
||||
{
|
||||
private static int firstCapital(String str) {
|
||||
for (int i = 0; i < str.length(); i++) {
|
||||
if (Character.isUpperCase(str.charAt(i))) {
|
||||
return i;
|
||||
}
|
||||
}
|
||||
@ -376,10 +312,8 @@ public class DisguiseAPI
|
||||
* @param disguised
|
||||
* @return
|
||||
*/
|
||||
public static Disguise getDisguise(Entity disguised)
|
||||
{
|
||||
if (disguised == null)
|
||||
{
|
||||
public static Disguise getDisguise(Entity disguised) {
|
||||
if (disguised == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -393,10 +327,8 @@ public class DisguiseAPI
|
||||
* @param disguised
|
||||
* @return
|
||||
*/
|
||||
public static Disguise getDisguise(Player observer, Entity disguised)
|
||||
{
|
||||
if (disguised == null || observer == null)
|
||||
{
|
||||
public static Disguise getDisguise(Player observer, Entity disguised) {
|
||||
if (disguised == null || observer == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
@ -409,18 +341,15 @@ public class DisguiseAPI
|
||||
* @param disguised
|
||||
* @return
|
||||
*/
|
||||
public static Disguise[] getDisguises(Entity disguised)
|
||||
{
|
||||
if (disguised == null)
|
||||
{
|
||||
public static Disguise[] getDisguises(Entity disguised) {
|
||||
if (disguised == null) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return DisguiseUtilities.getDisguises(disguised.getUniqueId());
|
||||
}
|
||||
|
||||
public static int getSelfDisguiseId()
|
||||
{
|
||||
public static int getSelfDisguiseId() {
|
||||
return -10;
|
||||
}
|
||||
|
||||
@ -430,8 +359,7 @@ public class DisguiseAPI
|
||||
* @param disguised
|
||||
* @return
|
||||
*/
|
||||
public static boolean isDisguised(Entity disguised)
|
||||
{
|
||||
public static boolean isDisguised(Entity disguised) {
|
||||
return getDisguise(disguised) != null;
|
||||
}
|
||||
|
||||
@ -442,18 +370,15 @@ public class DisguiseAPI
|
||||
* @param disguised
|
||||
* @return
|
||||
*/
|
||||
public static boolean isDisguised(Player observer, Entity disguised)
|
||||
{
|
||||
public static boolean isDisguised(Player observer, Entity disguised) {
|
||||
return getDisguise(observer, disguised) != null;
|
||||
}
|
||||
|
||||
public static boolean isDisguiseInUse(Disguise disguise)
|
||||
{
|
||||
public static boolean isDisguiseInUse(Disguise disguise) {
|
||||
return disguise.isDisguiseInUse();
|
||||
}
|
||||
|
||||
public static boolean isSelfDisguised(Player player)
|
||||
{
|
||||
public static boolean isSelfDisguised(Player player) {
|
||||
return DisguiseUtilities.getSelfDisguised().contains(player.getUniqueId());
|
||||
}
|
||||
|
||||
@ -463,8 +388,7 @@ public class DisguiseAPI
|
||||
* @param entity
|
||||
* @return
|
||||
*/
|
||||
public static boolean isViewSelfToggled(Entity entity)
|
||||
{
|
||||
public static boolean isViewSelfToggled(Entity entity) {
|
||||
return isDisguised(entity) ? getDisguise(entity).isSelfDisguiseVisible()
|
||||
: Disguise.getViewSelf().contains(entity.getUniqueId());
|
||||
}
|
||||
@ -475,12 +399,10 @@ public class DisguiseAPI
|
||||
*
|
||||
* @param entity
|
||||
*/
|
||||
public static void undisguiseToAll(Entity entity)
|
||||
{
|
||||
public static void undisguiseToAll(Entity entity) {
|
||||
Disguise[] disguises = getDisguises(entity);
|
||||
|
||||
for (Disguise disguise : disguises)
|
||||
{
|
||||
for (Disguise disguise : disguises) {
|
||||
disguise.removeDisguise();
|
||||
}
|
||||
}
|
||||
@ -491,28 +413,22 @@ public class DisguiseAPI
|
||||
* @param entity
|
||||
* @param toggled
|
||||
*/
|
||||
public static void setViewDisguiseToggled(Entity entity, boolean toggled)
|
||||
{
|
||||
if (isDisguised(entity))
|
||||
{
|
||||
public static void setViewDisguiseToggled(Entity entity, boolean toggled) {
|
||||
if (isDisguised(entity)) {
|
||||
Disguise disguise = getDisguise(entity);
|
||||
disguise.setViewSelfDisguise(toggled);
|
||||
}
|
||||
|
||||
if (toggled)
|
||||
{
|
||||
if (!Disguise.getViewSelf().contains(entity.getUniqueId()))
|
||||
{
|
||||
if (toggled) {
|
||||
if (!Disguise.getViewSelf().contains(entity.getUniqueId())) {
|
||||
Disguise.getViewSelf().add(entity.getUniqueId());
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
Disguise.getViewSelf().remove(entity.getUniqueId());
|
||||
}
|
||||
}
|
||||
|
||||
private DisguiseAPI()
|
||||
{
|
||||
private DisguiseAPI() {
|
||||
}
|
||||
}
|
||||
|
@ -36,7 +36,6 @@ import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.ArrowWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.GuardianWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.HorseWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.InsentientWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.MinecartWatcher;
|
||||
@ -54,32 +53,26 @@ import me.libraryaddict.disguise.utilities.Metrics;
|
||||
import me.libraryaddict.disguise.utilities.PacketsManager;
|
||||
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
||||
|
||||
public class LibsDisguises extends JavaPlugin
|
||||
{
|
||||
public class LibsDisguises extends JavaPlugin {
|
||||
private static LibsDisguises instance;
|
||||
private DisguiseListener listener;
|
||||
|
||||
@Override
|
||||
public void onEnable()
|
||||
{
|
||||
try
|
||||
{
|
||||
public void onEnable() {
|
||||
try {
|
||||
Class.forName("com.comphenix.protocol.wrappers.Vector3F").getName();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
catch (Exception ex) {
|
||||
System.err.println("[LibsDisguises] Lib's Disguises failed to startup, outdated ProtocolLib!");
|
||||
System.err.println(
|
||||
"[LibsDisguises] You need to update ProtocolLib, please try this build http://ci.dmulloy2.net/job/ProtocolLib/lastStableBuild/artifact/modules/ProtocolLib/target/ProtocolLib.jar");
|
||||
return;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
ReflectionManager.getNmsClass("EntityShulker").getName();
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
catch (Exception ex) {
|
||||
System.err.println("[LibsDisguises] Lib's Disguises failed to startup, outdated server!");
|
||||
System.err.println("[LibsDisguises] This plugin does not offer backwards support!");
|
||||
return;
|
||||
@ -117,21 +110,18 @@ public class LibsDisguises extends JavaPlugin
|
||||
|
||||
instance = this;
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
Metrics metrics = new Metrics(this);
|
||||
metrics.start();
|
||||
}
|
||||
catch (IOException e)
|
||||
{
|
||||
catch (IOException e) {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Reloads the config with new config options.
|
||||
*/
|
||||
public void reload()
|
||||
{
|
||||
public void reload() {
|
||||
HandlerList.unregisterAll(listener);
|
||||
|
||||
reloadConfig();
|
||||
@ -142,21 +132,16 @@ public class LibsDisguises extends JavaPlugin
|
||||
* Here we create a nms entity for each disguise. Then grab their default values in their datawatcher. Then their sound volume
|
||||
* for mob noises. As well as setting their watcher class and entity size.
|
||||
*/
|
||||
private void registerValues()
|
||||
{
|
||||
for (DisguiseType disguiseType : DisguiseType.values())
|
||||
{
|
||||
if (disguiseType.getEntityType() == null)
|
||||
{
|
||||
private void registerValues() {
|
||||
for (DisguiseType disguiseType : DisguiseType.values()) {
|
||||
if (disguiseType.getEntityType() == null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
Class watcherClass = null;
|
||||
|
||||
try
|
||||
{
|
||||
switch (disguiseType)
|
||||
{
|
||||
try {
|
||||
switch (disguiseType) {
|
||||
case SPECTRAL_ARROW:
|
||||
watcherClass = ArrowWatcher.class;
|
||||
break;
|
||||
@ -175,12 +160,6 @@ public class LibsDisguises extends JavaPlugin
|
||||
case CAVE_SPIDER:
|
||||
watcherClass = SpiderWatcher.class;
|
||||
break;
|
||||
case DONKEY:
|
||||
case MULE:
|
||||
case UNDEAD_HORSE:
|
||||
case SKELETON_HORSE:
|
||||
watcherClass = HorseWatcher.class;
|
||||
break;
|
||||
case ZOMBIE_VILLAGER:
|
||||
case PIG_ZOMBIE:
|
||||
case HUSK:
|
||||
@ -202,57 +181,46 @@ public class LibsDisguises extends JavaPlugin
|
||||
break;
|
||||
}
|
||||
}
|
||||
catch (ClassNotFoundException ex)
|
||||
{
|
||||
catch (ClassNotFoundException ex) {
|
||||
// There is no explicit watcher for this entity.
|
||||
Class entityClass = disguiseType.getEntityType().getEntityClass();
|
||||
|
||||
if (entityClass != null)
|
||||
{
|
||||
if (Tameable.class.isAssignableFrom(entityClass))
|
||||
{
|
||||
if (entityClass != null) {
|
||||
if (Tameable.class.isAssignableFrom(entityClass)) {
|
||||
watcherClass = TameableWatcher.class;
|
||||
}
|
||||
else if (Ageable.class.isAssignableFrom(entityClass))
|
||||
{
|
||||
else if (Ageable.class.isAssignableFrom(entityClass)) {
|
||||
watcherClass = AgeableWatcher.class;
|
||||
}
|
||||
else if (Creature.class.isAssignableFrom(entityClass))
|
||||
{
|
||||
else if (Creature.class.isAssignableFrom(entityClass)) {
|
||||
watcherClass = InsentientWatcher.class;
|
||||
}
|
||||
else if (LivingEntity.class.isAssignableFrom(entityClass))
|
||||
{
|
||||
else if (LivingEntity.class.isAssignableFrom(entityClass)) {
|
||||
watcherClass = LivingWatcher.class;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
watcherClass = FlagWatcher.class;
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
watcherClass = FlagWatcher.class; // Disguise is unknown type
|
||||
}
|
||||
}
|
||||
|
||||
if (watcherClass == null)
|
||||
{
|
||||
if (watcherClass == null) {
|
||||
System.err.println("Error loading " + disguiseType.name() + ", FlagWatcher not assigned");
|
||||
continue;
|
||||
}
|
||||
|
||||
disguiseType.setWatcherClass(watcherClass);
|
||||
|
||||
if (DisguiseValues.getDisguiseValues(disguiseType) != null)
|
||||
{
|
||||
if (DisguiseValues.getDisguiseValues(disguiseType) != null) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String nmsEntityName = toReadable(disguiseType.name());
|
||||
|
||||
switch (disguiseType)
|
||||
{
|
||||
switch (disguiseType) {
|
||||
case WITHER_SKELETON:
|
||||
case ZOMBIE_VILLAGER:
|
||||
case DONKEY:
|
||||
@ -299,18 +267,15 @@ public class LibsDisguises extends JavaPlugin
|
||||
break;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
if (nmsEntityName.equalsIgnoreCase("Unknown"))
|
||||
{
|
||||
try {
|
||||
if (nmsEntityName.equalsIgnoreCase("Unknown")) {
|
||||
DisguiseValues disguiseValues = new DisguiseValues(disguiseType, null, 0, 0);
|
||||
|
||||
disguiseValues.setAdultBox(new FakeBoundingBox(0, 0, 0));
|
||||
|
||||
DisguiseSound sound = DisguiseSound.getType(disguiseType.name());
|
||||
|
||||
if (sound != null)
|
||||
{
|
||||
if (sound != null) {
|
||||
sound.setDamageAndIdleSoundVolume(1f);
|
||||
}
|
||||
|
||||
@ -319,8 +284,7 @@ public class LibsDisguises extends JavaPlugin
|
||||
|
||||
Object nmsEntity = ReflectionManager.createEntityInstance(nmsEntityName);
|
||||
|
||||
if (nmsEntity == null)
|
||||
{
|
||||
if (nmsEntity == null) {
|
||||
getLogger().warning("Entity not found! (" + nmsEntityName + ")");
|
||||
|
||||
continue;
|
||||
@ -329,10 +293,8 @@ public class LibsDisguises extends JavaPlugin
|
||||
Entity bukkitEntity = ReflectionManager.getBukkitEntity(nmsEntity);
|
||||
int entitySize = 0;
|
||||
|
||||
for (Field field : ReflectionManager.getNmsClass("Entity").getFields())
|
||||
{
|
||||
if (field.getType().getName().equals("EnumEntitySize"))
|
||||
{
|
||||
for (Field field : ReflectionManager.getNmsClass("Entity").getFields()) {
|
||||
if (field.getType().getName().equals("EnumEntitySize")) {
|
||||
Enum enumEntitySize = (Enum) field.get(nmsEntity);
|
||||
|
||||
entitySize = enumEntitySize.ordinal();
|
||||
@ -346,12 +308,10 @@ public class LibsDisguises extends JavaPlugin
|
||||
|
||||
WrappedDataWatcher watcher = WrappedDataWatcher.getEntityWatcher(bukkitEntity);
|
||||
|
||||
for (WrappedWatchableObject watch : watcher.getWatchableObjects())
|
||||
{
|
||||
for (WrappedWatchableObject watch : watcher.getWatchableObjects()) {
|
||||
FlagType flagType = FlagType.getFlag(watcherClass, watch.getIndex());
|
||||
|
||||
if (flagType == null)
|
||||
{
|
||||
if (flagType == null) {
|
||||
System.err.println("Error finding the FlagType for " + disguiseType.name() + "! Index " + watch.getIndex()
|
||||
+ " can't be found!");
|
||||
System.err.println("Value is " + watch.getRawValue() + " (" + watch.getRawValue().getClass() + ") ("
|
||||
@ -363,12 +323,10 @@ public class LibsDisguises extends JavaPlugin
|
||||
|
||||
DisguiseSound sound = DisguiseSound.getType(disguiseType.name());
|
||||
|
||||
if (sound != null)
|
||||
{
|
||||
if (sound != null) {
|
||||
Float soundStrength = ReflectionManager.getSoundModifier(nmsEntity);
|
||||
|
||||
if (soundStrength != null)
|
||||
{
|
||||
if (soundStrength != null) {
|
||||
sound.setDamageAndIdleSoundVolume(soundStrength);
|
||||
}
|
||||
}
|
||||
@ -376,14 +334,12 @@ public class LibsDisguises extends JavaPlugin
|
||||
// Get the bounding box
|
||||
disguiseValues.setAdultBox(ReflectionManager.getBoundingBox(bukkitEntity));
|
||||
|
||||
if (bukkitEntity instanceof Ageable)
|
||||
{
|
||||
if (bukkitEntity instanceof Ageable) {
|
||||
((Ageable) bukkitEntity).setBaby();
|
||||
|
||||
disguiseValues.setBabyBox(ReflectionManager.getBoundingBox(bukkitEntity));
|
||||
}
|
||||
else if (bukkitEntity instanceof Zombie)
|
||||
{
|
||||
else if (bukkitEntity instanceof Zombie) {
|
||||
((Zombie) bukkitEntity).setBaby(true);
|
||||
|
||||
disguiseValues.setBabyBox(ReflectionManager.getBoundingBox(bukkitEntity));
|
||||
@ -391,8 +347,7 @@ public class LibsDisguises extends JavaPlugin
|
||||
|
||||
disguiseValues.setEntitySize(ReflectionManager.getSize(bukkitEntity));
|
||||
}
|
||||
catch (SecurityException | IllegalArgumentException | IllegalAccessException | FieldAccessException ex)
|
||||
{
|
||||
catch (SecurityException | IllegalArgumentException | IllegalAccessException | FieldAccessException ex) {
|
||||
System.out.print(
|
||||
"[LibsDisguises] Uh oh! Trouble while making values for the disguise " + disguiseType.name() + "!");
|
||||
System.out.print("[LibsDisguises] Before reporting this error, "
|
||||
@ -405,20 +360,17 @@ public class LibsDisguises extends JavaPlugin
|
||||
}
|
||||
}
|
||||
|
||||
private String toReadable(String string)
|
||||
{
|
||||
private String toReadable(String string) {
|
||||
StringBuilder builder = new StringBuilder();
|
||||
|
||||
for (String s : string.split("_"))
|
||||
{
|
||||
for (String s : string.split("_")) {
|
||||
builder.append(s.substring(0, 1)).append(s.substring(1).toLowerCase());
|
||||
}
|
||||
|
||||
return builder.toString();
|
||||
}
|
||||
|
||||
public DisguiseListener getListener()
|
||||
{
|
||||
public DisguiseListener getListener() {
|
||||
return listener;
|
||||
}
|
||||
|
||||
@ -427,8 +379,7 @@ public class LibsDisguises extends JavaPlugin
|
||||
*
|
||||
* @return The instance of this plugin
|
||||
*/
|
||||
public static LibsDisguises getInstance()
|
||||
{
|
||||
public static LibsDisguises getInstance() {
|
||||
return instance;
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -23,22 +23,18 @@ import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.RabbitType;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||
|
||||
public class HelpDisguiseCommand extends BaseDisguiseCommand
|
||||
{
|
||||
public class HelpDisguiseCommand extends BaseDisguiseCommand {
|
||||
|
||||
private class EnumHelp
|
||||
{
|
||||
private class EnumHelp {
|
||||
|
||||
private String enumDescription;
|
||||
private String enumName;
|
||||
private String[] enums;
|
||||
private String readableEnum;
|
||||
|
||||
public EnumHelp(String enumName, String enumReadable, String enumDescription, Enum[] enums)
|
||||
{
|
||||
public EnumHelp(String enumName, String enumReadable, String enumDescription, Enum[] enums) {
|
||||
String[] strings = new String[enums.length];
|
||||
for (int i = 0; i < strings.length; i++)
|
||||
{
|
||||
for (int i = 0; i < strings.length; i++) {
|
||||
strings[i] = toReadable(enums[i].name());
|
||||
}
|
||||
this.enumName = enumName;
|
||||
@ -47,95 +43,84 @@ public class HelpDisguiseCommand extends BaseDisguiseCommand
|
||||
this.readableEnum = enumReadable;
|
||||
}
|
||||
|
||||
public EnumHelp(String enumName, String enumReadable, String enumDescription, String[] enums)
|
||||
{
|
||||
public EnumHelp(String enumName, String enumReadable, String enumDescription, String[] enums) {
|
||||
this.enumName = enumName;
|
||||
this.enumDescription = enumDescription;
|
||||
this.enums = enums;
|
||||
this.readableEnum = enumReadable;
|
||||
}
|
||||
|
||||
public String getEnumDescription()
|
||||
{
|
||||
public String getEnumDescription() {
|
||||
return enumDescription;
|
||||
}
|
||||
|
||||
public String getEnumName()
|
||||
{
|
||||
public String getEnumName() {
|
||||
return enumName;
|
||||
}
|
||||
|
||||
public String[] getEnums()
|
||||
{
|
||||
public String[] getEnums() {
|
||||
return enums;
|
||||
}
|
||||
|
||||
public String getReadableEnum()
|
||||
{
|
||||
public String getReadableEnum() {
|
||||
return readableEnum;
|
||||
}
|
||||
}
|
||||
|
||||
private ArrayList<EnumHelp> enumHelp = new ArrayList<>();
|
||||
|
||||
public HelpDisguiseCommand()
|
||||
{
|
||||
try
|
||||
{
|
||||
public HelpDisguiseCommand() {
|
||||
try {
|
||||
enumHelp.add(new EnumHelp("AnimalColor", "Animal colors", ChatColor.RED + "/disguisehelp AnimalColors "
|
||||
+ ChatColor.GREEN + "- View all the colors you can use for a animal color", AnimalColor.values()));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
try
|
||||
{
|
||||
try {
|
||||
enumHelp.add(new EnumHelp("Art", "Arts",
|
||||
ChatColor.RED + "/disguisehelp Art " + ChatColor.GREEN
|
||||
+ "- View all the painting arts you can use on a painting disguise",
|
||||
(Enum[]) Class.forName("org.bukkit.Art").getEnumConstants()));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
catch (Exception ex) {
|
||||
}
|
||||
try
|
||||
{
|
||||
enumHelp.add(new EnumHelp("HorseColor", "Horse colors",
|
||||
try {
|
||||
enumHelp.add(new EnumHelp("LlamaColors", "Llama Colors",
|
||||
ChatColor.RED + "/disguisehelp LlamaColors " + ChatColor.GREEN
|
||||
+ "- View all the colors you can use for a llama color",
|
||||
(Enum[]) Class.forName("org.bukkit.entity.Llama$Color").getEnumConstants()));
|
||||
}
|
||||
catch (Exception ex) {
|
||||
}
|
||||
try {
|
||||
enumHelp.add(new EnumHelp("HorseColors", "Horse colors",
|
||||
ChatColor.RED + "/disguisehelp HorseColors " + ChatColor.GREEN
|
||||
+ "- View all the colors you can use for a horses color",
|
||||
(Enum[]) Class.forName("org.bukkit.entity.Horse$Color").getEnumConstants()));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
catch (Exception ex) {
|
||||
}
|
||||
try
|
||||
{
|
||||
enumHelp.add(new EnumHelp("HorseStyle", "Horse styles",
|
||||
try {
|
||||
enumHelp.add(new EnumHelp("HorseStyles", "Horse styles",
|
||||
ChatColor.RED + "/disguisehelp HorseStyles " + ChatColor.GREEN
|
||||
+ "- View all the styles you can use for a horses style",
|
||||
(Enum[]) Class.forName("org.bukkit.entity.Horse$Style").getEnumConstants()));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
catch (Exception ex) {
|
||||
}
|
||||
try
|
||||
{
|
||||
enumHelp.add(new EnumHelp("OcelotType", "Ocelot types",
|
||||
try {
|
||||
enumHelp.add(new EnumHelp("OcelotTypes", "Ocelot types",
|
||||
ChatColor.RED + "/disguisehelp OcelotTypes " + ChatColor.GREEN
|
||||
+ "- View all the ocelot types you can use for ocelots",
|
||||
(Enum[]) Class.forName("org.bukkit.entity.Ocelot$Type").getEnumConstants()));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
catch (Exception ex) {
|
||||
}
|
||||
try
|
||||
{
|
||||
try {
|
||||
ArrayList<String> enumReturns = new ArrayList<>();
|
||||
for (PotionEffectType potionType : PotionEffectType.values())
|
||||
{
|
||||
if (potionType != null)
|
||||
{
|
||||
for (PotionEffectType potionType : PotionEffectType.values()) {
|
||||
if (potionType != null) {
|
||||
enumReturns.add(toReadable(potionType.getName()) + ChatColor.RED + "(" + ChatColor.GREEN + potionType.getId()
|
||||
+ ChatColor.RED + ")");
|
||||
}
|
||||
@ -144,19 +129,16 @@ public class HelpDisguiseCommand extends BaseDisguiseCommand
|
||||
ChatColor.RED + "/disguisehelp PotionEffect " + ChatColor.GREEN + "- View all the potion effects you can set",
|
||||
enumReturns.toArray(new String[enumReturns.size()])));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
try
|
||||
{
|
||||
try {
|
||||
enumHelp.add(new EnumHelp("Profession", "Villager professions",
|
||||
ChatColor.RED + "/disguisehelp Professions " + ChatColor.GREEN
|
||||
+ "- View all the professions you can set on a villager",
|
||||
(Enum[]) Class.forName("org.bukkit.entity.Villager$Profession").getEnumConstants()));
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
catch (Exception ex) {
|
||||
}
|
||||
enumHelp.add(new EnumHelp("Direction", "Directions",
|
||||
ChatColor.RED + "/disguisehelp Directions " + ChatColor.GREEN
|
||||
@ -168,56 +150,43 @@ public class HelpDisguiseCommand extends BaseDisguiseCommand
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args)
|
||||
{
|
||||
for (String node : new String[]
|
||||
{
|
||||
"disguise", "disguiseradius", "disguiseentity", "disguiseplayer"
|
||||
})
|
||||
{
|
||||
public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
|
||||
for (String node : new String[] {
|
||||
"disguise", "disguiseradius", "disguiseentity", "disguiseplayer"
|
||||
}) {
|
||||
HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> permMap = getPermissions(sender,
|
||||
"libsdisguises." + node + ".");
|
||||
if (!permMap.isEmpty())
|
||||
{
|
||||
if (args.length == 0)
|
||||
{
|
||||
if (!permMap.isEmpty()) {
|
||||
if (args.length == 0) {
|
||||
sendCommandUsage(sender, null);
|
||||
return true;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
EnumHelp help = null;
|
||||
for (EnumHelp s : enumHelp)
|
||||
{
|
||||
if (args[0].equalsIgnoreCase(s.getEnumName()) || args[0].equalsIgnoreCase(s.getEnumName() + "s"))
|
||||
{
|
||||
for (EnumHelp s : enumHelp) {
|
||||
if (args[0].equalsIgnoreCase(s.getEnumName()) || args[0].equalsIgnoreCase(s.getEnumName() + "s")) {
|
||||
help = s;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (help != null)
|
||||
{
|
||||
if (help != null) {
|
||||
sender.sendMessage(ChatColor.RED + help.getReadableEnum() + ": " + ChatColor.GREEN
|
||||
+ StringUtils.join(help.getEnums(), ChatColor.RED + ", " + ChatColor.GREEN));
|
||||
return true;
|
||||
}
|
||||
DisguiseType type = null;
|
||||
for (DisguiseType disguiseType : DisguiseType.values())
|
||||
{
|
||||
for (DisguiseType disguiseType : DisguiseType.values()) {
|
||||
if (args[0].equalsIgnoreCase(disguiseType.name())
|
||||
|| disguiseType.name().replace("_", "").equalsIgnoreCase(args[0]))
|
||||
{
|
||||
|| disguiseType.name().replace("_", "").equalsIgnoreCase(args[0])) {
|
||||
type = disguiseType;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (type == null)
|
||||
{
|
||||
if (type == null) {
|
||||
sender.sendMessage(ChatColor.RED + "Cannot find the disguise " + args[0]);
|
||||
return true;
|
||||
}
|
||||
if (!permMap.containsKey(type))
|
||||
{
|
||||
if (!permMap.containsKey(type)) {
|
||||
sender.sendMessage(ChatColor.RED + "You do not have permission for that disguise!");
|
||||
return true;
|
||||
}
|
||||
@ -225,119 +194,90 @@ public class HelpDisguiseCommand extends BaseDisguiseCommand
|
||||
HashMap<String, ChatColor> map = new HashMap<>();
|
||||
Class watcher = type.getWatcherClass();
|
||||
int ignored = 0;
|
||||
try
|
||||
{
|
||||
for (Method method : this.getDisguiseWatcherMethods(watcher))
|
||||
{
|
||||
try {
|
||||
for (Method method : this.getDisguiseWatcherMethods(watcher)) {
|
||||
if (!method.getName().startsWith("get") && method.getParameterTypes().length == 1
|
||||
&& method.getAnnotation(Deprecated.class) == null)
|
||||
{
|
||||
if (args.length < 2 || !args[1].equalsIgnoreCase("show"))
|
||||
{
|
||||
&& method.getAnnotation(Deprecated.class) == null) {
|
||||
if (args.length < 2 || !args[1].equalsIgnoreCase("show")) {
|
||||
boolean allowed = false;
|
||||
for (ArrayList<String> key : permMap.get(type).keySet())
|
||||
{
|
||||
if (permMap.get(type).get(key))
|
||||
{
|
||||
if (key.contains("*") || key.contains(method.getName().toLowerCase()))
|
||||
{
|
||||
for (ArrayList<String> key : permMap.get(type).keySet()) {
|
||||
if (permMap.get(type).get(key)) {
|
||||
if (key.contains("*") || key.contains(method.getName().toLowerCase())) {
|
||||
allowed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
else if (!key.contains(method.getName().toLowerCase()))
|
||||
{
|
||||
else if (!key.contains(method.getName().toLowerCase())) {
|
||||
allowed = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
if (!allowed)
|
||||
{
|
||||
if (!allowed) {
|
||||
ignored++;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
Class c = method.getParameterTypes()[0];
|
||||
String valueType = null;
|
||||
if (c == String.class)
|
||||
{
|
||||
if (c == String.class) {
|
||||
valueType = "String";
|
||||
}
|
||||
else if (boolean.class == c)
|
||||
{
|
||||
else if (boolean.class == c) {
|
||||
valueType = "True/False";
|
||||
}
|
||||
else if (int.class == c)
|
||||
{
|
||||
else if (int.class == c) {
|
||||
valueType = "Number";
|
||||
}
|
||||
else if (float.class == c || double.class == c)
|
||||
{
|
||||
else if (float.class == c || double.class == c) {
|
||||
valueType = "Decimal";
|
||||
}
|
||||
else if (AnimalColor.class == c)
|
||||
{
|
||||
else if (AnimalColor.class == c) {
|
||||
valueType = "Color";
|
||||
}
|
||||
else if (ItemStack.class == c)
|
||||
{
|
||||
else if (ItemStack.class == c) {
|
||||
valueType = "Item (id:damage)";
|
||||
}
|
||||
else if (ItemStack[].class == c)
|
||||
{
|
||||
else if (ItemStack[].class == c) {
|
||||
valueType = "4 items (id:damage,id,...)";
|
||||
}
|
||||
else if (c.getSimpleName().equals("Style"))
|
||||
{
|
||||
else if (c.getSimpleName().equals("Style")) {
|
||||
valueType = "Horse Style";
|
||||
}
|
||||
else if (c.getSimpleName().equals("Color"))
|
||||
{
|
||||
else if (c.getSimpleName().equals("Color")) {
|
||||
valueType = "Horse Color";
|
||||
}
|
||||
else if (c.getSimpleName().equals("Type"))
|
||||
{
|
||||
else if (c.getSimpleName().equals("Type")) {
|
||||
valueType = "Ocelot type";
|
||||
}
|
||||
else if (c.getSimpleName().equals("Profession"))
|
||||
{
|
||||
else if (c.getSimpleName().equals("Profession")) {
|
||||
valueType = "Villager Profession";
|
||||
}
|
||||
else if (PotionEffectType.class == c)
|
||||
{
|
||||
else if (PotionEffectType.class == c) {
|
||||
valueType = "Potion effect";
|
||||
}
|
||||
else if (c == int[].class)
|
||||
{
|
||||
else if (c == int[].class) {
|
||||
valueType = "number,number,number...";
|
||||
}
|
||||
else if (c == BlockFace.class)
|
||||
{
|
||||
else if (c == BlockFace.class) {
|
||||
valueType = "direction";
|
||||
}
|
||||
else if (c == RabbitType.class)
|
||||
{
|
||||
else if (c == RabbitType.class) {
|
||||
valueType = "rabbit type";
|
||||
}
|
||||
else if (c == BlockPosition.class)
|
||||
{
|
||||
else if (c == BlockPosition.class) {
|
||||
valueType = "three numbers";
|
||||
}
|
||||
else if (c == WrappedGameProfile.class)
|
||||
{
|
||||
else if (c == WrappedGameProfile.class) {
|
||||
valueType = "gameprofile";
|
||||
}
|
||||
|
||||
if (valueType != null)
|
||||
{
|
||||
if (valueType != null) {
|
||||
ChatColor methodColor = ChatColor.YELLOW;
|
||||
Class<?> declaring = method.getDeclaringClass();
|
||||
if (declaring == LivingWatcher.class)
|
||||
{
|
||||
if (declaring == LivingWatcher.class) {
|
||||
methodColor = ChatColor.AQUA;
|
||||
}
|
||||
else if (!(FlagWatcher.class.isAssignableFrom(declaring)) || declaring == FlagWatcher.class)
|
||||
{
|
||||
else if (!(FlagWatcher.class.isAssignableFrom(declaring)) || declaring == FlagWatcher.class) {
|
||||
methodColor = ChatColor.GRAY;
|
||||
}
|
||||
String str = method.getName() + ChatColor.DARK_RED + "(" + ChatColor.GREEN + valueType
|
||||
@ -348,23 +288,19 @@ public class HelpDisguiseCommand extends BaseDisguiseCommand
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
catch (Exception ex) {
|
||||
ex.printStackTrace();
|
||||
}
|
||||
Collections.sort(methods, String.CASE_INSENSITIVE_ORDER);
|
||||
for (int i = 0; i < methods.size(); i++)
|
||||
{
|
||||
for (int i = 0; i < methods.size(); i++) {
|
||||
methods.set(i, map.get(methods.get(i)) + methods.get(i));
|
||||
}
|
||||
if (methods.isEmpty())
|
||||
{
|
||||
if (methods.isEmpty()) {
|
||||
methods.add(ChatColor.RED + "No options with permission to use");
|
||||
}
|
||||
sender.sendMessage(ChatColor.DARK_RED + type.toReadable() + " options: "
|
||||
+ StringUtils.join(methods, ChatColor.DARK_RED + ", "));
|
||||
if (ignored > 0)
|
||||
{
|
||||
if (ignored > 0) {
|
||||
sender.sendMessage(ChatColor.RED + "Ignored " + ignored
|
||||
+ " options you do not have permission to view. Add 'show' to view unusable options.");
|
||||
}
|
||||
@ -380,21 +316,17 @@ public class HelpDisguiseCommand extends BaseDisguiseCommand
|
||||
* Send the player the information
|
||||
*/
|
||||
@Override
|
||||
protected void sendCommandUsage(CommandSender sender, HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map)
|
||||
{
|
||||
protected void sendCommandUsage(CommandSender sender, HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map) {
|
||||
sender.sendMessage(ChatColor.RED + "/disguisehelp <DisguiseType> " + ChatColor.GREEN
|
||||
+ "- View the options you can set on a disguise. Add 'show' to reveal the options you don't have permission to use");
|
||||
for (EnumHelp s : enumHelp)
|
||||
{
|
||||
for (EnumHelp s : enumHelp) {
|
||||
sender.sendMessage(s.getEnumDescription());
|
||||
}
|
||||
}
|
||||
|
||||
public String toReadable(String string)
|
||||
{
|
||||
public String toReadable(String string) {
|
||||
String[] split = string.split("_");
|
||||
for (int i = 0; i < split.length; i++)
|
||||
{
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
split[i] = split[i].substring(0, 1) + split[i].substring(1).toLowerCase();
|
||||
}
|
||||
return StringUtils.join(split, "_");
|
||||
|
@ -11,7 +11,6 @@ import java.util.UUID;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Location;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Horse.Variant;
|
||||
import org.bukkit.entity.LivingEntity;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.bukkit.entity.Skeleton.SkeletonType;
|
||||
@ -31,7 +30,6 @@ import me.libraryaddict.disguise.disguisetypes.TargetedDisguise.TargetType;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.AgeableWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.BatWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.GuardianWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.HorseWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.SkeletonWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher;
|
||||
import me.libraryaddict.disguise.events.DisguiseEvent;
|
||||
@ -40,8 +38,7 @@ import me.libraryaddict.disguise.utilities.DisguiseUtilities;
|
||||
import me.libraryaddict.disguise.utilities.PacketsManager;
|
||||
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
||||
|
||||
public abstract class Disguise
|
||||
{
|
||||
public abstract class Disguise {
|
||||
private boolean disguiseInUse;
|
||||
private DisguiseType disguiseType;
|
||||
private Entity entity;
|
||||
@ -71,15 +68,12 @@ public abstract class Disguise
|
||||
* @param newType
|
||||
* The disguise
|
||||
*/
|
||||
protected void createDisguise(DisguiseType newType)
|
||||
{
|
||||
if (getWatcher() != null)
|
||||
{
|
||||
protected void createDisguise(DisguiseType newType) {
|
||||
if (getWatcher() != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (newType.getEntityType() == null)
|
||||
{
|
||||
if (newType.getEntityType() == null) {
|
||||
throw new RuntimeException("DisguiseType " + newType
|
||||
+ " was used in a futile attempt to construct a disguise, but this Minecraft version does not have that entity");
|
||||
}
|
||||
@ -90,45 +84,36 @@ public abstract class Disguise
|
||||
|
||||
boolean isAdult = true;
|
||||
|
||||
if (isMobDisguise())
|
||||
{
|
||||
if (isMobDisguise()) {
|
||||
isAdult = ((MobDisguise) this).isAdult();
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
// Construct the FlagWatcher from the stored class
|
||||
setWatcher((FlagWatcher) getType().getWatcherClass().getConstructor(Disguise.class).newInstance(this));
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
|
||||
// Set the disguise if its a baby or not
|
||||
if (!isAdult)
|
||||
{
|
||||
if (getWatcher() instanceof AgeableWatcher)
|
||||
{
|
||||
if (!isAdult) {
|
||||
if (getWatcher() instanceof AgeableWatcher) {
|
||||
((AgeableWatcher) getWatcher()).setBaby(true);
|
||||
}
|
||||
else if (getWatcher() instanceof ZombieWatcher)
|
||||
{
|
||||
else if (getWatcher() instanceof ZombieWatcher) {
|
||||
((ZombieWatcher) getWatcher()).setBaby(true);
|
||||
}
|
||||
}
|
||||
|
||||
// If the disguise type is a wither, set the flagwatcher value for the skeleton to a wither skeleton
|
||||
if (getType() == DisguiseType.WITHER_SKELETON)
|
||||
{
|
||||
if (getType() == DisguiseType.WITHER_SKELETON) {
|
||||
((SkeletonWatcher) getWatcher()).setType(SkeletonType.WITHER);
|
||||
}
|
||||
else if (getType() == DisguiseType.STRAY)
|
||||
{
|
||||
else if (getType() == DisguiseType.STRAY) {
|
||||
((SkeletonWatcher) getWatcher()).setType(SkeletonType.STRAY);
|
||||
} // Else if its a zombie, but the disguise type is a zombie villager. Set the value.
|
||||
else if (getType() == DisguiseType.ZOMBIE_VILLAGER)
|
||||
{
|
||||
else if (getType() == DisguiseType.ZOMBIE_VILLAGER) {
|
||||
Profession profession = null;
|
||||
|
||||
while (profession == null || profession == Profession.NORMAL || profession == Profession.HUSK)
|
||||
@ -136,31 +121,16 @@ public abstract class Disguise
|
||||
|
||||
((ZombieWatcher) getWatcher()).setProfession(profession);
|
||||
}
|
||||
else if (getType() == DisguiseType.HUSK)
|
||||
{
|
||||
else if (getType() == DisguiseType.HUSK) {
|
||||
((ZombieWatcher) getWatcher()).setProfession(Profession.HUSK);
|
||||
}
|
||||
else if (getType() == DisguiseType.ELDER_GUARDIAN)
|
||||
{
|
||||
else if (getType() == DisguiseType.ELDER_GUARDIAN) {
|
||||
((GuardianWatcher) getWatcher()).setElder(true);
|
||||
} // Else if its a horse. Set the horse watcher type
|
||||
else if (getWatcher() instanceof HorseWatcher)
|
||||
{
|
||||
try
|
||||
{
|
||||
Variant horseType = Variant.valueOf(getType().name());
|
||||
((HorseWatcher) getWatcher()).setVariant(horseType);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
// Ok.. So it aint a horse
|
||||
}
|
||||
}
|
||||
|
||||
final boolean alwaysSendVelocity;
|
||||
|
||||
switch (getType())
|
||||
{
|
||||
switch (getType()) {
|
||||
case EGG:
|
||||
case ENDER_PEARL:
|
||||
case BAT:
|
||||
@ -181,8 +151,7 @@ public abstract class Disguise
|
||||
|
||||
double velocitySpeed = 0.0005;
|
||||
|
||||
switch (getType())
|
||||
{
|
||||
switch (getType()) {
|
||||
case FIREWORK:
|
||||
velocitySpeed = -0.040;
|
||||
break;
|
||||
@ -232,32 +201,26 @@ public abstract class Disguise
|
||||
final TargetedDisguise disguise = (TargetedDisguise) this;
|
||||
|
||||
// A scheduler to clean up any unused disguises.
|
||||
velocityRunnable = new Runnable()
|
||||
{
|
||||
velocityRunnable = new Runnable() {
|
||||
private int blockX, blockY, blockZ, facing;
|
||||
private int deadTicks = 0;
|
||||
private int refreshDisguise = 0;
|
||||
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
public void run() {
|
||||
// If entity is no longer valid. Remove it.
|
||||
if (!getEntity().isValid())
|
||||
{
|
||||
if (!getEntity().isValid()) {
|
||||
// If it has been dead for 30+ ticks
|
||||
// This is to ensure that this disguise isn't removed while clients think its the real entity
|
||||
// The delay is because if it sends the destroy entity packets straight away, then it means no death animation
|
||||
// This is probably still a problem for wither and enderdragon deaths.
|
||||
if (deadTicks++ > (getType() == DisguiseType.ENDER_DRAGON ? 200 : 20))
|
||||
{
|
||||
if (deadTicks++ > (getType() == DisguiseType.ENDER_DRAGON ? 200 : 20)) {
|
||||
deadTicks = 0;
|
||||
|
||||
if (isRemoveDisguiseOnDeath())
|
||||
{
|
||||
if (isRemoveDisguiseOnDeath()) {
|
||||
removeDisguise();
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
entity = null;
|
||||
watcher = getWatcher().clone(disguise);
|
||||
task.cancel();
|
||||
@ -265,32 +228,27 @@ public abstract class Disguise
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
deadTicks = 0;
|
||||
|
||||
// If the disguise type is tnt, we need to resend the entity packet else it will turn invisible
|
||||
if (getType() == DisguiseType.FIREWORK)
|
||||
{
|
||||
if (getType() == DisguiseType.FIREWORK) {
|
||||
refreshDisguise++;
|
||||
|
||||
if (refreshDisguise % 40 == 0)
|
||||
{
|
||||
if (refreshDisguise % 40 == 0) {
|
||||
refreshDisguise = 0;
|
||||
|
||||
DisguiseUtilities.refreshTrackers(disguise);
|
||||
}
|
||||
}
|
||||
|
||||
if (getType() == DisguiseType.ITEM_FRAME)
|
||||
{
|
||||
if (getType() == DisguiseType.ITEM_FRAME) {
|
||||
Location loc = getEntity().getLocation();
|
||||
|
||||
int newFacing = (((int) loc.getYaw() + 720 + 45) / 90) % 4;
|
||||
|
||||
if (loc.getBlockX() != blockX || loc.getBlockY() != blockY || loc.getBlockZ() != blockZ
|
||||
|| newFacing != facing)
|
||||
{
|
||||
|| newFacing != facing) {
|
||||
blockX = loc.getBlockX();
|
||||
blockY = loc.getBlockY();
|
||||
blockZ = loc.getBlockZ();
|
||||
@ -300,37 +258,31 @@ public abstract class Disguise
|
||||
}
|
||||
}
|
||||
|
||||
if (isModifyBoundingBox())
|
||||
{
|
||||
if (isModifyBoundingBox()) {
|
||||
DisguiseUtilities.doBoundingBox(disguise);
|
||||
}
|
||||
|
||||
if (getType() == DisguiseType.BAT && !((BatWatcher) getWatcher()).isHanging())
|
||||
{
|
||||
if (getType() == DisguiseType.BAT && !((BatWatcher) getWatcher()).isHanging()) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If the vectorY isn't 0. Cos if it is. Then it doesn't want to send any vectors.
|
||||
// If this disguise has velocity sending enabled and the entity is flying.
|
||||
if (isVelocitySent() && vectorY != 0 && (alwaysSendVelocity || !getEntity().isOnGround()))
|
||||
{
|
||||
if (isVelocitySent() && vectorY != 0 && (alwaysSendVelocity || !getEntity().isOnGround())) {
|
||||
Vector vector = getEntity().getVelocity();
|
||||
|
||||
// If the entity doesn't have velocity changes already - You know. I really can't wrap my head about the
|
||||
// if statement.
|
||||
// But it doesn't seem to do anything wrong..
|
||||
if (vector.getY() != 0 && !(vector.getY() < 0 && alwaysSendVelocity && getEntity().isOnGround()))
|
||||
{
|
||||
if (vector.getY() != 0 && !(vector.getY() < 0 && alwaysSendVelocity && getEntity().isOnGround())) {
|
||||
return;
|
||||
}
|
||||
|
||||
// If disguise isn't a experience orb, or the entity isn't standing on the ground
|
||||
if (getType() != DisguiseType.EXPERIENCE_ORB || !getEntity().isOnGround())
|
||||
{
|
||||
if (getType() != DisguiseType.EXPERIENCE_ORB || !getEntity().isOnGround()) {
|
||||
PacketContainer lookPacket = null;
|
||||
|
||||
if (getType() == DisguiseType.WITHER_SKULL && DisguiseConfig.isWitherSkullPacketsEnabled())
|
||||
{
|
||||
if (getType() == DisguiseType.WITHER_SKULL && DisguiseConfig.isWitherSkullPacketsEnabled()) {
|
||||
lookPacket = new PacketContainer(Server.ENTITY_LOOK);
|
||||
|
||||
StructureModifier<Object> mods = lookPacket.getModifier();
|
||||
@ -342,26 +294,22 @@ public abstract class Disguise
|
||||
mods.write(5, PacketsManager.getPitch(getType(), DisguiseType.getType(getEntity().getType()),
|
||||
(byte) Math.floor(loc.getPitch() * 256.0F / 360.0F)));
|
||||
|
||||
if (isSelfDisguiseVisible() && getEntity() instanceof Player)
|
||||
{
|
||||
if (isSelfDisguiseVisible() && getEntity() instanceof Player) {
|
||||
PacketContainer selfLookPacket = lookPacket.shallowClone();
|
||||
|
||||
selfLookPacket.getIntegers().write(0, DisguiseAPI.getSelfDisguiseId());
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket((Player) getEntity(),
|
||||
selfLookPacket, false);
|
||||
}
|
||||
catch (InvocationTargetException e)
|
||||
{
|
||||
catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
PacketContainer velocityPacket = new PacketContainer(Server.ENTITY_VELOCITY);
|
||||
|
||||
StructureModifier<Integer> mods = velocityPacket.getIntegers();
|
||||
@ -369,26 +317,21 @@ public abstract class Disguise
|
||||
mods.write(1, (int) (vector.getX() * 8000));
|
||||
mods.write(3, (int) (vector.getZ() * 8000));
|
||||
|
||||
for (Player player : DisguiseUtilities.getPerverts(disguise))
|
||||
{
|
||||
if (getEntity() == player)
|
||||
{
|
||||
if (!isSelfDisguiseVisible())
|
||||
{
|
||||
for (Player player : DisguiseUtilities.getPerverts(disguise)) {
|
||||
if (getEntity() == player) {
|
||||
if (!isSelfDisguiseVisible()) {
|
||||
continue;
|
||||
}
|
||||
|
||||
mods.write(0, DisguiseAPI.getSelfDisguiseId());
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
mods.write(0, getEntity().getEntityId());
|
||||
}
|
||||
|
||||
mods.write(2, (int) (8000D * (vectorY * ReflectionManager.getPing(player)) * 0.069D));
|
||||
|
||||
if (lookPacket != null && player != getEntity())
|
||||
{
|
||||
if (lookPacket != null && player != getEntity()) {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, lookPacket, false);
|
||||
}
|
||||
|
||||
@ -396,47 +339,38 @@ public abstract class Disguise
|
||||
false);
|
||||
}
|
||||
}
|
||||
catch (Exception e)
|
||||
{
|
||||
catch (Exception e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
// If we need to send a packet to update the exp position as it likes to gravitate client sided to
|
||||
// players.
|
||||
}
|
||||
if (getType() == DisguiseType.EXPERIENCE_ORB)
|
||||
{
|
||||
if (getType() == DisguiseType.EXPERIENCE_ORB) {
|
||||
PacketContainer packet = new PacketContainer(Server.REL_ENTITY_MOVE);
|
||||
|
||||
packet.getIntegers().write(0, getEntity().getEntityId());
|
||||
try
|
||||
{
|
||||
for (Player player : DisguiseUtilities.getPerverts(disguise))
|
||||
{
|
||||
if (getEntity() != player)
|
||||
{
|
||||
try {
|
||||
for (Player player : DisguiseUtilities.getPerverts(disguise)) {
|
||||
if (getEntity() != player) {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet, false);
|
||||
}
|
||||
else if (isSelfDisguiseVisible())
|
||||
{
|
||||
else if (isSelfDisguiseVisible()) {
|
||||
PacketContainer selfPacket = packet.shallowClone();
|
||||
|
||||
selfPacket.getModifier().write(0, DisguiseAPI.getSelfDisguiseId());
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket((Player) getEntity(), selfPacket,
|
||||
false);
|
||||
}
|
||||
catch (InvocationTargetException e)
|
||||
{
|
||||
catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
catch (InvocationTargetException e)
|
||||
{
|
||||
catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -450,8 +384,7 @@ public abstract class Disguise
|
||||
*
|
||||
* @return entity
|
||||
*/
|
||||
public Entity getEntity()
|
||||
{
|
||||
public Entity getEntity() {
|
||||
return entity;
|
||||
}
|
||||
|
||||
@ -460,8 +393,7 @@ public abstract class Disguise
|
||||
*
|
||||
* @return disguiseType
|
||||
*/
|
||||
public DisguiseType getType()
|
||||
{
|
||||
public DisguiseType getType() {
|
||||
return disguiseType;
|
||||
}
|
||||
|
||||
@ -470,8 +402,7 @@ public abstract class Disguise
|
||||
*
|
||||
* @return flagWatcher
|
||||
*/
|
||||
public FlagWatcher getWatcher()
|
||||
{
|
||||
public FlagWatcher getWatcher() {
|
||||
return watcher;
|
||||
}
|
||||
|
||||
@ -481,68 +412,56 @@ public abstract class Disguise
|
||||
*
|
||||
* @return isDisguiseInUse
|
||||
*/
|
||||
public boolean isDisguiseInUse()
|
||||
{
|
||||
public boolean isDisguiseInUse() {
|
||||
return disguiseInUse;
|
||||
}
|
||||
|
||||
public boolean isHidingArmorFromSelf()
|
||||
{
|
||||
public boolean isHidingArmorFromSelf() {
|
||||
return hideArmorFromSelf;
|
||||
}
|
||||
|
||||
public boolean isHidingHeldItemFromSelf()
|
||||
{
|
||||
public boolean isHidingHeldItemFromSelf() {
|
||||
return hideHeldItemFromSelf;
|
||||
}
|
||||
|
||||
public boolean isKeepDisguiseOnEntityDespawn()
|
||||
{
|
||||
public boolean isKeepDisguiseOnEntityDespawn() {
|
||||
return this.keepDisguiseEntityDespawn;
|
||||
}
|
||||
|
||||
public boolean isKeepDisguiseOnPlayerDeath()
|
||||
{
|
||||
public boolean isKeepDisguiseOnPlayerDeath() {
|
||||
return this.keepDisguisePlayerDeath;
|
||||
}
|
||||
|
||||
public boolean isKeepDisguiseOnPlayerLogout()
|
||||
{
|
||||
public boolean isKeepDisguiseOnPlayerLogout() {
|
||||
return this.keepDisguisePlayerLogout;
|
||||
}
|
||||
|
||||
public boolean isMiscDisguise()
|
||||
{
|
||||
public boolean isMiscDisguise() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isMobDisguise()
|
||||
{
|
||||
public boolean isMobDisguise() {
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean isModifyBoundingBox()
|
||||
{
|
||||
public boolean isModifyBoundingBox() {
|
||||
return modifyBoundingBox;
|
||||
}
|
||||
|
||||
public boolean isPlayerDisguise()
|
||||
{
|
||||
public boolean isPlayerDisguise() {
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* Internal use
|
||||
*/
|
||||
public boolean isRemoveDisguiseOnDeath()
|
||||
{
|
||||
public boolean isRemoveDisguiseOnDeath() {
|
||||
return getEntity() == null || (getEntity() instanceof Player
|
||||
? (!((Player) getEntity()).isOnline() ? !isKeepDisguiseOnPlayerLogout() : !isKeepDisguiseOnPlayerDeath())
|
||||
: (!isKeepDisguiseOnEntityDespawn() || getEntity().isDead()));
|
||||
}
|
||||
|
||||
public boolean isSelfDisguiseSoundsReplaced()
|
||||
{
|
||||
public boolean isSelfDisguiseSoundsReplaced() {
|
||||
return hearSelfDisguise;
|
||||
}
|
||||
|
||||
@ -551,18 +470,15 @@ public abstract class Disguise
|
||||
*
|
||||
* @return viewSelfDisguise
|
||||
*/
|
||||
public boolean isSelfDisguiseVisible()
|
||||
{
|
||||
public boolean isSelfDisguiseVisible() {
|
||||
return viewSelfDisguise;
|
||||
}
|
||||
|
||||
public boolean isSoundsReplaced()
|
||||
{
|
||||
public boolean isSoundsReplaced() {
|
||||
return replaceSounds;
|
||||
}
|
||||
|
||||
public boolean isVelocitySent()
|
||||
{
|
||||
public boolean isVelocitySent() {
|
||||
return velocitySent;
|
||||
}
|
||||
|
||||
@ -571,8 +487,7 @@ public abstract class Disguise
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public boolean isShowName()
|
||||
{
|
||||
public boolean isShowName() {
|
||||
return showName;
|
||||
}
|
||||
|
||||
@ -581,20 +496,16 @@ public abstract class Disguise
|
||||
*
|
||||
* @return removeDiguise
|
||||
*/
|
||||
public boolean removeDisguise()
|
||||
{
|
||||
if (disguiseInUse)
|
||||
{
|
||||
public boolean removeDisguise() {
|
||||
if (disguiseInUse) {
|
||||
UndisguiseEvent event = new UndisguiseEvent(entity, this);
|
||||
|
||||
Bukkit.getPluginManager().callEvent(event);
|
||||
|
||||
if (!event.isCancelled())
|
||||
{
|
||||
if (!event.isCancelled()) {
|
||||
disguiseInUse = false;
|
||||
|
||||
if (task != null)
|
||||
{
|
||||
if (task != null) {
|
||||
task.cancel();
|
||||
task = null;
|
||||
}
|
||||
@ -602,58 +513,45 @@ public abstract class Disguise
|
||||
HashMap<UUID, HashSet<TargetedDisguise>> disguises = DisguiseUtilities.getDisguises();
|
||||
|
||||
// If this disguise has a entity set
|
||||
if (getEntity() != null)
|
||||
{
|
||||
if (getEntity() != null) {
|
||||
// If this disguise is active
|
||||
// Remove the disguise from the current disguises.
|
||||
if (DisguiseUtilities.removeDisguise((TargetedDisguise) this))
|
||||
{
|
||||
if (getEntity() instanceof Player)
|
||||
{
|
||||
if (DisguiseUtilities.removeDisguise((TargetedDisguise) this)) {
|
||||
if (getEntity() instanceof Player) {
|
||||
DisguiseUtilities.removeSelfDisguise((Player) getEntity());
|
||||
}
|
||||
|
||||
// Better refresh the entity to undisguise it
|
||||
if (getEntity().isValid())
|
||||
{
|
||||
if (getEntity().isValid()) {
|
||||
DisguiseUtilities.refreshTrackers((TargetedDisguise) this);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
DisguiseUtilities.destroyEntity((TargetedDisguise) this);
|
||||
}
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
// Loop through the disguises because it could be used with a unknown entity id.
|
||||
HashMap<Integer, HashSet<TargetedDisguise>> future = DisguiseUtilities.getFutureDisguises();
|
||||
|
||||
Iterator<Integer> itel = DisguiseUtilities.getFutureDisguises().keySet().iterator();
|
||||
|
||||
while (itel.hasNext())
|
||||
{
|
||||
while (itel.hasNext()) {
|
||||
int id = itel.next();
|
||||
|
||||
if (future.get(id).remove(this) && future.get(id).isEmpty())
|
||||
{
|
||||
if (future.get(id).remove(this) && future.get(id).isEmpty()) {
|
||||
itel.remove();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (isPlayerDisguise())
|
||||
{
|
||||
if (isPlayerDisguise()) {
|
||||
String name = ((PlayerDisguise) this).getName();
|
||||
|
||||
if (!DisguiseUtilities.getAddedByPlugins().contains(name.toLowerCase()))
|
||||
{
|
||||
for (HashSet<TargetedDisguise> disguise : disguises.values())
|
||||
{
|
||||
for (Disguise d : disguise)
|
||||
{
|
||||
if (d.isPlayerDisguise() && ((PlayerDisguise) d).getName().equals(name))
|
||||
{
|
||||
if (!DisguiseUtilities.getAddedByPlugins().contains(name.toLowerCase())) {
|
||||
for (HashSet<TargetedDisguise> disguise : disguises.values()) {
|
||||
for (Disguise d : disguise) {
|
||||
if (d.isPlayerDisguise() && ((PlayerDisguise) d).getName().equals(name)) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
@ -675,20 +573,16 @@ public abstract class Disguise
|
||||
* @param entity
|
||||
* @return disguise
|
||||
*/
|
||||
public Disguise setEntity(Entity entity)
|
||||
{
|
||||
if (this.getEntity() != null)
|
||||
{
|
||||
if (getEntity() == entity)
|
||||
{
|
||||
public Disguise setEntity(Entity entity) {
|
||||
if (this.getEntity() != null) {
|
||||
if (getEntity() == entity) {
|
||||
return this;
|
||||
}
|
||||
|
||||
throw new RuntimeException("This disguise is already in use! Try .clone()");
|
||||
}
|
||||
|
||||
if (isMiscDisguise() && !DisguiseConfig.isMiscDisguisesForLivingEnabled() && entity instanceof LivingEntity)
|
||||
{
|
||||
if (isMiscDisguise() && !DisguiseConfig.isMiscDisguisesForLivingEnabled() && entity instanceof LivingEntity) {
|
||||
throw new RuntimeException(
|
||||
"Cannot disguise a living entity with a misc disguise. Reenable MiscDisguisesForLiving in the config to do this");
|
||||
}
|
||||
@ -700,79 +594,66 @@ public abstract class Disguise
|
||||
return this;
|
||||
}
|
||||
|
||||
public Disguise setShowName(boolean showName)
|
||||
{
|
||||
public Disguise setShowName(boolean showName) {
|
||||
this.showName = showName;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public Disguise setHearSelfDisguise(boolean hearSelfDisguise)
|
||||
{
|
||||
public Disguise setHearSelfDisguise(boolean hearSelfDisguise) {
|
||||
this.hearSelfDisguise = hearSelfDisguise;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public Disguise setHideArmorFromSelf(boolean hideArmor)
|
||||
{
|
||||
public Disguise setHideArmorFromSelf(boolean hideArmor) {
|
||||
this.hideArmorFromSelf = hideArmor;
|
||||
|
||||
if (getEntity() instanceof Player)
|
||||
{
|
||||
if (getEntity() instanceof Player) {
|
||||
((Player) getEntity()).updateInventory();
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public Disguise setHideHeldItemFromSelf(boolean hideHeldItem)
|
||||
{
|
||||
public Disguise setHideHeldItemFromSelf(boolean hideHeldItem) {
|
||||
this.hideHeldItemFromSelf = hideHeldItem;
|
||||
|
||||
if (getEntity() instanceof Player)
|
||||
{
|
||||
if (getEntity() instanceof Player) {
|
||||
((Player) getEntity()).updateInventory();
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public Disguise setKeepDisguiseOnEntityDespawn(boolean keepDisguise)
|
||||
{
|
||||
public Disguise setKeepDisguiseOnEntityDespawn(boolean keepDisguise) {
|
||||
this.keepDisguiseEntityDespawn = keepDisguise;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public Disguise setKeepDisguiseOnPlayerDeath(boolean keepDisguise)
|
||||
{
|
||||
public Disguise setKeepDisguiseOnPlayerDeath(boolean keepDisguise) {
|
||||
this.keepDisguisePlayerDeath = keepDisguise;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public Disguise setKeepDisguiseOnPlayerLogout(boolean keepDisguise)
|
||||
{
|
||||
public Disguise setKeepDisguiseOnPlayerLogout(boolean keepDisguise) {
|
||||
this.keepDisguisePlayerLogout = keepDisguise;
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public Disguise setModifyBoundingBox(boolean modifyBox)
|
||||
{
|
||||
if (((TargetedDisguise) this).getDisguiseTarget() != TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS)
|
||||
{
|
||||
public Disguise setModifyBoundingBox(boolean modifyBox) {
|
||||
if (((TargetedDisguise) this).getDisguiseTarget() != TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS) {
|
||||
throw new RuntimeException(
|
||||
"Cannot modify the bounding box of a disguise which is not TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS");
|
||||
}
|
||||
|
||||
if (isModifyBoundingBox() != modifyBox)
|
||||
{
|
||||
if (isModifyBoundingBox() != modifyBox) {
|
||||
this.modifyBoundingBox = modifyBox;
|
||||
|
||||
if (DisguiseUtilities.isDisguiseInUse(this))
|
||||
{
|
||||
if (DisguiseUtilities.isDisguiseInUse(this)) {
|
||||
DisguiseUtilities.doBoundingBox((TargetedDisguise) this);
|
||||
}
|
||||
}
|
||||
@ -780,8 +661,7 @@ public abstract class Disguise
|
||||
return this;
|
||||
}
|
||||
|
||||
public Disguise setReplaceSounds(boolean areSoundsReplaced)
|
||||
{
|
||||
public Disguise setReplaceSounds(boolean areSoundsReplaced) {
|
||||
replaceSounds = areSoundsReplaced;
|
||||
|
||||
return this;
|
||||
@ -791,20 +671,17 @@ public abstract class Disguise
|
||||
* Sets up the FlagWatcher with the entityclass, it creates all the data it needs to prevent conflicts when sending the
|
||||
* datawatcher.
|
||||
*/
|
||||
private void setupWatcher()
|
||||
{
|
||||
private void setupWatcher() {
|
||||
ArrayList<FlagType> disguiseFlags = FlagType.getFlags(getType().getWatcherClass());
|
||||
ArrayList<FlagType> entityFlags = FlagType.getFlags(DisguiseType.getType(getEntity().getType()).getWatcherClass());
|
||||
|
||||
for (FlagType flag : entityFlags)
|
||||
{
|
||||
for (FlagType flag : entityFlags) {
|
||||
if (disguiseFlags.contains(flag))
|
||||
continue;
|
||||
|
||||
FlagType backup = null;
|
||||
|
||||
for (FlagType flagType : disguiseFlags)
|
||||
{
|
||||
for (FlagType flagType : disguiseFlags) {
|
||||
if (flagType.getIndex() == flag.getIndex())
|
||||
backup = flagType;
|
||||
}
|
||||
@ -815,8 +692,7 @@ public abstract class Disguise
|
||||
getWatcher().setNoGravity(true);
|
||||
}
|
||||
|
||||
public Disguise setVelocitySent(boolean sendVelocity)
|
||||
{
|
||||
public Disguise setVelocitySent(boolean sendVelocity) {
|
||||
this.velocitySent = sendVelocity;
|
||||
|
||||
return this;
|
||||
@ -828,22 +704,16 @@ public abstract class Disguise
|
||||
* @param viewSelfDisguise
|
||||
* @return
|
||||
*/
|
||||
public Disguise setViewSelfDisguise(boolean viewSelfDisguise)
|
||||
{
|
||||
if (isSelfDisguiseVisible() != viewSelfDisguise)
|
||||
{
|
||||
public Disguise setViewSelfDisguise(boolean viewSelfDisguise) {
|
||||
if (isSelfDisguiseVisible() != viewSelfDisguise) {
|
||||
this.viewSelfDisguise = viewSelfDisguise;
|
||||
|
||||
if (getEntity() != null && getEntity() instanceof Player)
|
||||
{
|
||||
if (DisguiseAPI.getDisguise((Player) getEntity(), getEntity()) == this)
|
||||
{
|
||||
if (isSelfDisguiseVisible())
|
||||
{
|
||||
if (getEntity() != null && getEntity() instanceof Player) {
|
||||
if (DisguiseAPI.getDisguise((Player) getEntity(), getEntity()) == this) {
|
||||
if (isSelfDisguiseVisible()) {
|
||||
DisguiseUtilities.setupFakeDisguise(this);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
DisguiseUtilities.removeSelfDisguise((Player) getEntity());
|
||||
}
|
||||
}
|
||||
@ -853,30 +723,24 @@ public abstract class Disguise
|
||||
return this;
|
||||
}
|
||||
|
||||
public Disguise setWatcher(FlagWatcher newWatcher)
|
||||
{
|
||||
if (!getType().getWatcherClass().isInstance(newWatcher))
|
||||
{
|
||||
public Disguise setWatcher(FlagWatcher newWatcher) {
|
||||
if (!getType().getWatcherClass().isInstance(newWatcher)) {
|
||||
throw new IllegalArgumentException(newWatcher.getClass().getSimpleName() + " is not a instance of "
|
||||
+ getType().getWatcherClass().getSimpleName() + " for DisguiseType " + getType().name());
|
||||
}
|
||||
|
||||
watcher = newWatcher;
|
||||
|
||||
if (getEntity() != null)
|
||||
{
|
||||
if (getEntity() != null) {
|
||||
setupWatcher();
|
||||
}
|
||||
|
||||
return this;
|
||||
}
|
||||
|
||||
public boolean startDisguise()
|
||||
{
|
||||
if (!isDisguiseInUse())
|
||||
{
|
||||
if (getEntity() == null)
|
||||
{
|
||||
public boolean startDisguise() {
|
||||
if (!isDisguiseInUse()) {
|
||||
if (getEntity() == null) {
|
||||
throw new RuntimeException("No entity is assigned to this disguise!");
|
||||
}
|
||||
|
||||
@ -887,8 +751,7 @@ public abstract class Disguise
|
||||
|
||||
// If they cancelled this disguise event. No idea why.
|
||||
// Just return.
|
||||
if (!event.isCancelled())
|
||||
{
|
||||
if (!event.isCancelled()) {
|
||||
disguiseInUse = true;
|
||||
|
||||
task = Bukkit.getScheduler().runTaskTimer(LibsDisguises.getInstance(), velocityRunnable, 1, 1);
|
||||
@ -896,8 +759,7 @@ public abstract class Disguise
|
||||
// Stick the disguise in the disguises bin
|
||||
DisguiseUtilities.addDisguise(entity.getUniqueId(), (TargetedDisguise) this);
|
||||
|
||||
if (isSelfDisguiseVisible() && getEntity() instanceof Player)
|
||||
{
|
||||
if (isSelfDisguiseVisible() && getEntity() instanceof Player) {
|
||||
DisguiseUtilities.removeSelfDisguise((Player) getEntity());
|
||||
}
|
||||
|
||||
@ -905,11 +767,9 @@ public abstract class Disguise
|
||||
DisguiseUtilities.refreshTrackers((TargetedDisguise) this);
|
||||
|
||||
// If he is a player, then self disguise himself
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(LibsDisguises.getInstance(), new Runnable()
|
||||
{
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(LibsDisguises.getInstance(), new Runnable() {
|
||||
@Override
|
||||
public void run()
|
||||
{
|
||||
public void run() {
|
||||
DisguiseUtilities.setupFakeDisguise(Disguise.this);
|
||||
}
|
||||
}, 2);
|
||||
@ -919,8 +779,7 @@ public abstract class Disguise
|
||||
return false;
|
||||
}
|
||||
|
||||
public boolean stopDisguise()
|
||||
{
|
||||
public boolean stopDisguise() {
|
||||
return removeDisguise();
|
||||
}
|
||||
|
||||
@ -929,8 +788,7 @@ public abstract class Disguise
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public static List<UUID> getViewSelf()
|
||||
{
|
||||
public static List<UUID> getViewSelf() {
|
||||
return viewSelf;
|
||||
}
|
||||
}
|
||||
|
@ -9,8 +9,7 @@ import org.bukkit.entity.Skeleton;
|
||||
import org.bukkit.entity.Skeleton.SkeletonType;
|
||||
import org.bukkit.entity.Zombie;
|
||||
|
||||
public enum DisguiseType
|
||||
{
|
||||
public enum DisguiseType {
|
||||
AREA_EFFECT_CLOUD(3, 0),
|
||||
|
||||
ARMOR_STAND(78),
|
||||
@ -53,6 +52,10 @@ public enum DisguiseType
|
||||
|
||||
ENDERMITE,
|
||||
|
||||
EVOKER,
|
||||
|
||||
EVOKER_FANGS(79),
|
||||
|
||||
EXPERIENCE_ORB,
|
||||
|
||||
FALLING_BLOCK(70, 1),
|
||||
@ -77,6 +80,10 @@ public enum DisguiseType
|
||||
|
||||
ITEM_FRAME(71),
|
||||
|
||||
LLAMA,
|
||||
|
||||
LLAMA_SPIT(68),
|
||||
|
||||
LEASH_HITCH(77),
|
||||
|
||||
MAGMA_CUBE,
|
||||
@ -153,8 +160,12 @@ public enum DisguiseType
|
||||
|
||||
UNKNOWN,
|
||||
|
||||
VEX,
|
||||
|
||||
VILLAGER,
|
||||
|
||||
VINDICATOR,
|
||||
|
||||
WITCH,
|
||||
|
||||
WITHER,
|
||||
@ -169,31 +180,21 @@ public enum DisguiseType
|
||||
|
||||
ZOMBIE_VILLAGER;
|
||||
|
||||
static
|
||||
{
|
||||
static {
|
||||
// We set the entity type in this so that we can safely ignore disguisetypes which don't exist in older versions of MC.
|
||||
// Without erroring up everything.
|
||||
|
||||
for (DisguiseType type : values())
|
||||
{
|
||||
for (DisguiseType type : values()) {
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
DisguiseType toUse = type;
|
||||
String name;
|
||||
|
||||
switch (type)
|
||||
{
|
||||
switch (type) {
|
||||
// Disguise item frame isn't supported. So we don't give it a entity type which should prevent it from being..
|
||||
// Usable.
|
||||
case ITEM_FRAME:
|
||||
break;
|
||||
case DONKEY:
|
||||
case MULE:
|
||||
case UNDEAD_HORSE:
|
||||
case SKELETON_HORSE:
|
||||
toUse = DisguiseType.HORSE;
|
||||
break;
|
||||
case ZOMBIE_VILLAGER:
|
||||
case HUSK:
|
||||
toUse = DisguiseType.ZOMBIE;
|
||||
@ -213,23 +214,19 @@ public enum DisguiseType
|
||||
|
||||
type.setEntityType(EntityType.valueOf(name));
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
catch (Throwable ex) {
|
||||
// This version of Spigot doesn't have the disguise.
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
public static DisguiseType getType(Entity entity)
|
||||
{
|
||||
public static DisguiseType getType(Entity entity) {
|
||||
DisguiseType disguiseType = getType(entity.getType());
|
||||
|
||||
switch (disguiseType)
|
||||
{
|
||||
switch (disguiseType) {
|
||||
case ZOMBIE:
|
||||
|
||||
if (((Zombie) entity).isVillager())
|
||||
{
|
||||
if (((Zombie) entity).isVillager()) {
|
||||
disguiseType = DisguiseType.ZOMBIE_VILLAGER;
|
||||
}
|
||||
|
||||
@ -243,16 +240,14 @@ public enum DisguiseType
|
||||
|
||||
case SKELETON:
|
||||
|
||||
if (((Skeleton) entity).getSkeletonType() == SkeletonType.WITHER)
|
||||
{
|
||||
if (((Skeleton) entity).getSkeletonType() == SkeletonType.WITHER) {
|
||||
disguiseType = DisguiseType.WITHER_SKELETON;
|
||||
}
|
||||
|
||||
break;
|
||||
case GUARDIAN:
|
||||
|
||||
if (((Guardian) entity).isElder())
|
||||
{
|
||||
if (((Guardian) entity).isElder()) {
|
||||
disguiseType = DisguiseType.ELDER_GUARDIAN;
|
||||
}
|
||||
|
||||
@ -265,14 +260,11 @@ public enum DisguiseType
|
||||
|
||||
}
|
||||
|
||||
public static DisguiseType getType(EntityType entityType)
|
||||
{
|
||||
try
|
||||
{
|
||||
public static DisguiseType getType(EntityType entityType) {
|
||||
try {
|
||||
return valueOf(entityType.name().toUpperCase());
|
||||
}
|
||||
catch (Throwable ex)
|
||||
{
|
||||
catch (Throwable ex) {
|
||||
return DisguiseType.UNKNOWN;
|
||||
}
|
||||
}
|
||||
@ -283,14 +275,11 @@ public enum DisguiseType
|
||||
|
||||
private Class<? extends FlagWatcher> watcherClass;
|
||||
|
||||
DisguiseType(int... ints)
|
||||
{
|
||||
for (int i = 0; i < ints.length; i++)
|
||||
{
|
||||
DisguiseType(int... ints) {
|
||||
for (int i = 0; i < ints.length; i++) {
|
||||
int value = ints[i];
|
||||
|
||||
switch (i)
|
||||
{
|
||||
switch (i) {
|
||||
case 0:
|
||||
objectId = value;
|
||||
|
||||
@ -305,23 +294,19 @@ public enum DisguiseType
|
||||
}
|
||||
}
|
||||
|
||||
public int getDefaultData()
|
||||
{
|
||||
public int getDefaultData() {
|
||||
return defaultData;
|
||||
}
|
||||
|
||||
public Class<? extends Entity> getEntityClass()
|
||||
{
|
||||
if (entityType != null)
|
||||
{
|
||||
public Class<? extends Entity> getEntityClass() {
|
||||
if (entityType != null) {
|
||||
return getEntityType().getEntityClass();
|
||||
}
|
||||
|
||||
return Entity.class;
|
||||
}
|
||||
|
||||
public EntityType getEntityType()
|
||||
{
|
||||
public EntityType getEntityType() {
|
||||
return entityType;
|
||||
}
|
||||
|
||||
@ -330,8 +315,7 @@ public enum DisguiseType
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getObjectId()
|
||||
{
|
||||
public int getObjectId() {
|
||||
return objectId;
|
||||
}
|
||||
|
||||
@ -340,52 +324,42 @@ public enum DisguiseType
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public int getTypeId()
|
||||
{
|
||||
public int getTypeId() {
|
||||
return (int) getEntityType().getTypeId();
|
||||
}
|
||||
|
||||
public Class<? extends FlagWatcher> getWatcherClass()
|
||||
{
|
||||
public Class<? extends FlagWatcher> getWatcherClass() {
|
||||
return watcherClass;
|
||||
}
|
||||
|
||||
public boolean isMisc()
|
||||
{
|
||||
public boolean isMisc() {
|
||||
return getEntityType() != null && !getEntityType().isAlive();
|
||||
}
|
||||
|
||||
public boolean isMob()
|
||||
{
|
||||
public boolean isMob() {
|
||||
return getEntityType() != null && getEntityType().isAlive() && !isPlayer();
|
||||
}
|
||||
|
||||
public boolean isPlayer()
|
||||
{
|
||||
public boolean isPlayer() {
|
||||
return this == DisguiseType.PLAYER;
|
||||
}
|
||||
|
||||
public boolean isUnknown()
|
||||
{
|
||||
public boolean isUnknown() {
|
||||
return this == DisguiseType.UNKNOWN;
|
||||
}
|
||||
|
||||
private void setEntityType(EntityType entityType)
|
||||
{
|
||||
private void setEntityType(EntityType entityType) {
|
||||
this.entityType = entityType;
|
||||
}
|
||||
|
||||
public void setWatcherClass(Class<? extends FlagWatcher> c)
|
||||
{
|
||||
public void setWatcherClass(Class<? extends FlagWatcher> c) {
|
||||
watcherClass = c;
|
||||
}
|
||||
|
||||
public String toReadable()
|
||||
{
|
||||
public String toReadable() {
|
||||
String[] split = name().split("_");
|
||||
|
||||
for (int i = 0; i < split.length; i++)
|
||||
{
|
||||
for (int i = 0; i < split.length; i++) {
|
||||
split[i] = split[i].substring(0, 1) + split[i].substring(1).toLowerCase();
|
||||
}
|
||||
|
||||
|
@ -28,16 +28,20 @@ import me.libraryaddict.disguise.disguisetypes.watchers.DroppedItemWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.EnderCrystalWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.EnderDragonWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.EndermanWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.EvokerWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.FallingBlockWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.FireworkWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.FishingHookWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.GhastWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.GuardianWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.HorseAbstractWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.HorseChestedWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.HorseWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.InsentientWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.IronGolemWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.ItemFrameWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.LlamaWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.MinecartWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.OcelotWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.PigWatcher;
|
||||
@ -53,15 +57,16 @@ import me.libraryaddict.disguise.disguisetypes.watchers.SpiderWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.SplashPotionWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.TNTWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.TameableWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.VexWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.VillagerWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.VindicatorWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.WitchWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.WitherSkullWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.WitherWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.WolfWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.watchers.ZombieWatcher;
|
||||
|
||||
public class FlagType<Y>
|
||||
{
|
||||
public class FlagType<Y> {
|
||||
private static FlagType[] _values = new FlagType[0];
|
||||
|
||||
public static FlagType<Boolean> AGEABLE_BABY = new FlagType<Boolean>(AgeableWatcher.class, 0, false);
|
||||
@ -79,11 +84,9 @@ public class FlagType<Y>
|
||||
|
||||
public static FlagType<Float> AREA_EFFECT_RADIUS = new FlagType<Float>(AreaEffectCloudWatcher.class, 0, 0F);
|
||||
|
||||
public static FlagType<Vector3F> ARMORSTAND_BODY = new FlagType<Vector3F>(ArmorStandWatcher.class, 2,
|
||||
new Vector3F(0, 0, 0));
|
||||
public static FlagType<Vector3F> ARMORSTAND_BODY = new FlagType<Vector3F>(ArmorStandWatcher.class, 2, new Vector3F(0, 0, 0));
|
||||
|
||||
public static FlagType<Vector3F> ARMORSTAND_HEAD = new FlagType<Vector3F>(ArmorStandWatcher.class, 1,
|
||||
new Vector3F(0, 0, 0));
|
||||
public static FlagType<Vector3F> ARMORSTAND_HEAD = new FlagType<Vector3F>(ArmorStandWatcher.class, 1, new Vector3F(0, 0, 0));
|
||||
|
||||
public static FlagType<Vector3F> ARMORSTAND_LEFT_ARM = new FlagType<Vector3F>(ArmorStandWatcher.class, 3,
|
||||
new Vector3F(0, 0, 0));
|
||||
@ -93,9 +96,11 @@ public class FlagType<Y>
|
||||
|
||||
public static FlagType<Byte> ARMORSTAND_META = new FlagType<Byte>(ArmorStandWatcher.class, 0, (byte) 0);
|
||||
|
||||
public static FlagType<Vector3F> ARMORSTAND_RIGHT_ARM = new FlagType<Vector3F>(ArmorStandWatcher.class, 4, new Vector3F(0,0,0));
|
||||
public static FlagType<Vector3F> ARMORSTAND_RIGHT_ARM = new FlagType<Vector3F>(ArmorStandWatcher.class, 4,
|
||||
new Vector3F(0, 0, 0));
|
||||
|
||||
public static FlagType<Vector3F> ARMORSTAND_RIGHT_LEG = new FlagType<Vector3F>(ArmorStandWatcher.class, 6, new Vector3F(0,0,0));
|
||||
public static FlagType<Vector3F> ARMORSTAND_RIGHT_LEG = new FlagType<Vector3F>(ArmorStandWatcher.class, 6,
|
||||
new Vector3F(0, 0, 0));
|
||||
|
||||
public static FlagType<Byte> ARROW_CRITICAL = new FlagType<Byte>(ArrowWatcher.class, 0, (byte) 0);
|
||||
|
||||
@ -148,6 +153,8 @@ public class FlagType<Y>
|
||||
|
||||
public static FlagType<Boolean> ENTITY_SILENT = new FlagType<Boolean>(FlagWatcher.class, 4, false);
|
||||
|
||||
public static FlagType<Byte> EVOKER_SPELL_TICKS = new FlagType<Byte>(EvokerWatcher.class, 0, (byte) 0);
|
||||
|
||||
public static FlagType<BlockPosition> FALLING_BLOCK_POSITION = new FlagType<BlockPosition>(FallingBlockWatcher.class, 0,
|
||||
BlockPosition.ORIGIN);
|
||||
|
||||
@ -162,16 +169,18 @@ public class FlagType<Y>
|
||||
|
||||
public static FlagType<Integer> GUARDIAN_TARGET = new FlagType<Integer>(GuardianWatcher.class, 1, 0);
|
||||
|
||||
public static FlagType<Integer> HORSE_ARMOR = new FlagType<Integer>(HorseWatcher.class, 4, 0);
|
||||
public static FlagType<Integer> HORSE_ARMOR = new FlagType<Integer>(HorseWatcher.class, 1, 0);
|
||||
|
||||
public static FlagType<Integer> HORSE_COLOR = new FlagType<Integer>(HorseWatcher.class, 2, 0);
|
||||
public static FlagType<Integer> HORSE_COLOR = new FlagType<Integer>(HorseWatcher.class, 0, 0);
|
||||
|
||||
public static FlagType<Byte> HORSE_META = new FlagType<Byte>(HorseWatcher.class, 0, (byte) 0);
|
||||
public static FlagType<Byte> HORSE_META = new FlagType<Byte>(HorseAbstractWatcher.class, 0, (byte) 0);
|
||||
|
||||
public static FlagType<Optional<UUID>> HORSE_OWNER = new FlagType<Optional<UUID>>(HorseWatcher.class, 3,
|
||||
public static FlagType<Boolean> HORSE_CARRYING_CHEST = new FlagType<Boolean>(HorseChestedWatcher.class, 0, false);
|
||||
|
||||
public static FlagType<Optional<UUID>> HORSE_OWNER = new FlagType<Optional<UUID>>(HorseAbstractWatcher.class, 1,
|
||||
Optional.<UUID> absent());
|
||||
|
||||
public static FlagType<Integer> HORSE_VARIANT = new FlagType<Integer>(HorseWatcher.class, 1, 0);
|
||||
// public static FlagType<Integer> HORSE_VARIANT = new FlagType<Integer>(HorseWatcher.class, 0, 0);
|
||||
|
||||
public static FlagType<Byte> INSENTIENT_META = new FlagType<Byte>(InsentientWatcher.class, 0, (byte) 0);
|
||||
|
||||
@ -182,6 +191,12 @@ public class FlagType<Y>
|
||||
|
||||
public static FlagType<Integer> ITEMFRAME_ROTATION = new FlagType<Integer>(ItemFrameWatcher.class, 1, 0);
|
||||
|
||||
public static FlagType<Integer> LLAMA_STRENGTH = new FlagType<Integer>(LlamaWatcher.class, 0, 0);
|
||||
|
||||
public static FlagType<Integer> LLAMA_COLOR = new FlagType<Integer>(LlamaWatcher.class, 1, -1);
|
||||
|
||||
public static FlagType<Integer> LLAMA_CARPET = new FlagType<Integer>(LlamaWatcher.class, 2, 0);
|
||||
|
||||
public static FlagType<Integer> LIVING_ARROWS = new FlagType<Integer>(LivingWatcher.class, 4, 0);
|
||||
|
||||
public static FlagType<Byte> LIVING_HAND = new FlagType<Byte>(LivingWatcher.class, 0, (byte) 0);
|
||||
@ -229,6 +244,8 @@ public class FlagType<Y>
|
||||
|
||||
public static FlagType<Byte> SHULKER_PEEKING = new FlagType<Byte>(ShulkerWatcher.class, 2, (byte) 0);
|
||||
|
||||
public static FlagType<Byte> SHULKER_COLOR = new FlagType<Byte>(ShulkerWatcher.class, 3, (byte) 10);
|
||||
|
||||
public static FlagType<Boolean> SKELETON_SWING_ARMS = new FlagType<Boolean>(SkeletonWatcher.class, 1, false);
|
||||
|
||||
public static FlagType<Integer> SKELETON_TYPE = new FlagType<Integer>(SkeletonWatcher.class, 0, 0);
|
||||
@ -257,8 +274,12 @@ public class FlagType<Y>
|
||||
|
||||
public static FlagType<Integer> TNT_FUSE_TICKS = new FlagType<Integer>(TNTWatcher.class, 0, Integer.MAX_VALUE);
|
||||
|
||||
public static FlagType<Boolean> VEX_ANGRY = new FlagType<Boolean>(VexWatcher.class, 0, false);
|
||||
|
||||
public static FlagType<Integer> VILLAGER_PROFESSION = new FlagType<Integer>(VillagerWatcher.class, 0, 0);
|
||||
|
||||
public static FlagType<Byte> VINDICATOR_JOHNNY = new FlagType<Byte>(VindicatorWatcher.class, 0, (byte) 0);
|
||||
|
||||
public static FlagType<Boolean> WITCH_AGGRESSIVE = new FlagType<Boolean>(WitchWatcher.class, 0, false);
|
||||
|
||||
public static FlagType<Integer> WITHER_INVUL = new FlagType<Integer>(WitherWatcher.class, 3, 0);
|
||||
@ -285,10 +306,8 @@ public class FlagType<Y>
|
||||
|
||||
public static FlagType<Boolean> ZOMBIE_SHAKING = new FlagType<Boolean>(ZombieWatcher.class, 2, false);
|
||||
|
||||
static
|
||||
{
|
||||
for (FlagType flagType : values())
|
||||
{
|
||||
static {
|
||||
for (FlagType flagType : values()) {
|
||||
if (flagType.getFlagWatcher() == FlagWatcher.class)
|
||||
continue;
|
||||
|
||||
@ -302,32 +321,27 @@ public class FlagType<Y>
|
||||
|
||||
HashMap<Class, Integer> maxValues = new HashMap<Class, Integer>();
|
||||
|
||||
for (FlagType type : values())
|
||||
{
|
||||
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())
|
||||
{
|
||||
for (Entry<Class, Integer> entry : maxValues.entrySet()) {
|
||||
loop:
|
||||
|
||||
for (int i = 0; i < entry.getValue(); i++)
|
||||
{
|
||||
for (int i = 0; i < entry.getValue(); i++) {
|
||||
FlagType found = null;
|
||||
|
||||
for (FlagType type : values())
|
||||
{
|
||||
for (FlagType type : values()) {
|
||||
if (type.getIndex() != i)
|
||||
continue;
|
||||
|
||||
if (!type.getFlagWatcher().isAssignableFrom(entry.getKey()))
|
||||
continue;
|
||||
|
||||
if (found != null)
|
||||
{
|
||||
if (found != null) {
|
||||
System.err.println(entry.getKey().getSimpleName() + " has multiple FlagType's registered for the index "
|
||||
+ i + " (" + type.getFlagWatcher().getSimpleName() + ", " + found.getFlagWatcher().getSimpleName()
|
||||
+ ")");
|
||||
@ -345,10 +359,8 @@ public class FlagType<Y>
|
||||
}
|
||||
}
|
||||
|
||||
public static FlagType getFlag(Class<? extends FlagWatcher> watcherClass, int flagNo)
|
||||
{
|
||||
for (FlagType type : values())
|
||||
{
|
||||
public static FlagType getFlag(Class<? extends FlagWatcher> watcherClass, int flagNo) {
|
||||
for (FlagType type : values()) {
|
||||
if (type.getIndex() != flagNo)
|
||||
continue;
|
||||
|
||||
@ -361,12 +373,10 @@ public class FlagType<Y>
|
||||
return null;
|
||||
}
|
||||
|
||||
public static ArrayList<FlagType> getFlags(Class<? extends FlagWatcher> watcherClass)
|
||||
{
|
||||
public static ArrayList<FlagType> getFlags(Class<? extends FlagWatcher> watcherClass) {
|
||||
ArrayList<FlagType> list = new ArrayList<FlagType>();
|
||||
|
||||
for (FlagType type : values())
|
||||
{
|
||||
for (FlagType type : values()) {
|
||||
if (!type.getFlagWatcher().isAssignableFrom(watcherClass))
|
||||
continue;
|
||||
|
||||
@ -376,28 +386,24 @@ public class FlagType<Y>
|
||||
return list;
|
||||
}
|
||||
|
||||
private static int getNoIndexes(Class c)
|
||||
{
|
||||
private static int getNoIndexes(Class c) {
|
||||
int found = 0;
|
||||
|
||||
for (FlagType type : values())
|
||||
{
|
||||
for (FlagType type : values()) {
|
||||
if (type.getFlagWatcher() != c)
|
||||
continue;
|
||||
|
||||
found++;
|
||||
}
|
||||
|
||||
if (c != FlagWatcher.class)
|
||||
{
|
||||
if (c != FlagWatcher.class) {
|
||||
found += getNoIndexes(c.getSuperclass());
|
||||
}
|
||||
|
||||
return found;
|
||||
}
|
||||
|
||||
public static FlagType[] values()
|
||||
{
|
||||
public static FlagType[] values() {
|
||||
return _values;
|
||||
}
|
||||
|
||||
@ -405,8 +411,7 @@ public class FlagType<Y>
|
||||
private int _index;
|
||||
private Class<? extends FlagWatcher> _watcher;
|
||||
|
||||
private FlagType(Class<? extends FlagWatcher> watcher, int index, Y defaultValue)
|
||||
{
|
||||
private FlagType(Class<? extends FlagWatcher> watcher, int index, Y defaultValue) {
|
||||
_index = index;
|
||||
_watcher = watcher;
|
||||
_defaultValue = defaultValue;
|
||||
@ -415,18 +420,15 @@ public class FlagType<Y>
|
||||
_values[_values.length - 1] = this;
|
||||
}
|
||||
|
||||
public Y getDefault()
|
||||
{
|
||||
public Y getDefault() {
|
||||
return _defaultValue;
|
||||
}
|
||||
|
||||
public Class<? extends FlagWatcher> getFlagWatcher()
|
||||
{
|
||||
public Class<? extends FlagWatcher> getFlagWatcher() {
|
||||
return _watcher;
|
||||
}
|
||||
|
||||
public int getIndex()
|
||||
{
|
||||
public int getIndex() {
|
||||
return _index;
|
||||
}
|
||||
}
|
||||
|
@ -243,7 +243,7 @@ public class FlagWatcher
|
||||
|
||||
public String getCustomName()
|
||||
{
|
||||
return (String) getValue(FlagType.ENTITY_CUSTOM_NAME);
|
||||
return (String) getData(FlagType.ENTITY_CUSTOM_NAME);
|
||||
}
|
||||
|
||||
protected TargetedDisguise getDisguise()
|
||||
@ -253,7 +253,7 @@ public class FlagWatcher
|
||||
|
||||
private boolean getEntityFlag(int byteValue)
|
||||
{
|
||||
return (getValue(FlagType.ENTITY_META) & 1 << byteValue) != 0;
|
||||
return (getData(FlagType.ENTITY_META) & 1 << byteValue) != 0;
|
||||
}
|
||||
|
||||
public EntityEquipment getEquipment()
|
||||
@ -301,7 +301,7 @@ public class FlagWatcher
|
||||
return null;
|
||||
}
|
||||
|
||||
protected <Y> Y getValue(FlagType<Y> flagType)
|
||||
protected <Y> Y getData(FlagType<Y> flagType)
|
||||
{
|
||||
if (_entityValues.containsKey(flagType.getIndex()))
|
||||
{
|
||||
@ -338,7 +338,7 @@ public class FlagWatcher
|
||||
|
||||
public boolean isCustomNameVisible()
|
||||
{
|
||||
return getValue(FlagType.ENTITY_CUSTOM_NAME_VISIBLE);
|
||||
return getData(FlagType.ENTITY_CUSTOM_NAME_VISIBLE);
|
||||
}
|
||||
|
||||
public boolean isEntityAnimationsAdded()
|
||||
@ -363,7 +363,7 @@ public class FlagWatcher
|
||||
|
||||
public boolean isNoGravity()
|
||||
{
|
||||
return getValue(FlagType.ENTITY_NO_GRAVITY);
|
||||
return getData(FlagType.ENTITY_NO_GRAVITY);
|
||||
}
|
||||
|
||||
public boolean isRightClicking()
|
||||
@ -509,13 +509,13 @@ public class FlagWatcher
|
||||
name = name.substring(0, 64);
|
||||
}
|
||||
|
||||
setValue(FlagType.ENTITY_CUSTOM_NAME, name);
|
||||
setData(FlagType.ENTITY_CUSTOM_NAME, name);
|
||||
sendData(FlagType.ENTITY_CUSTOM_NAME);
|
||||
}
|
||||
|
||||
public void setCustomNameVisible(boolean display)
|
||||
{
|
||||
setValue(FlagType.ENTITY_CUSTOM_NAME_VISIBLE, display);
|
||||
setData(FlagType.ENTITY_CUSTOM_NAME_VISIBLE, display);
|
||||
sendData(FlagType.ENTITY_CUSTOM_NAME_VISIBLE);
|
||||
}
|
||||
|
||||
@ -523,15 +523,15 @@ public class FlagWatcher
|
||||
{
|
||||
_modifiedEntityAnimations.add(byteValue);
|
||||
|
||||
byte b0 = (byte) getValue(FlagType.ENTITY_META);
|
||||
byte b0 = (byte) getData(FlagType.ENTITY_META);
|
||||
|
||||
if (flag)
|
||||
{
|
||||
setValue(FlagType.ENTITY_META, (byte) (b0 | 1 << byteValue));
|
||||
setData(FlagType.ENTITY_META, (byte) (b0 | 1 << byteValue));
|
||||
}
|
||||
else
|
||||
{
|
||||
setValue(FlagType.ENTITY_META, (byte) (b0 & ~(1 << byteValue)));
|
||||
setData(FlagType.ENTITY_META, (byte) (b0 & ~(1 << byteValue)));
|
||||
}
|
||||
}
|
||||
|
||||
@ -653,7 +653,7 @@ public class FlagWatcher
|
||||
|
||||
public void setNoGravity(boolean noGravity)
|
||||
{
|
||||
setValue(FlagType.ENTITY_NO_GRAVITY, noGravity);
|
||||
setData(FlagType.ENTITY_NO_GRAVITY, noGravity);
|
||||
sendData(FlagType.ENTITY_NO_GRAVITY);
|
||||
}
|
||||
|
||||
@ -675,7 +675,7 @@ public class FlagWatcher
|
||||
sendData(FlagType.ENTITY_META);
|
||||
}
|
||||
|
||||
protected <Y> void setValue(FlagType<Y> id, Y value)
|
||||
protected <Y> void setData(FlagType<Y> id, Y value)
|
||||
{
|
||||
_entityValues.put(id.getIndex(), value);
|
||||
|
||||
|
@ -17,7 +17,7 @@ public class AgeableWatcher extends InsentientWatcher
|
||||
|
||||
public boolean isBaby()
|
||||
{
|
||||
return getValue(FlagType.AGEABLE_BABY);
|
||||
return getData(FlagType.AGEABLE_BABY);
|
||||
}
|
||||
|
||||
public void setAdult()
|
||||
@ -32,7 +32,7 @@ public class AgeableWatcher extends InsentientWatcher
|
||||
|
||||
public void setBaby(boolean isBaby)
|
||||
{
|
||||
setValue(FlagType.AGEABLE_BABY, isBaby);
|
||||
setData(FlagType.AGEABLE_BABY, isBaby);
|
||||
sendData(FlagType.AGEABLE_BABY);
|
||||
}
|
||||
}
|
||||
|
@ -17,42 +17,42 @@ public class AreaEffectCloudWatcher extends FlagWatcher
|
||||
|
||||
public float getRadius()
|
||||
{
|
||||
return getValue(FlagType.AREA_EFFECT_RADIUS);
|
||||
return getData(FlagType.AREA_EFFECT_RADIUS);
|
||||
}
|
||||
|
||||
public int getColor()
|
||||
{
|
||||
return getValue(FlagType.AREA_EFFECT_COLOR);
|
||||
return getData(FlagType.AREA_EFFECT_COLOR);
|
||||
}
|
||||
|
||||
public boolean isIgnoreRadius()
|
||||
{
|
||||
return getValue(FlagType.AREA_EFFECT_IGNORE_RADIUS);
|
||||
return getData(FlagType.AREA_EFFECT_IGNORE_RADIUS);
|
||||
}
|
||||
|
||||
public int getParticleId()
|
||||
{
|
||||
return getValue(FlagType.AREA_EFFECT_PARTICLE);
|
||||
return getData(FlagType.AREA_EFFECT_PARTICLE);
|
||||
}
|
||||
|
||||
public void setRadius(float radius)
|
||||
{
|
||||
setValue(FlagType.AREA_EFFECT_RADIUS, radius);
|
||||
setData(FlagType.AREA_EFFECT_RADIUS, radius);
|
||||
}
|
||||
|
||||
public void setColor(int color)
|
||||
{
|
||||
setValue(FlagType.AREA_EFFECT_COLOR, color);
|
||||
setData(FlagType.AREA_EFFECT_COLOR, color);
|
||||
}
|
||||
|
||||
public void setIgnoreRadius(boolean ignore)
|
||||
{
|
||||
setValue(FlagType.AREA_EFFECT_IGNORE_RADIUS, ignore);
|
||||
setData(FlagType.AREA_EFFECT_IGNORE_RADIUS, ignore);
|
||||
}
|
||||
|
||||
public void setParticleId(int particleId)
|
||||
{
|
||||
setValue(FlagType.AREA_EFFECT_PARTICLE, particleId);
|
||||
setData(FlagType.AREA_EFFECT_PARTICLE, particleId);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,7 +16,7 @@ public class ArmorStandWatcher extends LivingWatcher
|
||||
|
||||
private boolean getArmorStandFlag(int value)
|
||||
{
|
||||
return (getValue(FlagType.ARMORSTAND_META) & value) != 0;
|
||||
return (getData(FlagType.ARMORSTAND_META) & value) != 0;
|
||||
}
|
||||
|
||||
public EulerAngle getBody()
|
||||
@ -44,7 +44,7 @@ public class ArmorStandWatcher extends LivingWatcher
|
||||
if (!hasValue(type))
|
||||
return new EulerAngle(0, 0, 0);
|
||||
|
||||
Vector3F vec = getValue(type);
|
||||
Vector3F vec = getData(type);
|
||||
|
||||
return new EulerAngle(vec.getX(), vec.getY(), vec.getZ());
|
||||
}
|
||||
@ -86,7 +86,7 @@ public class ArmorStandWatcher extends LivingWatcher
|
||||
|
||||
private void setArmorStandFlag(int value, boolean isTrue)
|
||||
{
|
||||
byte b1 = (byte) getValue(FlagType.ARMORSTAND_META);
|
||||
byte b1 = (byte) getData(FlagType.ARMORSTAND_META);
|
||||
|
||||
if (isTrue)
|
||||
{
|
||||
@ -97,7 +97,7 @@ public class ArmorStandWatcher extends LivingWatcher
|
||||
b1 = (byte) (b1 & value);
|
||||
}
|
||||
|
||||
setValue(FlagType.ARMORSTAND_META, b1);
|
||||
setData(FlagType.ARMORSTAND_META, b1);
|
||||
sendData(FlagType.ARMORSTAND_META);
|
||||
}
|
||||
|
||||
@ -141,7 +141,7 @@ public class ArmorStandWatcher extends LivingWatcher
|
||||
|
||||
private void setPose(FlagType<Vector3F> type, EulerAngle vector)
|
||||
{
|
||||
setValue(type, new Vector3F((float) vector.getX(), (float) vector.getY(), (float) vector.getZ()));
|
||||
setData(type, new Vector3F((float) vector.getX(), (float) vector.getY(), (float) vector.getZ()));
|
||||
sendData(type);
|
||||
}
|
||||
|
||||
|
@ -13,12 +13,12 @@ public class ArrowWatcher extends FlagWatcher
|
||||
|
||||
public boolean isCritical()
|
||||
{
|
||||
return (byte) getValue(FlagType.ARROW_CRITICAL) == 1;
|
||||
return (byte) getData(FlagType.ARROW_CRITICAL) == 1;
|
||||
}
|
||||
|
||||
public void setCritical(boolean critical)
|
||||
{
|
||||
setValue(FlagType.ARROW_CRITICAL, (byte) (critical ? 1 : 0));
|
||||
setData(FlagType.ARROW_CRITICAL, (byte) (critical ? 1 : 0));
|
||||
sendData(FlagType.ARROW_CRITICAL);
|
||||
}
|
||||
}
|
||||
|
@ -15,12 +15,12 @@ public class BatWatcher extends InsentientWatcher
|
||||
|
||||
public boolean isHanging()
|
||||
{
|
||||
return ((byte) getValue(FlagType.BAT_HANGING)) == 1;
|
||||
return ((byte) getData(FlagType.BAT_HANGING)) == 1;
|
||||
}
|
||||
|
||||
public void setHanging(boolean hanging)
|
||||
{
|
||||
setValue(FlagType.BAT_HANGING, hanging ? (byte) 1 : (byte) 0);
|
||||
setData(FlagType.BAT_HANGING, hanging ? (byte) 1 : (byte) 0);
|
||||
sendData(FlagType.BAT_HANGING);
|
||||
}
|
||||
}
|
||||
|
@ -12,12 +12,12 @@ public class BlazeWatcher extends InsentientWatcher
|
||||
|
||||
public boolean isBlazing()
|
||||
{
|
||||
return getValue(FlagType.BLAZE_BLAZING) == 1;
|
||||
return getData(FlagType.BLAZE_BLAZING) == 1;
|
||||
}
|
||||
|
||||
public void setBlazing(boolean isBlazing)
|
||||
{
|
||||
setValue(FlagType.BLAZE_BLAZING, (byte) (isBlazing ? 1 : 0));
|
||||
setData(FlagType.BLAZE_BLAZING, (byte) (isBlazing ? 1 : 0));
|
||||
sendData(FlagType.BLAZE_BLAZING);
|
||||
}
|
||||
|
||||
|
@ -19,46 +19,46 @@ public class BoatWatcher extends FlagWatcher
|
||||
|
||||
public float getDamage()
|
||||
{
|
||||
return getValue(FlagType.BOAT_DAMAGE);
|
||||
return getData(FlagType.BOAT_DAMAGE);
|
||||
}
|
||||
|
||||
public void setDamage(float dmg)
|
||||
{
|
||||
setValue(FlagType.BOAT_DAMAGE, dmg);
|
||||
setData(FlagType.BOAT_DAMAGE, dmg);
|
||||
sendData(FlagType.BOAT_DAMAGE);
|
||||
}
|
||||
|
||||
public void setRightPaddling(boolean rightPaddling)
|
||||
{
|
||||
setValue(FlagType.BOAT_RIGHT_PADDLING, rightPaddling);
|
||||
setData(FlagType.BOAT_RIGHT_PADDLING, rightPaddling);
|
||||
sendData(FlagType.BOAT_RIGHT_PADDLING);
|
||||
}
|
||||
|
||||
public void setLeftPaddling(boolean leftPaddling)
|
||||
{
|
||||
setValue(FlagType.BOAT_LEFT_PADDLING, leftPaddling);
|
||||
setData(FlagType.BOAT_LEFT_PADDLING, leftPaddling);
|
||||
sendData(FlagType.BOAT_LEFT_PADDLING);
|
||||
}
|
||||
|
||||
public boolean isRightPaddling()
|
||||
{
|
||||
return getValue(FlagType.BOAT_RIGHT_PADDLING);
|
||||
return getData(FlagType.BOAT_RIGHT_PADDLING);
|
||||
}
|
||||
|
||||
public boolean isLeftPaddling()
|
||||
{
|
||||
return getValue(FlagType.BOAT_LEFT_PADDLING);
|
||||
return getData(FlagType.BOAT_LEFT_PADDLING);
|
||||
}
|
||||
|
||||
public void setBoatType(TreeSpecies boatType)
|
||||
{
|
||||
setValue(FlagType.BOAT_TYPE, (int) boatType.getData());
|
||||
setData(FlagType.BOAT_TYPE, (int) boatType.getData());
|
||||
sendData(FlagType.BOAT_TYPE);
|
||||
}
|
||||
|
||||
public TreeSpecies getBoatType()
|
||||
{
|
||||
return TreeSpecies.getByData(getValue(FlagType.BOAT_TYPE).byteValue());
|
||||
return TreeSpecies.getByData(getData(FlagType.BOAT_TYPE).byteValue());
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -13,23 +13,23 @@ public class CreeperWatcher extends InsentientWatcher
|
||||
|
||||
public boolean isIgnited()
|
||||
{
|
||||
return (boolean) getValue(FlagType.CREEPER_IGNITED);
|
||||
return (boolean) getData(FlagType.CREEPER_IGNITED);
|
||||
}
|
||||
|
||||
public boolean isPowered()
|
||||
{
|
||||
return (boolean) getValue(FlagType.CREEPER_POWERED);
|
||||
return (boolean) getData(FlagType.CREEPER_POWERED);
|
||||
}
|
||||
|
||||
public void setIgnited(boolean ignited)
|
||||
{
|
||||
setValue(FlagType.CREEPER_IGNITED, ignited);
|
||||
setData(FlagType.CREEPER_IGNITED, ignited);
|
||||
sendData(FlagType.CREEPER_IGNITED);
|
||||
}
|
||||
|
||||
public void setPowered(boolean powered)
|
||||
{
|
||||
setValue(FlagType.CREEPER_POWERED, powered);
|
||||
setData(FlagType.CREEPER_POWERED, powered);
|
||||
sendData(FlagType.CREEPER_POWERED);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,11 @@
|
||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
|
||||
public class DonkeyWatcher extends HorseChestedWatcher {
|
||||
|
||||
public DonkeyWatcher(Disguise disguise) {
|
||||
super(disguise);
|
||||
}
|
||||
|
||||
}
|
@ -17,12 +17,12 @@ public class DroppedItemWatcher extends FlagWatcher
|
||||
|
||||
public ItemStack getItemStack()
|
||||
{
|
||||
return getValue(FlagType.DROPPED_ITEM).get();
|
||||
return getData(FlagType.DROPPED_ITEM).get();
|
||||
}
|
||||
|
||||
public void setItemStack(ItemStack item)
|
||||
{
|
||||
setValue(FlagType.DROPPED_ITEM, Optional.<ItemStack> of(item));
|
||||
setData(FlagType.DROPPED_ITEM, Optional.<ItemStack> of(item));
|
||||
sendData(FlagType.DROPPED_ITEM);
|
||||
}
|
||||
}
|
||||
|
@ -1,42 +1,42 @@
|
||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author Navid
|
||||
*/
|
||||
public class EnderCrystalWatcher extends FlagWatcher
|
||||
{
|
||||
public EnderCrystalWatcher(Disguise disguise)
|
||||
{
|
||||
super(disguise);
|
||||
}
|
||||
|
||||
public void setBeamTarget(BlockPosition position)
|
||||
{
|
||||
setValue(FlagType.ENDER_CRYSTAL_BEAM, Optional.of(position));
|
||||
sendData(FlagType.ENDER_CRYSTAL_BEAM);
|
||||
}
|
||||
|
||||
public Optional<BlockPosition> getBeamTarget()
|
||||
{
|
||||
return getValue(FlagType.ENDER_CRYSTAL_BEAM);
|
||||
}
|
||||
|
||||
public void setShowBottom(boolean bool)
|
||||
{
|
||||
setValue(FlagType.ENDER_CRYSTAL_PLATE, bool);
|
||||
sendData(FlagType.ENDER_CRYSTAL_PLATE);
|
||||
}
|
||||
|
||||
public boolean isShowBottom()
|
||||
{
|
||||
return getValue(FlagType.ENDER_CRYSTAL_PLATE);
|
||||
}
|
||||
|
||||
}
|
||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
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;
|
||||
|
||||
/**
|
||||
* @author Navid
|
||||
*/
|
||||
public class EnderCrystalWatcher extends FlagWatcher
|
||||
{
|
||||
public EnderCrystalWatcher(Disguise disguise)
|
||||
{
|
||||
super(disguise);
|
||||
}
|
||||
|
||||
public void setBeamTarget(BlockPosition position)
|
||||
{
|
||||
setData(FlagType.ENDER_CRYSTAL_BEAM, Optional.of(position));
|
||||
sendData(FlagType.ENDER_CRYSTAL_BEAM);
|
||||
}
|
||||
|
||||
public Optional<BlockPosition> getBeamTarget()
|
||||
{
|
||||
return getData(FlagType.ENDER_CRYSTAL_BEAM);
|
||||
}
|
||||
|
||||
public void setShowBottom(boolean bool)
|
||||
{
|
||||
setData(FlagType.ENDER_CRYSTAL_PLATE, bool);
|
||||
sendData(FlagType.ENDER_CRYSTAL_PLATE);
|
||||
}
|
||||
|
||||
public boolean isShowBottom()
|
||||
{
|
||||
return getData(FlagType.ENDER_CRYSTAL_PLATE);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -16,12 +16,12 @@ public class EnderDragonWatcher extends InsentientWatcher
|
||||
|
||||
public int getPhase()
|
||||
{
|
||||
return getValue(FlagType.ENDERDRAGON_PHASE);
|
||||
return getData(FlagType.ENDERDRAGON_PHASE);
|
||||
}
|
||||
|
||||
public void setPhase(int phase)
|
||||
{
|
||||
setValue(FlagType.ENDERDRAGON_PHASE, phase);
|
||||
setData(FlagType.ENDERDRAGON_PHASE, phase);
|
||||
sendData(FlagType.ENDERDRAGON_PHASE);
|
||||
}
|
||||
}
|
||||
|
@ -20,7 +20,7 @@ public class EndermanWatcher extends InsentientWatcher
|
||||
@Override
|
||||
public ItemStack getItemInMainHand()
|
||||
{
|
||||
Optional<WrappedBlockData> value = getValue(FlagType.ENDERMAN_ITEM);
|
||||
Optional<WrappedBlockData> value = getData(FlagType.ENDERMAN_ITEM);
|
||||
|
||||
if (value.isPresent())
|
||||
{
|
||||
@ -62,7 +62,7 @@ public class EndermanWatcher extends InsentientWatcher
|
||||
else
|
||||
optional = Optional.<WrappedBlockData> of(WrappedBlockData.createData(type, data));
|
||||
|
||||
setValue(FlagType.ENDERMAN_ITEM, optional);
|
||||
setData(FlagType.ENDERMAN_ITEM, optional);
|
||||
}
|
||||
|
||||
@Deprecated
|
||||
@ -73,12 +73,12 @@ public class EndermanWatcher extends InsentientWatcher
|
||||
|
||||
public boolean isAggressive()
|
||||
{
|
||||
return getValue(FlagType.ENDERMAN_AGRESSIVE);
|
||||
return getData(FlagType.ENDERMAN_AGRESSIVE);
|
||||
}
|
||||
|
||||
public void setAggressive(boolean isAggressive)
|
||||
{
|
||||
setValue(FlagType.ENDERMAN_AGRESSIVE, isAggressive);
|
||||
setData(FlagType.ENDERMAN_AGRESSIVE, isAggressive);
|
||||
sendData(FlagType.ENDERMAN_AGRESSIVE);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,20 @@
|
||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||
|
||||
public class EvokerWatcher extends InsentientWatcher {
|
||||
|
||||
public EvokerWatcher(Disguise disguise) {
|
||||
super(disguise);
|
||||
}
|
||||
|
||||
public void setSpellTicks(int spellTicks) {
|
||||
setData(FlagType.EVOKER_SPELL_TICKS, (byte) spellTicks);
|
||||
sendData(FlagType.EVOKER_SPELL_TICKS);
|
||||
}
|
||||
|
||||
public int getSpellTicks() {
|
||||
return getData(FlagType.EVOKER_SPELL_TICKS);
|
||||
}
|
||||
}
|
@ -18,12 +18,12 @@ public class FireworkWatcher extends FlagWatcher
|
||||
|
||||
public ItemStack getFirework()
|
||||
{
|
||||
if (getValue(FlagType.FIREWORK_ITEM) == null)
|
||||
if (getData(FlagType.FIREWORK_ITEM) == null)
|
||||
{
|
||||
return new ItemStack(Material.AIR);
|
||||
}
|
||||
|
||||
return (ItemStack) getValue(FlagType.FIREWORK_ITEM).get();
|
||||
return (ItemStack) getData(FlagType.FIREWORK_ITEM).get();
|
||||
}
|
||||
|
||||
public void setFirework(ItemStack newItem)
|
||||
@ -36,7 +36,7 @@ public class FireworkWatcher extends FlagWatcher
|
||||
newItem = newItem.clone();
|
||||
newItem.setAmount(1);
|
||||
|
||||
setValue(FlagType.FIREWORK_ITEM, Optional.<ItemStack> of(newItem));
|
||||
setData(FlagType.FIREWORK_ITEM, Optional.<ItemStack> of(newItem));
|
||||
sendData(FlagType.FIREWORK_ITEM);
|
||||
}
|
||||
|
||||
|
@ -13,13 +13,13 @@ public class FishingHookWatcher extends FlagWatcher
|
||||
|
||||
public void setHooked(int hookedId)
|
||||
{
|
||||
setValue(FlagType.FISHING_HOOK, hookedId + 1);
|
||||
setData(FlagType.FISHING_HOOK, hookedId + 1);
|
||||
sendData(FlagType.FISHING_HOOK);
|
||||
}
|
||||
|
||||
public int getHooked()
|
||||
{
|
||||
int hooked = getValue(FlagType.FISHING_HOOK);
|
||||
int hooked = getData(FlagType.FISHING_HOOK);
|
||||
|
||||
if (hooked > 0)
|
||||
hooked--;
|
||||
|
@ -13,12 +13,12 @@ public class GhastWatcher extends InsentientWatcher
|
||||
|
||||
public boolean isAggressive()
|
||||
{
|
||||
return getValue(FlagType.GHAST_AGRESSIVE);
|
||||
return getData(FlagType.GHAST_AGRESSIVE);
|
||||
}
|
||||
|
||||
public void setAggressive(boolean isAggressive)
|
||||
{
|
||||
setValue(FlagType.GHAST_AGRESSIVE, isAggressive);
|
||||
setData(FlagType.GHAST_AGRESSIVE, isAggressive);
|
||||
sendData(FlagType.GHAST_AGRESSIVE);
|
||||
}
|
||||
|
||||
|
@ -22,7 +22,7 @@ public class GuardianWatcher extends InsentientWatcher
|
||||
*/
|
||||
public boolean isTarget()
|
||||
{
|
||||
return ((int) getValue(FlagType.GUARDIAN_TARGET)) != 0;
|
||||
return ((int) getData(FlagType.GUARDIAN_TARGET)) != 0;
|
||||
}
|
||||
|
||||
/**
|
||||
@ -32,7 +32,7 @@ public class GuardianWatcher extends InsentientWatcher
|
||||
*/
|
||||
public void setTarget(int entityId)
|
||||
{
|
||||
setValue(FlagType.GUARDIAN_TARGET, entityId);
|
||||
setData(FlagType.GUARDIAN_TARGET, entityId);
|
||||
sendData(FlagType.GUARDIAN_TARGET);
|
||||
}
|
||||
|
||||
@ -53,7 +53,7 @@ public class GuardianWatcher extends InsentientWatcher
|
||||
if (player == null)
|
||||
return;
|
||||
|
||||
setValue(FlagType.GUARDIAN_TARGET, player.getEntityId());
|
||||
setData(FlagType.GUARDIAN_TARGET, player.getEntityId());
|
||||
sendData(FlagType.GUARDIAN_TARGET);
|
||||
}
|
||||
|
||||
@ -79,20 +79,20 @@ public class GuardianWatcher extends InsentientWatcher
|
||||
|
||||
protected boolean isGuardianFlag(int no)
|
||||
{
|
||||
return (getValue(FlagType.GUARDIAN_FLAG) & no) != 0;
|
||||
return (getData(FlagType.GUARDIAN_FLAG) & no) != 0;
|
||||
}
|
||||
|
||||
protected void setGuardianFlag(int no, boolean flag)
|
||||
{
|
||||
byte b0 = getValue(FlagType.GUARDIAN_FLAG);
|
||||
byte b0 = getData(FlagType.GUARDIAN_FLAG);
|
||||
|
||||
if (flag)
|
||||
{
|
||||
setValue(FlagType.GUARDIAN_FLAG, (byte) (b0 | no));
|
||||
setData(FlagType.GUARDIAN_FLAG, (byte) (b0 | no));
|
||||
}
|
||||
else
|
||||
{
|
||||
setValue(FlagType.GUARDIAN_FLAG, (byte) (b0 & -(no + 1)));
|
||||
setData(FlagType.GUARDIAN_FLAG, (byte) (b0 & -(no + 1)));
|
||||
}
|
||||
|
||||
sendData(FlagType.GUARDIAN_FLAG);
|
||||
|
@ -0,0 +1,101 @@
|
||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||
|
||||
public class HorseAbstractWatcher extends AgeableWatcher {
|
||||
public HorseAbstractWatcher(Disguise disguise) {
|
||||
super(disguise);
|
||||
}
|
||||
|
||||
public Optional<UUID> getOwner() {
|
||||
return getData(FlagType.HORSE_OWNER);
|
||||
}
|
||||
|
||||
public boolean hasChest() {
|
||||
return isHorseFlag(8);
|
||||
}
|
||||
|
||||
public boolean isBreedable() {
|
||||
return isHorseFlag(16);
|
||||
}
|
||||
|
||||
public boolean isGrazing() {
|
||||
return isHorseFlag(32);
|
||||
}
|
||||
|
||||
public boolean isMouthOpen() {
|
||||
return isHorseFlag(128);
|
||||
}
|
||||
|
||||
public boolean isRearing() {
|
||||
return isHorseFlag(64);
|
||||
}
|
||||
|
||||
public boolean isSaddled() {
|
||||
return isHorseFlag(4);
|
||||
}
|
||||
|
||||
public boolean isTamed() {
|
||||
return isHorseFlag(2);
|
||||
}
|
||||
|
||||
private boolean isHorseFlag(int i) {
|
||||
return (getHorseFlag() & i) != 0;
|
||||
}
|
||||
|
||||
private byte getHorseFlag() {
|
||||
return getData(FlagType.HORSE_META);
|
||||
}
|
||||
|
||||
public void setCanBreed(boolean breed) {
|
||||
setHorseFlag(16, breed);
|
||||
}
|
||||
|
||||
public void setCarryingChest(boolean chest) {
|
||||
setHorseFlag(8, chest);
|
||||
}
|
||||
|
||||
private void setHorseFlag(int i, boolean flag) {
|
||||
byte j = getData(FlagType.HORSE_META);
|
||||
|
||||
if (flag) {
|
||||
setData(FlagType.HORSE_META, (byte) (j | i));
|
||||
}
|
||||
else {
|
||||
setData(FlagType.HORSE_META, (byte) (j & ~i));
|
||||
}
|
||||
|
||||
sendData(FlagType.HORSE_META);
|
||||
}
|
||||
|
||||
public void setGrazing(boolean grazing) {
|
||||
setHorseFlag(32, grazing);
|
||||
}
|
||||
|
||||
public void setMouthOpen(boolean mouthOpen) {
|
||||
setHorseFlag(128, mouthOpen);
|
||||
}
|
||||
|
||||
public void setOwner(UUID uuid) {
|
||||
setData(FlagType.HORSE_OWNER, Optional.of(uuid));
|
||||
sendData(FlagType.HORSE_OWNER);
|
||||
}
|
||||
|
||||
public void setRearing(boolean rear) {
|
||||
setHorseFlag(64, rear);
|
||||
}
|
||||
|
||||
public void setSaddled(boolean saddled) {
|
||||
setHorseFlag(4, saddled);
|
||||
}
|
||||
|
||||
public void setTamed(boolean tamed) {
|
||||
setHorseFlag(2, tamed);
|
||||
}
|
||||
|
||||
}
|
@ -0,0 +1,20 @@
|
||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||
|
||||
public class HorseChestedWatcher extends HorseAbstractWatcher {
|
||||
|
||||
public HorseChestedWatcher(Disguise disguise) {
|
||||
super(disguise);
|
||||
}
|
||||
|
||||
public void setCarryingChest(boolean carryingChest) {
|
||||
setData(FlagType.HORSE_CARRYING_CHEST, carryingChest);
|
||||
sendData(FlagType.HORSE_CARRYING_CHEST);
|
||||
}
|
||||
|
||||
public boolean isCarryingChest() {
|
||||
return getData(FlagType.HORSE_CARRYING_CHEST);
|
||||
}
|
||||
}
|
@ -1,61 +1,30 @@
|
||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
import org.bukkit.Material;
|
||||
import org.bukkit.entity.Horse.Color;
|
||||
import org.bukkit.entity.Horse.Style;
|
||||
import org.bukkit.entity.Horse.Variant;
|
||||
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
|
||||
{
|
||||
public HorseWatcher(Disguise disguise)
|
||||
{
|
||||
public class HorseWatcher extends HorseAbstractWatcher {
|
||||
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()[getValue(FlagType.HORSE_VARIANT)];
|
||||
public Color getColor() {
|
||||
return Color.values()[((Integer) getData(FlagType.HORSE_COLOR) & 0xFF)];
|
||||
}
|
||||
|
||||
public void setVariant(Variant variant)
|
||||
{
|
||||
setVariant(variant.ordinal());
|
||||
}
|
||||
|
||||
public void setVariant(int variant)
|
||||
{
|
||||
if (variant < 0 || variant > 4)
|
||||
{
|
||||
variant = 0; // Crashing people is mean
|
||||
}
|
||||
|
||||
setValue(FlagType.HORSE_VARIANT, variant);
|
||||
sendData(FlagType.HORSE_VARIANT);
|
||||
}
|
||||
|
||||
public Color getColor()
|
||||
{
|
||||
return Color.values()[((Integer) getValue(FlagType.HORSE_COLOR) & 0xFF)];
|
||||
}
|
||||
|
||||
public ItemStack getHorseArmor()
|
||||
{
|
||||
public ItemStack getHorseArmor() {
|
||||
int horseValue = getHorseArmorAsInt();
|
||||
|
||||
switch (horseValue)
|
||||
{
|
||||
switch (horseValue) {
|
||||
case 1:
|
||||
return new ItemStack(Material.IRON_BARDING);
|
||||
case 2:
|
||||
@ -69,127 +38,42 @@ public class HorseWatcher extends AgeableWatcher
|
||||
return null;
|
||||
}
|
||||
|
||||
protected int getHorseArmorAsInt()
|
||||
{
|
||||
return getValue(FlagType.HORSE_ARMOR);
|
||||
public Style getStyle() {
|
||||
return Style.values()[(getData(FlagType.HORSE_COLOR) >>> 8)];
|
||||
}
|
||||
|
||||
public Optional<UUID> getOwner()
|
||||
{
|
||||
return getValue(FlagType.HORSE_OWNER);
|
||||
}
|
||||
|
||||
public Style getStyle()
|
||||
{
|
||||
return Style.values()[(getValue(FlagType.HORSE_COLOR) >>> 8)];
|
||||
}
|
||||
|
||||
public boolean hasChest()
|
||||
{
|
||||
return isHorseFlag(8);
|
||||
}
|
||||
|
||||
public boolean isBreedable()
|
||||
{
|
||||
return isHorseFlag(16);
|
||||
}
|
||||
|
||||
public boolean isGrazing()
|
||||
{
|
||||
return isHorseFlag(32);
|
||||
}
|
||||
|
||||
public boolean isMouthOpen()
|
||||
{
|
||||
return isHorseFlag(128);
|
||||
}
|
||||
|
||||
public boolean isRearing()
|
||||
{
|
||||
return isHorseFlag(64);
|
||||
}
|
||||
|
||||
public boolean isSaddled()
|
||||
{
|
||||
return isHorseFlag(4);
|
||||
}
|
||||
|
||||
public boolean isTamed()
|
||||
{
|
||||
return isHorseFlag(2);
|
||||
}
|
||||
|
||||
private boolean isHorseFlag(int i)
|
||||
{
|
||||
return (getHorseFlag() & i) != 0;
|
||||
}
|
||||
|
||||
private byte getHorseFlag()
|
||||
{
|
||||
return getValue(FlagType.HORSE_META);
|
||||
}
|
||||
|
||||
public void setCanBreed(boolean breed)
|
||||
{
|
||||
setHorseFlag(16, breed);
|
||||
}
|
||||
|
||||
public void setCarryingChest(boolean chest)
|
||||
{
|
||||
setHorseFlag(8, chest);
|
||||
}
|
||||
|
||||
public void setColor(Color color)
|
||||
{
|
||||
setValue(FlagType.HORSE_COLOR, color.ordinal() & 0xFF | getStyle().ordinal() << 8);
|
||||
public void setColor(Color color) {
|
||||
setData(FlagType.HORSE_COLOR, color.ordinal() & 0xFF | getStyle().ordinal() << 8);
|
||||
sendData(FlagType.HORSE_COLOR);
|
||||
}
|
||||
|
||||
private void setHorseFlag(int i, boolean flag)
|
||||
{
|
||||
byte j = getValue(FlagType.HORSE_META);
|
||||
|
||||
if (flag)
|
||||
{
|
||||
setValue(FlagType.HORSE_META, (byte) (j | i));
|
||||
}
|
||||
else
|
||||
{
|
||||
setValue(FlagType.HORSE_META, (byte) (j & ~i));
|
||||
}
|
||||
|
||||
sendData(FlagType.HORSE_META);
|
||||
protected int getHorseArmorAsInt() {
|
||||
return getData(FlagType.HORSE_ARMOR);
|
||||
}
|
||||
|
||||
public void setGrazing(boolean grazing)
|
||||
{
|
||||
setHorseFlag(32, grazing);
|
||||
}
|
||||
|
||||
protected void setHorseArmor(int armor)
|
||||
{
|
||||
setValue(FlagType.HORSE_ARMOR, armor);
|
||||
protected void setHorseArmor(int armor) {
|
||||
setData(FlagType.HORSE_ARMOR, armor);
|
||||
sendData(FlagType.HORSE_ARMOR);
|
||||
}
|
||||
|
||||
public void setHorseArmor(ItemStack item)
|
||||
{
|
||||
public void setStyle(Style style) {
|
||||
setData(FlagType.HORSE_COLOR, getColor().ordinal() & 0xFF | style.ordinal() << 8);
|
||||
sendData(FlagType.HORSE_COLOR);
|
||||
}
|
||||
|
||||
public void setHorseArmor(ItemStack item) {
|
||||
int value = 0;
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
if (item != null) {
|
||||
Material mat = item.getType();
|
||||
|
||||
if (mat == Material.IRON_BARDING)
|
||||
{
|
||||
if (mat == Material.IRON_BARDING) {
|
||||
value = 1;
|
||||
}
|
||||
else if (mat == Material.GOLD_BARDING)
|
||||
{
|
||||
else if (mat == Material.GOLD_BARDING) {
|
||||
value = 2;
|
||||
}
|
||||
else if (mat == Material.DIAMOND_BARDING)
|
||||
{
|
||||
else if (mat == Material.DIAMOND_BARDING) {
|
||||
value = 3;
|
||||
}
|
||||
}
|
||||
@ -197,36 +81,4 @@ public class HorseWatcher extends AgeableWatcher
|
||||
setHorseArmor(value);
|
||||
}
|
||||
|
||||
public void setMouthOpen(boolean mouthOpen)
|
||||
{
|
||||
setHorseFlag(128, mouthOpen);
|
||||
}
|
||||
|
||||
public void setOwner(UUID uuid)
|
||||
{
|
||||
setValue(FlagType.HORSE_OWNER, Optional.of(uuid));
|
||||
sendData(FlagType.HORSE_OWNER);
|
||||
}
|
||||
|
||||
public void setRearing(boolean rear)
|
||||
{
|
||||
setHorseFlag(64, rear);
|
||||
}
|
||||
|
||||
public void setSaddled(boolean saddled)
|
||||
{
|
||||
setHorseFlag(4, saddled);
|
||||
}
|
||||
|
||||
public void setStyle(Style style)
|
||||
{
|
||||
setValue(FlagType.HORSE_COLOR, getColor().ordinal() & 0xFF | style.ordinal() << 8);
|
||||
sendData(FlagType.HORSE_COLOR);
|
||||
}
|
||||
|
||||
public void setTamed(boolean tamed)
|
||||
{
|
||||
setHorseFlag(2, tamed);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -36,20 +36,20 @@ public class InsentientWatcher extends LivingWatcher
|
||||
|
||||
private void setInsentientFlag(int i, boolean flag)
|
||||
{
|
||||
byte b0 = (byte) getValue(FlagType.INSENTIENT_META);
|
||||
byte b0 = (byte) getData(FlagType.INSENTIENT_META);
|
||||
|
||||
if (flag)
|
||||
{
|
||||
setValue(FlagType.INSENTIENT_META, (byte) (b0 | 1 << i));
|
||||
setData(FlagType.INSENTIENT_META, (byte) (b0 | 1 << i));
|
||||
}
|
||||
else
|
||||
{
|
||||
setValue(FlagType.INSENTIENT_META, (byte) (b0 & (~1 << i)));
|
||||
setData(FlagType.INSENTIENT_META, (byte) (b0 & (~1 << i)));
|
||||
}
|
||||
}
|
||||
|
||||
private boolean getInsentientFlag(int i)
|
||||
{
|
||||
return ((byte) getValue(FlagType.INSENTIENT_META) & 1 << i) != 0;
|
||||
return ((byte) getData(FlagType.INSENTIENT_META) & 1 << i) != 0;
|
||||
}
|
||||
}
|
||||
|
@ -18,17 +18,17 @@ public class ItemFrameWatcher extends FlagWatcher
|
||||
|
||||
public ItemStack getItem()
|
||||
{
|
||||
if (getValue(FlagType.ITEMFRAME_ITEM) == null)
|
||||
if (getData(FlagType.ITEMFRAME_ITEM) == null)
|
||||
{
|
||||
return new ItemStack(Material.AIR);
|
||||
}
|
||||
|
||||
return (ItemStack) getValue(FlagType.ITEMFRAME_ITEM).get();
|
||||
return (ItemStack) getData(FlagType.ITEMFRAME_ITEM).get();
|
||||
}
|
||||
|
||||
public int getRotation()
|
||||
{
|
||||
return getValue(FlagType.ITEMFRAME_ROTATION);
|
||||
return getData(FlagType.ITEMFRAME_ROTATION);
|
||||
}
|
||||
|
||||
public void setItem(ItemStack newItem)
|
||||
@ -41,13 +41,13 @@ public class ItemFrameWatcher extends FlagWatcher
|
||||
newItem = newItem.clone();
|
||||
newItem.setAmount(1);
|
||||
|
||||
setValue(FlagType.ITEMFRAME_ITEM, Optional.<ItemStack> of(newItem));
|
||||
setData(FlagType.ITEMFRAME_ITEM, Optional.<ItemStack> of(newItem));
|
||||
sendData(FlagType.ITEMFRAME_ITEM);
|
||||
}
|
||||
|
||||
public void setRotation(int rotation)
|
||||
{
|
||||
setValue(FlagType.ITEMFRAME_ROTATION, rotation % 4);
|
||||
setData(FlagType.ITEMFRAME_ROTATION, rotation % 4);
|
||||
sendData(FlagType.ITEMFRAME_ROTATION);
|
||||
}
|
||||
|
||||
|
@ -82,7 +82,7 @@ public class LivingWatcher extends FlagWatcher
|
||||
|
||||
public float getHealth()
|
||||
{
|
||||
return (float) getValue(FlagType.LIVING_HEALTH);
|
||||
return (float) getData(FlagType.LIVING_HEALTH);
|
||||
}
|
||||
|
||||
public double getMaxHealth()
|
||||
@ -92,7 +92,7 @@ public class LivingWatcher extends FlagWatcher
|
||||
|
||||
public boolean isPotionParticlesAmbient()
|
||||
{
|
||||
return (boolean) getValue(FlagType.LIVING_POTION_AMBIENT);
|
||||
return (boolean) getData(FlagType.LIVING_POTION_AMBIENT);
|
||||
}
|
||||
|
||||
private int getPotions()
|
||||
@ -152,30 +152,30 @@ public class LivingWatcher extends FlagWatcher
|
||||
|
||||
public void setPotionParticlesAmbient(boolean particles)
|
||||
{
|
||||
setValue(FlagType.LIVING_POTION_AMBIENT, particles);
|
||||
setData(FlagType.LIVING_POTION_AMBIENT, particles);
|
||||
sendData(FlagType.LIVING_POTION_AMBIENT);
|
||||
}
|
||||
|
||||
private void sendPotionEffects()
|
||||
{
|
||||
setValue(FlagType.LIVING_POTIONS, getPotions());
|
||||
setData(FlagType.LIVING_POTIONS, getPotions());
|
||||
sendData(FlagType.LIVING_POTIONS);
|
||||
}
|
||||
|
||||
public void setHealth(float health)
|
||||
{
|
||||
setValue(FlagType.LIVING_HEALTH, health);
|
||||
setData(FlagType.LIVING_HEALTH, health);
|
||||
sendData(FlagType.LIVING_HEALTH);
|
||||
}
|
||||
|
||||
public int getArrowsSticking()
|
||||
{
|
||||
return (int) getValue(FlagType.LIVING_ARROWS);
|
||||
return (int) getData(FlagType.LIVING_ARROWS);
|
||||
}
|
||||
|
||||
public void setArrowsSticking(int arrowsNo)
|
||||
{
|
||||
setValue(FlagType.LIVING_ARROWS, arrowsNo);
|
||||
setData(FlagType.LIVING_ARROWS, arrowsNo);
|
||||
sendData(FlagType.LIVING_ARROWS);
|
||||
}
|
||||
|
||||
|
@ -0,0 +1,42 @@
|
||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
import org.bukkit.entity.Llama;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.AnimalColor;
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||
|
||||
public class LlamaWatcher extends HorseChestedWatcher {
|
||||
|
||||
public LlamaWatcher(Disguise disguise) {
|
||||
super(disguise);
|
||||
}
|
||||
|
||||
public void setColor(Llama.Color color) {
|
||||
setData(FlagType.LLAMA_COLOR, color.ordinal());
|
||||
sendData(FlagType.LLAMA_COLOR);
|
||||
}
|
||||
|
||||
public Llama.Color getColor() {
|
||||
return Llama.Color.values()[getData(FlagType.LLAMA_COLOR)];
|
||||
}
|
||||
|
||||
public void setCarpet(AnimalColor color) {
|
||||
setData(FlagType.LLAMA_CARPET, color.ordinal());
|
||||
sendData(FlagType.LLAMA_CARPET);
|
||||
}
|
||||
|
||||
public AnimalColor getCarpet() {
|
||||
return AnimalColor.getColor(getData(FlagType.LLAMA_CARPET));
|
||||
}
|
||||
|
||||
public void setStrength(int strength) {
|
||||
setData(FlagType.LLAMA_STRENGTH, strength);
|
||||
sendData(FlagType.LLAMA_STRENGTH);
|
||||
}
|
||||
|
||||
public int getStrength() {
|
||||
return getData(FlagType.LLAMA_STRENGTH);
|
||||
}
|
||||
|
||||
}
|
@ -16,20 +16,20 @@ public class MinecartWatcher extends FlagWatcher
|
||||
|
||||
public ItemStack getBlockInCart()
|
||||
{
|
||||
int id = (int) getValue(FlagType.MINECART_BLOCK) & 0xffff;
|
||||
int data = (int) getValue(FlagType.MINECART_BLOCK) >> 16;
|
||||
int id = (int) getData(FlagType.MINECART_BLOCK) & 0xffff;
|
||||
int data = (int) getData(FlagType.MINECART_BLOCK) >> 16;
|
||||
|
||||
return new ItemStack(id, 1, (short) data);
|
||||
}
|
||||
|
||||
public int getBlockYOffset()
|
||||
{
|
||||
return (int) getValue(FlagType.MINECART_BLOCK_Y);
|
||||
return (int) getData(FlagType.MINECART_BLOCK_Y);
|
||||
}
|
||||
|
||||
public boolean isViewBlockInCart()
|
||||
{
|
||||
return (boolean) getValue(FlagType.MINECART_BLOCK_VISIBLE);
|
||||
return (boolean) getData(FlagType.MINECART_BLOCK_VISIBLE);
|
||||
}
|
||||
|
||||
public void setBlockInCart(ItemStack item)
|
||||
@ -37,21 +37,21 @@ public class MinecartWatcher extends FlagWatcher
|
||||
int id = item.getTypeId();
|
||||
int data = item.getDurability();
|
||||
|
||||
setValue(FlagType.MINECART_BLOCK, id & 0xffff | data << 16);
|
||||
setValue(FlagType.MINECART_BLOCK_VISIBLE, true); // Show block
|
||||
setData(FlagType.MINECART_BLOCK, id & 0xffff | data << 16);
|
||||
setData(FlagType.MINECART_BLOCK_VISIBLE, true); // Show block
|
||||
|
||||
sendData(FlagType.MINECART_BLOCK);
|
||||
}
|
||||
|
||||
public void setBlockOffset(int i)
|
||||
{
|
||||
setValue(FlagType.MINECART_BLOCK_Y, i);
|
||||
setData(FlagType.MINECART_BLOCK_Y, i);
|
||||
sendData(FlagType.MINECART_BLOCK_Y);
|
||||
}
|
||||
|
||||
public void setViewBlockInCart(boolean viewBlock)
|
||||
{
|
||||
setValue(FlagType.MINECART_BLOCK_VISIBLE, viewBlock);
|
||||
setData(FlagType.MINECART_BLOCK_VISIBLE, viewBlock);
|
||||
sendData(FlagType.MINECART_BLOCK_VISIBLE);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
|
||||
public class MuleWatcher extends HorseChestedWatcher {
|
||||
|
||||
public MuleWatcher(Disguise disguise) {
|
||||
super(disguise);
|
||||
}
|
||||
|
||||
}
|
@ -1,27 +1,27 @@
|
||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
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 OcelotWatcher(Disguise disguise)
|
||||
{
|
||||
super(disguise);
|
||||
}
|
||||
|
||||
public Type getType()
|
||||
{
|
||||
return Ocelot.Type.getType(getValue(FlagType.OCELOT_TYPE));
|
||||
}
|
||||
|
||||
public void setType(Type newType)
|
||||
{
|
||||
setValue(FlagType.OCELOT_TYPE, newType.getId());
|
||||
sendData(FlagType.OCELOT_TYPE);
|
||||
}
|
||||
}
|
||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
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 OcelotWatcher(Disguise disguise)
|
||||
{
|
||||
super(disguise);
|
||||
}
|
||||
|
||||
public Type getType()
|
||||
{
|
||||
return Ocelot.Type.getType(getData(FlagType.OCELOT_TYPE));
|
||||
}
|
||||
|
||||
public void setType(Type newType)
|
||||
{
|
||||
setData(FlagType.OCELOT_TYPE, newType.getId());
|
||||
sendData(FlagType.OCELOT_TYPE);
|
||||
}
|
||||
}
|
||||
|
@ -1,24 +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 PigWatcher(Disguise disguise)
|
||||
{
|
||||
super(disguise);
|
||||
}
|
||||
|
||||
public boolean isSaddled()
|
||||
{
|
||||
return (boolean) getValue(FlagType.PIG_SADDLED);
|
||||
}
|
||||
|
||||
public void setSaddled(boolean isSaddled)
|
||||
{
|
||||
setValue(FlagType.PIG_SADDLED, isSaddled);
|
||||
sendData(FlagType.PIG_SADDLED);
|
||||
}
|
||||
}
|
||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||
|
||||
public class PigWatcher extends AgeableWatcher
|
||||
{
|
||||
|
||||
public PigWatcher(Disguise disguise)
|
||||
{
|
||||
super(disguise);
|
||||
}
|
||||
|
||||
public boolean isSaddled()
|
||||
{
|
||||
return (boolean) getData(FlagType.PIG_SADDLED);
|
||||
}
|
||||
|
||||
public void setSaddled(boolean isSaddled)
|
||||
{
|
||||
setData(FlagType.PIG_SADDLED, isSaddled);
|
||||
sendData(FlagType.PIG_SADDLED);
|
||||
}
|
||||
}
|
||||
|
@ -26,7 +26,7 @@ public class PlayerWatcher extends LivingWatcher
|
||||
{
|
||||
super(disguise);
|
||||
|
||||
setValue(FlagType.PLAYER_SKIN, FlagType.PLAYER_SKIN.getDefault());
|
||||
setData(FlagType.PLAYER_SKIN, FlagType.PLAYER_SKIN.getDefault());
|
||||
}
|
||||
|
||||
@Override
|
||||
@ -39,13 +39,13 @@ public class PlayerWatcher extends LivingWatcher
|
||||
|
||||
public void setMainHand(MainHand mainHand)
|
||||
{
|
||||
setValue(FlagType.PLAYER_HAND, (byte) mainHand.ordinal());
|
||||
setData(FlagType.PLAYER_HAND, (byte) mainHand.ordinal());
|
||||
sendData(FlagType.PLAYER_HAND);
|
||||
}
|
||||
|
||||
public MainHand getMainHand()
|
||||
{
|
||||
return MainHand.values()[getValue(FlagType.PLAYER_HAND)];
|
||||
return MainHand.values()[getData(FlagType.PLAYER_HAND)];
|
||||
}
|
||||
|
||||
public BlockFace getSleepingDirection()
|
||||
@ -75,7 +75,7 @@ public class PlayerWatcher extends LivingWatcher
|
||||
|
||||
private boolean isSkinFlag(int i)
|
||||
{
|
||||
return ((byte) getValue(FlagType.PLAYER_SKIN) & 1 << i) != 0;
|
||||
return ((byte) getData(FlagType.PLAYER_SKIN) & 1 << i) != 0;
|
||||
}
|
||||
|
||||
public boolean isCapeEnabled()
|
||||
@ -257,15 +257,15 @@ public class PlayerWatcher extends LivingWatcher
|
||||
|
||||
private void setSkinFlags(int i, boolean flag)
|
||||
{
|
||||
byte b0 = (byte) getValue(FlagType.PLAYER_SKIN);
|
||||
byte b0 = (byte) getData(FlagType.PLAYER_SKIN);
|
||||
|
||||
if (flag)
|
||||
{
|
||||
setValue(FlagType.PLAYER_SKIN, (byte) (b0 | 1 << i));
|
||||
setData(FlagType.PLAYER_SKIN, (byte) (b0 | 1 << i));
|
||||
}
|
||||
else
|
||||
{
|
||||
setValue(FlagType.PLAYER_SKIN, (byte) (b0 & (~1 << i)));
|
||||
setData(FlagType.PLAYER_SKIN, (byte) (b0 & (~1 << i)));
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -12,12 +12,12 @@ public class PolarBearWatcher extends AgeableWatcher
|
||||
|
||||
public void setStanding(boolean standing)
|
||||
{
|
||||
setValue(FlagType.POLAR_BEAR_STANDING, standing);
|
||||
setData(FlagType.POLAR_BEAR_STANDING, standing);
|
||||
sendData(FlagType.POLAR_BEAR_STANDING);
|
||||
}
|
||||
|
||||
public boolean isStanding()
|
||||
{
|
||||
return getValue(FlagType.POLAR_BEAR_STANDING);
|
||||
return getData(FlagType.POLAR_BEAR_STANDING);
|
||||
}
|
||||
}
|
||||
|
@ -1,28 +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 RabbitWatcher(Disguise disguise)
|
||||
{
|
||||
super(disguise);
|
||||
setType(RabbitType.values()[DisguiseUtilities.random.nextInt(RabbitType.values().length)]);
|
||||
}
|
||||
|
||||
public RabbitType getType()
|
||||
{
|
||||
return RabbitType.getType((int) getValue(FlagType.RABBIT_TYPE));
|
||||
}
|
||||
|
||||
public void setType(RabbitType type)
|
||||
{
|
||||
setValue(FlagType.RABBIT_TYPE, type.getTypeId());
|
||||
sendData(FlagType.RABBIT_TYPE);
|
||||
}
|
||||
|
||||
}
|
||||
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 RabbitWatcher(Disguise disguise)
|
||||
{
|
||||
super(disguise);
|
||||
setType(RabbitType.values()[DisguiseUtilities.random.nextInt(RabbitType.values().length)]);
|
||||
}
|
||||
|
||||
public RabbitType getType()
|
||||
{
|
||||
return RabbitType.getType((int) getData(FlagType.RABBIT_TYPE));
|
||||
}
|
||||
|
||||
public void setType(RabbitType type)
|
||||
{
|
||||
setData(FlagType.RABBIT_TYPE, type.getTypeId());
|
||||
sendData(FlagType.RABBIT_TYPE);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -1,57 +1,57 @@
|
||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
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 SheepWatcher(Disguise disguise)
|
||||
{
|
||||
super(disguise);
|
||||
|
||||
setValue(FlagType.SHEEP_WOOL, (byte) 0);
|
||||
}
|
||||
|
||||
public AnimalColor getColor()
|
||||
{
|
||||
return AnimalColor.getColor(((int) getValue(FlagType.SHEEP_WOOL) & 15));
|
||||
}
|
||||
|
||||
public boolean isSheared()
|
||||
{
|
||||
return ((byte) getValue(FlagType.SHEEP_WOOL) & 16) != 0;
|
||||
}
|
||||
|
||||
public void setColor(AnimalColor color)
|
||||
{
|
||||
setColor(DyeColor.getByWoolData((byte) color.getId()));
|
||||
}
|
||||
|
||||
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(FlagType.SHEEP_WOOL);
|
||||
|
||||
if (flag)
|
||||
{
|
||||
setValue(FlagType.SHEEP_WOOL, (byte) (b0 | 16));
|
||||
}
|
||||
else
|
||||
{
|
||||
setValue(FlagType.SHEEP_WOOL, (byte) (b0 & -17));
|
||||
}
|
||||
|
||||
sendData(FlagType.SHEEP_WOOL);
|
||||
}
|
||||
}
|
||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
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 SheepWatcher(Disguise disguise)
|
||||
{
|
||||
super(disguise);
|
||||
|
||||
setData(FlagType.SHEEP_WOOL, (byte) 0);
|
||||
}
|
||||
|
||||
public AnimalColor getColor()
|
||||
{
|
||||
return AnimalColor.getColor(((int) getData(FlagType.SHEEP_WOOL) & 15));
|
||||
}
|
||||
|
||||
public boolean isSheared()
|
||||
{
|
||||
return ((byte) getData(FlagType.SHEEP_WOOL) & 16) != 0;
|
||||
}
|
||||
|
||||
public void setColor(AnimalColor color)
|
||||
{
|
||||
setColor(DyeColor.getByWoolData((byte) color.getId()));
|
||||
}
|
||||
|
||||
public void setColor(DyeColor color)
|
||||
{
|
||||
byte b0 = (byte) getData(FlagType.SHEEP_WOOL);
|
||||
|
||||
setData(FlagType.SHEEP_WOOL, (byte) (b0 & 240 | color.getWoolData() & 15));
|
||||
sendData(FlagType.SHEEP_WOOL);
|
||||
}
|
||||
|
||||
public void setSheared(boolean flag)
|
||||
{
|
||||
byte b0 = (byte) getData(FlagType.SHEEP_WOOL);
|
||||
|
||||
if (flag)
|
||||
{
|
||||
setData(FlagType.SHEEP_WOOL, (byte) (b0 | 16));
|
||||
}
|
||||
else
|
||||
{
|
||||
setData(FlagType.SHEEP_WOOL, (byte) (b0 & -17));
|
||||
}
|
||||
|
||||
sendData(FlagType.SHEEP_WOOL);
|
||||
}
|
||||
}
|
||||
|
@ -6,57 +6,54 @@ import com.comphenix.protocol.wrappers.BlockPosition;
|
||||
import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
|
||||
import com.google.common.base.Optional;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.AnimalColor;
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||
|
||||
/**
|
||||
* @author Navid
|
||||
*/
|
||||
public class ShulkerWatcher extends InsentientWatcher
|
||||
{
|
||||
public class ShulkerWatcher extends InsentientWatcher {
|
||||
|
||||
public ShulkerWatcher(Disguise disguise)
|
||||
{
|
||||
public ShulkerWatcher(Disguise disguise) {
|
||||
super(disguise);
|
||||
}
|
||||
|
||||
public BlockFace getFacingDirection()
|
||||
{
|
||||
return BlockFace.valueOf(getValue(FlagType.SHULKER_FACING).name());
|
||||
public BlockFace getFacingDirection() {
|
||||
return BlockFace.valueOf(getData(FlagType.SHULKER_FACING).name());
|
||||
}
|
||||
|
||||
public void setFacingDirection(BlockFace face)
|
||||
{
|
||||
setValue(FlagType.SHULKER_FACING, Direction.valueOf(face.name()));
|
||||
public void setFacingDirection(BlockFace face) {
|
||||
setData(FlagType.SHULKER_FACING, Direction.valueOf(face.name()));
|
||||
sendData(FlagType.SHULKER_FACING);
|
||||
}
|
||||
|
||||
public BlockPosition getAttachmentPosition()
|
||||
{
|
||||
return getValue(FlagType.SHULKER_ATTACHED).get();
|
||||
public BlockPosition getAttachmentPosition() {
|
||||
return getData(FlagType.SHULKER_ATTACHED).get();
|
||||
}
|
||||
|
||||
public void setAttachmentPosition(BlockPosition pos)
|
||||
{
|
||||
setValue(FlagType.SHULKER_ATTACHED, Optional.of(pos));
|
||||
public void setAttachmentPosition(BlockPosition pos) {
|
||||
setData(FlagType.SHULKER_ATTACHED, Optional.of(pos));
|
||||
sendData(FlagType.SHULKER_ATTACHED);
|
||||
}
|
||||
|
||||
public int getShieldHeight()
|
||||
{
|
||||
return getValue(FlagType.SHULKER_PEEKING);
|
||||
public int getShieldHeight() {
|
||||
return getData(FlagType.SHULKER_PEEKING);
|
||||
}
|
||||
|
||||
public void setShieldHeight(int newHeight)
|
||||
{
|
||||
public void setShieldHeight(int newHeight) {
|
||||
if (newHeight < 0)
|
||||
newHeight = 0;
|
||||
|
||||
if (newHeight > 127)
|
||||
newHeight = 127;
|
||||
|
||||
setValue(FlagType.SHULKER_PEEKING, (byte) newHeight);
|
||||
setData(FlagType.SHULKER_PEEKING, (byte) newHeight);
|
||||
sendData(FlagType.SHULKER_PEEKING);
|
||||
}
|
||||
|
||||
public void setColor(AnimalColor color) {
|
||||
setData(FlagType.SHULKER_COLOR, (byte) color.getId());
|
||||
sendData(FlagType.SHULKER_COLOR);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
|
||||
public class SkeletonHorseWatcher extends HorseAbstractWatcher {
|
||||
|
||||
public SkeletonHorseWatcher(Disguise disguise) {
|
||||
super(disguise);
|
||||
}
|
||||
|
||||
}
|
@ -17,23 +17,23 @@ public class SkeletonWatcher extends InsentientWatcher
|
||||
|
||||
public void setSwingArms(boolean swingingArms)
|
||||
{
|
||||
setValue(FlagType.SKELETON_SWING_ARMS, swingingArms);
|
||||
setData(FlagType.SKELETON_SWING_ARMS, swingingArms);
|
||||
sendData(FlagType.SKELETON_SWING_ARMS);
|
||||
}
|
||||
|
||||
public boolean isSwingArms()
|
||||
{
|
||||
return getValue(FlagType.SKELETON_SWING_ARMS);
|
||||
return getData(FlagType.SKELETON_SWING_ARMS);
|
||||
}
|
||||
|
||||
public void setType(SkeletonType type)
|
||||
{
|
||||
setValue(FlagType.SKELETON_TYPE, type.ordinal());
|
||||
setData(FlagType.SKELETON_TYPE, type.ordinal());
|
||||
sendData(FlagType.SKELETON_TYPE);
|
||||
}
|
||||
|
||||
public SkeletonType getType()
|
||||
{
|
||||
return SkeletonType.values()[getValue(FlagType.SKELETON_TYPE)];
|
||||
return SkeletonType.values()[getData(FlagType.SKELETON_TYPE)];
|
||||
}
|
||||
}
|
||||
|
@ -15,7 +15,7 @@ public class SlimeWatcher extends InsentientWatcher
|
||||
|
||||
public int getSize()
|
||||
{
|
||||
return (int) getValue(FlagType.SLIME_SIZE);
|
||||
return (int) getData(FlagType.SLIME_SIZE);
|
||||
}
|
||||
|
||||
public void setSize(int size)
|
||||
@ -25,7 +25,7 @@ public class SlimeWatcher extends InsentientWatcher
|
||||
size = 1;
|
||||
}
|
||||
|
||||
setValue(FlagType.SLIME_SIZE, size);
|
||||
setData(FlagType.SLIME_SIZE, size);
|
||||
sendData(FlagType.SLIME_SIZE);
|
||||
}
|
||||
|
||||
|
@ -12,12 +12,12 @@ public class SnowmanWatcher extends InsentientWatcher
|
||||
|
||||
public void setHat(boolean hat)
|
||||
{
|
||||
setValue(FlagType.SNOWMAN_HAT, (byte) (hat ? 0 : 16));
|
||||
setData(FlagType.SNOWMAN_HAT, (byte) (hat ? 0 : 16));
|
||||
sendData(FlagType.SNOWMAN_HAT);
|
||||
}
|
||||
|
||||
public boolean isHat()
|
||||
{
|
||||
return getValue(FlagType.SNOWMAN_HAT) == 0;
|
||||
return getData(FlagType.SNOWMAN_HAT) == 0;
|
||||
}
|
||||
}
|
||||
|
@ -12,12 +12,12 @@ public class SpiderWatcher extends InsentientWatcher
|
||||
|
||||
public void setClimbing(boolean climbing)
|
||||
{
|
||||
setValue(FlagType.SPIDER_CLIMB, (byte) (climbing ? 1 : 0));
|
||||
setData(FlagType.SPIDER_CLIMB, (byte) (climbing ? 1 : 0));
|
||||
sendData(FlagType.SPIDER_CLIMB);
|
||||
}
|
||||
|
||||
public boolean isClimbing()
|
||||
{
|
||||
return getValue(FlagType.SPIDER_CLIMB) == (byte) 1;
|
||||
return getData(FlagType.SPIDER_CLIMB) == (byte) 1;
|
||||
}
|
||||
}
|
||||
|
@ -34,13 +34,13 @@ public class SplashPotionWatcher extends FlagWatcher
|
||||
|
||||
public void setSplashPotion(ItemStack item)
|
||||
{
|
||||
setValue(FlagType.SPLASH_POTION_ITEM, Optional.of(item));
|
||||
setData(FlagType.SPLASH_POTION_ITEM, Optional.of(item));
|
||||
sendData(FlagType.SPLASH_POTION_ITEM);
|
||||
}
|
||||
|
||||
public ItemStack getSplashPotion()
|
||||
{
|
||||
return getValue(FlagType.SPLASH_POTION_ITEM).get();
|
||||
return getData(FlagType.SPLASH_POTION_ITEM).get();
|
||||
}
|
||||
|
||||
public void setPotionId(int newPotionId)
|
||||
|
@ -1,69 +1,69 @@
|
||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public Optional<UUID> getOwner()
|
||||
{
|
||||
return getValue(FlagType.TAMEABLE_OWNER);
|
||||
}
|
||||
|
||||
public boolean isSitting()
|
||||
{
|
||||
return isTameableFlag(1);
|
||||
}
|
||||
|
||||
public boolean isTamed()
|
||||
{
|
||||
return isTameableFlag(4);
|
||||
}
|
||||
|
||||
protected boolean isTameableFlag(int no)
|
||||
{
|
||||
return ((byte) getValue(FlagType.TAMEABLE_META) & no) != 0;
|
||||
}
|
||||
|
||||
protected void setTameableFlag(int no, boolean flag)
|
||||
{
|
||||
byte value = (byte) getValue(FlagType.TAMEABLE_META);
|
||||
|
||||
if (flag)
|
||||
{
|
||||
setValue(FlagType.TAMEABLE_META, (byte) (value | no));
|
||||
}
|
||||
else
|
||||
{
|
||||
setValue(FlagType.TAMEABLE_META, (byte) (value & -(no + 1)));
|
||||
}
|
||||
|
||||
sendData(FlagType.TAMEABLE_META);
|
||||
}
|
||||
|
||||
public void setOwner(UUID owner)
|
||||
{
|
||||
setValue(FlagType.TAMEABLE_OWNER, Optional.of(owner));
|
||||
sendData(FlagType.TAMEABLE_OWNER);
|
||||
}
|
||||
|
||||
public void setSitting(boolean sitting)
|
||||
{
|
||||
setTameableFlag(1, sitting);
|
||||
}
|
||||
|
||||
public void setTamed(boolean tamed)
|
||||
{
|
||||
setTameableFlag(4, tamed);
|
||||
}
|
||||
|
||||
}
|
||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
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);
|
||||
}
|
||||
|
||||
public Optional<UUID> getOwner()
|
||||
{
|
||||
return getData(FlagType.TAMEABLE_OWNER);
|
||||
}
|
||||
|
||||
public boolean isSitting()
|
||||
{
|
||||
return isTameableFlag(1);
|
||||
}
|
||||
|
||||
public boolean isTamed()
|
||||
{
|
||||
return isTameableFlag(4);
|
||||
}
|
||||
|
||||
protected boolean isTameableFlag(int no)
|
||||
{
|
||||
return ((byte) getData(FlagType.TAMEABLE_META) & no) != 0;
|
||||
}
|
||||
|
||||
protected void setTameableFlag(int no, boolean flag)
|
||||
{
|
||||
byte value = (byte) getData(FlagType.TAMEABLE_META);
|
||||
|
||||
if (flag)
|
||||
{
|
||||
setData(FlagType.TAMEABLE_META, (byte) (value | no));
|
||||
}
|
||||
else
|
||||
{
|
||||
setData(FlagType.TAMEABLE_META, (byte) (value & -(no + 1)));
|
||||
}
|
||||
|
||||
sendData(FlagType.TAMEABLE_META);
|
||||
}
|
||||
|
||||
public void setOwner(UUID owner)
|
||||
{
|
||||
setData(FlagType.TAMEABLE_OWNER, Optional.of(owner));
|
||||
sendData(FlagType.TAMEABLE_OWNER);
|
||||
}
|
||||
|
||||
public void setSitting(boolean sitting)
|
||||
{
|
||||
setTameableFlag(1, sitting);
|
||||
}
|
||||
|
||||
public void setTamed(boolean tamed)
|
||||
{
|
||||
setTameableFlag(4, tamed);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -25,13 +25,13 @@ public class TippedArrowWatcher extends ArrowWatcher
|
||||
|
||||
public Color getColor()
|
||||
{
|
||||
int color = (int) getValue(FlagType.TIPPED_ARROW_COLOR);
|
||||
int color = (int) getData(FlagType.TIPPED_ARROW_COLOR);
|
||||
return Color.fromRGB(color);
|
||||
}
|
||||
|
||||
public void setColor(Color color)
|
||||
{
|
||||
setValue(FlagType.TIPPED_ARROW_COLOR, color.asRGB());
|
||||
setData(FlagType.TIPPED_ARROW_COLOR, color.asRGB());
|
||||
sendData(FlagType.TIPPED_ARROW_COLOR);
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,21 @@
|
||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||
|
||||
public class VexWatcher extends InsentientWatcher {
|
||||
|
||||
public VexWatcher(Disguise disguise) {
|
||||
super(disguise);
|
||||
}
|
||||
|
||||
public void setAngry(boolean angry) {
|
||||
setData(FlagType.VEX_ANGRY, angry);
|
||||
sendData(FlagType.VEX_ANGRY);
|
||||
}
|
||||
|
||||
public boolean isAngry() {
|
||||
return getData(FlagType.VEX_ANGRY);
|
||||
}
|
||||
|
||||
}
|
@ -1,33 +1,33 @@
|
||||
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 VillagerWatcher(Disguise disguise)
|
||||
{
|
||||
super(disguise);
|
||||
setProfession(Profession.values()[DisguiseUtilities.random.nextInt(Profession.values().length)]);
|
||||
}
|
||||
|
||||
public Profession getProfession()
|
||||
{
|
||||
return Profession.values()[getValue(FlagType.VILLAGER_PROFESSION)];
|
||||
}
|
||||
|
||||
public void setProfession(int professionId)
|
||||
{
|
||||
setValue(FlagType.VILLAGER_PROFESSION, professionId);
|
||||
sendData(FlagType.VILLAGER_PROFESSION);
|
||||
}
|
||||
|
||||
public void setProfession(Profession newProfession)
|
||||
{
|
||||
setProfession(newProfession.ordinal());
|
||||
}
|
||||
}
|
||||
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 VillagerWatcher(Disguise disguise)
|
||||
{
|
||||
super(disguise);
|
||||
setProfession(Profession.values()[DisguiseUtilities.random.nextInt(Profession.values().length)]);
|
||||
}
|
||||
|
||||
public Profession getProfession()
|
||||
{
|
||||
return Profession.values()[getData(FlagType.VILLAGER_PROFESSION)];
|
||||
}
|
||||
|
||||
public void setProfession(int professionId)
|
||||
{
|
||||
setData(FlagType.VILLAGER_PROFESSION, professionId);
|
||||
sendData(FlagType.VILLAGER_PROFESSION);
|
||||
}
|
||||
|
||||
public void setProfession(Profession newProfession)
|
||||
{
|
||||
setProfession(newProfession.ordinal());
|
||||
}
|
||||
}
|
||||
|
@ -0,0 +1,17 @@
|
||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.FlagType;
|
||||
|
||||
public class VindicatorWatcher extends InsentientWatcher {
|
||||
|
||||
public VindicatorWatcher(Disguise disguise) {
|
||||
super(disguise);
|
||||
}
|
||||
|
||||
public void setJohnny(boolean isJohnny) {
|
||||
setData(FlagType.VINDICATOR_JOHNNY, (byte) (isJohnny ? 1 : 0));
|
||||
sendData(FlagType.VINDICATOR_JOHNNY);
|
||||
}
|
||||
|
||||
}
|
@ -16,12 +16,12 @@ public class WitchWatcher extends InsentientWatcher
|
||||
|
||||
public boolean isAggressive()
|
||||
{
|
||||
return (boolean) getValue(FlagType.WITCH_AGGRESSIVE);
|
||||
return (boolean) getData(FlagType.WITCH_AGGRESSIVE);
|
||||
}
|
||||
|
||||
public void setAggressive(boolean aggressive)
|
||||
{
|
||||
setValue(FlagType.WITCH_AGGRESSIVE, aggressive);
|
||||
setData(FlagType.WITCH_AGGRESSIVE, aggressive);
|
||||
sendData(FlagType.WITCH_AGGRESSIVE);
|
||||
}
|
||||
|
||||
|
@ -1,26 +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 WitherSkullWatcher(Disguise disguise)
|
||||
{
|
||||
super(disguise);
|
||||
}
|
||||
|
||||
public boolean isBlue()
|
||||
{
|
||||
return (boolean) getValue(FlagType.WITHERSKULL_BLUE);
|
||||
}
|
||||
|
||||
public void setBlue(boolean blue)
|
||||
{
|
||||
setValue(FlagType.WITHERSKULL_BLUE, blue);
|
||||
sendData(FlagType.WITHERSKULL_BLUE);
|
||||
}
|
||||
|
||||
}
|
||||
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 WitherSkullWatcher(Disguise disguise)
|
||||
{
|
||||
super(disguise);
|
||||
}
|
||||
|
||||
public boolean isBlue()
|
||||
{
|
||||
return (boolean) getData(FlagType.WITHERSKULL_BLUE);
|
||||
}
|
||||
|
||||
public void setBlue(boolean blue)
|
||||
{
|
||||
setData(FlagType.WITHERSKULL_BLUE, blue);
|
||||
sendData(FlagType.WITHERSKULL_BLUE);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -22,14 +22,14 @@ public class WitherWatcher extends InsentientWatcher
|
||||
*/
|
||||
public int getInvulnerability()
|
||||
{
|
||||
return (int) getValue(FlagType.WITHER_INVUL);
|
||||
return (int) getData(FlagType.WITHER_INVUL);
|
||||
}
|
||||
|
||||
public int[] getTargets()
|
||||
{
|
||||
return new int[]
|
||||
{
|
||||
getValue(FlagType.WITHER_TARGET_1), getValue(FlagType.WITHER_TARGET_2), getValue(FlagType.WITHER_TARGET_3)
|
||||
getData(FlagType.WITHER_TARGET_1), getData(FlagType.WITHER_TARGET_2), getData(FlagType.WITHER_TARGET_3)
|
||||
};
|
||||
}
|
||||
|
||||
@ -38,7 +38,7 @@ public class WitherWatcher extends InsentientWatcher
|
||||
*/
|
||||
public void setInvulnerability(int invulnerability)
|
||||
{
|
||||
setValue(FlagType.WITHER_INVUL, invulnerability);
|
||||
setData(FlagType.WITHER_INVUL, invulnerability);
|
||||
sendData(FlagType.WITHER_INVUL);
|
||||
}
|
||||
|
||||
@ -49,9 +49,9 @@ public class WitherWatcher extends InsentientWatcher
|
||||
throw new InvalidParameterException(
|
||||
ChatColor.RED + "Expected 3 numbers for wither setTargets. Received " + targets.length);
|
||||
}
|
||||
setValue(FlagType.WITHER_TARGET_1, targets[0]);
|
||||
setValue(FlagType.WITHER_TARGET_2, targets[1]);
|
||||
setValue(FlagType.WITHER_TARGET_3, targets[2]);
|
||||
setData(FlagType.WITHER_TARGET_1, targets[0]);
|
||||
setData(FlagType.WITHER_TARGET_2, targets[1]);
|
||||
setData(FlagType.WITHER_TARGET_3, targets[2]);
|
||||
sendData(FlagType.WITHER_TARGET_1, FlagType.WITHER_TARGET_2, FlagType.WITHER_TARGET_3);
|
||||
}
|
||||
|
||||
|
@ -1,85 +1,85 @@
|
||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
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 WolfWatcher(Disguise disguise)
|
||||
{
|
||||
super(disguise);
|
||||
}
|
||||
|
||||
public AnimalColor getCollarColor()
|
||||
{
|
||||
return AnimalColor.getColor(getValue(FlagType.WOLF_COLLAR));
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for tail rotation.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public float getDamageTaken()
|
||||
{
|
||||
return (float) getValue(FlagType.WOLF_DAMAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for tail rotation.
|
||||
*
|
||||
* @param damage
|
||||
*/
|
||||
public void setDamageTaken(float damage)
|
||||
{
|
||||
setValue(FlagType.WOLF_DAMAGE, damage);
|
||||
sendData(FlagType.WOLF_DAMAGE);
|
||||
}
|
||||
|
||||
public boolean isBegging()
|
||||
{
|
||||
return (boolean) getValue(FlagType.WOLF_BEGGING);
|
||||
}
|
||||
|
||||
public void setBegging(boolean begging)
|
||||
{
|
||||
setValue(FlagType.WOLF_BEGGING, begging);
|
||||
sendData(FlagType.WOLF_BEGGING);
|
||||
}
|
||||
|
||||
public boolean isAngry()
|
||||
{
|
||||
return isTameableFlag(2);
|
||||
}
|
||||
|
||||
public void setAngry(boolean angry)
|
||||
{
|
||||
setTameableFlag(2, angry);
|
||||
}
|
||||
|
||||
public void setCollarColor(AnimalColor color)
|
||||
{
|
||||
setCollarColor(DyeColor.getByWoolData((byte) color.getId()));
|
||||
}
|
||||
|
||||
public void setCollarColor(DyeColor newColor)
|
||||
{
|
||||
if (!isTamed())
|
||||
{
|
||||
setTamed(true);
|
||||
}
|
||||
|
||||
if (newColor.getWoolData() == getCollarColor().getId())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
setValue(FlagType.WOLF_COLLAR, (int) newColor.getDyeData());
|
||||
sendData(FlagType.WOLF_COLLAR);
|
||||
}
|
||||
|
||||
}
|
||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
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 WolfWatcher(Disguise disguise)
|
||||
{
|
||||
super(disguise);
|
||||
}
|
||||
|
||||
public AnimalColor getCollarColor()
|
||||
{
|
||||
return AnimalColor.getColor(getData(FlagType.WOLF_COLLAR));
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for tail rotation.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public float getDamageTaken()
|
||||
{
|
||||
return (float) getData(FlagType.WOLF_DAMAGE);
|
||||
}
|
||||
|
||||
/**
|
||||
* Used for tail rotation.
|
||||
*
|
||||
* @param damage
|
||||
*/
|
||||
public void setDamageTaken(float damage)
|
||||
{
|
||||
setData(FlagType.WOLF_DAMAGE, damage);
|
||||
sendData(FlagType.WOLF_DAMAGE);
|
||||
}
|
||||
|
||||
public boolean isBegging()
|
||||
{
|
||||
return (boolean) getData(FlagType.WOLF_BEGGING);
|
||||
}
|
||||
|
||||
public void setBegging(boolean begging)
|
||||
{
|
||||
setData(FlagType.WOLF_BEGGING, begging);
|
||||
sendData(FlagType.WOLF_BEGGING);
|
||||
}
|
||||
|
||||
public boolean isAngry()
|
||||
{
|
||||
return isTameableFlag(2);
|
||||
}
|
||||
|
||||
public void setAngry(boolean angry)
|
||||
{
|
||||
setTameableFlag(2, angry);
|
||||
}
|
||||
|
||||
public void setCollarColor(AnimalColor color)
|
||||
{
|
||||
setCollarColor(DyeColor.getByWoolData((byte) color.getId()));
|
||||
}
|
||||
|
||||
public void setCollarColor(DyeColor newColor)
|
||||
{
|
||||
if (!isTamed())
|
||||
{
|
||||
setTamed(true);
|
||||
}
|
||||
|
||||
if (newColor.getWoolData() == getCollarColor().getId())
|
||||
{
|
||||
return;
|
||||
}
|
||||
|
||||
setData(FlagType.WOLF_COLLAR, (int) newColor.getDyeData());
|
||||
sendData(FlagType.WOLF_COLLAR);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -0,0 +1,11 @@
|
||||
package me.libraryaddict.disguise.disguisetypes.watchers;
|
||||
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
|
||||
public class ZombieHorseWatcher extends HorseAbstractWatcher {
|
||||
|
||||
public ZombieHorseWatcher(Disguise disguise) {
|
||||
super(disguise);
|
||||
}
|
||||
|
||||
}
|
@ -20,12 +20,12 @@ public class ZombieWatcher extends InsentientWatcher
|
||||
|
||||
public boolean isBaby()
|
||||
{
|
||||
return getValue(FlagType.ZOMBIE_BABY);
|
||||
return getData(FlagType.ZOMBIE_BABY);
|
||||
}
|
||||
|
||||
public boolean isShaking()
|
||||
{
|
||||
return getValue(FlagType.ZOMBIE_SHAKING);
|
||||
return getData(FlagType.ZOMBIE_SHAKING);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -35,12 +35,12 @@ public class ZombieWatcher extends InsentientWatcher
|
||||
*/
|
||||
public boolean isVillager()
|
||||
{
|
||||
return ((int) getValue(FlagType.ZOMBIE_PROFESSION)) != 0;
|
||||
return ((int) getData(FlagType.ZOMBIE_PROFESSION)) != 0;
|
||||
}
|
||||
|
||||
public boolean isAggressive()
|
||||
{
|
||||
return (boolean) getValue(FlagType.ZOMBIE_AGGRESSIVE);
|
||||
return (boolean) getData(FlagType.ZOMBIE_AGGRESSIVE);
|
||||
}
|
||||
|
||||
/**
|
||||
@ -50,7 +50,7 @@ public class ZombieWatcher extends InsentientWatcher
|
||||
*/
|
||||
public Profession getProfession()
|
||||
{
|
||||
return Profession.values()[getValue(FlagType.ZOMBIE_PROFESSION)];
|
||||
return Profession.values()[getData(FlagType.ZOMBIE_PROFESSION)];
|
||||
}
|
||||
|
||||
public void setAdult()
|
||||
@ -65,13 +65,13 @@ public class ZombieWatcher extends InsentientWatcher
|
||||
|
||||
public void setBaby(boolean baby)
|
||||
{
|
||||
setValue(FlagType.ZOMBIE_BABY, baby);
|
||||
setData(FlagType.ZOMBIE_BABY, baby);
|
||||
sendData(FlagType.ZOMBIE_BABY);
|
||||
}
|
||||
|
||||
public void setShaking(boolean shaking)
|
||||
{
|
||||
setValue(FlagType.ZOMBIE_SHAKING, shaking);
|
||||
setData(FlagType.ZOMBIE_SHAKING, shaking);
|
||||
sendData(FlagType.ZOMBIE_SHAKING);
|
||||
}
|
||||
|
||||
@ -82,7 +82,7 @@ public class ZombieWatcher extends InsentientWatcher
|
||||
*/
|
||||
public void setProfession(int id)
|
||||
{
|
||||
setValue(FlagType.ZOMBIE_PROFESSION, id);
|
||||
setData(FlagType.ZOMBIE_PROFESSION, id);
|
||||
sendData(FlagType.ZOMBIE_PROFESSION);
|
||||
}
|
||||
|
||||
@ -93,13 +93,13 @@ public class ZombieWatcher extends InsentientWatcher
|
||||
*/
|
||||
public void setProfession(Profession profession)
|
||||
{
|
||||
setValue(FlagType.ZOMBIE_PROFESSION, profession.ordinal());
|
||||
setData(FlagType.ZOMBIE_PROFESSION, profession.ordinal());
|
||||
sendData(FlagType.ZOMBIE_PROFESSION);
|
||||
}
|
||||
|
||||
public void setAggressive(boolean handsup)
|
||||
{
|
||||
setValue(FlagType.ZOMBIE_AGGRESSIVE, handsup);
|
||||
setData(FlagType.ZOMBIE_AGGRESSIVE, handsup);
|
||||
sendData(FlagType.ZOMBIE_AGGRESSIVE);
|
||||
}
|
||||
|
||||
|
@ -8,8 +8,7 @@ import org.bukkit.Sound;
|
||||
/**
|
||||
* Only living disguises go in here!
|
||||
*/
|
||||
public enum DisguiseSound
|
||||
{
|
||||
public enum DisguiseSound {
|
||||
|
||||
ARROW(null, null, null, null, Sound.ENTITY_ARROW_HIT, Sound.ENTITY_ARROW_SHOOT),
|
||||
|
||||
@ -44,6 +43,13 @@ public enum DisguiseSound
|
||||
ENDERMITE(Sound.ENTITY_SILVERFISH_HURT, Sound.ENTITY_ENDERMITE_STEP, Sound.ENTITY_ENDERMITE_DEATH,
|
||||
Sound.ENTITY_ENDERMITE_AMBIENT),
|
||||
|
||||
EVOKER(Sound.ENTITY_EVOCATION_ILLAGER_HURT, null, Sound.ENTITY_EVOCATION_ILLAGER_DEATH,
|
||||
Sound.ENTITY_EVOCATION_ILLAGER_AMBIENT, Sound.ENTITY_EVOCATION_ILLAGER_CAST_SPELL,
|
||||
Sound.ENTITY_EVOCATION_ILLAGER_PREPARE_ATTACK, Sound.ENTITY_EVOCATION_ILLAGER_PREPARE_SUMMON,
|
||||
Sound.ENTITY_EVOCATION_ILLAGER_PREPARE_WOLOLO),
|
||||
|
||||
EVOKER_FANGS(null, null, null, null, Sound.ENTITY_EVOCATION_FANGS_ATTACK),
|
||||
|
||||
GHAST(Sound.ENTITY_GHAST_HURT, null, Sound.ENTITY_GHAST_DEATH, Sound.ENTITY_GHAST_AMBIENT, Sound.ENTITY_PLAYER_SMALL_FALL,
|
||||
Sound.ENTITY_GHAST_SHOOT, Sound.ENTITY_PLAYER_BIG_FALL, Sound.ENTITY_GHAST_SCREAM, Sound.ENTITY_GHAST_WARN),
|
||||
|
||||
@ -58,6 +64,9 @@ public enum DisguiseSound
|
||||
IRON_GOLEM(Sound.ENTITY_IRONGOLEM_HURT, Sound.ENTITY_IRONGOLEM_STEP, Sound.ENTITY_IRONGOLEM_DEATH,
|
||||
Sound.ENTITY_IRONGOLEM_ATTACK),
|
||||
|
||||
LLAMA(Sound.ENTITY_LLAMA_HURT, Sound.ENTITY_LLAMA_STEP, Sound.ENTITY_LLAMA_DEATH, Sound.ENTITY_LLAMA_AMBIENT,
|
||||
Sound.ENTITY_LLAMA_ANGRY, Sound.ENTITY_LLAMA_CHEST, Sound.ENTITY_LLAMA_EAT, Sound.ENTITY_LLAMA_SWAG),
|
||||
|
||||
MAGMA_CUBE(Sound.ENTITY_MAGMACUBE_HURT, Sound.ENTITY_MAGMACUBE_JUMP, null, null),
|
||||
|
||||
MULE(Sound.ENTITY_MULE_HURT, "step.grass", Sound.ENTITY_MULE_DEATH, Sound.ENTITY_MULE_AMBIENT),
|
||||
@ -104,9 +113,14 @@ public enum DisguiseSound
|
||||
Sound.ENTITY_HORSE_GALLOP, Sound.ENTITY_HORSE_SADDLE, Sound.ENTITY_DONKEY_ANGRY, Sound.ENTITY_HORSE_STEP_WOOD,
|
||||
Sound.ENTITY_HORSE_ARMOR, Sound.ENTITY_HORSE_LAND, Sound.ENTITY_HORSE_JUMP, Sound.ENTITY_HORSE_ANGRY),
|
||||
|
||||
VEX(Sound.ENTITY_VEX_HURT, null, Sound.ENTITY_VEX_DEATH, Sound.ENTITY_VEX_AMBIENT, Sound.ENTITY_VEX_CHARGE),
|
||||
|
||||
VILLAGER(Sound.ENTITY_VILLAGER_HURT, null, Sound.ENTITY_VILLAGER_DEATH, Sound.ENTITY_VILLAGER_AMBIENT,
|
||||
Sound.ENTITY_VILLAGER_TRADING, Sound.ENTITY_VILLAGER_NO, Sound.ENTITY_VILLAGER_YES),
|
||||
|
||||
VINDICATOR(Sound.ENTITY_VINDICATION_ILLAGER_HURT, null, Sound.ENTITY_VINDICATION_ILLAGER_DEATH,
|
||||
Sound.ENTITY_VINDICATION_ILLAGER_AMBIENT),
|
||||
|
||||
WITCH(Sound.ENTITY_WITCH_HURT, null, Sound.ENTITY_WITCH_DEATH, Sound.ENTITY_WITCH_AMBIENT),
|
||||
|
||||
WITHER(Sound.ENTITY_WITHER_HURT, null, Sound.ENTITY_WITHER_DEATH, Sound.ENTITY_WITHER_AMBIENT, Sound.ENTITY_PLAYER_SMALL_FALL,
|
||||
@ -126,19 +140,15 @@ public enum DisguiseSound
|
||||
Sound.ENTITY_ZOMBIE_INFECT, Sound.ENTITY_ZOMBIE_BREAK_DOOR_WOOD, Sound.ENTITY_ZOMBIE_ATTACK_DOOR_WOOD,
|
||||
Sound.ENTITY_ZOMBIE_ATTACK_IRON_DOOR);
|
||||
|
||||
public enum SoundType
|
||||
{
|
||||
public enum SoundType {
|
||||
CANCEL, DEATH, HURT, IDLE, STEP
|
||||
}
|
||||
|
||||
public static DisguiseSound getType(String name)
|
||||
{
|
||||
try
|
||||
{
|
||||
public static DisguiseSound getType(String name) {
|
||||
try {
|
||||
return valueOf(name);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
catch (Exception ex) {
|
||||
return null;
|
||||
}
|
||||
}
|
||||
@ -147,43 +157,35 @@ public enum DisguiseSound
|
||||
private float damageSoundVolume = 1F;
|
||||
private HashMap<SoundType, String> disguiseSounds = new HashMap<>();
|
||||
|
||||
DisguiseSound(Object hurt, Object step, Object death, Object idle, Object... sounds)
|
||||
{
|
||||
DisguiseSound(Object hurt, Object step, Object death, Object idle, Object... sounds) {
|
||||
addSound(hurt, SoundType.HURT);
|
||||
addSound(step, SoundType.STEP);
|
||||
addSound(death, SoundType.DEATH);
|
||||
addSound(idle, SoundType.IDLE);
|
||||
|
||||
for (Object obj : sounds)
|
||||
{
|
||||
for (Object obj : sounds) {
|
||||
addSound(obj, SoundType.CANCEL);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
private void addSound(Object sound, SoundType type)
|
||||
{
|
||||
private void addSound(Object sound, SoundType type) {
|
||||
String s;
|
||||
|
||||
if (sound == null)
|
||||
{
|
||||
if (sound == null) {
|
||||
return;
|
||||
}
|
||||
else if (sound instanceof String)
|
||||
{
|
||||
else if (sound instanceof String) {
|
||||
s = (String) sound;
|
||||
}
|
||||
else if (sound instanceof Sound)
|
||||
{
|
||||
else if (sound instanceof Sound) {
|
||||
s = ReflectionManager.getCraftSound((Sound) sound);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
throw new RuntimeException("Was given a unknown object " + sound);
|
||||
}
|
||||
|
||||
switch (type)
|
||||
{
|
||||
switch (type) {
|
||||
case HURT:
|
||||
disguiseSounds.put(SoundType.HURT, s);
|
||||
break;
|
||||
@ -201,58 +203,47 @@ public enum DisguiseSound
|
||||
}
|
||||
}
|
||||
|
||||
public float getDamageAndIdleSoundVolume()
|
||||
{
|
||||
public float getDamageAndIdleSoundVolume() {
|
||||
return damageSoundVolume;
|
||||
}
|
||||
|
||||
public String getSound(SoundType type)
|
||||
{
|
||||
if (type == null || !disguiseSounds.containsKey(type))
|
||||
{
|
||||
public String getSound(SoundType type) {
|
||||
if (type == null || !disguiseSounds.containsKey(type)) {
|
||||
return null;
|
||||
}
|
||||
|
||||
return disguiseSounds.get(type);
|
||||
}
|
||||
|
||||
public HashSet<String> getSoundsToCancel()
|
||||
{
|
||||
public HashSet<String> getSoundsToCancel() {
|
||||
return cancelSounds;
|
||||
}
|
||||
|
||||
/**
|
||||
* Used to check if this sound name is owned by this disguise sound.
|
||||
*/
|
||||
public SoundType getType(String sound, boolean ignoreDamage)
|
||||
{
|
||||
public SoundType getType(String sound, boolean ignoreDamage) {
|
||||
if (sound == null)
|
||||
return SoundType.CANCEL;
|
||||
|
||||
if (isCancelSound(sound))
|
||||
{
|
||||
if (isCancelSound(sound)) {
|
||||
return SoundType.CANCEL;
|
||||
}
|
||||
|
||||
if (disguiseSounds.containsKey(SoundType.STEP) && disguiseSounds.get(SoundType.STEP).startsWith("step.")
|
||||
&& sound.startsWith("step."))
|
||||
{
|
||||
&& sound.startsWith("step.")) {
|
||||
return SoundType.STEP;
|
||||
}
|
||||
|
||||
for (SoundType type : SoundType.values())
|
||||
{
|
||||
if (!disguiseSounds.containsKey(type) || type == SoundType.DEATH || (ignoreDamage && type == SoundType.HURT))
|
||||
{
|
||||
for (SoundType type : SoundType.values()) {
|
||||
if (!disguiseSounds.containsKey(type) || type == SoundType.DEATH || (ignoreDamage && type == SoundType.HURT)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
String s = disguiseSounds.get(type);
|
||||
|
||||
if (s != null)
|
||||
{
|
||||
if (s.equals(sound))
|
||||
{
|
||||
if (s != null) {
|
||||
if (s.equals(sound)) {
|
||||
return type;
|
||||
}
|
||||
}
|
||||
@ -261,46 +252,36 @@ public enum DisguiseSound
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean isCancelSound(String sound)
|
||||
{
|
||||
public boolean isCancelSound(String sound) {
|
||||
return getSoundsToCancel().contains(sound);
|
||||
}
|
||||
|
||||
public void removeSound(SoundType type, Sound sound)
|
||||
{
|
||||
public void removeSound(SoundType type, Sound sound) {
|
||||
removeSound(type, ReflectionManager.getCraftSound(sound));
|
||||
}
|
||||
|
||||
public void removeSound(SoundType type, String sound)
|
||||
{
|
||||
if (type == SoundType.CANCEL)
|
||||
{
|
||||
public void removeSound(SoundType type, String sound) {
|
||||
if (type == SoundType.CANCEL) {
|
||||
cancelSounds.remove(sound);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
disguiseSounds.remove(type);
|
||||
}
|
||||
}
|
||||
|
||||
public void setDamageAndIdleSoundVolume(float strength)
|
||||
{
|
||||
public void setDamageAndIdleSoundVolume(float strength) {
|
||||
this.damageSoundVolume = strength;
|
||||
}
|
||||
|
||||
public void setSound(SoundType type, Sound sound)
|
||||
{
|
||||
public void setSound(SoundType type, Sound sound) {
|
||||
setSound(type, ReflectionManager.getCraftSound(sound));
|
||||
}
|
||||
|
||||
public void setSound(SoundType type, String sound)
|
||||
{
|
||||
if (type == SoundType.CANCEL)
|
||||
{
|
||||
public void setSound(SoundType type, String sound) {
|
||||
if (type == SoundType.CANCEL) {
|
||||
cancelSounds.add(sound);
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
disguiseSounds.put(type, sound);
|
||||
}
|
||||
}
|
||||
|
File diff suppressed because it is too large
Load Diff
@ -1,6 +1,7 @@
|
||||
package me.libraryaddict.disguise.utilities.packetlisteners;
|
||||
|
||||
import java.lang.reflect.InvocationTargetException;
|
||||
import java.util.List;
|
||||
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.Material;
|
||||
@ -20,12 +21,10 @@ import me.libraryaddict.disguise.LibsDisguises;
|
||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
|
||||
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
||||
|
||||
public class PacketListenerInventory extends PacketAdapter
|
||||
{
|
||||
public class PacketListenerInventory extends PacketAdapter {
|
||||
private LibsDisguises libsDisguises;
|
||||
|
||||
public PacketListenerInventory(LibsDisguises plugin)
|
||||
{
|
||||
public PacketListenerInventory(LibsDisguises plugin) {
|
||||
super(plugin, ListenerPriority.HIGH, Server.SET_SLOT, Server.WINDOW_ITEMS, PacketType.Play.Client.HELD_ITEM_SLOT,
|
||||
PacketType.Play.Client.SET_CREATIVE_SLOT, PacketType.Play.Client.WINDOW_CLICK);
|
||||
|
||||
@ -33,16 +32,14 @@ public class PacketListenerInventory extends PacketAdapter
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketReceiving(final PacketEvent event)
|
||||
{
|
||||
public void onPacketReceiving(final PacketEvent event) {
|
||||
if (event.isCancelled())
|
||||
return;
|
||||
|
||||
if (event.getPlayer().getName().contains("UNKNOWN[")) // If the player is temporary
|
||||
return;
|
||||
|
||||
if (event.getPlayer() instanceof com.comphenix.net.sf.cglib.proxy.Factory || event.getPlayer().getVehicle() != null)
|
||||
{
|
||||
if (event.getPlayer() instanceof com.comphenix.net.sf.cglib.proxy.Factory || event.getPlayer().getVehicle() != null) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -50,23 +47,18 @@ public class PacketListenerInventory extends PacketAdapter
|
||||
|
||||
// If player is disguised, views self disguises and has a inventory modifier
|
||||
if (disguise != null && disguise.isSelfDisguiseVisible()
|
||||
&& (disguise.isHidingArmorFromSelf() || disguise.isHidingHeldItemFromSelf()))
|
||||
{
|
||||
&& (disguise.isHidingArmorFromSelf() || disguise.isHidingHeldItemFromSelf())) {
|
||||
// If they are in creative and clicked on a slot
|
||||
if (event.getPacketType() == PacketType.Play.Client.SET_CREATIVE_SLOT)
|
||||
{
|
||||
if (event.getPacketType() == PacketType.Play.Client.SET_CREATIVE_SLOT) {
|
||||
int slot = event.getPacket().getIntegers().read(0);
|
||||
|
||||
if (slot >= 5 && slot <= 8)
|
||||
{
|
||||
if (disguise.isHidingArmorFromSelf())
|
||||
{
|
||||
if (slot >= 5 && slot <= 8) {
|
||||
if (disguise.isHidingArmorFromSelf()) {
|
||||
int armorSlot = Math.abs((slot - 5) - 3);
|
||||
|
||||
org.bukkit.inventory.ItemStack item = event.getPlayer().getInventory().getArmorContents()[armorSlot];
|
||||
|
||||
if (item != null && item.getType() != Material.AIR)
|
||||
{
|
||||
if (item != null && item.getType() != Material.AIR) {
|
||||
PacketContainer packet = new PacketContainer(Server.SET_SLOT);
|
||||
|
||||
StructureModifier<Object> mods = packet.getModifier();
|
||||
@ -75,29 +67,23 @@ public class PacketListenerInventory extends PacketAdapter
|
||||
mods.write(1, slot);
|
||||
mods.write(2, ReflectionManager.getNmsItem(new org.bukkit.inventory.ItemStack(0)));
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet, false);
|
||||
}
|
||||
catch (InvocationTargetException e)
|
||||
{
|
||||
catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (slot >= 36 && slot <= 44)
|
||||
{
|
||||
if (disguise.isHidingHeldItemFromSelf())
|
||||
{
|
||||
else if (slot >= 36 && slot <= 44) {
|
||||
if (disguise.isHidingHeldItemFromSelf()) {
|
||||
int currentSlot = event.getPlayer().getInventory().getHeldItemSlot();
|
||||
|
||||
if (slot + 36 == currentSlot)
|
||||
{
|
||||
if (slot + 36 == currentSlot) {
|
||||
org.bukkit.inventory.ItemStack item = event.getPlayer().getItemInHand();
|
||||
|
||||
if (item != null && item.getType() != Material.AIR)
|
||||
{
|
||||
if (item != null && item.getType() != Material.AIR) {
|
||||
PacketContainer packet = new PacketContainer(Server.SET_SLOT);
|
||||
|
||||
StructureModifier<Object> mods = packet.getModifier();
|
||||
@ -105,12 +91,10 @@ public class PacketListenerInventory extends PacketAdapter
|
||||
mods.write(1, slot);
|
||||
mods.write(2, ReflectionManager.getNmsItem(new org.bukkit.inventory.ItemStack(0)));
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet, false);
|
||||
}
|
||||
catch (InvocationTargetException e)
|
||||
{
|
||||
catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -119,18 +103,15 @@ public class PacketListenerInventory extends PacketAdapter
|
||||
}
|
||||
}
|
||||
// If the player switched item, aka he moved from slot 1 to slot 2
|
||||
else if (event.getPacketType() == PacketType.Play.Client.HELD_ITEM_SLOT)
|
||||
{
|
||||
if (disguise.isHidingHeldItemFromSelf())
|
||||
{
|
||||
else if (event.getPacketType() == PacketType.Play.Client.HELD_ITEM_SLOT) {
|
||||
if (disguise.isHidingHeldItemFromSelf()) {
|
||||
// From logging, it seems that both bukkit and nms uses the same thing for the slot switching.
|
||||
// 0 1 2 3 - 8
|
||||
// If the packet is coming, then I need to replace the item they are switching to
|
||||
// As for the old item, I need to restore it.
|
||||
org.bukkit.inventory.ItemStack currentlyHeld = event.getPlayer().getItemInHand();
|
||||
// If his old weapon isn't air
|
||||
if (currentlyHeld != null && currentlyHeld.getType() != Material.AIR)
|
||||
{
|
||||
if (currentlyHeld != null && currentlyHeld.getType() != Material.AIR) {
|
||||
PacketContainer packet = new PacketContainer(Server.SET_SLOT);
|
||||
|
||||
StructureModifier<Object> mods = packet.getModifier();
|
||||
@ -139,12 +120,10 @@ public class PacketListenerInventory extends PacketAdapter
|
||||
mods.write(1, event.getPlayer().getInventory().getHeldItemSlot() + 36);
|
||||
mods.write(2, ReflectionManager.getNmsItem(currentlyHeld));
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet, false);
|
||||
}
|
||||
catch (InvocationTargetException e)
|
||||
{
|
||||
catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -153,8 +132,7 @@ public class PacketListenerInventory extends PacketAdapter
|
||||
.getItem(event.getPacket().getIntegers().read(0));
|
||||
|
||||
// If his new weapon isn't air either!
|
||||
if (newHeld != null && newHeld.getType() != Material.AIR)
|
||||
{
|
||||
if (newHeld != null && newHeld.getType() != Material.AIR) {
|
||||
PacketContainer packet = new PacketContainer(Server.SET_SLOT);
|
||||
|
||||
StructureModifier<Object> mods = packet.getModifier();
|
||||
@ -163,36 +141,29 @@ public class PacketListenerInventory extends PacketAdapter
|
||||
mods.write(1, event.getPacket().getIntegers().read(0) + 36);
|
||||
mods.write(2, ReflectionManager.getNmsItem(new org.bukkit.inventory.ItemStack(0)));
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet, false);
|
||||
}
|
||||
catch (InvocationTargetException e)
|
||||
{
|
||||
catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (event.getPacketType() == PacketType.Play.Client.WINDOW_CLICK)
|
||||
{
|
||||
else if (event.getPacketType() == PacketType.Play.Client.WINDOW_CLICK) {
|
||||
int slot = event.getPacket().getIntegers().read(1);
|
||||
|
||||
org.bukkit.inventory.ItemStack clickedItem;
|
||||
|
||||
if (event.getPacket().getShorts().read(0) == 1)
|
||||
{
|
||||
if (event.getPacket().getShorts().read(0) == 1) {
|
||||
// Its a shift click
|
||||
clickedItem = event.getPacket().getItemModifier().read(0);
|
||||
|
||||
if (clickedItem != null && clickedItem.getType() != Material.AIR)
|
||||
{
|
||||
if (clickedItem != null && clickedItem.getType() != Material.AIR) {
|
||||
// Rather than predict the clients actions
|
||||
// Lets just update the entire inventory..
|
||||
Bukkit.getScheduler().runTask(libsDisguises, new Runnable()
|
||||
{
|
||||
public void run()
|
||||
{
|
||||
Bukkit.getScheduler().runTask(libsDisguises, new Runnable() {
|
||||
public void run() {
|
||||
event.getPlayer().updateInventory();
|
||||
}
|
||||
});
|
||||
@ -200,25 +171,20 @@ public class PacketListenerInventory extends PacketAdapter
|
||||
|
||||
return;
|
||||
}
|
||||
else
|
||||
{
|
||||
else {
|
||||
// If its not a player inventory click
|
||||
// Shift clicking is exempted for the item in hand..
|
||||
if (event.getPacket().getIntegers().read(0) != 0)
|
||||
{
|
||||
if (event.getPacket().getIntegers().read(0) != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
clickedItem = event.getPlayer().getItemOnCursor();
|
||||
}
|
||||
|
||||
if (clickedItem != null && clickedItem.getType() != Material.AIR)
|
||||
{
|
||||
if (clickedItem != null && clickedItem.getType() != Material.AIR) {
|
||||
// If the slot is a armor slot
|
||||
if (slot >= 5 && slot <= 8)
|
||||
{
|
||||
if (disguise.isHidingArmorFromSelf())
|
||||
{
|
||||
if (slot >= 5 && slot <= 8) {
|
||||
if (disguise.isHidingArmorFromSelf()) {
|
||||
PacketContainer packet = new PacketContainer(Server.SET_SLOT);
|
||||
|
||||
StructureModifier<Object> mods = packet.getModifier();
|
||||
@ -227,26 +193,21 @@ public class PacketListenerInventory extends PacketAdapter
|
||||
mods.write(1, slot);
|
||||
mods.write(2, ReflectionManager.getNmsItem(new org.bukkit.inventory.ItemStack(0)));
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet, false);
|
||||
}
|
||||
catch (InvocationTargetException e)
|
||||
{
|
||||
catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
// Else if its a hotbar slot
|
||||
}
|
||||
else if (slot >= 36 && slot <= 44)
|
||||
{
|
||||
if (disguise.isHidingHeldItemFromSelf())
|
||||
{
|
||||
else if (slot >= 36 && slot <= 44) {
|
||||
if (disguise.isHidingHeldItemFromSelf()) {
|
||||
int currentSlot = event.getPlayer().getInventory().getHeldItemSlot();
|
||||
|
||||
// Check if the player is on the same slot as the slot that its setting
|
||||
if (slot == currentSlot + 36)
|
||||
{
|
||||
if (slot == currentSlot + 36) {
|
||||
PacketContainer packet = new PacketContainer(Server.SET_SLOT);
|
||||
|
||||
StructureModifier<Object> mods = packet.getModifier();
|
||||
@ -254,12 +215,10 @@ public class PacketListenerInventory extends PacketAdapter
|
||||
mods.write(1, slot);
|
||||
mods.write(2, ReflectionManager.getNmsItem(new org.bukkit.inventory.ItemStack(0)));
|
||||
|
||||
try
|
||||
{
|
||||
try {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(event.getPlayer(), packet, false);
|
||||
}
|
||||
catch (InvocationTargetException e)
|
||||
{
|
||||
catch (InvocationTargetException e) {
|
||||
e.printStackTrace();
|
||||
}
|
||||
}
|
||||
@ -272,20 +231,17 @@ public class PacketListenerInventory extends PacketAdapter
|
||||
}
|
||||
|
||||
@Override
|
||||
public void onPacketSending(PacketEvent event)
|
||||
{
|
||||
public void onPacketSending(PacketEvent event) {
|
||||
// If the inventory is the players inventory
|
||||
if (event.getPlayer() instanceof com.comphenix.net.sf.cglib.proxy.Factory || event.getPlayer().getVehicle() != null
|
||||
|| event.getPacket().getIntegers().read(0) != 0)
|
||||
{
|
||||
|| event.getPacket().getIntegers().read(0) != 0) {
|
||||
return;
|
||||
}
|
||||
|
||||
Disguise disguise = DisguiseAPI.getDisguise(event.getPlayer(), event.getPlayer());
|
||||
|
||||
if (disguise == null || !disguise.isSelfDisguiseVisible()
|
||||
|| (!disguise.isHidingArmorFromSelf() && !disguise.isHidingHeldItemFromSelf()))
|
||||
{
|
||||
|| (!disguise.isHidingArmorFromSelf() && !disguise.isHidingHeldItemFromSelf())) {
|
||||
return;
|
||||
}
|
||||
|
||||
@ -297,24 +253,20 @@ public class PacketListenerInventory extends PacketAdapter
|
||||
/**
|
||||
* Done
|
||||
*/
|
||||
if (event.getPacketType() == Server.SET_SLOT)
|
||||
{
|
||||
if (event.getPacketType() == Server.SET_SLOT) {
|
||||
// The raw slot
|
||||
// nms code has the start of the hotbar being 36.
|
||||
int slot = event.getPacket().getIntegers().read(1);
|
||||
|
||||
// If the slot is a armor slot
|
||||
if (slot >= 5 && slot <= 8)
|
||||
{
|
||||
if (disguise.isHidingArmorFromSelf())
|
||||
{
|
||||
if (slot >= 5 && slot <= 8) {
|
||||
if (disguise.isHidingArmorFromSelf()) {
|
||||
// Get the bukkit armor slot!
|
||||
int armorSlot = Math.abs((slot - 5) - 3);
|
||||
|
||||
org.bukkit.inventory.ItemStack item = event.getPlayer().getInventory().getArmorContents()[armorSlot];
|
||||
|
||||
if (item != null && item.getType() != Material.AIR)
|
||||
{
|
||||
if (item != null && item.getType() != Material.AIR) {
|
||||
event.setPacket(event.getPacket().shallowClone());
|
||||
|
||||
event.getPacket().getModifier().write(2,
|
||||
@ -323,19 +275,15 @@ public class PacketListenerInventory extends PacketAdapter
|
||||
}
|
||||
// Else if its a hotbar slot
|
||||
}
|
||||
else if (slot >= 36 && slot <= 44)
|
||||
{
|
||||
if (disguise.isHidingHeldItemFromSelf())
|
||||
{
|
||||
else if (slot >= 36 && slot <= 44) {
|
||||
if (disguise.isHidingHeldItemFromSelf()) {
|
||||
int currentSlot = event.getPlayer().getInventory().getHeldItemSlot();
|
||||
|
||||
// Check if the player is on the same slot as the slot that its setting
|
||||
if (slot == currentSlot + 36)
|
||||
{
|
||||
if (slot == currentSlot + 36) {
|
||||
org.bukkit.inventory.ItemStack item = event.getPlayer().getItemInHand();
|
||||
|
||||
if (item != null && item.getType() != Material.AIR)
|
||||
{
|
||||
if (item != null && item.getType() != Material.AIR) {
|
||||
event.setPacket(event.getPacket().shallowClone());
|
||||
event.getPacket().getModifier().write(2,
|
||||
ReflectionManager.getNmsItem(new org.bukkit.inventory.ItemStack(0)));
|
||||
@ -344,45 +292,36 @@ public class PacketListenerInventory extends PacketAdapter
|
||||
}
|
||||
}
|
||||
}
|
||||
else if (event.getPacketType() == Server.WINDOW_ITEMS)
|
||||
{
|
||||
else if (event.getPacketType() == Server.WINDOW_ITEMS) {
|
||||
event.setPacket(event.getPacket().deepClone());
|
||||
|
||||
StructureModifier<ItemStack[]> mods = event.getPacket().getItemArrayModifier();
|
||||
ItemStack[] items = mods.read(0);
|
||||
StructureModifier<List<ItemStack>> mods = event.getPacket().getItemListModifier();
|
||||
List<ItemStack> items = mods.read(0);
|
||||
|
||||
for (int slot = 0; slot < items.length; slot++)
|
||||
{
|
||||
if (slot >= 5 && slot <= 8)
|
||||
{
|
||||
if (disguise.isHidingArmorFromSelf())
|
||||
{
|
||||
for (int slot = 0; slot < items.size(); slot++) {
|
||||
if (slot >= 5 && slot <= 8) {
|
||||
if (disguise.isHidingArmorFromSelf()) {
|
||||
// Get the bukkit armor slot!
|
||||
int armorSlot = Math.abs((slot - 5) - 3);
|
||||
|
||||
org.bukkit.inventory.ItemStack item = event.getPlayer().getInventory().getArmorContents()[armorSlot];
|
||||
ItemStack item = event.getPlayer().getInventory().getArmorContents()[armorSlot];
|
||||
|
||||
if (item != null && item.getType() != Material.AIR)
|
||||
{
|
||||
items[slot] = new org.bukkit.inventory.ItemStack(0);
|
||||
if (item != null && item.getType() != Material.AIR) {
|
||||
items.set(slot, new ItemStack(Material.AIR));
|
||||
}
|
||||
}
|
||||
// Else if its a hotbar slot
|
||||
}
|
||||
else if (slot >= 36 && slot <= 44)
|
||||
{
|
||||
if (disguise.isHidingHeldItemFromSelf())
|
||||
{
|
||||
else if (slot >= 36 && slot <= 44) {
|
||||
if (disguise.isHidingHeldItemFromSelf()) {
|
||||
int currentSlot = event.getPlayer().getInventory().getHeldItemSlot();
|
||||
|
||||
// Check if the player is on the same slot as the slot that its setting
|
||||
if (slot == currentSlot + 36)
|
||||
{
|
||||
org.bukkit.inventory.ItemStack item = event.getPlayer().getItemInHand();
|
||||
if (slot == currentSlot + 36) {
|
||||
ItemStack item = event.getPlayer().getItemInHand();
|
||||
|
||||
if (item != null && item.getType() != Material.AIR)
|
||||
{
|
||||
items[slot] = new org.bukkit.inventory.ItemStack(0);
|
||||
if (item != null && item.getType() != Material.AIR) {
|
||||
items.set(slot, new ItemStack(Material.AIR));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user