Solved Help! How to kick command sender

Discussion in 'Plugin Development' started by Just_Niico, Apr 26, 2015.

Thread Status:
Not open for further replies.
  1. Offline

    Just_Niico

    Code:
    package com.nico.marsragequit;
    
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.java.JavaPlugin;
    
    public class Main extends JavaPlugin{
            public void onEnable(){
                    getLogger().info("Plugin Enabled!");
            }
         
            public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
                    if(cmd.getName().equalsIgnoreCase("ragequit")){
                            if(sender instanceof Player){
                                getServer( ).broadcastMessage( "ChatColor.DARKRED + player.getName() + ChatColor.RED + has ragequit!" );
                            }else{
                                    sender.sendMessage(ChatColor.GREEN + "This is the console.");
                            }
                    }
                 
                    return false;
            }
    }
    
    I'm a noob at coding and am trying to make a plugin when a player type /ragequit it says that they ragequit in chat. I've done that part, I just need to know how to kick the player :(
     
  2. @Just_Niico You don't need the logger on enable. That broadcast will say
    ChatColor.DARKRED + player.getName() + ChatColor.RED + has ragequit!

    Exactly like that. You need to add in the quotation marks.
     
  3. Offline

    Just_Niico

    @bwfcwalshy Yes, but how do I make it when someone does /ragequit they get kicked?
     
  4. Offline

    TehHypnoz

    After you have checked if the sender is a player:

    Code:
    Player p = (Player) sender;
    p.kickPlayer("Reason");
    
     
  5. Offline

    Zombie_Striker

  6. Offline

    Just_Niico

    Thanks, all is working now :D
     
Thread Status:
Not open for further replies.

Share This Page