-
-
Notifications
You must be signed in to change notification settings - Fork 131
/
IslandPrivilege.java
69 lines (51 loc) · 1.8 KB
/
IslandPrivilege.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
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
package com.bgsoftware.superiorskyblock.api.island;
import com.google.common.base.Preconditions;
import java.util.Collection;
import java.util.HashMap;
import java.util.Locale;
import java.util.Map;
public final class IslandPrivilege {
private static final Map<String, IslandPrivilege> islandPrivileges = new HashMap<>();
private final String name;
private IslandPrivilege(String name) {
this.name = name.toUpperCase(Locale.ENGLISH);
}
/**
* Get all the island privileges.
*/
public static Collection<IslandPrivilege> values() {
return islandPrivileges.values();
}
/**
* Get an island privilege by it's name.
*
* @param name The name to check.
*/
public static IslandPrivilege getByName(String name) {
Preconditions.checkNotNull(name, "name parameter cannot be null.");
IslandPrivilege islandPrivilege = islandPrivileges.get(name.toUpperCase(Locale.ENGLISH));
Preconditions.checkNotNull(islandPrivilege, "Couldn't find an IslandPrivilege with the name " + name + ".");
return islandPrivilege;
}
/**
* Register a new island privilege.
*
* @param name The name for the island privilege.
*/
public static void register(String name) {
Preconditions.checkNotNull(name, "name parameter cannot be null.");
name = name.toUpperCase(Locale.ENGLISH);
Preconditions.checkState(!islandPrivileges.containsKey(name), "IslandPrivilege with the name " + name + " already exists.");
islandPrivileges.put(name, new IslandPrivilege(name));
}
/**
* Get the name of the island privilege.
*/
public String getName() {
return name;
}
@Override
public String toString() {
return "IslandPrivilege{name=" + name + "}";
}
}