Plugin doesn't work, no errors in console.

Discussion in 'Plugin Development' started by endistic, Nov 21, 2021.

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

    endistic

    Hi Bukkit People,

    I'm having a problem. I'm trying to do code in my plugin, but it just doesn't work. Whenever I check console, there's no errors. All I know is that stuff isn't running. Any ideas on what to do?
    JavaPlugin Content (open)

    package main;

    import java.util.HashMap;
    import commands.TestCommand;

    import org.bukkit.Bukkit;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.block.BlockBreakEvent;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;

    public class Main extends JavaPlugin implements Listener {

    public static Main instance;

    public void OnEnable() {
    Main.instance = this;

    PluginManager m = getServer().getPluginManager();
    m.registerEvents(this, this);

    System.out.println(instance.toString());
    System.out.println("okay");
    getCommand("test").setExecutor(new TestCommand());
    }


    public void OnDisable() {
    System.out.println("Disabling plugin.");
    }

    @EventHandler
    public void onBlockBreak(BlockBreakEvent event) {
    Bukkit.broadcastMessage("hey lol");
    event.setCancelled(true);
    }

    public void saveHashMap(HashMap<String, String> hm, String hashName) {
    // Map<String, Object> someMap = new HashMap<String, Object>();
    for (Object key : hm.keySet()) {
    this.getConfig().set(hashName + "."+key, hm.get(key));
    }
    saveConfig();
    }

    public HashMap<String, String> loadHashMap(String hashName) {
    HashMap<String, String> hm = new HashMap<String, String>();

    for (String key : this.getConfig().getConfigurationSection(hashName).getKeys(false)) {
    hm.put(key, (String) this.getConfig().get(hashName + "."+key));
    }
    return hm;
    }
    }


    plugin.yml (open)

    name: Celestial
    main: main.Main
    author: Endistic
    version: 1.0
    api-version: 1.17
    description: Project Celestial.

    commands:
    test:
    description: okay
     
    Last edited by a moderator: Nov 21, 2021
  2. Online

    timtower Administrator Administrator Moderator

    endistic likes this.
Thread Status:
Not open for further replies.

Share This Page