Refactor code for clarity: standardize optional checks, improve list handling, and adjust PhantomPreSpawnEvent import.
This commit is contained in:
@@ -43,21 +43,23 @@ public class BoosterCache {
|
||||
LinkedList<Booster> list = boosters.get(boosterType);
|
||||
Booster oldActive = null;
|
||||
if (list.size() > 1) {
|
||||
oldActive = list.get(0);
|
||||
oldActive = list.getFirst();
|
||||
}
|
||||
list.sort(Booster::compareTo);
|
||||
if (oldActive != null && !list.get(0).getBoosterUUID().equals(oldActive.getBoosterUUID())) {
|
||||
if (oldActive != null && !list.getFirst().getBoosterUUID().equals(oldActive.getBoosterUUID())) {
|
||||
oldActive.updateDuration();
|
||||
}
|
||||
}
|
||||
|
||||
public synchronized Optional<Booster> getActiveBooster(BoosterType boosterType) {
|
||||
if (!boosters.containsKey(boosterType))
|
||||
if (!boosters.containsKey(boosterType)) {
|
||||
return Optional.empty();
|
||||
}
|
||||
LinkedList<Booster> list = boosters.get(boosterType);
|
||||
if (list.isEmpty())
|
||||
if (list.isEmpty()) {
|
||||
return Optional.empty();
|
||||
return Optional.of(list.get(0));
|
||||
}
|
||||
return Optional.of(list.getFirst());
|
||||
}
|
||||
|
||||
public synchronized List<Booster> getAllActiveBoosters() {
|
||||
|
||||
Reference in New Issue
Block a user