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:
libraryaddict 2019-12-14 11:48:37 +13:00
parent 6f743eeafa
commit 320b4e1cb7
2 changed files with 33 additions and 12 deletions

View File

@ -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())) {
if (event.getTarget() == null) {
return;
}
switch (event.getReason()) {
case TARGET_ATTACKED_ENTITY:
case TARGET_ATTACKED_OWNER:
case OWNER_ATTACKED_TARGET:
case CUSTOM:
break;
return;
default:
event.setCancelled(true);
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);
}
}

View File

@ -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;
}
}