PluginSpy

Discussion in 'Plugin Development' started by robbcap, May 8, 2012.

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

    robbcap

    I was making a plugin for my server that protects the plugins but it seems to be broken but i look at the code and it seems fine. what the prob?



    Code:
    [PluginSpy] loading PluginSpy v1.0
    2012-05-08 22:58:31 [SEVERE] Error occurred while enabling PluginSpy v1.0 (Is it up to date?)
    java.lang.NullPointerException
        at me.robbcap.PluginSpy.PluginSpy.onEnable(PluginSpy.java:29)
        at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:215)
        at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:336)
        at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:381)
        at org.bukkit.craftbukkit.CraftServer.loadPlugin(CraftServer.java:250)
        at org.bukkit.craftbukkit.CraftServer.enablePlugins(CraftServer.java:232)
        at net.minecraft.server.MinecraftServer.t(MinecraftServer.java:371)
        at net.minecraft.server.MinecraftServer.a(MinecraftServer.java:358)
        at net.minecraft.server.MinecraftServer.init(MinecraftServer.java:187)
        at net.minecraft.server.MinecraftServer.run(MinecraftServer.java:422)
        at net.minecraft.server.ThreadServerApplication.run(SourceFile:492)

    Code:
    package me.robbcap.PluginSpy;
     
     
    import org.bukkit.plugin.java.JavaPlugin;
    import java.util.logging.Logger;
    import org.bukkit.plugin.PluginDescriptionFile;
     
     
    public class PluginSpy extends JavaPlugin{
        private Logger log;
        private PluginDescriptionFile description;
     
        private String prefix;
     
     
        @Override
        public void onEnable(){
            log = Logger.getLogger("Minecraft");
            description = getDescription();
            prefix = "["+description.getName()+"] ";
     
            log("loading "+description.getFullName());
     
     
       
     
       
            getCommand("pl").setExecutor(new CommandExecutor_Pl(this));
            getCommand("plugins").setExecutor(new CommandExecutor_Plugins(this));
     
       
     
        }
     
        @Override
        public void onDisable(){
            log("disabled "+description.getFullName());
     
        }
        public void log(String message){
            log.info(prefix+message);
        }
     
     
     
     
     
    }
    
     
  2. Offline

    Njol

    Did you register the commands "pl" and "plugins" in your plugin.yml?
     
  3. Offline

    robbcap

  4. Offline

    Njol

    I guess this is line 29:
    Code:
    getCommand("plugins").setExecutor(new CommandExecutor_Plugins(this));
    The only way for this to throw a NPE is if getCommand returns null, which happens for unknown commands. So I guess your plugin.yml is invalid, or you didn't put the correct one in the jar.
    Could you please post your plugin.yml?
     
  5. Offline

    robbcap

    Code:
    name: PluginSpy
    main: me.robbcap.PluginSpy.PluginSpy
    version: 1.0
    author: robbcap
    description: >
                Makes players die when they type /pl or /plugins
    commands:
      plugins:
        description: Kills the players for typing /plugins
       
      pl:
        description: Kills the player for typing /pl
     
     
    
     
  6. Offline

    Njol

    Can you try to rename the commands to find out whether it's an issue with overriding default Bukkit commands? If this is the case you can still use PlayerCommandPreProcessEvent to block these commands.
     
Thread Status:
Not open for further replies.

Share This Page