Skip to content

Commit d4dab36

Browse files
committed
Add caffeine library, rename methods in UserManager
1 parent 02e3412 commit d4dab36

File tree

3 files changed

+13
-10
lines changed

3 files changed

+13
-10
lines changed

build.gradle.kts

Lines changed: 6 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -78,6 +78,9 @@ dependencies {
7878
implementation("com.eternalcode:eternalcode-commons-adventure:1.3.0")
7979
implementation("com.eternalcode:eternalcode-commons-bukkit:1.3.0")
8080

81+
// caffeine
82+
implementation("com.github.ben-manes.caffeine:caffeine:3.2.2")
83+
8184
testImplementation("org.junit.jupiter:junit-jupiter-api:5.13.4")
8285
testImplementation("org.junit.jupiter:junit-jupiter-params:5.13.4")
8386
testRuntimeOnly("org.junit.jupiter:junit-jupiter-engine:5.13.4")
@@ -155,14 +158,14 @@ tasks {
155158
"io.sentry",
156159
"dev.rollczi",
157160
"de.eldoria",
158-
"com.eternalcode.commons",
159-
"com.eternalcode.gitcheck",
161+
"com.eternalcode",
160162
"com.fasterxml",
161163
"com.j256",
162164
"com.spotify",
163165
"com.zaxxer",
164166
"de.rapha149",
165-
"dev.triumphteam"
167+
"dev.triumphteam",
168+
"com.github.benmanes.caffeine"
166169
).forEach { relocate(it, "$relocationPrefix.$it") }
167170
}
168171
}

src/main/java/com/eternalcode/parcellockers/parcel/util/ParcelPlaceholderUtil.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -59,7 +59,7 @@ public static List<String> replaceParcelPlaceholders(Parcel parcel, List<String>
5959
}
6060

6161
private static CompletableFuture<String> getName(UUID userUuid, UserManager userManager) {
62-
return userManager.getUser(userUuid).thenApply(userOptional -> userOptional
62+
return userManager.get(userUuid).thenApply(userOptional -> userOptional
6363
.map(user -> user.name())
6464
.orElse("Unknown")
6565
);

src/main/java/com/eternalcode/parcellockers/user/UserManager.java

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -20,24 +20,24 @@ public UserManager(UserRepository userRepository) {
2020
this.userRepository = userRepository;
2121
}
2222

23-
public CompletableFuture<Optional<User>> getUser(UUID uuid) {
24-
User user = this.usersByUUID.get(uuid);
23+
public CompletableFuture<Optional<User>> get(UUID uniqueId) {
24+
User user = this.usersByUUID.get(uniqueId);
2525

2626
if (user != null) {
2727
return CompletableFuture.completedFuture(Optional.of(user));
2828
}
2929

30-
return this.userRepository.find(uuid);
30+
return this.userRepository.find(uniqueId);
3131
}
3232

33-
public CompletableFuture<Optional<User>> getUser(String name) {
34-
User user = this.usersByName.get(name);
33+
public CompletableFuture<Optional<User>> get(String username) {
34+
User user = this.usersByName.get(username);
3535

3636
if (user != null) {
3737
return CompletableFuture.completedFuture(Optional.of(user));
3838
}
3939

40-
return this.userRepository.find(name);
40+
return this.userRepository.find(username);
4141
}
4242

4343
public User getOrCreate(UUID uuid, String name) {

0 commit comments

Comments
 (0)