Plugin development help

Discussion in 'Plugin Development' started by SophiaDev, Mar 13, 2016.

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

    SophiaDev

    Hi!
    How do I access a class without having to use the class name to it. Example: Make api.blablabla
    also be accessible by blablabla of any class.



    You probably will not understand , but I tried to be as objective as possible . ( Sorry for bad english , I 'm Brazilian)
     
  2. Offline

    Zombie_Striker

    @SophiaDev
    This is done by creating a class with static methods or variables. It should look like the following:
    Code:
    public class API{
    
     public static void apiMethod(){
      //do stuff
     }
    Just note that unless you know how to manage singleton classes and static methods/fields, you should not work on APIs.
     
  3. Offline

    Gonmarte

    Se nao percebeste o que o @Zombie_Striker disse, mas ele disse que tu podes criar metodos static e podes aceder a esses metodos usando essa class. Ou seja, imagina que tens uma class chamada Main e la dentro tens este metodo:
    Code:
    public class Main{
      public void ola(){
        System.out.print("Helo");
      }
    }
    
    Agora imagina que nós queriamos aceder a este método noutra class. Nos poderiamos usar
    Code:
    public class Hi {
        Main main;
    
         main.ola()
      }
    
    Agora imagina a mesma class Main mas o metodo com static:
    Code:
    public class Main{
      public static void ola(){
        System.out.print("Helo");
      }
    }
    
    
    Agora tu poderias usar Main.ola(); para invocar o metodo noutra class uma vez que é static
    Code:
    Main.ola();
    
    Ambas as maneiras resultam bem :D
    Espero ter ajudado.
    Abraço
     
  4. Offline

    Zombie_Striker

    @Gonmarte
    Please remember that this is an English forum, and all public posts should be in English or at least have an English translation of what has been said.
     
  5. Offline

    Gonmarte

    I just did that so he could understand
     
  6. Offline

    87pen

    @Gonmarte Ye, @Zombie_Striker understands he just wants to be able to know what you told him to make sure there is no further confusion when approaching his problem.
     
    Gonmarte likes this.
  7. Offline

    Zombie_Striker

    Threads are not supposed to be meant as help for just one person. Other people should be able to visit these threads if they run into the same problem. They should be able to understand how to fix the same problem as the original poster of this thread without having to open up google translate.
     
    Gonmarte likes this.
  8. Offline

    Gonmarte

    Ik google translate sucks :-: He said that he had a bad english so i thoght it would be better i talk to him in portuguese... sorry
     
  9. Offline

    Scorpionvssub

    if you do wanna help out in a different language either do so in private or add a translation underneath that translates what you explained so others know what its all about even though its supposed to be english :p
     
    Zombie_Striker likes this.
Thread Status:
Not open for further replies.

Share This Page