Fixed isInvulnerable for real this time

This commit is contained in:
NavidK0 2015-03-30 23:07:47 -04:00
parent 15c0141c3d
commit 1ea2a3f94f
8 changed files with 25 additions and 5 deletions

View File

@ -4,7 +4,6 @@ import java.util.ArrayList;
import java.util.HashMap;
import me.libraryaddict.disguise.DisguiseConfig;
import me.libraryaddict.disguise.DisguiseListener;
import me.libraryaddict.disguise.LibsDisguises;
import me.libraryaddict.disguise.disguisetypes.Disguise;
import me.libraryaddict.disguise.disguisetypes.DisguiseType;
@ -42,7 +41,10 @@ public class DisguiseEntityCommand extends BaseDisguiseCommand {
/**
* Send the player the information
* @param sender
* @param map
*/
@Override
protected void sendCommandUsage(CommandSender sender, HashMap<DisguiseType, HashMap<ArrayList<String>, Boolean>> map) {
ArrayList<String> allowedDisguises = getAllowedDisguises(map);
sender.sendMessage(ChatColor.DARK_GREEN + "Choose a disguise then right click a entity to disguise it!");

View File

@ -19,7 +19,6 @@ import me.libraryaddict.disguise.utilities.DisguiseUtilities;
import me.libraryaddict.disguise.utilities.PacketsManager;
import me.libraryaddict.disguise.utilities.ReflectionManager;
import me.libraryaddict.disguise.utilities.DisguiseValues;
import me.libraryaddict.disguise.utilities.ReflectionManager.LibVersion;
import org.bukkit.Bukkit;
import org.bukkit.Location;
@ -27,7 +26,6 @@ import org.bukkit.entity.Entity;
import org.bukkit.entity.LivingEntity;
import org.bukkit.entity.Horse.Variant;
import org.bukkit.entity.Player;
import org.bukkit.plugin.java.JavaPlugin;
import org.bukkit.scheduler.BukkitTask;
import org.bukkit.util.Vector;
@ -54,6 +52,7 @@ public abstract class Disguise {
private boolean velocitySent = DisguiseConfig.isVelocitySent();
private boolean viewSelfDisguise = DisguiseConfig.isViewDisguises();
private FlagWatcher watcher;
private boolean showName = false;
@Override
public abstract Disguise clone();
@ -322,6 +321,7 @@ public abstract class Disguise {
/**
* Get the disguised entity
* @return
*/
public Entity getEntity() {
return entity;
@ -329,6 +329,7 @@ public abstract class Disguise {
/**
* Get the disguise type
* @return
*/
public DisguiseType getType() {
return disguiseType;
@ -336,6 +337,7 @@ public abstract class Disguise {
/**
* Get the flag watcher
* @return
*/
public FlagWatcher getWatcher() {
return watcher;
@ -344,6 +346,7 @@ public abstract class Disguise {
/**
* In use doesn't mean that this disguise is active. It means that Lib's Disguises still stores a reference to the disguise.
* getEntity() can still return null if this disguise is active after despawn, logout, etc.
* @return
*/
public boolean isDisguiseInUse() {
return disguiseInUse;
@ -417,6 +420,14 @@ public abstract class Disguise {
return velocitySent;
}
/**
* Returns true if the entity's name is showing through the disguise
* @return
*/
public boolean isShowName() {
return showName;
}
/**
* Removes the disguise and undisguises the entity if its using this disguise.
*
@ -482,6 +493,8 @@ public abstract class Disguise {
/**
* Set the entity of the disguise. Only used for internal things.
* @param entity
* @return
*/
public Disguise setEntity(Entity entity) {
if (this.getEntity() != null) {
@ -498,6 +511,11 @@ public abstract class Disguise {
return this;
}
public Disguise setShowName(boolean showName) {
this.showName = showName;
return this;
}
public Disguise setHearSelfDisguise(boolean hearSelfDisguise) {
this.hearSelfDisguise = hearSelfDisguise;
return this;

View File

@ -583,7 +583,7 @@ public class PacketsManager {
nmsEntity) == ReflectionManager.getNmsField("EntityLiving",
"maxNoDamageTicks").getInt(nmsEntity);
} else {
hasInvun = (Boolean) ReflectionManager.getNmsMethod("Entity", "isInvulnerable")
hasInvun = (Boolean) ReflectionManager.getNmsMethod("Entity", "isInvulnerable", DamageSource.class)
.invoke(nmsEntity, DamageSource.GENERIC);
}
} catch (Exception ex) {
@ -819,7 +819,7 @@ public class PacketsManager {
PacketContainer packet = new PacketContainer(PacketType.Play.Server.ENTITY_METADATA);
StructureModifier<Object> mods = packet.getModifier();
mods.write(0, observer.getEntityId());
List<WrappedWatchableObject> watchableList = new ArrayList<WrappedWatchableObject>();
List<WrappedWatchableObject> watchableList = new ArrayList<>();
byte b = (byte) 1 << 5;
if (observer.isSprinting())
b = (byte) (b | 1 << 3);