Get a hashmap from one class and put it in another

Discussion in 'BungeeCord Plugin Development' started by Fazzer84, Jun 5, 2018.

  1. I was wondering how could I get a hashmap of the class "BUILDCOMMANDS" and put it in the class "BUILDEVENTS"...
     

    Attached Files:

  2. First: Why do you screenshot your code? Seriously. There are better alternatives, that are much easier to read and to use. Take a look at haste or pastebin, or just use the forums own code insertion feature (but always use the correct syntax highlighting, pleeeaaase)

    Second: Your Map doesn't need to be static. You can keep a reference of the BuildCommands object you initialize to register that command, and implement a getter method for that Map (that would be the clean way)

    But to access static members of any class, you just type
    Code (Java):
    //e.g.
    ClassName.STATIC_MEMBER.fancyMethod();
    Third: I'm sure you would benefit from clean and readable code that is maintainable even after quite some time - take a look at the Java Conventions (you really just need a general idea of the conventions). If you know them, it can also make it easier to read and/or understand the code of someone else, as you will recognize common patterns.
     
  3. Where is saying "ClassName" is for me to put the class in which the hasmap is, where it is saying "STATIC_MEMBER" I do not understand what it is to put and where it is saying "fancyMethod" is for me to put what in it. I'm sorry for being stupid.
     
  4. What I provided was just an example, a pattern how to achieve what you were trying to do.
    I'm not going to spoonfeed you. If you can't make use of this really, really (I mean really) simple example, you gotta go learn the basics first, as this will save you and a lot of time, as well as a lot of other people on this forum.
     
  5. Dude, I already have the basics. All you need to do is learn the SPIGOT API. Please provide the code without an example, correct code. Please, I'll thank you so much. Please I need just help me by giving the right code. PLEASE.:cry:
     
  6. Take a read at this. You probably don't know what all the modifiers in
    Code (Java):
    public static int derp=0;
    mean so the link above will give you a good understanding.

    Before you do anything in Java even the Spigot/Bukkit Api. You oughta learn Java first. And learning how to print Hello World doesn't
    equate to shit. Learn how to Properly use Java.
     
  7. lol if you don't know how to move a hashmap around you don't know the basics. You should really start here https://docs.oracle.com/javase/tutorial/java/javaOO/index.html
     
    • Agree Agree x 2
  8. Your problem is not a problem you have with the Spigot API. You don't know the basics, otherwise this thread would not exist (as already implied by @John_Willikers)
     
    • Agree Agree x 1