mirror of
https://github.com/darksaid98/Carbon.git
synced 2026-12-02 22:16:22 +00:00
Progress on CarbonChat-Common
This commit is contained in:
1 parent
508ad88e26
commit
64295c84ea
60 files changed
+889
-556
No files matched your search
+19
-11
@@ -7,13 +7,14 @@ 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.CarbonChat;
|
||||
import net.draycia.carbon.CarbonChatBukkit;
|
||||
import net.kyori.adventure.audience.Audience;
|
||||
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;
|
||||
@@ -21,9 +22,9 @@ import java.util.LinkedHashMap;
|
||||
public class ShadowMuteCommand {
|
||||
|
||||
@NonNull
|
||||
private final CarbonChat carbonChat;
|
||||
private final CarbonChatBukkit carbonChat;
|
||||
|
||||
public ShadowMuteCommand(@NonNull final CarbonChat carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
public ShadowMuteCommand(@NonNull final CarbonChatBukkit carbonChat, @NonNull final CommandSettings commandSettings) {
|
||||
this.carbonChat = carbonChat;
|
||||
|
||||
if (!commandSettings.enabled()) {
|
||||
@@ -44,35 +45,42 @@ public class ShadowMuteCommand {
|
||||
}
|
||||
|
||||
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 Audience audience = this.carbonChat.adventureManager().audiences().audience(sender);
|
||||
|
||||
final OfflinePlayer player = Bukkit.getOfflinePlayer(user.uuid());
|
||||
|
||||
if (user.shadowMuted()) {
|
||||
user.shadowMuted(false);
|
||||
final String format = this.carbonChat.language().getString("no-longer-shadow-muted");
|
||||
final String format = this.carbonChat.translations().noLongerShadowMuted();
|
||||
|
||||
final Component message = this.carbonChat.adventureManager().processMessage(format, "br", "\n",
|
||||
final Component message = this.carbonChat.messageProcessor().processMessage(format, "br", "\n",
|
||||
"player", player.getName());
|
||||
|
||||
audience.sendMessage(message);
|
||||
cmdSender.sendMessage(message);
|
||||
} else {
|
||||
Bukkit.getScheduler().runTaskAsynchronously(this.carbonChat, () -> {
|
||||
final Permission permission = this.carbonChat.permission();
|
||||
final String format;
|
||||
|
||||
if (permission.playerHas(null, player, "carbonchat.shadowmute.exempt")) {
|
||||
format = this.carbonChat.language().getString("shadow-mute-exempt");
|
||||
format = this.carbonChat.translations().shadowMuteExempt();
|
||||
} else {
|
||||
user.shadowMuted(true);
|
||||
format = this.carbonChat.language().getString("is-now-shadow-muted");
|
||||
format = this.carbonChat.translations().nowShadowMuted();
|
||||
}
|
||||
|
||||
final Component message = this.carbonChat.adventureManager().processMessage(format, "br", "\n",
|
||||
final Component message = this.carbonChat.messageProcessor().processMessage(format, "br", "\n",
|
||||
"player", player.getName());
|
||||
|
||||
audience.sendMessage(message);
|
||||
cmdSender.sendMessage(message);
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Reference in new issue
Block a user