diff --git a/config.yml b/config.yml
index c801f202..9427d2e4 100644
--- a/config.yml
+++ b/config.yml
@@ -27,4 +27,17 @@ RemoveHeldItem: true
# If you set a disguise to burning, it will no longer be able to be shown as sneaking or invisible.
# Set this to true if you want the disguise to get the animations of the disguised entity. Such as invisible, on fire, sprinting, sneaking, blocking
# This is only valid if you set a animation on the disguise itself. Because the entitys animations are applied otherwise.
-AddEntityAnimations: true
\ No newline at end of file
+AddEntityAnimations: true
+# If all players who can see a targeted disguise (Only advalible to plugins) have quit.
+# Does the plugin remove that disguise from valid disguises? If your plugin handles this. Then thats good.
+# Else its a memory leak. This loops through all disguise to see if anyone else is online who can see that disguise.
+RemoveUnusedDisguises: true
+# This is only called into action when the disguise is constructed using the commands.
+# And when the disguise supports that. This will not be used at all for plugins constructing the disguises for instance.
+# Such as prophunt. Its also false because its kind of a retarded feature.
+# This is pretty simple. It shows the players displayname (Name as it appears in chat) above their head.
+# This also overrides any custom name they have set in their disguise options.
+ShowNamesAboveDisguises: false
+# This supports the above option.
+# If this is true, then the name shown above the head appears regardless of if you are looking at the disguise directly or not.
+NameAboveHeadAlwaysVisible: true
\ No newline at end of file
diff --git a/pom.xml b/pom.xml
index 329017a3..c485527f 100644
--- a/pom.xml
+++ b/pom.xml
@@ -41,6 +41,11 @@
Comphenix Repositoryhttp://repo.comphenix.net/content/groups/public
+
+ comphenix-snapshot-rep
+ Comphenix Snapshot Repository
+ http://repo.comphenix.net/content/repositories/snapshots/
+ bukkit-repohttp://repo.bukkit.org/content/groups/public
@@ -56,7 +61,7 @@
com.comphenix.protocolProtocolLib
- 2.7.0
+ 3.0.0-SNAPSHOT7.7.5-SNAPSHOT
diff --git a/src/me/libraryaddict/disguise/DisguiseAPI.java b/src/me/libraryaddict/disguise/DisguiseAPI.java
index d230d7af..ba9a2b3e 100644
--- a/src/me/libraryaddict/disguise/DisguiseAPI.java
+++ b/src/me/libraryaddict/disguise/DisguiseAPI.java
@@ -1,7 +1,12 @@
package me.libraryaddict.disguise;
import java.lang.reflect.Field;
+import java.util.Arrays;
+import java.util.List;
+
import me.libraryaddict.disguise.disguisetypes.Disguise;
+import me.libraryaddict.disguise.disguisetypes.TargetedDisguise;
+import me.libraryaddict.disguise.disguisetypes.TargetedDisguise.TargetType;
import me.libraryaddict.disguise.events.DisguiseEvent;
import me.libraryaddict.disguise.events.UndisguiseEvent;
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
@@ -10,42 +15,24 @@ import me.libraryaddict.disguise.utilities.ReflectionManager;
import org.bukkit.Bukkit;
import org.bukkit.entity.Entity;
+import org.bukkit.entity.Player;
public class DisguiseAPI {
private static boolean hearSelfDisguise;
private static boolean hidingArmor;
private static boolean hidingHeldItem;
private static boolean isEntityAnimationsAdded;
+ private static boolean removeUnseenDisguises;
private static boolean sendVelocity;
+ private static boolean showNameAboveHead;
+ private static boolean showNameAboveHeadAlwaysVisible;
@Deprecated
public static boolean canHearSelfDisguise() {
return hearSelfDisguise;
}
- /**
- * Disguise the next entity to spawn with this disguise. This may not work however if the entity doesn't actually spawn.
- */
- public static void disguiseNextEntity(Disguise disguise) {
- if (disguise == null)
- return;
- if (disguise.getEntity() != null || DisguiseUtilities.getDisguises().containsValue(disguise)) {
- disguise = disguise.clone();
- }
- try {
- Field field = ReflectionManager.getNmsClass("Entity").getDeclaredField("entityCount");
- field.setAccessible(true);
- int id = field.getInt(null);
- DisguiseUtilities.getDisguises().put(id, disguise);
- } catch (Exception ex) {
- ex.printStackTrace();
- }
- }
-
- /**
- * Disguise this entity with this disguise
- */
- public static void disguiseToAll(Entity entity, Disguise disguise) {
+ public static void disguiseEntity(Entity entity, Disguise disguise) {
// If they are trying to disguise a null entity or use a null disguise
// Just return.
if (entity == null || disguise == null)
@@ -67,28 +54,95 @@ public class DisguiseAPI {
}
// Set the disguise's entity
disguise.setEntity(entity);
- } // If there was a old disguise
- Disguise oldDisguise = getDisguise(entity);
+ }
// Stick the disguise in the disguises bin
- DisguiseUtilities.getDisguises().put(entity.getEntityId(), disguise);
+ DisguiseUtilities.addDisguise(entity.getEntityId(), (TargetedDisguise) disguise);
// Resend the disguised entity's packet
- DisguiseUtilities.refreshTrackers(entity);
+ DisguiseUtilities.refreshTrackers((TargetedDisguise) disguise);
// If he is a player, then self disguise himself
DisguiseUtilities.setupFakeDisguise(disguise);
- // Discard the disguise
- if (oldDisguise != null)
- oldDisguise.removeDisguise();
+ }
+
+ public static void disguiseIgnorePlayers(Entity entity, Disguise disguise, List playersToNotSeeDisguise) {
+ ((TargetedDisguise) disguise).setDisguiseTarget(TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS);
+ for (String name : playersToNotSeeDisguise) {
+ ((TargetedDisguise) disguise).addPlayer(name);
+ }
+ disguiseEntity(entity, disguise);
+ }
+
+ public static void disguiseIgnorePlayers(Entity entity, Disguise disguise, String... playersToNotSeeDisguise) {
+ disguiseIgnorePlayers(entity, disguise, Arrays.asList(playersToNotSeeDisguise));
+ }
+
+ /**
+ * Disguise the next entity to spawn with this disguise. This may not work however if the entity doesn't actually spawn.
+ */
+ public static void disguiseNextEntity(Disguise disguise) {
+ if (disguise == null)
+ return;
+ if (disguise.getEntity() != null || DisguiseUtilities.getDisguises().containsValue(disguise)) {
+ disguise = disguise.clone();
+ }
+ try {
+ Field field = ReflectionManager.getNmsClass("Entity").getDeclaredField("entityCount");
+ field.setAccessible(true);
+ int id = field.getInt(null);
+ DisguiseUtilities.addDisguise(id, (TargetedDisguise) disguise);
+ } catch (Exception ex) {
+ ex.printStackTrace();
+ }
+ }
+
+ /**
+ * Disguise this entity with this disguise
+ */
+ public static void disguiseToAll(Entity entity, Disguise disguise) {
+ // You called the disguiseToAll method foolish mortal! Prepare to have your custom settings wiped!!!
+ ((TargetedDisguise) disguise).setDisguiseTarget(TargetType.SHOW_TO_EVERYONE_BUT_THESE_PLAYERS);
+ for (String observer : ((TargetedDisguise) disguise).getObservers())
+ ((TargetedDisguise) disguise).removePlayer(observer);
+ disguiseEntity(entity, disguise);
+ }
+
+ public static void disguiseToPlayers(Entity entity, Disguise disguise, List playersToViewDisguise) {
+ ((TargetedDisguise) disguise).setDisguiseTarget(TargetType.HIDE_DISGUISE_TO_EVERYONE_BUT_THESE_PLAYERS);
+ for (String name : playersToViewDisguise) {
+ ((TargetedDisguise) disguise).addPlayer(name);
+ }
+ disguiseEntity(entity, disguise);
+ }
+
+ public static void disguiseToPlayers(Entity entity, Disguise disguise, String... playersToViewDisguise) {
+ disguiseToPlayers(entity, disguise, Arrays.asList(playersToViewDisguise));
}
/**
* Get the disguise of a entity
*/
+ @Deprecated
public static Disguise getDisguise(Entity disguised) {
if (disguised == null)
return null;
- if (DisguiseUtilities.getDisguises().containsKey(disguised.getEntityId()))
- return DisguiseUtilities.getDisguises().get(disguised.getEntityId());
- return null;
+ return DisguiseUtilities.getDisguise(disguised.getEntityId());
+ }
+
+ /**
+ * Get the disguise of a entity
+ */
+ public static Disguise getDisguise(Player observer, Entity disguised) {
+ if (disguised == null)
+ return null;
+ return DisguiseUtilities.getDisguise(observer, disguised.getEntityId());
+ }
+
+ /**
+ * Get the disguises of a entity
+ */
+ public static Disguise[] getDisguises(Entity disguised) {
+ if (disguised == null)
+ return null;
+ return DisguiseUtilities.getDisguises(disguised.getEntityId());
}
/**
@@ -103,10 +157,22 @@ public class DisguiseAPI {
/**
* Is this entity disguised
*/
+ @Deprecated
public static boolean isDisguised(Entity disguised) {
return getDisguise(disguised) != null;
}
+ /**
+ * Is this entity disguised
+ */
+ public static boolean isDisguised(Player observer, Entity disguised) {
+ return getDisguise(observer, disguised) != null;
+ }
+
+ public static boolean isDisguiseInUse(Disguise disguise) {
+ return DisguiseUtilities.isDisguiseInUse(disguise);
+ }
+
public static boolean isEntityAnimationsAdded() {
return isEntityAnimationsAdded;
}
@@ -125,8 +191,12 @@ public class DisguiseAPI {
return hidingHeldItem;
}
- public static boolean isInventoryListenerEnabled() {
- return PacketsManager.isInventoryListenerEnabled();
+ public static boolean isNameAboveHeadAlwaysVisible() {
+ return showNameAboveHeadAlwaysVisible;
+ }
+
+ public static boolean isNameOfPlayerShownAboveDisguise() {
+ return showNameAboveHead;
}
public static boolean isSelfDisguisesSoundsReplaced() {
@@ -140,6 +210,10 @@ public class DisguiseAPI {
return PacketsManager.isHearDisguisesEnabled();
}
+ public static boolean isUnusedDisguisesRemoved() {
+ return removeUnseenDisguises;
+ }
+
/**
* Is the velocity packets sent
*/
@@ -173,6 +247,7 @@ public class DisguiseAPI {
public static void setHideArmorFromSelf(boolean hideArmor) {
if (hidingArmor != hideArmor) {
hidingArmor = hideArmor;
+ PacketsManager.setInventoryListenerEnabled(isHidingHeldItemFromSelf() || isHidingArmorFromSelf());
}
}
@@ -182,13 +257,16 @@ public class DisguiseAPI {
public static void setHideHeldItemFromSelf(boolean hideHelditem) {
if (hidingHeldItem != hideHelditem) {
hidingHeldItem = hideHelditem;
+ PacketsManager.setInventoryListenerEnabled(isHidingHeldItemFromSelf() || isHidingArmorFromSelf());
}
}
- public static void setInventoryListenerEnabled(boolean inventoryListenerEnabled) {
- if (PacketsManager.isInventoryListenerEnabled() != inventoryListenerEnabled) {
- PacketsManager.setInventoryListenerEnabled(inventoryListenerEnabled);
- }
+ public static void setNameAboveHeadAlwaysVisible(boolean alwaysVisible) {
+ showNameAboveHeadAlwaysVisible = alwaysVisible;
+ }
+
+ public static void setNameOfPlayerShownAboveDisguise(boolean showNames) {
+ showNameAboveHead = showNames;
}
/**
@@ -198,6 +276,10 @@ public class DisguiseAPI {
PacketsManager.setHearDisguisesListener(isSoundsEnabled);
}
+ public static void setUnusedDisguisesRemoved(boolean remove) {
+ removeUnseenDisguises = remove;
+ }
+
/**
* Disable velocity packets being sent for w/e reason. Maybe you want every ounce of performance you can get?
*/
@@ -214,14 +296,14 @@ public class DisguiseAPI {
* the world.
*/
public static void undisguiseToAll(Entity entity) {
- Disguise disguise = getDisguise(entity);
- if (disguise == null)
- return;
- UndisguiseEvent event = new UndisguiseEvent(entity, disguise);
- Bukkit.getPluginManager().callEvent(event);
- if (event.isCancelled())
- return;
- disguise.removeDisguise();
+ Disguise[] disguises = getDisguises(entity);
+ for (Disguise disguise : disguises) {
+ UndisguiseEvent event = new UndisguiseEvent(entity, disguise);
+ Bukkit.getPluginManager().callEvent(event);
+ if (event.isCancelled())
+ continue;
+ disguise.removeDisguise();
+ }
}
private DisguiseAPI() {
diff --git a/src/me/libraryaddict/disguise/DisguiseListener.java b/src/me/libraryaddict/disguise/DisguiseListener.java
index b3f60fe7..be0871ee 100644
--- a/src/me/libraryaddict/disguise/DisguiseListener.java
+++ b/src/me/libraryaddict/disguise/DisguiseListener.java
@@ -3,6 +3,8 @@ package me.libraryaddict.disguise;
import java.util.HashMap;
import me.libraryaddict.disguise.disguisetypes.Disguise;
+import me.libraryaddict.disguise.disguisetypes.TargetedDisguise;
+import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utilities.UpdateChecker;
@@ -14,6 +16,7 @@ import org.bukkit.event.EventPriority;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEntityEvent;
import org.bukkit.event.player.PlayerJoinEvent;
+import org.bukkit.event.player.PlayerQuitEvent;
import org.bukkit.event.vehicle.VehicleEnterEvent;
import org.bukkit.event.vehicle.VehicleExitEvent;
import org.bukkit.scheduler.BukkitRunnable;
@@ -66,6 +69,15 @@ public class DisguiseListener implements Listener {
p.sendMessage(String.format(updateMessage, currentVersion, latestVersion));
}
+ @EventHandler
+ public void onQuit(PlayerQuitEvent event) {
+ if (DisguiseAPI.isUnusedDisguisesRemoved()) {
+ for (TargetedDisguise disguise : DisguiseUtilities.getSeenDisguises(event.getPlayer().getName())) {
+ disguise.removeDisguise();
+ }
+ }
+ }
+
@EventHandler
public void onRightClick(PlayerInteractEntityEvent event) {
if (disguiseSlap.containsKey(event.getPlayer().getName())) {
@@ -74,6 +86,15 @@ public class DisguiseListener implements Listener {
disguiseRunnable.remove(event.getPlayer().getName()).cancel();
String entityName = event.getRightClicked().getType().name().toLowerCase().replace("_", " ");
if (disguise != null) {
+ if (event.getRightClicked() instanceof Player && DisguiseAPI.isNameOfPlayerShownAboveDisguise()) {
+ if (disguise.getWatcher() instanceof LivingWatcher) {
+ ((LivingWatcher) disguise.getWatcher())
+ .setCustomName(((Player) event.getRightClicked()).getDisplayName());
+ if (DisguiseAPI.isNameAboveHeadAlwaysVisible()) {
+ ((LivingWatcher) disguise.getWatcher()).setCustomNameVisible(true);
+ }
+ }
+ }
DisguiseAPI.disguiseToAll(event.getRightClicked(), disguise);
event.getPlayer().sendMessage(
ChatColor.RED + "Disguised the " + entityName + " as a "
@@ -92,8 +113,7 @@ public class DisguiseListener implements Listener {
public void onVechileEnter(VehicleEnterEvent event) {
if (event.isCancelled())
return;
- Disguise disguise = DisguiseAPI.getDisguise(event.getEntered());
- if (disguise != null && event.getEntered() instanceof Player) {
+ if (event.getEntered() instanceof Player && DisguiseAPI.isDisguised((Player) event.getEntered(), event.getEntered())) {
DisguiseUtilities.removeSelfDisguise((Player) event.getEntered());
((Player) event.getEntered()).updateInventory();
}
@@ -103,14 +123,16 @@ public class DisguiseListener implements Listener {
public void onVechileLeave(VehicleExitEvent event) {
if (event.isCancelled())
return;
- final Disguise disguise = DisguiseAPI.getDisguise(event.getExited());
- if (disguise != null && event.getExited() instanceof Player) {
- Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
- public void run() {
- DisguiseUtilities.setupFakeDisguise(disguise);
- ((Player) disguise.getEntity()).updateInventory();
- }
- });
+ if (event.getExited() instanceof Player) {
+ final Disguise disguise = DisguiseAPI.getDisguise((Player) event.getExited(), event.getExited());
+ if (disguise != null) {
+ Bukkit.getScheduler().scheduleSyncDelayedTask(plugin, new Runnable() {
+ public void run() {
+ DisguiseUtilities.setupFakeDisguise(disguise);
+ ((Player) disguise.getEntity()).updateInventory();
+ }
+ });
+ }
}
}
diff --git a/src/me/libraryaddict/disguise/LibsDisguises.java b/src/me/libraryaddict/disguise/LibsDisguises.java
index 60820715..3f033f17 100644
--- a/src/me/libraryaddict/disguise/LibsDisguises.java
+++ b/src/me/libraryaddict/disguise/LibsDisguises.java
@@ -64,9 +64,8 @@ public class LibsDisguises extends JavaPlugin {
DisguiseAPI.setHideArmorFromSelf(getConfig().getBoolean("RemoveArmor"));
DisguiseAPI.setHideHeldItemFromSelf(getConfig().getBoolean("RemoveHeldItem"));
DisguiseAPI.setAddEntityAnimations(getConfig().getBoolean("AddEntityAnimations"));
- if (DisguiseAPI.isHidingArmorFromSelf() || DisguiseAPI.isHidingHeldItemFromSelf()) {
- DisguiseAPI.setInventoryListenerEnabled(true);
- }
+ DisguiseAPI.setNameOfPlayerShownAboveDisguise(getConfig().getBoolean("ShowNamesAboveDisguises"));
+ DisguiseAPI.setNameAboveHeadAlwaysVisible(getConfig().getBoolean("NameAboveHeadAlwaysVisible"));
try {
// Here I use reflection to set the plugin for Disguise..
// Kind of stupid but I don't want open API calls for a commonly used object.
diff --git a/src/me/libraryaddict/disguise/commands/DisguiseCommand.java b/src/me/libraryaddict/disguise/commands/DisguiseCommand.java
index c71244b3..ef05a279 100644
--- a/src/me/libraryaddict/disguise/commands/DisguiseCommand.java
+++ b/src/me/libraryaddict/disguise/commands/DisguiseCommand.java
@@ -3,6 +3,7 @@ package me.libraryaddict.disguise.commands;
import java.util.ArrayList;
import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.disguisetypes.Disguise;
+import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
import me.libraryaddict.disguise.utilities.BaseDisguiseCommand;
import org.apache.commons.lang.StringUtils;
@@ -30,6 +31,14 @@ public class DisguiseCommand extends BaseDisguiseCommand {
}
return true;
}
+ if (DisguiseAPI.isNameOfPlayerShownAboveDisguise()) {
+ if (disguise.getWatcher() instanceof LivingWatcher) {
+ ((LivingWatcher) disguise.getWatcher()).setCustomName(((Player) sender).getDisplayName());
+ if (DisguiseAPI.isNameAboveHeadAlwaysVisible()) {
+ ((LivingWatcher) disguise.getWatcher()).setCustomNameVisible(true);
+ }
+ }
+ }
DisguiseAPI.disguiseToAll((Player) sender, disguise);
sender.sendMessage(ChatColor.RED + "Now disguised as a " + disguise.getType().toReadable());
return true;
diff --git a/src/me/libraryaddict/disguise/commands/DisguisePlayerCommand.java b/src/me/libraryaddict/disguise/commands/DisguisePlayerCommand.java
index 4618a970..7130272d 100644
--- a/src/me/libraryaddict/disguise/commands/DisguisePlayerCommand.java
+++ b/src/me/libraryaddict/disguise/commands/DisguisePlayerCommand.java
@@ -3,6 +3,7 @@ package me.libraryaddict.disguise.commands;
import java.util.ArrayList;
import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.disguisetypes.Disguise;
+import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
import me.libraryaddict.disguise.utilities.BaseDisguiseCommand;
import org.apache.commons.lang.StringUtils;
@@ -49,6 +50,14 @@ public class DisguisePlayerCommand extends BaseDisguiseCommand {
}
return true;
}
+ if (DisguiseAPI.isNameOfPlayerShownAboveDisguise()) {
+ if (disguise.getWatcher() instanceof LivingWatcher) {
+ ((LivingWatcher) disguise.getWatcher()).setCustomName(((Player) player).getDisplayName());
+ if (DisguiseAPI.isNameAboveHeadAlwaysVisible()) {
+ ((LivingWatcher) disguise.getWatcher()).setCustomNameVisible(true);
+ }
+ }
+ }
DisguiseAPI.disguiseToAll(player, disguise);
sender.sendMessage(ChatColor.RED + "Successfully disguised " + player.getName() + " as a "
+ disguise.getType().toReadable() + "!");
diff --git a/src/me/libraryaddict/disguise/commands/DisguiseRadiusCommand.java b/src/me/libraryaddict/disguise/commands/DisguiseRadiusCommand.java
index 178daeb6..c1f885c5 100644
--- a/src/me/libraryaddict/disguise/commands/DisguiseRadiusCommand.java
+++ b/src/me/libraryaddict/disguise/commands/DisguiseRadiusCommand.java
@@ -3,6 +3,7 @@ package me.libraryaddict.disguise.commands;
import java.util.ArrayList;
import me.libraryaddict.disguise.DisguiseAPI;
import me.libraryaddict.disguise.disguisetypes.Disguise;
+import me.libraryaddict.disguise.disguisetypes.watchers.LivingWatcher;
import me.libraryaddict.disguise.utilities.BaseDisguiseCommand;
import org.apache.commons.lang.StringUtils;
@@ -66,6 +67,15 @@ public class DisguiseRadiusCommand extends BaseDisguiseCommand {
for (Entity entity : ((Player) sender).getNearbyEntities(radius, radius, radius)) {
if (entity == sender)
continue;
+ disguise = disguise.clone();
+ if (entity instanceof Player && DisguiseAPI.isNameOfPlayerShownAboveDisguise()) {
+ if (disguise.getWatcher() instanceof LivingWatcher) {
+ ((LivingWatcher) disguise.getWatcher()).setCustomName(((Player) entity).getDisplayName());
+ if (DisguiseAPI.isNameAboveHeadAlwaysVisible()) {
+ ((LivingWatcher) disguise.getWatcher()).setCustomNameVisible(true);
+ }
+ }
+ }
DisguiseAPI.disguiseToAll(entity, disguise);
disguisedEntitys++;
}
diff --git a/src/me/libraryaddict/disguise/disguisetypes/AnimalColor.java b/src/me/libraryaddict/disguise/disguisetypes/AnimalColor.java
index c1021d00..08a1fa5a 100644
--- a/src/me/libraryaddict/disguise/disguisetypes/AnimalColor.java
+++ b/src/me/libraryaddict/disguise/disguisetypes/AnimalColor.java
@@ -10,6 +10,9 @@ public enum AnimalColor {
value = newValue;
}
+ /**
+ * The color ID as defined by nms internals.
+ */
public int getId() {
return value;
}
diff --git a/src/me/libraryaddict/disguise/disguisetypes/Disguise.java b/src/me/libraryaddict/disguise/disguisetypes/Disguise.java
index edbba176..f7a5c21d 100644
--- a/src/me/libraryaddict/disguise/disguisetypes/Disguise.java
+++ b/src/me/libraryaddict/disguise/disguisetypes/Disguise.java
@@ -22,7 +22,7 @@ import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitRunnable;
import org.bukkit.util.Vector;
-import com.comphenix.protocol.Packets;
+import com.comphenix.protocol.PacketType;
import com.comphenix.protocol.ProtocolLibrary;
import com.comphenix.protocol.events.PacketContainer;
import com.comphenix.protocol.reflect.StructureModifier;
@@ -48,12 +48,15 @@ public abstract class Disguise {
@Override
public abstract Disguise clone();
+ /**
+ * Seems I do this method so I can make cleaner constructors on disguises..
+ */
protected void createDisguise(DisguiseType newType, boolean doSounds) {
if (getWatcher() != null)
return;
if (newType.getEntityType() == null) {
throw new RuntimeException("DisguiseType " + newType
- + " was used to attempt to construct a disguise, but this version of craftbukkit does not have that entity");
+ + " was used in a futile attempt to construct a disguise, but this version of craftbukkit does not have that entity");
}
// Set the disguise type
disguiseType = newType;
@@ -61,7 +64,7 @@ public abstract class Disguise {
setReplaceSounds(doSounds);
// Get if they are a adult now..
boolean isAdult = true;
- if (this instanceof MobDisguise) {
+ if (isMobDisguise()) {
isAdult = ((MobDisguise) this).isAdult();
}
try {
@@ -175,6 +178,7 @@ public abstract class Disguise {
final boolean sendMovementPacket = movement;
final double vectorY = fallSpeed;
final boolean alwaysSendVelocity = alwaysSend;
+ final TargetedDisguise disguise=(TargetedDisguise) this;
// A scheduler to clean up any unused disguises.
velocityRunnable = new BukkitRunnable() {
private int i = 0;
@@ -185,11 +189,11 @@ public abstract class Disguise {
DisguiseAPI.undisguiseToAll(getEntity());
} else {
// If the disguise type is tnt, we need to resend the entity packet else it will turn invisible
- if (getType() == DisguiseType.PRIMED_TNT) {
+ if (getType() == DisguiseType.PRIMED_TNT || getType() == DisguiseType.FIREWORK) {
i++;
if (i % 40 == 0) {
i = 0;
- DisguiseUtilities.refreshTrackers(getEntity());
+ DisguiseUtilities.refreshTrackers(disguise);
if (getEntity() instanceof Player && isSelfDisguiseVisible()) {
DisguiseUtilities.sendSelfDisguise((Player) getEntity());
}
@@ -206,7 +210,7 @@ public abstract class Disguise {
if (getType() != DisguiseType.EXPERIENCE_ORB || !getEntity().isOnGround()) {
PacketContainer lookPacket = null;
if (getType() == DisguiseType.WITHER_SKULL) {
- lookPacket = new PacketContainer(Packets.Server.ENTITY_LOOK);
+ lookPacket = new PacketContainer(PacketType.Play.Server.ENTITY_LOOK);
StructureModifier