Changed the feature somewhat
This commit is contained in:
parent
58ee6f37b7
commit
2aeb55cff9
@ -47,4 +47,6 @@ NameAboveHeadAlwaysVisible: true
|
|||||||
# This may have conflicts with some plugins, such as nocheatplus
|
# This may have conflicts with some plugins, such as nocheatplus
|
||||||
ModifyBoundingBox: false
|
ModifyBoundingBox: false
|
||||||
# This prevents disguised players from being targeted by monsters.
|
# This prevents disguised players from being targeted by monsters.
|
||||||
|
# This doesn't prevent their targeting you if already targeting when disguised
|
||||||
|
# They will just ignore you unless provoked.
|
||||||
MonstersIgnoreDisguises: false
|
MonstersIgnoreDisguises: false
|
@ -14,7 +14,6 @@ import me.libraryaddict.disguise.utilities.PacketsManager;
|
|||||||
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
import me.libraryaddict.disguise.utilities.ReflectionManager;
|
||||||
|
|
||||||
import org.bukkit.Bukkit;
|
import org.bukkit.Bukkit;
|
||||||
import org.bukkit.entity.Creature;
|
|
||||||
import org.bukkit.entity.Entity;
|
import org.bukkit.entity.Entity;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
@ -64,16 +63,6 @@ public class DisguiseAPI {
|
|||||||
DisguiseUtilities.refreshTrackers((TargetedDisguise) disguise);
|
DisguiseUtilities.refreshTrackers((TargetedDisguise) disguise);
|
||||||
// If he is a player, then self disguise himself
|
// If he is a player, then self disguise himself
|
||||||
DisguiseUtilities.setupFakeDisguise(disguise);
|
DisguiseUtilities.setupFakeDisguise(disguise);
|
||||||
// If the disguised is a player and you can't target disguised players..
|
|
||||||
if (isMonstersIgnoreDisguises() && entity instanceof Player) {
|
|
||||||
for (Entity monster : entity.getWorld().getEntities()) {
|
|
||||||
if (monster instanceof Creature) {
|
|
||||||
if (((Creature) monster).getTarget() == entity) {
|
|
||||||
((Creature) monster).setTarget(null);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void disguiseIgnorePlayers(Entity entity, Disguise disguise, List<String> playersToNotSeeDisguise) {
|
public static void disguiseIgnorePlayers(Entity entity, Disguise disguise, List<String> playersToNotSeeDisguise) {
|
||||||
|
@ -15,7 +15,6 @@ import org.bukkit.event.EventHandler;
|
|||||||
import org.bukkit.event.EventPriority;
|
import org.bukkit.event.EventPriority;
|
||||||
import org.bukkit.event.Listener;
|
import org.bukkit.event.Listener;
|
||||||
import org.bukkit.event.entity.EntityTargetEvent;
|
import org.bukkit.event.entity.EntityTargetEvent;
|
||||||
import org.bukkit.event.entity.EntityTargetEvent.TargetReason;
|
|
||||||
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
import org.bukkit.event.player.PlayerInteractEntityEvent;
|
||||||
import org.bukkit.event.player.PlayerJoinEvent;
|
import org.bukkit.event.player.PlayerJoinEvent;
|
||||||
import org.bukkit.event.player.PlayerQuitEvent;
|
import org.bukkit.event.player.PlayerQuitEvent;
|
||||||
@ -113,9 +112,18 @@ public class DisguiseListener implements Listener {
|
|||||||
|
|
||||||
@EventHandler
|
@EventHandler
|
||||||
public void onTarget(EntityTargetEvent event) {
|
public void onTarget(EntityTargetEvent event) {
|
||||||
if (DisguiseAPI.isMonstersIgnoreDisguises() && event.getReason() != TargetReason.CUSTOM && event.getTarget() != null
|
if (DisguiseAPI.isMonstersIgnoreDisguises() && event.getTarget() != null && event.getTarget() instanceof Player
|
||||||
&& event.getTarget() instanceof Player && DisguiseAPI.isDisguised(event.getTarget())) {
|
&& DisguiseAPI.isDisguised(event.getTarget())) {
|
||||||
|
switch (event.getReason()) {
|
||||||
|
case TARGET_ATTACKED_ENTITY:
|
||||||
|
case TARGET_ATTACKED_OWNER:
|
||||||
|
case OWNER_ATTACKED_TARGET:
|
||||||
|
case CUSTOM:
|
||||||
|
break;
|
||||||
|
default:
|
||||||
event.setCancelled(true);
|
event.setCancelled(true);
|
||||||
|
break;
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user