-
-
Notifications
You must be signed in to change notification settings - Fork 131
/
MenuPatternSlots.java
40 lines (30 loc) · 1.02 KB
/
MenuPatternSlots.java
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
package com.bgsoftware.superiorskyblock.core.menu;
import java.util.Collection;
import java.util.Collections;
import java.util.HashMap;
import java.util.LinkedList;
import java.util.List;
import java.util.Map;
public class MenuPatternSlots {
private final Map<Character, List<Integer>> charSlots = new HashMap<>();
public MenuPatternSlots() {
}
public Collection<Character> getChars() {
return this.charSlots.keySet();
}
public void addSlot(char character, int slot) {
this.charSlots.computeIfAbsent(character, ch -> new LinkedList<>()).add(slot);
}
public List<Integer> getSlots(char character) {
List<Integer> slots = this.charSlots.get(character);
return slots == null ? Collections.emptyList() : slots;
}
public List<Integer> getSlots(String str) {
for (char ch : str.toCharArray()) {
List<Integer> slots = getSlots(ch);
if (!slots.isEmpty())
return slots;
}
return Collections.emptyList();
}
}