Error when running plugin.

Discussion in 'Plugin Development' started by Jamesterjim, Dec 30, 2012.

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

    Jamesterjim

    Hello everyone, I have a plugin that makes it so if you have a certain permission node then you can't take items out of chests.

    Here is my ChestAccess.java
    Code:
    package Jamesterjim.main;
     
    import org.bukkit.Material;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.HumanEntity;
    import org.bukkit.entity.Player;
    import org.bukkit.event.inventory.InventoryOpenEvent;
    import org.bukkit.event.inventory.InventoryType;
    import org.bukkit.event.player.PlayerJoinEvent;
    import org.bukkit.inventory.ItemStack;
    import org.bukkit.inventory.PlayerInventory;
    import org.bukkit.plugin.java.*;
     
    public class ChestAccess extends JavaPlugin {
     
     
        public boolean onCommand(CommandSender sender, Command cmd, String label, String[] args){
            if(cmd.getName().equalsIgnoreCase("rca")){
                //currently not added
                return true;
            }
            return false;
        }
        @SuppressWarnings("deprecation")
        public void onInventoryOpen(InventoryOpenEvent event) {
              HumanEntity p = event.getPlayer();
              if (event.getInventory().getType() == InventoryType.CHEST) {
                  if(p.hasPermission("denyAccess")){
                          event.setCancelled(true);
                  }else{
                  }
              }
            }
     
        public void onEnable(){
            getLogger().info("ChestAccess was enabled.");
        }
        public void onDisable(){
            getLogger().info("ChestAccess was disabled.");
        }
    }
    
    Here is my YML
    Code:
    name: ChestAccess
    main: Jamesterjim.ChestAccess
    version: v1.0
    commands:
      ac:
          description: Deny Chest Access to players
          usage: /ac [player]
          permission: denyAccess
          permission-message: You don't have the ability to <permission>
    permissions:
        denyAccess:
            description: Deny access to Accessing Chests
    When I start my server I get this error
    Code:
    2012-12-30 17:03:50 [INFO] Starting minecraft server version 1.4.6
    2012-12-30 17:03:50 [WARNING] To start the server with more ram, launch it as "java -Xmx1024M -Xms1024M -jar minecraft_server.jar"
    2012-12-30 17:03:50 [INFO] Loading properties
    2012-12-30 17:03:50 [INFO] Default game type: SURVIVAL
    2012-12-30 17:03:50 [INFO] Generating keypair
    2012-12-30 17:03:51 [INFO] Starting Minecraft server on *:25565
    2012-12-30 17:03:51 [INFO] This server is running CraftBukkit version git-Bukkit-1.4.6-R0.2-b2583jnks (MC: 1.4.6) (Implementing API version 1.4.6-R0.2)
    2012-12-30 17:03:51 [SEVERE] Could not load 'plugins\ChestAccess-Archus[v1.0.6].jar' in folder 'plugins'
    org.bukkit.plugin.InvalidPluginException: java.lang.ClassNotFoundException: archus.ChestAccess
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:184)
        at org.bukkit.plugin.SimplePluginManager.loadPlugin(SimplePluginManager.java:305)
        at org.bukkit.plugin.SimplePluginManager.loadPlugins(SimplePluginManager.java:230)
        at org.bukkit.craftbukkit.v1_4_6.CraftServer.loadPlugins(CraftServer.java:239)
        at org.bukkit.craftbukkit.v1_4_6.CraftServer.<init>(CraftServer.java:217)
        at net.minecraft.server.v1_4_6.PlayerList.<init>(PlayerList.java:52)
        at net.minecraft.server.v1_4_6.DedicatedPlayerList.<init>(SourceFile:11)
        at net.minecraft.server.v1_4_6.DedicatedServer.init(DedicatedServer.java:104)
        at net.minecraft.server.v1_4_6.MinecraftServer.run(MinecraftServer.java:399)
        at net.minecraft.server.v1_4_6.ThreadServerApplication.run(SourceFile:849)
    Caused by: java.lang.ClassNotFoundException: archus.ChestAccess
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.net.URLClassLoader$1.run(Unknown Source)
        at java.security.AccessController.doPrivileged(Native Method)
        at java.net.URLClassLoader.findClass(Unknown Source)
        at org.bukkit.plugin.java.PluginClassLoader.findClass0(PluginClassLoader.java:80)
        at org.bukkit.plugin.java.PluginClassLoader.findClass(PluginClassLoader.java:53)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.ClassLoader.loadClass(Unknown Source)
        at java.lang.Class.forName0(Native Method)
        at java.lang.Class.forName(Unknown Source)
        at org.bukkit.plugin.java.JavaPluginLoader.loadPlugin(JavaPluginLoader.java:173)
        ... 9 more
    2012-12-30 17:03:51 [INFO] [PermissionsEx] sql backend registered!
    2012-12-30 17:03:51 [INFO] [PermissionsEx] file backend registered!
    2012-12-30 17:03:51 [INFO] [PermissionsEx] PermissionEx plugin initialized.
    2012-12-30 17:03:51 [INFO] [PermissionsEx] Loading PermissionsEx v1.19.5
    2012-12-30 17:03:51 [INFO] [PermissionsEx] Initializing file backend
    2012-12-30 17:03:51 [INFO] Permissions file successfully reloaded
    2012-12-30 17:03:51 [INFO] Preparing level "world"
    2012-12-30 17:03:51 [INFO] Preparing start region for level 0 (Seed: 2276313062435124870)
    2012-12-30 17:03:51 [INFO] ----- Bukkit Auto Updater -----
    2012-12-30 17:03:51 [INFO] It appears that you're running a Beta Build, when you've specified in bukkit.yml that you prefer to run Recommended Builds.
    2012-12-30 17:03:51 [INFO] If you would like to be kept informed about new Beta Build releases, it is recommended that you change 'preferred-channel' in your bukkit.yml to 'beta'.
    2012-12-30 17:03:51 [INFO] With that set, you will be told whenever a new version is available for download, so that you can always keep up to date and secure with the latest fixes.
    2012-12-30 17:03:51 [INFO] If you would like to disable this warning, simply set 'suggest-channels' to false in bukkit.yml.
    2012-12-30 17:03:51 [INFO] ----- ------------------- -----
    2012-12-30 17:03:52 [INFO] Preparing spawn area: 12%
    2012-12-30 17:03:53 [INFO] Preparing spawn area: 24%
    

    Thankyou for your time
     
  2. check your package name inside your main class and the plugin.yml
     
  3. Offline

    gomeow

    Change main to:

    main: Jamesterjim.main.ChestAccess
     
  4. Offline

    xMinecraft

    You see plugin.yml:

    Code:yaml
    1.  
    2. [FONT=Consolas]main: Jamesterjim.ChestAccess[/FONT]
    3.  


    Sorry for the bbcode.
     
  5. Offline

    Jamesterjim

    I changed that, plugin loads with no errors.

    If I try to take something out of a chest with the permission denyAccess it does not work. Acts like normal.

    Thanks, James.
     
  6. Offline

    MP5K

    hello Jamesterjim,
    1. your class must implement the Listener interface.
    2. add @EventHandler() to your "onInventoryOpen" method
    3. call ".getServer().getPluginManager().registerEvents(this, this);" in your on enable method

    btw: http://wiki.bukkit.org/Event_API_Reference
     
Thread Status:
Not open for further replies.

Share This Page