Importing Heroes plugin

Discussion in 'Plugin Development' started by Whatshiywl, Sep 2, 2012.

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


    Hello all! So I have been trying to make a plugin compatible with Heroes to be a kind of addon to it. It is my first time trying to make a plugin that needs another plugin and I seem to be having problems with using stuff on the code... (I don't acctualy have much java experience)

    The error is the following:
    2012-09-02 12:47:56 [SEVERE] null
    org.bukkit.command.CommandException: Unhandled exception executing command 'stats' in plugin HeroeStats v0.1
        at org.bukkit.command.PluginCommand.execute(
        at org.bukkit.command.SimpleCommandMap.dispatch(
        at org.bukkit.craftbukkit.CraftServer.dispatchCommand(
        at net.minecraft.server.NetServerHandler.handleCommand(
        at net.minecraft.server.NetServerHandler.a(
        at net.minecraft.server.Packet3Chat.handle(
        at net.minecraft.server.NetworkManager.b(
        at net.minecraft.server.NetServerHandler.d(
        at net.minecraft.server.ServerConnection.b(SourceFile:35)
        at net.minecraft.server.DedicatedServerConnection.b(SourceFile:30)
        at net.minecraft.server.MinecraftServer.q(
        at net.minecraft.server.DedicatedServer.q(
        at net.minecraft.server.MinecraftServer.p(
    Caused by: java.lang.NullPointerException
        at me.Whatshiywl.heroestats.HeroeStats.onCommand(
        at org.bukkit.command.PluginCommand.execute(
        ... 15 more
    It seems to point to this line of the code:


    The full thing is here:

    package me.Whatshiywl.heroestats;
    import java.util.logging.Logger;
    import me.Whatshiywl.heroestats.HeroeStats;
    import org.bukkit.ChatColor;
    import org.bukkit.command.Command;
    import org.bukkit.command.CommandSender;
    import org.bukkit.entity.Player;
    import org.bukkit.plugin.PluginDescriptionFile;
    import com.herocraftonline.heroes.Heroes;
    //import com.herocraftonline.heroes.characters.CharacterManager;
    import com.herocraftonline.heroes.characters.Hero;
    //import com.herocraftonline.heroes.characters.classes.HeroClassManager;
    public class HeroeStats extends JavaPlugin
        public final Logger logger = Logger.getLogger("Minecraft");
        //public final Hero hero;
        public Heroes heros;
        public static HeroeStats plugin;
        public void onDisable()
            PluginDescriptionFile pdfFile = this.getDescription();
   + " Has Been Disabled!");
        public void onEnable()
            PluginDescriptionFile pdfFile = this.getDescription();
   + " Version " + pdfFile.getVersion() + " Has Been Enabled!");
        public boolean onCommand(CommandSender sender, Command cmd, String commandLabel, String[] args)
            heros = (Heroes)plugin.
            Player player = (Player) sender;
            Hero hero = heros.
                player.sendMessage("Health is " + hero.getMaxHealth());
                player.sendMessage(ChatColor.BLUE + "Player stats go here!");
        return false;
    I'm not sure about it but is this telling me that my server is returning null? :confused: That makes no sense to me at all xD

    Can anyone please help me? Thanks in advance! \o/
  2. Offline


    I don’t see plugin field initialised anywhere.

    Look in bukkits javadocs and see what method can return nulls. Make appropriate checks and notifications.
  3. Offline


    but isn't "public static HeroeStats plugin;" supposed to initialise the plugin thing? tbh, i realy don't understand what is this plugin field u'r talking about D: nor do I know what are appropriate checks and notifications. basicaly i'm a complete noob with java and making plugins :S

    by methods that can return null you mean something like getServer() or whateverSomething() ?

    sorry for all the stupidity D:
  4. Offline


    Learn basic Java. Initialize plugin. Profit.
  5. Offline


    yep you only need basic java C:
  6. Offline


    ohhh it was "plugin = this;"!? that worked and makes sense :p i just didn't know this meant initialize haha thanks for the help!
  7. Offline


    No that would initialize HeroesPlugin as your plugin, not the actual Heroes plugin.
  8. Offline


    ahn... but it works D: it's so beautiful and fancy now without errors... is there any need to change it? I mean, is it bad to leave it like that? :S because i'm being able to manage everything i need so far. :p
  9. Offline


    You won't be using anything from Heroes if you leave it like that. Do you understand basic Java? This worries me that you hope you don't "need to change it."
  10. Offline


    well, no I don't understand basic Java. I understand basic programming (C++) and with Java I'm kind of learning things on the go. As for the plugin thing, I'm being able to use Heroes stuff. My plugin is being able to get and set Health so far and I think i could do the same for Mana and other stuff... But still, idk the difference of HeroesPlugin and Heroes plugin xD(?)
Thread Status:
Not open for further replies.

Share This Page