Plugin Already Intiliazed with 2 totaly different plugins?!

Discussion in 'Spigot Plugin Development' started by xerminator, Apr 6, 2019.

  1. I am new to Spigot/Bukkit coding. I have a lot of knowledge of Java and currently still learning it, but for some reason when I want to test my own 2 made plugins I can only use 1 out of the 2 everytime.



    Plugin 1:

    Main:
    Code (Java):
    package iofkrautils.main;

    import org.bukkit.Bukkit;
    import org.bukkit.ChatColor;
    import org.bukkit.command.ConsoleCommandSender;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.java.JavaPlugin;

    import commands.gamemode.adventure;
    import commands.gamemode.creative;
    import commands.gamemode.spectator;
    import commands.gamemode.survival;
    import commands.teleport.TeleportRequest;

    public class Main extends JavaPlugin {
       
        //get plugin.yml
        PluginDescriptionFile pdf = this.getDescription();
        ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
        public void onEnable() {
            console.sendMessage(ChatColor.GREEN + "[" + pdf.getName() + "] " + "has been enabled");
           
            /* Resitering Executors */
           
            TeleportRequest tprequest = new TeleportRequest();
           
            /* Registering Commands and set the right Executor for it */
            this.getCommand("survival").setExecutor(new survival());
            this.getCommand("creative").setExecutor(new creative());
            this.getCommand("adventure").setExecutor(new adventure());
            this.getCommand("spectator").setExecutor(new spectator());
            this.getCommand("tpa").setExecutor(tprequest);
            this.getCommand("tpaccept").setExecutor(tprequest);
            this.getCommand("tpdeny").setExecutor(tprequest);
        }
       
        public void onDisable() {
            console.sendMessage(ChatColor.GREEN + "[" + pdf.getName() + "] " + "has been disabled");
        }
       
    }
     
    plugin.yml
    Code (YAML):
    #Plugin.yml IofkraUtils
    #Author: xerminator

    main
    : iofkrautils.main.Main
    name
    : IofkraUtils
    version
    : 1.1.3
    description
    : Utils pluign for the Iofkra Server
    commands
    :
       survival
    :
          description
    : Change your or someone else gamemode to survival
       creative
    :
          description
    : Change your or someone else gamemode to creative
       adventure
    :
          description
    : Change your or someone else gamemode to adventure
       spectator
    :
          description
    : Change your or someone else gamemode to spectator
       tpa
    :
          description
    : Send a teleport request
       tpaccept
    :
          description
    : Accept a incoming teleport request
       tpdeny
    :
          description
    : Deny a incoming teleport request

    Plugin 2:
    Main:
    Code (Java):
    package sleepfixer.main;

    import org.bukkit.Bukkit;
    import org.bukkit.command.ConsoleCommandSender;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.java.JavaPlugin;

    import sleepfixer.event.sleeping.SleepListener;

    public class Main extends JavaPlugin {
        PluginDescriptionFile pdf = this.getDescription();
        ConsoleCommandSender console = Bukkit.getServer().getConsoleSender();
        public void onEnable() {
            console.getServer().getConsoleSender().sendMessage(
                pdf.getName() + pdf.getVersion() + " has been enabled!"
            );
           
            /* Register Events*/
            getServer().getPluginManager().registerEvents(new SleepListener(), this);
        }
       
        public void onDisable() {
            console.getServer().getConsoleSender().sendMessage(
                pdf.getName() + pdf.getVersion() + " has been disabled!"
            );
        }
       
       
       
    }
     
    plugin.yml
    Code (YAML):
    #Plugin.yml SleepFIxer plugin
    #author: xerminator

    main
    : sleepfixer.main
    name
    : SleepFixer
    version
    : 1.5
    description
    : SleepFixer for Iofkra Server
    Please someone explain why this is happening...
     
  2. `sleepfixer.main` in your second plugin.yml should be `sleepfixer.main.Main`
    Either way, post the stacktrace so we can help you further.
     
    • Winner Winner x 1
  3. make sure in either of the plugins you dont have "Main main = new Main();" or similar anywhere, instead use dependency injection.
     
    • Informative Informative x 1
  4. Strahan

    Benefactor

    I've never made a plugin where "Main" was the main class. That just seems silly to me. I use the plugin name as the main class. Especially since my package is the same for all my plugins; using "Main" would not end well.

    PS: Sending enable and disable messages is pointless; Spigot does that already for you.
     
    • Informative Informative x 1
  5. It was just for test and learning purposes anyway. Thanks for the advice on how to name my packages and stuff though
     
  6. I am not doing that anywhere. As you can see in my code
     
  7. Wow thanks, didn't notice that xd. It works now thanks
     

Share This Page