I’m a Java newbie and ran into a bit of a problem. I want a class to become another class. It’s hard to explain it the abstract way, so I’ll give you an example.
public class WorldGuard extends WorldGuardPlugin {
public WorldGuard(Plugin parent) {
WorldGuardPlugin plugin = parent.getServer().getPluginManager().getPlugin("WorldGuard")
// make plugin the actual class
}
}
WorldGuard should act like some kind of a wrapper here. When constructed it gets one parameter parent on which base it finds an instance of WorldGuardPlugin. The class should now become that instance.
It’s simple in JavaScript, I just return the instance, but I can’t do this in Java.
I’m not quite sure what you’re trying to do. A class cannot “become another class”. But perhaps your problem is just that you’re trying to use a constructor when you should be using a plain function. Maybe what you want to do is this:
That would get the object via parent and return it as a WorldGuard object.