Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9085961
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T21:22:21+00:00 2026-06-16T21:22:21+00:00

I’ve been working on a Bukkit plugin project for a while, and I’ve finally

  • 0

I’ve been working on a Bukkit plugin project for a while, and I’ve finally decided to make a formal release. So in my crazy scramble to document everything about my project, I decided to clean up some APIs for people that would like to use them. Now, I’ve hit the wall with a single problem though.

Basically, in this API, you must implement an interface and then register your implementation with a class that manages every implementation and also checks for/registers another variable with the PluginMetrics that are bundled inside the plugin.

Here is my interface, with the “name” and “tracker” fields being fields of concern:

public interface IAction {

    /**
     * Name of the action.
     */
    String name = null;
    /**
     * Stores args passed to the action by the player.
     */
    String[] args = null;
    /**
     * Holds the Metrics tracker object.
     */
    Tracker tracker = null;

    ...
}

And, here is the method (and init() method) where all my issues arise:

public static void registerAction(final Class a) {
    try {
        store.put((String) a.getField("name").get(a), a);
        log.exDebug(String.format("Action %s (%s) was registered.", (String) a.getField("name").get(a), a.getCanonicalName()));
        try {
            Tracker metric = (Tracker) a.getField("tracker").get(a);
            try {
                OpenAuth.getMetrics().addCustomData(metric);
                log.exDebug(String.format("Registered Metrics data tracker [%s] from %s.", metric.getColumnName(), a.getCanonicalName()));
            } catch (java.lang.Exception e) {
                log.info("Exception occurred while registering Action data tracker.");
            }
        } catch (java.lang.Exception e) {
            log.info("Exception occurred while registering Action data tracker.");
            // e.printStackTrace();
        }
    } catch (java.lang.Exception e) {
        log.info("Exception occurred while registering an Action.");
        e.printStackTrace();
    }
}

public static void init() {
    for (Actions a : Actions.values()) {
        try {
            registerAction(a.getAction());
        } catch (java.lang.Exception e) {
            log.info("Exception occurred while initialising Actions enumerator.");
            e.printStackTrace();
        }
    }
    for (Object ob : classLoader.load().getClasses()) {
        Class c = null;
        try {
            c = (Class) ob;
        } catch (java.lang.Exception e) {
            log.info("Exception occurred while casting up external Action.");
            e.printStackTrace();
        }
        try {
            registerAction(c);
        } catch (java.lang.Exception e) {
            log.info("Exception occurred while registering external Action.");
            e.printStackTrace();
        }
    }
}

And an example implementation:

public class FreezeStick implements IAction {

    public static final String name = "freeze";
    public static final Tracker tracker = new Tracker("FreezeStick");

    private String[] args = null;
    private Session attached;
    private SessionController sc;
    private final LogHandler log = new LogHandler();
    private final String permissible = "openauth.action.freeze";
    private OAServer server;
    private boolean used = false;

    protected OAPlayer sender;
    protected OAPlayer target;

    public FreezeStick(OAServer server, Session attached) {
        this.server = server;
        this.sc = server.getController().getSessionController();
        this.attached = attached;
        this.setSender(this.attached.getPlayer());
    }

-- etc.. --

Every time Tracker metric = (Tracker) a.getDeclaredField("tracker").get(a); happens, it’s
reported as null. I’ve tried with a.getField() instead of a.getDeclaredField(), but same problem. Both the name and tracker variables receive private, static, and final when they are declared in the implementations, and using a.getField() on the name variable has worked fine ever since I first wrote this.

If someone could point me in the right direction, I would greatly appreciate it 🙂

Also, here is the exception that occurs if it helps with figuring out my problem any better:

2013-01-02 10:48:10 [INFO] [OpenAuth-debug] Action ban (me.maiome.openauth.actions.BanStick) was registered.
2013-01-02 10:48:10 [INFO] [OpenAuth] Exception occurred while adding Action data tracker.
2013-01-02 10:48:10 [SEVERE] java.lang.NullPointerException
2013-01-02 10:48:10 [SEVERE]    at me.maiome.openauth.actions.Actions.registerAction(Actions.java:65)
2013-01-02 10:48:10 [SEVERE]    at me.maiome.openauth.actions.Actions.init(Actions.java:104)
2013-01-02 10:48:10 [SEVERE]    at me.maiome.openauth.bukkit.OpenAuth.onEnable(OpenAuth.java:230)
2013-01-02 10:48:10 [SEVERE]    at org.bukkit.plugin.java.JavaPlugin.setEnabled(JavaPlugin.java:217)
2013-01-02 10:48:10 [SEVERE]    at org.bukkit.plugin.java.JavaPluginLoader.enablePlugin(JavaPluginLoader.java:457)
2013-01-02 10:48:10 [SEVERE]    at org.bukkit.plugin.SimplePluginManager.enablePlugin(SimplePluginManager.java:381)
2013-01-02 10:48:10 [SEVERE]    at org.bukkit.craftbukkit.v1_4_6.CraftServer.loadPlugin(CraftServer.java:278)
2013-01-02 10:48:10 [SEVERE]    at org.bukkit.craftbukkit.v1_4_6.CraftServer.enablePlugins(CraftServer.java:260)
2013-01-02 10:48:10 [SEVERE]    at org.bukkit.craftbukkit.v1_4_6.CraftServer.<init>(CraftServer.java:214)
2013-01-02 10:48:10 [SEVERE]    at net.minecraft.server.v1_4_6.PlayerList.<init>(PlayerList.java:52)
2013-01-02 10:48:10 [SEVERE]    at net.minecraft.server.v1_4_6.DedicatedPlayerList.<init>(SourceFile:11)
2013-01-02 10:48:10 [SEVERE]    at net.minecraft.server.v1_4_6.DedicatedServer.init(DedicatedServer.java:104)
2013-01-02 10:48:10 [SEVERE]    at net.minecraft.server.v1_4_6.MinecraftServer.run(MinecraftServer.java:399)
2013-01-02 10:48:10 [SEVERE]    at net.minecraft.server.v1_4_6.ThreadServerApplication.run(SourceFile:849)
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T21:22:22+00:00Added an answer on June 16, 2026 at 9:22 pm

    I found my answer. Turns out, I was trying to run #addCustomData() on the Metrics instance before there was Metrics instance ready to be used. Just had to move Actions.init() down a few lines in my controller 🙂

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I'm parsing an RSS feed that has an &#8217; in it. SimpleXML turns this
I have been unable to fix a problem with Java Unicode and encoding. The
I'm trying to convert HTML to plain text. I get many &\#8217; &\#8220; etc.
I'm working with an upstream system that sometimes sends me text destined for HTML/XML
Let's say I'm outputting a post title and in our database, it's Hello Y&#8217;all
I have a string like this: La Torre Eiffel paragonata all&#8217;Everest What PHP function
I have a .ini file as follows: [playlist] numberofentries=2 File1=http://87.230.82.17:80 Title1=(#1 - 365/1400) Example
That's pretty much it. I'm using Nokogiri to scrape a web page what has

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.