mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-02 06:28:54 +00:00
10/15
This commit is contained in:
1 parent
6ef710084b
commit
f7fd50f5f5
3 files changed
+32
-16
No files matched your search
@@ -1,7 +1,9 @@
|
||||
package net.draycia.carbon.commands;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.annotation.*;
|
||||
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.CarbonChat;
|
||||
import net.draycia.carbon.storage.ChatUser;
|
||||
@@ -9,21 +11,32 @@ import net.kyori.adventure.text.Component;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
@CommandAlias("me|rp")
|
||||
@CommandPermission("carbonchat.me")
|
||||
public class MeCommand extends BaseCommand {
|
||||
import java.util.LinkedHashMap;
|
||||
import java.util.List;
|
||||
|
||||
@Dependency
|
||||
private CarbonChat carbonChat;
|
||||
public class MeCommand {
|
||||
|
||||
@Default
|
||||
@Syntax("<message>")
|
||||
public void baseCommand(Player player, String... args) {
|
||||
if (args == null || args.length == 0) {
|
||||
return;
|
||||
}
|
||||
private final CarbonChat carbonChat;
|
||||
|
||||
String message = String.join(" ", args).replace("</pre>", "");
|
||||
public MeCommand(CarbonChat carbonChat) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
String commandName = carbonChat.getConfig().getString("commands.me.name", "me");
|
||||
List<String> commandAliases = carbonChat.getConfig().getStringList("commands.me.aliases");
|
||||
|
||||
LinkedHashMap<String, Argument> channelArguments = new LinkedHashMap<>();
|
||||
channelArguments.put("message", new GreedyStringArgument());
|
||||
|
||||
new CommandAPICommand(commandName)
|
||||
.withArguments(channelArguments)
|
||||
.withAliases(commandAliases.toArray(new String[0]))
|
||||
.withPermission(CommandPermission.fromString("carbonchat.me"))
|
||||
.executesPlayer(this::execute)
|
||||
.register();
|
||||
}
|
||||
|
||||
private void execute(Player player, Object[] args) {
|
||||
String message = ((String) args[0]).replace("</pre>", "");
|
||||
String format = PlaceholderAPI.setPlaceholders(player, carbonChat.getLanguage().getString("me"));
|
||||
|
||||
if (!player.hasPermission("carbonchat.me.formatting")) {
|
||||
|
||||
@@ -86,7 +86,7 @@ public class CommandManager {
|
||||
new ChatReloadCommand(carbonChat);
|
||||
new ClearChatCommand(carbonChat);
|
||||
this.commandManager.registerCommand(new IgnoreCommand());
|
||||
this.commandManager.registerCommand(new MeCommand());
|
||||
new MeCommand(carbonChat);
|
||||
this.commandManager.registerCommand(new MessageCommand());
|
||||
new MuteCommand(carbonChat);
|
||||
new NicknameCommand(carbonChat);
|
||||
|
||||
@@ -170,4 +170,7 @@ commands:
|
||||
aliases: ['spych', 'spychannel']
|
||||
toggle:
|
||||
name: 'toggle'
|
||||
aliases: ['togglechannel', 'tch', 'togglech', 'tchannel', 'togglec']
|
||||
aliases: ['togglechannel', 'tch', 'togglech', 'tchannel', 'togglec']
|
||||
me:
|
||||
name: 'me'
|
||||
aliases: ['rp']
|
||||
Reference in new issue
Block a user