Solved Question about Constructors

Discussion in 'Plugin Development' started by mine2012craft, Feb 22, 2017.

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

    mine2012craft

    I know this isn't the place to really ask this and I should read some javadoc, but I prefer to ask a community that I'm familiar with and that I trust instead.

    Recently I've been sort of wondering what are constructors. I am sort of confused on what their uses are. Like are they there to save data? They have been slightly confusing for me for quite awhile now and I'm hoping that if I could understand it better, I would be able to hopefully use it in some way.

    Thank you,
    WarlordWeaponry
     
  2. Offline

    WolfMage1

    Difference between constructor and method in java

    Java Constructor
    Constructor is used to initialize the state of an object.
    Constructor must not have return type.
    Constructor is invoked implicitly.

    Java Method
    Method is used to expose behaviour of an object.
    Method must have return type.
    Method is invoked explicitly.

    http://www.dummies.com/programming/java/how-to-use-a-constructor-in-java/
     
  3. Offline

    Zombie_Striker

    @mine2012craft
    Please learn java Before working on bukkit, as this is a simple and important thing to understand before creating plugins.

    Since you are asking this question, something that should be covered within the first few chapters of any Java tutorial, it seems you have not officially learned Java. Please, pick a tutorial from the link below, learn Java, and then come back to bukkit. After that, you should have a complete understanding of Java and how it works.
    https://bukkit.org/threads/plugin-dev-sticky-learning-java-where-to-learn.395662/
     
    ipodtouch0218 likes this.
  4. Offline

    mine2012craft

    @Zombie_Striker Had a feeling someone like you would say that. Even though it hurts my feelings slightly, but reasonable, that's fine. Doing so now.

    Learning about Constructors I mean.
    EDIT:
    Got it. Should've known.

    Code:
    //Spell Constructor and methods
    
    //BeamSpell beam = new BeamSpell(Player caster, Double damage, int range, boolean stopOnHit);
    
    BeamSpell beam = new BeamSpell(player, 8D, 20, true);
    beam.setStopOnBlockHit(true);
    beam.setCastLocation(player.getEyeLocation());
    beam.cast();
    
    
     
    Last edited: Feb 22, 2017
  5. Offline

    PhantomUnicorns

    @mine2012craft You must understand that Bukkit is not an extension of Java and Java is required. It is very improper to learn Java while using a library to make a plugin, what I mean is it is an extremely bad way for someone to learn java.
     
  6. Offline

    mine2012craft

    @PhantomUnicorns OK. I'll try to learn, while also not being taken aback. I do understand where you are coming from though. I was supposed to learn Java decently before I started this, but I don't know, so far I've been able to get far decently with some questions of course. I don't really know how I've gotten as far as I have to be honest :I
     
    Last edited: Feb 22, 2017
Thread Status:
Not open for further replies.

Share This Page