Wont find my main class! Help please!

Discussion in 'Spigot Plugin Help' started by Chriisto, Jun 11, 2017.

  1. Ok, so I tried to create an anti-swear plugin and this is all my code... anyone know why I'm getting a console error that says: cannot find main class 'me.Christo.AntiCurse.Main

    Main.Java
    package me.Christo.AntiCurse;

    import org.bukkit.Bukkit;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.AsyncPlayerChatEvent;
    import org.bukkit.plugin.java.JavaPlugin;

    import net.md_5.bungee.api.ChatColor;

    public class Main extends JavaPlugin implements Listener {

    @EventHandler
    public void onPlayerChat(AsyncPlayerChatEvent e) {
    for (String word : e.getMessage().split(" ")) {
    if (getConfig().getStringList("badwords").contains(word)) {
    e.setCancelled(true);
    e.getPlayer().sendMessage(ChatColor.RED + "Cursing is not allowed!");
    }
    }
    }


    public void onEnabled() {
    getConfig().options().copyDefaults(true);
    saveConfig();
    Bukkit.getServer().getPluginManager().registerEvents(this, this);

    }

    }


    Config.yml
    badwords:
    - lol
    - hi

    Plugin.yml

    name: NoCurse
    main: me.Christo.AntiCurse.Main
    version: 1.0




    Please help and thanks!
    I also don't know how to use Rich Text Editor soo, all the spaces are there but if you can please correct me!
     
  2. Well first of all, your packages are technically named incorrectly. They should be all lower-cased. As for the error, is it possible your Main.java is actually main.java? Something as simple as that will cause an error as such.
     
  3. The only thing that shlould be in caps in plugin.yml is Main
     
  4. Ok it is not cancelling the word in chat, it's just not working in general
    Main.Java
    package me.Christo.AntiCurse;

    import org.bukkit.Bukkit;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.AsyncPlayerChatEvent;
    import org.bukkit.plugin.java.JavaPlugin;

    import net.md_5.bungee.api.ChatColor;

    public class Main extends JavaPlugin implements Listener {

    @EventHandler
    public void onPlayerChat(AsyncPlayerChatEvent e) {
    for (String word : e.getMessage().split(" ")) {
    if (getConfig().getStringList("badwords").contains(word)) {
    e.setCancelled(true);
    e.getPlayer().sendMessage(ChatColor.RED + "Cursing is not allowed!");
    }
    }
    }


    public void onEnabled() {
    getConfig().options().copyDefaults(true);
    saveConfig();
    Bukkit.getServer().getPluginManager().registerEvents(this, this);

    }

    }