mirror of
https://github.com/BentoBoxWorld/BentoBox.git
synced 2024-11-22 02:35:21 +01:00
Merge branch 'develop' of https://github.com/BentoBoxWorld/BentoBox.git into develop
This commit is contained in:
commit
0766f2967d
@ -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;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -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);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user