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(); char getChatQuestion();
boolean isShoutDefault();
boolean isPersistShout();
boolean isChatQuestionEnabled(); boolean isChatQuestionEnabled();
BigDecimal getCommandCost(IEssentialsCommand cmd); BigDecimal getCommandCost(IEssentialsCommand cmd);

View File

@ -226,6 +226,16 @@ public class Settings implements net.ess3.api.ISettings {
return chatQuestion; 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 @Override
public boolean isChatQuestionEnabled() { public boolean isChatQuestionEnabled() {
return config.getBoolean("chat.question-enabled", true); 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 long lastNotifiedAboutMailsMs;
private String lastHomeConfirmation; private String lastHomeConfirmation;
private long lastHomeConfirmationTimestamp; private long lastHomeConfirmationTimestamp;
private boolean toggleShout = false; private Boolean toggleShout;
private transient final List<String> signCopy = Lists.newArrayList("", "", "", ""); private transient final List<String> signCopy = Lists.newArrayList("", "", "", "");
public User(final Player base, final IEssentials ess) { public User(final Player base, final IEssentials ess) {
@ -1202,10 +1202,16 @@ public class User extends UserData implements Comparable<User>, IMessageRecipien
@Override @Override
public void setToggleShout(boolean toggleShout) { public void setToggleShout(boolean toggleShout) {
this.toggleShout = toggleShout; this.toggleShout = toggleShout;
if (ess.getSettings().isPersistShout()) {
setShouting(toggleShout);
}
} }
@Override @Override
public boolean isToggleShout() { 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(); 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() { public UUID getConfigUUID() {
return config.getUuid(); return config.getUuid();
} }

View File

@ -322,6 +322,16 @@ public class UserConfigHolder {
this.baltopExempt = value; 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(); private @NonNull Timestamps timestamps = new Timestamps();
public Timestamps timestamps() { public Timestamps timestamps() {

View File

@ -921,6 +921,12 @@ chat:
# plots: "&dP&r" # plots: "&dP&r"
# creative: "&eC&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. # Whether chat questions should be enabled or not.
question-enabled: true question-enabled: true