[help]

Discussion in 'Plugin Development' started by xguysprison, Jul 19, 2014.

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

    jimuskin

    xguysprison No no no, I don't mean place it in your main class, I mean initialize the Main variable in your RedCards class. Then you have pretty much full access to the commands in your main class:


    Code:
    public class RedCards {
     
        private Main plugin;
        public RedCards(Main main) {
            this.plugin = main;
        }
    
    Then if you need to use your main class (Like one of the arguments for the inventory command), do it like this:

    Code:
    private static IconMenu menu = new IconMenu
    ("Chose red or black cards", 9, new IconMenu.OptionClickEventHandler() {     
    
            @Override public void onOptionClick(OptionClickEvent event) {           
    Player player = event.getPlayer();
    String name = event.getName().toLowerCase();
    if (name.equals("red cards")) {               
    RedCards.open(player);           
    }
    if (name.equals("black cards")) {             
      event.getPlayer().chat("/shop");     
          }         
             
            }    }, this.plugin);
    
     
  2. Offline

    xguysprison

  3. Offline

    Gamesareme

    Add this to your main class.
    Code:
    public final RedCards rc = new RedCards(this);
    and also this
    Code:
    public final BarMenu bm = new BarMenu(this);
    then hover over RedCards an import it, and do the same with BarMenu.
    Also you will need to add this to the BarMenu as well.
    Code:
        private Main plugin;
        public BarMenu(Main main) {
            this.plugin = main;
        }
     
  4. Offline

    xguysprison

    Last edited by a moderator: Jun 9, 2016
Thread Status:
Not open for further replies.

Share This Page