Plugin won't start. Could not load TFlight

Discussion in 'BungeeCord Plugin Development' started by asenthd, Jun 5, 2017.

Thread Status:
Not open for further replies.
  1. Hey guys, I'm having another issue with my code. I can't get the plugin to load into my server.
    Code (Text):
    Command Class:


    package commands;

    import org.bukkit.Bukkit;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandExecutor;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.event.Listener;
    import net.md_5.bungee.api.ChatColor;
    import net.milkbowl.vault.economy.Economy;
    import net.milkbowl.vault.economy.EconomyResponse;
    import trollfaceryt.timedflygui.Core;

    public class TFlight implements CommandExecutor, Listener {

        Core config;

        private static Economy econ = null;

        public TFlight(Core plugin) {
            plugin.getServer().getPluginManager().registerEvents(this, plugin);
            config = plugin;
        }

        @Override
        public boolean onCommand(CommandSender sender, Command command, String label, String[] args) {
            if (label.equalsIgnoreCase("tfly"))
                if (args.length == 0 && sender instanceof Player) {
                    @SuppressWarnings("unused")
                    Player p = (Player) sender;
                }
            @SuppressWarnings("deprecation")
            int balance = (int) econ.getBalance(sender.getName());
            if (balance < config.getConfig().getInt("price")) {
                Bukkit.getPlayer(sender.getName()).sendMessage(ChatColor.RED + "Insufficient funds!");
            }else{
            }
            @SuppressWarnings({ "deprecation", "unused" })
            EconomyResponse r = econ.withdrawPlayer(sender.getName(), config.getConfig().getInt("price"));
            if (args.length == 0 && sender instanceof Player) {
                Player p = (Player) sender;
                p.setAllowFlight(true);
                sender.sendMessage(ChatColor.GREEN + "Flight has been purchased.");
            }
            return true;
        }
    }
    Code (Text):
    Core Class:

    package trollfaceryt.timedflygui;

    import org.bukkit.configuration.file.FileConfiguration;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.RegisteredServiceProvider;
    import org.bukkit.plugin.java.JavaPlugin;

    import net.milkbowl.vault.economy.Economy;


    @SuppressWarnings("unused")
    public class Core extends JavaPlugin {
        public static Economy econ = null;
       
        @Override
        public void onEnable() {
            FileConfiguration config = getConfig();
            this.getConfig().addDefault("price", 0);
            this.getConfig().options().copyDefaults(true);
            saveConfig();
            registerConfig();
            getConfig();
            getServer();
            getLogger().severe((" - Disabled due to no Vault dependency found!"));
            getServer().getPluginManager().disablePlugin(this);
            return;
        }

        private boolean setupEconomy() {
            if (getServer().getPluginManager().getPlugin("Vault") == null) {
                return false;
            }
            RegisteredServiceProvider<Economy> rsp = getServer().getServicesManager().getRegistration(Economy.class);
            if (rsp == null) {
                return false;
            }
            econ = rsp.getProvider();
            return econ != null;
        }

        private void registerConfig() {
        }

        public void onDisable() {
            saveConfig();

        }
    }
    Code (Text):
    Could not load 'plugins\CrazyAntiDupe.jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: Cannot find main class `trollfaceryt.crazyantidupe.Core'
            at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:66) ~[spigotmc-1.8.8-R0.1.jar:git-Spigot-e4d4710-e1ebe52]
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:131) ~[spigotmc-1.8.8-R0.1.jar:git-Spigot-e4d4710-e1ebe52]
            at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:329) ~[spigotmc-1.8.8-R0.1.jar:git-Spigot-e4d4710-e1ebe52]
            at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:251) [spigotmc-1.8.8-R0.1.jar:git-Spigot-e4d4710-e1ebe52]
            at org.bukkit.craftbukkit.v1_8_R3.CraftServer.loadPlugins(CraftServer.java:292) [spigotmc-1.8.8-R0.1.jar:git-Spigot-e4d4710-e1ebe52]
            at net.minecraft.server.v1_8_R3.DedicatedServer.init(DedicatedServer.java:198) [spigotmc-1.8.8-R0.1.jar:git-Spigot-e4d4710-e1ebe52]
            at net.minecraft.server.v1_8_R3.MinecraftServer.run(MinecraftServer.java:525) [spigotmc-1.8.8-R0.1.jar:git-Spigot-e4d4710-e1ebe52]
            at java.lang.Thread.run(Unknown Source) [?:1.8.0_131]
    Caused by: java.lang.ClassNotFoundException: trollfaceryt.crazyantidupe.Core
            at java.net.URLClassLoader.findClass(Unknown Source) ~[?:1.8.0_131]
            at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:101) ~[spigotmc-1.8.8-R0.1.jar:git-Spigot-e4d4710-e1ebe52]
            at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:86) ~[spigotmc-1.8.8-R0.1.jar:git-Spigot-e4d4710-e1ebe52]
            at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_131]
            at java.lang.ClassLoader.loadClass(Unknown Source) ~[?:1.8.0_131]
            at java.lang.Class.forName0(Native Method) ~[?:1.8.0_131]
            at java.lang.Class.forName(Unknown Source) ~[?:1.8.0_131]
            at org.bukkit.plugin.java.PluginClassLoader.<init>(PluginClassLoader.java:64) ~[spigotmc-1.8.8-R0.1.jar:git-Spigot-e4d4710-e1ebe52]
            ... 7 more
     
  2. Code (Text):
    org.bukkit.plugin.InvalidPluginException: Cannot find main class `trollfaceryt.crazyantidupe.Core'
     
  3. I see that, But how do I fix it? (I'm new to java development)
     
  4. Change .Core to .[name of main file]
     
  5. Core.java is my main class
     
  6. Does it extend JavaPlugin?
     
  7. Code (Text):
    public class Core extends JavaPlugin {
        public static Economy econ = null;
    Yes it does, ^
     
  8. Do you also have a package named Core?
     
  9. No, there is no package titled core. Core is inside of trollfaceryt.timedflygui
     
  10. Your plugin.yml is looking in trollfaceryt.crazyantidupe
     
  11. Oh, Thank you :) xD
     
Thread Status:
Not open for further replies.