[SEVERE] InvalidPluginException - NoSuchMethodExeption: com.bukkit.styller.DCIM.Main.<init>

Discussion in 'Plugin Development' started by StyllerSystems, Mar 30, 2011.

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

    StyllerSystems

    Code:
    16:12:30 [SEVERE] Could not load plugins\DCIM.jar in plugins: null
    org.bukkit.plugin.InvalidPluginException
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
    ava:113)
            at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.
    java:159)
            at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager
    .java:107)
            at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:61)
            at net.minecraft.server.MinecraftServer.e(MinecraftServer.java:204)
            at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:191)
            at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:131)
            at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:246)
            at net.minecraft.server.ThreadServerApplication.run(SourceFile:366)
    Caused by: java.lang.NoSuchMethodException: com.bukkit.styller.DCIM.Main.<init>(
    )
            at java.lang.Class.getConstructor0(Unknown Source)
            at java.lang.Class.getConstructor(Unknown Source)
            at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.j
    ava:108)
            ... 8 more
    16:12:30 [INFO] [Permissions] version [2.5.4] (Phoenix) was Initialized.
    16:12:30 [INFO] DefaultCommands 2.5.3 is enabled. Using Permissions.
    16:12:30 [INFO] [BlastPick] BlastPick 1.0.0 enabled successfully.
    16:12:30 [INFO] [Permissions] version [2.5.4] (Phoenix)  loaded
    16:12:30 [INFO] Done (0.227s)! For help, type "help" or "?"
    >
    what I want to know if possible is what the <init> is for. I tried the same script a little earlyer and it worked fine, no problems. yet I added:

    PHP:
    if(message[0].equalsIgnoreCase("/breeth")){
        
    players.setMaximumAir(1000000);
        
    players.setRemainingAir(1000000);
        
    players.sendMessage("Lung Capacity Improved");
    }
    on my player listener and:
    PHP:
    private final MainPListener playerListener = new MainPListener(this);
    on my Main.java right under
    PHP:
    public class Main extends JavaPlugin{
    This give no errors at all, yet when I export and try to use it it now gives me a new error after only adding a few lines. can anyone point out which one is the problem(or which one(s)) and tell me how to fix it?
     
  2. Offline

    Edward Hand

    I've never seen that error before, but I assume the <init> refers to this bit:
    Code:
    private final MainPListener playerListener = new MainPListener(this);
    (the stuff outside the functions in your class)

    Does your MainPListener have a constructor?
    If so could you post it?

    Also, you spelt 'Breathe' wrong in your command
     
  3. Offline

    StyllerSystems

    sorry about the spelling but I only testing stuff out for now, completely new to java.

    Whenever I add a constructor to and of my classes it comes up with the error:
    PHP:
    the constructor for JavaPlugin(argsis not defined
    this error apears at the
    PHP:
    super(args);
    line.

    The quick fix is to remove all the arguments from the super() to fit JavaPlugin().

    So either I'm getting errors or I get no errors and it loads on the server, but doesn't do anything.
    my code:

    com.bukkit.styller.DCIM.Main.java:
    Show Spoiler
    PHP:
    package com.bukkit.styller.DCIM;

    import java.io.*;
    import java.util.HashMap;

    import org.bukkit.Server;
    import org.bukkit.entity.Player;
    import org.bukkit.event.Event;
    import org.bukkit.event.Event.Priority;
    import org.bukkit.plugin.PluginDescriptionFile;
    import org.bukkit.plugin.PluginLoader;
    import org.bukkit.plugin.PluginManager;
    import org.bukkit.plugin.java.JavaPlugin;
    import org.bukkit.event.block.BlockPlaceEvent;
    import org.bukkit.command.Command;


    /**
     * DCIM for Bukkit
     * 
     * @author styller
     */
    public class Main extends JavaPlugin {
        private final 
    MainPListener playerListener = new MainPListener(this);
        public 
    Main(PluginLoader pluginLoaderServer instance,
                
    PluginDescriptionFile descFile folderFile plugin,
                
    ClassLoader cLoaderthrows IOException {
                   
    super(pluginLoaderinstancedescfolderplugincLoader);
        public 
    void onEnable(){
            
    PluginManager pm getServer().getPluginManager();
            
    pm.registerEvent(Event.Type.PLAYER_COMMAND_PREPROCESSplayerListenerPriority.Normalthis);
            
    System.out.println("DCIM Has Been Sucessfully Enabled!");
        }
        public 
    void onDisable() {
            
    System.out.println("!!DCIM is now Disabled!!");
        }
    }


    com.bukkit.styller.DCIM.MainPListener.java:
    Show Spoiler
    PHP:
    package com.bukkit.styller.DCIM;

    import java.io.*;
    import org.bukkit.Location;
    import org.bukkit.entity.*;
    import org.bukkit.event.player.PlayerChatEvent;
    import org.bukkit.event.player.PlayerEvent;
    import org.bukkit.event.player.PlayerListener;
    import org.bukkit.event.player.PlayerMoveEvent;
    import org.bukkit.event.player.PlayerInventoryEvent;
    import org.bukkit.inventory.*;
    import org.bukkit.material.MaterialData;
    import org.bukkit.*;
    import org.bukkit.inventory.Inventory;
    import org.bukkit.entity.LivingEntity;

    /**
     * Handle events for all Player related events
     * @author styller
     */

    public class MainPListener extends PlayerListener {
        private final 
    Main plugin;

        public 
    MainPListener(Main instance) {
            
    plugin instance;
        }

        public 
    void onPlayerCommand(PlayerChatEvent event) {
            
    Player players event.getPlayer();
            
    String[] message event.getMessage().split(" ");
            if(
    message[0].equalsIgnoreCase("/cmd")) {
                if(
    message[1].equalsIgnoreCase("cl_inv")||message[1].equalsIgnoreCase("c_i")){
                    
    players.getInventory().clear();
                    
    players.sendMessage("You Cleared your inventory");
               }
                if(
    message[1].equalsIgnoreCase("heal")||message[1].equalsIgnoreCase("h")){
                    
    players.setHealth(100);
                    
    players.sendMessage("You Healed to full health");
                }
                if(
    message[1].equalsIgnoreCase("suisuide")||message[0].equalsIgnoreCase("s")){
                    
    players.setHealth(0);
                    
    players.sendMessage("You Killed Yourself");
                }
                if(
    message[1].equalsIgnoreCase("OVERDRIVE")||message[1].equalsIgnoreCase("O_D")){
                    
    players.setHealth(500000);
                    
    players.sendMessage("You Overdrived yourself");
                }
                if(
    message[1].equalsIgnoreCase("swim_on")||message[1].equalsIgnoreCase("sw_on")||message[1].equalsIgnoreCase("diver_on")){
                    
    players.setMaximumAir(1000000);
                    
    players.setRemainingAir(1000000);
                    
    players.sendMessage("Lung Capacity Improved");
                }
                if(
    message[1].equalsIgnoreCase("swim_off")||message[1].equalsIgnoreCase("s_off")||message[1].equalsIgnoreCase("diver_off")){
                    
    players.setMaximumAir(300);
                    
    players.sendMessage("You Popped a Lung");
                }
            }
        }
    }


    And a picture to help you understand the error.
    Show Spoiler
    000.000.3.54.66.jpg


    All I need to really know is what line(s) I messed up on, and what to fix.
     
  4. Offline

    Edward Hand

    You need to completely remove the constructor from you Main class.

    That constructor has been banned for a while now.
     
  5. Offline

    EvilSeph

  6. Offline

    StyllerSystems

    Ok, sorry, I did not see that post. This plugin will not be released even, it's just a test, so I was following a tutorial, which told me to use that.

    @Edward Hand: If I don;t have the constructor It will still not work. On the server program it says "DCIM has been enabled!" but when I type a command it is not doing anything. Is there any problem with the script other than that? Because with no errors without the constructor it does not do anything when I type in the command.
     
  7. Offline

    Edward Hand

    Your Player Listener code is in the old function for PLAYER_COMMAND not the new PLAYER_COMMAND_PREPROCESS.
    (though you should be using the new onCommand way of doing things anyway).
     
  8. Offline

    StyllerSystems

    onCommand()? I can't even find that in the external reference library...

    I am confused on how to use the onCommand(), can you help a little more, hopefully that will be all I need.

    thanks for your help.
     
  9. Offline

    Edward Hand

  10. Offline

    StyllerSystems

    on, did that and compiled it. It said enabled sucessfully the first time, yet did not work at all, then the next time I loaded I get an error:
    PHP:
    07:35:11 [SEVEREnull loading ACMD v1.1 (Is it up to date?)
    java.lang.NullPointerException
            at org
    .styller.ACMD.Main.onEnable(Main.java:26)
            
    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:118)
            
    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader
    .java:511)
            
    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManage
    r
    .java:216)
            
    at org.bukkit.craftbukkit.CraftServer.loadPlugin(CraftServer.java:93)
            
    at org.bukkit.craftbukkit.CraftServer.loadPlugins(CraftServer.java:71)
            
    at net.minecraft.server.MinecraftServer.e(MinecraftServer.java:204)
            
    at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:191)
            
    at net.minecraft.server.MinecraftServer.d(MinecraftServer.java:131)
            
    at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:246)
            
    at net.minecraft.server.ThreadServerApplication.run(SourceFile:366)
    and nothing happens.

    I mean might this have to do with the recent update?

    I think I may have answered my own question, At the last step I forgot to register the command in the plugin.yml file... I'll see if that has anything to do with it.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 13, 2016
  11. Offline

    darknesschaos

    Well, you also seem to have a null pointer problem on line 26 within your onEnable() function. Recompile, run, and post error code if any with related code to get more help :D
     
  12. Offline

    StyllerSystems

    hmm, strange, line 26 is empty...
     
  13. Offline

    darknesschaos

    That could have changed, thats why I said to re-compile and re-run it to see if the error came up again.
     
  14. Offline

    StyllerSystems

    yeah, ok. YAY, it's working completely, minus the heal and overdrive. what is the max health? 100? is there any way to set your health above max? like for near godmode, but not quite.

    never mind, I found that out as well. here is a list of some commands that I have working. yes, some of these are already made but I just practicing.

    ***Teleport:
    ******to (self->player)
    ******ptp (player->player)
    ******tph (player->self)
    ******spawn (self->Spawn)
    ******point (self/player -> [x, y, z])
    ***Infinate Underwater Breathing (self)
    ***10 times health(self/player)
    ***heal (self/player)
    ***kill (player)
    ***suicide (self)
    ***Clear Inventory (self/Player)
    ***Dig <Fun Suicide - Pit to void> (self)

    thank you for your help.

    EDIT by Moderator: merged posts, please use the edit button instead of double posting.
     
    Last edited by a moderator: May 13, 2016
  15. Offline

    StyllerSystems

    I am making part of the plugin that will allow you if useing a certain Item it breaks blocks in one hit. Two problems:

    I have it working, but what events should I use to register the click event to be able to break bedrock? cause the only events I can get working are the BLOCK_DAMAGE and PLAYER_INTERACT, which seem not to affect bedrock or something, the bedrock will only be affected by the plugin if you hit a different block first then quickly point towards it.

    Secondly, how can I convert a block material into an item stack so I can make the broken items fall?
     
  16. Offline

    StyllerSystems

    never mind, I fixed those two problems, I just have to right click bedrock... and I had to say
    Code:
    ItemStack it = (new ItemStack(block.getType()));
    now I'm just having problems with hashmaps...
     
Thread Status:
Not open for further replies.

Share This Page