This commit is contained in:
Draycia committed 2020-08-26 04:22:05 -07:00
1 parent f17168f68f
commit 207eee3576
5 files changed
+46 -15

No files matched your search

+3
View File
@@ -30,6 +30,7 @@ repositories {
maven {url = 'https://repo.codemc.org/repository/maven-public/'}
maven {url = 'https://repo.minebench.de/'}
maven {url = "https://repo.aikar.co/content/groups/aikar/"}
maven {url = "https://raw.githubusercontent.com/JorelAli/CommandAPI/mvn-repo/"}
}
dependencies {
@@ -46,6 +47,8 @@ dependencies {
compile 'io.github.leonardosnt:bungeechannelapi:1.0.0-SNAPSHOT'
compile 'io.lettuce:lettuce-core:6.0.0.M1'
compile "dev.jorel:commandapi-core:4.0"
compileOnly 'com.gmail.nossr50.mcMMO:mcMMO:2.1.143'
compileOnly 'com.github.TownyAdvanced:Towny:0.96.2.0'
compileOnly 'com.sk89q.worldguard:worldguard-bukkit:7.0.4-SNAPSHOT'
@@ -1,39 +1,61 @@
package net.draycia.carbon.commands;
import co.aikar.commands.BaseCommand;
import co.aikar.commands.annotation.*;
import dev.jorel.commandapi.CommandAPICommand;
import dev.jorel.commandapi.arguments.Argument;
import dev.jorel.commandapi.arguments.GreedyStringArgument;
import net.draycia.carbon.CarbonChat;
import net.draycia.carbon.storage.ChatUser;
import net.kyori.adventure.text.Component;
import org.bukkit.entity.Player;
import java.util.LinkedHashMap;
import java.util.List;
@CommandAlias("reply|r")
@CommandPermission("carbonchat.reply")
public class ReplyCommand extends BaseCommand {
public class ReplyCommand {
@Dependency
private CarbonChat carbonChat;
private final CarbonChat carbonChat;
@Default
@Syntax("<message>")
public void baseCommand(Player player, String... args) {
if (args.length == 0) {
return;
}
public ReplyCommand(CarbonChat carbonChat) {
this.carbonChat = carbonChat;
LinkedHashMap<String, Argument> arguments = new LinkedHashMap<>();
arguments.put("message", new GreedyStringArgument());
String commandName = carbonChat.getConfig().getString("commands.reply.name", "reply");
List<String> commandAliases = carbonChat.getConfig().getStringList("commands.reply.aliases");
new CommandAPICommand(commandName)
.withArguments(arguments)
.withAliases(commandAliases.toArray(new String[0]))
.executesPlayer(this::execute)
.register();
}
private void execute(Player player, Object[] args) {
String input = (String) args[0];
ChatUser user = carbonChat.getUserService().wrap(player);
if (input == null || input.isEmpty()) {
String message = carbonChat.getLanguage().getString("reply-message-blank");
Component component = carbonChat.getAdventureManager().processMessage(message, "br", "\n");
user.sendMessage(component);
return;
}
if (user.getReplyTarget() == null) {
String message = carbonChat.getLanguage().getString("no-reply-target");
Component component = carbonChat.getAdventureManager().processMessage(message, "br", "\n");
user.sendMessage(component);
return;
}
ChatUser targetUser = carbonChat.getUserService().wrap(user.getReplyTarget());
targetUser.sendMessage(user, String.join(" ", args));
targetUser.sendMessage(user, input);
}
}
@@ -77,10 +77,10 @@ public class CommandManager {
}
});
reloadCommands();
reloadCommands(carbonChat);
}
public void reloadCommands() {
public void reloadCommands(CarbonChat carbonChat) {
this.commandManager.registerCommand(new ToggleCommand());
this.commandManager.registerCommand(new ChannelCommand());
this.commandManager.registerCommand(new ChannelListCommand());
@@ -89,7 +89,7 @@ public class CommandManager {
this.commandManager.registerCommand(new MeCommand());
this.commandManager.registerCommand(new MessageCommand());
this.commandManager.registerCommand(new NicknameCommand());
this.commandManager.registerCommand(new ReplyCommand());
new ReplyCommand(carbonChat);
this.commandManager.registerCommand(new SetColorCommand());
this.commandManager.registerCommand(new SpyChannelCommand());
+5
View File
@@ -145,3 +145,8 @@ redis:
port: 6379
#password: 'password'
database: 0
commands:
reply:
name: 'reply'
aliases: ['r']
+1
View File
@@ -21,6 +21,7 @@ available-channels-list: '<green>Available Channels:<reset> <list>.'
unavailable-channels-list: '<red>Unavailable Channels:<reset> <list>.'
channel-list-separator: ', '
user-must-be-online: '<red><player> must be online!'
reply-message-blank: '<red>Your reply message was blank!'
# The following messages are compatible with PlaceholderAPI and MiniMessage/MineDown
me: '<italic><dark_purple>*<displayname> <reset><message>*</dark_purple></italic>'