mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-02 22:16:22 +00:00
Finish up ping options and bug fixes
This commit is contained in:
1 parent
bb2ba72749
commit
41568b1ddf
5 files changed
+70
-21
No files matched your search
+14
-14
@@ -32,13 +32,12 @@ public class PingOptionsCommand {
|
||||
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.senderType(PlayerUser.class) // player
|
||||
.permission("carbonchat.nickname")
|
||||
.permission("carbonchat.pingoptions.channels")
|
||||
.argument(StaticArgument.of("channels"))
|
||||
.argument(EnumArgument.of(Sound.Source.class, "sound"))
|
||||
//.argument(FloatArgument.newBuilder("volume").withMin(0).withMax(1).build()) // this doesn't work idk why
|
||||
.argument(FloatArgument.of("volume"))
|
||||
.argument(FloatArgument.of("pitch"))
|
||||
.handler(this::setChannelOptions)
|
||||
.argument(FloatArgument.<CarbonUser>newBuilder("volume").withMin(0).withMax(1).asRequired().build())
|
||||
.argument(FloatArgument.<CarbonUser>newBuilder("pitch").withMin(0).withMax(1).asRequired().build())
|
||||
.handler(this::channelOptions)
|
||||
.build()
|
||||
);
|
||||
|
||||
@@ -46,29 +45,30 @@ public class PingOptionsCommand {
|
||||
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.senderType(PlayerUser.class) // player
|
||||
.permission("carbonchat.nickname")
|
||||
.permission("carbonchat.pingoptions.whispers")
|
||||
.argument(StaticArgument.of("whispers"))
|
||||
.argument(EnumArgument.of(Sound.Source.class, "sound"))
|
||||
//.argument(FloatArgument.newBuilder("volume").withMin(0).withMax(1).build()) // this doesn't work idk why
|
||||
.argument(FloatArgument.of("volume"))
|
||||
.argument(FloatArgument.of("pitch"))
|
||||
.handler(this::setWhisperOptions)
|
||||
.argument(FloatArgument.<CarbonUser>newBuilder("volume").withMin(0).withMax(1).asRequired().build())
|
||||
.argument(FloatArgument.<CarbonUser>newBuilder("pitch").withMin(0).withMax(1).asRequired().build())
|
||||
.handler(this::whisperOptions)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
private void setChannelOptions(CommandContext<CarbonUser> context) {
|
||||
private void channelOptions(final @NonNull CommandContext<CarbonUser> context) {
|
||||
((PlayerUser) context.getSender()).pingOptions().pingSound(Sound.sound(Key.key(context.get("sound")),
|
||||
Sound.Source.PLAYER, context.get("volume"), context.get("pitch")));
|
||||
|
||||
// TODO: send message "your ping settings were changed!"
|
||||
context.getSender().sendMessage(this.carbonChat.messageProcessor().processMessage(
|
||||
this.carbonChat.translations().channelPingChanged()));
|
||||
}
|
||||
|
||||
private void setWhisperOptions(CommandContext<CarbonUser> context) {
|
||||
private void whisperOptions(final @NonNull CommandContext<CarbonUser> context) {
|
||||
((PlayerUser) context.getSender()).pingOptions().whisperSound(Sound.sound(Key.key(context.get("sound")),
|
||||
Sound.Source.PLAYER, context.get("volume"), context.get("pitch")));
|
||||
|
||||
// TODO: send message "your whisper ping settings were changed!"
|
||||
context.getSender().sendMessage(this.carbonChat.messageProcessor().processMessage(
|
||||
this.carbonChat.translations().whisperPingChanged()));
|
||||
}
|
||||
|
||||
}
|
||||
+30
-2
@@ -254,6 +254,34 @@ public class MySQLUserService<T extends PlayerUser, C extends ConsoleUser> imple
|
||||
}
|
||||
|
||||
final Sound whisperSound = user.pingOptions().whisperSound();
|
||||
final String whisperName;
|
||||
final Float whisperVolume;
|
||||
final Float whisperPitch;
|
||||
|
||||
if (whisperSound != null) {
|
||||
whisperName = whisperSound.name().asString();
|
||||
whisperVolume = whisperSound.volume();
|
||||
whisperPitch = whisperSound.pitch();
|
||||
} else {
|
||||
whisperName = null;
|
||||
whisperVolume = null;
|
||||
whisperPitch = null;
|
||||
}
|
||||
|
||||
final Sound channelSound = user.pingOptions().pingSound();
|
||||
final String channelName;
|
||||
final Float channelVolume;
|
||||
final Float channelPitch;
|
||||
|
||||
if (channelSound != null) {
|
||||
channelName = channelSound.name().asString();
|
||||
channelVolume = channelSound.volume();
|
||||
channelPitch = channelSound.pitch();
|
||||
} else {
|
||||
channelName = null;
|
||||
channelVolume = null;
|
||||
channelPitch = null;
|
||||
}
|
||||
|
||||
this.carbonChat.logger().info("Saving user data!");
|
||||
stm.executeUpdateQuery("INSERT INTO sc_users (uuid, channel, muted, shadowmuted, spyingwhispers, nickname, customchatcolor, whisperpingkey, whisperpingvolume " +
|
||||
@@ -262,9 +290,9 @@ public class MySQLUserService<T extends PlayerUser, C extends ConsoleUser> imple
|
||||
"whisperpingpitch = ?, channelpingkey = ?, channelpingvolume = ?, channelpingpitch = ?",
|
||||
user.uuid().toString(),
|
||||
selectedName, user.muted(), user.shadowMuted(), user.spyingWhispers(), user.nickname(), user.customChatColor(),
|
||||
whisperSound.name().asString(), whisperSound.volume(), whisperSound.pitch(),
|
||||
whisperName, whisperVolume, whisperPitch, channelName, channelVolume, channelPitch,
|
||||
selectedName, user.muted(), user.shadowMuted(), user.spyingWhispers(), user.nickname(), user.customChatColor(),
|
||||
whisperSound.name().asString(), whisperSound.volume(), whisperSound.pitch());
|
||||
whisperName, whisperVolume, whisperPitch, channelName, channelVolume, channelPitch);
|
||||
|
||||
this.carbonChat.logger().info("Saving user channel settings!");
|
||||
// Save user channel settings
|
||||
|
||||
Reference in new issue
Block a user