Help

Status
This thread has been locked.

Glitch1

Uhhhhhhhh yeaaaaaaaaaa
Banned
Feedback score
0
Posts
163
Reactions
27
Resources
0
so i've created a plugin but it did no work the way i wanted it to so i made a plugin which when i type /thor it would give me a golden hoe and then when i left click it would strike lightning but then the problem comes in game when i type /thor it only strikes lightning so someone please fix my code thanks :D
Main core
Code:
package me.glitches.effects;

import org.bukkit.plugin.java.JavaPlugin;

public class Core extends JavaPlugin {
   
    @Override
    public void onEnable() {
        getLogger().info(">> Plugin v" + getDescription().getVersion() +" is enabled!");
        getCommand("thor").setExecutor(new Thorshammer());
        getServer().getPluginManager().registerEvents(new AbilityUse(this), (this));
    }

    @Override
    public void onDisable() {
        getLogger().info(">> Plugin v" + getDescription().getVersion() +" is disabled!");
    }
}
Lightning ability
Code:
package me.glitches.effects;

import java.util.Set;

import org.bukkit.Material;
import org.bukkit.entity.Player;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.player.PlayerInteractEvent;

public class AbilityUse implements Listener {
   
    public AbilityUse(Core core) {
    }

    @EventHandler
    public void onUse(PlayerInteractEvent event) {
        Player p = event.getPlayer();
            if(event.getItem().getItemMeta().getDisplayName().contains("Thor's Hammer")) {
                p.getWorld().strikeLightning(p.getTargetBlock((Set<Material>)null, 25).getLocation());
               
            }                   
        }
    }
Creating the golden hoe
Code:
package me.glitches.effects;

import java.util.ArrayList;
import java.util.List;

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.entity.Player;
import org.bukkit.inventory.ItemStack;
import org.bukkit.inventory.meta.ItemMeta;

public class Thorshammer implements CommandExecutor{

    @Override
    public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args) {
        if(sender instanceof Player) {
            if(label.equalsIgnoreCase("thor")) {
                Player p = (Player)sender;
                    ItemStack i = new ItemStack(Material.GOLD_HOE);
                    ItemMeta meta = i.getItemMeta();
                    List<String> lore = new ArrayList<String>();
                    lore.add(ChatColor.DARK_AQUA + ChatColor.BOLD.toString() + "Thor's hammer");
                    lore.add("Testing");
                    lore.add("lol");
                    lore.add("Line with a space");
                    lore.add(ChatColor.DARK_PURPLE + ChatColor.ITALIC.toString() + "Effect:");
                    lore.add(ChatColor.AQUA + ChatColor.BOLD.toString() + "p" + ChatColor.GRAY + "Smite your foes!");
                    meta.setLore(lore);
                    meta.setDisplayName(ChatColor.DARK_PURPLE + ChatColor.BOLD.toString() + "Thor's Hammer");
                    i.setItemMeta(meta);
                    p.getInventory().addItem(i);
                    return true;
            }
        }
        return false;
    }

}
 
PebbleHost
High performance, consistent uptime and fast support. Minecraft hosting that just works.

Tehker

Schleep
Premium
Feedback score
26
Posts
1,175
Reactions
307
Resources
0
Just curious, but there is also a power tool thing that does /Thor too. Could that be the problem? I'm an idiot when it comes to this, but I'm just suspecting it's because of the command "/Thor" which strikes lightning.
 

Glitch1

Uhhhhhhhh yeaaaaaaaaaa
Banned
Feedback score
0
Posts
163
Reactions
27
Resources
0
I know but I'm a beginner on this so then i just wanted to do small coding like that
 
Banned forever. Reason: Scamming (https://builtbybit.com/threads/glitch-scam-report.96253/)

Tyler

Developer
Supreme
Feedback score
14
Posts
2,589
Reactions
2,238
Resources
0
I know but I'm a beginner on this so then i just wanted to do small coding like that
he's saying there's something with essentials that will strike lightning when you use /thor. is essentials on the server you are testing your plugin on?
 

Glitch1

Uhhhhhhhh yeaaaaaaaaaa
Banned
Feedback score
0
Posts
163
Reactions
27
Resources
0
oh
i did not notice that
 
Banned forever. Reason: Scamming (https://builtbybit.com/threads/glitch-scam-report.96253/)

Isaiah

Developer
Premium
Feedback score
4
Posts
76
Reactions
39
Resources
1
Instead of having your loggers you could switch the to system.out.print.("Plugin is being enabled"),and not use the version and desc of the plugin, that loads up the console if every plugin on there made by you had the ver and desc. Or you could not add that since Java tells the console that the plugin is being started.
Just a suggestion :)
 
Status
This thread has been locked.
Top