Solved Use HashMap from another Class

Discussion in 'Plugin Development' started by idkG0D, Oct 4, 2019.

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

    idkG0D

    Basically, i want to use a HashMap created in a Class, in another Class. Example:

    In the Class Spawn i have a HashMap:

    HashMap<UUID, Integer> cooldown = new HashMap<>();

    And in another Class named CancelSpawn, i want to use that HashMap. How can i do that without using public static in the HashMap?
     
  2. Offline

    timtower Administrator Administrator Moderator

    @idkG0D Put the map in the main class.
     
  3. Offline

    MrGriefer_

    Create your HashMap as a variable and provide a method to access it in your class, like:
    PHP:
    CancelSpawn cancelSpawn = new CancelSpawn();
    cancelSpawn.getCooldown();
     
    idkG0D likes this.
Thread Status:
Not open for further replies.

Share This Page