Update to 1.14.1, first dev build. Other changes included.
This commit is contained in:
		
							
								
								
									
										6
									
								
								pom.xml
									
									
									
									
									
								
							
							
						
						
									
										6
									
								
								pom.xml
									
									
									
									
									
								
							@@ -4,7 +4,7 @@
 | 
			
		||||
    <!-- A good example on why temporary names for project identification shouldn't be used -->
 | 
			
		||||
    <groupId>LibsDisguises</groupId>
 | 
			
		||||
    <artifactId>LibsDisguises</artifactId>
 | 
			
		||||
    <version>9.8.2</version>
 | 
			
		||||
    <version>9.8.2-SNAPSHOT</version>
 | 
			
		||||
 | 
			
		||||
    <build>
 | 
			
		||||
        <defaultGoal>clean install</defaultGoal>
 | 
			
		||||
@@ -53,12 +53,12 @@
 | 
			
		||||
        <dependency>
 | 
			
		||||
            <groupId>org.spigotmc</groupId>
 | 
			
		||||
            <artifactId>spigot-api</artifactId>
 | 
			
		||||
            <version>1.13.2-R0.1-SNAPSHOT</version>
 | 
			
		||||
            <version>1.14-R0.1-SNAPSHOT</version>
 | 
			
		||||
        </dependency>
 | 
			
		||||
        <dependency>
 | 
			
		||||
            <groupId>org.spigotmc</groupId>
 | 
			
		||||
            <artifactId>spigot</artifactId>
 | 
			
		||||
            <version>1.13.2-R0.1-SNAPSHOT</version>
 | 
			
		||||
            <version>1.14-R0.1-SNAPSHOT</version>
 | 
			
		||||
        </dependency>
 | 
			
		||||
        <!-- testing -->
 | 
			
		||||
        <dependency>
 | 
			
		||||
 
 | 
			
		||||
