mirror of
https://github.com/libraryaddict/LibsDisguises.git
synced 2024-12-13 15:16:50 +01:00
Fix the way we're listening to user preference on notify bar
This commit is contained in:
parent
7cb24b8dda
commit
e3cf06db0c
@ -221,10 +221,6 @@ public class DisguiseAPI {
|
||||
disguise.setViewSelfDisguise(!disguise.isSelfDisguiseVisible());
|
||||
}
|
||||
|
||||
if (hasActionBarPreference(entity) && !isNotifyBarShown(entity)) {
|
||||
disguise.setNotifyBar(DisguiseConfig.NotifyBar.NONE);
|
||||
}
|
||||
|
||||
disguise.startDisguise(commandSender);
|
||||
}
|
||||
|
||||
@ -519,24 +515,34 @@ public class DisguiseAPI {
|
||||
}
|
||||
|
||||
public static void setActionBarShown(Player player, boolean isShown) {
|
||||
if (isDisguised(player)) {
|
||||
Disguise[] disguises = getDisguises(player);
|
||||
|
||||
for (Disguise disguise : disguises) {
|
||||
disguise.setNotifyBar(isShown ? DisguiseConfig.getNotifyBar() : DisguiseConfig.NotifyBar.NONE);
|
||||
}
|
||||
}
|
||||
boolean toggled = false;
|
||||
|
||||
// If default is view and we want the opposite
|
||||
if (!isShown) {
|
||||
if (!hasActionBarPreference(player)) {
|
||||
toggled = true;
|
||||
DisguiseUtilities.getViewBar().add(player.getUniqueId());
|
||||
DisguiseUtilities.addSaveAttempt();
|
||||
}
|
||||
} else {
|
||||
DisguiseUtilities.getViewBar().remove(player.getUniqueId());
|
||||
toggled = DisguiseUtilities.getViewBar().remove(player.getUniqueId());
|
||||
DisguiseUtilities.addSaveAttempt();
|
||||
}
|
||||
|
||||
if (!toggled || !isDisguised(player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
Disguise[] disguises = getDisguises(player);
|
||||
|
||||
for (Disguise disguise : disguises) {
|
||||
if (disguise.getNotifyBar() != DisguiseConfig.NotifyBar.BOSS_BAR) {
|
||||
continue;
|
||||
}
|
||||
|
||||
disguise.setNotifyBar(DisguiseConfig.NotifyBar.NONE);
|
||||
disguise.setNotifyBar(DisguiseConfig.NotifyBar.BOSS_BAR);
|
||||
}
|
||||
}
|
||||
|
||||
private DisguiseAPI() {
|
||||
|
@ -78,10 +78,6 @@ public class DisguiseCommand extends DisguiseBaseCommand implements TabCompleter
|
||||
}
|
||||
}
|
||||
|
||||
if (!DisguiseAPI.isNotifyBarShown(disguise.getEntity())) {
|
||||
disguise.setNotifyBar(DisguiseConfig.NotifyBar.NONE);
|
||||
}
|
||||
|
||||
if (!sender.isOp() && LibsPremium.isBisectHosted() && !Bukkit.getIp().matches("((25[0-5]|(2[0-4]|1\\d|[1-9]|)\\d)(\\.(?!$)|$)){4}")) {
|
||||
disguise.setExpires(DisguiseConfig.isDynamicExpiry() ? 20 * 60 * 10 : System.currentTimeMillis() + TimeUnit.MINUTES.toMillis(10));
|
||||
}
|
||||
|
@ -113,10 +113,6 @@ public class DisguisePlayerCommand extends DisguiseBaseCommand implements TabCom
|
||||
}
|
||||
}
|
||||
|
||||
if (!DisguiseAPI.isNotifyBarShown(disguise.getEntity())) {
|
||||
disguise.setNotifyBar(DisguiseConfig.NotifyBar.NONE);
|
||||
}
|
||||
|
||||
disguise.startDisguise(sender);
|
||||
|
||||
if (disguise.isDisguiseInUse()) {
|
||||
|
@ -196,10 +196,6 @@ public class DisguiseRadiusCommand extends DisguiseBaseCommand implements TabCom
|
||||
}
|
||||
}
|
||||
|
||||
if (!DisguiseAPI.isNotifyBarShown(disguise.getEntity())) {
|
||||
disguise.setNotifyBar(DisguiseConfig.NotifyBar.NONE);
|
||||
}
|
||||
|
||||
disguise.startDisguise(sender);
|
||||
|
||||
if (disguise.isDisguiseInUse()) {
|
||||
|
@ -369,6 +369,10 @@ public abstract class Disguise {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!DisguiseAPI.isNotifyBarShown(getEntity())) {
|
||||
return;
|
||||
}
|
||||
|
||||
removeBossBar();
|
||||
|
||||
BossBar bar = Bukkit.createBossBar(getBossBar(), BaseComponent.toLegacyText(LibsMsg.ACTION_BAR_MESSAGE.getBase(getDisguiseName())), getBossBarColor(),
|
||||
@ -388,8 +392,8 @@ public abstract class Disguise {
|
||||
}
|
||||
|
||||
protected void doActionBar() {
|
||||
if (getNotifyBar() == DisguiseConfig.NotifyBar.ACTION_BAR && getEntity() instanceof Player && !getEntity().hasPermission("libsdisguises.noactionbar") &&
|
||||
DisguiseAPI.getDisguise(getEntity()) == Disguise.this) {
|
||||
if (getNotifyBar() == DisguiseConfig.NotifyBar.ACTION_BAR && getEntity() instanceof Player && DisguiseAPI.isNotifyBarShown(getEntity()) &&
|
||||
!getEntity().hasPermission("libsdisguises.noactionbar") && DisguiseAPI.getDisguise(getEntity()) == Disguise.this) {
|
||||
((Player) getEntity()).spigot().sendMessage(ChatMessageType.ACTION_BAR, LibsMsg.ACTION_BAR_MESSAGE.getBase(getDisguiseName()));
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user