mirror of
https://github.com/correl/mage.git
synced 2024-11-28 19:19:55 +00:00
* Server: added /pings chat command to show players and watchers ping info;
This commit is contained in:
parent
17cf3cd129
commit
2079065af3
3 changed files with 48 additions and 3 deletions
|
@ -433,7 +433,8 @@ public class CallbackClientImpl implements CallbackClient {
|
|||
.append(KeyEvent.getKeyText(PreferencesDialog.getCurrentControlKey(PreferencesDialog.KEY_CONTROL_TOGGLE_MACRO)))
|
||||
.append("</b> - Toggle recording a sequence of actions to repeat. Will not pause if interrupted and can fail if a selected card changes such as when scrying top card to bottom.")
|
||||
.append("<br/><b>").append(System.getProperty("os.name").contains("Mac OS X") ? "Cmd" : "Ctrl").append(" + click</b> - Hold priority while casting a spell or activating an ability")
|
||||
.append("<br/>").append("Type <b>/FIX</b> message in chat to fix freezed game")
|
||||
.append("<br/>").append("Type <b>/fix</b> message in chat to fix freezed game")
|
||||
.append("<br/>").append("Type <b>/pings</b> message in chat to show players and watchers ping")
|
||||
.toString(),
|
||||
null, MessageType.USER_INFO, ChatMessage.MessageColor.BLUE);
|
||||
break;
|
||||
|
|
|
@ -201,7 +201,7 @@ public enum ChatManager {
|
|||
return true;
|
||||
}
|
||||
if (command.startsWith("GAME")) {
|
||||
message += "<br/>" + GameManager.instance.getChatId(chatId);
|
||||
message += "<br/>";
|
||||
ChatSession session = chatSessions.get(chatId);
|
||||
if (session != null && session.getInfo() != null) {
|
||||
String gameId = session.getInfo();
|
||||
|
@ -222,7 +222,7 @@ public enum ChatManager {
|
|||
return true;
|
||||
}
|
||||
if (command.startsWith("FIX")) {
|
||||
message += "<br/>" + GameManager.instance.getChatId(chatId);
|
||||
message += "<br/>";
|
||||
ChatSession session = chatSessions.get(chatId);
|
||||
if (session != null && session.getInfo() != null) {
|
||||
String gameId = session.getInfo();
|
||||
|
@ -242,6 +242,27 @@ public enum ChatManager {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
if (command.equals("PINGS")) {
|
||||
message += "<br/>";
|
||||
ChatSession session = chatSessions.get(chatId);
|
||||
if (session != null && session.getInfo() != null) {
|
||||
String gameId = session.getInfo();
|
||||
if (gameId.startsWith("Game ")) {
|
||||
UUID id = java.util.UUID.fromString(gameId.substring(5));
|
||||
for (Entry<UUID, GameController> entry : GameManager.instance.getGameController().entrySet()) {
|
||||
if (entry.getKey().equals(id)) {
|
||||
GameController controller = entry.getValue();
|
||||
if (controller != null) {
|
||||
message += controller.getPingsInfo();
|
||||
chatSessions.get(chatId).broadcastInfoToUser(user, message);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
return true;
|
||||
}
|
||||
if (command.startsWith("CARD ")) {
|
||||
Matcher matchPattern = getCardTextPattern.matcher(message.toLowerCase(Locale.ENGLISH));
|
||||
if (matchPattern.find()) {
|
||||
|
|
|
@ -1188,6 +1188,29 @@ public class GameController implements GameCallback {
|
|||
return player != null ? player.getName() : "-";
|
||||
}
|
||||
|
||||
public String getPingsInfo() {
|
||||
List<String> usersInfo = new ArrayList<>();
|
||||
for (Map.Entry<UUID, UUID> entry : userPlayerMap.entrySet()) {
|
||||
Optional<User> user = UserManager.instance.getUser(entry.getKey());
|
||||
user.ifPresent(u -> usersInfo.add(u.getName() + ": " + u.getPingInfo()));
|
||||
}
|
||||
Collections.sort(usersInfo);
|
||||
usersInfo.add(0, "Players ping:");
|
||||
|
||||
List<String> watchersinfo = new ArrayList<>();
|
||||
for (Map.Entry<UUID, GameSessionWatcher> entry : watchers.entrySet()) {
|
||||
Optional<User> user = UserManager.instance.getUser(entry.getValue().userId);
|
||||
user.ifPresent(u -> watchersinfo.add(u.getName() + ": " + u.getPingInfo()));
|
||||
}
|
||||
Collections.sort(watchersinfo);
|
||||
if (watchersinfo.size() > 0) {
|
||||
watchersinfo.add(0, "Watchers ping:");
|
||||
}
|
||||
|
||||
usersInfo.addAll(watchersinfo);
|
||||
return String.join("<br>", usersInfo);
|
||||
}
|
||||
|
||||
public String attemptToFixGame() {
|
||||
// try to fix disconnects
|
||||
|
||||
|
|
Loading…
Reference in a new issue