Solved Multiple classes

Discussion in 'Spigot Plugin Development' started by SwagiWagi, Jun 8, 2016.

Thread Status:
Not open for further replies.
  1. Hey there!

    How do I connect two classes?
  2. MiniDigger


    learn java....
    really, if you don't know the simplest concepts of oop then you should NOT be looking into spigot at all.
    • Agree Agree x 5
    • Agree Agree x 1
  3. +1

    Create a constructor
  4. Do not all say: Learn java .-.


    This is how I do that:

    Code (Text):
    public void onEnable(){

    Bukkit.getPluginManager().registerEvents(new <OtherClassName>(), this);

    // if you used a configuration in that class you can do it like this:

    Bukkit.getPluginManager().registerEvents(new <OtherClassName>(this), this);
    • Funny Funny x 1
    • Winner Winner x 1
    • Optimistic Optimistic x 1
  5. MiniDigger


    we will because this is what you need to do. You will fail missilery if you don't.
    • Agree Agree x 7
    • Friendly Friendly x 1
  6. okay true..
  7. Well, I learned Java, but it's not the same as in regular Java, with the spigot, I didn't knew where to put it, just asked for a friendly advice.
    Same for you.
    • Useful Useful x 1
  8. look for static variables, i dont know what u want to do at the moment
  9. Oh btw,

    I forgot to add implementing commands from another class:

    Code (Text):
    public void onEnable(){

    getCommand("<the command you filled in>").setExecutor(new  <other class name>());

    // or when it contains configuration

    getCommand("<the command you filled in>").setExecutor(new  <other class name>(this));

    using this way means you have an external class like this:

    Code (Text):
    public class <ClassName> implements CommandExecutor {

    public boolean onCommand(CommandSender sender, Command cmd, String label , String[] args){

    Hope this helped you out a bit !
  10. Google could have solved this in 5 minutes. This question has probably been asked 1000 times...
    • Agree Agree x 2
  11. Hockey i agree with you, But sometime's things needs a bump aswell.
    I also post a issue i guess it's asked earlier but can't find it so yea i made a topic aswell
  12. MiniDigger


    and waste the time of a couple of ppl, great idea.
  13. what does it matter, he now probably knows how to do, if you find it a waste of time then don't reply to it .-.
  14. MiniDigger


    it is more a general advise. don't post a question if you could just search for the answer.
  15. Then you need to work on using google. I found multiple answers on the first page of my first search. Took me 10 seconds.
  16. That makes absolutely zero sense...
    • Agree Agree x 1
  17. I know, right?

    new <Class>();

    public <Class> {

    <MainClass> m;

    public <Class>(<MainClass> main) {
    this.m = main;

    <anything you want to do when the class is activated>
  18. Where should I put stuff?
    After onEnable() or before, so it's a bit different from normal Java.
    • Funny Funny x 2
  19. And for everyone else, if you find it a waste of time, don't replay.
Thread Status:
Not open for further replies.