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
+22

No files matched your search

@@ -12,6 +12,11 @@ public final class WhisperOptions {
@Comment("Plays a sound when receiving private messages with /whisper /msg") @Comment("Plays a sound when receiving private messages with /whisper /msg")
private @NonNull WhisperPings pings = new WhisperPings(); 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 @Setting
@Comment("") @Comment("")
private @NonNull String switchMessage = "<gray>You are now in <color><channel> <gray>chat!"; private @NonNull String switchMessage = "<gray>You are now in <color><channel> <gray>chat!";
@@ -84,6 +89,10 @@ public final class WhisperOptions {
return this.pings; return this.pings;
} }
public boolean useEnhancedWhispers() {
return this.useEnhancedWhispers;
}
public @NonNull String consoleFormat() { public @NonNull String consoleFormat() {
return this.consoleFormat; return this.consoleFormat;
} }
@@ -32,6 +32,7 @@ public class MessageCommand {
return; return;
} }
if (this.carbonChat.carbonSettings().whisperOptions().useEnhancedWhispers()) {
commandManager.command( commandManager.command(
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(), commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
commandManager.createDefaultCommandMeta()) commandManager.createDefaultCommandMeta())
@@ -42,6 +43,18 @@ public class MessageCommand {
.handler(this::sendMessage) .handler(this::sendMessage)
.build() .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) { private void sendMessage(final @NonNull CommandContext<CarbonUser> context) {