mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-02 14:38:49 +00:00
Add reply command and system
This commit is contained in:
1 parent
fe70cf82bc
commit
97355f0ce2
5 files changed
+85
-22
No files matched your search
@@ -29,28 +29,7 @@ public class MessageCommand extends BaseCommand {
|
||||
return;
|
||||
}
|
||||
|
||||
if (simpleChat.playerHasPlayerIgnored(targetPlayer, player)) {
|
||||
return;
|
||||
}
|
||||
|
||||
String message = String.join(" ", args);
|
||||
|
||||
String toPlayerFormat = simpleChat.getConfig().getString("language.message-to-other");
|
||||
String fromPlayerFormat = simpleChat.getConfig().getString("language.message-from-other");
|
||||
|
||||
Component toPlayerComponent = MiniMessage.instance().parse(toPlayerFormat, "message", message,
|
||||
"target", targetPlayer.getName());
|
||||
|
||||
Component fromPlayerComponent = MiniMessage.instance().parse(fromPlayerFormat, "message", message,
|
||||
"sender", player.getName());
|
||||
|
||||
simpleChat.getAudiences().player(player).sendMessage(toPlayerComponent);
|
||||
|
||||
if (targetPlayer.isOnline()) {
|
||||
simpleChat.getAudiences().player(targetPlayer.getPlayer()).sendMessage(fromPlayerComponent);
|
||||
} else {
|
||||
// TODO: cross server msg support, don't forget to include /ignore support
|
||||
}
|
||||
simpleChat.sendPlayerPrivateMessage(player, targetPlayer, String.join(" ", args));
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,40 @@
|
||||
package net.draycia.simplechat.commands;
|
||||
|
||||
import co.aikar.commands.BaseCommand;
|
||||
import co.aikar.commands.annotation.CommandAlias;
|
||||
import co.aikar.commands.annotation.CommandPermission;
|
||||
import co.aikar.commands.annotation.Default;
|
||||
import net.draycia.simplechat.SimpleChat;
|
||||
import net.kyori.adventure.text.Component;
|
||||
import net.kyori.adventure.text.minimessage.MiniMessage;
|
||||
import org.bukkit.Bukkit;
|
||||
import org.bukkit.entity.Player;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
@CommandAlias("reply|r")
|
||||
@CommandPermission("simplechat.reply")
|
||||
public class ReplyCommand extends BaseCommand {
|
||||
|
||||
private SimpleChat simpleChat;
|
||||
|
||||
public ReplyCommand(SimpleChat simpleChat) {
|
||||
this.simpleChat = simpleChat;
|
||||
}
|
||||
|
||||
@Default
|
||||
public void baseCommand(Player player, String... args) {
|
||||
UUID target = simpleChat.getPlayerReply(player.getUniqueId());
|
||||
|
||||
if (target == null) {
|
||||
String message = simpleChat.getConfig().getString("language.no-reply-target");
|
||||
Component component = MiniMessage.instance().parse(message);
|
||||
simpleChat.getAudiences().player(player).sendMessage(component);
|
||||
|
||||
return;
|
||||
}
|
||||
|
||||
simpleChat.sendPlayerPrivateMessage(player, Bukkit.getOfflinePlayer(target), String.join(" ", args));
|
||||
}
|
||||
|
||||
}
|
||||
Reference in new issue
Block a user