Package com.github.zathrus_writer.commandsex.commands

Source Code of com.github.zathrus_writer.commandsex.commands.Command_cex_kickall

package com.github.zathrus_writer.commandsex.commands;

import org.bukkit.Bukkit;
import org.bukkit.ChatColor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import com.github.zathrus_writer.commandsex.helpers.LogHelper;
import com.github.zathrus_writer.commandsex.helpers.Utils;

public class Command_cex_kickall {

  /***
   * KICKALL - Kicks all players without permission from the server, with customizable message
   * @param sender
   * @param args
   * @return
   */
 
  public static Boolean run(CommandSender sender, String alias, String[] args){
   
    if (sender instanceof Player){
      Player player = (Player) sender;
      if (Utils.checkCommandSpam(player, "cex_kickall")){
        return true;
      }
    }
   
    if (!(sender instanceof Player) || sender.hasPermission("cex.kickall")){
      String kickMsg = "kickAllSuccess";
      if (args.length > 0) {
        kickMsg = "kickAllSuccessReason#####[" + " " + kickMsg + Utils.implode(args, " ");
      }
     
      for (Player player : Bukkit.getOnlinePlayers()){
        if (!player.hasPermission("cex.bypass.kick") && player != sender){
          player.kickPlayer(kickMsg);
        }
      }

      LogHelper.showInfo("kickAllSuccessReason#####[" + " " + kickMsg, sender, ChatColor.GREEN);
    }
   
    return true;
  }
 
}
TOP

Related Classes of com.github.zathrus_writer.commandsex.commands.Command_cex_kickall

TOP
Copyright © 2018 www.massapi.com. All rights reserved.
All source code are property of their respective owners. Java is a trademark of Sun Microsystems, Inc and owned by ORACLE Inc. Contact coftware#gmail.com.