java - How to send contsructor parameters from one class to another -


so wouldn't i'm new java, i've forgotten quite bit since i've last coded. such, wondering if @ possible send constructor's parameters 1 class another. assumed had make object of constructor "class b" in "class a". however, there multiple constructors in second class, , unless can figure out how send parameters over, i'm stuck constructor don't want use. here's snippet of code.

public class title{ /* title packet */ private class<?> packettitle; /* title packet actions enum */ private class<?> packetactions; /* chat serializer */ private class<?> nmschatserializer; private class<?> chatbasecomponent; /* title text , color */ private string title = "falling maze"; private chatcolor titlecolor = chatcolor.green; /* subtitle text , color */ private string subtitle = "tip: fall through maze win! may touch sandstone!"; private chatcolor subtitlecolor = chatcolor.red; /* title timings */ private int fadeintime = 10; private int staytime = 20; private int fadeouttime = 20; private boolean ticks = true; private static final map<class<?>, class<?>> corresponding_types = new hashmap<>();  /**  * create new 1.8 title  *  * @param title  *            title  */ public title(string title) {     this.title = title;     loadclasses(); }  /**  * create new blank title.  */ public title() {     this(""); }  /**  * create new 1.8 title  *  * @param title  *            title text  * @param subtitle  *            subtitle text  */ public title(string title, string subtitle) {     this.title = title;     this.subtitle = subtitle;     loadclasses(); }  /**  * copy 1.8 title  *  * @param title  *            title  */ public title(title title) {     // copy title     this.title = title.title;     subtitle = title.subtitle;     titlecolor = title.titlecolor;     subtitlecolor = title.subtitlecolor;     fadeintime = title.fadeintime;     fadeouttime = title.fadeouttime;     staytime = title.staytime;     ticks = title.ticks;     loadclasses(); }  /**  * create new 1.8 title  *  * @param title  *            title text  * @param subtitle  *            subtitle text  * @param fadeintime  *            fade in time  * @param staytime  *            stay on screen time  * @param fadeouttime  *            fade out time  */ public title(string title, string subtitle, int fadeintime, int staytime, int fadeouttime) {     this.title = title;     this.subtitle = subtitle;     this.fadeintime = fadeintime;     this.staytime = staytime;     this.fadeouttime = fadeouttime;     loadclasses(); } 

this class different constructors used different types of titles. want able create title title, subtitle, fadeintime, staytime, , fadeouttime , call in other class placed below.

public class main extends javaplugin implements listener{  private title t1 = new title();  public void onenable() {     bukkit.getpluginmanager().registerevents(this, this);  } @eventhandler public void playerjoin(playerjoinevent event) {     //getting player's name     player player = event.getplayer();     //adding gold ingot , bed respective inventory slots.     itemstack bed = new itemstack(material.bed);     itemstack goldingot = new itemstack(material.gold_ingot);     player.getinventory().setitem(0, goldingot);     player.getinventory().setitem(8, bed);     t1.send(player); } 

when created object of title class did bring on first constructor(the 1 creates blank title). bring on ability create full title with, said before, title, subtitle, fadeintime, staytime, , fadeouttime. appreciated, because when try pass parameters on new object title() says parameters cannot resolved variable.thank in advance. tried specific possible, ask me , i'll answer best of abilities.

big props andreas helping me figure out. turns out title being overwritten no matter what, set loop in main class send timer title. enabled pull other class. thank much! ^-^ there way upvote comment?


Comments