Add support for 1.8 disguises
This commit is contained in:
@@ -14,6 +14,7 @@ import me.libraryaddict.disguise.disguisetypes.FlagWatcher;
|
||||
import me.libraryaddict.disguise.disguisetypes.MiscDisguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.MobDisguise;
|
||||
import me.libraryaddict.disguise.disguisetypes.PlayerDisguise;
|
||||
import me.libraryaddict.disguise.utilities.ReflectionManager.LibVersion;
|
||||
|
||||
import org.bukkit.ChatColor;
|
||||
import org.bukkit.Material;
|
||||
@@ -22,7 +23,6 @@ import org.bukkit.command.CommandExecutor;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Ageable;
|
||||
import org.bukkit.entity.Animals;
|
||||
import org.bukkit.entity.Entity;
|
||||
import org.bukkit.entity.Monster;
|
||||
import org.bukkit.inventory.ItemStack;
|
||||
import org.bukkit.permissions.PermissionAttachmentInfo;
|
||||
@@ -31,15 +31,15 @@ import org.bukkit.potion.PotionEffectType;
|
||||
public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
|
||||
public class DisguiseParseException extends Exception {
|
||||
public DisguiseParseException(String string) {
|
||||
super(string);
|
||||
}
|
||||
private static final long serialVersionUID = 1276971370793124510L;
|
||||
|
||||
public DisguiseParseException() {
|
||||
super();
|
||||
}
|
||||
|
||||
private static final long serialVersionUID = 1276971370793124510L;
|
||||
public DisguiseParseException(String string) {
|
||||
super(string);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -147,7 +147,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
} else {
|
||||
for (DisguiseType type : DisguiseType.values()) {
|
||||
HashMap<ArrayList<String>, Boolean> options = null;
|
||||
Class entityClass = type.getEntityType() == null ? Entity.class : type.getEntityType().getEntityClass();
|
||||
Class entityClass = type.getEntityClass();
|
||||
if (disguiseType.equals("mob")) {
|
||||
if (type.isMob()) {
|
||||
options = getOptions(perm);
|
||||
@@ -203,7 +203,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
} else {
|
||||
for (DisguiseType type : DisguiseType.values()) {
|
||||
boolean foundHim = false;
|
||||
Class entityClass = type.getEntityType() == null ? Entity.class : type.getEntityType().getEntityClass();
|
||||
Class entityClass = type.getEntityClass();
|
||||
if (disguiseType.equals("mob")) {
|
||||
if (type.isMob()) {
|
||||
foundHim = true;
|
||||
@@ -337,7 +337,7 @@ public abstract class BaseDisguiseCommand implements CommandExecutor {
|
||||
throw new DisguiseParseException(ChatColor.RED + "Error! The disguise " + ChatColor.GREEN + args[0]
|
||||
+ ChatColor.RED + " doesn't exist!");
|
||||
}
|
||||
if (disguiseType.getEntityType() == null) {
|
||||
if (!(LibVersion.is1_8() && disguiseType.is1_8()) && disguiseType.getEntityType() == null) {
|
||||
throw new DisguiseParseException(ChatColor.RED + "Error! This version of minecraft does not have that disguise!");
|
||||
}
|
||||
if (!map.containsKey(disguiseType)) {
|
||||
|
@@ -264,7 +264,7 @@ public class DisguiseUtilities {
|
||||
destroyPacket.getIntegerArrays().write(0, new int[] { disguise.getEntity().getEntityId() });
|
||||
for (Object p : cloned) {
|
||||
Player player = (Player) ReflectionManager.getBukkitEntity(p);
|
||||
if (player == disguise.getEntity() || disguise.canSee(player.getName())) {
|
||||
if (player == disguise.getEntity() || disguise.canSee(player)) {
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, destroyPacket);
|
||||
}
|
||||
}
|
||||
@@ -787,7 +787,7 @@ public class DisguiseUtilities {
|
||||
HashSet cloned = (HashSet) trackedPlayers.clone();
|
||||
for (final Object p : cloned) {
|
||||
Player player = (Player) ReflectionManager.getBukkitEntity(p);
|
||||
if (disguise.getEntity() != player && disguise.canSee(player.getName())) {
|
||||
if (disguise.getEntity() != player && disguise.canSee(player)) {
|
||||
clear.invoke(entityTrackerEntry, p);
|
||||
ProtocolLibrary.getProtocolManager().sendServerPacket(player, destroyPacket);
|
||||
Bukkit.getScheduler().scheduleSyncDelayedTask(libsDisguises, new Runnable() {
|
||||
|
@@ -277,14 +277,14 @@ public class PacketsManager {
|
||||
delayedPackets = new PacketContainer[] { delayedPacket };
|
||||
}
|
||||
|
||||
} else if (disguise.getType().isMob()) {
|
||||
} else if (disguise.getType().isMob() || disguise.getType() == DisguiseType.ARMOR_STAND) {
|
||||
|
||||
DisguiseValues values = DisguiseValues.getDisguiseValues(disguise.getType());
|
||||
Vector vec = disguisedEntity.getVelocity();
|
||||
spawnPackets[0] = new PacketContainer(PacketType.Play.Server.SPAWN_ENTITY_LIVING);
|
||||
StructureModifier<Object> mods = spawnPackets[0].getModifier();
|
||||
mods.write(0, disguisedEntity.getEntityId());
|
||||
mods.write(1, (int) disguise.getType().getEntityType().getTypeId());
|
||||
mods.write(1, disguise.getType().getTypeId()); // TODO
|
||||
double d1 = 3.9D;
|
||||
double d2 = vec.getX();
|
||||
double d3 = vec.getY();
|
||||
@@ -421,7 +421,7 @@ public class PacketsManager {
|
||||
value = (byte) -(value + 128);
|
||||
break;
|
||||
default:
|
||||
if (disguiseType.isMisc()) {
|
||||
if (disguiseType.isMisc() && disguiseType != DisguiseType.ARMOR_STAND) {
|
||||
value -= 64;
|
||||
}
|
||||
break;
|
||||
|
Reference in New Issue
Block a user