mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-01 22:15:08 +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
@@ -65,6 +65,8 @@ public final class CarbonTranslations {
|
||||
@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!";
|
||||
@Setting private String whisperPingChanged = "<green>Whisper ping settings changed!";
|
||||
@Setting private String channelPingChanged = "<green>Channel ping settings changed!";
|
||||
|
||||
public ExceptionMessages exceptionMessages() {
|
||||
return this.exceptionMessages;
|
||||
@@ -214,4 +216,12 @@ public final class CarbonTranslations {
|
||||
return this.cannotWhisperSelf;
|
||||
}
|
||||
|
||||
public String channelPingChanged() {
|
||||
return this.channelPingChanged;
|
||||
}
|
||||
|
||||
public String whisperPingChanged() {
|
||||
return this.whisperPingChanged;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -137,11 +137,11 @@ public interface PlayerUser extends CarbonUser {
|
||||
|
||||
void pingOptions(@NonNull PingOptions pingOptions);
|
||||
|
||||
public static class PingOptions {
|
||||
class PingOptions {
|
||||
public @Nullable Sound whisperSound;
|
||||
public @Nullable Sound pingSound;
|
||||
|
||||
public PingOptions(@Nullable Sound whisperSound, @Nullable Sound pingSound) {
|
||||
public PingOptions(final @Nullable Sound whisperSound, final @Nullable Sound pingSound) {
|
||||
this.whisperSound = whisperSound;
|
||||
this.pingSound = pingSound;
|
||||
}
|
||||
@@ -150,7 +150,7 @@ public interface PlayerUser extends CarbonUser {
|
||||
return this.whisperSound;
|
||||
}
|
||||
|
||||
public void whisperSound(@Nullable Sound whisperSound) {
|
||||
public void whisperSound(final @Nullable Sound whisperSound) {
|
||||
this.whisperSound = whisperSound;
|
||||
}
|
||||
|
||||
@@ -158,7 +158,7 @@ public interface PlayerUser extends CarbonUser {
|
||||
return this.pingSound;
|
||||
}
|
||||
|
||||
public void pingSound(@Nullable Sound pingSound) {
|
||||
public void pingSound(final @Nullable Sound pingSound) {
|
||||
this.pingSound = pingSound;
|
||||
}
|
||||
}
|
||||
|
||||
+12
-1
@@ -48,13 +48,14 @@ public class BukkitPlayerUser implements PlayerUser, ForwardingAudience.Single {
|
||||
private @Nullable String nickname = null;
|
||||
private @Nullable UUID replyTarget = null;
|
||||
private @Nullable TextColor customChatColor = null;
|
||||
private @NonNull PingOptions pingOptions = new PingOptions(null, null);
|
||||
|
||||
private @Nullable String selectedChannelKey = null;
|
||||
private transient @Nullable ChatChannel selectedChannel = null;
|
||||
|
||||
private transient @NonNull Audience audience;
|
||||
|
||||
@SuppressWarnings("initialization.fields.uninitialized")
|
||||
@SuppressWarnings({"initialization.fields.uninitialized", "method.invocation.invalid"})
|
||||
public BukkitPlayerUser() {
|
||||
final CarbonChatBukkit carbonChatBukkit =
|
||||
(CarbonChatBukkit) Bukkit.getPluginManager().getPlugin("CarbonChat");
|
||||
@@ -97,6 +98,16 @@ public class BukkitPlayerUser implements PlayerUser, ForwardingAudience.Single {
|
||||
return PlaceholderAPI.setPlaceholders(player, input);
|
||||
}
|
||||
|
||||
@Override
|
||||
public @NonNull PingOptions pingOptions() {
|
||||
return this.pingOptions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void pingOptions(final @NonNull PingOptions pingOptions) {
|
||||
this.pingOptions = pingOptions;
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean online() {
|
||||
return Bukkit.getPlayer(this.uuid()) != null;
|
||||
|
||||
+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