mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-02 14:38:49 +00:00
More command progress aaaaa
This commit is contained in:
1 parent
74ebee707c
commit
e7088c6b56
24 files changed
+267
-283
No files matched your search
@@ -4,6 +4,7 @@ import net.draycia.carbon.api.adventure.CarbonTranslations;
|
||||
import net.draycia.carbon.api.adventure.MessageProcessor;
|
||||
import net.draycia.carbon.api.channels.ChannelRegistry;
|
||||
import net.draycia.carbon.api.commands.settings.CommandSettingsRegistry;
|
||||
import net.draycia.carbon.api.config.ModerationSettings;
|
||||
import net.draycia.carbon.api.users.UserService;
|
||||
import net.kyori.adventure.text.serializer.legacy.LegacyComponentSerializer;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
@@ -18,6 +19,8 @@ public interface CarbonChat {
|
||||
.useUnusualXRepeatedCharacterHexFormat()
|
||||
.build();
|
||||
|
||||
void reloadConfig();
|
||||
|
||||
@NonNull UserService userService();
|
||||
|
||||
@NonNull MessageProcessor messageProcessor();
|
||||
@@ -28,4 +31,6 @@ public interface CarbonChat {
|
||||
|
||||
@NonNull CarbonTranslations translations();
|
||||
|
||||
@NonNull ModerationSettings moderationSettings();
|
||||
|
||||
}
|
||||
@@ -0,0 +1,86 @@
|
||||
package net.draycia.carbon.api.config;
|
||||
|
||||
import org.spongepowered.configurate.objectmapping.Setting;
|
||||
import org.spongepowered.configurate.serialize.ConfigSerializable;
|
||||
|
||||
@ConfigSerializable
|
||||
public class ModerationSettings {
|
||||
|
||||
// TODO: comment this
|
||||
@Setting
|
||||
private String shadowMutePrefix = "[SM] ";
|
||||
|
||||
public String shadowMutePrefix() {
|
||||
return this.shadowMutePrefix;
|
||||
}
|
||||
|
||||
@Setting(comment = "If true, muted users will be unable to use /whisper /msg")
|
||||
private boolean muteStopsWhispers = true;
|
||||
|
||||
public boolean muteStopsWhispers() {
|
||||
return this.muteStopsWhispers;
|
||||
}
|
||||
|
||||
@Setting
|
||||
private ClearChat clearChat = new ClearChat();
|
||||
|
||||
public ClearChat clearChat() {
|
||||
return this.clearChat;
|
||||
}
|
||||
|
||||
@ConfigSerializable
|
||||
public static class ClearChat {
|
||||
@Setting(comment = "The message sent to clear chat, you probably want to leave this blank")
|
||||
private String message = "";
|
||||
|
||||
@Setting(comment = "How many messages will be sent in order to clear chat")
|
||||
private int messageCount = 100;
|
||||
|
||||
public String message() {
|
||||
return this.message;
|
||||
}
|
||||
|
||||
public int messageCount() {
|
||||
return this.messageCount;
|
||||
}
|
||||
}
|
||||
|
||||
@Setting
|
||||
private CapsProtection capsProtection = new CapsProtection();
|
||||
|
||||
public CapsProtection capsProtection() {
|
||||
return this.capsProtection;
|
||||
}
|
||||
|
||||
@ConfigSerializable
|
||||
public static class CapsProtection {
|
||||
@Setting(comment = "If caps protection is enabled")
|
||||
private boolean enabled = true;
|
||||
|
||||
@Setting(comment = "The minimum message length for caps protection to activate")
|
||||
private int minimumLength = 10;
|
||||
|
||||
@Setting(comment = "The amount of letters in the message for it to trigger the protection")
|
||||
private float percentCaps = 0.80F;
|
||||
|
||||
@Setting(comment = "If true, stops message from sending. If false, simply changes the message to lowercase")
|
||||
private boolean blockMessage = false;
|
||||
|
||||
public boolean enabled() {
|
||||
return this.enabled;
|
||||
}
|
||||
|
||||
public int minimumLength() {
|
||||
return this.minimumLength;
|
||||
}
|
||||
|
||||
public float percentCaps() {
|
||||
return this.percentCaps;
|
||||
}
|
||||
|
||||
public boolean blockMessage() {
|
||||
return this.blockMessage;
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.draycia.carbon;
|
||||
|
||||
import com.intellectualsites.commands.PaperCommandManager;
|
||||
import com.intellectualsites.commands.execution.CommandExecutionCoordinator;
|
||||
import com.intellectualsites.commands.paper.PaperCommandManager;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.adventure.CarbonTranslations;
|
||||
@@ -178,6 +178,8 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
|
||||
// TODO: weeeeee fix this
|
||||
throw new IllegalArgumentException("Non-players not supported yet!");
|
||||
}
|
||||
}, user -> {
|
||||
return Bukkit.getPlayer(user.uuid());
|
||||
});
|
||||
|
||||
CommandRegistrar.registerCommands(manager);
|
||||
@@ -190,8 +192,8 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
|
||||
public void reloadConfig() {
|
||||
super.reloadConfig();
|
||||
|
||||
this.loadModConfig();
|
||||
this.loadLanguage();
|
||||
this.loadModerationSettings();
|
||||
this.loadCommandSettings();
|
||||
}
|
||||
|
||||
@@ -208,6 +210,7 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
|
||||
}
|
||||
|
||||
private void loadCommandSettings() {
|
||||
// TODO: probably redo this from scratch
|
||||
if (!(new File(this.getDataFolder(), "carbon-commands.yml").exists())) {
|
||||
this.saveResource("carbon-commands.yml", false);
|
||||
}
|
||||
@@ -223,6 +226,10 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
|
||||
}
|
||||
}
|
||||
|
||||
private void loadModerationSettings() {
|
||||
|
||||
}
|
||||
|
||||
public void reloadFilters() {
|
||||
this.filterContext.reloadFilters();
|
||||
}
|
||||
@@ -254,11 +261,6 @@ public final class CarbonChatBukkit extends JavaPlugin implements CarbonChat {
|
||||
return this.permission;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public CommandRegistrar commandManager() {
|
||||
return this.commandRegistrar;
|
||||
}
|
||||
|
||||
@NonNull
|
||||
public MessageManager messageManager() {
|
||||
return this.messageManager;
|
||||
|
||||
@@ -1,14 +1,3 @@
|
||||
caps-protection:
|
||||
enabled: true
|
||||
minimum-length: 10
|
||||
percent-caps: 80
|
||||
block-message: false
|
||||
|
||||
shadow-mute-prefix: '[SM] '
|
||||
|
||||
# If true, muted users will be unable to use /whisper /msg
|
||||
mute-stops-whispers: false
|
||||
|
||||
filters:
|
||||
enabled: true
|
||||
case-sensitive: false
|
||||
@@ -27,9 +16,3 @@ filters:
|
||||
# Set to blocked-words: [] if you want to disable the blocked words feature.
|
||||
blocked-words:
|
||||
- "pineapple doesn't belong on pizza"
|
||||
|
||||
clear-chat:
|
||||
# The message sent to clear chat, you probably want to leave this blank
|
||||
message: ""
|
||||
# How many messages will be sent in order to clear chat
|
||||
message-count: 100
|
||||
+3
-4
@@ -1,9 +1,8 @@
|
||||
package net.draycia.carbon.common.commands;
|
||||
|
||||
import com.intellectualsites.commands.CommandManager;
|
||||
import com.intellectualsites.commands.components.standard.StringComponent;
|
||||
import com.intellectualsites.commands.arguments.standard.StringArgument;
|
||||
import com.intellectualsites.commands.context.CommandContext;
|
||||
import com.intellectualsites.commands.meta.CommandMeta;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
@@ -19,7 +18,7 @@ public class AliasedChannelCommand {
|
||||
|
||||
private final @NonNull String commandName;
|
||||
|
||||
public AliasedChannelCommand(@NonNull final CommandManager<ChatUser, SimpleCommandMeta> commandManager, @NonNull final ChatChannel chatChannel) {
|
||||
public AliasedChannelCommand(@NonNull final CommandManager<ChatUser> commandManager, @NonNull final ChatChannel chatChannel) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
this.chatChannel = chatChannel;
|
||||
this.commandName = chatChannel.key();
|
||||
@@ -36,7 +35,7 @@ public class AliasedChannelCommand {
|
||||
commandManager.commandBuilder(this.commandName)
|
||||
.withSenderType(ChatUser.class) // player
|
||||
.withPermission("carbonchat.channel.message")
|
||||
.component(StringComponent.required("message"))
|
||||
.argument(StringArgument.required("message"))
|
||||
.handler(this::sendMessage)
|
||||
.build()
|
||||
);
|
||||
|
||||
+5
-7
@@ -1,10 +1,8 @@
|
||||
package net.draycia.carbon.common.commands;
|
||||
|
||||
import com.intellectualsites.commands.CommandManager;
|
||||
import com.intellectualsites.commands.components.standard.StringComponent;
|
||||
import com.intellectualsites.commands.arguments.standard.StringArgument;
|
||||
import com.intellectualsites.commands.context.CommandContext;
|
||||
import com.intellectualsites.commands.meta.CommandMeta;
|
||||
import com.intellectualsites.commands.meta.SimpleCommandMeta;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.commands.settings.CommandSettings;
|
||||
@@ -19,7 +17,7 @@ public class ChannelCommand {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public ChannelCommand(final @NonNull CommandManager<ChatUser, SimpleCommandMeta> commandManager) {
|
||||
public ChannelCommand(final @NonNull CommandManager<ChatUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettingsRegistry().get("channel");
|
||||
@@ -33,7 +31,7 @@ public class ChannelCommand {
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.withSenderType(ChatUser.class) // player
|
||||
.withPermission("carbonchat.channel")
|
||||
.component(CommandUtils.channelComponent())
|
||||
.argument(CommandUtils.channelArgument())
|
||||
.handler(this::channel)
|
||||
.build()
|
||||
);
|
||||
@@ -42,8 +40,8 @@ public class ChannelCommand {
|
||||
commandManager.commandBuilder(commandSettings.name())
|
||||
.withSenderType(ChatUser.class) // player
|
||||
.withPermission("carbonchat.channel.message")
|
||||
.component(CommandUtils.channelComponent())
|
||||
.component(StringComponent.required("message"))
|
||||
.argument(CommandUtils.channelArgument())
|
||||
.argument(StringArgument.required("message"))
|
||||
.handler(this::sendMessage)
|
||||
.build()
|
||||
);
|
||||
|
||||
+2
-3
@@ -2,7 +2,6 @@ package net.draycia.carbon.common.commands;
|
||||
|
||||
import com.intellectualsites.commands.CommandManager;
|
||||
import com.intellectualsites.commands.context.CommandContext;
|
||||
import com.intellectualsites.commands.meta.SimpleCommandMeta;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
@@ -23,7 +22,7 @@ public class ChannelListCommand {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public ChannelListCommand(@NonNull final CommandManager<ChatUser, SimpleCommandMeta> commandManager) {
|
||||
public ChannelListCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettingsRegistry().get("channellist");
|
||||
@@ -46,7 +45,7 @@ public class ChannelListCommand {
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.withSenderType(ChatUser.class) // console & player
|
||||
.withPermission("carbonchat.channellist.other")
|
||||
.component(CommandUtils.chatUserComponent())
|
||||
.argument(CommandUtils.chatUserArgument())
|
||||
.handler(this::toggleOther)
|
||||
.build()
|
||||
);
|
||||
|
||||
+1
-4
@@ -2,8 +2,6 @@ package net.draycia.carbon.common.commands;
|
||||
|
||||
import com.intellectualsites.commands.CommandManager;
|
||||
import com.intellectualsites.commands.context.CommandContext;
|
||||
import com.intellectualsites.commands.meta.CommandMeta;
|
||||
import com.intellectualsites.commands.meta.SimpleCommandMeta;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.commands.settings.CommandSettings;
|
||||
@@ -16,7 +14,7 @@ public class ChatReloadCommand {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public ChatReloadCommand(@NonNull final CommandManager<ChatUser, SimpleCommandMeta> commandManager) {
|
||||
public ChatReloadCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettingsRegistry().get("chatreload");
|
||||
@@ -37,7 +35,6 @@ public class ChatReloadCommand {
|
||||
|
||||
private void reloadConfig(@NonNull final CommandContext<ChatUser> context) {
|
||||
this.carbonChat.reloadConfig();
|
||||
this.carbonChat.reloadFilters();
|
||||
|
||||
final Component message = this.carbonChat.messageProcessor()
|
||||
.processMessage(this.carbonChat.translations().reloaded().replace("br", "\n"));
|
||||
|
||||
+3
-5
@@ -2,8 +2,6 @@ package net.draycia.carbon.common.commands;
|
||||
|
||||
import com.intellectualsites.commands.CommandManager;
|
||||
import com.intellectualsites.commands.context.CommandContext;
|
||||
import com.intellectualsites.commands.meta.CommandMeta;
|
||||
import com.intellectualsites.commands.meta.SimpleCommandMeta;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
@@ -16,7 +14,7 @@ public class ClearChatCommand {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public ClearChatCommand(@NonNull final CommandManager<ChatUser, SimpleCommandMeta> commandManager) {
|
||||
public ClearChatCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettingsRegistry().get("clearchat");
|
||||
@@ -37,7 +35,7 @@ public class ClearChatCommand {
|
||||
|
||||
private void clearChat(@NonNull final CommandContext<ChatUser> context) {
|
||||
final String sender = context.getSender().name();
|
||||
final String format = this.carbonChat.moderationConfig().getString("clear-chat.message", "");
|
||||
final String format = this.carbonChat.moderationSettings().clearChat().message();
|
||||
final Component component = this.carbonChat.messageProcessor().processMessage(format, "br", "\n");
|
||||
|
||||
for (final ChatUser user : this.carbonChat.userService().onlineUsers()) {
|
||||
@@ -45,7 +43,7 @@ public class ClearChatCommand {
|
||||
final String message = this.carbonChat.translations().clearExempt();
|
||||
user.sendMessage(this.carbonChat.messageProcessor().processMessage(message, "player", sender));
|
||||
} else {
|
||||
for (int i = 0; i < this.carbonChat.moderationConfig().getInt("clear-chat.message-count", 100); i++) {
|
||||
for (int i = 0; i < this.carbonChat.moderationSettings().clearChat().messageCount(); i++) {
|
||||
user.sendMessage(component);
|
||||
}
|
||||
}
|
||||
|
||||
+22
-24
@@ -2,13 +2,11 @@ package net.draycia.carbon.common.commands;
|
||||
|
||||
import com.intellectualsites.commands.CommandManager;
|
||||
import com.intellectualsites.commands.context.CommandContext;
|
||||
import com.intellectualsites.commands.meta.SimpleCommandMeta;
|
||||
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.ChatUser;
|
||||
import net.draycia.carbon.common.utils.CommandUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class IgnoreCommand {
|
||||
@@ -16,7 +14,7 @@ public class IgnoreCommand {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public IgnoreCommand(@NonNull final CommandManager<ChatUser, SimpleCommandMeta> commandManager) {
|
||||
public IgnoreCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettingsRegistry().get("ignore");
|
||||
@@ -30,7 +28,7 @@ public class IgnoreCommand {
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.withSenderType(ChatUser.class) // console & player
|
||||
.withPermission("carbonchat.ignore")
|
||||
.component(CommandUtils.chatUserComponent())
|
||||
.argument(CommandUtils.chatUserArgument())
|
||||
.handler(this::ignoreUser)
|
||||
.build()
|
||||
);
|
||||
@@ -40,30 +38,30 @@ public class IgnoreCommand {
|
||||
final ChatUser sender = context.getSender();
|
||||
final ChatUser targetUser = context.getRequired("user");
|
||||
|
||||
final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(sender.uuid());
|
||||
//final OfflinePlayer offlinePlayer = Bukkit.getOfflinePlayer(sender.uuid());
|
||||
|
||||
if (sender.ignoringUser(targetUser)) {
|
||||
sender.ignoringUser(targetUser, false);
|
||||
sender.sendMessage(this.carbonChat.messageProcessor().processMessage(
|
||||
this.carbonChat.translations().notIgnoringUser(),
|
||||
"br", "\n", "player", offlinePlayer.getName()));
|
||||
// sender.sendMessage(this.carbonChat.messageProcessor().processMessage(
|
||||
// this.carbonChat.translations().notIgnoringUser(),
|
||||
// "br", "\n", "player", offlinePlayer.getName()));
|
||||
} else {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(this.carbonChat, () -> {
|
||||
final Permission permission = this.carbonChat.permission();
|
||||
final String format;
|
||||
|
||||
if (permission.playerHas(null, offlinePlayer, "carbonchat.ignore.exempt")) {
|
||||
format = this.carbonChat.translations().ignoreExempt();
|
||||
} else {
|
||||
user.ignoringUser(targetUser, true);
|
||||
format = this.carbonChat.translations().ignoringUser();
|
||||
}
|
||||
|
||||
final Component message = this.carbonChat.messageProcessor().processMessage(format,
|
||||
"br", "\n", "sender", player.getDisplayName(), "player", offlinePlayer.getName());
|
||||
|
||||
user.sendMessage(message);
|
||||
});
|
||||
// Bukkit.getScheduler().runTaskAsynchronously(this.carbonChat, () -> {
|
||||
// final Permission permission = this.carbonChat.permission();
|
||||
// final String format;
|
||||
//
|
||||
// if (permission.playerHas(null, offlinePlayer, "carbonchat.ignore.exempt")) {
|
||||
// format = this.carbonChat.translations().ignoreExempt();
|
||||
// } else {
|
||||
// user.ignoringUser(targetUser, true);
|
||||
// format = this.carbonChat.translations().ignoringUser();
|
||||
// }
|
||||
//
|
||||
// final Component message = this.carbonChat.messageProcessor().processMessage(format,
|
||||
// "br", "\n", "sender", player.getDisplayName(), "player", offlinePlayer.getName());
|
||||
//
|
||||
// user.sendMessage(message);
|
||||
// });
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,32 +1,21 @@
|
||||
package net.draycia.carbon.common.commands;
|
||||
|
||||
import com.intellectualsites.commands.CommandManager;
|
||||
import com.intellectualsites.commands.meta.CommandMeta;
|
||||
import com.intellectualsites.commands.meta.SimpleCommandMeta;
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import dev.jorel.commandapi.CommandPermission;
|
||||
import dev.jorel.commandapi.arguments.Argument;
|
||||
import dev.jorel.commandapi.arguments.GreedyStringArgument;
|
||||
import me.clip.placeholderapi.PlaceholderAPI;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import com.intellectualsites.commands.arguments.standard.StringArgument;
|
||||
import com.intellectualsites.commands.context.CommandContext;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.commands.settings.CommandSettings;
|
||||
import net.draycia.carbon.util.CommandUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
public class MeCommand {
|
||||
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public MeCommand(@NonNull final CommandManager<ChatUser, SimpleCommandMeta> commandManager) {
|
||||
public MeCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettingsRegistry().get("me");
|
||||
@@ -35,39 +24,39 @@ public class MeCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
final LinkedHashMap<String, Argument> channelArguments = new LinkedHashMap<>();
|
||||
channelArguments.put("message", new GreedyStringArgument());
|
||||
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
.withArguments(channelArguments)
|
||||
.withAliases(commandSettings.aliases())
|
||||
.withPermission(CommandPermission.fromString("carbonchat.me"))
|
||||
.executesPlayer(this::execute)
|
||||
.register();
|
||||
commandManager.command(
|
||||
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.withSenderType(ChatUser.class) // console & player
|
||||
.withPermission("carbonchat.me")
|
||||
.argument(StringArgument.<ChatUser>newBuilder("message").greedy().build())
|
||||
.handler(this::message)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
private void execute(@NonNull final Player player, @NonNull final Object @NonNull [] args) {
|
||||
final String message = ((String) args[0]).replace("</pre>", "");
|
||||
String format = PlaceholderAPI.setPlaceholders(player, this.carbonChat.translations().roleplayFormat());
|
||||
private void message(@NonNull final CommandContext<ChatUser> context) {
|
||||
final ChatUser user = context.getSender();
|
||||
|
||||
if (!player.hasPermission("carbonchat.me.formatting")) {
|
||||
final String message = context.<String>getRequired("message").replace("</pre>", "");
|
||||
String format = this.carbonChat.translations().roleplayFormat();
|
||||
|
||||
if (!user.hasPermission("carbonchat.me.formatting")) {
|
||||
format = format.replace("<message>", "<pre><message></pre>");
|
||||
}
|
||||
|
||||
final Component component = this.carbonChat.messageProcessor().processMessage(format, "br", "\n",
|
||||
"displayname", player.getDisplayName(), "message", message);
|
||||
|
||||
final ChatUser user = this.carbonChat.userService().wrap(player.getUniqueId());
|
||||
"displayname", user.displayName(), "message", message);
|
||||
|
||||
if (user.shadowMuted()) {
|
||||
user.sendMessage(component);
|
||||
} else {
|
||||
for (final Player onlinePlayer : Bukkit.getOnlinePlayers()) {
|
||||
if (this.carbonChat.userService().wrap(onlinePlayer.getUniqueId()).ignoringUser(user)) {
|
||||
for (final ChatUser onlineUser : this.carbonChat.userService().onlineUsers()) {
|
||||
if (onlineUser.ignoringUser(user)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
this.carbonChat.messageProcessor().audiences().player(onlinePlayer.getUniqueId()).sendMessage(component);
|
||||
onlineUser.sendMessage(component);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
+4
-5
@@ -1,9 +1,8 @@
|
||||
package net.draycia.carbon.common.commands;
|
||||
|
||||
import com.intellectualsites.commands.CommandManager;
|
||||
import com.intellectualsites.commands.components.standard.StringComponent;
|
||||
import com.intellectualsites.commands.arguments.standard.StringArgument;
|
||||
import com.intellectualsites.commands.context.CommandContext;
|
||||
import com.intellectualsites.commands.meta.SimpleCommandMeta;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.commands.settings.CommandSettings;
|
||||
@@ -13,7 +12,7 @@ import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
public class MessageCommand {
|
||||
|
||||
public MessageCommand(@NonNull final CommandManager<ChatUser, SimpleCommandMeta> commandManager) {
|
||||
public MessageCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
final CarbonChat carbonChat = CarbonChatProvider.carbonChat();
|
||||
final CommandSettings commandSettings = carbonChat.commandSettingsRegistry().get("message");
|
||||
|
||||
@@ -26,8 +25,8 @@ public class MessageCommand {
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.withSenderType(ChatUser.class) // player
|
||||
.withPermission("carbonchat.message")
|
||||
.component(CommandUtils.chatUserComponent())
|
||||
.component(StringComponent.<ChatUser>newBuilder("message").greedy().build())
|
||||
.argument(CommandUtils.chatUserArgument())
|
||||
.argument(StringArgument.<ChatUser>newBuilder("message").greedy().build())
|
||||
.handler(this::sendMessage)
|
||||
.build()
|
||||
);
|
||||
|
||||
+29
-54
@@ -1,35 +1,21 @@
|
||||
package net.draycia.carbon.common.commands;
|
||||
|
||||
import com.intellectualsites.commands.CommandManager;
|
||||
import com.intellectualsites.commands.meta.CommandMeta;
|
||||
import com.intellectualsites.commands.meta.SimpleCommandMeta;
|
||||
import com.intellectualsites.commands.context.CommandContext;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.commands.settings.CommandSettings;
|
||||
import net.draycia.carbon.util.CarbonUtils;
|
||||
import net.draycia.carbon.util.CommandUtils;
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import dev.jorel.commandapi.CommandPermission;
|
||||
import dev.jorel.commandapi.arguments.Argument;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.draycia.carbon.common.utils.CommandUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
public class MuteCommand {
|
||||
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public MuteCommand(@NonNull final CommandManager<ChatUser, SimpleCommandMeta> commandManager) {
|
||||
public MuteCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettingsRegistry().get("mute");
|
||||
@@ -38,55 +24,44 @@ public class MuteCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
final LinkedHashMap<String, Argument> arguments = new LinkedHashMap<>();
|
||||
arguments.put("player", CarbonUtils.chatUserArgument());
|
||||
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
.withArguments(arguments)
|
||||
.withAliases(commandSettings.aliases())
|
||||
.withPermission(CommandPermission.fromString("carbonchat.mute"))
|
||||
.executes(this::execute)
|
||||
.register();
|
||||
commandManager.command(
|
||||
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.withSenderType(ChatUser.class) // player
|
||||
.withPermission("carbonchat.mute")
|
||||
.argument(CommandUtils.chatUserArgument())
|
||||
.handler(this::mute)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
private void execute(@NonNull final CommandSender sender, @NonNull final Object @NonNull [] args) {
|
||||
final ChatUser user = (ChatUser) args[0];
|
||||
private void mute(@NonNull final CommandContext<ChatUser> context) {
|
||||
final ChatUser user = context.getSender();
|
||||
final ChatUser target = context.getRequired("user");
|
||||
|
||||
final Audience cmdSender;
|
||||
|
||||
if (sender instanceof Player) {
|
||||
cmdSender = this.carbonChat.userService().wrap(((Player) sender).getUniqueId());
|
||||
} else {
|
||||
cmdSender = this.carbonChat.messageProcessor().audiences().console();
|
||||
}
|
||||
|
||||
final OfflinePlayer player = Bukkit.getOfflinePlayer(user.uuid());
|
||||
|
||||
if (user.shadowMuted()) {
|
||||
if (user.muted()) {
|
||||
user.muted(false);
|
||||
final String format = this.carbonChat.translations().noLongerMuted();
|
||||
|
||||
final Component message = this.carbonChat.messageProcessor().processMessage(format, "br", "\n",
|
||||
"player", player.getName());
|
||||
"player", target.name());
|
||||
|
||||
cmdSender.sendMessage(message);
|
||||
user.sendMessage(message);
|
||||
} else {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(this.carbonChat, () -> {
|
||||
final Permission permission = this.carbonChat.permission();
|
||||
final String format;
|
||||
// TODO: schedule task because LuckPerms doesn't like sync offline permission checks
|
||||
final String format;
|
||||
|
||||
if (permission.playerHas(null, player, "carbonchat.mute.exempt")) {
|
||||
format = this.carbonChat.translations().muteExempt();
|
||||
} else {
|
||||
user.muted(true);
|
||||
format = this.carbonChat.translations().nowMuted();
|
||||
}
|
||||
if (target.hasPermission("carbonchat.mute.exempt")) {
|
||||
format = this.carbonChat.translations().muteExempt();
|
||||
} else {
|
||||
user.muted(true);
|
||||
format = this.carbonChat.translations().nowMuted();
|
||||
}
|
||||
|
||||
final Component message = this.carbonChat.messageProcessor().processMessage(format, "br", "\n",
|
||||
"player", player.getName());
|
||||
final Component message = this.carbonChat.messageProcessor().processMessage(format, "br", "\n",
|
||||
"player", target.name());
|
||||
|
||||
cmdSender.sendMessage(message);
|
||||
});
|
||||
user.sendMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
+7
-16
@@ -1,9 +1,8 @@
|
||||
package net.draycia.carbon.common.commands;
|
||||
|
||||
import com.intellectualsites.commands.CommandManager;
|
||||
import com.intellectualsites.commands.components.standard.StringComponent;
|
||||
import com.intellectualsites.commands.arguments.standard.StringArgument;
|
||||
import com.intellectualsites.commands.context.CommandContext;
|
||||
import com.intellectualsites.commands.meta.SimpleCommandMeta;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.commands.settings.CommandSettings;
|
||||
@@ -16,7 +15,7 @@ public class NicknameCommand {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public NicknameCommand(@NonNull final CommandManager<ChatUser, SimpleCommandMeta> commandManager) {
|
||||
public NicknameCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettingsRegistry().get("nickname");
|
||||
@@ -25,13 +24,14 @@ public class NicknameCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
// TODO: make this deterministic, has to be Nickname -> User
|
||||
commandManager.command(
|
||||
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.withSenderType(ChatUser.class) // player
|
||||
.withPermission("carbonchat.nickname")
|
||||
.component(StringComponent.<ChatUser>newBuilder("nickname").single().build())
|
||||
.handler(this::nicknameOther)
|
||||
.argument(StringArgument.required("nickname"))
|
||||
.handler(this::nicknameSelf)
|
||||
.build()
|
||||
);
|
||||
|
||||
@@ -40,20 +40,11 @@ public class NicknameCommand {
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.withSenderType(ChatUser.class) // player
|
||||
.withPermission("carbonchat.nickname")
|
||||
.component(CommandUtils.chatUserComponent())
|
||||
.component(StringComponent.<ChatUser>newBuilder("nickname").single().build())
|
||||
.argument(CommandUtils.chatUserArgument())
|
||||
.argument(StringArgument.required("nickname"))
|
||||
.handler(this::nicknameOther)
|
||||
.build()
|
||||
);
|
||||
|
||||
selfArguments.put("nickname", new StringArgument());
|
||||
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
.withArguments(selfArguments)
|
||||
.withAliases(commandSettings.aliases())
|
||||
.withPermission(CommandPermission.fromString("carbonchat.nickname"))
|
||||
.executesPlayer(this::executeSelf)
|
||||
.register();
|
||||
}
|
||||
|
||||
private void nicknameSelf(@NonNull final CommandContext<ChatUser> context) {
|
||||
|
||||
+15
-25
@@ -1,30 +1,21 @@
|
||||
package net.draycia.carbon.common.commands;
|
||||
|
||||
import com.intellectualsites.commands.CommandManager;
|
||||
import com.intellectualsites.commands.meta.CommandMeta;
|
||||
import com.intellectualsites.commands.meta.SimpleCommandMeta;
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import dev.jorel.commandapi.CommandPermission;
|
||||
import dev.jorel.commandapi.arguments.Argument;
|
||||
import dev.jorel.commandapi.arguments.GreedyStringArgument;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import com.intellectualsites.commands.arguments.standard.StringArgument;
|
||||
import com.intellectualsites.commands.context.CommandContext;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.commands.settings.CommandSettings;
|
||||
import net.draycia.carbon.util.CommandUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
public class ReplyCommand {
|
||||
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public ReplyCommand(@NonNull final CommandManager<ChatUser, SimpleCommandMeta> commandManager) {
|
||||
public ReplyCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettingsRegistry().get("reply");
|
||||
@@ -33,21 +24,20 @@ public class ReplyCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
final LinkedHashMap<String, Argument> arguments = new LinkedHashMap<>();
|
||||
arguments.put("message", new GreedyStringArgument());
|
||||
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
.withArguments(arguments)
|
||||
.withAliases(commandSettings.aliases())
|
||||
.withPermission(CommandPermission.fromString("carbonchat.reply"))
|
||||
.executesPlayer(this::execute)
|
||||
.register();
|
||||
commandManager.command(
|
||||
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.withSenderType(ChatUser.class) // player
|
||||
.withPermission("carbonchat.reply")
|
||||
.argument(StringArgument.<ChatUser>newBuilder("message").greedy().build())
|
||||
.handler(this::reply)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
private void execute(@NonNull final Player player, @NonNull final Object @NonNull [] args) {
|
||||
final String input = (String) args[0];
|
||||
|
||||
final ChatUser user = this.carbonChat.userService().wrap(player.getUniqueId());
|
||||
private void reply(@NonNull final CommandContext<ChatUser> context) {
|
||||
final ChatUser user = context.getSender();
|
||||
final String input = context.getRequired("message");
|
||||
|
||||
if (input.isEmpty()) {
|
||||
final String message = this.carbonChat.translations().replyMessageBlank();
|
||||
|
||||
+1
-1
@@ -26,7 +26,7 @@ public class SetColorCommand {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public SetColorCommand(@NonNull final CommandManager<ChatUser, SimpleCommandMeta> commandManager) {
|
||||
public SetColorCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettingsRegistry().get("setcolor");
|
||||
|
||||
+28
-53
@@ -1,35 +1,21 @@
|
||||
package net.draycia.carbon.common.commands;
|
||||
|
||||
import com.intellectualsites.commands.CommandManager;
|
||||
import com.intellectualsites.commands.meta.CommandMeta;
|
||||
import com.intellectualsites.commands.meta.SimpleCommandMeta;
|
||||
import com.intellectualsites.commands.context.CommandContext;
|
||||
import net.draycia.carbon.api.CarbonChat;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
import net.draycia.carbon.api.commands.settings.CommandSettings;
|
||||
import net.draycia.carbon.util.CarbonUtils;
|
||||
import net.draycia.carbon.util.CommandUtils;
|
||||
import dev.jorel.commandapi.CommandAPICommand;
|
||||
import dev.jorel.commandapi.CommandPermission;
|
||||
import dev.jorel.commandapi.arguments.Argument;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
import net.draycia.carbon.common.utils.CommandUtils;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.milkbowl.vault.permission.Permission;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.OfflinePlayer;
|
||||
import org.bukkit.command.CommandSender;
|
||||
import org.bukkit.entity.Player;
|
||||
import org.checkerframework.checker.nullness.qual.NonNull;
|
||||
|
||||
import java.util.LinkedHashMap;
|
||||
|
||||
public class ShadowMuteCommand {
|
||||
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public ShadowMuteCommand(@NonNull final CommandManager<ChatUser, SimpleCommandMeta> commandManager) {
|
||||
public ShadowMuteCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettingsRegistry().get("shadowmute");
|
||||
@@ -38,55 +24,44 @@ public class ShadowMuteCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
final LinkedHashMap<String, Argument> arguments = new LinkedHashMap<>();
|
||||
arguments.put("player", CarbonUtils.chatUserArgument());
|
||||
|
||||
new CommandAPICommand(commandSettings.name())
|
||||
.withArguments(arguments)
|
||||
.withAliases(commandSettings.aliases())
|
||||
.withPermission(CommandPermission.fromString("carbonchat.shadowmute"))
|
||||
.executes(this::execute)
|
||||
.register();
|
||||
commandManager.command(
|
||||
commandManager.commandBuilder(commandSettings.name(), commandSettings.aliases(),
|
||||
commandManager.createDefaultCommandMeta())
|
||||
.withSenderType(ChatUser.class) // player
|
||||
.withPermission("carbonchat.shadowmute")
|
||||
.argument(CommandUtils.chatUserArgument())
|
||||
.handler(this::shadowMute)
|
||||
.build()
|
||||
);
|
||||
}
|
||||
|
||||
private void execute(@NonNull final CommandSender sender, @NonNull final Object @NonNull [] args) {
|
||||
final Audience cmdSender;
|
||||
|
||||
if (sender instanceof Player) {
|
||||
cmdSender = this.carbonChat.userService().wrap(((Player) sender).getUniqueId());
|
||||
} else {
|
||||
cmdSender = this.carbonChat.messageProcessor().audiences().console();
|
||||
}
|
||||
|
||||
final ChatUser user = (ChatUser) args[0];
|
||||
|
||||
final OfflinePlayer player = Bukkit.getOfflinePlayer(user.uuid());
|
||||
private void shadowMute(@NonNull final CommandContext<ChatUser> context) {
|
||||
final ChatUser user = context.getSender();
|
||||
final ChatUser target = context.getRequired("user");
|
||||
|
||||
if (user.shadowMuted()) {
|
||||
user.shadowMuted(false);
|
||||
final String format = this.carbonChat.translations().noLongerShadowMuted();
|
||||
|
||||
final Component message = this.carbonChat.messageProcessor().processMessage(format, "br", "\n",
|
||||
"player", player.getName());
|
||||
"player", target.name());
|
||||
|
||||
cmdSender.sendMessage(message);
|
||||
user.sendMessage(message);
|
||||
} else {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(this.carbonChat, () -> {
|
||||
final Permission permission = this.carbonChat.permission();
|
||||
final String format;
|
||||
// TODO: schedule task because LuckPerms doesn't like sync offline permission checks
|
||||
final String format;
|
||||
|
||||
if (permission.playerHas(null, player, "carbonchat.shadowmute.exempt")) {
|
||||
format = this.carbonChat.translations().shadowMuteExempt();
|
||||
} else {
|
||||
user.shadowMuted(true);
|
||||
format = this.carbonChat.translations().nowShadowMuted();
|
||||
}
|
||||
if (target.hasPermission("carbonchat.mute.exempt")) {
|
||||
format = this.carbonChat.translations().shadowMuteExempt();
|
||||
} else {
|
||||
user.shadowMuted(true);
|
||||
format = this.carbonChat.translations().nowShadowMuted();
|
||||
}
|
||||
|
||||
final Component message = this.carbonChat.messageProcessor().processMessage(format, "br", "\n",
|
||||
"player", player.getName());
|
||||
final Component message = this.carbonChat.messageProcessor().processMessage(format, "br", "\n",
|
||||
"player", target.name());
|
||||
|
||||
cmdSender.sendMessage(message);
|
||||
});
|
||||
user.sendMessage(message);
|
||||
}
|
||||
}
|
||||
}
|
||||
+1
-1
@@ -27,7 +27,7 @@ public class SpyChannelCommand {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public SpyChannelCommand(@NonNull final CommandManager<ChatUser, SimpleCommandMeta> commandManager) {
|
||||
public SpyChannelCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettingsRegistry().get("spy");
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ public class SudoChannelCommand {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public SudoChannelCommand(@NonNull final CommandManager<ChatUser, SimpleCommandMeta> commandManager) {
|
||||
public SudoChannelCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettingsRegistry().get("sudochannel");
|
||||
|
||||
+1
-1
@@ -29,7 +29,7 @@ public class ToggleCommand {
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
public ToggleCommand(@NonNull final CommandManager<ChatUser, SimpleCommandMeta> commandManager) {
|
||||
public ToggleCommand(@NonNull final CommandManager<ChatUser> commandManager) {
|
||||
this.carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
final CommandSettings commandSettings = this.carbonChat.commandSettingsRegistry().get("toggle");
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ public final class CommandRegistrar {
|
||||
|
||||
}
|
||||
|
||||
public static <Meta extends CommandMeta, Manager extends CommandManager<ChatUser, Meta>> void registerCommands(final @NonNull Manager commandManager) {
|
||||
public static void registerCommands(final @NonNull CommandManager<ChatUser> commandManager) {
|
||||
new ChannelCommand(commandManager);
|
||||
new ChannelListCommand(commandManager);
|
||||
new ChatReloadCommand(commandManager);
|
||||
|
||||
+4
-4
@@ -12,11 +12,11 @@ public class CapsHandler {
|
||||
final CarbonChat carbonChat = CarbonChatProvider.carbonChat();
|
||||
|
||||
CarbonEvents.register(PreChatFormatEvent.class, PostOrders.FIRST, false, event -> {
|
||||
if (!carbonChat.moderationConfig().getBoolean("caps-protection.enabled")) {
|
||||
if (!carbonChat.moderationSettings().capsProtection().enabled()) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (!(event.message().length() >= carbonChat.moderationConfig().getInt("caps-protection.minimum-length"))) {
|
||||
if (!(event.message().length() >= carbonChat.moderationSettings().capsProtection().minimumLength())) {
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -30,11 +30,11 @@ public class CapsHandler {
|
||||
|
||||
final double capsPercentage = (amountOfCaps * 100.0) / event.message().length();
|
||||
|
||||
if (!(capsPercentage >= carbonChat.moderationConfig().getDouble("caps-protection.percent-caps"))) {
|
||||
if (!(capsPercentage >= carbonChat.moderationSettings().capsProtection().percentCaps())) {
|
||||
return;
|
||||
}
|
||||
|
||||
if (carbonChat.moderationConfig().getBoolean("block-message")) {
|
||||
if (carbonChat.moderationSettings().capsProtection().blockMessage()) {
|
||||
event.cancelled(true);
|
||||
} else {
|
||||
event.message(event.message().toLowerCase());
|
||||
|
||||
+1
-1
@@ -27,7 +27,7 @@ public class ShadowMuteHandler {
|
||||
return;
|
||||
}
|
||||
|
||||
final String prefix = carbonChat.moderationConfig().getString("shadow-mute-prefix", "[SM] ");
|
||||
final String prefix = carbonChat.moderationSettings().shadowMutePrefix();
|
||||
|
||||
event.format(prefix + event.format());
|
||||
});
|
||||
|
||||
@@ -1,7 +1,7 @@
|
||||
package net.draycia.carbon.common.utils;
|
||||
|
||||
import com.intellectualsites.commands.components.CommandComponent;
|
||||
import com.intellectualsites.commands.components.parser.ComponentParseResult;
|
||||
import com.intellectualsites.commands.arguments.CommandArgument;
|
||||
import com.intellectualsites.commands.arguments.parser.ArgumentParseResult;
|
||||
import net.draycia.carbon.api.CarbonChatProvider;
|
||||
import net.draycia.carbon.api.channels.ChatChannel;
|
||||
import net.draycia.carbon.api.users.ChatUser;
|
||||
@@ -13,55 +13,55 @@ public final class CommandUtils {
|
||||
}
|
||||
|
||||
// TODO: turn this into a proper class that handles suggestions
|
||||
private static final CommandComponent<ChatUser, ChatChannel> commandComponent =
|
||||
CommandComponent.<ChatUser, ChatChannel>ofType(ChatChannel.class, "channel")
|
||||
private static final CommandArgument<ChatUser, ChatChannel> channelArgument =
|
||||
CommandArgument.<ChatUser, ChatChannel>ofType(ChatChannel.class, "channel")
|
||||
.asRequired()
|
||||
.withParser((c, i) -> {
|
||||
final String input = i.peek();
|
||||
|
||||
if (input == null) {
|
||||
return ComponentParseResult.failure(new IllegalArgumentException("Channel cannot be null"));
|
||||
return ArgumentParseResult.failure(new IllegalArgumentException("Channel cannot be null"));
|
||||
}
|
||||
|
||||
final ChatChannel channel = CarbonChatProvider.carbonChat()
|
||||
.channelRegistry().get(input);
|
||||
|
||||
if (channel != null) {
|
||||
return ComponentParseResult.success(channel);
|
||||
return ArgumentParseResult.success(channel);
|
||||
} else {
|
||||
return ComponentParseResult.failure(new IllegalArgumentException("Channel does not exist"));
|
||||
return ArgumentParseResult.failure(new IllegalArgumentException("Channel does not exist"));
|
||||
}
|
||||
})
|
||||
.build();
|
||||
|
||||
public static CommandComponent<ChatUser, ChatChannel> channelComponent() {
|
||||
return commandComponent;
|
||||
public static CommandArgument<ChatUser, ChatChannel> channelArgument() {
|
||||
return channelArgument;
|
||||
}
|
||||
|
||||
// TODO: turn this into a proper class that handles suggestions
|
||||
private static final CommandComponent<ChatUser, ChatUser> chatUserComponent =
|
||||
CommandComponent.<ChatUser, ChatUser>ofType(ChatUser.class, "user")
|
||||
private static final CommandArgument<ChatUser, ChatUser> chatUserArgument =
|
||||
CommandArgument.<ChatUser, ChatUser>ofType(ChatUser.class, "user")
|
||||
.asRequired()
|
||||
.withParser((c, i) -> {
|
||||
final String input = i.peek();
|
||||
|
||||
if (input == null) {
|
||||
return ComponentParseResult.failure(new IllegalArgumentException("Player cannot be null"));
|
||||
return ArgumentParseResult.failure(new IllegalArgumentException("Player cannot be null"));
|
||||
}
|
||||
|
||||
final ChatUser user = CarbonChatProvider.carbonChat()
|
||||
.userService().wrap(null); // TODO: find way to resolve name -> uuid
|
||||
|
||||
if (user != null) {
|
||||
return ComponentParseResult.success(user);
|
||||
return ArgumentParseResult.success(user);
|
||||
} else {
|
||||
return ComponentParseResult.failure(new IllegalArgumentException("Player does not exist"));
|
||||
return ArgumentParseResult.failure(new IllegalArgumentException("Player does not exist"));
|
||||
}
|
||||
})
|
||||
.build();
|
||||
|
||||
public static CommandComponent<ChatUser, ChatUser> chatUserComponent() {
|
||||
return chatUserComponent;
|
||||
public static CommandArgument<ChatUser, ChatUser> chatUserArgument() {
|
||||
return chatUserArgument;
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user