Main.java
package me.gideon.chatbot;
import org.bukkit.plugin.java.JavaPlugin;
public final class ChatBot extends JavaPlugin {
@Override
public void onEnable() {
System.out.println("Help me please!!!");
getServer().getPluginManager().registerEvent(new BreakBlock(), this);
}
@Override
public void onDisable() {
// Plugin shutdown logic
}
}
and
BreakBlock.java
package me.gideon.chatbot;
import org.bukkit.Material;
import org.bukkit.block.Block;
import org.bukkit.event.EventHandler;
import org.bukkit.event.Listener;
import org.bukkit.event.block.BlockBreakEvent;
import org.bukkit.inventory.ItemStack;
public class BreakBlock implements Listener {
@EventHandler
public void onPlayerBreakBlock(BlockBreakEvent event)
{
Block blockBroken = event.getBlock();
if(blockBroken.getType() == Material.DIAMOND_ORE)
{
event.setCancelled(true);
blockBroken.setType(Material.DIRT);
ItemStack diamonds = new ItemStack(Material.DIAMOND, 2);
blockBroken.getWorld().dropItemNaturally(blockBroken.getLocation(), diamonds);
}
}
}
It's erroring here: java getServer().getPluginManager().registerEvent(new BreakBlock(), this);
here is the console: no suitable method found for registerEvent(me.gideon.chatbot.BreakBlock,me.gideon.chatbot.ChatBot)
I haven't tried anything really, I'm super new... here is a link to the youtube video I'm following: https://www.youtube.com/watch?v=GK4aQzxQSoQ
registerEvents
notregisterEvent
note the extras
on the end. There is a method without thes
on the end, but it requires different parameters as shown in the APIregisterEvent(Event, Listener, EventPriority, EventExecutor, Plugin)
– sorifiend