Multiple Classes! :)

Discussion in 'Plugin Development' started by ChrisStarr32, May 8, 2014.

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

    ChrisStarr32

    I was wondering how I can get a variable from my Main class?
     
  2. Offline

    AoH_Ruthless

    ChrisStarr32
    This is basic Java ..

    There's a great tool called google for things like this.
     
  3. Offline

    ChrisStarr32

  4. Offline

    AoH_Ruthless

    ChrisStarr32
    I understand. Bukkit is going to confuse the hell out of you while you don't know Java. If I were you, I would put down Bukkit for the time being and learn the basics of Java. Learning Java will make coding Bukkit maybe 94x easier. As you learn new things in Java, there's no better way to assert and test your understanding than by using an API: So, when you learn something new, apply it to Bukkit.

    I recommend taking either a Computer Science class, or better yet, use a book resource. Java for Dummies 5th edition is pretty good and I heard an e-book edition is available free somewhere (otherwise $20 on Amazon).

    Trust me, taking the time to learn Java will avoid you pulling out your hairs at unnecessary problems. Then when you need help with Bukkit, you know where to turn to!
     
  5. Offline

    ChrisStarr32

  6. Offline

    reider45

    Code:java
    1. public ClassName name = new ClassName(this);

    Pop that in the Main class

    Then, in ClassName
    Code:java
    1. public class ClassName {
    2. public Main plugin;
    3.  
    4.  
    5. public ClassName(Main instance){
    6. plugin = instance;
    7. }
    8.  
    9. // now if i have a variable named x in Main, in here I can
    10. // use plugin.x to get X
     
Thread Status:
Not open for further replies.

Share This Page