@@ -93,9 +93,6 @@ public class DisguiseAPI {
 | 
			
		||||
                if (saddle != null && saddle.getType() == Material.SADDLE) {
 | 
			
		||||
                    ((AbstractHorseWatcher) watcher).setSaddled(true);
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                if (watcher instanceof HorseWatcher)
 | 
			
		||||
                    ((HorseWatcher) watcher).setHorseArmor(horseInventory.getArmor());
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        for (Method method : entity.getClass().getMethods()) {
 | 
			
		||||
@@ -217,7 +214,7 @@ public class DisguiseAPI {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void disguiseIgnorePlayers(Entity entity, Disguise disguise, Player... playersToNotSeeDisguise) {
 | 
			
		||||
        disguiseIgnorePlayers(entity, disguise, (Collection) Arrays.asList(playersToNotSeeDisguise));
 | 
			
		||||
        disguiseIgnorePlayers(entity, disguise, Arrays.asList(playersToNotSeeDisguise));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void disguiseIgnorePlayers(Entity entity, Disguise disguise, String... playersToNotSeeDisguise) {
 | 
			
		||||
@@ -290,7 +287,7 @@ public class DisguiseAPI {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void disguiseToPlayers(Entity entity, Disguise disguise, Player... playersToViewDisguise) {
 | 
			
		||||
        disguiseToPlayers(entity, disguise, (Collection) Arrays.asList(playersToViewDisguise));
 | 
			
		||||
        disguiseToPlayers(entity, disguise, Arrays.asList(playersToViewDisguise));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void disguiseToPlayers(Entity entity, Disguise disguise, String... playersToViewDisguise) {
 | 
			
		||||
 
 | 
			
		||||
@@ -20,10 +20,10 @@ import java.util.HashMap;
 | 
			
		||||
import java.util.Map.Entry;
 | 
			
		||||
 | 
			
		||||
public class DisguiseConfig {
 | 
			
		||||
    public static enum DisguisePushing { // This enum has a really bad name..
 | 
			
		||||
    public enum DisguisePushing { // This enum has a really bad name..
 | 
			
		||||
        MODIFY_SCOREBOARD,
 | 
			
		||||
        IGNORE_SCOREBOARD,
 | 
			
		||||
        CREATE_SCOREBOARD;
 | 
			
		||||
        CREATE_SCOREBOARD
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public enum UpdatesBranch {
 | 
			
		||||
@@ -33,7 +33,6 @@ public class DisguiseConfig {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private static boolean animationEnabled;
 | 
			
		||||
    private static boolean bedEnabled;
 | 
			
		||||
    private static boolean blowDisguisesWhenAttacking;
 | 
			
		||||
    private static boolean blowDisguisesWhenAttacked;
 | 
			
		||||
    private static boolean collectEnabled;
 | 
			
		||||
@@ -307,7 +306,6 @@ public class DisguiseConfig {
 | 
			
		||||
        setWitherSkullPacketsEnabled(config.getBoolean("PacketsEnabled.WitherSkull"));
 | 
			
		||||
        setEquipmentPacketsEnabled(config.getBoolean("PacketsEnabled.Equipment"));
 | 
			
		||||
        setAnimationPacketsEnabled(config.getBoolean("PacketsEnabled.Animation"));
 | 
			
		||||
        setBedPacketsEnabled(config.getBoolean("PacketsEnabled.Bed"));
 | 
			
		||||
        setEntityStatusPacketsEnabled(config.getBoolean("PacketsEnabled.EntityStatus"));
 | 
			
		||||
        setCollectPacketsEnabled(config.getBoolean("PacketsEnabled.Collect"));
 | 
			
		||||
        setMetadataPacketsEnabled(config.getBoolean("PacketsEnabled.Metadata"));
 | 
			
		||||
@@ -447,10 +445,6 @@ public class DisguiseConfig {
 | 
			
		||||
        return animationEnabled;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static boolean isBedPacketsEnabled() {
 | 
			
		||||
        return bedEnabled;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static boolean isCollectPacketsEnabled() {
 | 
			
		||||
        return collectEnabled;
 | 
			
		||||
    }
 | 
			
		||||
@@ -600,14 +594,6 @@ public class DisguiseConfig {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void setBedPacketsEnabled(boolean enabled) {
 | 
			
		||||
        if (enabled != isBedPacketsEnabled()) {
 | 
			
		||||
            bedEnabled = enabled;
 | 
			
		||||
 | 
			
		||||
            PacketsManager.setupMainPacketsListener();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void setCollectPacketsEnabled(boolean enabled) {
 | 
			
		||||
        if (enabled != isCollectPacketsEnabled()) {
 | 
			
		||||
            collectEnabled = enabled;
 | 
			
		||||
 
 | 
			
		||||
@@ -93,12 +93,9 @@ public class DisguiseListener implements Listener {
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // If build number is null, or not a number. Then we can't check snapshots regardless
 | 
			
		||||
        if (!plugin.isNumberedBuild()) {
 | 
			
		||||
            return true;
 | 
			
		||||
        }
 | 
			
		||||
        return !plugin.isNumberedBuild();
 | 
			
		||||
 | 
			
		||||
        // Check snapshots
 | 
			
		||||
        return false;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void runUpdateScheduler() {
 | 
			
		||||
@@ -190,53 +187,6 @@ public class DisguiseListener implements Listener {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void chunkMove(Player player, Location newLoc, Location oldLoc) {
 | 
			
		||||
        try {
 | 
			
		||||
            // Resend the bed chunks
 | 
			
		||||
            for (PacketContainer packet : DisguiseUtilities.getBedChunkPacket(newLoc, oldLoc)) {
 | 
			
		||||
                ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet, false);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            if (newLoc != null) {
 | 
			
		||||
                for (HashSet<TargetedDisguise> list : DisguiseUtilities.getDisguises().values()) {
 | 
			
		||||
                    for (TargetedDisguise disguise : list) {
 | 
			
		||||
                        if (disguise.getEntity() == null)
 | 
			
		||||
                            continue;
 | 
			
		||||
 | 
			
		||||
                        if (!disguise.isPlayerDisguise())
 | 
			
		||||
                            continue;
 | 
			
		||||
 | 
			
		||||
                        if (!disguise.canSee(player))
 | 
			
		||||
                            continue;
 | 
			
		||||
 | 
			
		||||
                        if (!((PlayerDisguise) disguise).getWatcher().isSleeping())
 | 
			
		||||
                            continue;
 | 
			
		||||
 | 
			
		||||
                        if (!DisguiseUtilities.getPerverts(disguise).contains(player))
 | 
			
		||||
                            continue;
 | 
			
		||||
 | 
			
		||||
                        PacketContainer[] packets = DisguiseUtilities.getBedPackets(
 | 
			
		||||
                                disguise.getEntity() == player ? newLoc : disguise.getEntity().getLocation(), newLoc,
 | 
			
		||||
                                (PlayerDisguise) disguise);
 | 
			
		||||
 | 
			
		||||
                        if (disguise.getEntity() == player) {
 | 
			
		||||
                            for (PacketContainer packet : packets) {
 | 
			
		||||
                                packet.getIntegers().write(0, DisguiseAPI.getSelfDisguiseId());
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
 | 
			
		||||
                        for (PacketContainer packet : packets) {
 | 
			
		||||
                            ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        catch (InvocationTargetException e) {
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
 | 
			
		||||
    public void onVelocity(PlayerVelocityEvent event) {
 | 
			
		||||
        DisguiseUtilities.setPlayerVelocity(event.getPlayer());
 | 
			
		||||
@@ -332,10 +282,6 @@ public class DisguiseListener implements Listener {
 | 
			
		||||
 | 
			
		||||
        notifyUpdate(p);
 | 
			
		||||
 | 
			
		||||
        if (DisguiseConfig.isBedPacketsEnabled()) {
 | 
			
		||||
            chunkMove(p, p.getLocation(), null);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (DisguiseConfig.isSaveGameProfiles() && DisguiseConfig.isUpdateGameProfiles() &&
 | 
			
		||||
                DisguiseUtilities.hasGameProfile(p.getName())) {
 | 
			
		||||
            WrappedGameProfile profile = WrappedGameProfile.fromPlayer(p);
 | 
			
		||||
@@ -395,17 +341,6 @@ public class DisguiseListener implements Listener {
 | 
			
		||||
     */
 | 
			
		||||
    @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
 | 
			
		||||
    public void onMove(PlayerMoveEvent event) {
 | 
			
		||||
        if (DisguiseConfig.isBedPacketsEnabled()) {
 | 
			
		||||
            Location to = event.getTo();
 | 
			
		||||
            Location from = event.getFrom();
 | 
			
		||||
 | 
			
		||||
            if (DisguiseUtilities.getChunkCord(to.getBlockX()) != DisguiseUtilities.getChunkCord(from.getBlockX()) ||
 | 
			
		||||
                    DisguiseUtilities.getChunkCord(to.getBlockZ()) !=
 | 
			
		||||
                            DisguiseUtilities.getChunkCord(from.getBlockZ())) {
 | 
			
		||||
                chunkMove(event.getPlayer(), to, from);
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        // If the bounding boxes are modified and the player moved more than a little
 | 
			
		||||
        // The runnable in Disguise also calls it, so we should ignore smaller movements
 | 
			
		||||
        if (DisguiseConfig.isModifyBoundingBox() && event.getFrom().distanceSquared(event.getTo()) > 0.2) {
 | 
			
		||||
@@ -456,22 +391,6 @@ public class DisguiseListener implements Listener {
 | 
			
		||||
        DisguiseUtilities.saveDisguises(player.getUniqueId(), disguises);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @EventHandler
 | 
			
		||||
    public void onRespawn(PlayerRespawnEvent event) {
 | 
			
		||||
        if (DisguiseConfig.isBedPacketsEnabled()) {
 | 
			
		||||
            final Player player = event.getPlayer();
 | 
			
		||||
 | 
			
		||||
            chunkMove(event.getPlayer(), null, player.getLocation());
 | 
			
		||||
 | 
			
		||||
            Bukkit.getScheduler().runTask(plugin, new Runnable() {
 | 
			
		||||
                @Override
 | 
			
		||||
                public void run() {
 | 
			
		||||
                    chunkMove(player, player.getLocation(), null);
 | 
			
		||||
                }
 | 
			
		||||
            });
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @EventHandler
 | 
			
		||||
    public void onRightClick(PlayerInteractEntityEvent event) {
 | 
			
		||||
        Player p = event.getPlayer();
 | 
			
		||||
@@ -658,21 +577,6 @@ public class DisguiseListener implements Listener {
 | 
			
		||||
        Location to = event.getTo();
 | 
			
		||||
        Location from = event.getFrom();
 | 
			
		||||
 | 
			
		||||
        if (DisguiseConfig.isBedPacketsEnabled()) {
 | 
			
		||||
            if (DisguiseUtilities.getChunkCord(to.getBlockX()) != DisguiseUtilities.getChunkCord(from.getBlockX()) ||
 | 
			
		||||
                    DisguiseUtilities.getChunkCord(to.getBlockZ()) !=
 | 
			
		||||
                            DisguiseUtilities.getChunkCord(from.getBlockZ())) {
 | 
			
		||||
                chunkMove(player, null, from);
 | 
			
		||||
 | 
			
		||||
                Bukkit.getScheduler().runTask(plugin, new Runnable() {
 | 
			
		||||
                    @Override
 | 
			
		||||
                    public void run() {
 | 
			
		||||
                        chunkMove(player, player.getLocation(), null);
 | 
			
		||||
                    }
 | 
			
		||||
                });
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (!DisguiseAPI.isDisguised(player)) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
@@ -743,10 +647,6 @@ public class DisguiseListener implements Listener {
 | 
			
		||||
 | 
			
		||||
    @EventHandler(priority = EventPriority.MONITOR, ignoreCancelled = true)
 | 
			
		||||
    public void onWorldSwitch(final PlayerChangedWorldEvent event) {
 | 
			
		||||
        if (DisguiseConfig.isBedPacketsEnabled()) {
 | 
			
		||||
            chunkMove(event.getPlayer(), event.getPlayer().getLocation(), null);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (!DisguiseAPI.isDisguised(event.getPlayer())) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 
 | 
			
		||||
@@ -16,8 +16,8 @@ import me.libraryaddict.disguise.utilities.packets.PacketsManager;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.reflection.DisguiseValues;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.reflection.FakeBoundingBox;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
 | 
			
		||||
import org.apache.commons.lang3.ArrayUtils;
 | 
			
		||||
import org.apache.commons.lang3.StringUtils;
 | 
			
		||||
import org.apache.commons.lang.ArrayUtils;
 | 
			
		||||
import org.apache.commons.lang.StringUtils;
 | 
			
		||||
import org.bukkit.Bukkit;
 | 
			
		||||
import org.bukkit.command.CommandExecutor;
 | 
			
		||||
import org.bukkit.command.PluginCommand;
 | 
			
		||||
@@ -55,9 +55,18 @@ public class LibsDisguises extends JavaPlugin {
 | 
			
		||||
 | 
			
		||||
        LibsPremium.check(getDescription().getVersion());
 | 
			
		||||
 | 
			
		||||
        if (!ReflectionManager.getMinecraftVersion().startsWith("1.13")) {
 | 
			
		||||
        if (!LibsPremium.isPremium()) {
 | 
			
		||||
            getLogger().severe("You must purchase the plugin to use support for 1.14!");
 | 
			
		||||
            getLogger().severe("This will be released free once the plugin is stable!");
 | 
			
		||||
            getLogger().severe("If you've already purchased the plugin, place the purchased jar inside the " +
 | 
			
		||||
                    "Lib's Disguises plugin folder");
 | 
			
		||||
            getPluginLoader().disablePlugin(this);
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (!ReflectionManager.getMinecraftVersion().startsWith("1.14")) {
 | 
			
		||||
            getLogger().severe("You're using the wrong version of Lib's Disguises for your server! This is " +
 | 
			
		||||
                    "intended for 1.13!");
 | 
			
		||||
                    "intended for 1.14!");
 | 
			
		||||
            getPluginLoader().disablePlugin(this);
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
@@ -311,6 +320,12 @@ public class LibsDisguises extends JavaPlugin {
 | 
			
		||||
                    case TRIDENT:
 | 
			
		||||
                        nmsEntityName = "ThrownTrident";
 | 
			
		||||
                        break;
 | 
			
		||||
                    case WANDERING_TRADER:
 | 
			
		||||
                        nmsEntityName = "VillagerTrader";
 | 
			
		||||
                        break;
 | 
			
		||||
                    case TRADER_LLAMA:
 | 
			
		||||
                        nmsEntityName = "LLamaTrader"; // Interesting capitalization
 | 
			
		||||
                        break;
 | 
			
		||||
                    default:
 | 
			
		||||
                        break;
 | 
			
		||||
                }
 | 
			
		||||
@@ -336,14 +351,15 @@ public class LibsDisguises extends JavaPlugin {
 | 
			
		||||
                    continue;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                Object nmsEntity = ReflectionManager.createEntityInstance(nmsEntityName);
 | 
			
		||||
                Object nmsEntity = ReflectionManager.createEntityInstance(disguiseType, nmsEntityName);
 | 
			
		||||
 | 
			
		||||
                if (nmsEntity == null) {
 | 
			
		||||
                    getLogger().warning("Entity not found! (" + nmsEntityName + ")");
 | 
			
		||||
                    continue;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                disguiseType.setTypeId(ReflectionManager.getEntityType(nmsEntity));
 | 
			
		||||
                disguiseType.setTypeId(ReflectionManager.getEntityTypeId(disguiseType.getEntityType()));
 | 
			
		||||
 | 
			
		||||
                Entity bukkitEntity = ReflectionManager.getBukkitEntity(nmsEntity);
 | 
			
		||||
 | 
			
		||||
                int entitySize = 0;
 | 
			
		||||
@@ -431,7 +447,7 @@ public class LibsDisguises extends JavaPlugin {
 | 
			
		||||
                    disguiseValues.setBabyBox(ReflectionManager.getBoundingBox(bukkitEntity));
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                disguiseValues.setEntitySize(ReflectionManager.getSize(bukkitEntity));
 | 
			
		||||
                //disguiseValues.setEntitySize(ReflectionManager.getSize(bukkitEntity));
 | 
			
		||||
            }
 | 
			
		||||
            catch (SecurityException | IllegalArgumentException | IllegalAccessException | FieldAccessException ex) {
 | 
			
		||||
                getLogger().severe("Uh oh! Trouble while making values for the disguise " + disguiseType.name() + "!");
 | 
			
		||||
 
 | 
			
		||||
@@ -4,7 +4,7 @@ import me.libraryaddict.disguise.disguisetypes.DisguiseType;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.parser.ParamInfoManager;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.parser.params.ParamInfoManager;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.parser.params.ParamInfo;
 | 
			
		||||
import org.bukkit.Bukkit;
 | 
			
		||||
import org.bukkit.command.CommandExecutor;
 | 
			
		||||
 
 | 
			
		||||
@@ -5,7 +5,7 @@ import me.libraryaddict.disguise.utilities.translations.TranslateType;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParser;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.parser.DisguisePermissions;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.parser.ParamInfoManager;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.parser.params.ParamInfoManager;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.parser.params.ParamInfo;
 | 
			
		||||
import org.apache.commons.lang.StringUtils;
 | 
			
		||||
import org.bukkit.ChatColor;
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,7 @@ import me.libraryaddict.disguise.disguisetypes.Disguise;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.parser.*;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.parser.params.ParamInfoManager;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.translations.TranslateType;
 | 
			
		||||
import org.apache.commons.lang.StringUtils;
 | 
			
		||||
 
 | 
			
		||||
@@ -9,17 +9,17 @@ public enum AnimalColor {
 | 
			
		||||
    BROWN(DyeColor.BROWN, Material.COCOA_BEANS),
 | 
			
		||||
    CYAN(DyeColor.CYAN, Material.CYAN_DYE),
 | 
			
		||||
    GRAY(DyeColor.GRAY, Material.GRAY_DYE),
 | 
			
		||||
    GREEN(DyeColor.GREEN, Material.CACTUS_GREEN),
 | 
			
		||||
    GREEN(DyeColor.GREEN, Material.GREEN_DYE),
 | 
			
		||||
    LIGHT_BLUE(DyeColor.LIGHT_BLUE, Material.LIGHT_BLUE_DYE),
 | 
			
		||||
    LIME(DyeColor.LIME, Material.LIME_DYE),
 | 
			
		||||
    MAGENTA(DyeColor.MAGENTA, Material.MAGENTA_DYE),
 | 
			
		||||
    ORANGE(DyeColor.ORANGE, Material.ORANGE_DYE),
 | 
			
		||||
    PINK(DyeColor.PINK, Material.PINK_DYE),
 | 
			
		||||
    PURPLE(DyeColor.PURPLE, Material.PURPLE_DYE),
 | 
			
		||||
    RED(DyeColor.RED, Material.ROSE_RED),
 | 
			
		||||
    RED(DyeColor.RED, Material.RED_DYE),
 | 
			
		||||
    LIGHT_GRAY(DyeColor.LIGHT_GRAY, Material.LIGHT_GRAY_DYE),
 | 
			
		||||
    WHITE(DyeColor.WHITE, Material.BONE_MEAL),
 | 
			
		||||
    YELLOW(DyeColor.YELLOW, Material.DANDELION_YELLOW);
 | 
			
		||||
    YELLOW(DyeColor.YELLOW, Material.YELLOW_DYE);
 | 
			
		||||
 | 
			
		||||
    public static AnimalColor getColorByWool(int woolId) {
 | 
			
		||||
        for (AnimalColor color : values()) {
 | 
			
		||||
 
 | 
			
		||||
@@ -18,6 +18,8 @@ public enum DisguiseType {
 | 
			
		||||
 | 
			
		||||
    BOAT(1),
 | 
			
		||||
 | 
			
		||||
    CAT,
 | 
			
		||||
 | 
			
		||||
    CAVE_SPIDER,
 | 
			
		||||
 | 
			
		||||
    CHICKEN,
 | 
			
		||||
@@ -68,6 +70,8 @@ public enum DisguiseType {
 | 
			
		||||
 | 
			
		||||
    FISHING_HOOK(90),
 | 
			
		||||
 | 
			
		||||
    FOX,
 | 
			
		||||
 | 
			
		||||
    GHAST,
 | 
			
		||||
 | 
			
		||||
    GIANT,
 | 
			
		||||
@@ -114,6 +118,8 @@ public enum DisguiseType {
 | 
			
		||||
 | 
			
		||||
    PAINTING,
 | 
			
		||||
 | 
			
		||||
    PANDA,
 | 
			
		||||
 | 
			
		||||
    PARROT,
 | 
			
		||||
 | 
			
		||||
    PHANTOM,
 | 
			
		||||
@@ -122,6 +128,8 @@ public enum DisguiseType {
 | 
			
		||||
 | 
			
		||||
    PIG_ZOMBIE,
 | 
			
		||||
 | 
			
		||||
    PILLAGER,
 | 
			
		||||
 | 
			
		||||
    PLAYER,
 | 
			
		||||
 | 
			
		||||
    POLAR_BEAR,
 | 
			
		||||
@@ -132,6 +140,8 @@ public enum DisguiseType {
 | 
			
		||||
 | 
			
		||||
    RABBIT,
 | 
			
		||||
 | 
			
		||||
    RAVAGER,
 | 
			
		||||
 | 
			
		||||
    SALMON,
 | 
			
		||||
 | 
			
		||||
    SHEEP,
 | 
			
		||||
@@ -166,10 +176,10 @@ public enum DisguiseType {
 | 
			
		||||
 | 
			
		||||
    THROWN_EXP_BOTTLE(75),
 | 
			
		||||
 | 
			
		||||
    TIPPED_ARROW(60),
 | 
			
		||||
 | 
			
		||||
    TRIDENT(94, 0),
 | 
			
		||||
 | 
			
		||||
    TRADER_LLAMA,
 | 
			
		||||
 | 
			
		||||
    TROPICAL_FISH,
 | 
			
		||||
 | 
			
		||||
    TURTLE,
 | 
			
		||||
@@ -184,6 +194,8 @@ public enum DisguiseType {
 | 
			
		||||
 | 
			
		||||
    VINDICATOR,
 | 
			
		||||
 | 
			
		||||
    WANDERING_TRADER,
 | 
			
		||||
 | 
			
		||||
    WITCH,
 | 
			
		||||
 | 
			
		||||
    WITHER,
 | 
			
		||||
@@ -198,14 +210,6 @@ public enum DisguiseType {
 | 
			
		||||
 | 
			
		||||
    ZOMBIE_VILLAGER;
 | 
			
		||||
 | 
			
		||||
    static {
 | 
			
		||||
        for (DisguiseType type : values()) {
 | 
			
		||||
            String name = type.name();
 | 
			
		||||
 | 
			
		||||
            type.setEntityType(EntityType.valueOf(name));
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static DisguiseType getType(Entity entity) {
 | 
			
		||||
        DisguiseType disguiseType = getType(entity.getType());
 | 
			
		||||
 | 
			
		||||
@@ -213,12 +217,15 @@ public enum DisguiseType {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static DisguiseType getType(EntityType entityType) {
 | 
			
		||||
        try {
 | 
			
		||||
            return valueOf(entityType.name().toUpperCase());
 | 
			
		||||
        }
 | 
			
		||||
        catch (Throwable ex) {
 | 
			
		||||
            return DisguiseType.UNKNOWN;
 | 
			
		||||
        for (DisguiseType type : values()) {
 | 
			
		||||
            if (type.getEntityType() != entityType) {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return type;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return DisguiseType.UNKNOWN;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private EntityType entityType;
 | 
			
		||||
@@ -245,6 +252,8 @@ public enum DisguiseType {
 | 
			
		||||
                    break;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        setEntityType(EntityType.valueOf(name()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public int getDefaultData() {
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,14 @@
 | 
			
		||||
package me.libraryaddict.disguise.disguisetypes;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created by libraryaddict on 6/05/2019.
 | 
			
		||||
 */
 | 
			
		||||
public enum EntityPose {
 | 
			
		||||
    STANDING,
 | 
			
		||||
    FALL_FLYING,
 | 
			
		||||
    SLEEPING,
 | 
			
		||||
    SWIMMING,
 | 
			
		||||
    SPIN_ATTACK,
 | 
			
		||||
    SNEAKING,
 | 
			
		||||
    DYING
 | 
			
		||||
}
 | 
			
		||||
@@ -191,6 +191,15 @@ public class FlagWatcher {
 | 
			
		||||
        return newList;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public EntityPose getEntityPose() {
 | 
			
		||||
        return getData(MetaIndex.ENTITY_POSE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setEntityPose(EntityPose entityPose) {
 | 
			
		||||
        setData(MetaIndex.ENTITY_POSE, entityPose);
 | 
			
		||||
        sendData(MetaIndex.ENTITY_POSE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public ItemStack[] getArmor() {
 | 
			
		||||
        return getEquipment().getArmorContents();
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -10,6 +10,8 @@ import me.libraryaddict.disguise.utilities.DisguiseUtilities;
 | 
			
		||||
import org.bukkit.Color;
 | 
			
		||||
import org.bukkit.Material;
 | 
			
		||||
import org.bukkit.Particle;
 | 
			
		||||
import org.bukkit.entity.MushroomCow;
 | 
			
		||||
import org.bukkit.entity.Villager;
 | 
			
		||||
import org.bukkit.inventory.ItemStack;
 | 
			
		||||
 | 
			
		||||
import java.lang.reflect.Field;
 | 
			
		||||
@@ -98,6 +100,8 @@ public class MetaIndex<Y> {
 | 
			
		||||
     */
 | 
			
		||||
    public static MetaIndex<Optional<UUID>> ARROW_UUID = new MetaIndex<>(ArrowWatcher.class, 1, Optional.empty());
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Byte> ARROW_PIERCE_LEVEL = new MetaIndex<>(ArrowWatcher.class, 2, (byte) 0);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * If the bat is hanging, false/true state
 | 
			
		||||
     */
 | 
			
		||||
@@ -128,6 +132,14 @@ public class MetaIndex<Y> {
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Integer> BOAT_SHAKE = new MetaIndex<>(BoatWatcher.class, 6, 0);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Integer> CAT_TYPE = new MetaIndex<>(CatWatcher.class, 0, 0);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Boolean> CAT_LYING_DOWN = new MetaIndex<>(CatWatcher.class, 1, false);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Boolean> CAT_LOOKING_UP = new MetaIndex<>(CatWatcher.class, 2, false);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Integer> CAT_COLLAR = new MetaIndex<>(CatWatcher.class, 3, AnimalColor.RED.ordinal());
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * If creeper is ignited, about to blow up
 | 
			
		||||
     */
 | 
			
		||||
@@ -174,6 +186,9 @@ public class MetaIndex<Y> {
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Integer> ENDER_DRAGON_PHASE = new MetaIndex<>(EnderDragonWatcher.class, 0, 10);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<ItemStack> ENDER_SIGNAL_ITEM = new MetaIndex<>(EnderSignalWatcher.class, 0,
 | 
			
		||||
            new ItemStack(Material.AIR));
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * If the enderman is screaming
 | 
			
		||||
     */
 | 
			
		||||
@@ -213,18 +228,40 @@ public class MetaIndex<Y> {
 | 
			
		||||
     */
 | 
			
		||||
    public static MetaIndex<Boolean> ENTITY_SILENT = new MetaIndex<>(FlagWatcher.class, 4, false);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * If entity can make sounds, no noticable effects
 | 
			
		||||
     */
 | 
			
		||||
    public static MetaIndex<EntityPose> ENTITY_POSE = new MetaIndex<>(FlagWatcher.class, 6, EntityPose.STANDING);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<BlockPosition> FALLING_BLOCK_POSITION = new MetaIndex<>(FallingBlockWatcher.class, 0,
 | 
			
		||||
            BlockPosition.ORIGIN);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<ItemStack> FIREBALL_ITEM = new MetaIndex<>(FireballWatcher.class, 0,
 | 
			
		||||
            new ItemStack(Material.AIR));
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<ItemStack> FIREWORK_ITEM = new MetaIndex<>(FireworkWatcher.class, 0,
 | 
			
		||||
            new ItemStack(Material.FIREWORK_ROCKET));
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Boolean> FISH_FROM_BUCKET = new MetaIndex<>(FishWatcher.class, 0, false);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Integer> FIREWORK_ATTACHED_ENTITY = new MetaIndex<>(FireworkWatcher.class, 1, 0);
 | 
			
		||||
    public static MetaIndex<OptionalInt> FIREWORK_ATTACHED_ENTITY = new MetaIndex<>(FireworkWatcher.class, 1,
 | 
			
		||||
            OptionalInt.empty());
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Boolean> FIREWORK_SHOT_AT_ANGLE = new MetaIndex<>(FireworkWatcher.class, 2, false);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Integer> FISHING_HOOK_HOOKED = new MetaIndex<>(FishingHookWatcher.class, 0, 0);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * The type of fox, its coloring
 | 
			
		||||
     */
 | 
			
		||||
    public static MetaIndex<Integer> FOX_TYPE = new MetaIndex<>(FoxWatcher.class, 0, 0);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Byte> FOX_META = new MetaIndex<>(FoxWatcher.class, 1, (byte) 0);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Optional<UUID>> FOX_TRUSTED_1 = new MetaIndex<>(FoxWatcher.class, 2, Optional.empty());
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Optional<UUID>> FOX_TRUSTED_2 = new MetaIndex<>(FoxWatcher.class, 3, Optional.empty());
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Changes the face of the ghast
 | 
			
		||||
     */
 | 
			
		||||
@@ -240,11 +277,6 @@ public class MetaIndex<Y> {
 | 
			
		||||
     */
 | 
			
		||||
    public static MetaIndex<Integer> GUARDIAN_TARGET = new MetaIndex<>(GuardianWatcher.class, 1, 0);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * What type of armor the horse has
 | 
			
		||||
     */
 | 
			
		||||
    public static MetaIndex<Integer> HORSE_ARMOR = new MetaIndex<>(HorseWatcher.class, 1, 0);
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * If horse has chest, set for donkey
 | 
			
		||||
     */
 | 
			
		||||
@@ -267,9 +299,7 @@ public class MetaIndex<Y> {
 | 
			
		||||
    public static MetaIndex<Optional<UUID>> HORSE_OWNER = new MetaIndex<>(AbstractHorseWatcher.class, 1,
 | 
			
		||||
            Optional.empty());
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Byte> ILLAGER_META = new MetaIndex<>(IllagerWatcher.class, 0, (byte) 0);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Byte> ILLAGER_SPELL_TICKS = new MetaIndex<>(IllagerWizardWatcher.class, 0, (byte) 0);
 | 
			
		||||
    public static MetaIndex<Byte> ILLAGER_SPELL = new MetaIndex<>(IllagerWizardWatcher.class, 0, (byte) 0);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Byte> INSENTIENT_META = new MetaIndex<>(InsentientWatcher.class, 0, (byte) 0);
 | 
			
		||||
 | 
			
		||||
@@ -311,6 +341,9 @@ public class MetaIndex<Y> {
 | 
			
		||||
     */
 | 
			
		||||
    public static MetaIndex<Integer> LIVING_POTIONS = new MetaIndex<>(LivingWatcher.class, 2, 0);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Optional<BlockPosition>> LIVING_BED_POSITION = new MetaIndex<>(LivingWatcher.class, 5,
 | 
			
		||||
            Optional.empty());
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * If there is no carpet, -1. Otherwise it's a color enum value
 | 
			
		||||
     */
 | 
			
		||||
@@ -357,7 +390,22 @@ public class MetaIndex<Y> {
 | 
			
		||||
     */
 | 
			
		||||
    public static MetaIndex<Boolean> MINECART_FURANCE_FUELED = new MetaIndex<>(MinecartFurnaceWatcher.class, 0, false);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Integer> OCELOT_TYPE = new MetaIndex<>(OcelotWatcher.class, 0, 0);
 | 
			
		||||
    public static MetaIndex<String> MUSHROOM_COW_TYPE = new MetaIndex<>(MushroomCowWatcher.class, 0,
 | 
			
		||||
            MushroomCow.Variant.RED.name().toLowerCase());
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Boolean> OCELOT_TRUST = new MetaIndex<>(OcelotWatcher.class, 0, false);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Integer> PANDA_HEAD_SHAKING = new MetaIndex<>(PandaWatcher.class, 0, 0);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Integer> PANDA_UNKNOWN_1 = new MetaIndex<>(PandaWatcher.class, 1, 0);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Integer> PANDA_UNKNOWN_2 = new MetaIndex<>(PandaWatcher.class, 2, 0);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Byte> PANDA_MAIN_GENE = new MetaIndex<>(PandaWatcher.class, 3, (byte) 0);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Byte> PANDA_HIDDEN_GENE = new MetaIndex<>(PandaWatcher.class, 4, (byte) 0);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Byte> PANDA_META = new MetaIndex<>(PandaWatcher.class, 5, (byte) 0);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Integer> PARROT_VARIANT = new MetaIndex<>(ParrotWatcher.class, 0, 0);
 | 
			
		||||
 | 
			
		||||
@@ -370,6 +418,8 @@ public class MetaIndex<Y> {
 | 
			
		||||
     */
 | 
			
		||||
    public static MetaIndex<Integer> PIG_BOOST = new MetaIndex<>(PigWatcher.class, 1, 0);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Boolean> PILLAGER_AIMING_BOW = new MetaIndex<>(PillagerWatcher.class, 0, false);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Float> PLAYER_ABSORPTION = new MetaIndex<>(PlayerWatcher.class, 0, 0F);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Byte> PLAYER_HAND = new MetaIndex<>(PlayerWatcher.class, 3, (byte) 0);
 | 
			
		||||
@@ -390,6 +440,8 @@ public class MetaIndex<Y> {
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Integer> RABBIT_TYPE = new MetaIndex<>(RabbitWatcher.class, 0, 0);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Boolean> RAIDER_CASTING_SPELL = new MetaIndex<>(RaiderWatcher.class, 0, false);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Byte> SHEEP_WOOL = new MetaIndex<>(SheepWatcher.class, 0, (byte) 0);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Optional<BlockPosition>> SHULKER_ATTACHED = new MetaIndex<>(ShulkerWatcher.class, 1,
 | 
			
		||||
@@ -401,8 +453,6 @@ public class MetaIndex<Y> {
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Byte> SHULKER_PEEKING = new MetaIndex<>(ShulkerWatcher.class, 2, (byte) 0);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Boolean> SKELETON_SWING_ARMS = new MetaIndex<>(SkeletonWatcher.class, 0, false);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Integer> SLIME_SIZE = new MetaIndex<>(SlimeWatcher.class, 0, 1);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Byte> SNOWMAN_DERP = new MetaIndex<>(SnowmanWatcher.class, 0, (byte) 16);
 | 
			
		||||
@@ -417,6 +467,9 @@ public class MetaIndex<Y> {
 | 
			
		||||
    public static MetaIndex<Optional<UUID>> TAMEABLE_OWNER = new MetaIndex<>(TameableWatcher.class, 1,
 | 
			
		||||
            Optional.empty());
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<ItemStack> THROWABLE_ITEM = new MetaIndex<>(ThrowableWatcher.class, 0,
 | 
			
		||||
            new ItemStack(Material.AIR));
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Integer> TIPPED_ARROW_COLOR = new MetaIndex<>(TippedArrowWatcher.class, 0, -1);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Integer> TNT_FUSE_TICKS = new MetaIndex<>(TNTWatcher.class, 0, Integer.MAX_VALUE);
 | 
			
		||||
@@ -441,7 +494,10 @@ public class MetaIndex<Y> {
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Byte> VEX_ANGRY = new MetaIndex<>(VexWatcher.class, 0, (byte) 0);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Integer> VILLAGER_PROFESSION = new MetaIndex<>(VillagerWatcher.class, 0, 0);
 | 
			
		||||
    public static MetaIndex<Integer> ABSTRACT_VILLAGER_ANGRY = new MetaIndex<>(AbstractVillagerWatcher.class, 0, 0);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<VillagerData> VILLAGER_DATA = new MetaIndex<>(VillagerWatcher.class, 0,
 | 
			
		||||
            new VillagerData(Villager.Type.PLAINS, Villager.Profession.NONE, 1));
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Boolean> WITCH_AGGRESSIVE = new MetaIndex<>(WitchWatcher.class, 0, false);
 | 
			
		||||
 | 
			
		||||
@@ -461,15 +517,14 @@ public class MetaIndex<Y> {
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Float> WOLF_DAMAGE = new MetaIndex<>(WolfWatcher.class, 0, 1F);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Boolean> ZOMBIE_AGGRESSIVE = new MetaIndex<>(ZombieWatcher.class, 2, false);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Boolean> ZOMBIE_BABY = new MetaIndex<>(ZombieWatcher.class, 0, false);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Boolean> ZOMBIE_CONVERTING_DROWNED = new MetaIndex<>(ZombieWatcher.class, 3, false);
 | 
			
		||||
    public static MetaIndex<Boolean> ZOMBIE_CONVERTING_DROWNED = new MetaIndex<>(ZombieWatcher.class, 2, false);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Integer> ZOMBIE_PLACEHOLDER = new MetaIndex<>(ZombieWatcher.class, 1, 0);
 | 
			
		||||
 | 
			
		||||
    public static MetaIndex<Integer> ZOMBIE_VILLAGER_PROFESSION = new MetaIndex<>(ZombieVillagerWatcher.class, 1, 0);
 | 
			
		||||
    public static MetaIndex<VillagerData> ZOMBIE_VILLAGER_PROFESSION = new MetaIndex<>(ZombieVillagerWatcher.class, 1,
 | 
			
		||||
            new VillagerData(Villager.Type.PLAINS, Villager.Profession.NONE, 1));
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Shown for villager conversion
 | 
			
		||||
 
 | 
			
		||||
@@ -75,7 +75,6 @@ public class MiscDisguise extends TargetedDisguise {
 | 
			
		||||
            case FISHING_HOOK: // Entity ID of whoever is holding fishing rod
 | 
			
		||||
            case ARROW: // Entity ID of shooter. Used for "Is he on this scoreboard team and do I render it moving
 | 
			
		||||
                // through his body?"
 | 
			
		||||
            case TIPPED_ARROW:
 | 
			
		||||
            case SPECTRAL_ARROW:
 | 
			
		||||
            case SMALL_FIREBALL: // Unknown. Uses entity id of shooter. 0 if no shooter
 | 
			
		||||
            case FIREBALL: // Unknown. Uses entity id of shooter. 0 if no shooter
 | 
			
		||||
 
 | 
			
		||||
@@ -15,7 +15,7 @@ public enum RabbitType {
 | 
			
		||||
 | 
			
		||||
    private int type;
 | 
			
		||||
 | 
			
		||||
    private RabbitType(int type) {
 | 
			
		||||
    RabbitType(int type) {
 | 
			
		||||
        this.type = type;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -156,9 +156,7 @@ public abstract class TargetedDisguise extends Disguise {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public TargetedDisguise silentlyRemovePlayer(String playername) {
 | 
			
		||||
        if (disguiseViewers.contains(playername)) {
 | 
			
		||||
            disguiseViewers.remove(playername);
 | 
			
		||||
        }
 | 
			
		||||
        disguiseViewers.remove(playername);
 | 
			
		||||
 | 
			
		||||
        return this;
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,30 @@
 | 
			
		||||
package me.libraryaddict.disguise.disguisetypes;
 | 
			
		||||
 | 
			
		||||
import org.bukkit.entity.Villager;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created by libraryaddict on 6/05/2019.
 | 
			
		||||
 */
 | 
			
		||||
public class VillagerData {
 | 
			
		||||
    private final Villager.Type type;
 | 
			
		||||
    private final Villager.Profession profession;
 | 
			
		||||
    private final int level;
 | 
			
		||||
 | 
			
		||||
    public VillagerData(Villager.Type type, Villager.Profession profession, int level) {
 | 
			
		||||
        this.type = type;
 | 
			
		||||
        this.profession = profession;
 | 
			
		||||
        this.level = level;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Villager.Type getType() {
 | 
			
		||||
        return type;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Villager.Profession getProfession() {
 | 
			
		||||
        return profession;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public int getLevel() {
 | 
			
		||||
        return level;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,18 @@
 | 
			
		||||
package me.libraryaddict.disguise.disguisetypes.watchers;
 | 
			
		||||
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created by libraryaddict on 18/05/2019.
 | 
			
		||||
 */
 | 
			
		||||
public class AbstractVillagerWatcher extends AgeableWatcher {
 | 
			
		||||
    public AbstractVillagerWatcher(Disguise disguise) {
 | 
			
		||||
        super(disguise);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setAngry(int ticks) {
 | 
			
		||||
        setData(MetaIndex.ABSTRACT_VILLAGER_ANGRY, ticks);
 | 
			
		||||
        sendData(MetaIndex.ABSTRACT_VILLAGER_ANGRY);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -7,40 +7,32 @@ import com.comphenix.protocol.wrappers.Vector3F;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
 | 
			
		||||
 | 
			
		||||
public class ArmorStandWatcher extends LivingWatcher
 | 
			
		||||
{
 | 
			
		||||
    public ArmorStandWatcher(Disguise disguise)
 | 
			
		||||
    {
 | 
			
		||||
public class ArmorStandWatcher extends LivingWatcher {
 | 
			
		||||
    public ArmorStandWatcher(Disguise disguise) {
 | 
			
		||||
        super(disguise);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private boolean getArmorStandFlag(int value)
 | 
			
		||||
    {
 | 
			
		||||
    private boolean getArmorStandFlag(int value) {
 | 
			
		||||
        return (getData(MetaIndex.ARMORSTAND_META) & value) != 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public EulerAngle getBody()
 | 
			
		||||
    {
 | 
			
		||||
    public EulerAngle getBody() {
 | 
			
		||||
        return getPose(MetaIndex.ARMORSTAND_BODY);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public EulerAngle getHead()
 | 
			
		||||
    {
 | 
			
		||||
    public EulerAngle getHead() {
 | 
			
		||||
        return getPose(MetaIndex.ARMORSTAND_HEAD);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public EulerAngle getLeftArm()
 | 
			
		||||
    {
 | 
			
		||||
    public EulerAngle getLeftArm() {
 | 
			
		||||
        return getPose(MetaIndex.ARMORSTAND_LEFT_ARM);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public EulerAngle getLeftLeg()
 | 
			
		||||
    {
 | 
			
		||||
    public EulerAngle getLeftLeg() {
 | 
			
		||||
        return getPose(MetaIndex.ARMORSTAND_LEFT_LEG);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private EulerAngle getPose(MetaIndex<Vector3F> type)
 | 
			
		||||
    {
 | 
			
		||||
    private EulerAngle getPose(MetaIndex<Vector3F> type) {
 | 
			
		||||
        if (!hasValue(type))
 | 
			
		||||
            return new EulerAngle(0, 0, 0);
 | 
			
		||||
 | 
			
		||||
@@ -49,51 +41,40 @@ public class ArmorStandWatcher extends LivingWatcher
 | 
			
		||||
        return new EulerAngle(vec.getX(), vec.getY(), vec.getZ());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public EulerAngle getRightArm()
 | 
			
		||||
    {
 | 
			
		||||
    public EulerAngle getRightArm() {
 | 
			
		||||
        return getPose(MetaIndex.ARMORSTAND_RIGHT_ARM);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public EulerAngle getRightLeg()
 | 
			
		||||
    {
 | 
			
		||||
    public EulerAngle getRightLeg() {
 | 
			
		||||
        return getPose(MetaIndex.ARMORSTAND_RIGHT_LEG);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isMarker()
 | 
			
		||||
    {
 | 
			
		||||
    public boolean isMarker() {
 | 
			
		||||
        return getArmorStandFlag(10);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isNoBasePlate()
 | 
			
		||||
    {
 | 
			
		||||
    public boolean isNoBasePlate() {
 | 
			
		||||
        return getArmorStandFlag(8);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isNoGravity()
 | 
			
		||||
    {
 | 
			
		||||
    public boolean isNoGravity() {
 | 
			
		||||
        return getArmorStandFlag(2);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isShowArms()
 | 
			
		||||
    {
 | 
			
		||||
    public boolean isShowArms() {
 | 
			
		||||
        return getArmorStandFlag(4);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isSmall()
 | 
			
		||||
    {
 | 
			
		||||
    public boolean isSmall() {
 | 
			
		||||
        return getArmorStandFlag(1);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void setArmorStandFlag(int value, boolean isTrue)
 | 
			
		||||
    {
 | 
			
		||||
        byte b1 = (byte) getData(MetaIndex.ARMORSTAND_META);
 | 
			
		||||
    private void setArmorStandFlag(int value, boolean isTrue) {
 | 
			
		||||
        byte b1 = getData(MetaIndex.ARMORSTAND_META);
 | 
			
		||||
 | 
			
		||||
        if (isTrue)
 | 
			
		||||
        {
 | 
			
		||||
        if (isTrue) {
 | 
			
		||||
            b1 = (byte) (b1 | value);
 | 
			
		||||
        }
 | 
			
		||||
        else
 | 
			
		||||
        {
 | 
			
		||||
        } else {
 | 
			
		||||
            b1 = (byte) (b1 & value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@@ -101,70 +82,52 @@ public class ArmorStandWatcher extends LivingWatcher
 | 
			
		||||
        sendData(MetaIndex.ARMORSTAND_META);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setBody(EulerAngle vector)
 | 
			
		||||
    {
 | 
			
		||||
    public void setBody(EulerAngle vector) {
 | 
			
		||||
        setPose(MetaIndex.ARMORSTAND_BODY, vector);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setHead(EulerAngle vector)
 | 
			
		||||
    {
 | 
			
		||||
    public void setHead(EulerAngle vector) {
 | 
			
		||||
        setPose(MetaIndex.ARMORSTAND_HEAD, vector);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setLeftArm(EulerAngle vector)
 | 
			
		||||
    {
 | 
			
		||||
    public void setLeftArm(EulerAngle vector) {
 | 
			
		||||
        setPose(MetaIndex.ARMORSTAND_LEFT_ARM, vector);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setLeftLeg(EulerAngle vector)
 | 
			
		||||
    {
 | 
			
		||||
    public void setLeftLeg(EulerAngle vector) {
 | 
			
		||||
        setPose(MetaIndex.ARMORSTAND_LEFT_LEG, vector);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setMarker(boolean isMarker)
 | 
			
		||||
    {
 | 
			
		||||
    public void setMarker(boolean isMarker) {
 | 
			
		||||
        setArmorStandFlag(16, isMarker);
 | 
			
		||||
        sendData(MetaIndex.ARMORSTAND_META);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setNoBasePlate(boolean noBasePlate)
 | 
			
		||||
    {
 | 
			
		||||
    public void setNoBasePlate(boolean noBasePlate) {
 | 
			
		||||
        setArmorStandFlag(8, noBasePlate);
 | 
			
		||||
        sendData(MetaIndex.ARMORSTAND_META);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setNoGravity(boolean noGravity)
 | 
			
		||||
    {
 | 
			
		||||
    public void setNoGravity(boolean noGravity) {
 | 
			
		||||
        setArmorStandFlag(2, noGravity);
 | 
			
		||||
        sendData(MetaIndex.ARMORSTAND_META);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void setPose(MetaIndex<Vector3F> type, EulerAngle vector)
 | 
			
		||||
    {
 | 
			
		||||
    private void setPose(MetaIndex<Vector3F> type, EulerAngle vector) {
 | 
			
		||||
        setData(type, new Vector3F((float) vector.getX(), (float) vector.getY(), (float) vector.getZ()));
 | 
			
		||||
        sendData(type);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setRightArm(EulerAngle vector)
 | 
			
		||||
    {
 | 
			
		||||
    public void setRightArm(EulerAngle vector) {
 | 
			
		||||
        setPose(MetaIndex.ARMORSTAND_RIGHT_ARM, vector);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setRightLeg(EulerAngle vector)
 | 
			
		||||
    {
 | 
			
		||||
    public void setRightLeg(EulerAngle vector) {
 | 
			
		||||
        setPose(MetaIndex.ARMORSTAND_RIGHT_LEG, vector);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setShowArms(boolean showArms)
 | 
			
		||||
    {
 | 
			
		||||
    public void setShowArms(boolean showArms) {
 | 
			
		||||
        setArmorStandFlag(4, showArms);
 | 
			
		||||
        sendData(MetaIndex.ARMORSTAND_META);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setSmall(boolean isSmall)
 | 
			
		||||
    {
 | 
			
		||||
    public void setSmall(boolean isSmall) {
 | 
			
		||||
        setArmorStandFlag(1, isSmall);
 | 
			
		||||
        sendData(MetaIndex.ARMORSTAND_META);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -17,4 +17,13 @@ public class ArrowWatcher extends FlagWatcher {
 | 
			
		||||
        setData(MetaIndex.ARROW_CRITICAL, (byte) (critical ? 1 : 0));
 | 
			
		||||
        sendData(MetaIndex.ARROW_CRITICAL);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setPierceLevel(int pierceLevel) {
 | 
			
		||||
        setData(MetaIndex.ARROW_PIERCE_LEVEL, (byte) pierceLevel);
 | 
			
		||||
        sendData(MetaIndex.ARROW_PIERCE_LEVEL);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public int getPierceLevel() {
 | 
			
		||||
        return getData(MetaIndex.ARROW_PIERCE_LEVEL);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -15,7 +15,7 @@ public class BatWatcher extends InsentientWatcher
 | 
			
		||||
 | 
			
		||||
    public boolean isHanging()
 | 
			
		||||
    {
 | 
			
		||||
        return ((byte) getData(MetaIndex.BAT_HANGING)) == 1;
 | 
			
		||||
        return getData(MetaIndex.BAT_HANGING) == 1;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setHanging(boolean hanging)
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,69 @@
 | 
			
		||||
package me.libraryaddict.disguise.disguisetypes.watchers;
 | 
			
		||||
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.AnimalColor;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
 | 
			
		||||
import org.bukkit.DyeColor;
 | 
			
		||||
import org.bukkit.entity.Cat;
 | 
			
		||||
 | 
			
		||||
import java.util.Random;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created by libraryaddict on 6/05/2019.
 | 
			
		||||
 */
 | 
			
		||||
public class CatWatcher extends TameableWatcher {
 | 
			
		||||
    public CatWatcher(Disguise disguise) {
 | 
			
		||||
        super(disguise);
 | 
			
		||||
 | 
			
		||||
        setType(Cat.Type.values()[new Random().nextInt(Cat.Type.values().length)]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Cat.Type getType() {
 | 
			
		||||
        return Cat.Type.values()[getData(MetaIndex.CAT_TYPE)];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setType(Cat.Type type) {
 | 
			
		||||
        setData(MetaIndex.CAT_TYPE, type.ordinal());
 | 
			
		||||
        sendData(MetaIndex.CAT_TYPE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public void setCollarColor(AnimalColor color) {
 | 
			
		||||
        setCollarColor(color.getDyeColor());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setCollarColor(DyeColor newColor) {
 | 
			
		||||
        if (!isTamed()) {
 | 
			
		||||
            setTamed(true);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        if (newColor == getCollarColor().getDyeColor()) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        setData(MetaIndex.CAT_COLLAR, (int) newColor.getWoolData());
 | 
			
		||||
        sendData(MetaIndex.CAT_COLLAR);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public AnimalColor getCollarColor() {
 | 
			
		||||
        return AnimalColor.getColorByWool(getData(MetaIndex.CAT_COLLAR));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setLyingDown(boolean value) {
 | 
			
		||||
        setData(MetaIndex.CAT_LYING_DOWN, value);
 | 
			
		||||
        sendData(MetaIndex.CAT_LYING_DOWN);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isLyingDown() {
 | 
			
		||||
        return getData(MetaIndex.CAT_LYING_DOWN);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setLookingUp(boolean value) {
 | 
			
		||||
        setData(MetaIndex.CAT_LOOKING_UP, value);
 | 
			
		||||
        sendData(MetaIndex.CAT_LOOKING_UP);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isLookingUp() {
 | 
			
		||||
        return getData(MetaIndex.CAT_LOOKING_UP);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -13,12 +13,12 @@ public class CreeperWatcher extends InsentientWatcher
 | 
			
		||||
 | 
			
		||||
    public boolean isIgnited()
 | 
			
		||||
    {
 | 
			
		||||
        return (boolean) getData(MetaIndex.CREEPER_IGNITED);
 | 
			
		||||
        return getData(MetaIndex.CREEPER_IGNITED);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isPowered()
 | 
			
		||||
    {
 | 
			
		||||
        return (boolean) getData(MetaIndex.CREEPER_POWERED);
 | 
			
		||||
        return getData(MetaIndex.CREEPER_POWERED);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setIgnited(boolean ignited)
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,19 @@
 | 
			
		||||
package me.libraryaddict.disguise.disguisetypes.watchers;
 | 
			
		||||
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
 | 
			
		||||
import org.bukkit.Material;
 | 
			
		||||
import org.bukkit.inventory.ItemStack;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created by libraryaddict on 6/05/2019.
 | 
			
		||||
 */
 | 
			
		||||
public class EggWatcher extends ThrowableWatcher {
 | 
			
		||||
    public EggWatcher(Disguise disguise) {
 | 
			
		||||
        super(disguise);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected ItemStack getDefaultItemStack() {
 | 
			
		||||
        return new ItemStack(Material.EGG);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,19 @@
 | 
			
		||||
package me.libraryaddict.disguise.disguisetypes.watchers;
 | 
			
		||||
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
 | 
			
		||||
import org.bukkit.Material;
 | 
			
		||||
import org.bukkit.inventory.ItemStack;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created by libraryaddict on 6/05/2019.
 | 
			
		||||
 */
 | 
			
		||||
public class EnderPearlWatcher extends ThrowableWatcher {
 | 
			
		||||
    public EnderPearlWatcher(Disguise disguise) {
 | 
			
		||||
        super(disguise);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected ItemStack getDefaultItemStack() {
 | 
			
		||||
        return new ItemStack(Material.ENDER_PEARL);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,27 @@
 | 
			
		||||
package me.libraryaddict.disguise.disguisetypes.watchers;
 | 
			
		||||
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
 | 
			
		||||
import org.bukkit.Material;
 | 
			
		||||
import org.bukkit.inventory.ItemStack;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created by libraryaddict on 6/05/2019.
 | 
			
		||||
 */
 | 
			
		||||
public class EnderSignalWatcher extends FlagWatcher {
 | 
			
		||||
    public EnderSignalWatcher(Disguise disguise) {
 | 
			
		||||
        super(disguise);
 | 
			
		||||
 | 
			
		||||
        setItemStack(new ItemStack(Material.ENDER_EYE));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setItemStack(ItemStack item) {
 | 
			
		||||
        setData(MetaIndex.ENDER_SIGNAL_ITEM, item);
 | 
			
		||||
        sendData(MetaIndex.ENDER_SIGNAL_ITEM);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public ItemStack getItemStack() {
 | 
			
		||||
        return getData(MetaIndex.ENDER_SIGNAL_ITEM);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,27 @@
 | 
			
		||||
package me.libraryaddict.disguise.disguisetypes.watchers;
 | 
			
		||||
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
 | 
			
		||||
import org.bukkit.Material;
 | 
			
		||||
import org.bukkit.inventory.ItemStack;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created by libraryaddict on 6/05/2019.
 | 
			
		||||
 */
 | 
			
		||||
public class FireballWatcher extends FlagWatcher {
 | 
			
		||||
    public FireballWatcher(Disguise disguise) {
 | 
			
		||||
        super(disguise);
 | 
			
		||||
 | 
			
		||||
        setData(MetaIndex.FIREBALL_ITEM, new ItemStack(Material.FIRE_CHARGE));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public ItemStack getItemStack() {
 | 
			
		||||
        return getData(MetaIndex.FIREBALL_ITEM);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setItemStack(ItemStack item) {
 | 
			
		||||
        setData(MetaIndex.FIREBALL_ITEM, item);
 | 
			
		||||
        sendData(MetaIndex.FIREBALL_ITEM);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -7,6 +7,8 @@ import me.libraryaddict.disguise.disguisetypes.Disguise;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
 | 
			
		||||
 | 
			
		||||
import java.util.OptionalInt;
 | 
			
		||||
 | 
			
		||||
public class FireworkWatcher extends FlagWatcher {
 | 
			
		||||
    public FireworkWatcher(Disguise disguise) {
 | 
			
		||||
        super(disguise);
 | 
			
		||||
@@ -17,7 +19,16 @@ public class FireworkWatcher extends FlagWatcher {
 | 
			
		||||
            return new ItemStack(Material.AIR);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return (ItemStack) getData(MetaIndex.FIREWORK_ITEM);
 | 
			
		||||
        return getData(MetaIndex.FIREWORK_ITEM);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isShotAtAngle() {
 | 
			
		||||
        return getData(MetaIndex.FIREWORK_SHOT_AT_ANGLE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setShotAtAngle(boolean shotAtAngle) {
 | 
			
		||||
        setData(MetaIndex.FIREWORK_SHOT_AT_ANGLE, shotAtAngle);
 | 
			
		||||
        sendData(MetaIndex.FIREWORK_SHOT_AT_ANGLE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setFirework(ItemStack newItem) {
 | 
			
		||||
@@ -32,12 +43,12 @@ public class FireworkWatcher extends FlagWatcher {
 | 
			
		||||
        sendData(MetaIndex.FIREWORK_ITEM);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setAttachedEntity(int entityId) {
 | 
			
		||||
    public void setAttachedEntity(OptionalInt entityId) {
 | 
			
		||||
        setData(MetaIndex.FIREWORK_ATTACHED_ENTITY, entityId);
 | 
			
		||||
        sendData(MetaIndex.FIREWORK_ATTACHED_ENTITY);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public int getAttachedEntity() {
 | 
			
		||||
    public OptionalInt getAttachedEntity() {
 | 
			
		||||
        return getData(MetaIndex.FIREWORK_ATTACHED_ENTITY);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,100 @@
 | 
			
		||||
package me.libraryaddict.disguise.disguisetypes.watchers;
 | 
			
		||||
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
 | 
			
		||||
import org.bukkit.entity.Fox;
 | 
			
		||||
 | 
			
		||||
import java.util.Random;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created by libraryaddict on 6/05/2019.
 | 
			
		||||
 */
 | 
			
		||||
public class FoxWatcher extends AgeableWatcher {
 | 
			
		||||
    public FoxWatcher(Disguise disguise) {
 | 
			
		||||
        super(disguise);
 | 
			
		||||
 | 
			
		||||
        setType(Fox.Type.values()[new Random().nextInt(Fox.Type.values().length)]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isSitting() {
 | 
			
		||||
        return getFoxFlag(1);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isCrouching() {
 | 
			
		||||
        return getFoxFlag(4);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setCrouching(boolean value) {
 | 
			
		||||
        setFoxFlag(4, value);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setSitting(boolean value) {
 | 
			
		||||
        setFoxFlag(1, value);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isSleeping() {
 | 
			
		||||
        return getFoxFlag(32);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setSleeping(boolean value) {
 | 
			
		||||
        setFoxFlag(32, value);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Fox.Type getType() {
 | 
			
		||||
        return Fox.Type.values()[getData(MetaIndex.FOX_TYPE)];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setType(Fox.Type type) {
 | 
			
		||||
        setData(MetaIndex.FOX_TYPE, type.ordinal());
 | 
			
		||||
        sendData(MetaIndex.FOX_TYPE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setHeadTilted(boolean value) {
 | 
			
		||||
        setFoxFlag(8, value);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isHeadTilted() {
 | 
			
		||||
        return getFoxFlag(8);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setSpringing(boolean value) {
 | 
			
		||||
        setFoxFlag(16, value);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isSpringing() {
 | 
			
		||||
        return getFoxFlag(16);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setTipToeing(boolean value) {
 | 
			
		||||
        setFoxFlag(64, value);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isTipToeing() {
 | 
			
		||||
        return getFoxFlag(64);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setAngry(boolean value) {
 | 
			
		||||
        setFoxFlag(128, value);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isAngry() {
 | 
			
		||||
        return getFoxFlag(128);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private boolean getFoxFlag(int value) {
 | 
			
		||||
        return (getData(MetaIndex.FOX_META) & value) != 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void setFoxFlag(int no, boolean flag) {
 | 
			
		||||
        byte b1 = getData(MetaIndex.FOX_META);
 | 
			
		||||
 | 
			
		||||
        if (flag) {
 | 
			
		||||
            b1 = (byte) (b1 | no);
 | 
			
		||||
        } else {
 | 
			
		||||
            b1 = (byte) (b1 & ~no);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        setData(MetaIndex.FOX_META, b1);
 | 
			
		||||
        sendData(MetaIndex.FOX_META);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -18,7 +18,7 @@ public class GuardianWatcher extends InsentientWatcher {
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    public boolean isTarget() {
 | 
			
		||||
        return ((int) getData(MetaIndex.GUARDIAN_TARGET)) != 0;
 | 
			
		||||
        return getData(MetaIndex.GUARDIAN_TARGET) != 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
 
 | 
			
		||||
@@ -18,24 +18,7 @@ public class HorseWatcher extends AbstractHorseWatcher {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Color getColor() {
 | 
			
		||||
        return Color.values()[((Integer) getData(MetaIndex.HORSE_COLOR) & 0xFF)];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public ItemStack getHorseArmor() {
 | 
			
		||||
        int horseValue = getHorseArmorAsInt();
 | 
			
		||||
 | 
			
		||||
        switch (horseValue) {
 | 
			
		||||
        case 1:
 | 
			
		||||
            return new ItemStack(Material.IRON_HORSE_ARMOR);
 | 
			
		||||
        case 2:
 | 
			
		||||
            return new ItemStack(Material.GOLDEN_HORSE_ARMOR);
 | 
			
		||||
        case 3:
 | 
			
		||||
            return new ItemStack(Material.DIAMOND_HORSE_ARMOR);
 | 
			
		||||
        default:
 | 
			
		||||
            break;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return null;
 | 
			
		||||
        return Color.values()[(getData(MetaIndex.HORSE_COLOR) & 0xFF)];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Style getStyle() {
 | 
			
		||||
@@ -47,38 +30,8 @@ public class HorseWatcher extends AbstractHorseWatcher {
 | 
			
		||||
        sendData(MetaIndex.HORSE_COLOR);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected int getHorseArmorAsInt() {
 | 
			
		||||
        return getData(MetaIndex.HORSE_ARMOR);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected void setHorseArmor(int armor) {
 | 
			
		||||
        setData(MetaIndex.HORSE_ARMOR, armor);
 | 
			
		||||
        sendData(MetaIndex.HORSE_ARMOR);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setStyle(Style style) {
 | 
			
		||||
        setData(MetaIndex.HORSE_COLOR, getColor().ordinal() & 0xFF | style.ordinal() << 8);
 | 
			
		||||
        sendData(MetaIndex.HORSE_COLOR);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setHorseArmor(ItemStack item) {
 | 
			
		||||
        int value = 0;
 | 
			
		||||
 | 
			
		||||
        if (item != null) {
 | 
			
		||||
            Material mat = item.getType();
 | 
			
		||||
 | 
			
		||||
            if (mat == Material.IRON_HORSE_ARMOR) {
 | 
			
		||||
                value = 1;
 | 
			
		||||
            }
 | 
			
		||||
            else if (mat == Material.GOLDEN_HORSE_ARMOR) {
 | 
			
		||||
                value = 2;
 | 
			
		||||
            }
 | 
			
		||||
            else if (mat == Material.DIAMOND_HORSE_ARMOR) {
 | 
			
		||||
                value = 3;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        setHorseArmor(value);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,11 +1,12 @@
 | 
			
		||||
package me.libraryaddict.disguise.disguisetypes.watchers;
 | 
			
		||||
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
 | 
			
		||||
import net.minecraft.server.v1_14_R1.EntityRaider;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created by libraryaddict on 9/06/2017.
 | 
			
		||||
 */
 | 
			
		||||
public class IllagerWatcher extends InsentientWatcher {
 | 
			
		||||
public class IllagerWatcher extends RaiderWatcher {
 | 
			
		||||
    public IllagerWatcher(Disguise disguise) {
 | 
			
		||||
        super(disguise);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -2,19 +2,19 @@ package me.libraryaddict.disguise.disguisetypes.watchers;
 | 
			
		||||
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
 | 
			
		||||
import org.bukkit.entity.Spellcaster;
 | 
			
		||||
 | 
			
		||||
public class IllagerWizardWatcher extends IllagerWatcher {
 | 
			
		||||
 | 
			
		||||
    public IllagerWizardWatcher(Disguise disguise) {
 | 
			
		||||
        super(disguise);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setSpellTicks(int spellTicks) {
 | 
			
		||||
        setData(MetaIndex.ILLAGER_SPELL_TICKS, (byte) spellTicks);
 | 
			
		||||
        sendData(MetaIndex.ILLAGER_SPELL_TICKS);
 | 
			
		||||
    public void setSpell(Spellcaster.Spell spell) {
 | 
			
		||||
        setData(MetaIndex.ILLAGER_SPELL, (byte) spell.ordinal());
 | 
			
		||||
        sendData(MetaIndex.ILLAGER_SPELL);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public int getSpellTicks() {
 | 
			
		||||
        return getData(MetaIndex.ILLAGER_SPELL_TICKS);
 | 
			
		||||
    public Spellcaster.Spell getSpell() {
 | 
			
		||||
        return Spellcaster.Spell.values()[getData(MetaIndex.ILLAGER_SPELL)];
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -29,7 +29,7 @@ public class InsentientWatcher extends LivingWatcher {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void setInsentientFlag(int i, boolean flag) {
 | 
			
		||||
        byte b0 = (byte) getData(MetaIndex.INSENTIENT_META);
 | 
			
		||||
        byte b0 = getData(MetaIndex.INSENTIENT_META);
 | 
			
		||||
 | 
			
		||||
        if (flag) {
 | 
			
		||||
            setData(MetaIndex.INSENTIENT_META, (byte) (b0 | 1 << i));
 | 
			
		||||
@@ -39,6 +39,6 @@ public class InsentientWatcher extends LivingWatcher {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private boolean getInsentientFlag(int i) {
 | 
			
		||||
        return ((byte) getData(MetaIndex.INSENTIENT_META) & 1 << i) != 0;
 | 
			
		||||
        return (getData(MetaIndex.INSENTIENT_META) & 1 << i) != 0;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -17,7 +17,7 @@ public class ItemFrameWatcher extends FlagWatcher {
 | 
			
		||||
            return new ItemStack(Material.AIR);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return (ItemStack) getData(MetaIndex.ITEMFRAME_ITEM);
 | 
			
		||||
        return getData(MetaIndex.ITEMFRAME_ITEM);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public int getRotation() {
 | 
			
		||||
 
 | 
			
		||||
@@ -3,6 +3,7 @@ package me.libraryaddict.disguise.disguisetypes.watchers;
 | 
			
		||||
import com.comphenix.protocol.PacketType.Play.Server;
 | 
			
		||||
import com.comphenix.protocol.ProtocolLibrary;
 | 
			
		||||
import com.comphenix.protocol.events.PacketContainer;
 | 
			
		||||
import com.comphenix.protocol.wrappers.BlockPosition;
 | 
			
		||||
import com.comphenix.protocol.wrappers.WrappedAttribute;
 | 
			
		||||
import com.comphenix.protocol.wrappers.WrappedAttribute.Builder;
 | 
			
		||||
import me.libraryaddict.disguise.DisguiseAPI;
 | 
			
		||||
@@ -19,6 +20,7 @@ import java.lang.reflect.InvocationTargetException;
 | 
			
		||||
import java.util.ArrayList;
 | 
			
		||||
import java.util.HashSet;
 | 
			
		||||
import java.util.List;
 | 
			
		||||
import java.util.Optional;
 | 
			
		||||
 | 
			
		||||
public class LivingWatcher extends FlagWatcher {
 | 
			
		||||
    private double maxHealth;
 | 
			
		||||
@@ -39,6 +41,23 @@ public class LivingWatcher extends FlagWatcher {
 | 
			
		||||
        return clone;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setBedPosition(BlockPosition blockPosition) {
 | 
			
		||||
        Optional<BlockPosition> optional;
 | 
			
		||||
 | 
			
		||||
        if (blockPosition != null) {
 | 
			
		||||
            optional = Optional.of(blockPosition);
 | 
			
		||||
        } else {
 | 
			
		||||
            optional = Optional.empty();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        setData(MetaIndex.LIVING_BED_POSITION, optional);
 | 
			
		||||
        sendData(MetaIndex.LIVING_BED_POSITION);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public BlockPosition getBedPosition() {
 | 
			
		||||
        return getData(MetaIndex.LIVING_BED_POSITION).orElse(null);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public float getHealth() {
 | 
			
		||||
        return getData(MetaIndex.LIVING_HEALTH);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -26,6 +26,7 @@ public class LlamaWatcher extends ChestedHorseWatcher {
 | 
			
		||||
        sendData(MetaIndex.LLAMA_CARPET);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public void setCarpet(AnimalColor color) {
 | 
			
		||||
        setCarpet(color.getDyeColor());
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,23 @@
 | 
			
		||||
package me.libraryaddict.disguise.disguisetypes.watchers;
 | 
			
		||||
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
 | 
			
		||||
import org.bukkit.entity.MushroomCow;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created by libraryaddict on 6/05/2019.
 | 
			
		||||
 */
 | 
			
		||||
public class MushroomCowWatcher extends AgeableWatcher {
 | 
			
		||||
    public MushroomCowWatcher(Disguise disguise) {
 | 
			
		||||
        super(disguise);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public MushroomCow.Variant getVariant() {
 | 
			
		||||
        return MushroomCow.Variant.valueOf(getData(MetaIndex.MUSHROOM_COW_TYPE).toUpperCase());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setVariant(MushroomCow.Variant variant) {
 | 
			
		||||
        setData(MetaIndex.MUSHROOM_COW_TYPE, variant.name().toLowerCase());
 | 
			
		||||
        sendData(MetaIndex.MUSHROOM_COW_TYPE);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -6,22 +6,18 @@ import org.bukkit.entity.Ocelot.Type;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
 | 
			
		||||
 | 
			
		||||
public class OcelotWatcher extends TameableWatcher
 | 
			
		||||
{
 | 
			
		||||
public class OcelotWatcher extends AgeableWatcher {
 | 
			
		||||
 | 
			
		||||
    public OcelotWatcher(Disguise disguise)
 | 
			
		||||
    {
 | 
			
		||||
    public OcelotWatcher(Disguise disguise) {
 | 
			
		||||
        super(disguise);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Type getType()
 | 
			
		||||
    {
 | 
			
		||||
        return Ocelot.Type.getType(getData(MetaIndex.OCELOT_TYPE));
 | 
			
		||||
    public boolean isTrusting() {
 | 
			
		||||
        return getData(MetaIndex.OCELOT_TRUST);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setType(Type newType)
 | 
			
		||||
    {
 | 
			
		||||
        setData(MetaIndex.OCELOT_TYPE, newType.getId());
 | 
			
		||||
        sendData(MetaIndex.OCELOT_TYPE);
 | 
			
		||||
    public void setTrusting(boolean trusting) {
 | 
			
		||||
        setData(MetaIndex.OCELOT_TRUST, trusting);
 | 
			
		||||
        sendData(MetaIndex.OCELOT_TRUST);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,115 @@
 | 
			
		||||
package me.libraryaddict.disguise.disguisetypes.watchers;
 | 
			
		||||
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
 | 
			
		||||
import org.bukkit.entity.Panda;
 | 
			
		||||
 | 
			
		||||
import java.util.Random;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created by libraryaddict on 6/05/2019.
 | 
			
		||||
 */
 | 
			
		||||
public class PandaWatcher extends AgeableWatcher {
 | 
			
		||||
    public PandaWatcher(Disguise disguise) {
 | 
			
		||||
        super(disguise);
 | 
			
		||||
 | 
			
		||||
        setMainGene(Panda.Gene.values()[new Random().nextInt(Panda.Gene.values().length)]);
 | 
			
		||||
        setHiddenGene(Panda.Gene.values()[new Random().nextInt(Panda.Gene.values().length)]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Panda.Gene getMainGene() {
 | 
			
		||||
        int id = getData(MetaIndex.PANDA_MAIN_GENE);
 | 
			
		||||
 | 
			
		||||
        for (Panda.Gene gene : Panda.Gene.values()) {
 | 
			
		||||
            if (gene.ordinal() != id) {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return gene;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return Panda.Gene.NORMAL;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Panda.Gene getHiddenGene() {
 | 
			
		||||
        int id = getData(MetaIndex.PANDA_HIDDEN_GENE);
 | 
			
		||||
 | 
			
		||||
        for (Panda.Gene gene : Panda.Gene.values()) {
 | 
			
		||||
            if (gene.ordinal() != id) {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return gene;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return Panda.Gene.NORMAL;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setMainGene(Panda.Gene gene) {
 | 
			
		||||
        setData(MetaIndex.PANDA_MAIN_GENE, (byte) gene.ordinal());
 | 
			
		||||
        sendData(MetaIndex.PANDA_MAIN_GENE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setHiddenGene(Panda.Gene gene) {
 | 
			
		||||
        setData(MetaIndex.PANDA_HIDDEN_GENE, (byte) gene.ordinal());
 | 
			
		||||
        sendData(MetaIndex.PANDA_HIDDEN_GENE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setSneeze(boolean value) {
 | 
			
		||||
        setPandaFlag(2, value);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isSneeze() {
 | 
			
		||||
        return getPandaFlag(2);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setTumble(boolean value) {
 | 
			
		||||
        setPandaFlag(4, value);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isTumble() {
 | 
			
		||||
        return getPandaFlag(4);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setSitting(boolean value) {
 | 
			
		||||
        setPandaFlag(8, value);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isSitting() {
 | 
			
		||||
        return getPandaFlag(8);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setUpsideDown(boolean value) {
 | 
			
		||||
        setPandaFlag(16, value);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isUpsideDown() {
 | 
			
		||||
        return getPandaFlag(16);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setHeadShaking(int timeInTicks) {
 | 
			
		||||
        setData(MetaIndex.PANDA_HEAD_SHAKING, timeInTicks);
 | 
			
		||||
        sendData(MetaIndex.PANDA_HEAD_SHAKING);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public int getHeadShakingTicks() {
 | 
			
		||||
        return getData(MetaIndex.PANDA_HEAD_SHAKING);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private boolean getPandaFlag(int value) {
 | 
			
		||||
        return (getData(MetaIndex.PANDA_META) & value) != 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void setPandaFlag(int no, boolean flag) {
 | 
			
		||||
        byte b1 = getData(MetaIndex.PANDA_META);
 | 
			
		||||
 | 
			
		||||
        if (flag) {
 | 
			
		||||
            b1 = (byte) (b1 | no);
 | 
			
		||||
        } else {
 | 
			
		||||
            b1 = (byte) (b1 & ~no);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        setData(MetaIndex.PANDA_META, b1);
 | 
			
		||||
        sendData(MetaIndex.PANDA_META);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,22 @@
 | 
			
		||||
package me.libraryaddict.disguise.disguisetypes.watchers;
 | 
			
		||||
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created by libraryaddict on 6/05/2019.
 | 
			
		||||
 */
 | 
			
		||||
public class PillagerWatcher extends IllagerWatcher {
 | 
			
		||||
    public PillagerWatcher(Disguise disguise) {
 | 
			
		||||
        super(disguise);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setAimimgBow(boolean value) {
 | 
			
		||||
        setData(MetaIndex.PILLAGER_AIMING_BOW, value);
 | 
			
		||||
        sendData(MetaIndex.PILLAGER_AIMING_BOW);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isAimingBow() {
 | 
			
		||||
        return getData(MetaIndex.PILLAGER_AIMING_BOW);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -1,5 +1,6 @@
 | 
			
		||||
package me.libraryaddict.disguise.disguisetypes.watchers;
 | 
			
		||||
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.EntityPose;
 | 
			
		||||
import org.bukkit.block.BlockFace;
 | 
			
		||||
import org.bukkit.entity.Player;
 | 
			
		||||
import org.bukkit.inventory.MainHand;
 | 
			
		||||
@@ -18,8 +19,6 @@ import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
 | 
			
		||||
 | 
			
		||||
public class PlayerWatcher extends LivingWatcher {
 | 
			
		||||
    private boolean isInBed;
 | 
			
		||||
    private BlockFace sleepingDirection;
 | 
			
		||||
    private boolean alwaysShowInTab = DisguiseConfig.isShowDisguisedPlayersInTab();
 | 
			
		||||
 | 
			
		||||
    public PlayerWatcher(Disguise disguise) {
 | 
			
		||||
@@ -42,8 +41,6 @@ public class PlayerWatcher extends LivingWatcher {
 | 
			
		||||
    @Override
 | 
			
		||||
    public PlayerWatcher clone(Disguise disguise) {
 | 
			
		||||
        PlayerWatcher watcher = (PlayerWatcher) super.clone(disguise);
 | 
			
		||||
        watcher.isInBed = isInBed;
 | 
			
		||||
        watcher.sleepingDirection = sleepingDirection;
 | 
			
		||||
        watcher.alwaysShowInTab = alwaysShowInTab;
 | 
			
		||||
        return watcher;
 | 
			
		||||
    }
 | 
			
		||||
@@ -57,16 +54,9 @@ public class PlayerWatcher extends LivingWatcher {
 | 
			
		||||
        return MainHand.values()[getData(MetaIndex.PLAYER_HAND)];
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public BlockFace getSleepingDirection() {
 | 
			
		||||
        if (sleepingDirection == null) {
 | 
			
		||||
            if (this.getDisguise().getEntity() != null && isSleeping()) {
 | 
			
		||||
                this.sleepingDirection = BlockFace.values()[Math
 | 
			
		||||
                        .round(this.getDisguise().getEntity().getLocation().getYaw() / 90F) & 0x3];
 | 
			
		||||
            } else {
 | 
			
		||||
                return BlockFace.EAST;
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        return sleepingDirection;
 | 
			
		||||
        return BlockFace.SELF;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    // Bit 0 (0x01): Cape enabled
 | 
			
		||||
@@ -78,7 +68,7 @@ public class PlayerWatcher extends LivingWatcher {
 | 
			
		||||
    // Bit 6 (0x40): Hat enabled
 | 
			
		||||
 | 
			
		||||
    private boolean isSkinFlag(int i) {
 | 
			
		||||
        return ((byte) getData(MetaIndex.PLAYER_SKIN) & 1 << i) != 0;
 | 
			
		||||
        return (getData(MetaIndex.PLAYER_SKIN) & 1 << i) != 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isCapeEnabled() {
 | 
			
		||||
@@ -151,8 +141,9 @@ public class PlayerWatcher extends LivingWatcher {
 | 
			
		||||
        sendData(MetaIndex.PLAYER_SKIN);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public boolean isSleeping() {
 | 
			
		||||
        return isInBed;
 | 
			
		||||
        return getEntityPose() == EntityPose.SLEEPING;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setSkin(String playerName) {
 | 
			
		||||
@@ -163,10 +154,12 @@ public class PlayerWatcher extends LivingWatcher {
 | 
			
		||||
        ((PlayerDisguise) getDisguise()).setSkin(profile);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public void setSleeping(BlockFace sleepingDirection) {
 | 
			
		||||
        setSleeping(true, sleepingDirection);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public void setSleeping(boolean sleep) {
 | 
			
		||||
        setSleeping(sleep, null);
 | 
			
		||||
    }
 | 
			
		||||
@@ -177,56 +170,18 @@ public class PlayerWatcher extends LivingWatcher {
 | 
			
		||||
     * @param sleeping
 | 
			
		||||
     * @param sleepingDirection
 | 
			
		||||
     */
 | 
			
		||||
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public void setSleeping(boolean sleeping, BlockFace sleepingDirection) {
 | 
			
		||||
        if (sleepingDirection != null) {
 | 
			
		||||
            this.sleepingDirection = BlockFace.values()[sleepingDirection.ordinal() % 4];
 | 
			
		||||
        if (sleeping == isSleeping()) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        isInBed = sleeping;
 | 
			
		||||
 | 
			
		||||
        if (DisguiseConfig.isBedPacketsEnabled() && DisguiseUtilities.isDisguiseInUse(getDisguise())) {
 | 
			
		||||
            try {
 | 
			
		||||
                if (isSleeping()) {
 | 
			
		||||
                    for (Player player : DisguiseUtilities.getPerverts(getDisguise())) {
 | 
			
		||||
                        PacketContainer[] packets = DisguiseUtilities
 | 
			
		||||
                                .getBedPackets(getDisguise().getEntity().getLocation(), player.getLocation(),
 | 
			
		||||
                                        (PlayerDisguise) getDisguise());
 | 
			
		||||
 | 
			
		||||
                        if (getDisguise().getEntity() == player) {
 | 
			
		||||
                            for (PacketContainer packet : packets) {
 | 
			
		||||
                                packet = packet.shallowClone();
 | 
			
		||||
 | 
			
		||||
                                packet.getIntegers().write(0, DisguiseAPI.getSelfDisguiseId());
 | 
			
		||||
 | 
			
		||||
                                ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
 | 
			
		||||
                            }
 | 
			
		||||
                        } else {
 | 
			
		||||
                            for (PacketContainer packet : packets) {
 | 
			
		||||
                                ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
 | 
			
		||||
                            }
 | 
			
		||||
                        }
 | 
			
		||||
                    }
 | 
			
		||||
                } else {
 | 
			
		||||
                    PacketContainer packet = new PacketContainer(Server.ANIMATION);
 | 
			
		||||
 | 
			
		||||
                    StructureModifier<Integer> mods = packet.getIntegers();
 | 
			
		||||
 | 
			
		||||
                    mods.write(0, getDisguise().getEntity().getEntityId());
 | 
			
		||||
                    mods.write(1, 3);
 | 
			
		||||
 | 
			
		||||
                    for (Player player : DisguiseUtilities.getPerverts(getDisguise())) {
 | 
			
		||||
                        ProtocolLibrary.getProtocolManager().sendServerPacket(player, packet);
 | 
			
		||||
                    }
 | 
			
		||||
                }
 | 
			
		||||
            }
 | 
			
		||||
            catch (Exception ex) {
 | 
			
		||||
                ex.printStackTrace();
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
        setEntityPose(sleeping ? EntityPose.SLEEPING : EntityPose.STANDING);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    private void setSkinFlags(int i, boolean flag) {
 | 
			
		||||
        byte b0 = (byte) getData(MetaIndex.PLAYER_SKIN);
 | 
			
		||||
        byte b0 = getData(MetaIndex.PLAYER_SKIN);
 | 
			
		||||
 | 
			
		||||
        if (flag) {
 | 
			
		||||
            setData(MetaIndex.PLAYER_SKIN, (byte) (b0 | 1 << i));
 | 
			
		||||
 
 | 
			
		||||
@@ -16,7 +16,7 @@ public class RabbitWatcher extends AgeableWatcher
 | 
			
		||||
 | 
			
		||||
    public RabbitType getType()
 | 
			
		||||
    {
 | 
			
		||||
        return RabbitType.getType((int) getData(MetaIndex.RABBIT_TYPE));
 | 
			
		||||
        return RabbitType.getType(getData(MetaIndex.RABBIT_TYPE));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setType(RabbitType type)
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,22 @@
 | 
			
		||||
package me.libraryaddict.disguise.disguisetypes.watchers;
 | 
			
		||||
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created by libraryaddict on 6/05/2019.
 | 
			
		||||
 */
 | 
			
		||||
public class RaiderWatcher extends InsentientWatcher {
 | 
			
		||||
    public RaiderWatcher(Disguise disguise) {
 | 
			
		||||
        super(disguise);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setCastingSpell(boolean value) {
 | 
			
		||||
        setData(MetaIndex.RAIDER_CASTING_SPELL, value);
 | 
			
		||||
        sendData(MetaIndex.RAIDER_CASTING_SPELL);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isCastingSpell() {
 | 
			
		||||
        return getData(MetaIndex.RAIDER_CASTING_SPELL);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,12 @@
 | 
			
		||||
package me.libraryaddict.disguise.disguisetypes.watchers;
 | 
			
		||||
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created by libraryaddict on 6/05/2019.
 | 
			
		||||
 */
 | 
			
		||||
public class RavagerWatcher extends RaiderWatcher {
 | 
			
		||||
    public RavagerWatcher(Disguise disguise) {
 | 
			
		||||
        super(disguise);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -19,6 +19,7 @@ public class SheepWatcher extends AgeableWatcher {
 | 
			
		||||
        return (getData(MetaIndex.SHEEP_WOOL) & 16) != 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public void setColor(AnimalColor color) {
 | 
			
		||||
        setColor(color.getDyeColor());
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,7 @@ import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.AnimalColor;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
 | 
			
		||||
import org.bukkit.DyeColor;
 | 
			
		||||
import org.bukkit.block.BlockFace;
 | 
			
		||||
 | 
			
		||||
import java.util.Optional;
 | 
			
		||||
@@ -51,11 +52,21 @@ public class ShulkerWatcher extends InsentientWatcher {
 | 
			
		||||
        sendData(MetaIndex.SHULKER_PEEKING);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public void setColor(AnimalColor color) {
 | 
			
		||||
        setData(MetaIndex.SHULKER_COLOR, color.getDyeColor().getWoolData());
 | 
			
		||||
        sendData(MetaIndex.SHULKER_COLOR);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setColor(DyeColor newColor) {
 | 
			
		||||
        if (newColor == getColor().getDyeColor()) {
 | 
			
		||||
            return;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        setData(MetaIndex.SHULKER_COLOR, newColor.getWoolData());
 | 
			
		||||
        sendData(MetaIndex.SHULKER_COLOR);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public AnimalColor getColor() {
 | 
			
		||||
        return AnimalColor.getColorByWool(getData(MetaIndex.SHULKER_COLOR));
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -10,13 +10,4 @@ public class SkeletonWatcher extends InsentientWatcher {
 | 
			
		||||
    public SkeletonWatcher(Disguise disguise) {
 | 
			
		||||
        super(disguise);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setSwingArms(boolean swingingArms) {
 | 
			
		||||
        setData(MetaIndex.SKELETON_SWING_ARMS, swingingArms);
 | 
			
		||||
        sendData(MetaIndex.SKELETON_SWING_ARMS);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isSwingArms() {
 | 
			
		||||
        return getData(MetaIndex.SKELETON_SWING_ARMS);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -12,7 +12,7 @@ public class SlimeWatcher extends InsentientWatcher {
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public int getSize() {
 | 
			
		||||
        return (int) getData(MetaIndex.SLIME_SIZE);
 | 
			
		||||
        return getData(MetaIndex.SLIME_SIZE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setSize(int size) {
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,12 @@
 | 
			
		||||
package me.libraryaddict.disguise.disguisetypes.watchers;
 | 
			
		||||
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created by libraryaddict on 6/05/2019.
 | 
			
		||||
 */
 | 
			
		||||
public class SmallFireballWatcher extends FireballWatcher {
 | 
			
		||||
    public SmallFireballWatcher(Disguise disguise) {
 | 
			
		||||
        super(disguise);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,19 @@
 | 
			
		||||
package me.libraryaddict.disguise.disguisetypes.watchers;
 | 
			
		||||
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
 | 
			
		||||
import org.bukkit.Material;
 | 
			
		||||
import org.bukkit.inventory.ItemStack;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created by libraryaddict on 6/05/2019.
 | 
			
		||||
 */
 | 
			
		||||
public class SnowballWatcher extends ThrowableWatcher {
 | 
			
		||||
    public SnowballWatcher(Disguise disguise) {
 | 
			
		||||
        super(disguise);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected ItemStack getDefaultItemStack() {
 | 
			
		||||
        return new ItemStack(Material.SNOWBALL);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -30,12 +30,12 @@ public class TameableWatcher extends AgeableWatcher
 | 
			
		||||
 | 
			
		||||
    protected boolean isTameableFlag(int no)
 | 
			
		||||
    {
 | 
			
		||||
        return ((byte) getData(MetaIndex.TAMEABLE_META) & no) != 0;
 | 
			
		||||
        return (getData(MetaIndex.TAMEABLE_META) & no) != 0;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected void setTameableFlag(int no, boolean flag)
 | 
			
		||||
    {
 | 
			
		||||
        byte value = (byte) getData(MetaIndex.TAMEABLE_META);
 | 
			
		||||
        byte value = getData(MetaIndex.TAMEABLE_META);
 | 
			
		||||
 | 
			
		||||
        if (flag)
 | 
			
		||||
        {
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,28 @@
 | 
			
		||||
package me.libraryaddict.disguise.disguisetypes.watchers;
 | 
			
		||||
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
 | 
			
		||||
import org.bukkit.inventory.ItemStack;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created by libraryaddict on 6/05/2019.
 | 
			
		||||
 */
 | 
			
		||||
public abstract class ThrowableWatcher extends FlagWatcher {
 | 
			
		||||
    public ThrowableWatcher(Disguise disguise) {
 | 
			
		||||
        super(disguise);
 | 
			
		||||
 | 
			
		||||
        setItemStack(getDefaultItemStack());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    protected abstract ItemStack getDefaultItemStack();
 | 
			
		||||
 | 
			
		||||
    public ItemStack getItemStack() {
 | 
			
		||||
        return getData(MetaIndex.THROWABLE_ITEM);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setItemStack(ItemStack item) {
 | 
			
		||||
        setData(MetaIndex.THROWABLE_ITEM, item);
 | 
			
		||||
        sendData(MetaIndex.THROWABLE_ITEM);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,19 @@
 | 
			
		||||
package me.libraryaddict.disguise.disguisetypes.watchers;
 | 
			
		||||
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
 | 
			
		||||
import org.bukkit.Material;
 | 
			
		||||
import org.bukkit.inventory.ItemStack;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created by libraryaddict on 6/05/2019.
 | 
			
		||||
 */
 | 
			
		||||
public class ThrownExpBottleWatcher extends ThrowableWatcher {
 | 
			
		||||
    public ThrownExpBottleWatcher(Disguise disguise) {
 | 
			
		||||
        super(disguise);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
    protected ItemStack getDefaultItemStack() {
 | 
			
		||||
        return new ItemStack(Material.EXPERIENCE_BOTTLE);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -0,0 +1,12 @@
 | 
			
		||||
package me.libraryaddict.disguise.disguisetypes.watchers;
 | 
			
		||||
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created by libraryaddict on 6/05/2019.
 | 
			
		||||
 */
 | 
			
		||||
public class TraderLlamaWatcher extends LlamaWatcher {
 | 
			
		||||
    public TraderLlamaWatcher(Disguise disguise) {
 | 
			
		||||
        super(disguise);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -2,27 +2,49 @@ package me.libraryaddict.disguise.disguisetypes.watchers;
 | 
			
		||||
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.VillagerData;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
 | 
			
		||||
import org.bukkit.entity.Villager;
 | 
			
		||||
import org.bukkit.entity.Villager.Profession;
 | 
			
		||||
 | 
			
		||||
public class VillagerWatcher extends AgeableWatcher {
 | 
			
		||||
public class VillagerWatcher extends AbstractVillagerWatcher {
 | 
			
		||||
 | 
			
		||||
    public VillagerWatcher(Disguise disguise) {
 | 
			
		||||
        super(disguise);
 | 
			
		||||
 | 
			
		||||
        setProfession(Profession.values()[DisguiseUtilities.random.nextInt(Profession.values().length)]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public VillagerData getVillagerData() {
 | 
			
		||||
        return getData(MetaIndex.VILLAGER_DATA);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setVillagerData(VillagerData villagerData) {
 | 
			
		||||
        setData(MetaIndex.VILLAGER_DATA, villagerData);
 | 
			
		||||
        sendData(MetaIndex.VILLAGER_DATA);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Profession getProfession() {
 | 
			
		||||
        return Profession.values()[getData(MetaIndex.VILLAGER_PROFESSION) + 1];
 | 
			
		||||
        return getVillagerData().getProfession();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public void setProfession(int professionId) {
 | 
			
		||||
        setData(MetaIndex.VILLAGER_PROFESSION, professionId);
 | 
			
		||||
        sendData(MetaIndex.VILLAGER_PROFESSION);
 | 
			
		||||
    public Villager.Type getType() {
 | 
			
		||||
        return getVillagerData().getType();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setProfession(Profession newProfession) {
 | 
			
		||||
        setProfession(newProfession.ordinal() - 1);
 | 
			
		||||
    public int getLevel() {
 | 
			
		||||
        return getVillagerData().getLevel();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setProfession(Profession profession) {
 | 
			
		||||
        setVillagerData(new VillagerData(getType(), profession, getLevel()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setType(Villager.Type type) {
 | 
			
		||||
        setVillagerData(new VillagerData(type, getProfession(), getLevel()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setLevel(int level) {
 | 
			
		||||
        setVillagerData(new VillagerData(getType(), getProfession(), getLevel()));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -8,10 +8,4 @@ public class VindicatorWatcher extends IllagerWatcher {
 | 
			
		||||
    public VindicatorWatcher(Disguise disguise) {
 | 
			
		||||
        super(disguise);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setJohnny(boolean isJohnny) {
 | 
			
		||||
        setData(MetaIndex.ILLAGER_META, (byte) (isJohnny ? 1 : 0));
 | 
			
		||||
        sendData(MetaIndex.ILLAGER_META);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,12 @@
 | 
			
		||||
package me.libraryaddict.disguise.disguisetypes.watchers;
 | 
			
		||||
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created by libraryaddict on 6/05/2019.
 | 
			
		||||
 */
 | 
			
		||||
public class WanderingTraderWatcher extends AbstractVillagerWatcher {
 | 
			
		||||
    public WanderingTraderWatcher(Disguise disguise) {
 | 
			
		||||
        super(disguise);
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
@@ -6,23 +6,18 @@ import me.libraryaddict.disguise.disguisetypes.MetaIndex;
 | 
			
		||||
/**
 | 
			
		||||
 * @author Navid
 | 
			
		||||
 */
 | 
			
		||||
public class WitchWatcher extends InsentientWatcher
 | 
			
		||||
{
 | 
			
		||||
public class WitchWatcher extends RaiderWatcher {
 | 
			
		||||
 | 
			
		||||
    public WitchWatcher(Disguise disguise)
 | 
			
		||||
    {
 | 
			
		||||
    public WitchWatcher(Disguise disguise) {
 | 
			
		||||
        super(disguise);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isAggressive()
 | 
			
		||||
    {
 | 
			
		||||
        return (boolean) getData(MetaIndex.WITCH_AGGRESSIVE);
 | 
			
		||||
    public boolean isAggressive() {
 | 
			
		||||
        return getData(MetaIndex.WITCH_AGGRESSIVE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setAggressive(boolean aggressive)
 | 
			
		||||
    {
 | 
			
		||||
    public void setAggressive(boolean aggressive) {
 | 
			
		||||
        setData(MetaIndex.WITCH_AGGRESSIVE, aggressive);
 | 
			
		||||
        sendData(MetaIndex.WITCH_AGGRESSIVE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -14,7 +14,7 @@ public class WitherSkullWatcher extends FlagWatcher
 | 
			
		||||
 | 
			
		||||
    public boolean isBlue()
 | 
			
		||||
    {
 | 
			
		||||
        return (boolean) getData(MetaIndex.WITHER_SKULL_BLUE);
 | 
			
		||||
        return getData(MetaIndex.WITHER_SKULL_BLUE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setBlue(boolean blue)
 | 
			
		||||
 
 | 
			
		||||
@@ -22,7 +22,7 @@ public class WitherWatcher extends InsentientWatcher
 | 
			
		||||
     */
 | 
			
		||||
    public int getInvulnerability()
 | 
			
		||||
    {
 | 
			
		||||
        return (int) getData(MetaIndex.WITHER_INVUL);
 | 
			
		||||
        return getData(MetaIndex.WITHER_INVUL);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public int[] getTargets()
 | 
			
		||||
 
 | 
			
		||||
@@ -51,6 +51,7 @@ public class WolfWatcher extends TameableWatcher {
 | 
			
		||||
        setTameableFlag(2, angry);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public void setCollarColor(AnimalColor color) {
 | 
			
		||||
        setCollarColor(color.getDyeColor());
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -2,12 +2,18 @@ package me.libraryaddict.disguise.disguisetypes.watchers;
 | 
			
		||||
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.VillagerData;
 | 
			
		||||
import org.bukkit.entity.Villager;
 | 
			
		||||
import org.bukkit.entity.Villager.Profession;
 | 
			
		||||
 | 
			
		||||
import java.util.Random;
 | 
			
		||||
 | 
			
		||||
public class ZombieVillagerWatcher extends ZombieWatcher {
 | 
			
		||||
 | 
			
		||||
    public ZombieVillagerWatcher(Disguise disguise) {
 | 
			
		||||
        super(disguise);
 | 
			
		||||
 | 
			
		||||
        setProfession(Profession.values()[new Random().nextInt(Profession.values().length)]);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isShaking() {
 | 
			
		||||
@@ -20,7 +26,7 @@ public class ZombieVillagerWatcher extends ZombieWatcher {
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    public boolean isVillager() {
 | 
			
		||||
        return ((int) getData(MetaIndex.ZOMBIE_VILLAGER_PROFESSION)) != 0;
 | 
			
		||||
        return getData(MetaIndex.ZOMBIE_VILLAGER_PROFESSION).getProfession() != Profession.NONE;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setShaking(boolean shaking) {
 | 
			
		||||
@@ -28,32 +34,36 @@ public class ZombieVillagerWatcher extends ZombieWatcher {
 | 
			
		||||
        sendData(MetaIndex.ZOMBIE_VILLAGER_SHAKING);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Only returns a valid value if this zombie is a villager.
 | 
			
		||||
     *
 | 
			
		||||
     * @return
 | 
			
		||||
     */
 | 
			
		||||
    public VillagerData getVillagerData() {
 | 
			
		||||
        return getData(MetaIndex.VILLAGER_DATA);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setVillagerData(VillagerData villagerData) {
 | 
			
		||||
        setData(MetaIndex.VILLAGER_DATA, villagerData);
 | 
			
		||||
        sendData(MetaIndex.VILLAGER_DATA);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public Profession getProfession() {
 | 
			
		||||
        return Profession.values()[getData(MetaIndex.ZOMBIE_VILLAGER_PROFESSION) + 1];
 | 
			
		||||
        return getVillagerData().getProfession();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Sets the profession of this zombie, in turn turning it into a Zombie Villager
 | 
			
		||||
     *
 | 
			
		||||
     * @param id
 | 
			
		||||
     */
 | 
			
		||||
    @Deprecated
 | 
			
		||||
    public void setProfession(int id) {
 | 
			
		||||
        setData(MetaIndex.ZOMBIE_VILLAGER_PROFESSION, id);
 | 
			
		||||
        sendData(MetaIndex.ZOMBIE_VILLAGER_PROFESSION);
 | 
			
		||||
    public Villager.Type getType() {
 | 
			
		||||
        return getVillagerData().getType();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public int getLevel() {
 | 
			
		||||
        return getVillagerData().getLevel();
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Sets the profession of this zombie, in turn turning it into a Zombie Villager
 | 
			
		||||
     *
 | 
			
		||||
     * @param profession
 | 
			
		||||
     */
 | 
			
		||||
    public void setProfession(Profession profession) {
 | 
			
		||||
        setProfession(profession.ordinal() - 1);
 | 
			
		||||
        setVillagerData(new VillagerData(getType(), profession, getLevel()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setType(Villager.Type type) {
 | 
			
		||||
        setVillagerData(new VillagerData(type, getProfession(), getLevel()));
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setLevel(int level) {
 | 
			
		||||
        setVillagerData(new VillagerData(getType(), getProfession(), getLevel()));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -17,10 +17,6 @@ public class ZombieWatcher extends InsentientWatcher {
 | 
			
		||||
        return getData(MetaIndex.ZOMBIE_BABY);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isAggressive() {
 | 
			
		||||
        return (boolean) getData(MetaIndex.ZOMBIE_AGGRESSIVE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setAdult() {
 | 
			
		||||
        setBaby(false);
 | 
			
		||||
    }
 | 
			
		||||
@@ -34,11 +30,6 @@ public class ZombieWatcher extends InsentientWatcher {
 | 
			
		||||
        sendData(MetaIndex.ZOMBIE_BABY);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setAggressive(boolean handsup) {
 | 
			
		||||
        setData(MetaIndex.ZOMBIE_AGGRESSIVE, handsup);
 | 
			
		||||
        sendData(MetaIndex.ZOMBIE_AGGRESSIVE);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public boolean isConverting() {
 | 
			
		||||
        return getData(MetaIndex.ZOMBIE_CONVERTING_DROWNED);
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -27,13 +27,13 @@ import me.libraryaddict.disguise.utilities.reflection.FakeBoundingBox;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.reflection.LibsProfileLookup;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
 | 
			
		||||
import org.apache.commons.io.FileUtils;
 | 
			
		||||
import org.apache.logging.log4j.util.Strings;
 | 
			
		||||
import org.bukkit.Bukkit;
 | 
			
		||||
import org.bukkit.Location;
 | 
			
		||||
import org.bukkit.Material;
 | 
			
		||||
import org.bukkit.World;
 | 
			
		||||
import org.bukkit.block.BlockFace;
 | 
			
		||||
import org.bukkit.craftbukkit.libs.org.apache.commons.io.FileUtils;
 | 
			
		||||
import org.bukkit.entity.*;
 | 
			
		||||
import org.bukkit.inventory.EquipmentSlot;
 | 
			
		||||
import org.bukkit.inventory.ItemStack;
 | 
			
		||||
@@ -559,13 +559,13 @@ public class DisguiseUtilities {
 | 
			
		||||
        int entity = disguise.getEntity().getEntityId();
 | 
			
		||||
        PlayerWatcher watcher = disguise.getWatcher();
 | 
			
		||||
 | 
			
		||||
        PacketContainer setBed = new PacketContainer(Server.BED);
 | 
			
		||||
        //PacketContainer setBed = new PacketContainer(Server.BED);
 | 
			
		||||
 | 
			
		||||
        int bX = (getChunkCord(playerLocation.getBlockX()) * 16) + 1 + watcher.getSleepingDirection().getModX();
 | 
			
		||||
        int bZ = (getChunkCord(playerLocation.getBlockZ()) * 16) + 1 + watcher.getSleepingDirection().getModZ();
 | 
			
		||||
 | 
			
		||||
        setBed.getIntegers().write(0, entity);
 | 
			
		||||
        setBed.getBlockPositionModifier().write(0, new BlockPosition(bX, 0, bZ));
 | 
			
		||||
        // setBed.getIntegers().write(0, entity);
 | 
			
		||||
        // setBed.getBlockPositionModifier().write(0, new BlockPosition(bX, 0, bZ));
 | 
			
		||||
 | 
			
		||||
        PacketContainer teleport = new PacketContainer(Server.ENTITY_TELEPORT);
 | 
			
		||||
 | 
			
		||||
@@ -577,7 +577,7 @@ public class DisguiseUtilities {
 | 
			
		||||
        doubles.write(1, DisguiseUtilities.getYModifier(disguise.getEntity(), disguise) + sleepingLocation.getY());
 | 
			
		||||
        doubles.write(2, sleepingLocation.getZ());
 | 
			
		||||
 | 
			
		||||
        return new PacketContainer[]{setBed, teleport};
 | 
			
		||||
        return new PacketContainer[]{teleport};
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static Disguise getClonedDisguise(String key) {
 | 
			
		||||
@@ -903,10 +903,13 @@ public class DisguiseUtilities {
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            for (Constructor constructor : chunkClass.getConstructors()) {
 | 
			
		||||
                if (constructor.getParameterTypes().length != 8)
 | 
			
		||||
                if (constructor.getParameterTypes().length != 9)
 | 
			
		||||
                    continue;
 | 
			
		||||
 | 
			
		||||
                bedChunk = constructor.newInstance(world, 0, 0, biomes, null, null, null, 0L);
 | 
			
		||||
                Object cords = ReflectionManager.getNmsConstructor("ChunkCoordIntPair", int.class, int.class)
 | 
			
		||||
                        .newInstance(0, 0);
 | 
			
		||||
 | 
			
		||||
                bedChunk = constructor.newInstance(world, cords, biomes, null, null, null, 0L, null, null);
 | 
			
		||||
                break;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
@@ -917,8 +920,8 @@ public class DisguiseUtilities {
 | 
			
		||||
            Field cSection = chunkClass.getDeclaredField("sections");
 | 
			
		||||
            cSection.setAccessible(true);
 | 
			
		||||
 | 
			
		||||
            Object chunkSection = ReflectionManager.getNmsClass("ChunkSection").getConstructor(int.class, boolean.class)
 | 
			
		||||
                    .newInstance(0, true);
 | 
			
		||||
            Object chunkSection = ReflectionManager.getNmsClass("ChunkSection").getConstructor(int.class)
 | 
			
		||||
                    .newInstance(0);
 | 
			
		||||
 | 
			
		||||
            Class blockClass = ReflectionManager.getNmsClass("Block");
 | 
			
		||||
            Object REGISTRY = ReflectionManager.getNmsField("IRegistry", "BLOCK").get(null);
 | 
			
		||||
@@ -938,8 +941,6 @@ public class DisguiseUtilities {
 | 
			
		||||
 | 
			
		||||
            Method setType = chunkSection.getClass()
 | 
			
		||||
                    .getMethod("setType", int.class, int.class, int.class, ReflectionManager.getNmsClass("IBlockData"));
 | 
			
		||||
            Method setSky = chunkSection.getClass().getMethod("a", int.class, int.class, int.class, int.class);
 | 
			
		||||
            Method setEmitted = chunkSection.getClass().getMethod("b", int.class, int.class, int.class, int.class);
 | 
			
		||||
 | 
			
		||||
            for (BlockFace face : new BlockFace[]{BlockFace.EAST, BlockFace.WEST, BlockFace.NORTH, BlockFace.SOUTH}) {
 | 
			
		||||
                int x = 1 + face.getModX();
 | 
			
		||||
@@ -961,7 +962,7 @@ public class DisguiseUtilities {
 | 
			
		||||
                    .createPacketConstructor(PacketType.Play.Server.MAP_CHUNK, bedChunk, 65535)
 | 
			
		||||
                    .createPacket(bedChunk, 65535);
 | 
			
		||||
 | 
			
		||||
            Field threadField = ReflectionManager.getNmsField("MinecraftServer", "primaryThread");
 | 
			
		||||
            Field threadField = ReflectionManager.getNmsField("MinecraftServer", "serverThread");
 | 
			
		||||
            threadField.setAccessible(true);
 | 
			
		||||
 | 
			
		||||
            mainThread = (Thread) threadField.get(ReflectionManager.getMinecraftServer());
 | 
			
		||||
@@ -1036,10 +1037,10 @@ public class DisguiseUtilities {
 | 
			
		||||
                        .get(entityTrackerEntry);
 | 
			
		||||
 | 
			
		||||
                Method clear = ReflectionManager
 | 
			
		||||
                        .getNmsMethod("EntityTrackerEntry", "clear", ReflectionManager.getNmsClass("EntityPlayer"));
 | 
			
		||||
                        .getNmsMethod("EntityTrackerEntry", "a", ReflectionManager.getNmsClass("EntityPlayer"));
 | 
			
		||||
 | 
			
		||||
                final Method updatePlayer = ReflectionManager.getNmsMethod("EntityTrackerEntry", "updatePlayer",
 | 
			
		||||
                        ReflectionManager.getNmsClass("EntityPlayer"));
 | 
			
		||||
                final Method updatePlayer = ReflectionManager
 | 
			
		||||
                        .getNmsMethod("EntityTrackerEntry", "b", ReflectionManager.getNmsClass("EntityPlayer"));
 | 
			
		||||
 | 
			
		||||
                trackedPlayers = (Set) new HashSet(trackedPlayers).clone(); // Copy before iterating to prevent
 | 
			
		||||
                // ConcurrentModificationException
 | 
			
		||||
@@ -1090,10 +1091,10 @@ public class DisguiseUtilities {
 | 
			
		||||
                            .get(entityTrackerEntry);
 | 
			
		||||
 | 
			
		||||
                    Method clear = ReflectionManager
 | 
			
		||||
                            .getNmsMethod("EntityTrackerEntry", "clear", ReflectionManager.getNmsClass("EntityPlayer"));
 | 
			
		||||
                            .getNmsMethod("EntityTrackerEntry", "a", ReflectionManager.getNmsClass("EntityPlayer"));
 | 
			
		||||
 | 
			
		||||
                    final Method updatePlayer = ReflectionManager.getNmsMethod("EntityTrackerEntry", "updatePlayer",
 | 
			
		||||
                            ReflectionManager.getNmsClass("EntityPlayer"));
 | 
			
		||||
                    final Method updatePlayer = ReflectionManager
 | 
			
		||||
                            .getNmsMethod("EntityTrackerEntry", "b", ReflectionManager.getNmsClass("EntityPlayer"));
 | 
			
		||||
 | 
			
		||||
                    trackedPlayers = (Set) new HashSet(trackedPlayers).clone(); // Copy before iterating to prevent
 | 
			
		||||
                    // ConcurrentModificationException
 | 
			
		||||
@@ -1161,10 +1162,10 @@ public class DisguiseUtilities {
 | 
			
		||||
                        .get(entityTrackerEntry);
 | 
			
		||||
 | 
			
		||||
                final Method clear = ReflectionManager
 | 
			
		||||
                        .getNmsMethod("EntityTrackerEntry", "clear", ReflectionManager.getNmsClass("EntityPlayer"));
 | 
			
		||||
                        .getNmsMethod("EntityTrackerEntry", "a", ReflectionManager.getNmsClass("EntityPlayer"));
 | 
			
		||||
 | 
			
		||||
                final Method updatePlayer = ReflectionManager.getNmsMethod("EntityTrackerEntry", "updatePlayer",
 | 
			
		||||
                        ReflectionManager.getNmsClass("EntityPlayer"));
 | 
			
		||||
                final Method updatePlayer = ReflectionManager
 | 
			
		||||
                        .getNmsMethod("EntityTrackerEntry", "b", ReflectionManager.getNmsClass("EntityPlayer"));
 | 
			
		||||
 | 
			
		||||
                trackedPlayers = (Set) new HashSet(trackedPlayers).clone();
 | 
			
		||||
 | 
			
		||||
@@ -1567,7 +1568,7 @@ public class DisguiseUtilities {
 | 
			
		||||
            boolean isMoving = false;
 | 
			
		||||
 | 
			
		||||
            try {
 | 
			
		||||
                Field field = ReflectionManager.getNmsClass("EntityTrackerEntry").getDeclaredField("isMoving");
 | 
			
		||||
                Field field = ReflectionManager.getNmsClass("EntityTrackerEntry").getDeclaredField("q");
 | 
			
		||||
                field.setAccessible(true);
 | 
			
		||||
                isMoving = field.getBoolean(entityTrackerEntry);
 | 
			
		||||
            }
 | 
			
		||||
@@ -1630,10 +1631,10 @@ public class DisguiseUtilities {
 | 
			
		||||
 | 
			
		||||
            // If the disguised is sleeping for w/e reason
 | 
			
		||||
            if (player.isSleeping()) {
 | 
			
		||||
                sendSelfPacket(player,
 | 
			
		||||
            /*    sendSelfPacket(player,
 | 
			
		||||
                        manager.createPacketConstructor(Server.BED, player, ReflectionManager.getBlockPosition(0, 0, 0))
 | 
			
		||||
                                .createPacket(player, ReflectionManager
 | 
			
		||||
                                        .getBlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())));
 | 
			
		||||
                                        .getBlockPosition(loc.getBlockX(), loc.getBlockY(), loc.getBlockZ())));*/
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // Resend any active potion effects
 | 
			
		||||
@@ -1811,7 +1812,6 @@ public class DisguiseUtilities {
 | 
			
		||||
            case WITHER_SKULL:
 | 
			
		||||
                return (byte) (value - 128);
 | 
			
		||||
            case ARROW:
 | 
			
		||||
            case TIPPED_ARROW:
 | 
			
		||||
            case SPECTRAL_ARROW:
 | 
			
		||||
                return (byte) -value;
 | 
			
		||||
            case PAINTING:
 | 
			
		||||
@@ -1832,8 +1832,7 @@ public class DisguiseUtilities {
 | 
			
		||||
    public static double getYModifier(Entity entity, Disguise disguise) {
 | 
			
		||||
        double yMod = 0;
 | 
			
		||||
 | 
			
		||||
        if ((disguise.getType() != DisguiseType.PLAYER || !((PlayerWatcher) disguise.getWatcher()).isSleeping()) &&
 | 
			
		||||
                entity.getType() == EntityType.DROPPED_ITEM) {
 | 
			
		||||
        if (disguise.getType() != DisguiseType.PLAYER && entity.getType() == EntityType.DROPPED_ITEM) {
 | 
			
		||||
            yMod -= 0.13;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@@ -1859,7 +1858,7 @@ public class DisguiseUtilities {
 | 
			
		||||
                    default:
 | 
			
		||||
                        return yMod + 0.4;
 | 
			
		||||
                }
 | 
			
		||||
            case TIPPED_ARROW:
 | 
			
		||||
            case ARROW:
 | 
			
		||||
            case SPECTRAL_ARROW:
 | 
			
		||||
            case BOAT:
 | 
			
		||||
            case EGG:
 | 
			
		||||
@@ -1873,12 +1872,6 @@ public class DisguiseUtilities {
 | 
			
		||||
            case THROWN_EXP_BOTTLE:
 | 
			
		||||
            case WITHER_SKULL:
 | 
			
		||||
                return yMod + 0.7;
 | 
			
		||||
            case PLAYER:
 | 
			
		||||
                if (DisguiseConfig.isBedPacketsEnabled() && ((PlayerWatcher) disguise.getWatcher()).isSleeping()) {
 | 
			
		||||
                    return yMod + 0.35;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                break;
 | 
			
		||||
            case DROPPED_ITEM:
 | 
			
		||||
                return yMod + 0.13;
 | 
			
		||||
            default:
 | 
			
		||||
 
 | 
			
		||||
@@ -1,6 +1,7 @@
 | 
			
		||||
package me.libraryaddict.disguise.utilities;
 | 
			
		||||
 | 
			
		||||
import com.comphenix.protocol.PacketType;
 | 
			
		||||
import me.libraryaddict.disguise.LibsDisguises;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
 | 
			
		||||
import org.bukkit.configuration.file.YamlConfiguration;
 | 
			
		||||
 | 
			
		||||
@@ -235,9 +236,6 @@ public class LibsPremium {
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    /**
 | 
			
		||||
     * Add a naughty message for the invalid user ids
 | 
			
		||||
     */
 | 
			
		||||
    private static String getSanitizedUser(String userID) {
 | 
			
		||||
        if (userID == null) {
 | 
			
		||||
            return "N/A";
 | 
			
		||||
@@ -247,13 +245,19 @@ public class LibsPremium {
 | 
			
		||||
            return String.format("... %s? Am I reading this right?", userID);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return userID;
 | 
			
		||||
        int total = 0;
 | 
			
		||||
 | 
			
		||||
        for (char c : userID.toCharArray()) {
 | 
			
		||||
            total += Character.getNumericValue(c);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return String.format("%s(%s)", userID, total);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static void check(String version) {
 | 
			
		||||
        thisPluginIsPaidFor = isPremium();
 | 
			
		||||
 | 
			
		||||
        if (!isPremium()) {
 | 
			
		||||
        if (!isPremium() || !LibsDisguises.getInstance().isReleaseBuild()) {
 | 
			
		||||
            doSecondaryCheck(version);
 | 
			
		||||
        } else {
 | 
			
		||||
            DisguiseUtilities.getLogger().info("Registered to: " + getSanitizedUser(getUserID()));
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
package me.libraryaddict.disguise.utilities;
 | 
			
		||||
 | 
			
		||||
import com.google.gson.Gson;
 | 
			
		||||
import org.apache.commons.io.IOUtils;
 | 
			
		||||
import org.bukkit.craftbukkit.libs.org.apache.commons.io.IOUtils;
 | 
			
		||||
 | 
			
		||||
import java.io.InputStream;
 | 
			
		||||
import java.io.OutputStream;
 | 
			
		||||
 
 | 
			
		||||
@@ -6,13 +6,9 @@ import com.comphenix.protocol.wrappers.WrappedGameProfile;
 | 
			
		||||
import com.google.gson.*;
 | 
			
		||||
import com.google.gson.reflect.TypeToken;
 | 
			
		||||
import com.mojang.authlib.properties.PropertyMap;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.MetaIndex;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.*;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.watchers.ArrowWatcher;
 | 
			
		||||
import org.bukkit.inventory.ItemStack;
 | 
			
		||||
import sun.reflect.generics.tree.BaseType;
 | 
			
		||||
 | 
			
		||||
import java.lang.reflect.Field;
 | 
			
		||||
import java.lang.reflect.Method;
 | 
			
		||||
@@ -67,23 +63,30 @@ public class SerializerFlagWatcher implements JsonDeserializer<FlagWatcher>, Jso
 | 
			
		||||
        HashMap<Integer, Object> map = (HashMap<Integer, Object>) field.get(watcher);
 | 
			
		||||
 | 
			
		||||
        for (Map.Entry<Integer, Object> entry : map.entrySet()) {
 | 
			
		||||
            if (!(entry.getValue() instanceof Double))
 | 
			
		||||
                continue;
 | 
			
		||||
            if (entry.getValue() instanceof Double) {
 | 
			
		||||
                MetaIndex index = MetaIndex.getMetaIndex(flagWatcher, entry.getKey());
 | 
			
		||||
 | 
			
		||||
            MetaIndex index = MetaIndex.getMetaIndex(flagWatcher, entry.getKey());
 | 
			
		||||
                Object def = index.getDefault();
 | 
			
		||||
 | 
			
		||||
            Object def = index.getDefault();
 | 
			
		||||
                if (def instanceof Long)
 | 
			
		||||
                    entry.setValue(((Double) entry.getValue()).longValue());
 | 
			
		||||
                else if (def instanceof Float)
 | 
			
		||||
                    entry.setValue(((Double) entry.getValue()).floatValue());
 | 
			
		||||
                else if (def instanceof Integer)
 | 
			
		||||
                    entry.setValue(((Double) entry.getValue()).intValue());
 | 
			
		||||
                else if (def instanceof Short)
 | 
			
		||||
                    entry.setValue(((Double) entry.getValue()).shortValue());
 | 
			
		||||
                else if (def instanceof Byte)
 | 
			
		||||
                    entry.setValue(((Double) entry.getValue()).byteValue());
 | 
			
		||||
            } else if (entry.getValue() instanceof Map) {
 | 
			
		||||
                MetaIndex index = MetaIndex.getMetaIndex(flagWatcher, entry.getKey());
 | 
			
		||||
 | 
			
		||||
            if (def instanceof Long)
 | 
			
		||||
                entry.setValue(((Double) entry.getValue()).longValue());
 | 
			
		||||
            else if (def instanceof Float)
 | 
			
		||||
                entry.setValue(((Double) entry.getValue()).floatValue());
 | 
			
		||||
            else if (def instanceof Integer)
 | 
			
		||||
                entry.setValue(((Double) entry.getValue()).intValue());
 | 
			
		||||
            else if (def instanceof Short)
 | 
			
		||||
                entry.setValue(((Double) entry.getValue()).shortValue());
 | 
			
		||||
            else if (def instanceof Byte)
 | 
			
		||||
                entry.setValue(((Double) entry.getValue()).byteValue());
 | 
			
		||||
                if (!(index.getDefault() instanceof VillagerData)) {
 | 
			
		||||
                    continue;
 | 
			
		||||
                }
 | 
			
		||||
 | 
			
		||||
                entry.setValue(new Gson().fromJson(new Gson().toJson(entry.getValue()),VillagerData.class));
 | 
			
		||||
            }
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -23,6 +23,6 @@ public class SerializerItemStack implements JsonSerializer<ItemStack>, JsonDeser
 | 
			
		||||
    @Override
 | 
			
		||||
    public ItemStack deserialize(JsonElement json, Type typeOfT,
 | 
			
		||||
            JsonDeserializationContext context) throws JsonParseException {
 | 
			
		||||
        return ItemStack.deserialize((Map<String, Object>) context.deserialize(json, HashMap.class));
 | 
			
		||||
        return ItemStack.deserialize(context.deserialize(json, HashMap.class));
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -14,6 +14,7 @@ import java.io.File;
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.lang.reflect.InvocationTargetException;
 | 
			
		||||
import java.net.URL;
 | 
			
		||||
import java.nio.charset.StandardCharsets;
 | 
			
		||||
import java.util.*;
 | 
			
		||||
import java.util.logging.Level;
 | 
			
		||||
import java.util.zip.GZIPOutputStream;
 | 
			
		||||
@@ -321,7 +322,7 @@ public class Metrics {
 | 
			
		||||
        }
 | 
			
		||||
        ByteArrayOutputStream outputStream = new ByteArrayOutputStream();
 | 
			
		||||
        GZIPOutputStream gzip = new GZIPOutputStream(outputStream);
 | 
			
		||||
        gzip.write(str.getBytes("UTF-8"));
 | 
			
		||||
        gzip.write(str.getBytes(StandardCharsets.UTF_8));
 | 
			
		||||
        gzip.close();
 | 
			
		||||
        return outputStream.toByteArray();
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -136,11 +136,6 @@ public class PacketsManager {
 | 
			
		||||
                packetsToListen.add(Server.UPDATE_ATTRIBUTES);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // The bed packet.
 | 
			
		||||
            if (DisguiseConfig.isBedPacketsEnabled()) {
 | 
			
		||||
                packetsToListen.add(Server.BED);
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            // Add movement packets
 | 
			
		||||
            if (DisguiseConfig.isMovementPacketsEnabled()) {
 | 
			
		||||
                packetsToListen.add(Server.ENTITY_LOOK);
 | 
			
		||||
 
 | 
			
		||||
@@ -23,8 +23,7 @@ public class PacketHandlerAnimation implements IPacketHandler {
 | 
			
		||||
    public void handle(Disguise disguise, PacketContainer sentPacket, LibsPackets packets, Player observer,
 | 
			
		||||
            Entity entity) {
 | 
			
		||||
        // Else if the disguise is attempting to send players a forbidden packet
 | 
			
		||||
        if (disguise.getType().isMisc() || (sentPacket.getIntegers().read(1) == 2 && (!disguise.getType().isPlayer() ||
 | 
			
		||||
                (DisguiseConfig.isBedPacketsEnabled() && ((PlayerWatcher) disguise.getWatcher()).isSleeping())))) {
 | 
			
		||||
        if (disguise.getType().isMisc()) {
 | 
			
		||||
            packets.clear();
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
 
 | 
			
		||||
@@ -14,7 +14,7 @@ import org.bukkit.entity.Player;
 | 
			
		||||
public class PacketHandlerBed implements IPacketHandler {
 | 
			
		||||
    @Override
 | 
			
		||||
    public PacketType[] getHandledPackets() {
 | 
			
		||||
        return new PacketType[]{PacketType.Play.Server.BED};
 | 
			
		||||
        return new PacketType[]{};
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    @Override
 | 
			
		||||
 
 | 
			
		||||
@@ -25,18 +25,6 @@ public class PacketHandlerCollect implements IPacketHandler {
 | 
			
		||||
            Entity entity) {
 | 
			
		||||
        if (disguise.getType().isMisc()) {
 | 
			
		||||
            packets.clear();
 | 
			
		||||
        } else if (DisguiseConfig.isBedPacketsEnabled() && disguise.getType().isPlayer() &&
 | 
			
		||||
                ((PlayerWatcher) disguise.getWatcher()).isSleeping()) {
 | 
			
		||||
            PacketContainer newPacket = new PacketContainer(PacketType.Play.Server.ANIMATION);
 | 
			
		||||
 | 
			
		||||
            StructureModifier<Integer> mods = newPacket.getIntegers();
 | 
			
		||||
            mods.write(0, disguise.getEntity().getEntityId());
 | 
			
		||||
            mods.write(1, 3);
 | 
			
		||||
 | 
			
		||||
            packets.clear();
 | 
			
		||||
 | 
			
		||||
            packets.addPacket(newPacket);
 | 
			
		||||
            packets.addPacket(sentPacket);
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -240,15 +240,7 @@ public class PacketHandlerSpawn implements IPacketHandler {
 | 
			
		||||
 | 
			
		||||
            packets.addPacket(spawnPlayer);
 | 
			
		||||
 | 
			
		||||
            if (DisguiseConfig.isBedPacketsEnabled() && ((PlayerWatcher) disguise.getWatcher()).isSleeping()) {
 | 
			
		||||
                PacketContainer[] bedPackets = DisguiseUtilities.getBedPackets(
 | 
			
		||||
                        loc.clone().subtract(0, DisguiseUtilities.getYModifier(disguisedEntity, disguise), 0),
 | 
			
		||||
                        observer.getLocation(), ((PlayerDisguise) disguise));
 | 
			
		||||
 | 
			
		||||
                for (PacketContainer packet : bedPackets) {
 | 
			
		||||
                    packets.addPacket(packet);
 | 
			
		||||
                }
 | 
			
		||||
            } else if (!selfDisguise) {
 | 
			
		||||
            if (!selfDisguise) {
 | 
			
		||||
                // Teleport the player back to where he's supposed to be
 | 
			
		||||
                PacketContainer teleportPacket = new PacketContainer(PacketType.Play.Server.ENTITY_TELEPORT);
 | 
			
		||||
 | 
			
		||||
@@ -336,7 +328,6 @@ public class PacketHandlerSpawn implements IPacketHandler {
 | 
			
		||||
                    .createSanitizedDataWatcher(WrappedDataWatcher.getEntityWatcher(disguisedEntity),
 | 
			
		||||
                            disguise.getWatcher()));
 | 
			
		||||
        } else if (disguise.getType().isMisc()) {
 | 
			
		||||
            int objectId = disguise.getType().getObjectId();
 | 
			
		||||
            int data = ((MiscDisguise) disguise).getData();
 | 
			
		||||
 | 
			
		||||
            if (disguise.getType() == DisguiseType.FALLING_BLOCK) {
 | 
			
		||||
@@ -351,11 +342,14 @@ public class PacketHandlerSpawn implements IPacketHandler {
 | 
			
		||||
                data = ((((int) loc.getYaw() % 360) + 720 + 45) / 90) % 4;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            Object nmsEntity = ReflectionManager.getNmsEntity(disguisedEntity);
 | 
			
		||||
            Object entityType = ReflectionManager.getEntityType(disguise.getType().getEntityType());
 | 
			
		||||
 | 
			
		||||
            Object[] params = new Object[]{disguisedEntity.getEntityId(), disguisedEntity.getUniqueId(), loc.getX(),
 | 
			
		||||
                    loc.getY(), loc.getZ(), loc.getPitch(), loc.getYaw(), entityType, data,
 | 
			
		||||
                    ReflectionManager.getVec3D(disguisedEntity.getVelocity())};
 | 
			
		||||
 | 
			
		||||
            PacketContainer spawnEntity = ProtocolLibrary.getProtocolManager()
 | 
			
		||||
                    .createPacketConstructor(PacketType.Play.Server.SPAWN_ENTITY, nmsEntity, objectId, data)
 | 
			
		||||
                    .createPacket(nmsEntity, objectId, data);
 | 
			
		||||
                    .createPacketConstructor(PacketType.Play.Server.SPAWN_ENTITY, params).createPacket(params);
 | 
			
		||||
            packets.addPacket(spawnEntity);
 | 
			
		||||
 | 
			
		||||
            // If it's not the same type, then highly likely they have different velocity settings which we'd want to
 | 
			
		||||
 
 | 
			
		||||
@@ -26,7 +26,7 @@ public class PacketListenerViewSelfDisguise extends PacketAdapter {
 | 
			
		||||
    public PacketListenerViewSelfDisguise(LibsDisguises plugin) {
 | 
			
		||||
        super(plugin, ListenerPriority.HIGH, Server.NAMED_ENTITY_SPAWN, Server.ATTACH_ENTITY, Server.REL_ENTITY_MOVE,
 | 
			
		||||
                Server.REL_ENTITY_MOVE_LOOK, Server.ENTITY_LOOK, Server.ENTITY_TELEPORT, Server.ENTITY_HEAD_ROTATION,
 | 
			
		||||
                Server.ENTITY_METADATA, Server.ENTITY_EQUIPMENT, Server.ANIMATION, Server.BED, Server.ENTITY_EFFECT,
 | 
			
		||||
                Server.ENTITY_METADATA, Server.ENTITY_EQUIPMENT, Server.ANIMATION, Server.ENTITY_EFFECT,
 | 
			
		||||
                Server.ENTITY_VELOCITY, Server.UPDATE_ATTRIBUTES, Server.ENTITY_STATUS);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
 
 | 
			
		||||
@@ -5,6 +5,7 @@ import me.libraryaddict.disguise.DisguiseConfig;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.*;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.parser.params.ParamInfo;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.parser.params.ParamInfoManager;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.reflection.ReflectionManager;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.translations.TranslateType;
 | 
			
		||||
 
 | 
			
		||||
@@ -1,9 +1,10 @@
 | 
			
		||||
package me.libraryaddict.disguise.utilities.parser;
 | 
			
		||||
package me.libraryaddict.disguise.utilities.parser.params;
 | 
			
		||||
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.Disguise;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.parser.DisguisePerm;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.parser.params.ParamInfo;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.parser.params.ParamInfoTypes;
 | 
			
		||||
import org.bukkit.ChatColor;
 | 
			
		||||
@@ -4,6 +4,7 @@ import com.comphenix.protocol.wrappers.BlockPosition;
 | 
			
		||||
import com.comphenix.protocol.wrappers.WrappedGameProfile;
 | 
			
		||||
import com.comphenix.protocol.wrappers.WrappedParticle;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.AnimalColor;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.EntityPose;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.RabbitType;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.parser.params.types.ParamInfoEnum;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.parser.params.types.base.*;
 | 
			
		||||
@@ -31,15 +32,13 @@ public class ParamInfoTypes {
 | 
			
		||||
        List<ParamInfo> paramInfos = new ArrayList<>();
 | 
			
		||||
 | 
			
		||||
        // Register enum types
 | 
			
		||||
        paramInfos.add(new ParamInfoEnum(AnimalColor.class, "Animal Color",
 | 
			
		||||
                "View all the colors you can use for an animal color"));
 | 
			
		||||
        //paramInfos.add(new ParamInfoEnum(AnimalColor.class, "Animal Color",
 | 
			
		||||
        //        "View all the colors you can use for an animal color"));
 | 
			
		||||
        paramInfos
 | 
			
		||||
                .add(new ParamInfoEnum(Art.class, "Art", "View all the paintings you can use for a painting disguise"));
 | 
			
		||||
        paramInfos.add(new ParamInfoEnum(Horse.Color.class, "Horse Color",
 | 
			
		||||
                "View all the colors you can use for a horses color"));
 | 
			
		||||
 | 
			
		||||
        paramInfos.add(new ParamInfoEnum(Ocelot.Type.class, "Ocelot Type",
 | 
			
		||||
                "View all the ocelot types you can use for ocelots"));
 | 
			
		||||
        paramInfos.add(new ParamInfoEnum(Villager.Profession.class, "Villager Profession",
 | 
			
		||||
                "View all the professions you can set on a Zombie and Normal Villager"));
 | 
			
		||||
        paramInfos.add(new ParamInfoEnum(BlockFace.class, "Direction", "Direction (North, East, South, West, Up, Down)",
 | 
			
		||||
@@ -61,6 +60,12 @@ public class ParamInfoTypes {
 | 
			
		||||
        paramInfos.add(new ParamInfoEnum(DyeColor.class, "DyeColor", "Dye colors of many different colors"));
 | 
			
		||||
        paramInfos.add(new ParamInfoEnum(Horse.Style.class, "Horse Style",
 | 
			
		||||
                "Horse style which is the patterns on the horse"));
 | 
			
		||||
        paramInfos.add(new ParamInfoEnum(EntityPose.class, "EntityPose", "The pose the entity should strike"));
 | 
			
		||||
        paramInfos.add(new ParamInfoEnum(Cat.Type.class, "Cat Type", "The type of cat"));
 | 
			
		||||
        paramInfos.add(new ParamInfoEnum(Fox.Type.class, "Fox Type", "The type of fox"));
 | 
			
		||||
        paramInfos.add(new ParamInfoEnum(Panda.Gene.class, "Panda Gene", "The panda gene type"));
 | 
			
		||||
        paramInfos.add(new ParamInfoEnum(MushroomCow.Variant.class, "Mushroom Cow Variant",
 | 
			
		||||
                "The different variants for mushroom cows"));
 | 
			
		||||
 | 
			
		||||
        // Register custom types
 | 
			
		||||
        paramInfos.add(new ParamInfoEulerAngle(EulerAngle.class, "Euler Angle", "Euler Angle (X,Y,Z)",
 | 
			
		||||
 
 | 
			
		||||
@@ -5,7 +5,7 @@ import com.comphenix.protocol.wrappers.WrappedParticle;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.translations.LibsMsg;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.parser.DisguiseParseException;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.parser.params.types.ParamInfoEnum;
 | 
			
		||||
import org.apache.commons.lang3.StringUtils;
 | 
			
		||||
import org.apache.commons.lang.StringUtils;
 | 
			
		||||
import org.bukkit.Color;
 | 
			
		||||
import org.bukkit.Material;
 | 
			
		||||
import org.bukkit.Particle;
 | 
			
		||||
 
 | 
			
		||||
@@ -36,10 +36,6 @@ public class DisguiseValues {
 | 
			
		||||
        return babyBox;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public float[] getEntitySize() {
 | 
			
		||||
        return entitySize;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public double getMaxHealth() {
 | 
			
		||||
        return maxHealth;
 | 
			
		||||
    }
 | 
			
		||||
@@ -55,8 +51,4 @@ public class DisguiseValues {
 | 
			
		||||
    public void setBabyBox(FakeBoundingBox newBox) {
 | 
			
		||||
        babyBox = newBox;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public void setEntitySize(float[] size) {
 | 
			
		||||
        this.entitySize = size;
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
 
 | 
			
		||||
@@ -1,21 +1,32 @@
 | 
			
		||||
package me.libraryaddict.disguise.utilities.reflection;
 | 
			
		||||
 | 
			
		||||
import com.comphenix.protocol.ProtocolLibrary;
 | 
			
		||||
import com.comphenix.protocol.events.PacketContainer;
 | 
			
		||||
import com.comphenix.protocol.reflect.cloning.AggregateCloner;
 | 
			
		||||
import com.comphenix.protocol.wrappers.*;
 | 
			
		||||
import com.comphenix.protocol.wrappers.EnumWrappers.Direction;
 | 
			
		||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher.Registry;
 | 
			
		||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher.Serializer;
 | 
			
		||||
import com.comphenix.protocol.wrappers.WrappedDataWatcher.WrappedDataWatcherObject;
 | 
			
		||||
import com.comphenix.protocol.wrappers.nbt.NbtWrapper;
 | 
			
		||||
import com.mojang.datafixers.Dynamic;
 | 
			
		||||
import me.libraryaddict.disguise.DisguiseConfig;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
 | 
			
		||||
import org.apache.commons.io.IOUtils;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.EntityPose;
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.VillagerData;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
 | 
			
		||||
import net.minecraft.server.v1_14_R1.IRegistry;
 | 
			
		||||
import org.bukkit.*;
 | 
			
		||||
import org.bukkit.configuration.InvalidConfigurationException;
 | 
			
		||||
import org.bukkit.configuration.file.YamlConfiguration;
 | 
			
		||||
import org.bukkit.craftbukkit.libs.it.unimi.dsi.fastutil.ints.Int2ObjectMap;
 | 
			
		||||
import org.bukkit.craftbukkit.libs.org.apache.commons.io.IOUtils;
 | 
			
		||||
import org.bukkit.craftbukkit.v1_14_R1.util.CraftNamespacedKey;
 | 
			
		||||
import org.bukkit.entity.*;
 | 
			
		||||
import org.bukkit.inventory.EquipmentSlot;
 | 
			
		||||
import org.bukkit.inventory.ItemStack;
 | 
			
		||||
import org.bukkit.potion.PotionEffect;
 | 
			
		||||
import org.bukkit.util.Vector;
 | 
			
		||||
 | 
			
		||||
import java.io.IOException;
 | 
			
		||||
import java.io.InputStream;
 | 
			
		||||
@@ -23,22 +34,24 @@ import java.lang.reflect.*;
 | 
			
		||||
import java.nio.ByteBuffer;
 | 
			
		||||
import java.util.Optional;
 | 
			
		||||
import java.util.UUID;
 | 
			
		||||
import java.util.concurrent.atomic.AtomicInteger;
 | 
			
		||||
 | 
			
		||||
public class ReflectionManager {
 | 
			
		||||
    private static final String bukkitVersion = Bukkit.getServer().getClass().getName().split("\\.")[3];
 | 
			
		||||
    private static final Class<?> craftItemClass;
 | 
			
		||||
    private static Method damageAndIdleSoundMethod;
 | 
			
		||||
    private static final Field entitiesField;
 | 
			
		||||
    private static final Constructor<?> boundingBoxConstructor;
 | 
			
		||||
    private static final Method setBoundingBoxMethod;
 | 
			
		||||
    private static final Method ihmGet;
 | 
			
		||||
    private static final Field pingField;
 | 
			
		||||
    private static final Field trackerField;
 | 
			
		||||
    public static final Field entityCountField;
 | 
			
		||||
    private static final Field chunkMapField;
 | 
			
		||||
    private static final Field chunkProviderField;
 | 
			
		||||
    private static final Field entityTrackerField;
 | 
			
		||||
    private static final Field trackedEntitiesField;
 | 
			
		||||
 | 
			
		||||
    static {
 | 
			
		||||
        try {
 | 
			
		||||
            Object entity = createEntityInstance("Cow");
 | 
			
		||||
            Object entity = createEntityInstance(DisguiseType.COW, "Cow");
 | 
			
		||||
 | 
			
		||||
            for (Method method : getNmsClass("EntityLiving").getDeclaredMethods()) {
 | 
			
		||||
                if (method.getReturnType() != float.class)
 | 
			
		||||
@@ -69,11 +82,10 @@ public class ReflectionManager {
 | 
			
		||||
 | 
			
		||||
        pingField = getNmsField("EntityPlayer", "ping");
 | 
			
		||||
 | 
			
		||||
        trackerField = getNmsField("WorldServer", "tracker");
 | 
			
		||||
 | 
			
		||||
        entitiesField = getNmsField("EntityTracker", "trackedEntities");
 | 
			
		||||
 | 
			
		||||
        ihmGet = getNmsMethod("IntHashMap", "get", int.class);
 | 
			
		||||
        chunkProviderField = getNmsField("World", "chunkProvider");
 | 
			
		||||
        chunkMapField = getNmsField("ChunkProviderServer", "playerChunkMap");
 | 
			
		||||
        trackedEntitiesField = getNmsField("PlayerChunkMap", "trackedEntities");
 | 
			
		||||
        entityTrackerField = getNmsField("PlayerChunkMap$EntityTracker", "trackerEntry");
 | 
			
		||||
 | 
			
		||||
        boundingBoxConstructor = getNmsConstructor("AxisAlignedBB", double.class, double.class, double.class,
 | 
			
		||||
                double.class, double.class, double.class);
 | 
			
		||||
@@ -105,10 +117,14 @@ public class ReflectionManager {
 | 
			
		||||
 | 
			
		||||
    public static int getNewEntityId(boolean increment) {
 | 
			
		||||
        try {
 | 
			
		||||
            int id = entityCountField.getInt(null);
 | 
			
		||||
            AtomicInteger entityCount = (AtomicInteger) entityCountField.get(null);
 | 
			
		||||
 | 
			
		||||
            int id;
 | 
			
		||||
 | 
			
		||||
            if (increment) {
 | 
			
		||||
                entityCountField.set(null, id + 1);
 | 
			
		||||
                id = entityCount.getAndIncrement();
 | 
			
		||||
            } else {
 | 
			
		||||
                id = entityCount.get();
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return id;
 | 
			
		||||
@@ -120,7 +136,7 @@ public class ReflectionManager {
 | 
			
		||||
        return -1;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static Object createEntityInstance(String entityName) {
 | 
			
		||||
    public static Object createEntityInstance(DisguiseType disguiseType, String entityName) {
 | 
			
		||||
        try {
 | 
			
		||||
            Class<?> entityClass = getNmsClass("Entity" + entityName);
 | 
			
		||||
            Object entityObject;
 | 
			
		||||
@@ -131,7 +147,7 @@ public class ReflectionManager {
 | 
			
		||||
                    Object minecraftServer = getNmsMethod("MinecraftServer", "getServer").invoke(null);
 | 
			
		||||
 | 
			
		||||
                    Object playerinteractmanager = getNmsClass("PlayerInteractManager")
 | 
			
		||||
                            .getDeclaredConstructor(getNmsClass("World")).newInstance(world);
 | 
			
		||||
                            .getDeclaredConstructor(getNmsClass("WorldServer")).newInstance(world);
 | 
			
		||||
 | 
			
		||||
                    WrappedGameProfile gameProfile = getGameProfile(new UUID(0, 0), "Steve");
 | 
			
		||||
 | 
			
		||||
@@ -142,26 +158,25 @@ public class ReflectionManager {
 | 
			
		||||
                    break;
 | 
			
		||||
                case "EnderPearl":
 | 
			
		||||
                    entityObject = entityClass.getDeclaredConstructor(getNmsClass("World"), getNmsClass("EntityLiving"))
 | 
			
		||||
                            .newInstance(world, createEntityInstance("Cow"));
 | 
			
		||||
                    break;
 | 
			
		||||
                case "Potion":
 | 
			
		||||
                    entityObject = entityClass
 | 
			
		||||
                            .getDeclaredConstructor(getNmsClass("World"), Double.TYPE, Double.TYPE, Double.TYPE,
 | 
			
		||||
                                    getNmsClass("ItemStack"))
 | 
			
		||||
                            .newInstance(world, 0d, 0d, 0d, getNmsItem(new ItemStack(Material.SPLASH_POTION)));
 | 
			
		||||
                            .newInstance(world, createEntityInstance(DisguiseType.COW, "Cow"));
 | 
			
		||||
                    break;
 | 
			
		||||
                case "FishingHook":
 | 
			
		||||
                    entityObject = entityClass.getDeclaredConstructor(getNmsClass("World"), getNmsClass("EntityHuman"))
 | 
			
		||||
                            .newInstance(world, createEntityInstance("Player"));
 | 
			
		||||
                    entityObject = entityClass
 | 
			
		||||
                            .getDeclaredConstructor(getNmsClass("EntityHuman"), getNmsClass("World"), int.class,
 | 
			
		||||
                                    int.class)
 | 
			
		||||
                            .newInstance(createEntityInstance(DisguiseType.PLAYER, "Player"), world, 0, 0);
 | 
			
		||||
                    break;
 | 
			
		||||
                default:
 | 
			
		||||
                    entityObject = entityClass.getDeclaredConstructor(getNmsClass("World")).newInstance(world);
 | 
			
		||||
                    entityObject = entityClass.getDeclaredConstructor(getNmsClass("EntityTypes"), getNmsClass("World"))
 | 
			
		||||
                            .newInstance(getEntityType(disguiseType.getEntityType()), world);
 | 
			
		||||
                    break;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            return entityObject;
 | 
			
		||||
        }
 | 
			
		||||
        catch (Exception e) {
 | 
			
		||||
            DisguiseUtilities.getLogger()
 | 
			
		||||
                    .warning("Error while attempting to create entity instance for " + disguiseType.name());
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
@@ -315,10 +330,17 @@ public class ReflectionManager {
 | 
			
		||||
 | 
			
		||||
    public static Object getEntityTrackerEntry(Entity target) throws Exception {
 | 
			
		||||
        Object world = getWorldServer(target.getWorld());
 | 
			
		||||
        Object tracker = trackerField.get(world);
 | 
			
		||||
        Object trackedEntities = entitiesField.get(tracker);
 | 
			
		||||
        Object chunkProvider = chunkProviderField.get(world);
 | 
			
		||||
        Object chunkMap = chunkMapField.get(chunkProvider);
 | 
			
		||||
        Int2ObjectMap trackedEntities = (Int2ObjectMap) trackedEntitiesField.get(chunkMap);
 | 
			
		||||
 | 
			
		||||
        return ihmGet.invoke(trackedEntities, target.getEntityId());
 | 
			
		||||
        Object entityTracker = trackedEntities.get(target.getEntityId());
 | 
			
		||||
 | 
			
		||||
        if (entityTracker == null) {
 | 
			
		||||
            return null;
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return entityTrackerField.get(entityTracker);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static Object getMinecraftServer() {
 | 
			
		||||
@@ -588,11 +610,13 @@ public class ReflectionManager {
 | 
			
		||||
 | 
			
		||||
    public static float[] getSize(Entity entity) {
 | 
			
		||||
        try {
 | 
			
		||||
            float length = getNmsField("Entity", "length").getFloat(getNmsEntity(entity));
 | 
			
		||||
            float width = getNmsField("Entity", "width").getFloat(getNmsEntity(entity));
 | 
			
		||||
            Object size = getNmsField("Entity", "size").get(getNmsEntity(entity));
 | 
			
		||||
 | 
			
		||||
            float height = (Float) getNmsMethod("Entity", "getHeadHeight").invoke(getNmsEntity(entity));
 | 
			
		||||
            return new float[]{length, width, height};
 | 
			
		||||
            //float length = getNmsField("EntitySize", "length").getFloat(size);
 | 
			
		||||
            float width = getNmsField("EntitySize", "width").getFloat(size);
 | 
			
		||||
            float height = getNmsField("Entity", "headHeight").getFloat(getNmsEntity(entity));
 | 
			
		||||
 | 
			
		||||
            return new float[]{width, height};
 | 
			
		||||
        }
 | 
			
		||||
        catch (Exception ex) {
 | 
			
		||||
            ex.printStackTrace();
 | 
			
		||||
@@ -884,11 +908,64 @@ public class ReflectionManager {
 | 
			
		||||
            return ((NbtWrapper) value).getHandle();
 | 
			
		||||
        } else if (value instanceof WrappedParticle) {
 | 
			
		||||
            return ((WrappedParticle) value).getHandle();
 | 
			
		||||
        } else if (value instanceof EntityPose) {
 | 
			
		||||
            return getNmsEntityPose((EntityPose) value);
 | 
			
		||||
        } else if (value instanceof VillagerData) {
 | 
			
		||||
            return getNmsVillagerData((VillagerData) value);
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return value;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static Object getNmsVillagerData(VillagerData data) {
 | 
			
		||||
        Object type = getVillagerType(data.getType());
 | 
			
		||||
        Object profession = getVillagerProfession(data.getProfession());
 | 
			
		||||
 | 
			
		||||
        try {
 | 
			
		||||
            return getNmsConstructor("VillagerData", getNmsClass("VillagerType"), profession.getClass(), int.class)
 | 
			
		||||
                    .newInstance(type, profession, data.getLevel());
 | 
			
		||||
        }
 | 
			
		||||
        catch (Exception e) {
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static Object getVillagerType(Villager.Type type) {
 | 
			
		||||
        try {
 | 
			
		||||
            Object villagerType = getNmsField("IRegistry", "VILLAGER_TYPE").get(null);
 | 
			
		||||
 | 
			
		||||
            Method toMinecraft = getCraftMethod("util.CraftNamespacedKey", "toMinecraft", NamespacedKey.class);
 | 
			
		||||
            Object mcKey = toMinecraft.invoke(null, type.getKey());
 | 
			
		||||
            Method getField = getNmsMethod("RegistryBlocks", "get", mcKey.getClass());
 | 
			
		||||
 | 
			
		||||
            return getField.invoke(villagerType, mcKey);
 | 
			
		||||
        }
 | 
			
		||||
        catch (Exception e) {
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static Object getVillagerProfession(Villager.Profession profession) {
 | 
			
		||||
        try {
 | 
			
		||||
            Object villagerProfession = getNmsField("IRegistry", "VILLAGER_PROFESSION").get(null);
 | 
			
		||||
 | 
			
		||||
            Method toMinecraft = getCraftMethod("util.CraftNamespacedKey", "toMinecraft", NamespacedKey.class);
 | 
			
		||||
            Object mcKey = toMinecraft.invoke(null, profession.getKey());
 | 
			
		||||
            Method getField = getNmsMethod("RegistryBlocks", "get", mcKey.getClass());
 | 
			
		||||
 | 
			
		||||
            return getField.invoke(villagerProfession, mcKey);
 | 
			
		||||
        }
 | 
			
		||||
        catch (Exception e) {
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static String getMinecraftVersion() {
 | 
			
		||||
        String version = Bukkit.getVersion();
 | 
			
		||||
        version = version.substring(version.lastIndexOf(" ") + 1, version.length() - 1);
 | 
			
		||||
@@ -976,27 +1053,57 @@ public class ReflectionManager {
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static int getEntityType(Object nmsEntity) {
 | 
			
		||||
    public static Object getVec3D(Vector vector) {
 | 
			
		||||
        try {
 | 
			
		||||
            Field entityTypesField = null;
 | 
			
		||||
            Constructor c = getNmsConstructor("Vec3D", double.class, double.class, double.class);
 | 
			
		||||
 | 
			
		||||
            for (Method method : getNmsClass("Entity").getMethods()) {
 | 
			
		||||
                if (!method.getReturnType().getSimpleName().equals("EntityTypes"))
 | 
			
		||||
                    continue;
 | 
			
		||||
 | 
			
		||||
                Object entityType = method.invoke(nmsEntity);
 | 
			
		||||
                Class typesClass = getNmsClass("IRegistry");
 | 
			
		||||
 | 
			
		||||
                Object registry = typesClass.getField("ENTITY_TYPE").get(null);
 | 
			
		||||
 | 
			
		||||
                return (int) registry.getClass().getMethod("a", Object.class).invoke(registry, entityType);
 | 
			
		||||
            }
 | 
			
		||||
            return c.newInstance(vector.getX(), vector.getY(), vector.getZ());
 | 
			
		||||
        }
 | 
			
		||||
        catch (Exception ex) {
 | 
			
		||||
            ex.printStackTrace();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        throw new IllegalStateException("Failed to find EntityType for " + nmsEntity.getClass().getSimpleName());
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static Object getEntityType(EntityType entityType) {
 | 
			
		||||
        try {
 | 
			
		||||
            Method entityTypes = getNmsMethod("EntityTypes", "a", String.class);
 | 
			
		||||
 | 
			
		||||
            Optional<Object> entityObj = (Optional<Object>) entityTypes.invoke(null, entityType.getName());
 | 
			
		||||
 | 
			
		||||
            return entityObj.orElse(null);
 | 
			
		||||
        }
 | 
			
		||||
        catch (Exception e) {
 | 
			
		||||
            e.printStackTrace();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        return null;
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static int getEntityTypeId(EntityType entityType) {
 | 
			
		||||
        try {
 | 
			
		||||
            Object entityTypes = getEntityType(entityType);
 | 
			
		||||
 | 
			
		||||
            Class typesClass = getNmsClass("IRegistry");
 | 
			
		||||
 | 
			
		||||
            Object registry = typesClass.getField("ENTITY_TYPE").get(null);
 | 
			
		||||
 | 
			
		||||
            return (int) registry.getClass().getMethod("a", Object.class).invoke(registry, entityTypes);
 | 
			
		||||
        }
 | 
			
		||||
        catch (Exception ex) {
 | 
			
		||||
            ex.printStackTrace();
 | 
			
		||||
        }
 | 
			
		||||
 | 
			
		||||
        throw new IllegalStateException("Failed to find EntityType id for " + entityType);
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static Object getNmsEntityPose(EntityPose entityPose) {
 | 
			
		||||
        return Enum.valueOf(getNmsClass("EntityPose"), entityPose.name());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static EntityPose getEntityPose(Object nmsEntityPose) {
 | 
			
		||||
        return EntityPose.valueOf(((Enum) nmsEntityPose).name());
 | 
			
		||||
    }
 | 
			
		||||
 | 
			
		||||
    public static WrappedWatchableObject createWatchable(int index, Object obj) {
 | 
			
		||||
 
 | 
			
		||||
@@ -1,7 +1,7 @@
 | 
			
		||||
package me.libraryaddict.disguise.utilities.translations;
 | 
			
		||||
 | 
			
		||||
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
 | 
			
		||||
import org.apache.commons.lang3.StringUtils;
 | 
			
		||||
import org.apache.commons.lang.StringUtils;
 | 
			
		||||
import org.bukkit.ChatColor;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 
 | 
			
		||||
@@ -2,7 +2,7 @@ package me.libraryaddict.disguise.utilities.translations;
 | 
			
		||||
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.reflection.ClassGetter;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.parser.ParamInfoManager;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.parser.params.ParamInfoManager;
 | 
			
		||||
import me.libraryaddict.disguise.utilities.parser.params.ParamInfo;
 | 
			
		||||
import org.apache.commons.lang.StringUtils;
 | 
			
		||||
import org.bukkit.entity.Entity;
 | 
			
		||||
 
 | 
			
		||||
@@ -214,9 +214,6 @@ PacketsEnabled:
 | 
			
		||||
  # This disables the animation packet. If a disguised entity sends a animation packet and they are using a non-living disguise. People will crash.
 | 
			
		||||
  # Disabling this also means that if a player disguised as a non-player leaves a bug. People will crash
 | 
			
		||||
  Animation: true
 | 
			
		||||
  # Disabling this means that you can't use the setSleeping option on a player disguise. Also you will crash anyone watching when you try to sleep in a bed if disguised as a non-player
 | 
			
		||||
  # This also sends a chunk packet at key positions
 | 
			
		||||
  Bed: true
 | 
			
		||||
  # This disguises the collect packet. If a living entity disguised as a non-living entity picks up a item. People will crash. This fixes it
 | 
			
		||||
  # This also fixes people crashing if a item disguised as a sleeping player is picked up - Only true if Bed is enabled as well
 | 
			
		||||
  Collect: true
 | 
			
		||||
 
 | 
			
		||||
@@ -0,0 +1,25 @@
 | 
			
		||||
package me.libraryaddict.disguise.utilities;
 | 
			
		||||
 | 
			
		||||
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
 | 
			
		||||
import org.bukkit.entity.EntityType;
 | 
			
		||||
import org.junit.Assert;
 | 
			
		||||
import org.junit.Test;
 | 
			
		||||
 | 
			
		||||
/**
 | 
			
		||||
 * Created by libraryaddict on 4/05/2019.
 | 
			
		||||
 */
 | 
			
		||||
public class DisguiseTypesTest {
 | 
			
		||||
    @Test
 | 
			
		||||
    public void testDisguiseTypes() {
 | 
			
		||||
        for (EntityType entityType : EntityType.values()) {
 | 
			
		||||
            if (entityType == EntityType.LIGHTNING) {
 | 
			
		||||
                continue;
 | 
			
		||||
            }
 | 
			
		||||
 | 
			
		||||
            DisguiseType disguiseType = DisguiseType.getType(entityType);
 | 
			
		||||
 | 
			
		||||
            Assert.assertSame(entityType.name() + " has no DisguiseType registered!", disguiseType.name(),
 | 
			
		||||
                    entityType.name());
 | 
			
		||||
        }
 | 
			
		||||
    }
 | 
			
		||||
}
 | 
			
		||||
		Reference in New Issue
	
	Block a user