2021-07-30 21:23:16 +00:00
package com.alttd.chat.commands ;
import com.alttd.chat.ChatPlugin ;
import com.alttd.chat.config.Config ;
import com.alttd.chat.util.Utility ;
import net.kyori.adventure.text.minimessage.MiniMessage ;
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 java.util.UUID ;
public class MuteServer implements CommandExecutor {
@Override
public boolean onCommand ( CommandSender sender , Command command , String label , String [ ] args ) {
if ( ! ( sender instanceof Player ) ) { // must be a player
return true ;
}
new BukkitRunnable ( ) {
@Override
public void run ( ) {
UUID uuid = ( ( Player ) sender ) . getUniqueId ( ) ;
if ( ! Utility . hasPermission ( uuid , Config . SERVERMUTEPERMISSION ) ) {
2021-07-31 21:27:29 +00:00
sender . sendMessage ( MiniMessage . get ( ) . parse ( " <red>You don't have permission to use this command.</red> " ) ) ;
2021-07-30 21:23:16 +00:00
return ;
}
ChatPlugin . getInstance ( ) . toggleServerMuted ( ) ;
2021-07-31 01:46:37 +00:00
sender . sendMessage ( MiniMessage . get ( ) . parse ( " You have " + ( ! Utility . hasPermission ( uuid , Config . GCPERMISSION ) ? " <green>muted</green> " : " <red>unmuted</red> " ) + " chat for this server. " ) ) ; // TODO load from config and minimessage
2021-07-30 21:23:16 +00:00
}
} . runTaskAsynchronously ( ChatPlugin . getInstance ( ) ) ;
return false ;
}
}