Solved Can't solve the problem

Discussion in 'Plugin Development' started by da_Do, Mar 31, 2018.

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


    Hi guys,
    i have this code :

    package me.david.src.blockevent;

    import org.bukkit.Material;
    import org.bukkit.block.Block;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.BlockBreakEvent;

    public class BreakBlock extends JavaPlugin implements Listener {

    public void onBlockBreak(BlockBreakEvent event) {
    Player player = event.getPlayer();

    Block block = event.getBlock();
    Material material = block.getType();

    if(material != Material.GRASS) {
    player.sendMessage("U can't break");

    and Main is here :

    package me.david.src;

    import org.bukkit.plugin.PluginManager;

    import me.david.src.blockevent.BreakBlock;
    import me.david.src.commands.Goodbye;
    import me.david.src.commands.Hello;

    public class Main extends JavaPlugin {

    public void onEnable() {
    getLogger().info("Plugin Enabled");

    public void onDisable() {
    getLogger().info("Plugin Disabled");

    public void registerCommands() {
    getCommand("hello").setExecutor(new Hello());
    getCommand("goodbye").setExecutor(new Goodbye());

    public void registerEvents() {
    PluginManager pm = getServer().getPluginManager();

    pm.registerEvents(new BreakBlock(), this);

    i have no errors, in console . Can someone help me ? Thanks
  2. 1) Only the Main class should extend JavaPlugin
    2) You need to be calling registerEvents() in onEnable. Currently it's not being called

    Sent from my SM-G903F using Tapatalk
  3. Offline


    thanks , i will try it

    okey, its working, thank you

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
    Last edited by a moderator: Mar 31, 2018
Thread Status:
Not open for further replies.

Share This Page