Package com.killruana.zcraft.administration

Source Code of com.killruana.zcraft.administration.KillBanCommand

package com.killruana.zcraft.administration;

import org.bukkit.Location;
import org.bukkit.command.Command;
import org.bukkit.command.CommandExecutor;
import org.bukkit.command.CommandSender;
import org.bukkit.entity.Player;

import com.killruana.zcraft.ZCraftPlugin;
import com.killruana.zcraft.divers.Textes;

public class KillBanCommand implements CommandExecutor
{
    private final ZCraftPlugin plugin;

    public KillBanCommand(ZCraftPlugin plugin) {
        this.plugin = plugin;
    }

    public boolean onCommand(CommandSender sender, Command command, String label, String[] args)
    {
      Player lanceur = (Player) sender;

        // T'as pas les droits, tu lances pas
      if (!lanceur.hasPermission("zcraft.administration.kban"))
      {
          lanceur.sendMessage(Textes.pas_les_droits);
            return true;
        }

        // On vérifie qu'il y a bien un argument
        if (args.length != 1)
        {
            return false;
        }

       
        Player cible = plugin.getServer().getPlayer(args[0]);
        if (cible == null)
        {
                lanceur.sendMessage("Ce joueur n'existe pas");
                return true;
        }

        Location locLanceur = lanceur.getLocation();
        cible.teleport(locLanceur);
        cible.setHealth(0);
        cible.setBanned(true);
        cible.kickPlayer("Le gourdin du bannissement a frappé !");
        String pseudoLanceur = lanceur.getDisplayName();
        String pseudoCible = cible.getDisplayName();
        lanceur.getServer().broadcastMessage(pseudoLanceur+" a banni "+pseudoCible);
     
        return true;
    }
}
TOP

Related Classes of com.killruana.zcraft.administration.KillBanCommand

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.