Entity reference

Discussion in 'Plugin Development' started by Kolia1_1, Apr 28, 2018.

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

    Kolia1_1

    How can I work with this if it's a little higher


    How to connect ?
    Screenshot_66.png
     
  2. Make a variable outside the command method like

    Villager villager;

    Then use
    villager = ...;
    Where you want it
     
  3. Offline

    Kolia1_1

    Please example code
     
  4. @Kolia1_1

    Villager villager;

    public boolean onCommand(<arguments>){
    if(cmd.getName().equalsIgnoreCase("villager"){
    villager = (Villager) p.getWorld().spawnEntity(p.getLocation(), EntityType.VILLAGER);
    }
    }
     
  5. Offline

    Kolia1_1

    And how to use to other Java class ?
     
  6. @Kolia1_1
    make it public and connect the classes using

    OtherClass class = new OtherClass();

    Villager villager = class.villager;
     
  7. Just for information you dont need to use
    Code:
    if(command is idk)
    {
    //do
    }
    else
    {
    if(comand is idk2)
    {
    //do
    }
    }
    
    but you can do
    Code:
    if(command is idk)
    {
    //do
    }
    else if(command is idk2)
    {
    
    }
    you will save some lines :D
     
Thread Status:
Not open for further replies.

Share This Page