Add new disguise option for mobs to ignore selective disguises. Not usable through commands due to potential for abuse by simplistic permissions.
This commit is contained in:
parent
6f743eeafa
commit
320b4e1cb7
@ -556,18 +556,30 @@ public class DisguiseListener implements Listener {
|
||||
|
||||
@EventHandler
|
||||
public void onTarget(EntityTargetEvent event) {
|
||||
if (DisguiseConfig.isMonstersIgnoreDisguises() && event.getTarget() != null &&
|
||||
event.getTarget() instanceof Player && 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);
|
||||
break;
|
||||
}
|
||||
if (event.getTarget() == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
switch (event.getReason()) {
|
||||
case TARGET_ATTACKED_ENTITY:
|
||||
case TARGET_ATTACKED_OWNER:
|
||||
case OWNER_ATTACKED_TARGET:
|
||||
case CUSTOM:
|
||||
return;
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
Disguise disguise = DisguiseAPI.getDisguise(event.getTarget());
|
||||
|
||||
if (disguise == null) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (disguise.isMobsIgnoreDisguise()) {
|
||||
event.setCancelled(true);
|
||||
} else if (DisguiseConfig.isMonstersIgnoreDisguises() && event.getTarget() instanceof Player) {
|
||||
event.setCancelled(true);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -54,6 +54,7 @@ public abstract class Disguise {
|
||||
private boolean modifyBoundingBox = DisguiseConfig.isModifyBoundingBox();
|
||||
private boolean playerHiddenFromTab = DisguiseConfig.isHideDisguisedPlayers();
|
||||
private boolean replaceSounds = DisguiseConfig.isSoundEnabled();
|
||||
private boolean mobsIgnoreDisguise;
|
||||
private boolean showName;
|
||||
private transient BukkitTask task;
|
||||
private Runnable velocityRunnable;
|
||||
@ -864,4 +865,12 @@ public abstract class Disguise {
|
||||
public boolean stopDisguise() {
|
||||
return removeDisguise();
|
||||
}
|
||||
|
||||
public boolean isMobsIgnoreDisguise() {
|
||||
return mobsIgnoreDisguise;
|
||||
}
|
||||
|
||||
public void setMobsIgnoreDisguise(boolean mobsIgnoreDisguise) {
|
||||
this.mobsIgnoreDisguise = mobsIgnoreDisguise;
|
||||
}
|
||||
}
|
Loading…
Reference in New Issue
Block a user