mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-02 06:28:54 +00:00
Add ping and whisper ping options
This commit is contained in:
1 parent
75b6def2d4
commit
7a97d6530a
8 files changed
+129
-4
No files matched your search
@@ -20,7 +20,7 @@ dependencies {
|
||||
compile 'net.kyori:event-api:3.0.0'
|
||||
compile 'net.kyori:registry:1.0.0-SNAPSHOT'
|
||||
|
||||
api 'cloud.commandframework:cloud-core:1.0.1'
|
||||
api 'cloud.commandframework:cloud-core:1.1.0'
|
||||
|
||||
api 'org.spongepowered:configurate-hocon:4.0.0-SNAPSHOT'
|
||||
api 'org.slf4j:slf4j-api:1.7.25'
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
package net.draycia.carbon.api.users;
|
||||
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
import net.kyori.adventure.text.format.TextColor;
|
||||
import net.luckperms.api.model.group.Group;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
@@ -132,4 +133,32 @@ public interface PlayerUser extends CarbonUser {
|
||||
|
||||
void clearSelectedChannel();
|
||||
|
||||
@NonNull PingOptions pingOptions();
|
||||
|
||||
public static class PingOptions {
|
||||
public @Nullable Sound whisperSound;
|
||||
public @Nullable Sound pingSound;
|
||||
|
||||
public PingOptions(@Nullable Sound whisperSound, @Nullable Sound pingSound) {
|
||||
this.whisperSound = whisperSound;
|
||||
this.pingSound = pingSound;
|
||||
}
|
||||
|
||||
public @Nullable Sound whisperSound() {
|
||||
return this.whisperSound;
|
||||
}
|
||||
|
||||
public void whisperSound(@Nullable Sound whisperSound) {
|
||||
this.whisperSound = whisperSound;
|
||||
}
|
||||
|
||||
public @Nullable Sound pingSound() {
|
||||
return this.pingSound;
|
||||
}
|
||||
|
||||
public void pingSound(@Nullable Sound pingSound) {
|
||||
this.pingSound = pingSound;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -16,7 +16,7 @@ dependencies {
|
||||
compile 'io.github.leonardosnt:bungeechannelapi:1.0.0-SNAPSHOT'
|
||||
|
||||
// Commands
|
||||
compile "cloud.commandframework:cloud-paper:1.0.1"
|
||||
compile "cloud.commandframework:cloud-paper:1.1.0"
|
||||
|
||||
// Plugins
|
||||
compileOnly('com.gmail.nossr50.mcMMO:mcMMO:2.1.143') {
|
||||
|
||||
+74
@@ -0,0 +1,74 @@
|
||||
package net.draycia.carbon.common.commands;
|
||||
|
||||
import cloud.commandframework.CommandManager;
|
||||
import cloud.commandframework.arguments.StaticArgument;
|
||||
import cloud.commandframework.arguments.standard.EnumArgument;
|
||||
import cloud.commandframework.arguments.standard.FloatArgument;
|
||||
import cloud.commandframework.context.CommandContext;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.commands.settings.CommandSettings;
|
||||
import net.draycia.carbon.api.users.CarbonUser;
|
||||
import net.draycia.carbon.api.users.PlayerUser;
|
||||
import net.kyori.adventure.key.Key;
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class PingOptionsCommand {
|
||||
|
||||
private final @NonNull CarbonChat carbonChat;
|
||||
|
||||
@SuppressWarnings("methodref.receiver.bound.invalid")
|
||||
public PingOptionsCommand(final @NonNull CommandManager<CarbonUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettings().get("pingoptions");
|
||||
|
||||
if (commandSettings == null || !commandSettings.enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
commandManager.command(
|
||||
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.senderType(PlayerUser.class) // player
|
||||
.permission("carbonchat.nickname")
|
||||
.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)
|
||||
.build()
|
||||
);
|
||||
|
||||
commandManager.command(
|
||||
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.senderType(PlayerUser.class) // player
|
||||
.permission("carbonchat.nickname")
|
||||
.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)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
private void setChannelOptions(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!"
|
||||
}
|
||||
|
||||
private void setWhisperOptions(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!"
|
||||
}
|
||||
|
||||
}
|
||||
+2
@@ -15,6 +15,7 @@ import net.draycia.carbon.common.commands.MeCommand;
|
||||
import net.draycia.carbon.common.commands.MessageCommand;
|
||||
import net.draycia.carbon.common.commands.MuteCommand;
|
||||
import net.draycia.carbon.common.commands.NicknameCommand;
|
||||
import net.draycia.carbon.common.commands.PingOptionsCommand;
|
||||
import net.draycia.carbon.common.commands.ReplyCommand;
|
||||
import net.draycia.carbon.common.commands.SetChannelColorCommand;
|
||||
import net.draycia.carbon.common.commands.SpyChannelCommand;
|
||||
@@ -39,6 +40,7 @@ public final class CommandRegistrar {
|
||||
new MessageCommand(commandManager);
|
||||
new MuteCommand(commandManager);
|
||||
new NicknameCommand(commandManager);
|
||||
new PingOptionsCommand(commandManager);
|
||||
new ReplyCommand(commandManager);
|
||||
new SetChannelColorCommand(commandManager);
|
||||
new ShadowMuteCommand(commandManager);
|
||||
|
||||
+8
-1
@@ -6,6 +6,7 @@ import net.draycia.carbon.api.events.ChatComponentEvent;
|
||||
import net.draycia.carbon.api.events.ChatFormatEvent;
|
||||
import net.draycia.carbon.api.events.misc.CarbonEvents;
|
||||
import net.draycia.carbon.api.users.PlayerUser;
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
import net.kyori.event.PostOrders;
|
||||
|
||||
public class PingHandler {
|
||||
@@ -39,7 +40,13 @@ public class PingHandler {
|
||||
}
|
||||
}
|
||||
|
||||
target.playSound(carbonChat.carbonSettings().channelPings().sound());
|
||||
final Sound sound = target.pingOptions().pingSound();
|
||||
|
||||
if (sound != null) {
|
||||
target.playSound(sound);
|
||||
} else {
|
||||
target.playSound(carbonChat.carbonSettings().channelPings().sound());
|
||||
}
|
||||
});
|
||||
|
||||
CarbonEvents.register(ChatFormatEvent.class, PostOrders.LAST, false, event -> {
|
||||
|
||||
+8
-1
@@ -4,6 +4,7 @@ import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.events.misc.CarbonEvents;
|
||||
import net.draycia.carbon.api.events.PrivateMessageEvent;
|
||||
import net.kyori.adventure.sound.Sound;
|
||||
import net.kyori.event.PostOrders;
|
||||
|
||||
public class WhisperPingHandler {
|
||||
@@ -21,7 +22,13 @@ public class WhisperPingHandler {
|
||||
}
|
||||
|
||||
if (carbonChat.carbonSettings().whisperOptions().pings().enabled()) {
|
||||
event.target().playSound(carbonChat.carbonSettings().whisperOptions().pings().sound());
|
||||
final Sound sound = event.target().pingOptions().whisperSound();
|
||||
|
||||
if (sound != null) {
|
||||
event.target().playSound(sound);
|
||||
} else {
|
||||
event.target().playSound(carbonChat.carbonSettings().whisperOptions().pings().sound());
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -76,6 +76,12 @@
|
||||
"enabled": true,
|
||||
"name": "nickname"
|
||||
},
|
||||
"pingoptions": {
|
||||
"aliases": [
|
||||
],
|
||||
"enabled": true,
|
||||
"name": "pingoptions"
|
||||
},
|
||||
"reply": {
|
||||
"aliases": [
|
||||
"r"
|
||||
|
||||
Reference in new issue
Block a user