Fixed bug where players switching worlds would become invisible.

Fixed bug where arrows wouldn't blow disguises.
Added default permission for /libsdisguises reload (only ops can use by default)
This commit is contained in:
NavidK0 2015-08-02 18:39:44 -04:00
parent 3e19045a2c
commit 41cfa8eeaa
51 changed files with 2032 additions and 2009 deletions

@ -13,7 +13,7 @@ println 'Compiling LibsDisguises via Gradle ver. ' + gradle.gradleVersion
sourceCompatibility = '1.7'
ext.spigotVersion = '1.8.8-R0.1-SNAPSHOT'
ext.disguisesVersion = '8.6.3'
ext.disguisesVersion = '8.6.4'
[compileJava, compileTestJava]*.options*.encoding = 'UTF-8'

@ -143,8 +143,9 @@ public class DisguiseAPI {
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) {
@ -192,12 +193,14 @@ public class DisguiseAPI {
/**
* Disguise the next entity to spawn with this disguise. This may not work however if the entity doesn't actually spawn.
*
* @param disguise
* @return
*/
public static int disguiseNextEntity(Disguise disguise) {
if (disguise == null)
if (disguise == null) {
return -1;
}
if (disguise.getEntity() != null || DisguiseUtilities.getDisguises().containsValue(disguise)) {
disguise = disguise.clone();
}
@ -215,6 +218,7 @@ public class DisguiseAPI {
/**
* Disguise this entity with this disguise
*
* @param entity
* @param disguise
*/
@ -224,8 +228,9 @@ public class DisguiseAPI {
}
// 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);
}
@ -268,40 +273,47 @@ public class DisguiseAPI {
/**
* Get the disguise of a entity
*
* @param disguised
* @return
*/
public static Disguise getDisguise(Entity disguised) {
if (disguised == null)
if (disguised == null) {
return null;
}
return DisguiseUtilities.getMainDisguise(disguised.getUniqueId());
}
/**
* Get the disguise of a entity
*
* @param observer
* @param disguised
* @return
*/
public static Disguise getDisguise(Player observer, Entity disguised) {
if (disguised == null || observer == null)
if (disguised == null || observer == null) {
return null;
}
return DisguiseUtilities.getDisguise(observer, disguised);
}
/**
* Get the disguises of a entity
*
* @param disguised
* @return
*/
public static Disguise[] getDisguises(Entity disguised) {
if (disguised == null)
if (disguised == null) {
return null;
}
return DisguiseUtilities.getDisguises(disguised.getUniqueId());
}
/**
* Get the ID of a fake disguise for a entityplayer
*
* @param entityId
* @return
*/
@ -316,6 +328,7 @@ public class DisguiseAPI {
/**
* Is this entity disguised
*
* @param disguised
* @return
*/
@ -325,6 +338,7 @@ public class DisguiseAPI {
/**
* Is this entity disguised
*
* @param observer
* @param disguised
* @return
@ -342,8 +356,8 @@ public class DisguiseAPI {
}
/**
* Returns true if the entitiy has /disguiseviewself toggled
* on.
* Returns true if the entitiy has /disguiseviewself toggled on.
*
* @param entity
* @return
*/
@ -352,8 +366,8 @@ public class DisguiseAPI {
}
/**
* Undisguise the entity. This doesn't let you cancel the UndisguiseEvent if the entity is no longer valid. Aka removed from
* the world.
* Undisguise the entity. This doesn't let you cancel the UndisguiseEvent if the entity is no longer valid. Aka removed from the world.
*
* @param entity
*/
public static void undisguiseToAll(Entity entity) {
@ -364,8 +378,8 @@ public class DisguiseAPI {
}
/**
* Set whether this player can see his
* own disguise or not.
* Set whether this player can see his own disguise or not.
*
* @param entity
* @param toggled
*/
@ -375,8 +389,9 @@ public class DisguiseAPI {
disguise.setViewSelfDisguise(toggled);
}
if (toggled) {
if (!Disguise.getViewSelf().contains(entity.getUniqueId()))
if (!Disguise.getViewSelf().contains(entity.getUniqueId())) {
Disguise.getViewSelf().add(entity.getUniqueId());
}
} else {
Disguise.getViewSelf().remove(entity.getUniqueId());
}

@ -6,6 +6,7 @@ import org.bukkit.ChatColor;
import org.bukkit.configuration.ConfigurationSection;
public class DisguiseConfig {
private static boolean animationEnabled;
private static boolean bedEnabled;
private static boolean blowDisguisesOnAttack;
@ -218,6 +219,7 @@ public class DisguiseConfig {
/**
* Is the velocity packets sent
*
* @return
*/
public static boolean isVelocitySent() {
@ -226,6 +228,7 @@ public class DisguiseConfig {
/**
* The default value if a player views his own disguise
*
* @return
*/
public static boolean isViewDisguises() {
@ -408,6 +411,7 @@ public class DisguiseConfig {
/**
* Disable velocity packets being sent for w/e reason. Maybe you want every ounce of performance you can get?
*
* @param sendVelocityPackets
*/
public static void setVelocitySent(boolean sendVelocityPackets) {

@ -38,6 +38,7 @@ import org.bukkit.scheduler.BukkitRunnable;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.PacketContainer;
import org.bukkit.entity.Arrow;
import org.bukkit.scheduler.BukkitTask;
public class DisguiseListener implements Listener {
@ -66,11 +67,13 @@ public class DisguiseListener implements Listener {
Bukkit.getScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
for (Player p : Bukkit.getOnlinePlayers())
if (p.hasPermission(DisguiseConfig.getUpdateNotificationPermission()))
for (Player p : Bukkit.getOnlinePlayers()) {
if (p.hasPermission(DisguiseConfig.getUpdateNotificationPermission())) {
p.sendMessage(String.format(DisguiseConfig.getUpdateMessage(), currentVersion,
latestVersion));
}
}
}
});
}
} catch (Exception ex) {
@ -159,6 +162,8 @@ public class DisguiseListener implements Listener {
/**
* Most likely faster if we don't bother doing checks if he sees a player disguise
*
* @param event
*/
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onMove(PlayerMoveEvent event) {
@ -266,12 +271,13 @@ public class DisguiseListener implements Listener {
if (DisguiseAPI.isDisguised(entity)) {
DisguiseAPI.undisguiseToAll(entity);
p.sendMessage(ChatColor.RED + "Undisguised " + (entity instanceof Player ? "" : "the ") + entityName);
} else
} else {
p.sendMessage(ChatColor.RED + (entity instanceof Player ? "" : "the") + entityName + " isn't disguised!");
}
}
}
}
}
@EventHandler
public void onTarget(EntityTargetEvent event) {
@ -292,6 +298,9 @@ public class DisguiseListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onTeleport(final PlayerTeleportEvent event) {
if (!DisguiseAPI.isDisguised(event.getPlayer())) {
return;
}
Location to = event.getTo();
Location from = event.getFrom();
if (DisguiseConfig.isBedPacketsEnabled()) {
@ -301,7 +310,7 @@ public class DisguiseListener implements Listener {
int z2 = (int) Math.floor(from.getZ() / 16D) - 17;
if (x1 - (x1 % 8) != x2 - (x2 % 8) || z1 - (z1 % 8) != z2 - (z2 % 8)) {
chunkMove(event.getPlayer(), null, from);
Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
Bukkit.getScheduler().runTask(plugin, new Runnable() {
@Override
public void run() {
if (!event.isCancelled()) {
@ -318,6 +327,17 @@ public class DisguiseListener implements Listener {
for (Disguise disguise : DisguiseAPI.getDisguises(event.getPlayer())) {
disguise.removeDisguise();
}
} else {
//Stupid hack to fix worldswitch invisibility bug
final boolean viewSelfToggled = DisguiseAPI.isViewSelfToggled(event.getPlayer());
final Disguise disguise = DisguiseAPI.getDisguise(event.getPlayer());
disguise.setViewSelfDisguise(!viewSelfToggled);
Bukkit.getScheduler().runTaskLater(plugin, new Runnable() {
@Override
public void run() {
disguise.setViewSelfDisguise(viewSelfToggled);
}
}, 20L); //I wish I could use lambdas here, so badly
}
}
@ -347,6 +367,9 @@ public class DisguiseListener implements Listener {
@EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
public void onWorldSwitch(final PlayerChangedWorldEvent event) {
if (!DisguiseAPI.isDisguised(event.getPlayer())) {
return;
}
if (DisguiseConfig.isBedPacketsEnabled()) {
chunkMove(event.getPlayer(), event.getPlayer().getLocation(), null);
}

@ -69,7 +69,8 @@ public class LibsDisguises extends JavaPlugin {
try {
Metrics metrics = new Metrics(this);
metrics.start();
} catch (IOException e) {}
} catch (IOException e) {
}
}
/**
@ -82,8 +83,7 @@ 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.
* 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()) {

@ -62,10 +62,12 @@ public class DisguiseCommand extends BaseDisguiseCommand {
sender.sendMessage(ChatColor.DARK_GREEN + "Choose a disguise to become the disguise!");
sender.sendMessage(ChatColor.DARK_GREEN + "You can use the disguises: " + ChatColor.GREEN
+ StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN));
if (allowedDisguises.contains("player"))
if (allowedDisguises.contains("player")) {
sender.sendMessage(ChatColor.DARK_GREEN + "/disguise player <Name>");
}
sender.sendMessage(ChatColor.DARK_GREEN + "/disguise <DisguiseType> <Baby>");
if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block"))
if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) {
sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseplayer <Dropped_Item/Falling_Block> <Id> <Durability>");
}
}
}

@ -42,6 +42,7 @@ public class DisguiseEntityCommand extends BaseDisguiseCommand {
/**
* Send the player the information
*
* @param sender
* @param map
*/
@ -51,11 +52,13 @@ public class DisguiseEntityCommand extends BaseDisguiseCommand {
sender.sendMessage(ChatColor.DARK_GREEN + "Choose a disguise then right click a entity to disguise it!");
sender.sendMessage(ChatColor.DARK_GREEN + "You can use the disguises: " + ChatColor.GREEN
+ StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN));
if (allowedDisguises.contains("player"))
if (allowedDisguises.contains("player")) {
sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseentity player <Name>");
}
sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseentity <DisguiseType> <Baby>");
if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block"))
if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) {
sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseentity <Dropped_Item/Falling_Block> <Id> <Durability>");
}
}
}

@ -22,7 +22,9 @@ import org.bukkit.inventory.ItemStack;
import org.bukkit.potion.PotionEffectType;
public class DisguiseHelpCommand extends BaseDisguiseCommand {
private class EnumHelp {
private String enumDescription;
private String enumName;
private String[] enums;
@ -99,10 +101,11 @@ public class DisguiseHelpCommand extends BaseDisguiseCommand {
try {
ArrayList<String> enumReturns = new ArrayList<>();
for (PotionEffectType potionType : PotionEffectType.values()) {
if (potionType != null)
if (potionType != null) {
enumReturns.add(toReadable(potionType.getName()) + ChatColor.RED + "(" + ChatColor.GREEN + potionType.getId()
+ ChatColor.RED + ")");
}
}
enumHelp.add(new EnumHelp("PotionEffect", "PotionEffect", ChatColor.RED + "/disguisehelp PotionEffect "
+ ChatColor.GREEN + "- View all the potion effects you can set", enumReturns.toArray(new String[enumReturns
.size()])));
@ -273,8 +276,9 @@ public class DisguiseHelpCommand extends BaseDisguiseCommand {
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, "_");
}
}

@ -85,11 +85,13 @@ public class DisguisePlayerCommand extends BaseDisguiseCommand {
sender.sendMessage(ChatColor.DARK_GREEN + "Disguise another player!");
sender.sendMessage(ChatColor.DARK_GREEN + "You can use the disguises: " + ChatColor.GREEN
+ StringUtils.join(allowedDisguises, ChatColor.RED + ", " + ChatColor.GREEN));
if (allowedDisguises.contains("player"))
if (allowedDisguises.contains("player")) {
sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseplayer <PlayerName> player <Name>");
}
sender.sendMessage(ChatColor.DARK_GREEN + "/disguiseplayer <PlayerName> <DisguiseType> <Baby>");
if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block"))
if (allowedDisguises.contains("dropped_item") || allowedDisguises.contains("falling_block")) {
sender.sendMessage(ChatColor.DARK_GREEN
+ "/disguiseplayer <PlayerName> <Dropped_Item/Falling_Block> <Id> <Durability>");
}
}
}

@ -21,6 +21,7 @@ import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Player;
public class DisguiseRadiusCommand extends BaseDisguiseCommand {
private int maxRadius = 30;
private ArrayList<Class> validClasses = new ArrayList<>();
@ -111,8 +112,9 @@ public class DisguiseRadiusCommand extends BaseDisguiseCommand {
int disguisedEntitys = 0;
int miscDisguises = 0;
for (Entity entity : ((Player) sender).getNearbyEntities(radius, radius, radius)) {
if (entity == sender)
if (entity == sender) {
continue;
}
if (type != null ? entity.getType() == type : entityClass.isAssignableFrom(entity.getClass())) {
if (disguise.isMiscDisguise() && !DisguiseConfig.isMiscDisguisesForLivingEnabled()
&& entity instanceof LivingEntity) {

@ -19,7 +19,7 @@ public class LibsDisguisesCommand implements CommandExecutor {
+ " by libraryaddict, maintained by NavidK0.\n"
+ "Use /libsdisguises reload to reload the config. All disguises will be blown by doing this.");
} else if (args.length > 0) {
if (!sender.hasPermission("libsdisguises.reload")) {
if (sender.hasPermission("libsdisguises.reload")) {
if (args[0].equalsIgnoreCase("reload")) {
LibsDisguises.instance.reload();
sender.sendMessage(ChatColor.GREEN + "[LibsDisguises] Reloaded config.");

@ -21,10 +21,12 @@ public class UndisguiseCommand implements CommandExecutor {
if (DisguiseAPI.isDisguised((Entity) sender)) {
DisguiseAPI.undisguiseToAll((Player) sender);
sender.sendMessage(ChatColor.RED + "You are no longer disguised");
} else
} else {
sender.sendMessage(ChatColor.RED + "You are not disguised!");
} else
}
} else {
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
}
return true;
}
}

@ -19,8 +19,9 @@ public class UndisguiseEntityCommand implements CommandExecutor {
if (sender.hasPermission("libsdisguises.undisguiseentity")) {
LibsDisguises.instance.getListener().setDisguiseEntity(sender.getName(), null);
sender.sendMessage(ChatColor.RED + "Right click a disguised entity to undisguise them!");
} else
} else {
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
}
return true;
}
}

@ -20,14 +20,18 @@ public class UndisguisePlayerCommand implements CommandExecutor {
if (DisguiseAPI.isDisguised(p)) {
DisguiseAPI.undisguiseToAll(p);
sender.sendMessage(ChatColor.RED + "The player is no longer disguised");
} else
} else {
sender.sendMessage(ChatColor.RED + "The player is not disguised!");
} else
}
} else {
sender.sendMessage(ChatColor.RED + "Player not found");
} else
}
} else {
sender.sendMessage(ChatColor.RED + "/undisguiseplayer <Name>");
} else
}
} else {
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
}
return true;
}
}

@ -10,6 +10,7 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.Player;
public class UndisguiseRadiusCommand implements CommandExecutor {
private int maxRadius = 30;
public UndisguiseRadiusCommand(int maxRadius) {
@ -48,16 +49,18 @@ public class UndisguiseRadiusCommand implements CommandExecutor {
}
int disguisedEntitys = 0;
for (Entity entity : ((Player) sender).getNearbyEntities(radius, radius, radius)) {
if (entity == sender)
if (entity == sender) {
continue;
}
if (DisguiseAPI.isDisguised(entity)) {
DisguiseAPI.undisguiseToAll(entity);
disguisedEntitys++;
}
}
sender.sendMessage(ChatColor.RED + "Successfully undisguised " + disguisedEntitys + " entities!");
} else
} else {
sender.sendMessage(ChatColor.RED + "You are forbidden to use this command.");
}
return true;
}
}

@ -1,6 +1,7 @@
package me.libraryaddict.disguise.disguisetypes;
public enum AnimalColor {
BLACK(15), BLUE(11), BROWN(12), CYAN(9), GRAY(7), GREEN(13), LIGHT_BLUE(3), LIME(5), MAGENTA(2), ORANGE(1), PINK(6), PURPLE(
10), RED(14), SILVER(8), WHITE(0), YELLOW(4);

@ -39,6 +39,7 @@ import java.util.Map;
import me.libraryaddict.disguise.LibsDisguises;
public abstract class Disguise {
private boolean disguiseInUse;
private DisguiseType disguiseType;
private Entity entity;
@ -64,11 +65,13 @@ public abstract class Disguise {
/**
* Seems I do this method so I can make cleaner constructors on disguises..
*
* @param newType
*/
protected void createDisguise(DisguiseType newType) {
if (getWatcher() != null)
if (getWatcher() != null) {
return;
}
if (newType.getEntityType() == null) {
throw new RuntimeException(
"DisguiseType "
@ -99,16 +102,12 @@ public abstract class Disguise {
// If the disguise type is a wither, set the flagwatcher value for the skeleton to a wither skeleton
if (getType() == DisguiseType.WITHER_SKELETON) {
getWatcher().setValue(13, (byte) 1);
}
// Else if its a zombie, but the disguise type is a zombie villager. Set the value.
} // Else if its a zombie, but the disguise type is a zombie villager. Set the value.
else if (getType() == DisguiseType.ZOMBIE_VILLAGER) {
getWatcher().setValue(13, (byte) 1);
}
else if (getType() == DisguiseType.ELDER_GUARDIAN) {
} else if (getType() == DisguiseType.ELDER_GUARDIAN) {
getWatcher().setValue(16, 0 | 4);
}
// Else if its a horse. Set the horse watcher type
} // Else if its a horse. Set the horse watcher type
else if (getWatcher() instanceof HorseWatcher) {
try {
// Don't mess with this because Varient is something like ZombieHorse and so on.
@ -328,6 +327,7 @@ public abstract class Disguise {
/**
* Get the disguised entity
*
* @return
*/
public Entity getEntity() {
@ -336,6 +336,7 @@ public abstract class Disguise {
/**
* Get the disguise type
*
* @return
*/
public DisguiseType getType() {
@ -344,6 +345,7 @@ public abstract class Disguise {
/**
* Get the flag watcher
*
* @return
*/
public FlagWatcher getWatcher() {
@ -351,8 +353,8 @@ public abstract class Disguise {
}
/**
* In use doesn't mean that this disguise is active. It means that Lib's Disguises still stores a reference to the disguise.
* getEntity() can still return null if this disguise is active after despawn, logout, etc.
* In use doesn't mean that this disguise is active. It means that Lib's Disguises still stores a reference to the disguise. getEntity() can still return null if this disguise is active after despawn, logout, etc.
*
* @return
*/
public boolean isDisguiseInUse() {
@ -397,17 +399,16 @@ public abstract class Disguise {
/**
* Internal use
*
* @return
*/
public boolean isRemoveDisguiseOnDeath() {
if (getEntity() == null) return true;
return getEntity() instanceof Player ?
(!((Player) getEntity()).isOnline() ? !isKeepDisguiseOnPlayerLogout() : !isKeepDisguiseOnPlayerDeath())
:
(!isKeepDisguiseOnEntityDespawn() || getEntity().isDead());
if (getEntity() == null) {
return true;
}
return getEntity() instanceof Player
? (!((Player) getEntity()).isOnline() ? !isKeepDisguiseOnPlayerLogout() : !isKeepDisguiseOnPlayerDeath())
: (!isKeepDisguiseOnEntityDespawn() || getEntity().isDead());
}
public boolean isSelfDisguiseSoundsReplaced() {
@ -416,6 +417,7 @@ public abstract class Disguise {
/**
* Can the disguised view himself as the disguise
*
* @return
*/
public boolean isSelfDisguiseVisible() {
@ -432,6 +434,7 @@ public abstract class Disguise {
/**
* Returns true if the entity's name is showing through the disguise
*
* @return
*/
public boolean isShowName() {
@ -503,13 +506,15 @@ public abstract class Disguise {
/**
* Set the entity of the disguise. Only used for internal things.
*
* @param entity
* @return
*/
public Disguise setEntity(Entity entity) {
if (this.getEntity() != null) {
if (getEntity() == entity)
if (getEntity() == entity) {
return this;
}
throw new RuntimeException("This disguise is already in use! Try .clone()");
}
if (isMiscDisguise() && !DisguiseConfig.isMiscDisguisesForLivingEnabled() && entity instanceof LivingEntity) {
@ -582,8 +587,7 @@ 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.
* Sets up the FlagWatcher with the entityclass, it creates all the data it needs to prevent conflicts when sending the datawatcher.
*/
private void setupWatcher() {
HashMap<Integer, Object> disguiseValues = DisguiseValues.getMetaValues(getType());
@ -611,8 +615,9 @@ public abstract class Disguise {
}
// STEP 2. As the watcher has not set data on it, check if I need to set the default data.
// If neither of them touch it
if (!entityValues.containsKey(dataNo) && !disguiseValues.containsKey(dataNo))
if (!entityValues.containsKey(dataNo) && !disguiseValues.containsKey(dataNo)) {
continue;
}
// If the disguise has this, but not the entity. Then better set it!
if (!entityValues.containsKey(dataNo) && disguiseValues.containsKey(dataNo)) {
getWatcher().setBackupValue(dataNo, disguiseValues.get(dataNo));
@ -626,9 +631,9 @@ public abstract class Disguise {
Object eObj = entityValues.get(dataNo);
Object dObj = disguiseValues.get(dataNo);
if (eObj == null || dObj == null) {
if (eObj == null && dObj == null)
if (eObj == null && dObj == null) {
continue;
else {
} else {
getWatcher().setBackupValue(dataNo, dObj);
continue;
}
@ -645,7 +650,6 @@ public abstract class Disguise {
// EntityInsentient is 10 & 11
// EntityZombie is 12 & 13 & 14 - But it overrides other values and another check already does this.
// EntityLiving is 6 & 7 & 8 & 9
// Lets use switch
Class baseClass = null;
switch (dataNo) {
@ -670,16 +674,18 @@ public abstract class Disguise {
if (nmsDisguiseClass != null) {
// If they both extend the same base class. They OBVIOUSLY share the same datavalue. Right..?
if (baseClass != null && baseClass.isAssignableFrom(nmsDisguiseClass)
&& baseClass.isAssignableFrom(nmsEntityClass))
&& baseClass.isAssignableFrom(nmsEntityClass)) {
continue;
}
// So they don't extend a basic class.
// Maybe if I check that they extend each other..
// Seeing as I only store the finished forms of entitys. This should raise no problems and allow for more shared
// datawatchers.
if (nmsEntityClass.isAssignableFrom(nmsDisguiseClass) || nmsDisguiseClass.isAssignableFrom(nmsEntityClass))
if (nmsEntityClass.isAssignableFrom(nmsDisguiseClass) || nmsDisguiseClass.isAssignableFrom(nmsEntityClass)) {
continue;
}
}
// Well I can't find a reason I should leave it alone. They will probably conflict.
// Time to set the value to the disguises value so no conflicts!
getWatcher().setBackupValue(dataNo, disguiseValues.get(dataNo));
@ -704,11 +710,12 @@ public abstract class Disguise {
if (DisguiseAPI.getDisguise((Player) getEntity(), getEntity()) == this) {
if (isSelfDisguiseVisible()) {
DisguiseUtilities.setupFakeDisguise(this);
} else
} else {
DisguiseUtilities.removeSelfDisguise((Player) getEntity());
}
}
}
}
return this;
}
@ -762,8 +769,8 @@ public abstract class Disguise {
}
/**
* Returns the list of people who have /disguiseViewSelf
* toggled on
* Returns the list of people who have /disguiseViewSelf toggled on
*
* @return
*/
public static List<UUID> getViewSelf() {

@ -11,144 +11,76 @@ import org.bukkit.entity.Skeleton;
import org.bukkit.entity.Zombie;
public enum DisguiseType {
ARMOR_STAND(78),
ARROW(60),
BAT,
BLAZE,
BOAT(1),
CAVE_SPIDER,
CHICKEN,
COW,
CREEPER,
DONKEY,
DROPPED_ITEM(2, 1),
EGG(62),
ELDER_GUARDIAN,
ENDER_CRYSTAL(51),
ENDER_DRAGON,
ENDER_PEARL(65),
ENDER_SIGNAL(72),
ENDERMAN,
ENDERMITE,
EXPERIENCE_ORB,
FALLING_BLOCK(70, 1),
FIREBALL(63, 0),
FIREWORK(76),
FISHING_HOOK(90),
GHAST,
GIANT,
GUARDIAN,
HORSE,
IRON_GOLEM,
ITEM_FRAME(71),
LEASH_HITCH(77),
MAGMA_CUBE,
MINECART(10, 0),
MINECART_CHEST(10, 1),
MINECART_COMMAND(10, 6),
MINECART_FURNACE(10, 2),
MINECART_HOPPER(10, 5),
MINECART_MOB_SPAWNER(10, 4),
MINECART_TNT(10, 3),
MULE,
MUSHROOM_COW,
OCELOT,
PAINTING,
PIG,
PIG_ZOMBIE,
PLAYER,
PRIMED_TNT(50),
RABBIT,
SHEEP,
SILVERFISH,
SKELETON,
SKELETON_HORSE,
SLIME,
SMALL_FIREBALL(64, 0),
SNOWBALL(61),
SNOWMAN,
SPIDER,
SPLASH_POTION(73),
SQUID,
THROWN_EXP_BOTTLE(75),
UNDEAD_HORSE,
VILLAGER,
WITCH,
WITHER,
WITHER_SKELETON,
WITHER_SKULL(66),
WOLF,
ZOMBIE,
ZOMBIE_VILLAGER,
UNKNOWN;
private static Method isVillager, getVariant, getSkeletonType, isElder;
@ -332,8 +264,9 @@ public enum DisguiseType {
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();
}
return StringUtils.join(split, " ");
}
}

@ -24,7 +24,9 @@ import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utilities.ReflectionManager;
public class FlagWatcher {
public enum SlotType {
BOOTS(0), CHESTPLATE(2), HELD_ITEM(4), HELMET(3), LEGGINGS(1);
// The ints is for bukkit. Not nms slots.
private int slotNo = 0;
@ -89,16 +91,19 @@ public class FlagWatcher {
sentValues.add(dataType);
// Its sending the air metadata. This is the least commonly sent metadata which all entitys still share.
// I send my custom values if I see this!
if (dataType == 1)
if (dataType == 1) {
sendAllCustom = true;
}
Object value = null;
if (entityValues.containsKey(dataType)) {
if (entityValues.get(dataType) == null)
if (entityValues.get(dataType) == null) {
continue;
}
value = entityValues.get(dataType);
} else if (backupEntityValues.containsKey(dataType)) {
if (backupEntityValues.get(dataType) == null)
if (backupEntityValues.get(dataType) == null) {
continue;
}
value = backupEntityValues.get(dataType);
}
if (value != null) {
@ -107,24 +112,28 @@ public class FlagWatcher {
}
boolean isDirty = watch.getDirtyState();
watch = new WrappedWatchableObject(dataType, value);
if (!isDirty)
if (!isDirty) {
watch.setDirtyState(false);
}
} else {
boolean isDirty = watch.getDirtyState();
watch = new WrappedWatchableObject(dataType, watch.getValue());
if (!isDirty)
if (!isDirty) {
watch.setDirtyState(false);
}
}
newList.add(watch);
}
if (sendAllCustom) {
// Its sending the entire meta data. Better add the custom meta
for (int value : entityValues.keySet()) {
if (sentValues.contains(value))
if (sentValues.contains(value)) {
continue;
}
Object obj = entityValues.get(value);
if (obj == null)
if (obj == null) {
continue;
}
WrappedWatchableObject watch = new WrappedWatchableObject(value, obj);
newList.add(watch);
}
@ -182,8 +191,9 @@ public class FlagWatcher {
}
protected Object getValue(int no, Object backup) {
if (entityValues.containsKey(no))
if (entityValues.containsKey(no)) {
return entityValues.get(no);
}
return backup;
}
@ -246,12 +256,14 @@ public class FlagWatcher {
}
protected void sendData(int... dataValues) {
if (!DisguiseAPI.isDisguiseInUse(getDisguise()) || getDisguise().getWatcher() != this)
if (!DisguiseAPI.isDisguiseInUse(getDisguise()) || getDisguise().getWatcher() != this) {
return;
}
List<WrappedWatchableObject> list = new ArrayList<>();
for (int data : dataValues) {
if (!entityValues.containsKey(data) || entityValues.get(data) == null)
if (!entityValues.containsKey(data) || entityValues.get(data) == null) {
continue;
}
Object value = entityValues.get(data);
if (isEntityAnimationsAdded() && DisguiseConfig.isMetadataPacketsEnabled() && data == 0) {
value = addEntityAnimations((Byte) value, WrappedDataWatcher.getEntityWatcher(disguise.getEntity()).getByte(0));
@ -348,8 +360,9 @@ public class FlagWatcher {
items[slot] = itemStack;
if (DisguiseAPI.isDisguiseInUse(getDisguise()) && getDisguise().getWatcher() == this) {
slot++;
if (slot > 4)
if (slot > 4) {
slot = 0;
}
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_EQUIPMENT);
StructureModifier<Object> mods = packet.getModifier();
mods.write(0, getDisguise().getEntity().getEntityId());

@ -14,6 +14,7 @@ import org.bukkit.entity.Player;
import org.bukkit.inventory.ItemStack;
public class MiscDisguise extends TargetedDisguise {
private int id = -1, data = 0;
public MiscDisguise(DisguiseType disguiseType) {

@ -13,14 +13,16 @@ import me.libraryaddict.disguise.utilities.LibsProfileLookup;
import me.libraryaddict.disguise.utilities.ReflectionManager;
public class PlayerDisguise extends TargetedDisguise {
private LibsProfileLookup currentLookup;
private WrappedGameProfile gameProfile;
private String playerName;
private String skinToUse;
public PlayerDisguise(String name) {
if (name.length() > 16)
if (name.length() > 16) {
name = name.substring(0, 16);
}
playerName = name;
createDisguise(DisguiseType.PLAYER);
}
@ -199,8 +201,7 @@ public class PlayerDisguise extends TargetedDisguise {
/**
* Set the GameProfile, without tampering.
*
* @param gameProfile
* GameProfile
* @param gameProfile GameProfile
* @return
*/
public PlayerDisguise setSkin(WrappedGameProfile gameProfile) {

@ -1,6 +1,7 @@
package me.libraryaddict.disguise.disguisetypes;
public enum RabbitType {
BLACK(2), BROWN(0), GOLD(4), KILLER_BUNNY(99), PATCHES(3), PEPPER(5), WHITE(1);
public static RabbitType getType(int id) {

@ -10,7 +10,9 @@ import me.libraryaddict.disguise.utilities.ReflectionManager;
import org.bukkit.entity.Player;
public abstract class TargetedDisguise extends Disguise {
public enum TargetType {
HIDE_DISGUISE_TO_EVERYONE_BUT_THESE_PLAYERS, SHOW_TO_EVERYONE_BUT_THESE_PLAYERS;
}

@ -30,9 +30,9 @@ public class ArmorStandWatcher extends LivingWatcher {
private void set10(int value, boolean isTrue) {
byte b1 = (Byte) getValue(10, (byte) 0);
if (isTrue)
if (isTrue) {
b1 = (byte) (b1 | value);
else {
} else {
b1 = (byte) (b1 & value);
}
setValue(10, b1);

@ -9,6 +9,7 @@ import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
public class FallingBlockWatcher extends FlagWatcher {
private ItemStack block;
public FallingBlockWatcher(Disguise disguise) {

@ -11,8 +11,9 @@ public class ItemFrameWatcher extends FlagWatcher {
}
public ItemStack getItem() {
if (getValue(2, null) == null)
if (getValue(2, null) == null) {
return new ItemStack(0);
}
return (ItemStack) getValue(8, null);
}
@ -21,8 +22,9 @@ public class ItemFrameWatcher extends FlagWatcher {
}
public void setItem(ItemStack newItem) {
if (newItem == null)
if (newItem == null) {
newItem = new ItemStack(0);
}
newItem = newItem.clone();
newItem.setAmount(1);
setValue(8, newItem);

@ -23,8 +23,10 @@ import com.comphenix.protocol.wrappers.WrappedAttribute;
import com.comphenix.protocol.wrappers.WrappedAttribute.Builder;
public class LivingWatcher extends FlagWatcher {
static Object[] list;
static Method potionNo;
static {
try {
list = (Object[]) ReflectionManager.getNmsField("MobEffectList", "byId").get(null);

@ -6,6 +6,7 @@ import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
public class PaintingWatcher extends FlagWatcher {
private Art painting;
public PaintingWatcher(Disguise disguise) {

@ -16,6 +16,7 @@ import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utilities.ReflectionManager.LibVersion;
public class PlayerWatcher extends LivingWatcher {
private boolean isInBed;
private BlockFace sleepingDirection;
@ -82,6 +83,7 @@ public class PlayerWatcher extends LivingWatcher {
/**
* If no BlockFace is supplied. It grabs it from the entities facing direction if applicable.
*
* @param sleeping
* @param sleepingDirection
*/

@ -5,6 +5,7 @@ import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
public class SplashPotionWatcher extends FlagWatcher {
private int potionId;
public SplashPotionWatcher(Disguise disguise) {

@ -8,6 +8,7 @@ import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class DisguiseEvent extends Event implements Cancellable {
private static final HandlerList handlers = new HandlerList();
public static HandlerList getHandlerList() {

@ -8,6 +8,7 @@ import org.bukkit.event.Event;
import org.bukkit.event.HandlerList;
public class UndisguiseEvent extends Event implements Cancellable {
private static final HandlerList handlers = new HandlerList();
public static HandlerList getHandlerList() {

@ -35,6 +35,7 @@ import org.bukkit.potion.PotionEffectType;
public abstract class BaseDisguiseCommand implements CommandExecutor {
public class DisguiseParseException extends Exception {
private static final long serialVersionUID = 1276971370793124510L;
public DisguiseParseException() {
@ -105,6 +106,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
/**
* Get perms for the node. Returns a hashmap of allowed disguisetypes and their options
*
* @param sender
* @param permissionNode
* @return
@ -265,8 +267,9 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
option = option.substring(1);
isRemove = false;
}
if (option.equals("baby"))
if (option.equals("baby")) {
option = "setbaby";
}
list.add(option);
}
HashMap<ArrayList<String>, Boolean> options = new HashMap<>();
@ -293,9 +296,8 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
}
/**
* Returns the disguise if it all parsed correctly. Returns a exception with a complete message if it didn't. The
* commandsender is purely used for checking permissions. Would defeat the purpose otherwise. To reach this point, the
* disguise has been feed a proper disguisetype.
* Returns the disguise if it all parsed correctly. Returns a exception with a complete message if it didn't. The commandsender is purely used for checking permissions. Would defeat the purpose otherwise. To reach this point, the disguise has been feed a proper disguisetype.
*
* @param sender
* @param args
* @param map
@ -577,8 +579,9 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
if (potionType == null && isNumeric(valueString)) {
potionType = PotionEffectType.getById(Integer.parseInt(valueString));
}
if (potionType == null)
if (potionType == null) {
throw new DisguiseParseException();
}
value = potionType;
} catch (Exception ex) {
throw parseToException("a potioneffect type", valueString, methodName);
@ -597,8 +600,9 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
} else if (param == BlockFace.class) {
try {
BlockFace face = BlockFace.valueOf(valueString.toUpperCase());
if (face.ordinal() > 4)
if (face.ordinal() > 4) {
throw new DisguiseParseException();
}
value = face;
} catch (Exception ex) {
throw parseToException("a direction (north, east, south, west, up)", valueString, methodName);
@ -661,11 +665,12 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
usedOptions.add(methodName.toLowerCase());
}
doCheck(optionPermissions, usedOptions);
if (FlagWatcher.class.isAssignableFrom(methodToUse.getDeclaringClass()))
if (FlagWatcher.class.isAssignableFrom(methodToUse.getDeclaringClass())) {
methodToUse.invoke(disguise.getWatcher(), value);
else
} else {
methodToUse.invoke(disguise, value);
}
}
// Alright. We've constructed our disguise.
return disguise;
}

@ -13,7 +13,6 @@ import java.util.jar.JarFile;
/**
* User: Austin Date: 4/22/13 Time: 11:47 PM (c) lazertester
*/
// Code for this taken and slightly modified from
// https://github.com/ddopson/java-class-enumerator
public class ClassGetter {
@ -59,10 +58,11 @@ public class ClassGetter {
}
if (className != null) {
Class<?> c = loadClass(className);
if (c != null)
if (c != null) {
classes.add(c);
}
}
}
} catch (Exception ex) {
ex.printStackTrace(System.out);
}

@ -11,107 +11,69 @@ import org.bukkit.Sound;
* Only living disguises go in here!
*/
public enum DisguiseSound {
ARROW(null, null, null, null, "random.bowhit"),
ARROW(null, null, null, null, "random.bowhit"),
BAT("mob.bat.hurt", null, "mob.bat.death", "mob.bat.idle", "damage.fallsmall", "mob.bat.loop", "damage.fallbig",
"mob.bat.takeoff"),
BLAZE("mob.blaze.hit", null, "mob.blaze.death", "mob.blaze.breathe", "damage.fallsmall", "damage.fallbig"),
CAVE_SPIDER("mob.spider.say", "mob.spider.step", "mob.spider.death", "mob.spider.say"),
CHICKEN("mob.chicken.hurt", "mob.chicken.step", "mob.chicken.hurt", "mob.chicken.say", "damage.fallsmall",
"mob.chicken.plop", "damage.fallbig"),
COW("mob.cow.hurt", "mob.cow.step", "mob.cow.hurt", "mob.cow.say"),
CREEPER("mob.creeper.say", "step.grass", "mob.creeper.death", null),
DONKEY("mob.horse.donkey.hit", "step.grass", "mob.horse.donkey.death", "mob.horse.donkey.idle", "mob.horse.gallop",
"mob.horse.leather", "mob.horse.donkey.angry", "mob.horse.wood", "mob.horse.armor", "mob.horse.soft",
"mob.horse.land", "mob.horse.jump", "mob.horse.angry"),
ELDER_GUARDIAN("mob.guardian.elder.hit", null, "mob.guardian.elder.death", "mob.guardian.elder.death"),
ENDER_DRAGON("mob.enderdragon.hit", null, "mob.enderdragon.end", "mob.enderdragon.growl", "damage.fallsmall",
"mob.enderdragon.wings", "damage.fallbig"),
ENDERMAN("mob.endermen.hit", "step.grass", "mob.endermen.death", "mob.endermen.idle", "mob.endermen.scream",
"mob.endermen.portal", "mob.endermen.stare"),
ENDERMITE("mob.silverfish.hit", "mob.silverfish.step", "mob.silverfish.kill", "mob.silverfish.say"),
GHAST("mob.ghast.scream", null, "mob.ghast.death", "mob.ghast.moan", "damage.fallsmall", "mob.ghast.fireball",
"damage.fallbig", "mob.ghast.affectionate_scream", "mob.ghast.charge"),
GIANT("damage.hit", "step.grass", null, null),
GUARDIAN("mob.guardian.hit", null, "mob.guardian.death", "mob.guardian.death"),
HORSE("mob.horse.hit", "step.grass", "mob.horse.death", "mob.horse.idle", "mob.horse.gallop", "mob.horse.leather",
"mob.horse.wood", "mob.horse.armor", "mob.horse.soft", "mob.horse.land", "mob.horse.jump", "mob.horse.angry",
"mob.horse.leather"),
IRON_GOLEM("mob.irongolem.hit", "mob.irongolem.walk", "mob.irongolem.death", "mob.irongolem.throw"),
MAGMA_CUBE("mob.slime.attack", "mob.slime.big", null, null, "mob.slime.small"),
MULE("mob.horse.donkey.hit", "step.grass", "mob.horse.donkey.death", "mob.horse.donkey.idle"),
MUSHROOM_COW("mob.cow.hurt", "mob.cow.step", "mob.cow.hurt", "mob.cow.say"),
OCELOT("mob.cat.hitt", "step.grass", "mob.cat.hitt", "mob.cat.meow", "mob.cat.purreow", "mob.cat.purr"),
PIG("mob.pig.say", "mob.pig.step", "mob.pig.death", "mob.pig.say"),
PIG_ZOMBIE("mob.zombiepig.zpighurt", null, "mob.zombiepig.zpigdeath", "mob.zombiepig.zpig", "mob.zombiepig.zpigangry"),
PLAYER("game.player.hurt", "step.grass", "game.player.hurt", null),
RABBIT("mob.rabbit.hurt", "mob.rabbit.hop", "mob.rabbit.death", "mob.rabbit.idle"),
SHEEP("mob.sheep.say", "mob.sheep.step", null, "mob.sheep.say", "mob.sheep.shear"),
SILVERFISH("mob.silverfish.hit", "mob.silverfish.step", "mob.silverfish.kill", "mob.silverfish.say"),
SKELETON("mob.skeleton.hurt", "mob.skeleton.step", "mob.skeleton.death", "mob.skeleton.say"),
SKELETON_HORSE("mob.horse.skeleton.hit", "step.grass", "mob.horse.skeleton.death", "mob.horse.skeleton.idle",
"mob.horse.gallop", "mob.horse.leather", "mob.horse.wood", "mob.horse.armor", "mob.horse.soft", "mob.horse.land",
"mob.horse.jump", "mob.horse.angry"),
SLIME("mob.slime.attack", "mob.slime.big", null, null, "mob.slime.small"),
SNOWMAN(),
SPIDER("mob.spider.say", "mob.spider.step", "mob.spider.death", "mob.spider.say"),
SQUID(),
UNDEAD_HORSE("mob.horse.zombie.hit", "step.grass", "mob.horse.zombie.death", "mob.horse.zombie.idle", "mob.horse.gallop",
"mob.horse.leather", "mob.horse.wood", "mob.horse.armor", "mob.horse.soft", "mob.horse.land", "mob.horse.jump",
"mob.horse.angry"),
VILLAGER("mob.villager.hit", null, "mob.villager.death", "mob.villager.idle", "mob.villager.haggle", "mob.villager.no",
"mob.villager.yes"),
WITCH("mob.witch.hurt", null, "mob.witch.death", "mob.witch.idle"),
WITHER("mob.wither.hurt", null, "mob.wither.death", "mob.wither.idle", "damage.fallsmall", "mob.wither.spawn",
"damage.fallbig", "mob.wither.shoot"),
WITHER_SKELETON("mob.skeleton.hurt", "mob.skeleton.step", "mob.skeleton.death", "mob.skeleton.say"),
WOLF("mob.wolf.hurt", "mob.wolf.step", "mob.wolf.death", "mob.wolf.bark", "mob.wolf.panting", "mob.wolf.whine",
"mob.wolf.howl", "mob.wolf.growl", "mob.wolf.shake"),
ZOMBIE("mob.zombie.hurt", "mob.zombie.step", "mob.zombie.death", "mob.zombie.say", "mob.zombie.infect",
"mob.zombie.woodbreak", "mob.zombie.metal", "mob.zombie.wood"),
ZOMBIE_VILLAGER("mob.zombie.hurt", "mob.zombie.step", "mob.zombie.death", "mob.zombie.say", "mob.zombie.infect",
"mob.zombie.woodbreak", "mob.zombie.metal", "mob.zombie.wood");
public enum SoundType {
CANCEL, DEATH, HURT, IDLE, STEP;
}
@ -131,9 +93,9 @@ public enum DisguiseSound {
for (int i = 0; i < sounds.length; i++) {
Object obj = sounds[i];
String s;
if (obj == null)
if (obj == null) {
continue;
else if (obj instanceof String) {
} else if (obj instanceof String) {
s = (String) obj;
} else if (obj instanceof Sound) {
s = ReflectionManager.getCraftSound((Sound) obj);
@ -166,8 +128,9 @@ public enum DisguiseSound {
}
public String getSound(SoundType type) {
if (type == null || !disguiseSounds.containsKey(type))
if (type == null || !disguiseSounds.containsKey(type)) {
return null;
}
return disguiseSounds.get(type);
}
@ -179,20 +142,24 @@ public enum DisguiseSound {
* Used to check if this sound name is owned by this disguise sound.
*/
public SoundType getType(String sound, boolean ignoreDamage) {
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))
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.equals(sound)) {
return type;
}
}
}
return null;
}
@ -205,9 +172,9 @@ public enum DisguiseSound {
}
public void removeSound(SoundType type, String sound) {
if (type == SoundType.CANCEL)
if (type == SoundType.CANCEL) {
cancelSounds.remove(sound);
else {
} else {
disguiseSounds.remove(type);
}
}
@ -221,9 +188,9 @@ public enum DisguiseSound {
}
public void setSound(SoundType type, String sound) {
if (type == SoundType.CANCEL)
if (type == SoundType.CANCEL) {
cancelSounds.add(sound);
else {
} else {
disguiseSounds.put(type, sound);
}
}

@ -51,20 +51,20 @@ import com.comphenix.protocol.wrappers.WrappedGameProfile;
import com.comphenix.protocol.wrappers.WrappedWatchableObject;
public class DisguiseUtilities {
/**
* This is a list of names which was called by other plugins. As such, don't remove from the gameProfiles as its the duty of
* the plugin to do that.
* This is a list of names which was called by other plugins. As such, don't remove from the gameProfiles as its the duty of the plugin to do that.
*/
private static HashSet<String> addedByPlugins = new HashSet<>();
private static Object bedChunk;
private static LinkedHashMap<String, Disguise> clonedDisguises = new LinkedHashMap<>();
/**
* A hashmap of the uuid's of entitys, alive and dead. And their disguises in use
**/
*
*/
private static HashMap<UUID, HashSet<TargetedDisguise>> disguisesInUse = new HashMap<>();
/**
* Disguises which are stored ready for a entity to be seen by a player Preferably, disguises in this should only stay in for
* a max of a second.
* Disguises which are stored ready for a entity to be seen by a player Preferably, disguises in this should only stay in for a max of a second.
*/
private static HashMap<Integer, HashSet<TargetedDisguise>> futureDisguises = new HashMap<>();
/**
@ -179,8 +179,7 @@ public class DisguiseUtilities {
}
/**
* If name isn't null. Make sure that the name doesn't see any other disguise. Else if name is null. Make sure that the
* observers in the disguise don't see any other disguise.
* If name isn't null. Make sure that the name doesn't see any other disguise. Else if name is null. Make sure that the observers in the disguise don't see any other disguise.
*/
public static void checkConflicts(TargetedDisguise disguise, String name) {
// If the disguise is being used.. Else we may accidentally undisguise something else
@ -237,7 +236,6 @@ public class DisguiseUtilities {
// System.out.print("Cannot set more than one " + TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS
// + " on a entity. Removed the old disguise.");
disguiseItel.remove();
d.removeDisguise();
}
@ -433,6 +431,7 @@ public class DisguiseUtilities {
/**
* Get all EntityPlayers who have this entity in their Entity Tracker And they are in the targetted disguise.
*
* @param disguise
* @return
*/
@ -478,8 +477,7 @@ public class DisguiseUtilities {
}
/**
* Thread safe to use. This returns a GameProfile. And if its GameProfile doesn't have a skin blob. Then it does a lookup
* using schedulers. The runnable is run once the GameProfile has been successfully dealt with
* Thread safe to use. This returns a GameProfile. And if its GameProfile doesn't have a skin blob. Then it does a lookup using schedulers. The runnable is run once the GameProfile has been successfully dealt with
*/
public static WrappedGameProfile getProfileFromMojang(String playerName, LibsProfileLookup runnableIfCantReturn) {
return getProfileFromMojang(playerName, (Object) runnableIfCantReturn);
@ -550,8 +548,7 @@ public class DisguiseUtilities {
}
/**
* Thread safe to use. This returns a GameProfile. And if its GameProfile doesn't have a skin blob. Then it does a lookup
* using schedulers. The runnable is run once the GameProfile has been successfully dealt with
* Thread safe to use. This returns a GameProfile. And if its GameProfile doesn't have a skin blob. Then it does a lookup using schedulers. The runnable is run once the GameProfile has been successfully dealt with
*/
public static WrappedGameProfile getProfileFromMojang(String playerName, Runnable runnableIfCantReturn) {
return getProfileFromMojang(playerName, (Object) runnableIfCantReturn);
@ -582,14 +579,14 @@ public class DisguiseUtilities {
}
/**
* Please note that in the future when 'DualInt' and the like are removed. This should break.. However, that should be negated
* in the future as I'd be able to set the watcher index's as per the spigot version. Instead of checking on the player's
* version every single packet..
* Please note that in the future when 'DualInt' and the like are removed. This should break.. However, that should be negated in the future as I'd be able to set the watcher index's as per the spigot version. Instead of checking on the player's version every single packet..
*/
public static List<WrappedWatchableObject> rebuildForVersion(Player player, FlagWatcher watcher,
List<WrappedWatchableObject> list) {
if (true) // Use for future protocol compatibility
{
return list;
}
ArrayList<WrappedWatchableObject> rebuiltList = new ArrayList<>();
ArrayList<WrappedWatchableObject> backups = new ArrayList<>();
for (WrappedWatchableObject obj : list) {
@ -625,8 +622,9 @@ public class DisguiseUtilities {
if (disguise.isDisguiseInUse() && disguise.getEntity() instanceof Player
&& ((Player) disguise.getEntity()).getName().equalsIgnoreCase(player)) {
removeSelfDisguise((Player) disguise.getEntity());
if (disguise.isSelfDisguiseVisible())
if (disguise.isSelfDisguiseVisible()) {
selfDisguised.add(disguise.getEntity().getUniqueId());
}
ProtocolLibrary.getProtocolManager().sendServerPacket((Player) disguise.getEntity(), destroyPacket);
Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() {
@Override
@ -972,6 +970,7 @@ public class DisguiseUtilities {
/**
* Setup it so he can see himself when disguised
*
* @param disguise
*/
public static void setupFakeDisguise(final Disguise disguise) {

@ -1,6 +1,7 @@
package me.libraryaddict.disguise.utilities;
public class FakeBoundingBox {
private double xMod;
private double yMod;
private double zMod;

@ -3,6 +3,7 @@ package me.libraryaddict.disguise.utilities;
import com.comphenix.protocol.wrappers.WrappedGameProfile;
public interface LibsProfileLookup {
public void onLookup(WrappedGameProfile gameProfile);
}

@ -6,6 +6,7 @@ import com.mojang.authlib.GameProfile;
import com.mojang.authlib.ProfileLookupCallback;
public class LibsProfileLookupCaller implements ProfileLookupCallback {
private WrappedGameProfile gameProfile;
public WrappedGameProfile getGameProfile() {

@ -54,6 +54,7 @@ import java.util.logging.Level;
import java.util.zip.GZIPOutputStream;
public class Metrics {
/**
* The current revision number
*/
@ -128,8 +129,7 @@ public class Metrics {
/**
* Construct and create a Graph that can be used to separate specific plotters to their own graphs on the metrics website. Plotters can be added to the graph object returned.
*
* @param name
* The name of the graph
* @param name The name of the graph
* @return Graph object created. Will never return NULL under normal circumstances unless bad parameters are given
*/
public Graph createGraph(final String name) {
@ -147,8 +147,7 @@ public class Metrics {
/**
* Add a Graph object to BukkitMetrics that represents data for the plugin that should be sent to the backend
*
* @param graph
* The name of the graph
* @param graph The name of the graph
*/
public void addGraph(final Graph graph) {
if (graph == null) {
@ -430,12 +429,13 @@ public class Metrics {
} catch (IOException e) {
e.printStackTrace(System.out);
} finally {
if (gzos != null)
if (gzos != null) {
try {
gzos.close();
} catch (IOException ignore) {
}
}
}
return baos.toByteArray();
}
@ -529,8 +529,7 @@ public class Metrics {
/**
* Encode text as UTF-8
*
* @param text
* the text to encode
* @param text the text to encode
* @return the encoded text, as UTF-8
*/
private static String urlEncode(final String text) throws UnsupportedEncodingException {
@ -541,6 +540,7 @@ public class Metrics {
* Represents a custom graph on the website
*/
public static class Graph {
/**
* The graph's name, alphanumeric and spaces only :) If it does not comply to the above when submitted, it is rejected
*/
@ -566,8 +566,7 @@ public class Metrics {
/**
* Add a plotter to the graph, which will be used to plot entries
*
* @param plotter
* the plotter to add to the graph
* @param plotter the plotter to add to the graph
*/
public void addPlotter(final Plotter plotter) {
plotters.add(plotter);
@ -576,8 +575,7 @@ public class Metrics {
/**
* Remove a plotter from the graph
*
* @param plotter
* the plotter to remove from the graph
* @param plotter the plotter to remove from the graph
*/
public void removePlotter(final Plotter plotter) {
plotters.remove(plotter);
@ -617,6 +615,7 @@ public class Metrics {
* Interface used to collect custom data for a plugin
*/
public static abstract class Plotter {
/**
* The plot's name
*/
@ -632,8 +631,7 @@ public class Metrics {
/**
* Construct a plotter with a specific plot name
*
* @param name
* the name of the plotter to use, which will show up on the website
* @param name the name of the plotter to use, which will show up on the website
*/
public Plotter(final String name) {
this.name = name;

@ -58,9 +58,9 @@ import com.comphenix.protocol.wrappers.WrappedWatchableObject;
import net.minecraft.server.v1_8_R3.DamageSource;
public class PacketsManager {
/**
* This is a fix for the stupidity that is
* "I can't separate the sounds from the sounds the player heard, and the sounds of the entity tracker heard"
* This is a fix for the stupidity that is "I can't separate the sounds from the sounds the player heard, and the sounds of the entity tracker heard"
*/
private static boolean cancelSound;
private static PacketListener clientInteractEntityListener;
@ -81,8 +81,9 @@ public class PacketsManager {
PacketType.Play.Client.USE_ENTITY) {
@Override
public void onPacketReceiving(PacketEvent event) {
if (event.isCancelled())
if (event.isCancelled()) {
return;
}
try {
Player observer = event.getPlayer();
StructureModifier<Entity> entityModifer = event.getPacket().getEntityModifier(observer.getWorld());
@ -118,14 +119,16 @@ public class PacketsManager {
/**
* Construct the packets I need to spawn in the disguise
*
* @param player
* @param disguise
* @param disguisedEntity
* @return
*/
public static PacketContainer[][] constructSpawnPackets(final Player player, Disguise disguise, Entity disguisedEntity) {
if (disguise.getEntity() == null)
if (disguise.getEntity() == null) {
disguise.setEntity(disguisedEntity);
}
Object nmsEntity = ReflectionManager.getNmsEntity(disguisedEntity);
ArrayList<PacketContainer> packets = new ArrayList<>();
// This sends the armor packets so that the player isn't naked.
@ -133,8 +136,9 @@ public class PacketsManager {
if (DisguiseConfig.isEquipmentPacketsEnabled()) {
for (int nmsSlot = 0; nmsSlot < 5; nmsSlot++) {
int armorSlot = nmsSlot - 1;
if (armorSlot < 0)
if (armorSlot < 0) {
armorSlot = 4;
}
ItemStack itemstack = disguise.getWatcher().getItemStack(armorSlot);
if (itemstack != null && itemstack.getTypeId() != 0) {
ItemStack item = null;
@ -299,18 +303,24 @@ public class PacketsManager {
double d2 = vec.getX();
double d3 = vec.getY();
double d4 = vec.getZ();
if (d2 < -d1)
if (d2 < -d1) {
d2 = -d1;
if (d3 < -d1)
}
if (d3 < -d1) {
d3 = -d1;
if (d4 < -d1)
}
if (d4 < -d1) {
d4 = -d1;
if (d2 > d1)
}
if (d2 > d1) {
d2 = d1;
if (d3 > d1)
}
if (d3 > d1) {
d3 = d1;
if (d4 > d1)
}
if (d4 > d1) {
d4 = d1;
}
mods.write(2, values.getEntitySize(loc.getX()));
mods.write(3, (int) Math.floor(loc.getY() * 32D));
mods.write(4, values.getEntitySize(loc.getZ()));
@ -480,8 +490,9 @@ public class PacketsManager {
}
switch (disguise.getType()) {
case BAT:
if (entity instanceof LivingEntity)
if (entity instanceof LivingEntity) {
return yMod + ((LivingEntity) entity).getEyeHeight();
}
case MINECART:
case MINECART_COMMAND:
case MINECART_CHEST:
@ -528,6 +539,7 @@ public class PacketsManager {
/**
* Creates the packet listeners
*
* @param plugin
*/
public static void init(LibsDisguises plugin) {
@ -608,8 +620,9 @@ public class PacketsManager {
if (disguise.isSoundsReplaced()) {
String sound = null;
DisguiseSound dSound = DisguiseSound.getType(disguise.getType().name());
if (dSound != null)
if (dSound != null) {
sound = dSound.getSound(soundType);
}
if (sound == null) {
event.setCancelled(true);
@ -655,8 +668,9 @@ public class PacketsManager {
float pitch = (Integer) mods.read(5);
if (baby) {
// If the pitch is not the expected
if (pitch > 97 || pitch < 111)
if (pitch > 97 || pitch < 111) {
return;
}
pitch = (new Random().nextFloat() - new Random().nextFloat()) * 0.2F + 1.5F;
// Min = 1.5
// Cap = 97.5
@ -664,8 +678,9 @@ public class PacketsManager {
// Cap = 110.5
} else {
// If the pitch is not the expected
if (pitch >= 63 || pitch <= 76)
if (pitch >= 63 || pitch <= 76) {
return;
}
pitch = (new Random().nextFloat() - new Random().nextFloat()) * 0.2F + 1.0F;
// Min = 1
// Cap = 63
@ -673,10 +688,12 @@ public class PacketsManager {
// Cap = 75.6
}
pitch *= 63;
if (pitch < 0)
if (pitch < 0) {
pitch = 0;
if (pitch > 255)
}
if (pitch > 255) {
pitch = 255;
}
mods.write(5, (int) pitch);
}
}
@ -694,8 +711,9 @@ public class PacketsManager {
if (disguise != null && !disguise.getType().isPlayer()
&& (disguise.isSelfDisguiseSoundsReplaced() || entity != event.getPlayer())) {
DisguiseSound disSound = DisguiseSound.getType(entity.getType().name());
if (disSound == null)
if (disSound == null) {
return;
}
SoundType soundType = null;
Object obj = null;
if (entity instanceof LivingEntity) {
@ -717,9 +735,10 @@ public class PacketsManager {
|| (disguise.isSelfDisguiseSoundsReplaced() && entity == event.getPlayer())) {
if (disguise.isSelfDisguiseSoundsReplaced() && entity == event.getPlayer()) {
cancelSound = !cancelSound;
if (cancelSound)
if (cancelSound) {
return;
}
}
disSound = DisguiseSound.getType(disguise.getType().name());
if (disSound != null) {
String sound = disSound.getSound(soundType);
@ -735,15 +754,19 @@ public class PacketsManager {
float pitch;
if (disguise instanceof MobDisguise && !((MobDisguise) disguise).isAdult()) {
pitch = (new Random().nextFloat() - new Random().nextFloat()) * 0.2F + 1.5F;
} else
} else {
pitch = (new Random().nextFloat() - new Random().nextFloat()) * 0.2F + 1.0F;
if (disguise.getType() == DisguiseType.BAT)
}
if (disguise.getType() == DisguiseType.BAT) {
pitch *= 95F;
}
pitch *= 63;
if (pitch < 0)
if (pitch < 0) {
pitch = 0;
if (pitch > 255)
}
if (pitch > 255) {
pitch = 255;
}
mods.write(5, (int) pitch);
try {
ProtocolLibrary.getProtocolManager().sendServerPacket(observer, packet);
@ -768,8 +791,9 @@ public class PacketsManager {
PacketType.Play.Server.UPDATE_ATTRIBUTES, PacketType.Play.Server.ENTITY_STATUS) {
@Override
public void onPacketSending(PacketEvent event) {
if (event.isCancelled())
if (event.isCancelled()) {
return;
}
final Player observer = event.getPlayer();
if (event.getPacket().getIntegers().read(0) == observer.getEntityId()) {
if (DisguiseAPI.isSelfDisguised(observer)) {
@ -813,8 +837,9 @@ public class PacketsManager {
if (watch.getIndex() == 0) {
byte b = (Byte) watch.getValue();
byte a = (byte) (b | 1 << 5);
if ((b & 1 << 3) != 0)
if ((b & 1 << 3) != 0) {
a = (byte) (a | 1 << 3);
}
watch.setValue(a);
}
}
@ -825,8 +850,9 @@ public class PacketsManager {
mods.write(0, observer.getEntityId());
List<WrappedWatchableObject> watchableList = new ArrayList<>();
byte b = (byte) 1 << 5;
if (observer.isSprinting())
if (observer.isSprinting()) {
b = (byte) (b | 1 << 3);
}
watchableList.add(new WrappedWatchableObject(0, b));
packet.getWatchableCollectionModifier().write(0, watchableList);
try {
@ -865,8 +891,9 @@ public class PacketsManager {
PacketType.Play.Client.SET_CREATIVE_SLOT, PacketType.Play.Client.WINDOW_CLICK) {
@Override
public void onPacketReceiving(final PacketEvent event) {
if (event.isCancelled())
if (event.isCancelled()) {
return;
}
if (!(event.getPlayer() instanceof com.comphenix.net.sf.cglib.proxy.Factory)
&& event.getPlayer().getVehicle() == null) {
Disguise disguise = DisguiseAPI.getDisguise(event.getPlayer(), event.getPlayer());
@ -915,8 +942,7 @@ public class PacketsManager {
}
}
}
}
// If the player switched item, aka he moved from slot 1 to slot 2
} // 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()) {
// From logging, it seems that both bukkit and nms uses the same thing for the slot switching.
@ -1197,8 +1223,9 @@ public class PacketsManager {
mainListener = new PacketAdapter(libsDisguises, ListenerPriority.HIGH, packetsToListen) {
@Override
public void onPacketSending(PacketEvent event) {
if (event.isCancelled())
if (event.isCancelled()) {
return;
}
final Player observer = event.getPlayer();
// First get the entity, the one sending this packet
StructureModifier<Entity> entityModifer = event.getPacket().getEntityModifier(observer.getWorld());
@ -1206,8 +1233,9 @@ public class PacketsManager {
.read((PacketType.Play.Server.COLLECT == event.getPacketType() ? 1 : 0));
// If the entity is the same as the sender. Don't disguise!
// Prevents problems and there is no advantage to be gained.
if (entity == observer)
if (entity == observer) {
return;
}
PacketContainer[][] packets = transformPacket(event.getPacket(), event.getPlayer(), entity);
if (packets != null) {
event.setCancelled(true);
@ -1267,8 +1295,12 @@ public class PacketsManager {
}
/**
* Transform the packet magically into the one I have always dreamed off. My true luv!!! This will return null if its not
* transformed
* Transform the packet magically into the one I have always dreamed off. My true luv!!! This will return null if its not transformed
*
* @param sentPacket
* @param observer
* @param entity
* @return
*/
public static PacketContainer[][] transformPacket(PacketContainer sentPacket, Player observer, Entity entity) {
PacketContainer[] packets = null;
@ -1312,9 +1344,7 @@ public class PacketsManager {
packets = new PacketContainer[0];
}
}
}
// Else if the packet is sending entity metadata
} // Else if the packet is sending entity metadata
else if (sentPacket.getType() == PacketType.Play.Server.ENTITY_METADATA) {
if (DisguiseConfig.isMetadataPacketsEnabled()) {
List<WrappedWatchableObject> watchableObjects = disguise.getWatcher().convert(
@ -1327,9 +1357,7 @@ public class PacketsManager {
} else {
packets = new PacketContainer[0];
}
}
// Else if the packet is spawning..
} // Else if the packet is spawning..
else if (sentPacket.getType() == PacketType.Play.Server.NAMED_ENTITY_SPAWN
|| sentPacket.getType() == PacketType.Play.Server.SPAWN_ENTITY_LIVING
|| sentPacket.getType() == PacketType.Play.Server.SPAWN_ENTITY_EXPERIENCE_ORB
@ -1338,9 +1366,7 @@ public class PacketsManager {
PacketContainer[][] spawnPackets = constructSpawnPackets(observer, disguise, entity);
packets = spawnPackets[0];
delayedPackets = spawnPackets[1];
}
// Else if the disguise is attempting to send players a forbidden packet
} // Else if the disguise is attempting to send players a forbidden packet
else if (sentPacket.getType() == PacketType.Play.Server.ANIMATION) {
if (disguise.getType().isMisc()
|| (packets[0].getIntegers().read(1) == 2 && (!disguise.getType()
@ -1348,9 +1374,7 @@ public class PacketsManager {
.getWatcher()).isSleeping())))) {
packets = new PacketContainer[0];
}
}
else if (sentPacket.getType() == PacketType.Play.Server.COLLECT) {
} else if (sentPacket.getType() == PacketType.Play.Server.COLLECT) {
if (disguise.getType().isMisc()) {
packets = new PacketContainer[0];
} else if (DisguiseConfig.isBedPacketsEnabled() && disguise.getType().isPlayer()
@ -1361,9 +1385,7 @@ public class PacketsManager {
mods.write(1, 3);
packets = new PacketContainer[]{newPacket, sentPacket};
}
}
// Else if the disguise is moving.
} // Else if the disguise is moving.
else if (sentPacket.getType() == PacketType.Play.Server.ENTITY_MOVE_LOOK
|| sentPacket.getType() == PacketType.Play.Server.ENTITY_LOOK
|| sentPacket.getType() == PacketType.Play.Server.ENTITY_TELEPORT
@ -1393,9 +1415,9 @@ public class PacketsManager {
packets[0] = sentPacket.shallowClone();
StructureModifier<Byte> bytes = packets[0].getBytes();
boolean tele = sentPacket.getType() == PacketType.Play.Server.ENTITY_TELEPORT;
byte yawValue = (Byte) bytes.read(tele ? 0 : 3);
byte yawValue = bytes.read(tele ? 0 : 3);
bytes.write(tele ? 0 : 3, getYaw(disguise.getType(), entity.getType(), yawValue));
byte pitchValue = (Byte) bytes.read(tele ? 1 : 4);
byte pitchValue = bytes.read(tele ? 1 : 4);
bytes.write(tele ? 1 : 4,
getPitch(disguise.getType(), DisguiseType.getType(entity.getType()), pitchValue));
if (tele && disguise.getType() == DisguiseType.ITEM_FRAME) {
@ -1412,16 +1434,15 @@ public class PacketsManager {
double y = getYModifier(entity, disguise);
if (y != 0) {
y *= 32;
ints.write(2, (Integer) ints.read(2) + (int) Math.floor(y));
ints.write(2, ints.read(2) + (int) Math.floor(y));
}
}
}
}
else if (sentPacket.getType() == PacketType.Play.Server.ENTITY_EQUIPMENT) {
} else if (sentPacket.getType() == PacketType.Play.Server.ENTITY_EQUIPMENT) {
int slot = (Integer) packets[0].getModifier().read(1) - 1;
if (slot < 0)
if (slot < 0) {
slot = 4;
}
org.bukkit.inventory.ItemStack itemstack = disguise.getWatcher().getItemStack(slot);
if (itemstack != null) {
packets[0] = packets[0].shallowClone();
@ -1461,21 +1482,15 @@ public class PacketsManager {
// it.
}
}
}
else if (sentPacket.getType() == PacketType.Play.Server.BED) {
} else if (sentPacket.getType() == PacketType.Play.Server.BED) {
if (!disguise.getType().isPlayer()) {
packets = new PacketContainer[0];
}
}
else if (sentPacket.getType() == PacketType.Play.Server.ENTITY_STATUS) {
} else if (sentPacket.getType() == PacketType.Play.Server.ENTITY_STATUS) {
if (packets[0].getBytes().read(0) == (byte) 3) {
packets = new PacketContainer[0];
}
}
else if (sentPacket.getType() == PacketType.Play.Server.ENTITY_HEAD_ROTATION) {
} else if (sentPacket.getType() == PacketType.Play.Server.ENTITY_HEAD_ROTATION) {
if (disguise.getType().isPlayer() && entity.getType() != EntityType.PLAYER) {
Location loc = entity.getLocation();
byte pitch = getPitch(disguise.getType(), DisguiseType.getType(entity.getType()),
@ -1491,9 +1506,7 @@ public class PacketsManager {
look.getBytes().write(4, pitch);
packets = new PacketContainer[]{look, rotation};
}
}
else {
} else {
packets = null;
}

@ -31,8 +31,10 @@ import org.bukkit.potion.PotionEffect;
public class ReflectionManager {
public enum LibVersion {
V1_8;
private static LibVersion currentVersion;
static {
//String mcVersion = Bukkit.getVersion().split("MC: ")[1].replace(")", "");
currentVersion = V1_8;
@ -59,8 +61,7 @@ public class ReflectionManager {
private static Map<String, Map<String, String>> ForgeFieldMappings;
/**
* Map of Forge fully qualified class names to a map from mc-dev method names to a map from method signatures to Forge method
* names.
* Map of Forge fully qualified class names to a map from mc-dev method names to a map from method signatures to Forge method names.
*/
private static Map<String, Map<String, Map<String, String>>> ForgeMethodMappings;
private static final Method ihmGet;
@ -607,10 +608,8 @@ public class ReflectionManager {
public static void setAllowSleep(Player player) {
try {
/**
Object nmsEntity = getNmsEntity(player);
Object connection = getNmsField(nmsEntity.getClass(), "playerConnection").get(nmsEntity);
Field check = getNmsField(connection.getClass(), "checkMovement");
check.setBoolean(connection, true); **/
* Object nmsEntity = getNmsEntity(player); Object connection = getNmsField(nmsEntity.getClass(), "playerConnection").get(nmsEntity); Field check = getNmsField(connection.getClass(), "checkMovement"); check.setBoolean(connection, true); *
*/
} catch (Exception ex) {
ex.printStackTrace(System.out);
}

@ -7,6 +7,7 @@ import java.net.URL;
import java.util.regex.Pattern;
public class UpdateChecker {
private String latestVersion;
private boolean checkHigher(String currentVersion, String newVersion) {
@ -51,8 +52,9 @@ public class UpdateChecker {
private String toReadable(String version) {
String[] split = Pattern.compile(".", Pattern.LITERAL).split(version.replace("v", ""));
version = "";
for (String s : split)
for (String s : split) {
version += String.format("%4s", s);
}
return version;
}
}

@ -1,6 +1,6 @@
name: LibsDisguises
main: me.libraryaddict.disguise.LibsDisguises
version: 8.6.3
version: 8.6.4
author: libraryaddict
authors: [Byteflux, Navid K.]
depend: [ProtocolLib]
@ -54,6 +54,9 @@ commands:
description: Toggle seeing your own disguise on or off.
permissions:
libsdisguises.reload:
description: Allows the user to reload LibsDisguises.
default: op
libsdisguises.seethrough:
description: Allows player to see through disguises.
default: false
@ -97,4 +100,3 @@ permissions:
description: See the /undisguiseradius command in tab-completion
libsdisguises.seecmd.disguiseclone:
description: See the /disguiseclone command in tab-completion