mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-04 14:38:49 +00:00
1/15
This commit is contained in:
1 parent
f17168f68f
commit
207eee3576
5 files changed
+45
-14
No files matched your search
@@ -30,6 +30,7 @@ repositories {
|
|||||||
maven {url = 'https://repo.codemc.org/repository/maven-public/'}
|
maven {url = 'https://repo.codemc.org/repository/maven-public/'}
|
||||||
maven {url = 'https://repo.minebench.de/'}
|
maven {url = 'https://repo.minebench.de/'}
|
||||||
maven {url = "https://repo.aikar.co/content/groups/aikar/"}
|
maven {url = "https://repo.aikar.co/content/groups/aikar/"}
|
||||||
|
maven {url = "https://raw.githubusercontent.com/JorelAli/CommandAPI/mvn-repo/"}
|
||||||
}
|
}
|
||||||
|
|
||||||
dependencies {
|
dependencies {
|
||||||
@@ -46,6 +47,8 @@ dependencies {
|
|||||||
compile 'io.github.leonardosnt:bungeechannelapi:1.0.0-SNAPSHOT'
|
compile 'io.github.leonardosnt:bungeechannelapi:1.0.0-SNAPSHOT'
|
||||||
compile 'io.lettuce:lettuce-core:6.0.0.M1'
|
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.gmail.nossr50.mcMMO:mcMMO:2.1.143'
|
||||||
compileOnly 'com.github.TownyAdvanced:Towny:0.96.2.0'
|
compileOnly 'com.github.TownyAdvanced:Towny:0.96.2.0'
|
||||||
compileOnly 'com.sk89q.worldguard:worldguard-bukkit:7.0.4-SNAPSHOT'
|
compileOnly 'com.sk89q.worldguard:worldguard-bukkit:7.0.4-SNAPSHOT'
|
||||||
|
|||||||
@@ -1,39 +1,61 @@
|
|||||||
package net.draycia.carbon.commands;
|
package net.draycia.carbon.commands;
|
||||||
|
|
||||||
import co.aikar.commands.BaseCommand;
|
|
||||||
import co.aikar.commands.annotation.*;
|
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.CarbonChat;
|
||||||
import net.draycia.carbon.storage.ChatUser;
|
import net.draycia.carbon.storage.ChatUser;
|
||||||
import net.kyori.adventure.text.Component;
|
import net.kyori.adventure.text.Component;
|
||||||
import org.bukkit.entity.Player;
|
import org.bukkit.entity.Player;
|
||||||
|
|
||||||
|
import java.util.LinkedHashMap;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
@CommandAlias("reply|r")
|
@CommandAlias("reply|r")
|
||||||
@CommandPermission("carbonchat.reply")
|
@CommandPermission("carbonchat.reply")
|
||||||
public class ReplyCommand extends BaseCommand {
|
public class ReplyCommand {
|
||||||
|
|
||||||
@Dependency
|
private final CarbonChat carbonChat;
|
||||||
private CarbonChat carbonChat;
|
|
||||||
|
|
||||||
@Default
|
public ReplyCommand(CarbonChat carbonChat) {
|
||||||
@Syntax("<message>")
|
this.carbonChat = carbonChat;
|
||||||
public void baseCommand(Player player, String... args) {
|
|
||||||
if (args.length == 0) {
|
LinkedHashMap<String, Argument> arguments = new LinkedHashMap<>();
|
||||||
return;
|
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);
|
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) {
|
if (user.getReplyTarget() == null) {
|
||||||
String message = carbonChat.getLanguage().getString("no-reply-target");
|
String message = carbonChat.getLanguage().getString("no-reply-target");
|
||||||
Component component = carbonChat.getAdventureManager().processMessage(message, "br", "\n");
|
Component component = carbonChat.getAdventureManager().processMessage(message, "br", "\n");
|
||||||
user.sendMessage(component);
|
user.sendMessage(component);
|
||||||
|
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
ChatUser targetUser = carbonChat.getUserService().wrap(user.getReplyTarget());
|
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 ToggleCommand());
|
||||||
this.commandManager.registerCommand(new ChannelCommand());
|
this.commandManager.registerCommand(new ChannelCommand());
|
||||||
this.commandManager.registerCommand(new ChannelListCommand());
|
this.commandManager.registerCommand(new ChannelListCommand());
|
||||||
@@ -89,7 +89,7 @@ public class CommandManager {
|
|||||||
this.commandManager.registerCommand(new MeCommand());
|
this.commandManager.registerCommand(new MeCommand());
|
||||||
this.commandManager.registerCommand(new MessageCommand());
|
this.commandManager.registerCommand(new MessageCommand());
|
||||||
this.commandManager.registerCommand(new NicknameCommand());
|
this.commandManager.registerCommand(new NicknameCommand());
|
||||||
this.commandManager.registerCommand(new ReplyCommand());
|
new ReplyCommand(carbonChat);
|
||||||
this.commandManager.registerCommand(new SetColorCommand());
|
this.commandManager.registerCommand(new SetColorCommand());
|
||||||
this.commandManager.registerCommand(new SpyChannelCommand());
|
this.commandManager.registerCommand(new SpyChannelCommand());
|
||||||
|
|
||||||
|
|||||||
@@ -145,3 +145,8 @@ redis:
|
|||||||
port: 6379
|
port: 6379
|
||||||
#password: 'password'
|
#password: 'password'
|
||||||
database: 0
|
database: 0
|
||||||
|
|
||||||
|
commands:
|
||||||
|
reply:
|
||||||
|
name: 'reply'
|
||||||
|
aliases: ['r']
|
||||||
@@ -21,6 +21,7 @@ available-channels-list: '<green>Available Channels:<reset> <list>.'
|
|||||||
unavailable-channels-list: '<red>Unavailable Channels:<reset> <list>.'
|
unavailable-channels-list: '<red>Unavailable Channels:<reset> <list>.'
|
||||||
channel-list-separator: ', '
|
channel-list-separator: ', '
|
||||||
user-must-be-online: '<red><player> must be online!'
|
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
|
# The following messages are compatible with PlaceholderAPI and MiniMessage/MineDown
|
||||||
me: '<italic><dark_purple>*<displayname> <reset><message>*</dark_purple></italic>'
|
me: '<italic><dark_purple>*<displayname> <reset><message>*</dark_purple></italic>'
|
||||||
|
|||||||
Reference in new issue
Block a user