Plugin error?

Discussion in 'Plugin Development' started by Olivewhelmed, May 4, 2021.

  1. Offline


    My plugins show up in the server if I do /plugins, if I try using them they won't work. I tried using other plugins too but only one of them worked.


    package me.olive.Listeners;
    import me.olive.Listeners.join.JoinListener;
    public class Main extends JavaPlugin {
        public void onEnable() {
            new JoinListener(this);
    package me.olive.Listeners.join;
    import org.bukkit.Bukkit;
    import org.bukkit.entity.Player;
    import org.bukkit.event.EventHandler;
    import org.bukkit.event.Listener;
    import org.bukkit.event.player.PlayerJoinEvent;
    import me.olive.Listeners.Main;
    import me.olive.Listeners.utils.Utils;
    public class JoinListener implements Listener {
        private Main plugin;
        public JoinListener(Main plug) {
            this.plugin = plugin;
            Bukkit.getPluginManager().registerEvents(this, plugin);
        public void onJoin(PlayerJoinEvent e) {
            Player p = e.getPlayer();
            if (!p.hasPlayedBefore()) {
              "firstjoin_message").replace("<player>", p.getName())));
            }  else {
                Bukkit.broadcastMessage("firstjoin_message").replace("<player>", p.getName())));
    package me.olive.Listeners.utils;
    import org.bukkit.ChatColor;
    public class Utils {
        public static String chat (String s) {
            return ChatColor.translateAlternateColorCodes('&', s);
    firstJoin_message: '&a<player> &7has joined the server for the first time!'
    join_message: '&e<player> &7has joined the server!' 
    name: Listeners
    version: 1.0
    author: Olive
    main: me.olive.Listeners.Main
    description: sends message when joining
    Does anyone know how to fix this?
  2. Offline

    timtower Administrator Administrator Moderator

    public JoinListener(Main plug) {
    this.plugin = plugin;
    Look at the names.
    Kars likes this.
  3. Offline


    An IDE should tell you this before you even try to build the jar and should even stop (at least in IntelliJ) before you are able to completely finish the build. What are you using to write code in?...

    Edit: Ahh nvd, the compiler thinks that you are using the same plugin variable...but still. The IDE shows that to you. You should definitly read the errors before trying to use the plugin (not all errors are important tho but that should have been obvious)
  4. Offline


    Sorry, I'm new to making plugins, could you tell me what kind of errors are in the code? This is actually my first project:D
  5. Offline


    You are declaring a object variable of type Main with name plugin
    You declare a local variable of type Main with name plug
    You do not call plug here but plugin twice so the not initialised object variable gets assigned to itself
    For the IDE part: It should notably change the color of an unused variable so you can see when a variable doesn't get used. Smarter IDEs (like IntelliJ) would also show you that your are assigning a variable to itself

Share This Page