mirror of
https://github.com/magefree/mage.git
synced 2026-01-26 21:29:17 -08:00
rewrites to optionals
This commit is contained in:
parent
348faa345b
commit
ff6c6405aa
28 changed files with 760 additions and 494 deletions
|
|
@ -28,6 +28,7 @@
|
|||
package mage.interfaces;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.Set;
|
||||
import java.util.UUID;
|
||||
import mage.MageException;
|
||||
|
|
@ -113,7 +114,7 @@ public interface MageServer {
|
|||
|
||||
boolean isTableOwner(String sessionId, UUID roomId, UUID tableId) throws MageException;
|
||||
|
||||
TableView getTable(UUID roomId, UUID tableId) throws MageException;
|
||||
Optional<TableView> getTable(UUID roomId, UUID tableId) throws MageException;
|
||||
|
||||
List<TableView> getTables(UUID roomId) throws MageException;
|
||||
|
||||
|
|
@ -124,13 +125,13 @@ public interface MageServer {
|
|||
|
||||
void leaveChat(UUID chatId, String sessionId) throws MageException;
|
||||
|
||||
UUID getTableChatId(UUID tableId) throws MageException;
|
||||
Optional<UUID> getTableChatId(UUID tableId) throws MageException;
|
||||
|
||||
UUID getGameChatId(UUID gameId) throws MageException;
|
||||
Optional<UUID> getGameChatId(UUID gameId) throws MageException;
|
||||
|
||||
UUID getRoomChatId(UUID roomId) throws MageException;
|
||||
Optional<UUID> getRoomChatId(UUID roomId) throws MageException;
|
||||
|
||||
UUID getTournamentChatId(UUID tournamentId) throws MageException;
|
||||
Optional<UUID> getTournamentChatId(UUID tournamentId) throws MageException;
|
||||
|
||||
//room methods
|
||||
UUID getMainRoomId() throws MageException;
|
||||
|
|
|
|||
|
|
@ -600,7 +600,7 @@ public class SessionImpl implements Session {
|
|||
}
|
||||
|
||||
@Override
|
||||
public UUID getRoomChatId(UUID roomId) {
|
||||
public Optional<UUID> getRoomChatId(UUID roomId) {
|
||||
try {
|
||||
if (isConnected()) {
|
||||
return server.getRoomChatId(roomId);
|
||||
|
|
@ -608,11 +608,11 @@ public class SessionImpl implements Session {
|
|||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return null;
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getTableChatId(UUID tableId) {
|
||||
public Optional<UUID> getTableChatId(UUID tableId) {
|
||||
try {
|
||||
if (isConnected()) {
|
||||
return server.getTableChatId(tableId);
|
||||
|
|
@ -620,11 +620,11 @@ public class SessionImpl implements Session {
|
|||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return null;
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public UUID getGameChatId(UUID gameId) {
|
||||
public Optional<UUID> getGameChatId(UUID gameId) {
|
||||
try {
|
||||
if (isConnected()) {
|
||||
return server.getGameChatId(gameId);
|
||||
|
|
@ -634,11 +634,11 @@ public class SessionImpl implements Session {
|
|||
} catch (Throwable t) {
|
||||
handleThrowable(t);
|
||||
}
|
||||
return null;
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
public TableView getTable(UUID roomId, UUID tableId) {
|
||||
public Optional<TableView> getTable(UUID roomId, UUID tableId) {
|
||||
try {
|
||||
if (isConnected()) {
|
||||
return server.getTable(roomId, tableId);
|
||||
|
|
@ -646,7 +646,7 @@ public class SessionImpl implements Session {
|
|||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return null;
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -735,7 +735,7 @@ public class SessionImpl implements Session {
|
|||
} catch (Throwable t) {
|
||||
handleThrowable(t);
|
||||
}
|
||||
return null;
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -750,7 +750,7 @@ public class SessionImpl implements Session {
|
|||
} catch (Throwable t) {
|
||||
handleThrowable(t);
|
||||
}
|
||||
return null;
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -765,7 +765,7 @@ public class SessionImpl implements Session {
|
|||
} catch (Throwable t) {
|
||||
handleThrowable(t);
|
||||
}
|
||||
return null;
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -784,7 +784,7 @@ public class SessionImpl implements Session {
|
|||
}
|
||||
|
||||
@Override
|
||||
public UUID getTournamentChatId(UUID tournamentId) {
|
||||
public Optional<UUID> getTournamentChatId(UUID tournamentId) {
|
||||
try {
|
||||
if (isConnected()) {
|
||||
return server.getTournamentChatId(tournamentId);
|
||||
|
|
@ -794,7 +794,7 @@ public class SessionImpl implements Session {
|
|||
} catch (Throwable t) {
|
||||
handleThrowable(t);
|
||||
}
|
||||
return null;
|
||||
return Optional.empty();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
@ -1420,7 +1420,7 @@ public class SessionImpl implements Session {
|
|||
} catch (Throwable t) {
|
||||
handleThrowable(t);
|
||||
}
|
||||
return null;
|
||||
return new ArrayList<>();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
|||
|
|
@ -27,6 +27,7 @@
|
|||
*/
|
||||
package mage.remote.interfaces;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
|
@ -34,13 +35,13 @@ import java.util.UUID;
|
|||
*/
|
||||
public interface ChatSession {
|
||||
|
||||
UUID getRoomChatId(UUID roomId);
|
||||
Optional<UUID> getRoomChatId(UUID roomId);
|
||||
|
||||
UUID getTableChatId(UUID tableId);
|
||||
Optional<UUID> getTableChatId(UUID tableId);
|
||||
|
||||
UUID getGameChatId(UUID gameId);
|
||||
Optional<UUID> getGameChatId(UUID gameId);
|
||||
|
||||
UUID getTournamentChatId(UUID tournamentId);
|
||||
Optional<UUID> getTournamentChatId(UUID tournamentId);
|
||||
|
||||
boolean joinChat(UUID chatId);
|
||||
|
||||
|
|
|
|||
|
|
@ -34,6 +34,7 @@ import mage.remote.MageRemoteException;
|
|||
import mage.view.TableView;
|
||||
import mage.view.TournamentView;
|
||||
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
|
|
@ -71,7 +72,7 @@ public interface PlayerActions {
|
|||
|
||||
boolean joinTable(UUID roomId, UUID tableId, String playerName, String playerType, int skill, DeckCardLists deckList, String password);
|
||||
|
||||
TableView getTable(UUID roomId, UUID tableId);
|
||||
Optional<TableView> getTable(UUID roomId, UUID tableId);
|
||||
|
||||
TournamentView getTournament(UUID tournamentId) throws MageRemoteException;
|
||||
|
||||
|
|
|
|||
|
|
@ -29,6 +29,7 @@ package mage.remote.interfaces;
|
|||
|
||||
import java.util.Collection;
|
||||
import java.util.List;
|
||||
import java.util.Optional;
|
||||
import java.util.UUID;
|
||||
import mage.remote.MageRemoteException;
|
||||
import mage.view.MatchView;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue