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 @EventHandler
public void onTarget(EntityTargetEvent event) { public void onTarget(EntityTargetEvent event) {
if (DisguiseConfig.isMonstersIgnoreDisguises() && event.getTarget() != null && if (event.getTarget() == null) {
event.getTarget() instanceof Player && DisguiseAPI.isDisguised(event.getTarget())) { return;
switch (event.getReason()) { }
case TARGET_ATTACKED_ENTITY:
case TARGET_ATTACKED_OWNER: switch (event.getReason()) {
case OWNER_ATTACKED_TARGET: case TARGET_ATTACKED_ENTITY:
case CUSTOM: case TARGET_ATTACKED_OWNER:
break; case OWNER_ATTACKED_TARGET:
default: case CUSTOM:
event.setCancelled(true); return;
break; 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);
} }
} }

View File

@ -54,6 +54,7 @@ public abstract class Disguise {
private boolean modifyBoundingBox = DisguiseConfig.isModifyBoundingBox(); private boolean modifyBoundingBox = DisguiseConfig.isModifyBoundingBox();
private boolean playerHiddenFromTab = DisguiseConfig.isHideDisguisedPlayers(); private boolean playerHiddenFromTab = DisguiseConfig.isHideDisguisedPlayers();
private boolean replaceSounds = DisguiseConfig.isSoundEnabled(); private boolean replaceSounds = DisguiseConfig.isSoundEnabled();
private boolean mobsIgnoreDisguise;
private boolean showName; private boolean showName;
private transient BukkitTask task; private transient BukkitTask task;
private Runnable velocityRunnable; private Runnable velocityRunnable;
@ -864,4 +865,12 @@ public abstract class Disguise {
public boolean stopDisguise() { public boolean stopDisguise() {
return removeDisguise(); return removeDisguise();
} }
public boolean isMobsIgnoreDisguise() {
return mobsIgnoreDisguise;
}
public void setMobsIgnoreDisguise(boolean mobsIgnoreDisguise) {
this.mobsIgnoreDisguise = mobsIgnoreDisguise;
}
} }