package com.alttd.chat.commands; import com.alttd.chat.ChatPlugin; import com.alttd.chat.config.Config; import com.alttd.chat.managers.ChatUserManager; import com.alttd.chat.util.Utility; import org.bukkit.command.Command; import org.bukkit.command.CommandExecutor; import org.bukkit.command.CommandSender; import org.bukkit.entity.Player; import org.bukkit.scheduler.BukkitRunnable; import org.jetbrains.annotations.NotNull; import java.util.UUID; public class ToggleGlobalChat implements CommandExecutor { @Override public boolean onCommand(@NotNull CommandSender sender, @NotNull Command command, @NotNull String label, String[] args) { if (!(sender instanceof Player)) { return true; } new BukkitRunnable() { @Override public void run() { UUID uuid = ((Player) sender).getUniqueId(); ChatUserManager.getChatUser(uuid); Utility.flipPermission(uuid, Config.GCPERMISSION); sender.sendRichMessage("You have turned globalchat " + (!Utility.hasPermission(uuid, Config.GCPERMISSION) ? "on." : "off.")); // TODO load from config and minimessage } }.runTaskAsynchronously(ChatPlugin.getInstance()); return false; } }