Add option to enable enhanced whisper functionality, disabled by default

This commit is contained in:
Draycia committed 2021-01-20 17:44:18 -08:00
1 parent 564a3baede
commit 0a52817f1a
2 files changed
+32 -10

No files matched your search

@@ -12,6 +12,11 @@ public final class WhisperOptions {
@Comment("Plays a sound when receiving private messages with /whisper /msg")
private @NonNull WhisperPings pings = new WhisperPings();
@Setting
@Comment("If enabled, players will be able to whisper other players as if they had their own private channel, " +
"without the need to type /r or /msg each message. /msg [player]")
private boolean useEnhancedWhispers = false;
@Setting
@Comment("")
private @NonNull String switchMessage = "<gray>You are now in <color><channel> <gray>chat!";
@@ -84,6 +89,10 @@ public final class WhisperOptions {
return this.pings;
}
public boolean useEnhancedWhispers() {
return this.useEnhancedWhispers;
}
public @NonNull String consoleFormat() {
return this.consoleFormat;
}
@@ -32,16 +32,29 @@ public class MessageCommand {
return;
}
commandManager.command(
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
commandManager.createDefaultCommandMeta())
.senderType(PlayerUser.class) // player
.permission("carbonchat.message")
.argument(PlayerUserArgument.requiredPlayerUserArgument(commandSettings.name()))
.argument(StringArgument.<CarbonUser>newBuilder("message").greedy().asOptional().build())
.handler(this::sendMessage)
.build()
);
if (this.carbonChat.carbonSettings().whisperOptions().useEnhancedWhispers()) {
commandManager.command(
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
commandManager.createDefaultCommandMeta())
.senderType(PlayerUser.class) // player
.permission("carbonchat.message")
.argument(PlayerUserArgument.requiredPlayerUserArgument(commandSettings.name()))
.argument(StringArgument.<CarbonUser>newBuilder("message").greedy().asOptional().build())
.handler(this::sendMessage)
.build()
);
} else {
commandManager.command(
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
commandManager.createDefaultCommandMeta())
.senderType(PlayerUser.class) // player
.permission("carbonchat.message")
.argument(PlayerUserArgument.requiredPlayerUserArgument(commandSettings.name()))
.argument(StringArgument.<CarbonUser>newBuilder("message").greedy().asRequired().build())
.handler(this::sendMessage)
.build()
);
}
}
private void sendMessage(final @NonNull CommandContext<CarbonUser> context) {