Question Lightning on right-click?

Discussion in 'Plugin Help/Development/Requests' started by Exellanix, Jan 23, 2016.

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


    I'm new to developing plugins and I decided to make a kit pvp plugin for my server. I want a Zeus kit. I want it so the if you right-click a diamond axe it would strike lightning at the player or the ground where you're looking. Can someone help me with the code?

    Here is the Zeus class:

    package me.exellanix.kitpvp.commands;
    import org.bukkit.ChatColor;
    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.enchantments.Enchantment;
    import org.bukkit.entity.Player;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.PlayerInventory;
    public class Zeus implements CommandExecutor {
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
            if (label.equalsIgnoreCase("zeus"))
                if (!(sender instanceof Player)) {
                    sender.sendMessage("You must be a player to execute this command!");
                    return false;
            Player player = (Player) sender;
            PlayerInventory inv = player.getInventory();
            // clears player inv
            ItemStack diamondAxe = new ItemStack(Material.DIAMOND_AXE);
            ItemStack mushroomStew = new ItemStack(Material.MUSHROOM_SOUP, 35);
            ItemStack ironHelmet = new ItemStack(Material.DIAMOND_SWORD);
            ItemStack ironChestplate = new ItemStack(Material.DIAMOND_SWORD);
            ItemStack ironLeggings = new ItemStack(Material.DIAMOND_SWORD);
            ItemStack ironBoots = new ItemStack(Material.DIAMOND_SWORD);
            diamondAxe.addEnchantment(Enchantment.DAMAGE_ALL, 2);
            inv.addItem(diamondAxe, mushroomStew);
            player.sendMessage(ChatColor.GOLD + "You have chosen the kit " + ChatColor.YELLOW + "Zeus");
            return true;
  2. Offline


    Here you are the event of right clicking with a diamond axe:
        public void onPlayerInteract(PlayerInteractEvent e) {
            Player p = e.getPlayer();
            if(p.getItemInHand().getType() == Material.DIAMOND_AXE && (e.getAction() == Action.RIGHT_CLICK_BLOCK || e.getAction() == Action.RIGHT_CLICK_AIR)) {
                int MaxRange = 25;
                for(Block b : p.getLineOfSight((HashSet<Byte>) null, MaxRange)) {
                    if(b.getType() != Material.AIR) {
    Last edited: Jan 29, 2016
  3. Offline


    Thank you so much!
    But now how can I add a cool down of like 20 seconds?
  4. Offline


Thread Status:
Not open for further replies.

Share This Page