A proper hook for your plugin

Discussion in 'Plugin Development' started by Randy Schouten, Jul 28, 2011.

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

    Randy Schouten

    I have created an API for my plugin EpicQuest, but whenever I use it in another plugin, it just gives me the nullPointerException.
    This also happens if it's just a void method.

    Plugin code:

    	public static randy.eq.eqAPI EpicQuest;
    public void onPlayerInteractEntity(PlayerInteractEntityEvent event){
                Player player = event.getPlayer();
                String newplayer = player.toString().replace("CraftPlayer{name=", "").replace("}", "");
                String npcname = event.getRightClicked().toString().replace("CraftPlayer{name=", "").replace("}", "");
                npcname = ChatColor.stripColor(npcname);
                //If NPC has a specific quest
    EpicQuest code (this is part of the eqAPI class):
    public String getCurrentQuestList(String player){
            String list = eq.questcurrent.get(player+".questlist").toString();
            return list;
    I am sure it's not empty.
    I gave myself a few quests before trying it and checked that with another command I made in EpicQuest to check the quest list.
  2. Offline


    Do you ever load the the object?
    So EpicQuest = something;
    Otherwise the object will just be empty... (null)
  3. Offline

    Randy Schouten

    First I import the class, then I typed the other code with EpicQuest...

    As I said, I'm fairly new to making API's and all, so I don't know how else I would do it :p
  4. Offline


    You need to actually instantiate the variable. To do that with a plugin you would do
    EpicQuest quest=(EpicQuest) getServer().getPluginManager().getPlugin("EpicQuest");
  5. Offline


    You have to make whatever hooks into EpicQuest 'depend' on it. You do this in the plugin/yml of the plugin to hookinto epic quest.

    depend: [EpicQuest]
    Abrupt likes this.
  6. Offline

    Randy Schouten

    Gotcha, thanks!
  7. Offline


    No problem ;)
Thread Status:
Not open for further replies.

Share This Page