forked from External/mage
rewrites to optionals
This commit is contained in:
parent
348faa345b
commit
ff6c6405aa
28 changed files with 760 additions and 494 deletions
|
|
@ -30,6 +30,7 @@ package mage.server.draft;
|
|||
|
||||
import java.io.File;
|
||||
import java.util.Map.Entry;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
|
@ -129,11 +130,11 @@ public class DraftController {
|
|||
checkStart();
|
||||
}
|
||||
|
||||
public DraftSession getDraftSession(UUID playerId) {
|
||||
public Optional<DraftSession> getDraftSession(UUID playerId) {
|
||||
if (draftSessions.containsKey(playerId)) {
|
||||
return draftSessions.get(playerId);
|
||||
return Optional.of(draftSessions.get(playerId));
|
||||
}
|
||||
return null;
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
public boolean replacePlayer(Player oldPlayer, Player newPlayer) {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
package mage.server.draft;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import java.util.concurrent.ConcurrentHashMap;
|
||||
|
|
@ -87,12 +88,7 @@ public enum DraftManager {
|
|||
return draftControllers.get(draftId);
|
||||
}
|
||||
|
||||
public DraftController getController(UUID tableId) {
|
||||
for (DraftController controller: draftControllers.values()) {
|
||||
if (controller.getTableId().equals(tableId)) {
|
||||
return controller;
|
||||
}
|
||||
}
|
||||
return null;
|
||||
public Optional<DraftController> getController(UUID tableId) {
|
||||
return draftControllers.values().stream().filter(controller -> controller.getTableId().equals(tableId)).findFirst();
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue