Add config for default shout state and for persisting shout state

This commit is contained in:
Josh Roy 2021-09-28 20:31:44 -04:00
parent 94edbcfeb1
commit 88c8ccd29b
6 changed files with 50 additions and 2 deletions

View file

@ -46,6 +46,10 @@ public interface ISettings extends IConf {
char getChatQuestion();
boolean isShoutDefault();
boolean isPersistShout();
boolean isChatQuestionEnabled();
BigDecimal getCommandCost(IEssentialsCommand cmd);

View file

@ -226,6 +226,16 @@ public class Settings implements net.ess3.api.ISettings {
return chatQuestion;
}
@Override
public boolean isShoutDefault() {
return config.getBoolean("chat.shout-default", false);
}
@Override
public boolean isPersistShout() {
return config.getBoolean("chat.persist-shout", false);
}
@Override
public boolean isChatQuestionEnabled() {
return config.getBoolean("chat.question-enabled", true);

View file

@ -90,7 +90,7 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
private long lastNotifiedAboutMailsMs;
private String lastHomeConfirmation;
private long lastHomeConfirmationTimestamp;
private boolean toggleShout = false;
private Boolean toggleShout;
private transient final List<String> signCopy = Lists.newArrayList("", "", "", "");
public User(final Player base, final IEssentials ess) {
@ -1202,10 +1202,16 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
@Override
public void setToggleShout(boolean toggleShout) {
this.toggleShout = toggleShout;
if (ess.getSettings().isPersistShout()) {
setShouting(toggleShout);
}
}
@Override
public boolean isToggleShout() {
return toggleShout;
if (ess.getSettings().isPersistShout()) {
return toggleShout = isShouting();
}
return toggleShout == null ? toggleShout = ess.getSettings().isShoutDefault() : toggleShout;
}
}

View file

@ -722,6 +722,18 @@ public abstract class UserData extends PlayerExtension implements IConf {
config.save();
}
public boolean isShouting() {
if (holder.shouting() == null) {
holder.shouting(ess.getSettings().isShoutDefault());
}
return holder.shouting();
}
public void setShouting(boolean shouting) {
holder.shouting(shouting);
config.save();
}
public UUID getConfigUUID() {
return config.getUuid();
}

View file

@ -322,6 +322,16 @@ public class UserConfigHolder {
this.baltopExempt = value;
}
private @MonotonicNonNull Boolean shouting;
public Boolean shouting() {
return shouting;
}
public void shouting(final Boolean value) {
this.shouting = value;
}
private @NonNull Timestamps timestamps = new Timestamps();
public Timestamps timestamps() {

View file

@ -921,6 +921,12 @@ chat:
# plots: "&dP&r"
# creative: "&eC&r"
# Whether players should be placed into shout mode by default.
shout-default: false
# Whether a player's shout mode should persist restarts.
persist-shout: false
# Whether chat questions should be enabled or not.
question-enabled: true