Hashmap Get and Set

Discussion in 'Plugin Development' started by SeniorCluckers, Dec 18, 2018.

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

    SeniorCluckers

    Would you say this is right? Keep in mind I know about the use of player object and memory leaks.

    Code:
        private HashMap<Player, Player> invite = new HashMap<>();
    
        public HashMap<Player, Player> getInvite() {
            return invite;
        }
       
        public void addInvite(Player inviter, Player invited) {
            invite.put(inviter, target);
        }
     
  2. Online

    timtower Administrator Administrator Moderator

  3. On top of what timtower said, you may also want to check if there's already an invite for a specific player by doing "if (!invite.containsKey(inviter)) { code here }
     
Thread Status:
Not open for further replies.

Share This Page