mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-02 22:16:22 +00:00
Add channel defaults handling
This commit is contained in:
1 parent
6c9810ea72
commit
50e359a51f
4 files changed
+137
-49
No files matched your search
@@ -108,7 +108,7 @@ public class CarbonSettings {
|
||||
return this.showTips;
|
||||
}
|
||||
|
||||
public @NonNull List<@NonNull ChannelOptions> channelSettings() {
|
||||
public @NonNull List<@NonNull ChannelOptions> channelOptions() {
|
||||
return this.channelSettings;
|
||||
}
|
||||
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
package net.draycia.carbon.api.config;
|
||||
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.Context;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
import org.checkerframework.checker.nullness.qual.Nullable;
|
||||
@@ -20,17 +21,17 @@ public class ChannelOptions {
|
||||
@Setting private Map<String, Context> contexts = new HashMap<>(); // TODO: set defaults
|
||||
@Setting private Map<String, String> formats = new HashMap<>(); // TODO: set defaults
|
||||
@Setting private String defaultFormatName = "default";
|
||||
@Setting private boolean isDefault = false;
|
||||
@Setting private boolean ignorable = true;
|
||||
@Setting private boolean crossServer = true;
|
||||
@Setting private boolean honorsRecipientList = false;
|
||||
@Setting private boolean permissionGroupMatching = false;
|
||||
@Setting private boolean isDefault = false; // primitive because missing = false
|
||||
@Setting private Boolean ignorable = true; // boxed because missing = use defaults
|
||||
@Setting private Boolean crossServer = true;
|
||||
@Setting private Boolean honorsRecipientList = false;
|
||||
@Setting private Boolean permissionGroupMatching = false;
|
||||
@Setting private List<String> groupOverrides = new ArrayList<>();
|
||||
@Setting private String name = "";
|
||||
@Setting private String messagePrefix = "";
|
||||
@Setting private List<String> aliases = new ArrayList<>();
|
||||
@Setting private boolean shouldCancelChatEvent = false;
|
||||
@Setting private boolean primaryGroupOnly = false;
|
||||
@Setting private Boolean shouldCancelChatEvent = false;
|
||||
@Setting private Boolean primaryGroupOnly = false;
|
||||
@Setting private String switchMessage = "<gray>You are now in <color><channel> <gray>chat!";
|
||||
@Setting private String switchOtherMessage = "<gray><player> <reset><gray>is now in <color><channel> <gray>chat!";
|
||||
@Setting private String switchFailureMessage = "<red>You cannot use channel <channel>!";
|
||||
@@ -41,6 +42,9 @@ public class ChannelOptions {
|
||||
@Setting private String cannotUseMessage = "You cannot use that channel!";
|
||||
@Setting private String cannotIgnoreMessage = "<red>You cannot ignore that channel!";
|
||||
|
||||
private final SharedChannelOptions defaultOptions =
|
||||
CarbonChatProvider.carbonChat().channelSettings().defaultChannelOptions();
|
||||
|
||||
public static ChannelOptions defaultChannel() {
|
||||
final ChannelOptions settings = new ChannelOptions();
|
||||
settings.key = "global";
|
||||
@@ -58,21 +62,41 @@ public class ChannelOptions {
|
||||
|
||||
@Nullable
|
||||
public String color() {
|
||||
if (this.color == null) {
|
||||
return this.defaultOptions.color();
|
||||
}
|
||||
|
||||
return this.color;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Map<String, Context> contexts() {
|
||||
// TODO: properly implement default context inheritence
|
||||
// TODO: perhaps add an option to make it so overriding any context overrides all?
|
||||
if (this.contexts == null) {
|
||||
return this.defaultOptions.contexts();
|
||||
}
|
||||
|
||||
return this.contexts;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public Map<String, String> formats() {
|
||||
// TODO: properly implement default format inheritence
|
||||
// TODO: perhaps add an option to make it so overriding any format overrides all?
|
||||
if (this.formats == null) {
|
||||
return this.defaultOptions.formats();
|
||||
}
|
||||
|
||||
return this.formats;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String defaultFormatName() {
|
||||
if (this.defaultFormatName == null || this.defaultFormatName.isEmpty()) {
|
||||
return this.defaultOptions.defaultFormatName();
|
||||
}
|
||||
|
||||
return this.defaultFormatName;
|
||||
}
|
||||
|
||||
@@ -80,24 +104,44 @@ public class ChannelOptions {
|
||||
return this.isDefault;
|
||||
}
|
||||
|
||||
public boolean ignorable() {
|
||||
public Boolean ignorable() {
|
||||
if (this.ignorable == null) {
|
||||
return this.defaultOptions.ignorable();
|
||||
}
|
||||
|
||||
return this.ignorable;
|
||||
}
|
||||
|
||||
public boolean crossServer() {
|
||||
public Boolean crossServer() {
|
||||
if (this.crossServer == null) {
|
||||
return this.defaultOptions.crossServer();
|
||||
}
|
||||
|
||||
return this.crossServer;
|
||||
}
|
||||
|
||||
public boolean honorsRecipientList() {
|
||||
public Boolean honorsRecipientList() {
|
||||
if (this.honorsRecipientList == null) {
|
||||
return this.defaultOptions.honorsRecipientList();
|
||||
}
|
||||
|
||||
return this.honorsRecipientList;
|
||||
}
|
||||
|
||||
public boolean permissionGroupMatching() {
|
||||
public Boolean permissionGroupMatching() {
|
||||
if (this.permissionGroupMatching == null) {
|
||||
return this.defaultOptions.permissionGroupMatching();
|
||||
}
|
||||
|
||||
return this.permissionGroupMatching;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public List<@NonNull String> groupOverrides() {
|
||||
if (this.groupOverrides == null) {
|
||||
return this.defaultOptions.groupOverrides();
|
||||
}
|
||||
|
||||
return this.groupOverrides;
|
||||
}
|
||||
|
||||
@@ -117,54 +161,98 @@ public class ChannelOptions {
|
||||
|
||||
@Nullable
|
||||
public String switchMessage() {
|
||||
if (this.switchMessage == null) {
|
||||
return this.defaultOptions.switchMessage();
|
||||
}
|
||||
|
||||
return this.switchMessage;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String switchOtherMessage() {
|
||||
if (this.switchOtherMessage == null) {
|
||||
return this.defaultOptions.switchOtherMessage();
|
||||
}
|
||||
|
||||
return this.switchOtherMessage;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String switchFailureMessage() {
|
||||
if (this.switchFailureMessage == null) {
|
||||
return this.defaultOptions.switchFailureMessage();
|
||||
}
|
||||
|
||||
return this.switchFailureMessage;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String cannotIgnoreMessage() {
|
||||
if (this.cannotIgnoreMessage == null) {
|
||||
return this.defaultOptions.cannotIgnoreMessage();
|
||||
}
|
||||
|
||||
return this.cannotIgnoreMessage;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String toggleOffMessage() {
|
||||
if (this.toggleOffMessage == null) {
|
||||
return this.defaultOptions.toggleOffMessage();
|
||||
}
|
||||
|
||||
return this.toggleOffMessage;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String toggleOnMessage() {
|
||||
if (this.toggleOnMessage == null) {
|
||||
return this.defaultOptions.toggleOnMessage();
|
||||
}
|
||||
|
||||
return this.toggleOnMessage;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String toggleOtherOnMessage() {
|
||||
if (this.toggleOtherOnMessage == null) {
|
||||
return this.defaultOptions.toggleOtherOnMessage();
|
||||
}
|
||||
|
||||
return this.toggleOtherOnMessage;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String toggleOtherOffMessage() {
|
||||
if (this.toggleOtherOffMessage == null) {
|
||||
return this.defaultOptions.toggleOtherOffMessage();
|
||||
}
|
||||
|
||||
return this.toggleOtherOffMessage;
|
||||
}
|
||||
|
||||
@Nullable
|
||||
public String cannotUseMessage() {
|
||||
if (this.cannotUseMessage == null) {
|
||||
return this.defaultOptions.cannotUseMessage();
|
||||
}
|
||||
|
||||
return this.cannotUseMessage;
|
||||
}
|
||||
|
||||
public boolean primaryGroupOnly() {
|
||||
public Boolean primaryGroupOnly() {
|
||||
if (this.primaryGroupOnly == null) {
|
||||
return this.defaultOptions.primaryGroupOnly();
|
||||
}
|
||||
|
||||
return this.primaryGroupOnly;
|
||||
}
|
||||
|
||||
public boolean shouldCancelChatEvent() {
|
||||
public Boolean shouldCancelChatEvent() {
|
||||
if (this.shouldCancelChatEvent == null) {
|
||||
return this.defaultOptions.shouldCancelChatEvent();
|
||||
}
|
||||
|
||||
return this.shouldCancelChatEvent;
|
||||
}
|
||||
|
||||
|
||||
Reference in new issue
Block a user