replace craftbukkit class

Discussion in 'Plugin Development' started by dralletje, Sep 13, 2011.

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

    dralletje

    hello,

    I was wondering if it is possible to kinda replace a class from craftbukkit with your own using a plugin. Like I make that class, call it the same and say that it is in org.bukkit.craftbukkit is it replace then?
     
  2. Offline

    ItsHarry

    That's not possible without a Server mod.
     
  3. It is actually possible in a lot of cases (that's what Spout is based on), but you are not replacing the class itself, but instances of that class with your own class that extends the class (sounds confusing, I know).

    So if you want to implement your own CustomCraftPlayer for example, you look for the place where players are stored in craftbukkit, hack into it with java reflect calls, and replace the instances with a class like that:
    Code:
    public class CustomCraftPlayer extends CraftPlayer
    Note that that conflicts with other plugins doing the same then (Spout, for example) and you should only do it when absolutely necessairy.
     
  4. Offline

    dralletje

    and how do I replace a ,ethod inside that class then?
    and not add a method but realy replace the one that is there now.
     
  5. You know Java, right? Then you should know that when you extend a class, you are able to override methods of the superclass.
     
  6. Offline

    dralletje

    knowing java is a big word... :p
    but I think I'll find how to overwrite the mehtod (google)

    thanks for the awnser anyway :)
     
Thread Status:
Not open for further replies.

Share This Page