Merge branch 'develop' of https://github.com/BentoBoxWorld/BentoBox.git into develop

This commit is contained in:
tastybento 2024-08-02 07:45:46 -07:00
commit 0766f2967d
2 changed files with 30 additions and 10 deletions

View File

@ -151,6 +151,8 @@ public class Flag implements Comparable<Flag> {
private final Mode mode;
private final Set<Flag> subflags;
private final HideWhen hideWhen;
private boolean isSubFlag;
private Flag parentFlag;
private Flag(Builder builder) {
this.id = builder.id;
@ -169,6 +171,8 @@ public class Flag implements Comparable<Flag> {
this.mode = builder.mode;
this.subflags = builder.subflags;
this.hideWhen = builder.hideWhen;
this.isSubFlag = false;
this.parentFlag = null;
}
public String getID() {
@ -305,6 +309,20 @@ public class Flag implements Comparable<Flag> {
return hideWhen;
}
/**
* @return the isSubFlag
*/
public boolean isSubFlag() {
return isSubFlag;
}
/**
* @return the parentFlag
*/
public Flag getParentFlag() {
return parentFlag;
}
/* (non-Javadoc)
* @see java.lang.Object#hashCode()
*/
@ -711,6 +729,9 @@ public class Flag implements Comparable<Flag> {
*/
public Builder subflags(Flag... flags) {
this.subflags.addAll(Arrays.asList(flags));
for (Flag flag : flags) {
flag.isSubFlag = true;
}
return this;
}
@ -739,9 +760,9 @@ public class Flag implements Comparable<Flag> {
default -> new CycleClick(id);
};
}
return new Flag(this);
Flag flag = new Flag(this);
subflags.forEach(subflag -> subflag.parentFlag = flag);
return flag;
}
}
}

View File

@ -136,15 +136,14 @@ public class SettingsTab implements Tab, ClickHandler {
}
// Remove any sub-flags that shouldn't be shown
Set<Flag> toBeRemoved = new HashSet<>();
flags.stream().forEach(flag -> {
if ((flag.getType() == Type.SETTING || flag.getType() == Type.WORLD_SETTING) && flag.hasSubflags()) {
if (flag.isSetForWorld(world) && flag.getHideWhen() == HideWhen.SETTING_TRUE) {
toBeRemoved.addAll(flag.getSubflags());
} else if (!flag.isSetForWorld(world) && flag.getHideWhen() == HideWhen.SETTING_FALSE) {
toBeRemoved.addAll(flag.getSubflags());
flags.forEach(flag -> {
if (flag.isSubFlag() && flag.getHideWhen() != HideWhen.NEVER) {
if (!flag.getParentFlag().isSetForWorld(world) && flag.getHideWhen() == HideWhen.SETTING_FALSE) {
toBeRemoved.add(flag);
} else if (flag.getParentFlag().isSetForWorld(world) && flag.getHideWhen() == HideWhen.SETTING_TRUE) {
toBeRemoved.add(flag);
}
}
});
flags.removeAll(toBeRemoved);