Add channel whisper functionality (#91)

* ChatChannel -> TextChannel, WhisperChannel, GroupChannel

* Add basic whisper channel support

* Move WhisperPings into WhisperOptions

* Add defaults to WhisperOptions

* Various deprecation and refactor fixes

* Test and fux bugs
This commit is contained in:
Josh (Vicarious) authored and GitHub committed 2020-10-02 02:23:25 -07:00
1 parent 14dfcfbf38
commit f9cac355b6
44 files changed
+797 -304

No files matched your search

@@ -74,8 +74,8 @@ public class CarbonSettings {
@Setting(comment = "Plays a sound and highlights the message when someone types your name")
private @NonNull ChannelPings channelPings = new ChannelPings();
@Setting(comment = "Plays a sound when receiving private messages with /whisper /msg")
private @NonNull WhisperPings whisperPings = new WhisperPings();
@Setting(comment = "")
private @NonNull WhisperOptions whisperOptions = new WhisperOptions();
@Setting(comment = "Sets the player's channel to the specified channel when they join" +
"\nSet to \"\" or remove to disable" +
@@ -132,8 +132,8 @@ public class CarbonSettings {
return this.channelPings;
}
public @NonNull WhisperPings whisperPings() {
return this.whisperPings;
public @NonNull WhisperOptions whisperOptions() {
return this.whisperOptions;
}
}
@@ -0,0 +1,206 @@
package net.draycia.carbon.api.config;
import org.spongepowered.configurate.CommentedConfigurationNode;
import org.spongepowered.configurate.objectmapping.ObjectMapper;
import org.spongepowered.configurate.objectmapping.ObjectMappingException;
import org.spongepowered.configurate.objectmapping.Setting;
import org.spongepowered.configurate.serialize.ConfigSerializable;
@ConfigSerializable
public class CarbonTranslations {
private static final ObjectMapper<CarbonTranslations> MAPPER;
static {
try {
MAPPER = ObjectMapper.forClass(CarbonTranslations.class); // We hold on to the instance of our ObjectMapper
} catch (final ObjectMappingException e) {
throw new ExceptionInInitializerError(e);
}
}
public static CarbonTranslations loadFrom(final CommentedConfigurationNode node) throws ObjectMappingException {
return MAPPER.bindToNew().populate(node);
}
public void saveTo(final CommentedConfigurationNode node) throws ObjectMappingException {
MAPPER.bind(this).serialize(node);
}
@Setting private String reloaded = "<yellow>Chat config has been reloaded!";
@Setting private String otherPlayerOffline = "<red>That player is offline!";
@Setting private String spyWhispers = "<yellow>Spy [<gray><sender><reset> <gold>-> <gray><target><reset><yellow>] <message>";
@Setting private String noReplyTarget = "<red>You have no one to reply to!";
@Setting private String otherNicknameSet = "<green><user><reset>''s nickname was set to <nickname><green>!";
@Setting private String otherNicknameReset = "<green><user><reset>'s nickname was reset!";
@Setting private String availableChannelsList = "<green>Available Channels:<reset> <list>.";
@Setting private String unavailableChannelsList = "<red>Unavailable Channels:<reset> <list>.";
@Setting private String channelListSeparator = ", ";
@Setting private String userMustBeOnline = "<red><player> must be online!";
@Setting private String replyMessageBlank = "<red>Your reply message was blank!";
@Setting private String invalidColor = "<red>The input <input> is not a valid color!";
@Setting private String cannotSetColor = "<red>You do not have permission to set a color for this channel!";
@Setting private String roleplayFormat = "<italic><dark_purple>*<displayname> <reset><message>*</dark_purple></italic>";
@Setting private String ignoringUser = "<green>You are now ignoring <gold><player><reset><green>!";
@Setting private String notIgnoringUser = "<green>You are no longer ignoring <gold><player><reset><green>!";
@Setting private String ignoreExempt = "<red>User <player> <red>is exempt from being ignored!";
@Setting private String channelColorSet = "<green>You have set <color><channel> <green>color to <hex>!";
@Setting private String spyToggledOn = "<gray>You are now spying on <color><channel> <gray>chat!";
@Setting private String spyToggledOff = "<gray>You are no longer spying on <color><channel> <gray>chat!";
@Setting private String spyWhispersOn = "<gray>You are now spying on whispers!";
@Setting private String spyWhispersOff = "<gray>You are no longer spying on whispers!";
@Setting private String spyEverythingOn = "<gray>All spying toggled on!";
@Setting private String spyEverythingOff = "<gray>All spying toggled off!";
@Setting private String nicknameSet = "<green>Your nickname was set to <nickname><reset><green>!";
@Setting private String nicknameReset = "<green>Your nickname was reset!";
@Setting private String nowShadowMuted = "<yellow>Player <player> is now shadow muted!";
@Setting private String noLongerShadowMuted = "<yellow>Player <player> is no longer shadow muted!";
@Setting private String shadowMuteExempt = "<red>Player <player> is exempt from being shadow muted!";
@Setting private String nowMuted = "<yellow>Player <player> is now muted!";
@Setting private String noLongerMuted = "<yellow>Player <player> is no longer muted!";
@Setting private String muteExempt = "<red>Player <player> is exempt from being muted!";
@Setting private String clearNotify = "<yellow>Chat has been cleared by <player>.";
@Setting private String clearExempt = "<yellow>You were exempt from the clear due to your permissions!";
@Setting private String cannotWhisperSelf = "<yellow>You cannot whisper yourself!";
public String reloaded() {
return this.reloaded;
}
public String otherPlayerOffline() {
return this.otherPlayerOffline;
}
public String spyWhispers() {
return this.spyWhispers;
}
public String noReplyTarget() {
return this.noReplyTarget;
}
public String otherNicknameSet() {
return this.otherNicknameSet;
}
public String otherNicknameReset() {
return this.otherNicknameReset;
}
public String availableChannelsList() {
return this.availableChannelsList;
}
public String unavailableChannelsList() {
return this.unavailableChannelsList;
}
public String channelListSeparator() {
return this.channelListSeparator;
}
public String userMustBeOnline() {
return this.userMustBeOnline;
}
public String replyMessageBlank() {
return this.replyMessageBlank;
}
public String invalidColor() {
return this.invalidColor;
}
public String cannotSetColor() {
return this.cannotSetColor;
}
public String roleplayFormat() {
return this.roleplayFormat;
}
public String ignoringUser() {
return this.ignoringUser;
}
public String notIgnoringUser() {
return this.notIgnoringUser;
}
public String ignoreExempt() {
return this.ignoreExempt;
}
public String channelColorSet() {
return this.channelColorSet;
}
public String spyToggledOn() {
return this.spyToggledOn;
}
public String spyToggledOff() {
return this.spyToggledOff;
}
public String spyWhispersOn() {
return this.spyWhispersOn;
}
public String spyWhispersOff() {
return this.spyWhispersOff;
}
public String spyEverythingOn() {
return this.spyEverythingOn;
}
public String spyEverythingOff() {
return this.spyEverythingOff;
}
public String nicknameSet() {
return this.nicknameSet;
}
public String nicknameReset() {
return this.nicknameReset;
}
public String nowShadowMuted() {
return this.nowShadowMuted;
}
public String noLongerShadowMuted() {
return this.noLongerShadowMuted;
}
public String shadowMuteExempt() {
return this.shadowMuteExempt;
}
public String nowMuted() {
return this.nowMuted;
}
public String noLongerMuted() {
return this.noLongerMuted;
}
public String muteExempt() {
return this.muteExempt;
}
public String clearNotify() {
return this.clearNotify;
}
public String clearExempt() {
return this.clearExempt;
}
public String cannotWhisperSelf() {
return this.cannotWhisperSelf;
}
}
@@ -103,6 +103,8 @@ public class ChannelOptions {
settings.key = "global";
settings.isDefault = true;
settings.name = "Global";
settings.color = "#FFFFFF";
settings.defaultFormatName = "default";
settings.formats = Collections.singletonMap("default", "<color><<displayname><reset><color>> <message>");
return settings;
@@ -12,7 +12,7 @@ public final class ChannelPings {
@Setting private @NonNull String prefix = "";
@Setting private boolean caseSensitive = false;
@Setting private @NonNull Key sound =
Key.of(Key.MINECRAFT_NAMESPACE, "entity.experience_orb.pickup");
Key.key(Key.MINECRAFT_NAMESPACE, "entity.experience_orb.pickup");
@Setting private Sound.Source source = Sound.Source.PLAYER;
@Setting private float volume = 10.0F;
@Setting private float pitch = 1.0F;
@@ -30,7 +30,8 @@ public class ChannelSettings {
MAPPER.bind(this).serialize(node);
}
@Setting(comment = "All options here act like the defaults for all channels.\nAdding any of these options to any channel overrides the relevant defaults.")
@Setting(comment = "All options here act like the defaults for all channels.\n" +
"Adding any of these options to any channel overrides the relevant defaults.")
private SharedChannelOptions sharedChannelOptions = new SharedChannelOptions();
@Setting
@@ -0,0 +1,121 @@
package net.draycia.carbon.api.config;
import org.checkerframework.checker.nullness.qual.NonNull;
import org.checkerframework.checker.nullness.qual.Nullable;
import org.spongepowered.configurate.objectmapping.Setting;
import org.spongepowered.configurate.serialize.ConfigSerializable;
@ConfigSerializable
public class WhisperOptions {
@Setting(comment = "Plays a sound when receiving private messages with /whisper /msg")
private @NonNull WhisperPings pings = new WhisperPings();
@Setting(comment = "")
private String switchMessage = "<gray>You are now in <color><channel> <gray>chat!";
@Setting(comment = "")
private String switchOtherMessage = "<gray><player> <reset><gray>is now in <color><channel> <gray>chat!";
@Setting(comment = "")
private String switchFailureMessage = "<red>You cannot use channel <channel>!";
@Setting(comment = "")
private String toggleOnMessage = "<gray>You can now see <color><channel> <gray>chat!";
@Setting(comment = "")
private String toggleOffMessage = "<gray>You can no longer see <color><channel> <gray>chat!";
@Setting(comment = "")
private String toggleOtherOnMessage = "<gray><player> <reset><gray>can now see <color><channel> <gray>chat!";
@Setting(comment = "")
private String toggleOtherOffMessage = "<gray><player> <reset><gray>can no longer see <color><channel> <gray>chat!";
@Setting(comment = "")
private String cannotUseMessage = "You cannot use that channel!";
@Setting(comment = "")
private String cannotIgnoreMessage = "<red>You cannot ignore that channel!";
@Setting(comment = "")
private String senderFormat = "<gold>[<white>Me <gray>-> <white><receiver><gold>] <message>";
@Setting(comment = "")
private String receiverFormat = "<gold>[<white><sender> <gray>-> <white>Me<gold>] <message>";
@Setting(comment = "")
private String consoleFormat = "<gold>[<white><sender> <gray>-> <white><receiver><gold>] <message>";
@Setting(comment = "")
private boolean logToConsole = true;
public boolean logToConsole() {
return this.logToConsole;
}
public @NonNull WhisperPings pings() {
return this.pings;
}
@Nullable
public String consoleFormat() {
return this.consoleFormat;
}
@Nullable
public String senderFormat() {
return this.senderFormat;
}
@Nullable
public String receiverFormat() {
return this.receiverFormat;
}
@Nullable
public String switchMessage() {
return this.switchMessage;
}
@Nullable
public String switchOtherMessage() {
return this.switchOtherMessage;
}
@Nullable
public String switchFailureMessage() {
return this.switchFailureMessage;
}
@Nullable
public String cannotIgnoreMessage() {
return this.cannotIgnoreMessage;
}
@Nullable
public String toggleOffMessage() {
return this.toggleOffMessage;
}
@Nullable
public String toggleOnMessage() {
return this.toggleOnMessage;
}
@Nullable
public String toggleOtherOnMessage() {
return this.toggleOtherOnMessage;
}
@Nullable
public String toggleOtherOffMessage() {
return this.toggleOtherOffMessage;
}
@Nullable
public String cannotUseMessage() {
return this.cannotUseMessage;
}
}
@@ -8,29 +8,22 @@ import org.spongepowered.configurate.serialize.ConfigSerializable;
@ConfigSerializable
public final class WhisperPings {
@Setting private boolean enabled = true;
@Setting private @NonNull Key sound = Key.of(Key.MINECRAFT_NAMESPACE, "entity.experience_orb.pickup");
@Setting private Sound.Source source = Sound.Source.PLAYER;
@Setting private float volume = 10.0F;
@Setting private float pitch = 1.0F;
@Setting private @NonNull Sound sound = Sound.sound(
Key.key(Key.MINECRAFT_NAMESPACE, "entity.experience_orb.pickup"),
Sound.Source.PLAYER,
10.0F,
1.0F
);
public boolean enabled() {
return this.enabled;
}
public Key sound() {
public Sound sound() {
return this.sound;
}
public Sound.Source source() {
return this.source;
}
public float volume() {
return this.volume;
}
public float pitch() {
return this.pitch;
}
}